[TASK] Cleanup EXT:taskcenter 69/40769/3
authorFrederic Gaus <frederic.gaus@flagbit.de>
Tue, 30 Jun 2015 14:35:24 +0000 (16:35 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 30 Jun 2015 22:10:15 +0000 (00:10 +0200)
Resolves: #67861
Releases: master
Change-Id: I18531f6ef4d9541e9ef1163c3b4703f6b37bc84c
Reviewed-on: http://review.typo3.org/40769
Reviewed-by: Stephan GroƟberndt <stephan@grossberndt.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/sysext/taskcenter/Classes/Controller/TaskModuleController.php
typo3/sysext/taskcenter/Classes/TaskStatus.php

index 23712f0..5992842 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Taskcenter\TaskInterface;
 
 /**
  * This class provides a taskcenter for BE users
@@ -41,8 +42,6 @@ class TaskModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
 
        /**
         * Initializes the Module
-        *
-        * @return void
         */
        public function __construct() {
                $this->getLanguageService()->includeLLFile('EXT:taskcenter/task/locallang.xlf');
@@ -97,7 +96,7 @@ class TaskModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                        $this->renderModuleContent();
                }
                // Compile document
-               $markers['FUNC_MENU'] = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu(0, 'SET[mode]', $this->MOD_SETTINGS['mode'], $this->MOD_MENU['mode']);
+               $markers['FUNC_MENU'] = BackendUtility::getFuncMenu(0, 'SET[mode]', $this->MOD_SETTINGS['mode'], $this->MOD_MENU['mode']);
                $markers['CONTENT'] = $this->content;
                // Build the <body> for the module
                $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
@@ -120,18 +119,17 @@ class TaskModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
         * @return void
         */
        protected function renderModuleContent() {
-               $title = ($content = ($actionContent = ''));
                $chosenTask = (string)$this->MOD_SETTINGS['function'];
                // Render the taskcenter task as default
                if (empty($chosenTask) || $chosenTask == 'index') {
                        $chosenTask = 'taskcenter.tasks';
                }
                // Render the task
+               $actionContent = '';
                list($extKey, $taskClass) = explode('.', $chosenTask, 2);
-               $title = $this->getLanguageService()->sL($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['taskcenter'][$extKey][$taskClass]['title']);
                if (class_exists($taskClass)) {
                        $taskInstance = GeneralUtility::makeInstance($taskClass, $this);
-                       if ($taskInstance instanceof \TYPO3\CMS\Taskcenter\TaskInterface) {
+                       if ($taskInstance instanceof TaskInterface) {
                                // Check if the task is restricted to admins only
                                if ($this->checkAccess($extKey, $taskClass)) {
                                        $actionContent .= $taskInstance->getTask();
@@ -148,7 +146,7 @@ class TaskModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                                // Error if the task is not an instance of \TYPO3\CMS\Taskcenter\TaskInterface
                                $flashMessage = GeneralUtility::makeInstance(
                                        FlashMessage::class,
-                                       sprintf($this->getLanguageService()->getLL('error_no-instance', TRUE), $taskClass, \TYPO3\CMS\Taskcenter\TaskInterface::class),
+                                       sprintf($this->getLanguageService()->getLL('error_no-instance', TRUE), $taskClass, TaskInterface::class),
                                        $this->getLanguageService()->getLL('error_header'),
                                        FlashMessage::ERROR
                                );
@@ -247,7 +245,7 @@ class TaskModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                                                        $icon = '<img src="' . $icon . '" title="' . $title . '" alt="' . $title . '" />';
                                                }
                                                if (@is_file($icon)) {
-                                                       $icon = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], $icon, 'width="16" height="16"') . ' title="' . $title . '" alt="' . $title . '" />';
+                                                       $icon = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], $icon, 'width="16" height="16"') . ' title="' . $title . '" alt="' . $title . '" />';
                                                }
                                        } else {
                                                $icon = $item['icon'];
@@ -272,10 +270,12 @@ class TaskModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                                $active = (string)$this->MOD_SETTINGS['function'] == $item['uid'] ? ' active-task' : '';
                                // Main menu: Render additional syntax to sort tasks
                                if ($mainMenu) {
-                                       $dragIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-move', array('title' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.move', TRUE)));
+                                       $dragIcon = IconUtility::getSpriteIcon('actions-document-move', array('title' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.move', TRUE)));
                                        $section = '<div class="down">&nbsp;</div>
                                                                <div class="drag">' . $dragIcon . '</div>';
                                        $backgroundClass = 't3-row-header ';
+                               } else {
+                                       $backgroundClass = '';
                                }
                                $content .= '<li class="' . $additionalClass . $active . '" id="el_' . $id . '">
                                                                ' . $section . '
@@ -316,7 +316,7 @@ class TaskModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
                                        }
                                        if (class_exists($taskClass)) {
                                                $taskInstance = GeneralUtility::makeInstance($taskClass, $this);
-                                               if ($taskInstance instanceof \TYPO3\CMS\Taskcenter\TaskInterface) {
+                                               if ($taskInstance instanceof TaskInterface) {
                                                        $taskDescriptionHtml = $taskInstance->getOverview();
                                                }
                                        }
index a223e19..74caa6a 100644 (file)
@@ -14,6 +14,9 @@ namespace TYPO3\CMS\Taskcenter;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Http\AjaxRequestHandler;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * Status of tasks
  *
@@ -25,32 +28,41 @@ class TaskStatus {
         * Saves the section toggle state of tasks in the backend user's uc
         *
         * @param array $params Array of parameters from the AJAX interface, currently unused
-        * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
+        * @param AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
         * @return void
         */
-       public function saveCollapseState(array $params, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj) {
+       public function saveCollapseState(array $params, AjaxRequestHandler $ajaxObj) {
                // Remove 'el_' in the beginning which is needed for the saveSortingState()
-               $item = substr(htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('item')), 3);
-               $state = (bool)\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('state');
-               $GLOBALS['BE_USER']->uc['taskcenter']['states'][$item] = $state;
-               $GLOBALS['BE_USER']->writeUC();
+               $item = substr(htmlspecialchars(GeneralUtility::_POST('item')), 3);
+               $state = (bool)GeneralUtility::_POST('state');
+               $this->getBackendUserAuthentication()->uc['taskcenter']['states'][$item] = $state;
+               $this->getBackendUserAuthentication()->writeUC();
        }
 
        /**
         * Saves the sorting order of tasks in the backend user's uc
         *
         * @param array $params Array of parameters from the AJAX interface, currently unused
-        * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
+        * @param AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
         * @return void
         */
-       public function saveSortingState(array $params, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj) {
+       public function saveSortingState(array $params, AjaxRequestHandler $ajaxObj) {
                $sort = array();
-               $items = explode('&', \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('data'));
+               $items = explode('&', GeneralUtility::_POST('data'));
                foreach ($items as $item) {
                        $sort[] = substr($item, 12);
                }
-               $GLOBALS['BE_USER']->uc['taskcenter']['sorting'] = serialize($sort);
-               $GLOBALS['BE_USER']->writeUC();
+               $this->getBackendUserAuthentication()->uc['taskcenter']['sorting'] = serialize($sort);
+               $this->getBackendUserAuthentication()->writeUC();
+       }
+
+       /**
+        * Returns BackendUserAuthentication
+        *
+        * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
+        */
+       protected function getBackendUserAuthentication() {
+               return $GLOBALS['BE_USER'];
        }
 
 }