Esempio n. 1
0
 /**
  * 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'));
     }
 }
Esempio n. 2
0
 /**
  * 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'));
     }
 }