Source for file help.php

Documentation is available at help.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_admin
  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.  * Admin Component Help Model
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_admin
  17.  * @since       1.6
  18.  */
  19. class AdminModelHelp extends JModelLegacy
  20. {
  21.     /**
  22.      * The search string
  23.      * @var    string 
  24.      *
  25.      * @since  1.6
  26.      */
  27.     protected $help_search = null;
  28.  
  29.     /**
  30.      * The page to be viewed
  31.      * @var    string 
  32.      *
  33.      * @since  1.6
  34.      */
  35.     protected $page = null;
  36.  
  37.     /**
  38.      * The iso language tag
  39.      * @var    string 
  40.      *
  41.      * @since  1.6
  42.      */
  43.     protected $lang_tag = null;
  44.  
  45.     /**
  46.      * Table of contents
  47.      *
  48.      * @var    array 
  49.      * @since  1.6
  50.      */
  51.     protected $toc = null;
  52.  
  53.     /**
  54.      * URL for the latest version check
  55.      *
  56.      * @var    string 
  57.      * @since  1.6
  58.      */
  59.     protected $latest_version_check = null;
  60.  
  61.     /**
  62.      * Method to get the help search string
  63.      *
  64.      * @return  string  Help search string
  65.      *
  66.      * @since  1.6
  67.      */
  68.     public function &getHelpSearch()
  69.     {
  70.         if (is_null($this->help_search))
  71.         {
  72.             $this->help_search = JFactory::getApplication()->input->getString('helpsearch');
  73.         }
  74.  
  75.         return $this->help_search;
  76.     }
  77.  
  78.     /**
  79.      * Method to get the page
  80.      *
  81.      * @return  string  The page
  82.      *
  83.      * @since  1.6
  84.      */
  85.     public function &getPage()
  86.     {
  87.         if (is_null($this->page))
  88.         {
  89.             $page JFactory::getApplication()->input->get('page''JHELP_START_HERE');
  90.             $this->page = JHelp::createUrl($page);
  91.         }
  92.  
  93.         return $this->page;
  94.     }
  95.  
  96.     /**
  97.      * Method to get the lang tag
  98.      *
  99.      * @return  string  lang iso tag
  100.      *
  101.      * @since  1.6
  102.      */
  103.     public function getLangTag()
  104.     {
  105.         if (is_null($this->lang_tag))
  106.         {
  107.             $lang JFactory::getLanguage();
  108.             $this->lang_tag = $lang->getTag();
  109.  
  110.             if (!is_dir(JPATH_BASE '/help/' $this->lang_tag))
  111.             {
  112.                 // Use english as fallback
  113.                 $this->lang_tag = 'en-GB';
  114.             }
  115.         }
  116.  
  117.         return $this->lang_tag;
  118.     }
  119.  
  120.     /**
  121.      * Method to get the toc
  122.      *
  123.      * @return  array  Table of contents
  124.      */
  125.     public function &getToc()
  126.     {
  127.         if (is_null($this->toc))
  128.         {
  129.             // Get vars
  130.             $lang_tag $this->getLangTag();
  131.             $help_search $this->getHelpSearch();
  132.  
  133.             // Get Help files
  134.             jimport('joomla.filesystem.folder');
  135.             $files JFolder::files(JPATH_BASE '/help/' $lang_tag'\.xml$|\.html$');
  136.             $this->toc = array();
  137.  
  138.             foreach ($files as $file)
  139.             {
  140.                 $buffer file_get_contents(JPATH_BASE '/help/' $lang_tag '/' $file);
  141.  
  142.                 if (preg_match('#<title>(.*?)</title>#'$buffer$m))
  143.                 {
  144.                     $title trim($m[1]);
  145.  
  146.                     if ($title)
  147.                     {
  148.                         // Translate the page title
  149.                         $title JText::_($title);
  150.  
  151.                         // Strip the extension
  152.                         $file preg_replace('#\.xml$|\.html$#'''$file);
  153.  
  154.                         if ($help_search)
  155.                         {
  156.                             if (JString::strpos(JString::strtolower(strip_tags($buffer))JString::strtolower($help_search)) !== false)
  157.                             {
  158.                                 // Add an item in the Table of Contents
  159.                                 $this->toc[$file$title;
  160.                             }
  161.                         }
  162.                         else
  163.                         {
  164.                             // Add an item in the Table of Contents
  165.                             $this->toc[$file$title;
  166.                         }
  167.                     }
  168.                 }
  169.             }
  170.             // Sort the Table of Contents
  171.             asort($this->toc);
  172.         }
  173.  
  174.         return $this->toc;
  175.     }
  176.  
  177.     /**
  178.      * Method to get the latest version check
  179.      *
  180.      * @return  string  Latest Version Check URL
  181.      */
  182.     public function &getLatestVersionCheck()
  183.     {
  184.         if (!$this->latest_version_check)
  185.         {
  186.             $override 'http://help.joomla.org/proxy/index.php?option=com_help&keyref=Help{major}{minor}:Joomla_Version_{major}_{minor}_{maintenance}';
  187.             $this->latest_version_check = JHelp::createUrl('JVERSION'false$override);
  188.         }
  189.  
  190.         return $this->latest_version_check;
  191.     }
  192. }

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