Source for file view.html.php

Documentation is available at view.html.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  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.  * View to edit an article.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_content
  17.  * @since       1.6
  18.  */
  19. {
  20.     protected $form;
  21.  
  22.     protected $item;
  23.  
  24.     protected $state;
  25.  
  26.     /**
  27.      * Display the view
  28.      */
  29.     public function display($tpl null)
  30.     {
  31.         if ($this->getLayout(== 'pagebreak')
  32.         {
  33.             // TODO: This is really dogy - should change this one day.
  34.             $eName    JRequest::getVar('e_name');
  35.             $eName    preg_replace('#[^A-Z0-9\-\_\[\]]#i'''$eName);
  36.             $document JFactory::getDocument();
  37.             $document->setTitle(JText::_('COM_CONTENT_PAGEBREAK_DOC_TITLE'));
  38.             $this->eName &$eName;
  39.             parent::display($tpl);
  40.             return;
  41.         }
  42.  
  43.         $this->form        = $this->get('Form');
  44.         $this->item        = $this->get('Item');
  45.         $this->state    = $this->get('State');
  46.         $this->canDo    JHelperContent::getActions($this->state->get('filter.category_id')0'com_content');
  47.  
  48.         // Check for errors.
  49.         if (count($errors $this->get('Errors')))
  50.         {
  51.             JError::raiseError(500implode("\n"$errors));
  52.             return false;
  53.         }
  54.  
  55.         if ($this->getLayout(== 'modal')
  56.         {
  57.             $this->form->setFieldAttribute('language''readonly''true');
  58.             $this->form->setFieldAttribute('catid''readonly''true');
  59.         }
  60.  
  61.         $this->addToolbar();
  62.         parent::display($tpl);
  63.     }
  64.  
  65.     /**
  66.      * Add the page title and toolbar.
  67.      *
  68.      * @since   1.6
  69.      */
  70.     protected function addToolbar()
  71.     {
  72.         JFactory::getApplication()->input->set('hidemainmenu'true);
  73.         $user        JFactory::getUser();
  74.         $userId        $user->get('id');
  75.         $isNew        ($this->item->id == 0);
  76.         $checkedOut    !($this->item->checked_out == || $this->item->checked_out == $userId);
  77.  
  78.         // Built the actions for new and existing records.
  79.         $canDo        $this->canDo;
  80.             JToolbarHelper::title(JText::_('COM_CONTENT_PAGE_' ($checkedOut 'VIEW_ARTICLE' ($isNew 'ADD_ARTICLE' 'EDIT_ARTICLE')))'pencil-2 article-add');
  81.  
  82.         // For new records, check the create permission.
  83.         if ($isNew && (count($user->getAuthorisedCategories('com_content''core.create')) 0))
  84.         {
  85.             JToolbarHelper::apply('article.apply');
  86.             JToolbarHelper::save('article.save');
  87.             JToolbarHelper::save2new('article.save2new');
  88.             JToolbarHelper::cancel('article.cancel');
  89.         }
  90.         else
  91.         {
  92.             // Can't save the record if it's checked out.
  93.             if (!$checkedOut)
  94.             {
  95.                 // Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
  96.                 if ($canDo->get('core.edit'|| ($canDo->get('core.edit.own'&& $this->item->created_by == $userId))
  97.                 {
  98.                     JToolbarHelper::apply('article.apply');
  99.                     JToolbarHelper::save('article.save');
  100.  
  101.                     // We can save this record, but check the create permission to see if we can return to make a new one.
  102.                     if ($canDo->get('core.create'))
  103.                     {
  104.                         JToolbarHelper::save2new('article.save2new');
  105.                     }
  106.                 }
  107.             }
  108.  
  109.             // If checked out, we can still save
  110.             if ($canDo->get('core.create'))
  111.             {
  112.                 JToolbarHelper::save2copy('article.save2copy');
  113.             }
  114.  
  115.             if ($this->state->params->get('save_history'0&& $user->authorise('core.edit'))
  116.             {
  117.                 JToolbarHelper::versions('com_content.article'$this->item->id);
  118.             }
  119.  
  120.             JToolbarHelper::cancel('article.cancel''JTOOLBAR_CLOSE');
  121.         }
  122.  
  123.         JToolbarHelper::divider();
  124.         JToolbarHelper::help('JHELP_CONTENT_ARTICLE_MANAGER_EDIT');
  125.     }
  126. }

Documentation generated on Tue, 19 Nov 2013 15:16:52 +0100 by phpDocumentor 1.4.3