PageRenderTime 34ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/components/com_xmap/views/html/view.html.php

https://bitbucket.org/linoyepost/epg_intranet_innokat
PHP | 146 lines | 86 code | 29 blank | 31 comment | 18 complexity | 1739c7c8a5f1f602a334ffe54bdce59b MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, Apache-2.0, BSD-3-Clause
  1. <?php
  2. /**
  3. * @version $Id$
  4. * @copyright Copyright (C) 2005 - 2009 Joomla! Vargas. All rights reserved.
  5. * @license GNU General Public License version 2 or later; see LICENSE.txt
  6. * @author Guillermo Vargas (guille@vargas.co.cr)
  7. */
  8. // No direct access
  9. defined('_JEXEC') or die;
  10. jimport('joomla.application.component.view');
  11. # For compatibility with older versions of Joola 2.5
  12. if (!class_exists('JViewLegacy')){
  13. class JViewLegacy extends JView {
  14. }
  15. }
  16. /**
  17. * HTML Site map View class for the Xmap component
  18. *
  19. * @package Xmap
  20. * @subpackage com_xmap
  21. * @since 2.0
  22. */
  23. class XmapViewHtml extends JViewLegacy
  24. {
  25. protected $state;
  26. protected $print;
  27. function display($tpl = null)
  28. {
  29. // Initialise variables.
  30. $this->app = JFactory::getApplication();
  31. $this->user = JFactory::getUser();
  32. $doc = JFactory::getDocument();
  33. // Get view related request variables.
  34. $this->print = JRequest::getBool('print');
  35. // Get model data.
  36. $this->state = $this->get('State');
  37. $this->item = $this->get('Item');
  38. $this->items = $this->get('Items');
  39. $this->canEdit = JFactory::getUser()->authorise('core.admin', 'com_xmap');
  40. // Check for errors.
  41. if (count($errors = $this->get('Errors'))) {
  42. JError::raiseWarning(500, implode("\n", $errors));
  43. return false;
  44. }
  45. $this->extensions = $this->get('Extensions');
  46. // Add router helpers.
  47. $this->item->slug = $this->item->alias ? ($this->item->id . ':' . $this->item->alias) : $this->item->id;
  48. $this->item->rlink = JRoute::_('index.php?option=com_xmap&view=html&id=' . $this->item->slug);
  49. // Create a shortcut to the paramemters.
  50. $params = &$this->state->params;
  51. $offset = $this->state->get('page.offset');
  52. if ($params->get('include_css', 0)){
  53. $doc->addStyleSheet(JURI::root().'components/com_xmap/assets/css/xmap.css');
  54. }
  55. // If a guest user, they may be able to log in to view the full article
  56. // TODO: Does this satisfy the show not auth setting?
  57. if (!$this->item->params->get('access-view')) {
  58. if ($user->get('guest')) {
  59. // Redirect to login
  60. $uri = JFactory::getURI();
  61. $app->redirect(
  62. 'index.php?option=com_users&view=login&return=' . base64_encode($uri),
  63. JText::_('Xmap_Error_Login_to_view_sitemap')
  64. );
  65. return;
  66. } else {
  67. JError::raiseWarning(403, JText::_('Xmap_Error_Not_auth'));
  68. return;
  69. }
  70. }
  71. // Override the layout.
  72. if ($layout = $params->get('layout')) {
  73. $this->setLayout($layout);
  74. }
  75. // Load the class used to display the sitemap
  76. $this->loadTemplate('class');
  77. $this->displayer = new XmapHtmlDisplayer($params, $this->item);
  78. $this->displayer->setJView($this);
  79. $this->displayer->canEdit = $this->canEdit;
  80. $this->_prepareDocument();
  81. parent::display($tpl);
  82. $model = $this->getModel();
  83. $model->hit($this->displayer->getCount());
  84. }
  85. /**
  86. * Prepares the document
  87. */
  88. protected function _prepareDocument()
  89. {
  90. $app = JFactory::getApplication();
  91. $pathway = $app->getPathway();
  92. $menus = $app->getMenu();
  93. $title = null;
  94. // Because the application sets a default page title,
  95. // we need to get it from the menu item itself
  96. if ($menu = $menus->getActive()) {
  97. if (isset($menu->query['view']) && isset($menu->query['id'])) {
  98. if ($menu->query['view'] == 'html' && $menu->query['id'] == $this->item->id) {
  99. $menuParams = new JRegistry($menu->params);
  100. $title = $menuParams->get('page_title');
  101. $this->document->setDescription($menuParams->get('menu-meta_description'));
  102. $this->document->setMetadata('keywords', $menuParams->get('menu-meta_keywords'));
  103. }
  104. }
  105. }
  106. if (empty($title)) {
  107. $title = $this->item->title;
  108. }
  109. $this->document->setTitle($title);
  110. if ($app->getCfg('MetaTitle') == '1') {
  111. $this->document->setMetaData('title', $this->item->title);
  112. }
  113. if ($this->print) {
  114. $this->document->setMetaData('robots', 'noindex, nofollow');
  115. }
  116. }
  117. }