ee69a6c0fee8f4df29c75ff19a549da0cf55e12d
2 /***************************************************************
5 * (c) 2009-2010 Ingo Renner <ingo@typo3.org>
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.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
26 $LANG->includeLLFile('EXT:reports/mod/locallang.xml');
27 // This checks permissions and exits if the users has no permission for entry.
28 $BE_USER->modAccess($MCONF, 1);
32 * Module 'Reports' for the 'reports' extension.
34 * @author Ingo Renner <ingo@typo3.org>
36 * @subpackage tx_reports
40 class tx_reports_Module
extends t3lib_SCbase
{
45 * Initializes the Module
49 public function __construct() {
52 // initialize document
53 $this->doc
= t3lib_div
::makeInstance('template');
54 $this->doc
->setModuleTemplate(
55 t3lib_extMgm
::extPath('reports') . 'mod/mod_template.html'
57 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
58 $this->doc
->getPageRenderer()->loadScriptaculous('effects');
59 $this->doc
->addStyleSheet(
61 '../' . t3lib_extMgm
::siteRelPath('reports') . 'mod/mod_styles.css'
66 * Adds items to the ->MOD_MENU array. Used for the function menu selector.
70 public function menuConfig() {
71 $reportsMenuItems = array();
72 $this->MOD_MENU
= array('function' => array());
74 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'] as $extKey => $reports) {
75 foreach ($reports as $reportName => $report) {
76 $reportsMenuItems[$extKey . '.' . $reportName] = $GLOBALS['LANG']->sL($report['title']);
80 asort($reportsMenuItems);
81 $reportsMenuItems = array_merge(
82 array('index' => $GLOBALS['LANG']->getLL('reports_overview')),
86 foreach ($reportsMenuItems as $key => $title) {
87 $this->MOD_MENU
['function'][$key] = $title;
94 * Creates the module's content. In this case it rather acts as a kind of #
95 * dispatcher redirecting requests to specific reports.
99 public function main() {
100 $docHeaderButtons = $this->getButtons();
103 // The page will show only if user has admin rights
104 if ($GLOBALS['BE_USER']->user
['admin']) {
107 $this->doc
->form
= '<form action="" method="post" enctype="multipart/form-data">';
109 $this->doc
->JScodeArray
[] = '
111 function jumpToUrl(URL) {
112 document.location = URL;
115 Event.observe(document, "dom:loaded", function(){
116 $$("h2.section-header").invoke("observe", "click", function(event){
117 var item = Event.element(event);
118 // possible icon inside h2
119 if (item.hasClassName("t3-icon")) {
120 item = item.up("h2");
122 if (item.hasClassName("expanded")) {
123 item.removeClassName("expanded").addClassName("collapsed");
124 Effect.BlindUp(item.next("div"), {duration : 0.5});
127 item.removeClassName("collapsed").addClassName("expanded");
128 Effect.BlindDown(item.next("div"), {duration : 0.5});
132 new Ajax.Request("ajax.php", {
133 parameters : "ajaxID=Reports::saveCollapseState&item=" + item.id + "&state=" + state
138 $this->doc
->postCode
='
139 <script language="javascript" type="text/javascript">
142 top.fsMod.recentIds["web"] = 0;
147 $this->renderModuleContent();
149 // If no access or if ID == 0
150 $docHeaderButtons['save'] = '';
151 $this->content
.=$this->doc
->spacer(10);
155 $markers['FUNC_MENU'] = $GLOBALS['LANG']->getLL('choose_report')
156 . t3lib_BEfunc
::getFuncMenu(
159 $this->MOD_SETTINGS
['function'],
160 $this->MOD_MENU
['function']
162 $markers['CONTENT'] = $this->content
;
164 // Build the <body> for the module
165 $this->content
= $this->doc
->startPage($GLOBALS['LANG']->getLL('title'));
166 $this->content
.= $this->doc
->moduleBody($this->pageinfo
, $docHeaderButtons, $markers);
167 $this->content
.= $this->doc
->endPage();
168 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
172 * Prints out the module's HTML
176 public function printContent() {
181 * Generates the module content by calling the selected report
185 protected function renderModuleContent() {
186 $action = (string) $this->MOD_SETTINGS
['function'];
190 if ($action == 'index') {
191 $content = $this->indexAction();
192 $title = $GLOBALS['LANG']->getLL('reports_overview');
195 list($extKey, $reportName) = explode('.', $action, 2);
197 $reportClass = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extKey][$reportName]['report'];
198 $title = $GLOBALS['LANG']->sL($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extKey][$reportName]['title']);
200 $reportInstance = t3lib_div
::makeInstance($reportClass, $this);
202 if ($reportInstance instanceof tx_reports_Report
) {
203 $content = $reportInstance->getReport();
205 $content = $reportClass . ' does not implement the Report Interface which is necessary to be displayed here.';
209 $this->content
.= $this->doc
->section($title, $content, false, true);
213 * Shows an overview list of available reports.
215 * @return string list of available reports
217 protected function indexAction() {
218 $defaultIcon = t3lib_extMgm
::extRelPath('reports') . 'mod/moduleicon.gif';
219 $content = '<dl class="report-list">';
222 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'] as $extKey => $extensionReports) {
223 foreach ($extensionReports as $reportName => $report) {
224 $action = $extKey . '.' . $reportName;
225 $link = 'mod.php?M=tools_txreportsM1' . htmlspecialchars('&SET[function]=') . $action;
227 $reportTitle = $GLOBALS['LANG']->sL($report['title']);
229 // Set default report icon
230 $icon = $defaultIcon;
231 // Check for custom icon
232 if (!empty($report['icon'])) {
233 $absIconPath = t3lib_div
::getFileAbsFilename($report['icon']);
234 // If the file indeed exists, assemble relative path to it
235 if (file_exists($absIconPath)) {
236 $icon = $GLOBALS['BACK_PATH'] . '../' . str_replace(PATH_site
, '', $absIconPath);
239 $icon = '<img' . t3lib_iconworks
::skinImg($GLOBALS['BACK_PATH'], $icon, 'width="16" height="16"') . ' title="' . $reportTitle . '" alt="' . $reportTitle . '" />';
240 $reportContent = '<dt><a href="' . $link . '">' . $icon . $reportTitle . '</a></dt>';
241 $reportContent .= '<dd>' . $GLOBALS['LANG']->sL($report['description']) . '</dd>';
243 $reports[$reportTitle] = $reportContent;
249 foreach ($reports as $reportContent) {
250 $content .= $reportContent;
253 return $content . '</dl>';
257 * Create the panel of buttons for submitting the form or otherwise
258 * perform operations.
260 * @return array all available buttons as an assoc. array
262 protected function getButtons() {
269 $buttons['csh'] = t3lib_BEfunc
::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
272 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
273 $buttons['shortcut'] = $this->doc
->makeShortcutIcon('', 'function', $this->MCONF
['name']);
284 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/reports/mod/index.php']) {
285 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/reports/mod/index.php']);
292 $SOBE = t3lib_div
::makeInstance('tx_reports_Module');
295 foreach($SOBE->include_once as $INC_FILE) {
296 include_once($INC_FILE);
300 $SOBE->printContent();