[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/administrator/components/com_content/views/article/ -> view.html.php (source)

   1  <?php
   2  /**
   3   * @copyright    Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   4   * @license        GNU General Public License version 2 or later; see LICENSE.txt
   5   */
   6  
   7  // No direct access
   8  defined('_JEXEC') or die;
   9  
  10  jimport('joomla.application.component.view');
  11  
  12  /**
  13   * View to edit an article.
  14   *
  15   * @package        Joomla.Administrator
  16   * @subpackage    com_content
  17   * @since        1.6
  18   */
  19  class ContentViewArticle extends JView
  20  {
  21      protected $form;
  22      protected $item;
  23      protected $state;
  24  
  25      /**
  26       * Display the view
  27       */
  28  	public function display($tpl = null)
  29      {
  30          if ($this->getLayout() == 'pagebreak') {
  31              // TODO: This is really dogy - should change this one day.
  32              $eName        = JRequest::getVar('e_name');
  33              $eName        = preg_replace( '#[^A-Z0-9\-\_\[\]]#i', '', $eName );
  34              $document    = JFactory::getDocument();
  35              $document->setTitle(JText::_('COM_CONTENT_PAGEBREAK_DOC_TITLE'));
  36              $this->assignRef('eName', $eName);
  37              parent::display($tpl);
  38              return;
  39          }
  40  
  41          // Initialiase variables.
  42          $this->form        = $this->get('Form');
  43          $this->item        = $this->get('Item');
  44          $this->state    = $this->get('State');
  45          $this->canDo    = ContentHelper::getActions($this->state->get('filter.category_id'));
  46  
  47          // Check for errors.
  48          if (count($errors = $this->get('Errors'))) {
  49              JError::raiseError(500, implode("\n", $errors));
  50              return false;
  51          }
  52  
  53          $this->addToolbar();
  54          parent::display($tpl);
  55      }
  56  
  57      /**
  58       * Add the page title and toolbar.
  59       *
  60       * @since    1.6
  61       */
  62  	protected function addToolbar()
  63      {
  64          JRequest::setVar('hidemainmenu', true);
  65          $user        = JFactory::getUser();
  66          $userId        = $user->get('id');
  67          $isNew        = ($this->item->id == 0);
  68          $checkedOut    = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);
  69          $canDo        = ContentHelper::getActions($this->state->get('filter.category_id'), $this->item->id);
  70          JToolBarHelper::title(JText::_('COM_CONTENT_PAGE_'.($checkedOut ? 'VIEW_ARTICLE' : ($isNew ? 'ADD_ARTICLE' : 'EDIT_ARTICLE'))), 'article-add.png');
  71  
  72          // Built the actions for new and existing records.
  73  
  74          // For new records, check the create permission.
  75          if ($isNew && (count($user->getAuthorisedCategories('com_content', 'core.create')) > 0)) {
  76              JToolBarHelper::apply('article.apply');
  77              JToolBarHelper::save('article.save');
  78              JToolBarHelper::save2new('article.save2new');
  79              JToolBarHelper::cancel('article.cancel');
  80          }
  81          else {
  82              // Can't save the record if it's checked out.
  83              if (!$checkedOut) {
  84                  // Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
  85                  if ($canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $userId)) {
  86                      JToolBarHelper::apply('article.apply');
  87                      JToolBarHelper::save('article.save');
  88  
  89                      // We can save this record, but check the create permission to see if we can return to make a new one.
  90                      if ($canDo->get('core.create')) {
  91                          JToolBarHelper::save2new('article.save2new');
  92                      }
  93                  }
  94              }
  95  
  96              // If checked out, we can still save
  97              if ($canDo->get('core.create')) {
  98                  JToolBarHelper::save2copy('article.save2copy');
  99              }
 100  
 101              JToolBarHelper::cancel('article.cancel', 'JTOOLBAR_CLOSE');
 102          }
 103  
 104          JToolBarHelper::divider();
 105          JToolBarHelper::help('JHELP_CONTENT_ARTICLE_MANAGER_EDIT');
 106      }
 107  }


Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1