d18e5ee02be6a4011df3fa6fe785f307b621ec77
[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, initialize.
64 *
65 * @return void
66 * @todo Define visibility
67 */
68 public function init() {
69 // Start the template object:
70 $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
71 $this->doc->bodyTagMargins['x'] = 5;
72 $this->doc->bodyTagMargins['y'] = 5;
73 $this->doc->backPath = $GLOBALS['BACK_PATH'];
74 // Add JS
75 $this->doc->JScode = $this->doc->wrapScriptTags('
76 function jump(url, modName, mainModName) {
77 // clear information about which entry in nav. tree that might have been highlighted.
78 top.fsMod.navFrameHighlightedID = [];
79
80 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
81 top.content.nav_frame.refresh_nav();
82 }
83
84 top.nextLoadModuleUrl = url;
85 top.goToModule(modName);
86 }
87 ');
88 // Start the page:
89 $this->content = '';
90 $this->content .= $this->doc->startPage('TYPO3 Edit Document');
91 // Loads the backend modules available for the logged in user.
92 $this->loadModules = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader');
93 $this->loadModules->load($GLOBALS['TBE_MODULES']);
94 }
95
96 /**
97 * Rendering the content.
98 *
99 * @return void
100 * @todo Define visibility
101 */
102 public function main() {
103 $msg = array();
104 // Add a message, telling that no documents were open...
105 $msg[] = '<p>' . $GLOBALS['LANG']->getLL('noDocuments_msg', 1) . '</p><br />';
106 // If another page module was specified, replace the default Page module with the new one
107 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
108 $pageModule = \TYPO3\CMS\Backend\Utility\BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
109 // Perform some access checks:
110 $a_wl = $GLOBALS['BE_USER']->check('modules', 'web_list');
111 $a_wp = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms') && $GLOBALS['BE_USER']->check('modules', $pageModule);
112 // Finding module images: PAGE
113 $imgFile = $GLOBALS['LANG']->moduleLabels['tabs_images']['web_layout_tab'];
114 $imgInfo = @getimagesize($imgFile);
115 $img_web_layout = is_array($imgInfo) ? '<img src="../' . substr($imgFile, strlen(PATH_site)) . '" ' . $imgInfo[3] . ' alt="" />' : '';
116 // Finding module images: LIST
117 $imgFile = $GLOBALS['LANG']->moduleLabels['tabs_images']['web_list_tab'];
118 $imgInfo = @getimagesize($imgFile);
119 $img_web_list = is_array($imgInfo) ? '<img src="../' . substr($imgFile, strlen(PATH_site)) . '" ' . $imgInfo[3] . ' alt="" />' : '';
120 // If either the Web>List OR Web>Page module are active, show the little message with links to those modules:
121 if ($a_wl || $a_wp) {
122 $msg_2 = array();
123 // Web>Page:
124 if ($a_wp) {
125 $msg_2[] = '<strong><a href="#" onclick="top.goToModule(\'' . $pageModule . '\'); return false;">' . $GLOBALS['LANG']->getLL('noDocuments_pagemodule', 1) . $img_web_layout . '</a></strong>';
126 if ($a_wl) {
127 $msg_2[] = $GLOBALS['LANG']->getLL('noDocuments_OR');
128 }
129 }
130 // Web>List
131 if ($a_wl) {
132 $msg_2[] = '<strong><a href="#" onclick="top.goToModule(\'web_list\'); return false;">' . $GLOBALS['LANG']->getLL('noDocuments_listmodule', 1) . $img_web_list . '</a></strong>';
133 }
134 $msg[] = '<p>' . sprintf($GLOBALS['LANG']->getLL('noDocuments_msg2', 1), implode(' ', $msg_2)) . '</p><br />';
135 }
136 // Display the list of the most recently edited documents:
137 $modObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Opendocs\\Controller\\OpendocsController');
138 $msg[] = '<p>' . $GLOBALS['LANG']->getLL('noDocuments_msg3', TRUE) . '</p><br />' . $modObj->renderMenu();
139 // Adding the content:
140 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('noDocuments'), implode(' ', $msg), 0, 1);
141 }
142
143 /**
144 * Printing the content.
145 *
146 * @return void
147 * @todo Define visibility
148 */
149 public function printContent() {
150 $this->content .= $this->doc->endPage();
151 $this->content = $this->doc->insertStylesAndJS($this->content);
152 echo $this->content;
153 }
154
155 }
156
157 ?>