Пример #1
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a Error object.
  */
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->item = $this->get('Item');
     $this->print = $app->input->getBool('print');
     $this->secretkey = $app->input->getString('secretkey');
     $this->state = $this->get('State');
     $this->user = $user;
     $this->params = $this->state->get('params');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     // Check the view access to the request print.
     if ($user->get('guest')) {
         if (!empty($this->secretkey) && $this->secretkey == $this->item->secretkey) {
             // User requested diet print by secret key
         } else {
             JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
             return;
         }
     }
     // Convert body field to array.
     $registry = new JRegistry();
     $registry->loadString($this->item->body);
     $this->item->body = $registry->toArray();
     $this->item = (object) array_merge((array) $this->item, $this->item->body);
     $this->item = SibdietHelper::calculate($this->item);
     //Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     $this->_prepareDocument();
     parent::display($tpl);
 }