[!!!][TASK] Remove module URI storage in global variable 06/37406/2
authorHelmut Hummel <helmut.hummel@typo3.org>
Sun, 1 Mar 2015 12:29:59 +0000 (13:29 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 1 Mar 2015 14:18:11 +0000 (15:18 +0100)
Previously the URI to a module which was dispatched through mod.php was stored
in a global variable $GLOBALS['MCONF']['_']

In terms of cleanup of global variable usage and
module configuration cleanup, this functionality is removed without substitution.

Instead BackendUtility::getModuleUrl() API must be used now.

Releases: master
Resolves: #65432
Change-Id: Iad436056e96d2334357320278cd8243f0f975538
Reviewed-on: http://review.typo3.org/37406
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/mod.php
typo3/sysext/core/Documentation/Changelog/master/Breaking-65432-ModulUriInGlobalVarRemoved.rst [new file with mode: 0644]
typo3/sysext/impexp/Classes/Controller/ImportExportController.php
typo3/sysext/openid/Classes/Wizard.php
typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
typo3/sysext/scheduler/Classes/ViewHelpers/ModuleLinkViewHelper.php
typo3/sysext/scheduler/Resources/Private/Templates/Backend/SchedulerModule/InfoScreen.html

index f17d8cc..6e09e28 100644 (file)
@@ -27,7 +27,6 @@ if (!$formProtection->validateToken(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP(
        throw new UnexpectedValueException('Invalid form/module token detected. Access Denied!', 1392409507);
 }
 if ($temp_path = $GLOBALS['TBE_MODULES']['_PATHS'][$moduleName]) {
-       $GLOBALS['MCONF']['_'] = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl($moduleName);
        if (file_exists($temp_path . 'conf.php')) {
                require $temp_path . 'conf.php';
                $moduleConfiguration = $GLOBALS['MCONF'];
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-65432-ModulUriInGlobalVarRemoved.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-65432-ModulUriInGlobalVarRemoved.rst
new file mode 100644 (file)
index 0000000..0ec882f
--- /dev/null
@@ -0,0 +1,30 @@
+============================================================================
+Breaking: #65432 - Storage of module URI in global variable has been removed
+============================================================================
+
+Description
+===========
+
+Previously the URI to a module which was dispatched through mod.php was stored
+in a global variable ``$GLOBALS['MCONF']['_']``.
+
+In terms of cleanup of global variable usage and module configuration cleanup and streamlining,
+this functionality has been removed without substitution.
+
+
+Impact
+======
+
+Any backend module code which accesses ``$GLOBALS['MCONF']['_']`` to get the module URI will not function any more.
+
+
+Affected installations
+======================
+
+TYPO3 CMS 7 installations using extensions with backend modules which use ``$GLOBALS['MCONF']['_']``.
+
+
+Migration
+=========
+
+Extension code needs to be changed in a way that the API ``BackendUtility::getModuleUrl('module_name')`` is used instead of accessing ``$GLOBALS['MCONF']['_']``.
index 982f8dc..f213487 100644 (file)
@@ -99,7 +99,7 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                // Setting up the context sensitive menu:
                $this->doc->getContextMenuCode();
                $this->doc->postCode = $this->doc->wrapScriptTags('if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int)$this->id . ';');
-               $this->doc->form = '<form action="' . htmlspecialchars($GLOBALS['MCONF']['_']) . '" method="post" enctype="'
+               $this->doc->form = '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('xMOD_tximpexp')) . '" method="post" enctype="'
                        . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '"><input type="hidden" name="id" value="' . $this->id . '" />';
                $this->content .= $this->doc->header($this->lang->getLL('title'));
                $this->content .= $this->doc->spacer(5);
index 120200f..d1af979 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Openid;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -96,8 +97,9 @@ class Wizard extends OpenidService {
         * @return string Full URL with protocol and hostname
         */
        protected function getSelfUrl() {
-               return GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir .
-                       $GLOBALS['MCONF']['_'];
+               return GeneralUtility::getIndpEnv('TYPO3_SITE_URL')
+                       . TYPO3_mainDir
+                       . BackendUtility::getModuleUrl('wizard_openid');
        }
 
        /**
index c8ad306..7d8744d 100644 (file)
@@ -90,6 +90,11 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
        protected $moduleName = 'system_txschedulerM1';
 
        /**
+        * @var string Base URI of scheduler module
+        */
+       protected $moduleUri;
+
+       /**
         * @return \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController
         */
        public function __construct() {
@@ -102,6 +107,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                $this->backendTemplatePath = ExtensionManagementUtility::extPath('scheduler') . 'Resources/Private/Templates/Backend/SchedulerModule/';
                $this->view = GeneralUtility::makeInstance(\TYPO3\CMS\Fluid\View\StandaloneView::class);
                $this->view->getRequest()->setControllerExtensionName('scheduler');
+               $this->moduleUri = BackendUtility::getModuleUrl($this->moduleName);
        }
 
        /**
@@ -386,7 +392,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                // Check CLI user
                $checkUser = $this->checkSchedulerUser();
                if ($checkUser == -1) {
-                       $link = $GLOBALS['MCONF']['_'] . '&SET[function]=check&CMD=user';
+                       $link = $this->moduleUri . '&SET[function]=check&CMD=user';
                        $message = sprintf($this->getLanguageService()->getLL('msg.schedulerUserMissing'), htmlspecialchars($link));
                        $severity = FlashMessage::ERROR;
                } elseif ($checkUser == 0) {
@@ -932,7 +938,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
 
 
                                foreach ($taskGroup['tasks'] as $schedulerRecord) {// Define action icons
-                                       $editAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=edit&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:edit', TRUE) . '" class="icon">' .
+                                       $editAction = '<a href="' . htmlspecialchars($this->moduleUri . '&CMD=edit&tx_scheduler[uid]=' . $schedulerRecord['uid']) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:edit', TRUE) . '" class="icon">' .
                                                IconUtility::getSpriteIcon('actions-document-open') . '</a>';
                                        if ((int)$schedulerRecord['disable'] === 1) {
                                                $translationKey = 'enable';
@@ -941,13 +947,13 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                                                $translationKey = 'disable';
                                                $spriteIcon = 'actions-edit-hide';
                                        }
-                                       $toggleHiddenAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=toggleHidden&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:' . $translationKey, TRUE) . '" class="icon">' .
+                                       $toggleHiddenAction = '<a href="' . htmlspecialchars($this->moduleUri . '&CMD=toggleHidden&tx_scheduler[uid]=' . $schedulerRecord['uid']) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:' . $translationKey, TRUE) . '" class="icon">' .
                                                IconUtility::getSpriteIcon($spriteIcon) . '</a>';
-                                       $deleteAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=delete&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" onclick="return confirm(\'' . $this->getLanguageService()->getLL('msg.delete') . '\');" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:delete', TRUE) . '" class="icon">' .
+                                       $deleteAction = '<a href="' . htmlspecialchars($this->moduleUri . '&CMD=delete&tx_scheduler[uid]=' . $schedulerRecord['uid']) . '" onclick="return confirm(' . GeneralUtility::quoteJSvalue($this->getLanguageService()->getLL('msg.delete')) . ');" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:delete', TRUE) . '" class="icon">' .
                                                IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
-                                       $stopAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=stop&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" onclick="return confirm(\'' . $this->getLanguageService()->getLL('msg.stop') . '\');" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:stop', TRUE) . '" class="icon">' .
+                                       $stopAction = '<a href="' . htmlspecialchars($this->moduleUri . '&CMD=stop&tx_scheduler[uid]=' . $schedulerRecord['uid']) . '" onclick="return confirm(' . GeneralUtility::quoteJSvalue($this->getLanguageService()->getLL('msg.stop')) . ');" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:stop', TRUE) . '" class="icon">' .
                                                '<img ' . IconUtility::skinImg($this->backPath, (ExtensionManagementUtility::extRelPath('scheduler') . '/Resources/Public/Images/stop.png')) . ' alt="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:stop') . '" /></a>';
-                                       $runAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&tx_scheduler[execute][]=' . $schedulerRecord['uid'] . '" title="' . $this->getLanguageService()->getLL('action.run_task') . '" class="icon">' .
+                                       $runAction = '<a href="' . htmlspecialchars($this->moduleUri . '&tx_scheduler[execute][]=' . $schedulerRecord['uid']) . '" title="' . $this->getLanguageService()->getLL('action.run_task', TRUE) . '" class="icon">' .
                                                IconUtility::getSpriteIcon('extensions-scheduler-run-task') . '</a>';
 
                                        // Define some default values
@@ -1454,15 +1460,15 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                        'shortcut' => $this->getShortcutButton()
                );
                if (empty($this->CMD) || $this->CMD === 'list' || $this->CMD === 'delete' || $this->CMD === 'stop' || $this->CMD === 'toggleHidden') {
-                       $buttons['reload'] = '<a href="' . $GLOBALS['MCONF']['_'] . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', TRUE) . '">' . IconUtility::getSpriteIcon('actions-system-refresh') . '</a>';
+                       $buttons['reload'] = '<a href="' . htmlspecialchars($this->moduleUri) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', TRUE) . '">' . IconUtility::getSpriteIcon('actions-system-refresh') . '</a>';
                        if ($this->MOD_SETTINGS['function'] === 'scheduler' && count($this->getRegisteredClasses())) {
-                               $link = $GLOBALS['MCONF']['_'] . '&CMD=add';
+                               $link = $this->moduleUri . '&CMD=add';
                                $image = IconUtility::getSpriteIcon('actions-document-new', array('alt' => $this->getLanguageService()->getLL('action.add')));
                                $buttons['addtask'] = '<a href="' . htmlspecialchars($link) . '" ' . 'title="' . $this->getLanguageService()->getLL('action.add') . '">' . $image . '</a>';
                        }
                }
                if ($this->CMD === 'add' || $this->CMD === 'edit') {
-                       $buttons['close'] = '<a href="#" onclick="document.location=\'' . $GLOBALS['MCONF']['_'] . '\'" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:cancel', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-close') . '</a>';
+                       $buttons['close'] = '<a href="#" onclick="document.location=' . htmlspecialchars(GeneralUtility::quoteJSvalue($this->moduleUri)) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:cancel', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-close') . '</a>';
                        $buttons['save'] = '<button style="padding: 0; margin: 0; cursor: pointer;" type="submit" name="CMD" value="save" class="c-inputButton" src="clear.gif" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:save', TRUE) . '" />' . IconUtility::getSpriteIcon('actions-document-save') . '</button>';
                        $buttons['saveclose'] = '<button style="padding: 0; margin: 0; cursor: pointer;" type="submit" name="CMD" value="saveclose" class="c-inputButton" src="clear.gif" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:saveAndClose', TRUE) . '" />' . IconUtility::getSpriteIcon('actions-document-save-close') . '</button>';
                        $buttons['savenew'] = '<button style="padding: 0; margin: 0; cursor: pointer;" type="submit" name="CMD" value="savenew" class="c-inputButton" src="clear.gif" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:saveAndCreateNewDoc', TRUE) . '" />' . IconUtility::getSpriteIcon('actions-document-save-new') . '</button>';
index d5458be..187937f 100644 (file)
@@ -14,31 +14,54 @@ namespace TYPO3\CMS\Scheduler\ViewHelpers;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
+
 /**
- * Create internal link within backend app
- * @TODO: Later I want to be an AbstractTagBasedViewHelper
+ * Create internal link tag within backend app
  * @internal
  */
-class ModuleLinkViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
+class ModuleLinkViewHelper extends AbstractTagBasedViewHelper {
 
        /**
-        * Generate module link
+        * @var string
+        */
+       protected $tagName = 'a';
+
+       /**
+        * Arguments initialization
         *
-        * @param string $function
-        * @param string $cms
-        * @param array $arguments
-        * @return string
+        * @return void
         */
-       public function render($function = '', $cmd = '', array $arguments = array()) {
-               $link = $GLOBALS['MCONF']['_'] . '&SET[function]=' . $function . '&CMD=' . $cmd;
+       public function initializeArguments() {
+               $this->registerUniversalTagAttributes();
+               $this->registerTagAttribute('name', 'string', 'Specifies the name of an anchor');
+               $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document');
+               $this->registerTagAttribute('rev', 'string', 'Specifies the relationship between the linked document and the current document');
+               $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document');
+       }
 
+       /**
+        * Render module link with command and arguments
+        *
+        * @param string $controller The "controller" of scheduler. Possible values are "scheduler", "check", "info"
+        * @param string $action The action to be called within each controller
+        * @param array $arguments Arguments for the action
+        * @return string
+        */
+       public function render($controller, $action, array $arguments = array()) {
+               $moduleArguments = array();
+               $moduleArguments['SET']['function'] = $controller;
+               $moduleArguments['CMD'] = $action;
                if (!empty($arguments)) {
-                       foreach ($arguments as $key => $value) {
-                               $link .= '&tx_scheduler[' . $key . ']=' . $value;
-                       }
+                       $moduleArguments['tx_scheduler'] = $arguments;
                }
 
-               return htmlspecialchars($link);
+               $uri = BackendUtility::getModuleUrl('system_txschedulerM1', $moduleArguments);
+               $this->tag->addAttribute('href', $uri);
+               $this->tag->setContent($this->renderChildren());
+               $this->tag->forceClosingTag(TRUE);
+               return $this->tag->render();
        }
 
 }
\ No newline at end of file
index 780c16f..865a26f 100644 (file)
                                <td>{classInfo.description}</td>
                                <td>
                                        <div class="btn-group" role="group">
-                                               <a
-                                                       href="{s:moduleLink(function:'list',cmd:'add',arguments:'{class: class}')}"
+                                               <s:moduleLink
+                                                       controller="scheduler"
+                                                       action="add" arguments="{class: class}"
                                                        title="{f:translate(key:'LLL:EXT:lang/locallang_common.xlf:new')}"
-                                                       class="btn btn-default">
-                                                               <s:spriteIcon iconName="actions-document-new" />
-                                               </a>
+                                                       class="btn btn-default"
+                                               >
+                                                       <s:spriteIcon iconName="actions-document-new" />
+                                               </s:moduleLink>
                                        </div>
                                </td>
                        </tr>