Source for file view.html.php

Documentation is available at view.html.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Site
  4.  * @subpackage  com_users
  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.  * Profile view class for Users.
  14.  *
  15.  * @package     Joomla.Site
  16.  * @subpackage  com_users
  17.  * @since       1.6
  18.  */
  19. class UsersViewProfile extends JViewLegacy
  20. {
  21.     protected $data;
  22.  
  23.     protected $form;
  24.  
  25.     protected $params;
  26.  
  27.     protected $state;
  28.  
  29.     /**
  30.      * Execute and display a template script.
  31.      *
  32.      * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  33.      *
  34.      * @return  mixed  A string if successful, otherwise a Error object.
  35.      *
  36.      * @since   1.6
  37.      */
  38.     public function display($tpl null)
  39.     {
  40.         // Get the view data.
  41.         $this->data                = $this->get('Data');
  42.         $this->form                = $this->get('Form');
  43.         $this->state            = $this->get('State');
  44.         $this->params           = $this->state->get('params');
  45.         $this->twofactorform    $this->get('Twofactorform');
  46.         $this->twofactormethods UsersHelper::getTwoFactorMethods();
  47.         $this->otpConfig        $this->get('OtpConfig');
  48.  
  49.         // Check for errors.
  50.         if (count($errors $this->get('Errors')))
  51.         {
  52.             JError::raiseError(500implode('<br />'$errors));
  53.             return false;
  54.         }
  55.  
  56.         // View also takes responsibility for checking if the user logged in with remember me.
  57.         $user JFactory::getUser();
  58.         $cookieLogin $user->get('cookieLogin');
  59.  
  60.         if (!empty($cookieLogin))
  61.         {
  62.             // If so, the user must login to edit the password and other data.
  63.             // What should happen here? Should we force a logout which detroys the cookies?
  64.             $app JFactory::getApplication();
  65.             $app->enqueueMessage(JText::_('JGLOBAL_REMEMBER_MUST_LOGIN')'message');
  66.             $app->redirect(JUri::base('index.php?option=com_users&view=login'''302);
  67.  
  68.             return false;
  69.         }
  70.  
  71.         // Check if a user was found.
  72.         if (!$this->data->id)
  73.         {
  74.             JError::raiseError(404JText::_('JERROR_USERS_PROFILE_NOT_FOUND'));
  75.             return false;
  76.         }
  77.  
  78.         $this->data->tags new JHelperTags;
  79.         $this->data->tags->getItemTags('com_users.user.'$this->data->id);
  80.  
  81.         // Check for layout override
  82.         $active JFactory::getApplication()->getMenu()->getActive();
  83.  
  84.         if (isset($active->query['layout']))
  85.         {
  86.             $this->setLayout($active->query['layout']);
  87.         }
  88.  
  89.         //Escape strings for HTML output
  90.         $this->pageclass_sfx htmlspecialchars($this->params->get('pageclass_sfx'));
  91.  
  92.         $this->prepareDocument();
  93.  
  94.         return parent::display($tpl);
  95.     }
  96.  
  97.     /**
  98.      * Prepares the document
  99.      *
  100.      * @since   1.6
  101.      */
  102.     protected function prepareDocument()
  103.     {
  104.         $app        JFactory::getApplication();
  105.         $menus        $app->getMenu();
  106.         $user        JFactory::getUser();
  107.         $title         null;
  108.  
  109.         // Because the application sets a default page title,
  110.         // we need to get it from the menu item itself
  111.         $menu $menus->getActive();
  112.  
  113.         if ($menu)
  114.         {
  115.             $this->params->def('page_heading'$this->params->get('page_title'$user->name));
  116.         }
  117.         else
  118.         {
  119.             $this->params->def('page_heading'JText::_('COM_USERS_PROFILE'));
  120.         }
  121.  
  122.         $title $this->params->get('page_title''');
  123.  
  124.         if (empty($title))
  125.         {
  126.             $title $app->getCfg('sitename');
  127.         }
  128.         elseif ($app->getCfg('sitename_pagetitles'0== 1)
  129.         {
  130.             $title JText::sprintf('JPAGETITLE'$app->getCfg('sitename')$title);
  131.         }
  132.         elseif ($app->getCfg('sitename_pagetitles'0== 2)
  133.         {
  134.             $title JText::sprintf('JPAGETITLE'$title$app->getCfg('sitename'));
  135.         }
  136.  
  137.         $this->document->setTitle($title);
  138.  
  139.         if ($this->params->get('menu-meta_description'))
  140.         {
  141.             $this->document->setDescription($this->params->get('menu-meta_description'));
  142.         }
  143.  
  144.         if ($this->params->get('menu-meta_keywords'))
  145.         {
  146.             $this->document->setMetadata('keywords'$this->params->get('menu-meta_keywords'));
  147.         }
  148.  
  149.         if ($this->params->get('robots'))
  150.         {
  151.             $this->document->setMetadata('robots'$this->params->get('robots'));
  152.         }
  153.     }
  154. }

Documentation generated on Tue, 19 Nov 2013 15:17:22 +0100 by phpDocumentor 1.4.3