| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: help.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla.Framework 5 * @subpackage Language 6 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 defined('JPATH_BASE') or die(); 15 /** 16 * Help system class 17 * 18 * @package Joomla.Framework 19 * @subpackage Language 20 * @since 1.5 21 */ 22 class JHelp 23 { 24 25 /** 26 * Create an URL for a giving help file reference 27 * 28 * @param string The name of the popup file (excluding the file extension for an xml file) 29 * @param boolean Use the help file in the component directory 30 */ 31 function createURL($ref, $useComponent = false) 32 { 33 global $mainframe, $option; 34 35 $user =& JFactory::getUser(); 36 $userHelpUrl = $user->getParam( 'helpsite' ); 37 $globalHelpUrl = $mainframe->getCfg('helpurl'); 38 $lang =& JFactory::getLanguage(); 39 40 if ($useComponent) 41 { 42 if (!preg_match( '#\.html$#i', $ref )) { 43 $ref = $ref . '.html'; 44 } 45 46 $url = 'components/' . $option. '/help'; 47 $tag = $lang->getTag(); 48 49 // Check if the file exists within a different language! 50 if( $lang->getTag() != 'en-GB' ) { 51 $localeURL = JPATH_BASE.DS.$url.DS.$tag.DS.$ref; 52 jimport( 'joomla.filesystem.file' ); 53 if( !JFile::exists( $localeURL ) ) { 54 $tag = 'en-GB'; 55 } 56 } 57 return $url.'/'.$tag.'/'.$ref; 58 } 59 60 61 if ( $userHelpUrl ) 62 { 63 // Online help site as defined in GC 64 $version = new JVersion(); 65 $ref .= $version->getHelpVersion(); 66 $url = $userHelpUrl . '/index2.php?option=com_content&task=findkey&tmpl=component&keyref=' . urlencode( $ref ); 67 } 68 else if ( $globalHelpUrl ) 69 { 70 // Online help site as defined in GC 71 $version = new JVersion(); 72 $ref .= $version->getHelpVersion(); 73 $url = $globalHelpUrl . '/index2.php?option=com_content&task=findkey&tmpl=component;1&keyref=' . urlencode( $ref ); 74 } 75 else 76 { 77 // Included html help files 78 $helpURL = 'help/' .$lang->getTag() .'/'; 79 80 if (!preg_match( '#\.html$#i', $ref )) { 81 $ref = $ref . '.html'; 82 } 83 84 // Check if the file exists within a different language! 85 if( $lang->getTag() != 'en-GB' ) { 86 $localeURL = JPATH_BASE . $helpURL .$ref; 87 jimport( 'joomla.filesystem.file' ); 88 if( !JFile::exists( $localeURL ) ) { 89 $helpURL = 'help/en-GB/'; 90 } 91 } 92 $url = $helpURL . $ref; 93 } 94 95 return $url; 96 } 97 98 /** 99 * Builds a list of the help sites which can be used in a select option 100 * 101 * @param string Path to an xml file 102 * @param string Language tag to select (if exists) 103 * @param array An array of arrays ( text, value, selected ) 104 */ 105 function createSiteList($pathToXml, $selected = null) 106 { 107 $list = array (); 108 $xml =& JFactory::getXMLParser('Simple'); 109 $data = null; 110 if( !empty( $pathToXml ) ) { 111 $data = file_get_contents($pathToXml); 112 } 113 114 if(empty($data)) 115 { 116 $option['text'] = 'English (GB) help.joomla.org'; 117 $option['value'] = 'http://help.joomla.org'; 118 $list[] = $option; 119 } 120 else 121 { 122 if($xml->loadString($data)) 123 { 124 // Are there any languages?? 125 $elmSites = & $xml->document->sites[0]; 126 127 if (is_object($elmSites)) { 128 129 $option = array (); 130 $sites = $elmSites->children(); 131 foreach ($sites as $site) 132 { 133 $text = $site->data(); 134 $url = $site->attributes('url'); 135 $option['text'] = $text; 136 $option['value'] = $url; 137 $list[] = $option; 138 } 139 } 140 } 141 } 142 143 return $list; 144 } 145 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |