Source for file view.html.php

Documentation is available at view.html.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_contact
  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 a contact.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_contact
  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.         // Initialise variables.
  32.         $this->form        = $this->get('Form');
  33.         $this->item        = $this->get('Item');
  34.         $this->state    = $this->get('State');
  35.  
  36.         // Check for errors.
  37.         if (count($errors $this->get('Errors')))
  38.         {
  39.             JError::raiseError(500implode("\n"$errors));
  40.             return false;
  41.         }
  42.  
  43.         if ($this->getLayout(== 'modal')
  44.         {
  45.             $this->form->setFieldAttribute('language''readonly''true');
  46.             $this->form->setFieldAttribute('catid''readonly''true');
  47.         }
  48.  
  49.         $this->addToolbar();
  50.         parent::display($tpl);
  51.     }
  52.  
  53.     /**
  54.      * Add the page title and toolbar.
  55.      *
  56.      * @since   1.6
  57.      */
  58.     protected function addToolbar()
  59.     {
  60.         JFactory::getApplication()->input->set('hidemainmenu'true);
  61.  
  62.         $user        JFactory::getUser();
  63.         $userId        $user->get('id');
  64.         $isNew        ($this->item->id == 0);
  65.         $checkedOut    !($this->item->checked_out == || $this->item->checked_out == $userId);
  66.         // Since we don't track these assets at the item level, use the category id.
  67.         $canDo        JHelperContent::getActions($this->item->catid0'com_contact');
  68.  
  69.         JToolbarHelper::title(JText::_('COM_CONTACT_MANAGER_CONTACT')'address contact');
  70.  
  71.         // Build the actions for new and existing records.
  72.         if ($isNew)
  73.         {
  74.             // For new records, check the create permission.
  75.             if ($isNew && (count($user->getAuthorisedCategories('com_contact''core.create')) 0))
  76.             {
  77.                 JToolbarHelper::apply('contact.apply');
  78.                 JToolbarHelper::save('contact.save');
  79.                 JToolbarHelper::save2new('contact.save2new');
  80.             }
  81.  
  82.             JToolbarHelper::cancel('contact.cancel');
  83.         }
  84.         else
  85.         {
  86.             // Can't save the record if it's checked out.
  87.             if (!$checkedOut)
  88.             {
  89.                 // Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
  90.                 if ($canDo->get('core.edit'|| ($canDo->get('core.edit.own'&& $this->item->created_by == $userId))
  91.                 {
  92.                     JToolbarHelper::apply('contact.apply');
  93.                     JToolbarHelper::save('contact.save');
  94.  
  95.                     // We can save this record, but check the create permission to see if we can return to make a new one.
  96.                     if ($canDo->get('core.create'))
  97.                     {
  98.                         JToolbarHelper::save2new('contact.save2new');
  99.                     }
  100.                 }
  101.             }
  102.  
  103.             // If checked out, we can still save
  104.             if ($canDo->get('core.create'))
  105.             {
  106.                 JToolbarHelper::save2copy('contact.save2copy');
  107.             }
  108.  
  109.             if ($this->state->params->get('save_history'0&& $user->authorise('core.edit'))
  110.             {
  111.                 JToolbarHelper::versions('com_contact.contact'$this->item->id);
  112.             }
  113.  
  114.             JToolbarHelper::cancel('contact.cancel''JTOOLBAR_CLOSE');
  115.         }
  116.  
  117.         JToolbarHelper::divider();
  118.         JToolbarHelper::help('JHELP_COMPONENTS_CONTACTS_CONTACTS_EDIT');
  119.     }
  120. }

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