[TASK] Clean up about modules extension
[Packages/TYPO3.CMS.git] / typo3 / sysext / aboutmodules / mod / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * 'About modules' script - the default start-up module.
30 * Will display the list of main- and sub-modules available to the user.
31 * Each module will be show with description and a link to the module.
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 * @package TYPO3
35 * @subpackage aboutmodules
36 */
37 class SC_mod_help_aboutmodules_index {
38
39 /**
40 * Default constructor
41 */
42 public function __construct() {
43 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_alt_intro.xml');
44 }
45
46 /**
47 * Render the module
48 *
49 * @return void
50 */
51 public function render() {
52 $GLOBALS['TBE_TEMPLATE']->divClass = $GLOBALS['TBE_TEMPLATE']->bodyTagId;
53 $GLOBALS['TBE_TEMPLATE']->backPath = $GLOBALS['BACK_PATH'];
54
55 $content = array();
56 $content[] = '<div id="typo3-docheader"><div id="typo3-docheader-row1">&nbsp;</div></div>';
57 $content[] = '<div id="typo3-alt-intro-php-sub">';
58
59 $content[] = '<h1>TYPO3 ' . TYPO3_version . '<br />' . $GLOBALS['LANG']->getLL('introtext') . '</h1>';
60 $content[] = '<p>' . t3lib_BEfunc::TYPO3_copyRightNotice() . '</p>';
61
62 $content[] = t3lib_BEfunc::displayWarningMessages();
63 $content[] = '<h3>' . $GLOBALS['LANG']->getLL('introtext2') . '</h3>';
64
65 /** @var $loadModules t3lib_loadModules */
66 $loadModules = t3lib_div::makeInstance('t3lib_loadModules');
67 $loadModules->observeWorkspaces = TRUE;
68 // Load available backend modules to create the description overview.
69 $loadModules->load($GLOBALS['TBE_MODULES']);
70 $content[] = $this->renderModules($loadModules->modules);
71 $content[] = '<br />';
72
73 // End text: 'Features may vary depending on your website and permissions'
74 $content[] = '<p class="c-features"><em>(' . $GLOBALS['LANG']->getLL('endText') . ')</em></p>';
75
76 $content[] = '<br />';
77 $content[] = '</div>';
78
79 echo $GLOBALS['TBE_TEMPLATE']->render(
80 'About modules',
81 implode(LF, $content),
82 TRUE
83 );
84 }
85
86 /**
87 * Render an overview of modules and its sub modules
88 *
89 * @param array $modules is the output from load_modules class
90 * @return string Module list HTML
91 */
92 protected function renderModules(array $modules) {
93 $moduleHtml = array();
94
95 // Traverse array with modules
96 foreach ($modules as $moduleName => $moduleInfo) {
97 $moduleKey = $moduleName . '_tab';
98
99 // Create image icon
100 $icon = @getimagesize($GLOBALS['LANG']->moduleLabels['tabs_images'][$moduleKey]);
101 $iconHtml = '';
102 if ($icon) {
103 $iconPath = '../' . substr($GLOBALS['LANG']->moduleLabels['tabs_images'][$moduleKey], strlen(PATH_site));
104 $iconHtml = '<img src="' . $iconPath . '" ' . $icon[3] . ' alt="" />';
105 }
106
107 $label = htmlspecialchars($GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey]);
108 // Creating main module link, if there are no sub modules
109 if (!is_array($moduleInfo['sub'])) {
110 $label = '<a href="#" onclick="top.goToModule(\'' . $moduleName . '\');return false;">' . $label . '</a>';
111 }
112 $label = '&nbsp;<strong>' . $label . '</strong>&nbsp;';
113
114 $moduleHtml[] = '<tr class="c-mainitem"><td colspan="3">' . $iconHtml . $label . '</td></tr>';
115
116 // Traverse sub modules
117 $subHtml = array();
118 if (is_array($moduleInfo['sub'])) {
119 $subCount = 0;
120 foreach ($moduleInfo['sub'] as $subName => $subInfo) {
121 $subCount ++;
122 if ($subCount === 1) {
123 $subHtml[] = '
124 <tr class="c-first">
125 <td colspan="3"></td>
126 </tr>
127 ';
128 }
129
130 $subKey = $moduleName . '_' . $subName . '_tab';
131
132 // Create image icon
133 $icon = @getimagesize($GLOBALS['LANG']->moduleLabels['tabs_images'][$subKey]);
134 $iconHtml = '';
135 if ($icon) {
136 $iconPath = '../' . substr($GLOBALS['LANG']->moduleLabels['tabs_images'][$subKey], strlen(PATH_site));
137 $iconHtml = '<img src="' . $iconPath . '" ' . $icon[3] . ' title="' . htmlspecialchars($GLOBALS['LANG']->moduleLabels['labels'][$subKey . 'label']) . '" alt="" />';
138 }
139
140 // Label for sub module
141 $label = $GLOBALS['LANG']->moduleLabels['tabs'][$subKey];
142 $labelDescription = ' title="' . htmlspecialchars($GLOBALS['LANG']->moduleLabels['labels'][$subKey . 'label']) . '"';
143 $onClickString = htmlspecialchars('top.goToModule(\'' . $moduleName . '_' . $subName . '\');return false;');
144 $linkedLabel = '<a href="#" onclick="' . $onClickString . '"' . $labelDescription . '>' . htmlspecialchars($label) . '</a>';
145
146 $moduleLabel = htmlspecialchars($GLOBALS['LANG']->moduleLabels['labels'][$subKey . 'label']);
147 $moduleLabelHtml = !empty($moduleLabel) ? '<strong>' . $moduleLabel . '</strong><br />' : '';
148 $moduleDescription = $GLOBALS['LANG']->moduleLabels['labels'][$subKey . 'descr'];
149
150 $subHtml[] = '<tr class="c-subitem-row">';
151 $subHtml[] = '<td align="center">' . $iconHtml . '</td>';
152 $subHtml[] = '<td>' . $linkedLabel . '&nbsp;&nbsp;</td>';
153
154 if (!empty($moduleLabel) || !empty($moduleDescription)) {
155 $subHtml[] = '<td class="module-description">' . $moduleLabelHtml . $moduleDescription . '</td>';
156 } else {
157 $subHtml[] = '<td>&nbsp;</td>';
158 }
159
160 $subHtml[] = '</tr>';
161 }
162 }
163
164 if (count($subHtml) > 0) {
165 $moduleHtml[] = implode(LF, $subHtml);
166 $moduleHtml[] = '<tr class="c-endrow"><td colspan="3"></td></tr>';
167 }
168 }
169
170 return '
171 <table border="0" cellpadding="0" cellspacing="0" id="typo3-about-modules">
172 ' . implode(LF, $moduleHtml) . '
173 </table>
174 ';
175 }
176 }
177
178 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/aboutmodules/mod/index.php'])) {
179 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/aboutmodules/mod/index.php']);
180 }
181
182 t3lib_div::makeInstance('SC_mod_help_aboutmodules_index')->render();
183 ?>