Source for file view.html.php

Documentation is available at view.html.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Site
  4.  * @subpackage  com_weblinks
  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 Weblinks component
  14.  *
  15.  * @package     Joomla.Site
  16.  * @subpackage  com_weblinks
  17.  * @since       1.5
  18.  */
  19. class WeblinksViewForm 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_weblinks'|| (count($user->getAuthorisedCategories('com_weblinks''core.create'))));
  42.         }
  43.         else
  44.         {
  45.             $authorised $user->authorise('core.edit''com_weblinks.category.'.$this->item->catid);
  46.  
  47.         }
  48.  
  49.         if ($authorised !== true)
  50.         {
  51.             JError::raiseError(403JText::_('JERROR_ALERTNOAUTHOR'));
  52.             return false;
  53.         }
  54.  
  55.         if (!empty($this->item))
  56.         {
  57.             $this->form->bind($this->item);
  58.         }
  59.  
  60.         // Check for errors.
  61.         if (count($errors $this->get('Errors')))
  62.         {
  63.             JError::raiseWarning(500implode("\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.         $this->_prepareDocument();
  77.         parent::display($tpl);
  78.     }
  79.  
  80.     /**
  81.      * Prepares the document
  82.      */
  83.     protected function _prepareDocument()
  84.     {
  85.         $app    JFactory::getApplication();
  86.         $menus    $app->getMenu();
  87.         $title    null;
  88.  
  89.         // Because the application sets a default page title,
  90.         // we need to get it from the menu item itself
  91.         $menu $menus->getActive();
  92.  
  93.         if (empty($this->item->id))
  94.     {
  95.         $head JText::_('COM_WEBLINKS_FORM_SUBMIT_WEBLINK');
  96.         }
  97.         else
  98.         {
  99.         $head JText::_('COM_WEBLINKS_FORM_EDIT_WEBLINK');
  100.         }
  101.  
  102.         if ($menu)
  103.         {
  104.             $this->params->def('page_heading'$this->params->get('page_title'$menu->title));
  105.         }
  106.         else
  107.         {
  108.             $this->params->def('page_heading'$head);
  109.         }
  110.  
  111.         $title $this->params->def('page_title'$head);
  112.         if ($app->getCfg('sitename_pagetitles'0== 1)
  113.         {
  114.             $title JText::sprintf('JPAGETITLE'$app->getCfg('sitename')$title);
  115.         }
  116.         elseif ($app->getCfg('sitename_pagetitles'0== 2)
  117.         {
  118.             $title JText::sprintf('JPAGETITLE'$title$app->getCfg('sitename'));
  119.         }
  120.         $this->document->setTitle($title);
  121.  
  122.         if ($this->params->get('menu-meta_description'))
  123.         {
  124.             $this->document->setDescription($this->params->get('menu-meta_description'));
  125.         }
  126.  
  127.         if ($this->params->get('menu-meta_keywords'))
  128.         {
  129.             $this->document->setMetadata('keywords'$this->params->get('menu-meta_keywords'));
  130.         }
  131.  
  132.             if ($this->params->get('robots'))
  133.         {
  134.             $this->document->setMetadata('robots'$this->params->get('robots'));
  135.         }
  136.     }
  137. }

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