Guest User

Untitled

a guest
Apr 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. <?php
  2. /**
  3. * @version $Id: view.html.php 22032 2011-09-04 08:57:16Z chdemko $
  4. * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
  5. * @license GNU General Public License version 2 or later; see LICENSE.txt
  6. */
  7.  
  8. // No direct access
  9. defined('_JEXEC') or die;
  10.  
  11. jimport('joomla.application.component.view');
  12.  
  13. /**
  14. * HTML Article View class for the Content component
  15. *
  16. * @package Joomla.Site
  17. * @subpackage com_content
  18. * @since 1.5
  19. */
  20. class ContentViewForm extends JView
  21. {
  22. protected $form;
  23. protected $item;
  24. protected $return_page;
  25. protected $state;
  26.  
  27. public function display($tpl = null)
  28. {
  29. // Initialise variables.
  30. $app = JFactory::getApplication();
  31. $user = JFactory::getUser();
  32.  
  33. // Get model data.
  34. $this->state = $this->get('State');
  35. $this->item = $this->get('Item');
  36. $this->form = $this->get('Form');
  37. $this->return_page = $this->get('ReturnPage');
  38.  
  39. if (empty($this->item->id)) {
  40. $authorised = $user->authorise('core.create', 'com_content') || (count($user->getAuthorisedCategories('com_content', 'core.create')));
  41. }
  42. else {
  43. $authorised = $this->item->params->get('access-edit');
  44. }
  45.  
  46. if ($authorised !== true) {
  47. JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
  48. return false;
  49. }
  50.  
  51. if (!empty($this->item)) {
  52. $this->item->images = json_decode($this->item->images);
  53. $this->item->urls = json_decode($this->item->urls);
  54.  
  55. $this->form->bind($this->item);
  56. $this->form->bind($this->item->urls);
  57. $this->form->bind($this->item->images);
  58.  
  59. }
  60.  
  61. // Check for errors.
  62. if (count($errors = $this->get('Errors'))) {
  63. JError::raiseWarning(500, implode("\n", $errors));
  64. return false;
  65. }
  66.  
  67. // Create a shortcut to the parameters.
  68. $params = &$this->state->params;
  69.  
  70. //Escape strings for HTML output
  71. $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
  72.  
  73. $this->params = $params;
  74. $this->user = $user;
  75.  
  76. if ($this->params->get('enable_category') == 1) {
  77. $catid = JRequest::getInt('catid');
  78. $category = JCategories::getInstance('Content')->get($this->params->get('catid', 1));
  79. $this->category_title = $category->title;
  80. }
  81.  
  82. $this->_prepareDocument();
  83. parent::display($tpl);
  84. }
  85.  
  86. /**
  87. * Prepares the document
  88. */
  89. protected function _prepareDocument()
  90. {
  91. $app = JFactory::getApplication();
  92. $menus = $app->getMenu();
  93. $pathway = $app->getPathway();
  94. $title = null;
  95.  
  96. // Because the application sets a default page title,
  97. // we need to get it from the menu item itself
  98. $menu = $menus->getActive();
  99. if ($menu)
  100. {
  101. $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
  102. } else {
  103. $this->params->def('page_heading', JText::_('COM_CONTENT_FORM_EDIT_ARTICLE'));
  104. }
  105.  
  106. $title = $this->params->def('page_title', JText::_('COM_CONTENT_FORM_EDIT_ARTICLE'));
  107. if ($app->getCfg('sitename_pagetitles', 0) == 1) {
  108. $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
  109. }
  110. elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
  111. $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
  112. }
  113. $this->document->setTitle($title);
  114.  
  115. $pathway = $app->getPathWay();
  116. $pathway->addItem($title, '');
  117.  
  118. if ($this->params->get('menu-meta_description'))
  119. {
  120. $this->document->setDescription($this->params->get('menu-meta_description'));
  121. }
  122.  
  123. if ($this->params->get('menu-meta_keywords'))
  124. {
  125. $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
  126. }
  127.  
  128. if ($this->params->get('robots'))
  129. {
  130. $this->document->setMetadata('robots', $this->params->get('robots'));
  131. }
  132. }
  133. }
Add Comment
Please, Sign In to add comment