PageRenderTime 23ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/administrator/components/com_admin/admin.admin.html.php

https://github.com/Shigaru/shigaru
PHP | 337 lines | 264 code | 34 blank | 39 comment | 27 complexity | b59708110d62d6f0186fac2e0d83ea69 MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: admin.admin.html.php 18162 2010-07-16 07:00:47Z ian $
  4. * @package Joomla
  5. * @subpackage Admin
  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. // no direct access
  15. defined( '_JEXEC' ) or die( 'Restricted access' );
  16. /**
  17. * @package Joomla
  18. * @subpackage Admin
  19. */
  20. class HTML_admin_misc
  21. {
  22. function get_php_setting($val)
  23. {
  24. $r = (ini_get($val) == '1' ? 1 : 0);
  25. return $r ? JText::_( 'ON' ) : JText::_( 'OFF' ) ;
  26. }
  27. function get_server_software()
  28. {
  29. if (isset($_SERVER['SERVER_SOFTWARE'])) {
  30. return $_SERVER['SERVER_SOFTWARE'];
  31. } else if (($sf = getenv('SERVER_SOFTWARE'))) {
  32. return $sf;
  33. } else {
  34. return JText::_( 'n/a' );
  35. }
  36. }
  37. function system_info( )
  38. {
  39. global $mainframe;
  40. //Load switcher behavior
  41. JHTML::_('behavior.switcher');
  42. $db =& JFactory::getDBO();
  43. $contents = '';
  44. ob_start();
  45. require_once(JPATH_COMPONENT.DS.'tmpl'.DS.'navigation.php');
  46. $contents = ob_get_contents();
  47. ob_clean();
  48. $document =& JFactory::getDocument();
  49. $document->setBuffer($contents, 'modules', 'submenu');
  50. ?>
  51. <form action="index.php" method="post" name="adminForm">
  52. <div id="config-document">
  53. <div id="page-site">
  54. <table class="noshow">
  55. <tr>
  56. <td>
  57. <?php require_once(JPATH_COMPONENT.DS.'tmpl'.DS.'sysinfo_system.php'); ?>
  58. </td>
  59. </tr>
  60. </table>
  61. </div>
  62. <div id="page-phpsettings">
  63. <table class="noshow">
  64. <tr>
  65. <td>
  66. <?php require_once(JPATH_COMPONENT.DS.'tmpl'.DS.'sysinfo_phpsettings.php'); ?>
  67. </td>
  68. </tr>
  69. </table>
  70. </div>
  71. <div id="page-config">
  72. <table class="noshow">
  73. <tr>
  74. <td>
  75. <?php require_once(JPATH_COMPONENT.DS.'tmpl'.DS.'sysinfo_config.php'); ?>
  76. </td>
  77. </tr>
  78. </table>
  79. </div>
  80. <div id="page-directory">
  81. <table class="noshow">
  82. <tr>
  83. <td>
  84. <?php require_once(JPATH_COMPONENT.DS.'tmpl'.DS.'sysinfo_directory.php'); ?>
  85. </td>
  86. </tr>
  87. </table>
  88. </div>
  89. <div id="page-phpinfo">
  90. <table class="noshow">
  91. <tr>
  92. <td>
  93. <?php require_once(JPATH_COMPONENT.DS.'tmpl'.DS.'sysinfo_phpinfo.php'); ?>
  94. </td>
  95. </tr>
  96. </table>
  97. </div>
  98. </div>
  99. <div class="clr"></div>
  100. <?php
  101. }
  102. /**
  103. * Display Help Page
  104. *
  105. * For this method the important two scenarios are local or remote help files.
  106. * In the case of local help files the language tag will be added in order to
  107. * allow different languages of help.<br />
  108. * In case of the remote server it is assumed that this server provide one specific
  109. * help set of files in one particular language.
  110. */
  111. function help()
  112. {
  113. global $mainframe;
  114. jimport( 'joomla.filesystem.folder' );
  115. jimport( 'joomla.language.help' );
  116. // Get Help URL - an empty helpurl is interpreted as local help files!
  117. $helpurl = $mainframe->getCfg('helpurl');
  118. if ( $helpurl == 'http://help.mamboserver.com' ) {
  119. $helpurl = 'http://help.joomla.org';
  120. }
  121. $fullhelpurl = $helpurl . '/index2.php?option=com_content&amp;task=findkey&amp;pop=1&amp;keyref=';
  122. $helpsearch = JRequest::getString('helpsearch');
  123. $helpsearch = str_replace(array('=', '<', '"'), '', $helpsearch);
  124. $page = JRequest::getCmd('page', 'joomla.whatsnew15.html');
  125. $toc = getHelpToc( $helpsearch );
  126. $lang =& JFactory::getLanguage();
  127. $langTag = $lang->getTag();
  128. if( !JFolder::exists( JPATH_BASE.DS.'help'.DS.$langTag ) ) {
  129. $langTag = 'en-GB'; // use english as fallback
  130. }
  131. if (!preg_match( '#\.html$#i', $page )) {
  132. $page .= '.xml';
  133. }
  134. ?>
  135. <form action="index.php?option=com_admin&amp;task=help" method="post" name="adminForm">
  136. <table class="adminform" border="1">
  137. <tr>
  138. <td colspan="2">
  139. <table width="100%">
  140. <tr>
  141. <td>
  142. <strong><?php echo JText::_( 'Search' ); ?>:</strong>
  143. <input class="text_area" type="hidden" name="option" value="com_admin" />
  144. <input type="text" name="helpsearch" value="<?php echo htmlspecialchars($helpsearch);?>" class="inputbox" />
  145. <input type="submit" value="<?php echo JText::_( 'Go' ); ?>" class="button" />
  146. <input type="button" value="<?php echo JText::_( 'Clear Results' ); ?>" class="button" onclick="f=document.adminForm;f.helpsearch.value='';f.submit()" />
  147. </td>
  148. <td class="helpMenu">
  149. <?php
  150. if ($helpurl) {
  151. ?>
  152. <?php echo JHTML::_('link', JHelp::createUrl( 'joomla.glossary' ), JText::_( 'Glossary' ), array('target' => 'helpFrame')) ?>
  153. |
  154. <?php echo JHTML::_('link', JHelp::createUrl( 'joomla.credits' ), JText::_( 'Credits' ), array('target' => 'helpFrame')) ?>
  155. |
  156. <?php echo JHTML::_('link', JHelp::createUrl( 'joomla.support' ), JText::_( 'Support' ), array('target' => 'helpFrame')) ?>
  157. <?php
  158. } else {
  159. ?>
  160. <?php echo JHTML::_('link', 'http://docs.joomla.org/index.php?title=Glossary&printable=true', JText::_( 'Glossary' ), array('target' => 'helpFrame')) ?> |
  161. <?php echo JHTML::_('link', 'http://docs.joomla.org/index.php?title=Joomla.credits.15&printable=true', JText::_( 'Credits' ), array('target' => 'helpFrame')) ?> |
  162. <?php echo JHTML::_('link', 'http://docs.joomla.org/index.php?title=Joomla.support.15&printable=true', JText::_( 'Support' ), array('target' => 'helpFrame')) ?>
  163. <?php } ?>
  164. |
  165. <?php echo JHTML::_('link', 'http://www.gnu.org/licenses/gpl-2.0.html', JText::_( 'License' ), array('target' => 'helpFrame')) ?>
  166. |
  167. <?php echo JHTML::_('link', 'http://docs.joomla.org', 'docs.joomla.org', array('target' => 'helpFrame')) ?>
  168. |
  169. <?php echo JHTML::_('link', 'index.php?option=com_admin&amp;task=changelog&amp;tmpl=component', JText::_( 'Changelog' ), array('target' => 'helpFrame')) ?>
  170. |
  171. <?php echo JHTML::_('link', 'http://docs.joomla.org/index.php?title=Joomla_1.5_version_history&printable=true', JText::_( 'Latest Version Check' ), array('target' => 'helpFrame')) ?>
  172. </td>
  173. </tr>
  174. </table>
  175. </td>
  176. </tr>
  177. </table>
  178. <div id="treecellhelp">
  179. <fieldset title="<?php echo JText::_( 'Alphabetical Index' ); ?>">
  180. <legend>
  181. <?php echo JText::_( 'Alphabetical Index' ); ?>
  182. </legend>
  183. <div class="helpIndex">
  184. <ul class="subext">
  185. <?php
  186. foreach ($toc as $k=>$v) {
  187. if ($helpurl) {
  188. echo '<li>';
  189. echo JHTML::_('link', JHelp::createUrl( $k ), $v, array('target' => 'helpFrame'));
  190. echo '</li>';
  191. } else {
  192. echo '<li>';
  193. echo JHTML::_('link', JURI::base() .'help/'.$langTag.'/'.$k, $v, array('target' => 'helpFrame'));
  194. echo '</li>';
  195. }
  196. }
  197. ?>
  198. </ul>
  199. </div>
  200. </fieldset>
  201. </div>
  202. <div id="datacellhelp">
  203. <fieldset title="<?php echo JText::_( 'View' ); ?>">
  204. <legend>
  205. <?php echo JText::_( 'View' ); ?>
  206. </legend>
  207. <?php
  208. if ($helpurl && $page != 'joomla.whatsnew15.html') {
  209. ?>
  210. <iframe name="helpFrame" src="<?php echo $fullhelpurl .preg_replace( '#\.xml$|\.html$#', '', $page );?>" class="helpFrame" frameborder="0"></iframe>
  211. <?php
  212. } else {
  213. ?>
  214. <iframe name="helpFrame" src="<?php echo JURI::base() .'help/' .$langTag. '/' . $page;?>" class="helpFrame" frameborder="0"></iframe>
  215. <?php
  216. }
  217. ?>
  218. </fieldset>
  219. </div>
  220. <input type="hidden" name="task" value="help" />
  221. </form>
  222. <?php
  223. }
  224. /*
  225. * Displays contents of Changelog.php file
  226. */
  227. function changelog()
  228. {
  229. ?>
  230. <pre>
  231. <?php
  232. ob_start();
  233. readfile( JPATH_SITE.DS.'CHANGELOG.php' );
  234. $changelog = ob_get_contents();
  235. ob_clean();
  236. // Strip php tag
  237. $changelog = preg_replace('/\<\?php[^\?]*\?\>/','',$changelog);
  238. // Convert all other HTML entities
  239. echo htmlentities($changelog);
  240. ?>
  241. </pre>
  242. <?php
  243. }
  244. }
  245. function writableCell( $folder, $relative=1, $text='', $visible=1 )
  246. {
  247. $writeable = '<b><font color="green">'. JText::_( 'Writable' ) .'</font></b>';
  248. $unwriteable = '<b><font color="red">'. JText::_( 'Unwritable' ) .'</font></b>';
  249. echo '<tr>';
  250. echo '<td class="item">';
  251. echo $text;
  252. if ( $visible ) {
  253. echo $folder . '/';
  254. }
  255. echo '</td>';
  256. echo '<td >';
  257. if ( $relative ) {
  258. echo is_writable( "../$folder" ) ? $writeable : $unwriteable;
  259. } else {
  260. echo is_writable( "$folder" ) ? $writeable : $unwriteable;
  261. }
  262. echo '</td>';
  263. echo '</tr>';
  264. }
  265. /**
  266. * Compiles the help table of contents
  267. * @param string A specific keyword on which to filter the resulting list
  268. */
  269. function getHelpTOC( $helpsearch )
  270. {
  271. global $mainframe;
  272. $lang =& JFactory::getLanguage();
  273. jimport( 'joomla.filesystem.folder' );
  274. $helpurl = $mainframe->getCfg('helpurl');
  275. // Check for files in the actual language
  276. $langTag = $lang->getTag();
  277. if( !JFolder::exists( JPATH_BASE.DS.'help'.DS.$langTag ) ) {
  278. $langTag = 'en-GB'; // use english as fallback
  279. }
  280. $files = JFolder::files( JPATH_BASE.DS.'help'.DS.$langTag, '\.xml$|\.html$' );
  281. $toc = array();
  282. foreach ($files as $file) {
  283. $buffer = file_get_contents( JPATH_BASE.DS.'help'.DS.$langTag.DS.$file );
  284. if (preg_match( '#<title>(.*?)</title>#', $buffer, $m )) {
  285. $title = trim( $m[1] );
  286. if ($title) {
  287. if ($helpurl) {
  288. // strip the extension
  289. $file = preg_replace( '#\.xml$|\.html$#', '', $file );
  290. }
  291. if ($helpsearch) {
  292. if (JString::strpos( strip_tags( $buffer ), $helpsearch ) !== false) {
  293. $toc[$file] = $title;
  294. }
  295. } else {
  296. $toc[$file] = $title;
  297. }
  298. }
  299. }
  300. }
  301. asort( $toc );
  302. return $toc;
  303. }