Source for file view.html.php

Documentation is available at view.html.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Site
  4.  * @subpackage  com_content
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * HTML Article View class for the Content component
  14.  *
  15.  * @package     Joomla.Site
  16.  * @subpackage  com_content
  17.  * @since       1.5
  18.  */
  19. class ContentViewForm extends JViewLegacy
  20. {
  21.     protected $form;
  22.  
  23.     protected $item;
  24.  
  25.     protected $return_page;
  26.  
  27.     protected $state;
  28.  
  29.     public function display($tpl null)
  30.     {
  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.         {
  41.             $authorised $user->authorise('core.create''com_content'|| (count($user->getAuthorisedCategories('com_content''core.create')));
  42.         }
  43.         else
  44.         {
  45.             $authorised $this->item->params->get('access-edit');
  46.         }
  47.  
  48.         if ($authorised !== true)
  49.         {
  50.             JError::raiseError(403JText::_('JERROR_ALERTNOAUTHOR'));
  51.             return false;
  52.         }
  53.  
  54.         $this->item->tags new JHelperTags;
  55.         if (!empty($this->item->id))
  56.         {
  57.             $this->item->tags->getItemTags('com_content.article.'$this->item->id);
  58.         }
  59.         if (!empty($this->item&& isset($this->item->id))
  60.         {
  61.             $this->item->images json_decode($this->item->images);
  62.             $this->item->urls json_decode($this->item->urls);
  63.  
  64.             $tmp new stdClass;
  65.             $tmp->images $this->item->images;
  66.             $tmp->urls $this->item->urls;
  67.             $this->form->bind($tmp);
  68.         }
  69.  
  70.         // Check for errors.
  71.         if (count($errors $this->get('Errors')))
  72.         {
  73.             JError::raiseWarning(500implode("\n"$errors));
  74.             return false;
  75.         }
  76.  
  77.         // Create a shortcut to the parameters.
  78.         $params    &$this->state->params;
  79.  
  80.         //Escape strings for HTML output
  81.         $this->pageclass_sfx htmlspecialchars($params->get('pageclass_sfx'));
  82.  
  83.         $this->params $params;
  84.         $this->user   $user;
  85.  
  86.         if ($params->get('enable_category'== 1)
  87.         {
  88.             $this->form->setFieldAttribute('catid''default'$params->get('catid'1));
  89.             $this->form->setFieldAttribute('catid''readonly''true');
  90.         }
  91.         $this->_prepareDocument();
  92.         parent::display($tpl);
  93.     }
  94.  
  95.     /**
  96.      * Prepares the document
  97.      */
  98.     protected function _prepareDocument()
  99.     {
  100.         $app        JFactory::getApplication();
  101.         $menus        $app->getMenu();
  102.         $title         null;
  103.  
  104.         // Because the application sets a default page title,
  105.         // we need to get it from the menu item itself
  106.         $menu $menus->getActive();
  107.         if ($menu)
  108.         {
  109.             $this->params->def('page_heading'$this->params->get('page_title'$menu->title));
  110.         }
  111.         else
  112.         {
  113.             $this->params->def('page_heading'JText::_('COM_CONTENT_FORM_EDIT_ARTICLE'));
  114.         }
  115.  
  116.         $title $this->params->def('page_title'JText::_('COM_CONTENT_FORM_EDIT_ARTICLE'));
  117.         if ($app->getCfg('sitename_pagetitles'0== 1)
  118.         {
  119.             $title JText::sprintf('JPAGETITLE'$app->getCfg('sitename')$title);
  120.         }
  121.         elseif ($app->getCfg('sitename_pagetitles'0== 2)
  122.         {
  123.             $title JText::sprintf('JPAGETITLE'$title$app->getCfg('sitename'));
  124.         }
  125.         $this->document->setTitle($title);
  126.  
  127.         $pathway $app->getPathWay();
  128.         $pathway->addItem($title'');
  129.  
  130.         if ($this->params->get('menu-meta_description'))
  131.         {
  132.             $this->document->setDescription($this->params->get('menu-meta_description'));
  133.         }
  134.  
  135.         if ($this->params->get('menu-meta_keywords'))
  136.         {
  137.             $this->document->setMetadata('keywords'$this->params->get('menu-meta_keywords'));
  138.         }
  139.  
  140.         if ($this->params->get('robots'))
  141.         {
  142.             $this->document->setMetadata('robots'$this->params->get('robots'));
  143.         }
  144.     }
  145. }

Documentation generated on Tue, 19 Nov 2013 15:17:02 +0100 by phpDocumentor 1.4.3