/** * Prepares the document */ protected function _prepareDocument() { global $jlistConfig; $app = JFactory::getApplication(); $menus = $app->getMenu(); $pathway = $app->getPathway(); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } else { $this->params->def('page_heading', JText::_('COM_JDOWNLOADS_DOWNLOADS')); } $title = $this->params->get('page_title', ''); if (isset($menu->query['catid'])) { $id = (int) @$menu->query['catid']; } else { $id = 0; } // if the menu item does not concern this download if ($menu && ($menu->query['option'] != 'com_jdownloads' || $menu->query['view'] != 'download' || $id != $this->item->file_id)) { // If this is not a single download menu item, set the page title to the download title if ($this->item->file_title) { $title = $this->item->file_title; } $path = array(array('title' => $this->item->file_title, 'link' => '')); $category = JDCategories::getInstance('Download')->get($this->item->cat_id); while ($category && ($menu->query['option'] != 'com_jdownloads' || $menu->query['view'] == 'download' || $id != $category->id) && $category->id > 1) { $path[] = array('title' => $category->title, 'link' => JdownloadsHelperRoute::getCategoryRoute($category->id, true)); $category = $category->getParent(); } $path = array_reverse($path); foreach ($path as $item) { $pathway->addItem($item['title'], $item['link']); } } // Check for empty title and add site name if param is set if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } if (empty($title)) { $title = $this->item->file_title; } $this->document->setTitle($title); if ($this->item->metadesc) { $this->document->setDescription($this->item->metadesc); } elseif (!$this->item->metadesc && $this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } // use the Downloads description when the metadesc is still empty if (empty($this->item->metadesc)) { $metadescription = strip_tags($this->item->description); if (strlen($metadescription) >= 150) { $metadescshort = substr($metadescription, 0, strpos($metadescription, " ", 150)) . " ..."; } else { $metadescshort = $metadescription; } $this->document->setDescription($metadescshort); } if ($this->item->metakey) { $this->document->setMetadata('keywords', $this->item->metakey); } // use at first settings from download - alternate from jD configuration if ($this->item->robots) { $this->document->setMetadata('robots', $this->item->robots); } elseif ($jlistConfig['robots']) { // use settings from jD-config $this->document->setMetadata('robots', $jlistConfig['robots']); } else { // is not defined in item or jd-config - so we use the global config setting $this->document->setMetadata('robots', $app->getCfg('robots')); } }
/** * Redefine the function an add some properties to make the styling more easy * * @param bool $recursive True if you want to return children recursively. * * @return mixed An array of data items on success, false on failure. */ public function getItems($recursive = false) { if (!count($this->_items)) { $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); $params = new JRegistry(); if ($active) { $params->loadString($active->params); } $options = array(); $options['countItems'] = 1; $option = $this->getState('list.ordering'); if ($option == 'c.ordering') { $options['ordering'] = 'c.lft'; } else { $options['ordering'] = $this->getState('list.ordering'); } $options['direction'] = $this->getState('list.direction'); $categories = JDCategories::getInstance('jdownloads', $options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if (is_object($this->_parent)) { $this->_items = $this->_parent->getChildren($recursive); } else { $this->_items = false; } //+FT li-de témakör láthatóság ellenörzés $user = JFactory::getUser(); $db = JFactory::getDBO(); $item = 0; $i = 0; $lathato = true; while ($i < count($this->_items)) { $lathato = true; $item = $this->_items[$i]; //DBG echo 'ciklus '.$item->cat_dir.'<br>'; if (substr($item->cat_dir, 0, 2) == 'SZ') { $db->setQuery('select sz.id from #__szavatasok sz left outer join #__temakorok t on t.id = sz.temakor_id left outer join #__tagok ta on ta.temakor_id = sz.temakor_id and ta.user_id = "' . $user->id . '" where sz.id = "' . trim(substr($item->cat_dir, 2, 6)) . '" and ((t.lathatosag = 0) or (t.lathatosag = 1 and "' . $user->id . '" > 0) or (t.lathatosag = 2 and ta.user_id is not null) ) '); //DBG echo '<pre>'.$db->getQuery().'</pre>'; $res = $db->loadObject(); if ($res == false) { $lathato = false; } } if (substr($item->cat_dir, 0, 1) == 'T') { $db->setQuery('select t.id from #__temakorok t left outer join #__tagok ta on ta.temakor_id = t.id and ta.user_id = "' . $user->id . '" where t.id = "' . trim(substr($item->cat_dir, 1, 6)) . '" and ((t.lathatosag = 0) or (t.lathatosag = 1 and "' . $user->id . '" > 0) or (t.lathatosag = 2 and ta.user_id is not null) ) '); //DBG echo '<pre>'.$db->getQuery().'</pre>'; $res = $db->loadObject(); if ($res == false) { $lathato = false; } } if ($lathato) { $i++; } else { unset($this->_items[$i]); } } //-FT li-de témakör láthatóság ellenörzés } return $this->_items; }
/** * Method to get category data for the current category * * @param int An optional ID * * @return object * @since 1.5 */ public function getCategory() { global $jlistConfig; $options = ''; if (!is_object($this->_item)) { $categories = JDCategories::getInstance('jdownloads', $options); $this->_item = $categories->get($this->getState('category.id', 'root')); // Compute selected asset permissions. if (is_object($this->_item)) { $user = JFactory::getUser(); $userId = $user->get('id'); $asset = 'com_jdownloads.category.' . $this->_item->id; // Check general create permission. if ($user->authorise('core.create', $asset)) { $this->_item->getParams()->set('access-create', true); } // TODO: Why aren't we lazy loading the children and siblings? $this->_children = $this->_item->getChildren(); $this->_parent = false; if ($this->_item->getParent()) { $this->_parent = $this->_item->getParent(); } $this->_rightsibling = $this->_item->getSibling(); $this->_leftsibling = $this->_item->getSibling(false); } else { $this->_children = false; $this->_parent = false; } if (count($this->_children)) { for ($i = 0; $i < count($this->_children); $i++) { // Get the tags $this->_children[$i]->tags = new JHelperTags(); $this->_children[$i]->tags->getItemTags('com_jdownloads.category', $this->_children[$i]->id); } } } return $this->_item; }
public function __construct($options = array()) { $options['table'] = '#__jdownloads_files'; parent::__construct($options); }
/** * Prepares the document */ protected function _prepareDocument() { global $jlistConfig; $app = JFactory::getApplication(); $menus = $app->getMenu(); $pathway = $app->getPathway(); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } else { $this->params->def('page_heading', JText::_('COM_JDOWNLOADS_DOWNLOADS')); } if (count($this->items) > 1) { $title = JText::_('COM_JDOWNLOADS_FRONTEND_HEADER_SUMMARY_PAGE_TITLE'); } else { $title = $this->params->get('page_title', ''); $title .= ' - ' . JText::_('COM_JDOWNLOADS_FRONTEND_HEADER_SUMMARY_PAGE_TITLE'); } if (isset($menu->query['catid'])) { $id = (int) @$menu->query['catid']; // the Download category has an own menu item } else { $id = 0; // the Download category has not an own menu item } if ($menu) { // we have a single download process - so we can add the link to this download in the breadcrumbs if ($this->items[0]->file_title && count($this->items) == 1) { $title = $this->items[0]->file_title; $title .= ' - ' . JText::_('COM_JDOWNLOADS_FRONTEND_HEADER_SUMMARY_PAGE_TITLE'); } $path = array(array('title' => JText::_('COM_JDOWNLOADS_FRONTEND_HEADER_SUMMARY_PAGE_TITLE'), 'link' => '')); if (count($this->items) == 1) { $path[] = array('title' => $this->items[0]->file_title, 'link' => JdownloadsHelperRoute::getDownloadRoute($this->items[0]->slug, $this->items[0]->cat_id, $this->items[0]->language)); } $category = JDCategories::getInstance('Download')->get($this->items[0]->cat_id); while ($category && ($menu->query['option'] != 'com_jdownloads' || $id == 0 && $id != $category->id) && $category->id != 'root') { $path[] = array('title' => $category->title, 'link' => JdownloadsHelperRoute::getCategoryRoute($category->id, true)); $category = $category->getParent(); } $path = array_reverse($path); foreach ($path as $item) { $pathway->addItem($item['title'], $item['link']); } } // Check for empty title and add site name if param is set if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } if (empty($title)) { $title = JText::_('COM_JDOWNLOADS_FRONTEND_HEADER_SUMMARY_PAGE_TITLE'); } $this->document->setTitle($title); $this->document->setDescription($this->params->get('menu-meta_description')); // use at first settings from download - alternate from jD configuration if ($jlistConfig['robots']) { // use settings from jD-config $this->document->setMetadata('robots', $jlistConfig['robots']); } else { // is not defined in item or jd-config - so we use the global config setting $this->document->setMetadata('robots', $app->getCfg('robots')); } }
/** @param int The route of the category item * boolean true when the url must be complete * string The URL type * int The mirror value (can be 0,1,2) */ public static function getCategoryRoute($catid, $complete_link = false) { if ($catid instanceof JCategoryNode) { $id = $catid->id; $category = $catid; } else { $id = (int) $catid; $category = JDCategories::getInstance('jdownloads')->get($id); } if ($id < 1) { $link = ''; } else { $needles = array('category' => array($id)); if (!$complete_link && ($item = self::_findItem($needles))) { $link = 'index.php?Itemid=' . $item; } else { //Create the link $link = 'index.php?option=com_jdownloads&view=category&catid=' . $id; if ($category) { $catids = array_reverse($category->getPath()); $needles = array('category' => $catids, 'categories' => $catids); if ($item = self::_findItem($needles)) { $link .= '&Itemid=' . $item; } elseif ($item = self::_findItem()) { $link .= '&Itemid=' . $item; } } } } return $link; }
/** * Redefine the function an add some properties to make the styling more easy * * @param bool $recursive True if you want to return children recursively. * * @return mixed An array of data items on success, false on failure. */ public function getItems($recursive = false) { if (!count($this->_items)) { $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); $params = new JRegistry(); if ($active) { $params->loadString($active->params); } $options = array(); $options['countItems'] = 1; $option = $this->getState('list.ordering'); if ($option == 'c.ordering') { $options['ordering'] = 'c.lft'; } else { $options['ordering'] = $this->getState('list.ordering'); } $options['direction'] = $this->getState('list.direction'); $options['category_id'] = $this->getState('filter.category_id'); $options['level'] = $this->getState('filter.level', 0); $categories = JDCategories::getInstance('jdownloads', $options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if (is_object($this->_parent)) { $this->_items = $this->_parent->getChildren($recursive); } else { $this->_items = false; } } return $this->_items; }
/** * Method to create a new category * * @param mixed $name * @param mixed $parent_id * @param mixed $note * @param mixed $description * @param mixed $published * @return JCategoryNode */ public function createCategory($name, $parent_id = 1, $note, $description, $published = 1) { global $jlistConfig; JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jdownloads/tables'); $cat_model = JModelLegacy::getInstance('Category', 'jdownloadsModel'); $data = array('id' => 0, 'parent_id' => $parent_id, 'title' => $name, 'alias' => '', 'notes' => $note, 'description' => $description, 'pic' => $jlistConfig['cat.pic.default.filename'], 'published' => $published, 'access' => '1', 'metadesc' => '', 'metakey' => '', 'created_user_id' => '0', 'language' => '*', 'rules' => array('core.create' => array(), 'core.delete' => array(), 'core.edit' => array(), 'core.edit.state' => array(), 'core.edit.own' => array(), 'download' => array()), 'params' => array()); if (!$cat_model->save($data)) { return NULL; } $options = array(); $categories = JDCategories::getInstance('jdownloads', $options); $subcategory = $categories->get($cat_model->getState("category.id")); return $subcategory; }