[TASK] Cleanup ext:func 68/22268/6
authorWouter Wolters <typo3@wouterwolters.nl>
Fri, 12 Jul 2013 18:53:20 +0000 (20:53 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 30 Jul 2013 16:08:11 +0000 (18:08 +0200)
- Remove require_once calls
- Replace global $LANG and $BACK_PATH

Change-Id: I279bf7a1a59ed3dbf490a6b875977915ef503d13
Resolves: #49989
Releases: 6.2
Reviewed-on: https://review.typo3.org/22268
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/func/Classes/Controller/PageFunctionsController.php
typo3/sysext/func/ext_tables.php
typo3/sysext/func/mod1/index.php

index 0ff61cd..99b5eb6 100644 (file)
@@ -55,17 +55,23 @@ class PageFunctionsController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
        public $doc;
 
        /**
+        * Constructor
+        */
+       public function __construct() {
+               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_mod_web_func.xlf');
+               $GLOBALS['BE_USER']->modAccess($GLOBALS['MCONF'], TRUE);
+       }
+
+       /**
         * Initialize module header etc and call extObjContent function
         *
         * @return void
-        * @todo Define visibility
         */
        public function main() {
-               global $LANG, $BACK_PATH;
                // Access check...
                // The page will show only if there is a valid page and if this page may be viewed by the user
                $this->pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $this->perms_clause);
-               $access = is_array($this->pageinfo) ? 1 : 0;
+               $access = is_array($this->pageinfo);
                // Template markers
                $markers = array(
                        'CSH' => '',
@@ -73,14 +79,14 @@ class PageFunctionsController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
                        'CONTENT' => ''
                );
                $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
-               $this->doc->backPath = $BACK_PATH;
+               $this->doc->backPath = $GLOBALS['BACK_PATH'];
                $this->doc->setModuleTemplate('EXT:func/Resources/Private/Templates/func.html');
                // Main
                if ($this->id && $access) {
                        // JavaScript
                        $this->doc->JScode = $this->doc->wrapScriptTags('
                                script_ended = 0;
-                               function jumpToUrl(URL) {       //
+                               function jumpToUrl(URL) {
                                        window.location.href = URL;
                                }
                        ');
@@ -91,7 +97,7 @@ class PageFunctionsController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
                        // Setting up the context sensitive menu:
                        $this->doc->getContextMenuCode();
                        $this->doc->form = '<form action="index.php" method="post"><input type="hidden" name="id" value="' . $this->id . '" />';
-                       $vContent = $this->doc->getVersionSelector($this->id, 1);
+                       $vContent = $this->doc->getVersionSelector($this->id, TRUE);
                        if ($vContent) {
                                $this->content .= $this->doc->section('', $vContent);
                        }
@@ -99,11 +105,21 @@ class PageFunctionsController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
                        // Setting up the buttons and markers for docheader
                        $docHeaderButtons = $this->getButtons();
                        $markers['CSH'] = $docHeaderButtons['csh'];
-                       $markers['FUNC_MENU'] = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
+                       $markers['FUNC_MENU'] = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu(
+                               $this->id,
+                               'SET[function]',
+                               $this->MOD_SETTINGS['function'],
+                               $this->MOD_MENU['function']
+                       );
                        $markers['CONTENT'] = $this->content;
                } else {
                        // If no access or if ID == zero
-                       $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('clickAPage_content'), $LANG->getLL('title'), \TYPO3\CMS\Core\Messaging\FlashMessage::INFO);
+                       $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
+                               'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
+                               $GLOBALS['LANG']->getLL('clickAPage_content'),
+                               $GLOBALS['LANG']->getLL('title'),
+                               \TYPO3\CMS\Core\Messaging\FlashMessage::INFO
+                       );
                        $this->content = $flashMessage->render();
                        // Setting up the buttons and markers for docheader
                        $docHeaderButtons = $this->getButtons();
@@ -113,14 +129,13 @@ class PageFunctionsController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
                // Build the <body> for the module
                $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
                // Renders the module page
-               $this->content = $this->doc->render($LANG->getLL('title'), $this->content);
+               $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
        }
 
        /**
         * Print module content (from $this->content)
         *
         * @return void
-        * @todo Define visibility
         */
        public function printContent() {
                echo $this->content;
@@ -132,7 +147,6 @@ class PageFunctionsController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
         * @return array All available buttons as an assoc. array
         */
        protected function getButtons() {
-               global $BACK_PATH;
                $buttons = array(
                        'csh' => '',
                        'view' => '',
@@ -143,7 +157,7 @@ class PageFunctionsController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
                if ($this->id && is_array($this->pageinfo)) {
                        // View page
                        $buttons['view'] = '<a href="#"
-                                       onclick="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick($this->pageinfo['uid'], $BACK_PATH, \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($this->pageinfo['uid']))) . '"
+                                       onclick="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick($this->pageinfo['uid'], $GLOBALS['BACK_PATH'], \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($this->pageinfo['uid']))) . '"
                                        title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', 1) . '
                                ">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-view') . '</a>';
                        // Shortcut
index 7923003..6f8c8e6 100644 (file)
@@ -3,6 +3,11 @@ if (!defined('TYPO3_MODE')) {
        die('Access denied.');
 }
 if (TYPO3_MODE === 'BE') {
-       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule('web', 'func', '', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'mod1/');
+       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule(
+               'web',
+               'func',
+               '',
+               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'mod1/'
+       );
 }
 ?>
\ No newline at end of file
index 3b7b408..cf88dba 100755 (executable)
@@ -24,6 +24,7 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
+
 /**
  * Module: Advanced functions
  * Advanced Functions related to pages
 unset($MCONF);
 require __DIR__ . '/conf.php';
 require $BACK_PATH . 'init.php';
-$LANG->includeLLFile('EXT:lang/locallang_mod_web_func.xlf');
-$BE_USER->modAccess($MCONF, 1);
-/*
- * @deprecated since 6.0, the classname SC_mod_web_func_index and this file is obsolete
- * and will be removed with 6.2. The class was renamed and is now located at:
- * typo3/sysext/func/Classes/Controller/PageFunctionsController.php
- */
-require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('func') . 'Classes/Controller/PageFunctionsController.php';
-// Make instance:
+
 /** @var $SOBE \TYPO3\CMS\Func\Controller\PageFunctionsController */
 $SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Func\\Controller\\PageFunctionsController');
 $SOBE->init();