[TASK] Add tool-function to strip PATH_site-part of paths
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / NoDocumentsOpenController.php
1 <?php
2 namespace TYPO3\CMS\Backend\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 use TYPO3\CMS\Core\Utility\GeneralUtility;
31
32 /**
33 * Script Class for the "No-doc" display; This shows most recently edited records.
34 *
35 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
36 */
37 class NoDocumentsOpenController {
38
39 // Internal:
40 // Content accumulation
41 /**
42 * @todo Define visibility
43 */
44 public $content;
45
46 /**
47 * Document template object
48 *
49 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
50 * @todo Define visibility
51 */
52 public $doc;
53
54 /**
55 * Object for backend modules.
56 *
57 * @var \TYPO3\CMS\Backend\Module\ModuleLoader
58 * @todo Define visibility
59 */
60 public $loadModules;
61
62 /**
63 * Constructor
64 */
65 public function __construct() {
66 $GLOBALS['SOBE'] = $this;
67 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_alt_doc.xml');
68
69 $this->init();
70 }
71
72 /**
73 * Initialize.
74 *
75 * @return void
76 */
77 protected function init() {
78 // Start the template object:
79 $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
80 $this->doc->bodyTagMargins['x'] = 5;
81 $this->doc->bodyTagMargins['y'] = 5;
82 $this->doc->backPath = $GLOBALS['BACK_PATH'];
83 // Add JS
84 $this->doc->JScode = $this->doc->wrapScriptTags('
85 function jump(url, modName, mainModName) {
86 // clear information about which entry in nav. tree that might have been highlighted.
87 top.fsMod.navFrameHighlightedID = [];
88
89 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
90 top.content.nav_frame.refresh_nav();
91 }
92
93 top.nextLoadModuleUrl = url;
94 top.goToModule(modName);
95 }
96 ');
97 // Start the page:
98 $this->content = '';
99 $this->content .= $this->doc->startPage('TYPO3 Edit Document');
100 // Loads the backend modules available for the logged in user.
101 $this->loadModules = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader');
102 $this->loadModules->load($GLOBALS['TBE_MODULES']);
103 }
104
105 /**
106 * Rendering the content.
107 *
108 * @return void
109 */
110 public function main() {
111 $msg = array();
112 // Add a message, telling that no documents were open...
113 $msg[] = '<p>' . $GLOBALS['LANG']->getLL('noDocuments_msg', TRUE) . '</p><br />';
114 // If another page module was specified, replace the default Page module with the new one
115 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
116 $pageModule = \TYPO3\CMS\Backend\Utility\BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
117 // Perform some access checks:
118 $a_wl = $GLOBALS['BE_USER']->check('modules', 'web_list');
119 $a_wp = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms') && $GLOBALS['BE_USER']->check('modules', $pageModule);
120 // Finding module images: PAGE
121 $imgFile = $GLOBALS['LANG']->moduleLabels['tabs_images']['web_layout_tab'];
122 $imgInfo = @getimagesize($imgFile);
123 $img_web_layout = is_array($imgInfo) ? '<img src="../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($imgFile) . '" ' . $imgInfo[3] . ' alt="" />' : '';
124 // Finding module images: LIST
125 $imgFile = $GLOBALS['LANG']->moduleLabels['tabs_images']['web_list_tab'];
126 $imgInfo = @getimagesize($imgFile);
127 $img_web_list = is_array($imgInfo) ? '<img src="../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($imgFile) . '" ' . $imgInfo[3] . ' alt="" />' : '';
128 // If either the Web>List OR Web>Page module are active, show the little message with links to those modules:
129 if ($a_wl || $a_wp) {
130 $msg_2 = array();
131 // Web>Page:
132 if ($a_wp) {
133 $msg_2[] = '<strong><a href="#" onclick="top.goToModule(\'' . $pageModule . '\'); return false;">' . $GLOBALS['LANG']->getLL('noDocuments_pagemodule', TRUE) . $img_web_layout . '</a></strong>';
134 if ($a_wl) {
135 $msg_2[] = $GLOBALS['LANG']->getLL('noDocuments_OR');
136 }
137 }
138 // Web>List
139 if ($a_wl) {
140 $msg_2[] = '<strong><a href="#" onclick="top.goToModule(\'web_list\'); return false;">' . $GLOBALS['LANG']->getLL('noDocuments_listmodule', TRUE) . $img_web_list . '</a></strong>';
141 }
142 $msg[] = '<p>' . sprintf($GLOBALS['LANG']->getLL('noDocuments_msg2', 1), implode(' ', $msg_2)) . '</p><br />';
143 }
144 // Display the list of the most recently edited documents:
145 $modObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Opendocs\\Controller\\OpendocsController');
146 $msg[] = '<p>' . $GLOBALS['LANG']->getLL('noDocuments_msg3', TRUE) . '</p><br />' . $modObj->renderMenu();
147 // Adding the content:
148 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('noDocuments'), implode(' ', $msg), 0, 1);
149 }
150
151 /**
152 * Printing the content.
153 *
154 * @return void
155 */
156 public function printContent() {
157 $this->content .= $this->doc->endPage();
158 $this->content = $this->doc->insertStylesAndJS($this->content);
159 echo $this->content;
160 }
161
162 }