[TASK] Revamp ext:linkvalidator 62/33262/17
authorWouter Wolters <typo3@wouterwolters.nl>
Sat, 11 Oct 2014 11:19:54 +0000 (13:19 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sat, 3 Jan 2015 15:05:41 +0000 (16:05 +0100)
* Migrate JavaScript to jQuery AMD module
* Cleanup the code
* Migrate CSS to less
* Use correct table styles
* Use dyntabmenu instead of ExtJs
* Replace $GLOBALS with corresponding getter

Resolves: #62164
Releases: master
Change-Id: I5021366f4f78ec129f1e769825a6beeed3525454
Reviewed-on: http://review.typo3.org/33262
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
16 files changed:
typo3/sysext/linkvalidator/Classes/LinkAnalyzer.php
typo3/sysext/linkvalidator/Classes/Linktype/AbstractLinktype.php
typo3/sysext/linkvalidator/Classes/Linktype/ExternalLinktype.php
typo3/sysext/linkvalidator/Classes/Linktype/FileLinktype.php
typo3/sysext/linkvalidator/Classes/Linktype/InternalLinktype.php
typo3/sysext/linkvalidator/Classes/Linktype/LinkHandler.php
typo3/sysext/linkvalidator/Classes/Linktype/LinktypeInterface.php
typo3/sysext/linkvalidator/Classes/Report/LinkValidatorReport.php
typo3/sysext/linkvalidator/Classes/Task/ValidatorTask.php
typo3/sysext/linkvalidator/Classes/Task/ValidatorTaskAdditionalFieldProvider.php
typo3/sysext/linkvalidator/Resources/Private/Language/Module/locallang.xlf
typo3/sysext/linkvalidator/Resources/Private/Styles/styles.less [new file with mode: 0644]
typo3/sysext/linkvalidator/Resources/Private/Templates/mod_template.html
typo3/sysext/linkvalidator/Resources/Public/Css/linkvalidator.css [deleted file]
typo3/sysext/linkvalidator/Resources/Public/JavaScript/Linkvalidator.js [new file with mode: 0644]
typo3/sysext/linkvalidator/Resources/Public/Styles/styles.css [new file with mode: 0644]

index 2e5d2d5..22efe4d 100644 (file)
@@ -15,6 +15,9 @@ namespace TYPO3\CMS\Linkvalidator;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Html\HtmlParser;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
 
 /**
  * This class provides Processing plugin implementation
@@ -98,11 +101,11 @@ class LinkAnalyzer {
         * Fill hookObjectsArr with different link types and possible XClasses.
         */
        public function __construct() {
-               $GLOBALS['LANG']->includeLLFile('EXT:linkvalidator/Resources/Private/Language/Module/locallang.xlf');
+               $this->getLanguageService()->includeLLFile('EXT:linkvalidator/Resources/Private/Language/Module/locallang.xlf');
                // Hook to handle own checks
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $key => $classRef) {
-                               $this->hookObjectsArr[$key] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
+                               $this->hookObjectsArr[$key] = GeneralUtility::getUserObj($classRef);
                        }
                }
        }
@@ -133,7 +136,7 @@ class LinkAnalyzer {
                if (count($checkOptions) > 0) {
                        $checkKeys = array_keys($checkOptions);
                        $checkLinkTypeCondition = ' AND link_type IN (\'' . implode('\',\'', $checkKeys) . '\')';
-                       $GLOBALS['TYPO3_DB']->exec_DELETEquery(
+                       $this->getDatabaseConnection()->exec_DELETEquery(
                                'tx_linkvalidator_link',
                                '(record_pid IN (' . $this->pidList . ')' .
                                        ' OR ( record_uid IN (' . $this->pidList . ') AND table_name like \'pages\'))' .
@@ -157,14 +160,14 @@ class LinkAnalyzer {
                                // Re-init selectFields for table
                                $selectFields = 'uid, pid';
                                $selectFields .= ', ' . $GLOBALS['TCA'][$table]['ctrl']['label'] . ', ' . implode(', ', $fields);
-                               // @todo only select rows that have content in at least one of the relevant fields (via OR)
-                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selectFields, $table, $where);
-                               // Get record rows of table
-                               while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) !== FALSE) {
-                                       // Analyse each record
-                                       $this->analyzeRecord($results, $table, $fields, $row);
+
+                               // @todo #64091: only select rows that have content in at least one of the relevant fields (via OR)
+                               $rows = $this->getDatabaseConnection()->exec_SELECTgetRows($selectFields, $table, $where);
+                               if (!empty($rows)) {
+                                       foreach ($rows as $row) {
+                                               $this->analyzeRecord($results, $table, $fields, $row);
+                                       }
                                }
-                               $GLOBALS['TYPO3_DB']->sql_free_result($res);
                        }
                        foreach ($this->hookObjectsArr as $key => $hookObj) {
                                if (is_array($results[$key]) && empty($checkOptions) || is_array($results[$key]) && $checkOptions[$key]) {
@@ -198,15 +201,15 @@ class LinkAnalyzer {
                                                        $record['link_type'] = $key;
                                                        $record['url'] = $url;
                                                        $record['url_response'] = serialize($response);
-                                                       $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_linkvalidator_link', $record);
-                                               } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('showalllinks')) {
+                                                       $this->getDatabaseConnection()->exec_INSERTquery('tx_linkvalidator_link', $record);
+                                               } elseif (GeneralUtility::_GP('showalllinks')) {
                                                        $response = array();
                                                        $response['valid'] = TRUE;
                                                        $this->brokenLinkCounts[$table]++;
                                                        $record['url'] = $url;
                                                        $record['link_type'] = $key;
                                                        $record['url_response'] = serialize($response);
-                                                       $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_linkvalidator_link', $record);
+                                                       $this->getDatabaseConnection()->exec_INSERTquery('tx_linkvalidator_link', $record);
                                                }
                                        }
                                }
@@ -226,8 +229,8 @@ class LinkAnalyzer {
        public function analyzeRecord(array &$results, $table, array $fields, array $record) {
                // Put together content of all relevant fields
                $haystack = '';
-               /** @var $htmlParser \TYPO3\CMS\Core\Html\HtmlParser */
-               $htmlParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Html\HtmlParser::class);
+               /** @var $htmlParser HtmlParser */
+               $htmlParser = GeneralUtility::makeInstance(HtmlParser::class);
                $idRecord = $record['uid'];
                // Get all references
                foreach ($fields as $field) {
@@ -310,7 +313,7 @@ class LinkAnalyzer {
         *
         * @param array $resultArray findRef parsed records
         * @param array $results Array of broken links
-        * @param \TYPO3\CMS\Core\Html\HtmlParser $htmlParser Instance of html parser
+        * @param HtmlParser $htmlParser Instance of html parser
         * @param array $record The current record
         * @param string $field The current field
         * @param string $table The current table
@@ -322,7 +325,8 @@ class LinkAnalyzer {
                $idRecord = $record['uid'];
                $type = '';
                $title = '';
-               for ($i = 1; $i < count($linkTags); $i += 2) {
+               $countLinkTags = count($linkTags);
+               for ($i = 1; $i < $countLinkTags; $i += 2) {
                        $referencedRecordType = '';
                        foreach ($resultArray['elements'] as $element) {
                                $type = '';
@@ -376,17 +380,19 @@ class LinkAnalyzer {
                        $this->pidList = $curPage;
                }
                $this->pidList = rtrim($this->pidList, ',');
-               if (($res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+
+               $rows = $this->getDatabaseConnection()->exec_SELECTgetRows(
                        'count(uid) as nbBrokenLinks,link_type',
                        'tx_linkvalidator_link',
-                       'record_pid in (' . $this->pidList . ')', 'link_type')
-               )) {
-                       while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) !== FALSE) {
+                       'record_pid in (' . $this->pidList . ')',
+                       'link_type'
+               );
+               if (!empty($rows)) {
+                       foreach ($rows as $row) {
                                $markerArray[$row['link_type']] = $row['nbBrokenLinks'];
                                $markerArray['brokenlinkCount'] += $row['nbBrokenLinks'];
                        }
                }
-               $GLOBALS['TYPO3_DB']->sql_free_result($res);
                return $markerArray;
        }
 
@@ -411,20 +417,22 @@ class LinkAnalyzer {
                $id = (int)$id;
                $theList = '';
                if ($depth > 0) {
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                       $rows = $this->getDatabaseConnection()->exec_SELECTgetRows(
                                'uid,title,hidden,extendToSubpages',
-                               'pages', 'pid=' . $id . ' AND deleted=0 AND ' . $permsClause
+                               'pages',
+                               'pid=' . $id . ' AND deleted=0 AND ' . $permsClause
                        );
-                       while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) !== FALSE) {
-                               if ($begin <= 0 && ($row['hidden'] == 0 || $considerHidden == 1)) {
-                                       $theList .= $row['uid'] . ',';
-                                       $this->extPageInTreeInfo[] = array($row['uid'], htmlspecialchars($row['title'], $depth));
-                               }
-                               if ($depth > 1 && (!($row['hidden'] == 1 && $row['extendToSubpages'] == 1) || $considerHidden == 1)) {
-                                       $theList .= $this->extGetTreeList($row['uid'], $depth - 1, $begin - 1, $permsClause, $considerHidden);
+                       if (!empty($rows)) {
+                               foreach ($rows as $row) {
+                                       if ($begin <= 0 && ($row['hidden'] == 0 || $considerHidden)) {
+                                               $theList .= $row['uid'] . ',';
+                                               $this->extPageInTreeInfo[] = array($row['uid'], htmlspecialchars($row['title'], $depth));
+                                       }
+                                       if ($depth > 1 && (!($row['hidden'] == 1 && $row['extendToSubpages'] == 1) || $considerHidden)) {
+                                               $theList .= $this->extGetTreeList($row['uid'], $depth - 1, $begin - 1, $permsClause, $considerHidden);
+                                       }
                                }
                        }
-                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
                }
                return $theList;
        }
@@ -441,16 +449,32 @@ class LinkAnalyzer {
                        $hidden = TRUE;
                } else {
                        if ($pageInfo['pid'] > 0) {
-                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,title,hidden,extendToSubpages', 'pages', 'uid=' . $pageInfo['pid']);
-                               while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) !== FALSE) {
-                                       $hidden = $this->getRootLineIsHidden($row);
+                               $rows = $this->getDatabaseConnection()->exec_SELECTgetRows(
+                                       'uid,title,hidden,extendToSubpages',
+                                       'pages',
+                                       'uid=' . $pageInfo['pid']
+                               );
+                               if (!empty($rows)) {
+                                       foreach ($rows as $row) {
+                                               $hidden = $this->getRootLineIsHidden($row);
+                                       }
                                }
-                               $GLOBALS['TYPO3_DB']->sql_free_result($res);
-                       } else {
-                               $hidden = FALSE;
                        }
                }
                return $hidden;
        }
 
+       /**
+        * @return \TYPO3\CMS\Core\Database\DatabaseConnection
+        */
+       protected function getDatabaseConnection() {
+               return $GLOBALS['TYPO3_DB'];
+       }
+
+       /**
+        * @return LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
 }
index ed1674f..e026d42 100644 (file)
@@ -13,13 +13,14 @@ namespace TYPO3\CMS\Linkvalidator\Linktype;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Lang\LanguageService;
 
 /**
  * This class provides Check Base plugin implementation
  *
  * @author Michael Miousse <michael.miousse@infoglobe.ca>
  */
-abstract class AbstractLinktype implements \TYPO3\CMS\Linkvalidator\Linktype\LinktypeInterface {
+abstract class AbstractLinktype implements LinktypeInterface {
 
        /**
         * Contains parameters needed for the rendering of the error message
@@ -72,4 +73,17 @@ abstract class AbstractLinktype implements \TYPO3\CMS\Linkvalidator\Linktype\Lin
                return $row['url'];
        }
 
+       /**
+        * @return LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
+       /**
+        * @return \TYPO3\CMS\Core\Database\DatabaseConnection
+        */
+       protected function getDatabaseConnection() {
+               return $GLOBALS['TYPO3_DB'];
+       }
 }
index f488074..177988d 100644 (file)
@@ -14,6 +14,9 @@ namespace TYPO3\CMS\Linkvalidator\Linktype;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Http\HttpRequest;
+
 /**
  * This class provides Check External Links plugin implementation
  *
@@ -21,7 +24,7 @@ namespace TYPO3\CMS\Linkvalidator\Linktype;
  * @author Michael Miousse <michael.miousse@infoglobe.ca>
  * @author Philipp Gampe <typo3.dev@philippgampe.info>
  */
-class ExternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype {
+class ExternalLinktype extends AbstractLinktype {
 
        /**
         * Cached list of the URLs, which were already checked for the current processing
@@ -67,8 +70,8 @@ class ExternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
                        'follow_redirects' => TRUE,
                        'strict_redirects' => TRUE
                );
-               /** @var $request \TYPO3\CMS\Core\Http\HttpRequest */
-               $request = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Http\HttpRequest::class, $url, 'HEAD', $config);
+               /** @var $request HttpRequest */
+               $request = GeneralUtility::makeInstance(HttpRequest::class, $url, 'HEAD', $config);
                // Observe cookies
                $request->setCookieJar(TRUE);
                try {
@@ -123,28 +126,29 @@ class ExternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
         * @return string Validation error message
         */
        public function getErrorMessage($errorParams) {
+               $lang = $this->getLanguageService();
                $errorType = $errorParams['errorType'];
                switch ($errorType) {
                        case 300:
-                               $response = sprintf($GLOBALS['LANG']->getLL('list.report.externalerror'), $errorType);
-                       break;
+                               $response = sprintf($lang->getLL('list.report.externalerror'), $errorType);
+                               break;
                        case 403:
-                               $response = $GLOBALS['LANG']->getLL('list.report.pageforbidden403');
-                       break;
+                               $response = $lang->getLL('list.report.pageforbidden403');
+                               break;
                        case 404:
-                               $response = $GLOBALS['LANG']->getLL('list.report.pagenotfound404');
-                       break;
+                               $response = $lang->getLL('list.report.pagenotfound404');
+                               break;
                        case 500:
-                               $response = $GLOBALS['LANG']->getLL('list.report.internalerror500');
-                       break;
+                               $response = $lang->getLL('list.report.internalerror500');
+                               break;
                        case 'loop':
-                               $response = sprintf($GLOBALS['LANG']->getLL('list.report.redirectloop'), $errorParams['errorCode'], $errorParams['location']);
-                       break;
+                               $response = sprintf($lang->getLL('list.report.redirectloop'), $errorParams['errorCode'], $errorParams['location']);
+                               break;
                        case 'exception':
-                               $response = sprintf($GLOBALS['LANG']->getLL('list.report.httpexception'), $errorParams['message']);
-                       break;
+                               $response = sprintf($lang->getLL('list.report.httpexception'), $errorParams['message']);
+                               break;
                        default:
-                               $response = sprintf($GLOBALS['LANG']->getLL('list.report.otherhttpcode'), $errorType, $errorParams['message']);
+                               $response = sprintf($lang->getLL('list.report.otherhttpcode'), $errorType, $errorParams['message']);
                }
                return $response;
        }
index 7f10346..3b7fc8b 100644 (file)
@@ -14,13 +14,15 @@ namespace TYPO3\CMS\Linkvalidator\Linktype;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * This class provides Check File Links plugin implementation
  *
  * @author Dimitri König <dk@cabag.ch>
  * @author Michael Miousse <michael.miousse@infoglobe.ca>
  */
-class FileLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype {
+class FileLinktype extends AbstractLinktype {
 
        /**
         * Checks a given URL + /path/filename.ext for validity
@@ -31,10 +33,7 @@ class FileLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype {
         * @return bool TRUE on success or FALSE on error
         */
        public function checkLink($url, $softRefEntry, $reference) {
-               if (!@file_exists((PATH_site . rawurldecode($url)))) {
-                       return FALSE;
-               }
-               return TRUE;
+               return @file_exists(PATH_site . rawurldecode($url));
        }
 
        /**
@@ -44,8 +43,7 @@ class FileLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype {
         * @return string Validation error message
         */
        public function getErrorMessage($errorParams) {
-               $response = $GLOBALS['LANG']->getLL('list.report.filenotexisting');
-               return $response;
+               return $this->getLanguageService()->getLL('list.report.filenotexisting');
        }
 
        /**
@@ -55,8 +53,7 @@ class FileLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype {
         * @return string Parsed broken url
         */
        public function getBrokenUrl($row) {
-               $brokenUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $row['url'];
-               return $brokenUrl;
+               return GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $row['url'];
        }
 
 }
index c15a0cb..3427386 100644 (file)
@@ -14,13 +14,16 @@ namespace TYPO3\CMS\Linkvalidator\Linktype;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Backend\Utility\BackendUtility;
+
 /**
  * This class provides Check Internal Links plugin implementation
  *
  * @author Dimitri König <dk@cabag.ch>
  * @author Michael Miousse <michael.miousse@infoglobe.ca>
  */
-class InternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype {
+class InternalLinktype extends AbstractLinktype {
 
        /**
         * @var string
@@ -43,13 +46,6 @@ class InternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
        const NOTEXISTING = 'notExisting';
 
        /**
-        * All parameters needed for rendering the error message
-        *
-        * @var array
-        */
-       protected $errorParams = array();
-
-       /**
         * Result of the check, if the current page uid is valid or not
         *
         * @var bool
@@ -96,17 +92,14 @@ class InternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
                        // Check if the content element is OK
                        $this->responseContent = $this->checkContent($page, $anchor);
                }
-               if (is_array($this->errorParams['page']) && !$this->responsePage
+               if (
+                       is_array($this->errorParams['page']) && !$this->responsePage
                        || is_array($this->errorParams['content']) && !$this->responseContent
                ) {
                        $this->setErrorParams($this->errorParams);
                }
-               if ($this->responsePage === TRUE && $this->responseContent === TRUE) {
-                       $response = TRUE;
-               } else {
-                       $response = FALSE;
-               }
-               return $response;
+
+               return ($this->responsePage && $this->responseContent);
        }
 
        /**
@@ -116,7 +109,7 @@ class InternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
         * @return bool TRUE on success or FALSE on error
         */
        protected function checkPage($page) {
-               $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid, title, deleted, hidden, starttime, endtime', 'pages', 'uid = ' . (int)$page);
+               $row = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('uid, title, deleted, hidden, starttime, endtime', 'pages', 'uid = ' . (int)$page);
                $this->responsePage = TRUE;
                if ($row) {
                        if ($row['deleted'] == '1') {
@@ -147,7 +140,11 @@ class InternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
         */
        protected function checkContent($page, $anchor) {
                // Get page ID on which the content element in fact is located
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid, pid, header, deleted, hidden, starttime, endtime', 'tt_content', 'uid = ' . (int)$anchor);
+               $res = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
+                       'uid, pid, header, deleted, hidden, starttime, endtime',
+                       'tt_content',
+                       'uid = ' . (int)$anchor
+               );
                $this->responseContent = TRUE;
                // this content element exists
                if ($res) {
@@ -191,6 +188,7 @@ class InternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
         * @return string Validation error message
         */
        public function getErrorMessage($errorParams) {
+               $lang = $this->getLanguageService();
                $errorType = $errorParams['errorType'];
                if (is_array($errorParams['page'])) {
                        switch ($errorType['page']) {
@@ -204,9 +202,9 @@ class InternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
                                                        $errorParams['page']['title'],
                                                        $errorParams['page']['uid']
                                                ),
-                                               $GLOBALS['LANG']->getLL('list.report.pagedeleted')
+                                               $lang->getLL('list.report.pagedeleted')
                                        );
-                               break;
+                                       break;
                                case self::HIDDEN:
                                        $errorPage = str_replace(
                                                array(
@@ -217,14 +215,14 @@ class InternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
                                                        $errorParams['page']['title'],
                                                        $errorParams['page']['uid']
                                                ),
-                                               $GLOBALS['LANG']->getLL('list.report.pagenotvisible')
+                                               $lang->getLL('list.report.pagenotvisible')
                                        );
-                               break;
+                                       break;
                                default:
                                        $errorPage = str_replace(
                                                '###uid###',
                                                $errorParams['page']['uid'],
-                                               $GLOBALS['LANG']->getLL('list.report.pagenotexisting')
+                                               $lang->getLL('list.report.pagenotexisting')
                                        );
                        }
                }
@@ -240,9 +238,9 @@ class InternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
                                                        $errorParams['content']['title'],
                                                        $errorParams['content']['uid']
                                                ),
-                                               $GLOBALS['LANG']->getLL('list.report.contentdeleted')
+                                               $lang->getLL('list.report.contentdeleted')
                                        );
-                               break;
+                                       break;
                                case self::HIDDEN:
                                        $errorContent = str_replace(
                                                array(
@@ -253,9 +251,9 @@ class InternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
                                                        $errorParams['content']['title'],
                                                        $errorParams['content']['uid']
                                                ),
-                                               $GLOBALS['LANG']->getLL('list.report.contentnotvisible')
+                                               $lang->getLL('list.report.contentnotvisible')
                                        );
-                               break;
+                                       break;
                                case self::MOVED:
                                        $errorContent = str_replace(
                                                array(
@@ -270,11 +268,11 @@ class InternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
                                                        $errorParams['content']['wrongPage'],
                                                        $errorParams['content']['rightPage']
                                                ),
-                                               $GLOBALS['LANG']->getLL('list.report.contentmoved')
+                                               $lang->getLL('list.report.contentmoved')
                                        );
-                               break;
+                                       break;
                                default:
-                                       $errorContent = str_replace('###uid###', $errorParams['content']['uid'], $GLOBALS['LANG']->getLL('list.report.contentnotexisting'));
+                                       $errorContent = str_replace('###uid###', $errorParams['content']['uid'], $lang->getLL('list.report.contentnotexisting'));
                        }
                }
                if (isset($errorPage) && isset($errorContent)) {
@@ -285,7 +283,7 @@ class InternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
                        $response = $errorContent;
                } else {
                        // This should not happen
-                       $response = $GLOBALS['LANG']->getLL('list.report.noinformation');
+                       $response = $lang->getLL('list.report.noinformation');
                }
                return $response;
        }
@@ -297,12 +295,12 @@ class InternalLinktype extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktyp
         * @return string Parsed broken url
         */
        public function getBrokenUrl($row) {
-               $domain = rtrim(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL'), '/');
-               $rootLine = \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($row['record_pid']);
+               $domain = rtrim(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'), '/');
+               $rootLine = BackendUtility::BEgetRootLine($row['record_pid']);
                // checks alternate domains
                if (count($rootLine) > 0) {
-                       $protocol = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://';
-                       $domainRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::firstDomainRecord($rootLine);
+                       $protocol = GeneralUtility::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://';
+                       $domainRecord = BackendUtility::firstDomainRecord($rootLine);
                        if (!empty($domainRecord)) {
                                $domain = $protocol . $domainRecord;
                        }
index a4ac102..d2be5d5 100644 (file)
@@ -15,7 +15,7 @@ namespace TYPO3\CMS\Linkvalidator\Linktype;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * This class provides Check Link Handler plugin implementation
@@ -23,7 +23,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  * @author Dimitri König <dk@cabag.ch>
  * @author Michael Miousse <michael.miousse@infoglobe.ca>
  */
-class LinkHandler extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype {
+class LinkHandler extends AbstractLinktype {
 
        /**
         * @var string
@@ -116,7 +116,7 @@ class LinkHandler extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype {
         * @return string fetched type
         */
        public function fetchType($value, $type, $key) {
-               if ($value['type'] === 'string' && GeneralUtility::isFirstPartOfStr(strtolower($value['tokenValue']), 'record:')) {
+               if ($value['type'] === 'string' && StringUtility::beginsWith(strtolower($value['tokenValue']), 'record:')) {
                        $type = 'linkhandler';
                }
                return $type;
@@ -132,13 +132,13 @@ class LinkHandler extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype {
                $errorType = $errorParams['errorType'];
                $tableName = $errorParams['tablename'];
                if (!empty($GLOBALS['TCA'][$tableName]['ctrl']['title'])) {
-                       $title = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tableName]['ctrl']['title'], TRUE);
+                       $title = $this->getLanguageService()->sL($GLOBALS['TCA'][$tableName]['ctrl']['title'], TRUE);
                } else {
                        $title = $tableName;
                }
                switch ($errorType) {
                        case self::DISABLED:
-                               $response = $GLOBALS['LANG']->getLL('list.report.rownotvisible');
+                               $response = $this->getLanguageService()->getLL('list.report.rownotvisible');
                                $response = str_replace('###title###', $title, $response);
                                $response = str_replace('###uid###', $errorParams['uid'], $response);
                                break;
@@ -152,11 +152,11 @@ class LinkHandler extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype {
                                                $title,
                                                $errorParams['uid']
                                        ),
-                                       $GLOBALS['LANG']->getLL('list.report.rowdeleted')
+                                       $this->getLanguageService()->getLL('list.report.rowdeleted')
                                );
                                break;
                        default:
-                               $response = str_replace('###uid###', $errorParams['uid'], $GLOBALS['LANG']->getLL('list.report.rownotexisting'));
+                               $response = str_replace('###uid###', $errorParams['uid'], $this->getLanguageService()->getLL('list.report.rownotexisting'));
                }
                return $response;
        }
@@ -203,11 +203,4 @@ class LinkHandler extends \TYPO3\CMS\Linkvalidator\Linktype\AbstractLinktype {
                return $row;
        }
 
-       /**
-        * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-        */
-       protected function getDatabaseConnection() {
-               return $GLOBALS['TYPO3_DB'];
-       }
-
 }
index 3f245a3..32e3cb7 100644 (file)
@@ -20,6 +20,7 @@ namespace TYPO3\CMS\Linkvalidator\Linktype;
  * @author Michael Miousse <michael.miousse@infoglobe.ca>
  */
 interface LinktypeInterface {
+
        /**
         * Checks a given link for validity
         *
index 601a898..d1a7ed5 100644 (file)
@@ -14,9 +14,14 @@ namespace TYPO3\CMS\Linkvalidator\Report;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+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\Core\Html\HtmlParser;
+use TYPO3\CMS\Linkvalidator\LinkAnalyzer;
 
 /**
  * Module 'Linkvalidator' for the 'linkvalidator' extension
@@ -27,16 +32,11 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule {
 
        /**
-        * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
+        * @var DocumentTemplate
         */
        public $doc;
 
        /**
-        * @var string
-        */
-       protected $relativePath;
-
-       /**
         * Information about the current page record
         *
         * @var array
@@ -60,9 +60,9 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
        /**
         * Link validation class
         *
-        * @var \TYPO3\CMS\Linkvalidator\LinkAnalyzer
+        * @var LinkAnalyzer
         */
-       protected $processor;
+       protected $linkAnalyzer;
 
        /**
         * TSconfig of the current module
@@ -87,26 +87,12 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
        protected $checkOpt = array();
 
        /**
-        * Html for the button "Check Links"
-        *
-        * @var string
-        */
-       protected $updateListHtml;
-
-       /**
-        * Html for the button "Refresh Display"
-        *
-        * @var string
-        */
-       protected $refreshListHtml;
-
-       /**
         * Html for the statistics table with the checkboxes of the link types
         * and the numbers of broken links for report tab
         *
         * @var string
         */
-       protected $checkOptHtml;
+       protected $checkOptionsHtml;
 
        /**
         * Html for the statistics table with the checkboxes of the link types
@@ -114,7 +100,7 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
         *
         * @var string
         */
-       protected $checkOptHtmlCheck;
+       protected $checkOptionsHtmlCheck;
 
        /**
         * Complete content (html) to be displayed
@@ -124,19 +110,19 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
        protected $content;
 
        /**
-        * @var \TYPO3\CMS\Core\Page\PageRenderer
+        * @var \TYPO3\CMS\Linkvalidator\Linktype\LinktypeInterface[]
         */
-       protected $pageRenderer;
+       protected $hookObjectsArr = array();
 
        /**
-        * @var \TYPO3\CMS\Linkvalidator\Linktype\LinktypeInterface[]
+        * @var string
         */
-       protected $hookObjectsArr = array();
+       protected $updateListHtml = '';
 
        /**
-        * @var string $checkAllHtml
+        * @var string
         */
-       protected $checkAllHtml = '';
+       protected $refreshListHtml = '';
 
        /**
         * Main method of modfuncreport
@@ -144,7 +130,7 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
         * @return string Module content
         */
        public function main() {
-               $GLOBALS['LANG']->includeLLFile('EXT:linkvalidator/Resources/Private/Language/Module/locallang.xlf');
+               $this->getLanguageService()->includeLLFile('EXT:linkvalidator/Resources/Private/Language/Module/locallang.xlf');
                $this->searchLevel = GeneralUtility::_GP('search_levels');
                if (isset($this->pObj->id)) {
                        $this->modTS = BackendUtility::getModTSconfig($this->pObj->id, 'mod.linkvalidator');
@@ -178,102 +164,56 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                                }
                        }
                }
-               $GLOBALS['BE_USER']->pushModuleData('web_info', $this->pObj->MOD_SETTINGS);
+               $this->getBackendUser()->pushModuleData('web_info', $this->pObj->MOD_SETTINGS);
                $this->initialize();
 
                // Localization
-               $this->pageRenderer->addInlineLanguageLabelFile(
-                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('linkvalidator', 'Resources/Private/Language/Module/locallang.xlf')
+               $this->doc->getPageRenderer()->addInlineLanguageLabelFile(
+                       ExtensionManagementUtility::extPath('linkvalidator', 'Resources/Private/Language/Module/locallang.xlf')
                );
-               $this->pageRenderer->addJsInlineCode('linkvalidator', 'function toggleActionButton(prefix) {
-                       var buttonDisable = true;
-                       Ext.select(\'.\' + prefix ,false).each(function(checkBox,i){
-                       checkDom = checkBox.dom;
-                       if (checkDom.checked){
-                               buttonDisable = false;
-                       }
 
-                       });
-                       if (prefix == \'check\'){
-                               checkSub = document.getElementById(\'updateLinkList\');
-                       } else {
-                               checkSub = document.getElementById(\'refreshLinkList\');
-                       }
-                       checkSub.disabled = buttonDisable;
-               }');
-               // Add JS
-               $this->pageRenderer->addJsFile($this->doc->backPath . 'js/extjs/ux/Ext.ux.FitToParent.js');
-               $this->pageRenderer->addJsFile($this->doc->backPath . 'sysext/backend/Resources/Public/JavaScript/iframepanel.js');
                if ($this->modTS['showCheckLinkTab'] == 1) {
-                       $this->updateListHtml = '<input type="submit" name="updateLinkList" id="updateLinkList" value="' . $GLOBALS['LANG']->getLL('label_update') . '"/>';
+                       $this->updateListHtml = '<input type="submit" name="updateLinkList" id="updateLinkList" value="' . $this->getLanguageService()->getLL('label_update') . '"/>';
                }
-               $this->refreshListHtml = '<input type="submit" name="refreshLinkList" id="refreshLinkList" value="' . $GLOBALS['LANG']->getLL('label_refresh') . '"/>';
-               $this->processor = GeneralUtility::makeInstance(\TYPO3\CMS\Linkvalidator\LinkAnalyzer::class);
+               $this->refreshListHtml = '<input type="submit" name="refreshLinkList" id="refreshLinkList" value="' . $this->getLanguageService()->getLL('label_refresh') . '"/>';
+               $this->linkAnalyzer = GeneralUtility::makeInstance(LinkAnalyzer::class);
                $this->updateBrokenLinks();
-               $brokenLinkOverView = $this->processor->getLinkCounts($this->pObj->id);
-               $this->checkOptHtml = $this->getCheckOptions($brokenLinkOverView);
-               $this->checkOptHtmlCheck = $this->getCheckOptions($brokenLinkOverView, 'check');
-               $this->createTabs();
 
-               $content = '';
+               $brokenLinkOverView = $this->linkAnalyzer->getLinkCounts($this->pObj->id);
+               $this->checkOptionsHtml = $this->getCheckOptions($brokenLinkOverView);
+               $this->checkOptionsHtmlCheck = $this->getCheckOptions($brokenLinkOverView, 'check');
+               $this->render();
+
+               $pageTile = '';
                if ($this->pObj->id) {
                        $pageRecord = BackendUtility::getRecord('pages', $this->pObj->id);
-                       $content = '<h1>' . htmlspecialchars(BackendUtility::getRecordTitle('pages', $pageRecord)) . '</h1>';
+                       $pageTile = '<h1>' . htmlspecialchars(BackendUtility::getRecordTitle('pages', $pageRecord)) . '</h1>';
                }
 
-               $content .= '<div id="linkvalidator-modfuncreport"></div>';
-               return $content;
+               return '<div id="linkvalidator-modfuncreport">' . $pageTile . $this->createTabs() . '</div>';
        }
 
        /**
-        * Create TabPanel to split the report and the checkLink functions
+        * Create tabs to split the report and the checkLink functions
         *
-        * @return void
+        * @return string
         */
        protected function createTabs() {
-               $panelCheck = '';
-               if ($this->modTS['showCheckLinkTab'] == 1) {
-                       $panelCheck = ',
-                       {
-                               title: TYPO3.l10n.localize(\'CheckLink\'),
-                               html: ' . json_encode($this->flush()) . ',
-                       }';
-               }
-               $this->render();
-               $js = 'var panel = new Ext.TabPanel( {
-                       renderTo: \'linkvalidator-modfuncreport\',
-                       id: \'linkvalidator-main\',
-                       plain: true,
-                       activeTab: 0,
-                       bodyStyle: \'padding:10px;\',
-                       items : [
-                       {
-                               autoHeight: true,
-                               title: TYPO3.l10n.localize(\'Report\'),
-                               html: ' . json_encode($this->flush(TRUE)) . '
-                       }' . $panelCheck . '
-                       ]
-
-               });
-               ';
-               $this->pageRenderer->addExtOnReadyCode($js);
-       }
-
-       /**
-        * Initializes the menu array internally
-        *
-        * @return array Module menu
-        */
-       public function modMenu() {
-               $modMenu = array(
-                       'checkAllLink' => 0
+               $menuItems = array(
+                       0 => array(
+                               'label' => $this->getLanguageService()->getLL('Report'),
+                               'content' => $this->flush(TRUE)
+                       ),
                );
-               if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
-                       foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $linkType => $value) {
-                               $modMenu[$linkType] = 1;
-                       }
+
+               if ((bool)$this->modTS['showCheckLinkTab']) {
+                       $menuItems[1] = array(
+                               'label' => $this->getLanguageService()->getLL('CheckLink'),
+                               'content' => $this->flush()
+                       );
                }
-               return $modMenu;
+
+               return $this->doc->getDynTabMenu($menuItems, 'ident');
        }
 
        /**
@@ -287,19 +227,22 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                                $this->hookObjectsArr[$linkType] = GeneralUtility::getUserObj($classRef);
                        }
                }
-               $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
+
+               $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
                $this->doc->backPath = $GLOBALS['BACK_PATH'];
-               $this->doc->setModuleTemplate(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('linkvalidator') . 'Resources/Private/Templates/mod_template.html');
-               $this->relativePath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('linkvalidator');
-               $this->pageRecord = BackendUtility::readPageAccess($this->pObj->id, $GLOBALS['BE_USER']->getPagePermsClause(1));
-               $this->pageRenderer = $this->doc->getPageRenderer();
-               $this->isAccessibleForCurrentUser = FALSE;
+               $this->doc->setModuleTemplate('EXT:linkvalidator/Resources/Private/Templates/mod_template.html');
+
+               $this->pageRecord = BackendUtility::readPageAccess($this->pObj->id, $this->getBackendUser()->getPagePermsClause(1));
                if ($this->pObj->id && is_array($this->pageRecord) || !$this->pObj->id && $this->isCurrentUserAdmin()) {
                        $this->isAccessibleForCurrentUser = TRUE;
                }
-               $this->loadHeaderData();
+
+               $this->doc->addStyleSheet('module', 'sysext/linkvalidator/Resources/Public/Styles/styles.css');
+               $this->doc->getPageRenderer()->loadJquery();
+               $this->doc->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Linkvalidator/Linkvalidator');
+
                // Don't access in workspace
-               if ($GLOBALS['BE_USER']->workspace !== 0) {
+               if ($this->getBackendUser()->workspace !== 0) {
                        $this->isAccessibleForCurrentUser = FALSE;
                }
        }
@@ -313,25 +256,33 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                $searchFields = array();
                // Get the searchFields from TypoScript
                foreach ($this->modTS['searchFields.'] as $table => $fieldList) {
-                       $fields = GeneralUtility::trimExplode(',', $fieldList);
+                       $fields = GeneralUtility::trimExplode(',', $fieldList, TRUE);
                        foreach ($fields as $field) {
-                               if (!$searchFields || !is_array($searchFields[$table]) || array_search($field, $searchFields[$table]) == FALSE) {
+                               if (!$searchFields || !is_array($searchFields[$table]) || array_search($field, $searchFields[$table]) === FALSE) {
                                        $searchFields[$table][] = $field;
                                }
                        }
                }
-               $rootLineHidden = $this->processor->getRootLineIsHidden($this->pObj->pageinfo);
+               $rootLineHidden = $this->linkAnalyzer->getRootLineIsHidden($this->pObj->pageinfo);
                if (!$rootLineHidden || $this->modTS['checkhidden'] == 1) {
                        // Get children pages
-                       $pageList = $this->processor->extGetTreeList($this->pObj->id, $this->searchLevel, 0, $GLOBALS['BE_USER']->getPagePermsClause(1), $this->modTS['checkhidden']);
-                       if ($this->pObj->pageinfo['hidden'] == 0 || $this->modTS['checkhidden'] == 1) {
+                       $pageList = $this->linkAnalyzer->extGetTreeList(
+                               $this->pObj->id,
+                               $this->searchLevel,
+                               0,
+                               $this->getBackendUser()->getPagePermsClause(1),
+                               $this->modTS['checkhidden']
+                       );
+                       if ($this->pObj->pageinfo['hidden'] == 0 || $this->modTS['checkhidden']) {
                                $pageList .= $this->pObj->id;
                        }
-                       $this->processor->init($searchFields, $pageList, $this->modTS);
+
+                       $this->linkAnalyzer->init($searchFields, $pageList, $this->modTS);
+
                        // Check if button press
                        $update = GeneralUtility::_GP('updateLinkList');
                        if (!empty($update)) {
-                               $this->processor->getLinkStatistics($this->checkOpt, $this->modTS['checkhidden']);
+                               $this->linkAnalyzer->getLinkStatistics($this->checkOpt, $this->modTS['checkhidden']);
                        }
                }
        }
@@ -349,8 +300,8 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                        /** @var FlashMessage $message */
                        $message = GeneralUtility::makeInstance(
                                FlashMessage::class,
-                               $GLOBALS['LANG']->getLL('no.access'),
-                               $GLOBALS['LANG']->getLL('no.access.title'),
+                               $this->getLanguageService()->getLL('no.access'),
+                               $this->getLanguageService()->getLL('no.access.title'),
                                FlashMessage::ERROR
                        );
                        $this->content .= $message->render();
@@ -364,12 +315,11 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
         * @return string $content
         */
        protected function flush($form = FALSE) {
-               $content = $this->doc->moduleBody(
+               return $this->doc->moduleBody(
                        $this->pageRecord,
                        $this->getDocHeaderButtons(),
                        $form ? $this->getTemplateMarkers() : $this->getTemplateMarkersCheck()
                );
-               return $content;
        }
 
        /**
@@ -379,19 +329,18 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
         */
        protected function getLevelSelector() {
                // Build level selector
-               $opt = array();
-               $parts = array(
-                       0 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_0'),
-                       1 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_1'),
-                       2 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_2'),
-                       3 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_3'),
-                       999 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_infi')
+               $options = array();
+               $availableOptions = array(
+                       0 => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_0'),
+                       1 => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_1'),
+                       2 => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_2'),
+                       3 => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_3'),
+                       999 => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_infi')
                );
-               foreach ($parts as $kv => $label) {
-                       $opt[] = '<option value="' . $kv . '"' . ($kv == (int)$this->searchLevel ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>';
+               foreach ($availableOptions as $optionValue => $optionLabel) {
+                       $options[] = '<option value="' . $optionValue . '"' . ($optionValue === (int)$this->searchLevel ? ' selected="selected"' : '') . '>' . htmlspecialchars($optionLabel) . '</option>';
                }
-               $lMenu = '<select name="search_levels">' . implode('', $opt) . '</select>';
-               return $lMenu;
+               return '<select name="search_levels">' . implode('', $options) . '</select>';
        }
 
        /**
@@ -400,57 +349,58 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
         * @return string Content of the table or of the note
         */
        protected function renderBrokenLinksTable() {
-               $items = ($brokenLinksMarker = array());
                $brokenLinkItems = '';
-               $brokenLinksTemplate = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($this->doc->moduleTemplate, '###NOBROKENLINKS_CONTENT###');
+               $brokenLinksTemplate = HtmlParser::getSubpart($this->doc->moduleTemplate, '###NOBROKENLINKS_CONTENT###');
                $keyOpt = array();
                if (is_array($this->checkOpt)) {
                        $keyOpt = array_keys($this->checkOpt);
                }
-               $rootLineHidden = $this->processor->getRootLineIsHidden($this->pObj->pageinfo);
-               if (!$rootLineHidden || $this->modTS['checkhidden'] == 1) {
-                       $pageList = $this->processor->extGetTreeList(
+
+               // Table header
+               $brokenLinksMarker = $this->startTable();
+
+               $rootLineHidden = $this->linkAnalyzer->getRootLineIsHidden($this->pObj->pageinfo);
+               if (!$rootLineHidden || (bool)$this->modTS['checkhidden']) {
+                       $pageList = $this->linkAnalyzer->extGetTreeList(
                                $this->pObj->id,
                                $this->searchLevel,
                                0,
-                               $GLOBALS['BE_USER']->getPagePermsClause(1),
+                               $this->getBackendUser()->getPagePermsClause(1),
                                $this->modTS['checkhidden']
                        );
                        // Always add the current page, because we are just displaying the results
                        $pageList .= $this->pObj->id;
-                       if (($res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+
+                       $records = $this->getDatabaseConnection()->exec_SELECTgetRows(
                                '*',
                                'tx_linkvalidator_link',
-                               'record_pid in (' . $pageList . ') and link_type in (\'' . implode('\',\'', $keyOpt) . '\')',
+                               'record_pid IN (' . $pageList . ') AND link_type IN (\'' . implode('\',\'', $keyOpt) . '\')',
                                '',
-                               'record_uid ASC, uid ASC')
-                       )) {
+                               'record_uid ASC, uid ASC'
+                       );
+                       if (!empty($records)) {
                                // Display table with broken links
-                               if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
-                                       $brokenLinksTemplate = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_CONTENT###');
-                                       $brokenLinksItemTemplate = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_ITEM###');
-                                       // Table header
-                                       $brokenLinksMarker = $this->startTable();
-                                       // Table rows containing the broken links
-                                       while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) !== FALSE) {
-                                               $items[] = $this->renderTableRow($row['table_name'], $row, $brokenLinksItemTemplate);
-                                       }
-                                       $brokenLinkItems = implode(LF, $items);
-                               } else {
-                                       $brokenLinksMarker = $this->getNoBrokenLinkMessage($brokenLinksMarker);
+                               $brokenLinksTemplate = HtmlParser::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_CONTENT###');
+                               $brokenLinksItemTemplate = HtmlParser::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_ITEM###');
+
+                               // Table rows containing the broken links
+                               $items = array();
+                               foreach ($records as $record) {
+                                       $items[] = $this->renderTableRow($record['table_name'], $record, $brokenLinksItemTemplate);
                                }
-                               $GLOBALS['TYPO3_DB']->sql_free_result($res);
+                               $brokenLinkItems = implode(LF, $items);
+                       } else {
+                               $brokenLinksMarker = $this->getNoBrokenLinkMessage($brokenLinksMarker);
                        }
                } else {
                        $brokenLinksMarker = $this->getNoBrokenLinkMessage($brokenLinksMarker);
                }
-               $brokenLinksTemplate = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray(
+               $brokenLinksTemplate = HtmlParser::substituteMarkerArray(
                        $brokenLinksTemplate,
                        $brokenLinksMarker, '###|###',
                        TRUE
                );
-               $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart($brokenLinksTemplate, '###BROKENLINKS_ITEM', $brokenLinkItems);
-               return $content;
+               return HtmlParser::substituteSubpart($brokenLinksTemplate, '###BROKENLINKS_ITEM', $brokenLinkItems);
        }
 
        /**
@@ -460,12 +410,12 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
         * @return array $brokenLinksMarker['NO_BROKEN_LINKS] replaced with flashmessage
         */
        protected function getNoBrokenLinkMessage(array $brokenLinksMarker) {
-               $brokenLinksMarker['LIST_HEADER'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header'));
+               $brokenLinksMarker['LIST_HEADER'] = $this->doc->sectionHeader($this->getLanguageService()->getLL('list.header'));
                /** @var $message FlashMessage */
                $message = GeneralUtility::makeInstance(
                        FlashMessage::class,
-                       $GLOBALS['LANG']->getLL('list.no.broken.links'),
-                       $GLOBALS['LANG']->getLL('list.no.broken.links.title'),
+                       $this->getLanguageService()->getLL('list.no.broken.links'),
+                       $this->getLanguageService()->getLL('list.no.broken.links.title'),
                        FlashMessage::OK
                );
                $brokenLinksMarker['NO_BROKEN_LINKS'] = $message->render();
@@ -479,20 +429,21 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
         */
        protected function startTable() {
                // Listing head
-               $makerTableHead = array();
-               $makerTableHead['tablehead_path'] = $GLOBALS['LANG']->getLL('list.tableHead.path');
-               $makerTableHead['tablehead_element'] = $GLOBALS['LANG']->getLL('list.tableHead.element');
-               $makerTableHead['tablehead_headlink'] = $GLOBALS['LANG']->getLL('list.tableHead.headlink');
-               $makerTableHead['tablehead_linktarget'] = $GLOBALS['LANG']->getLL('list.tableHead.linktarget');
-               $makerTableHead['tablehead_linkmessage'] = $GLOBALS['LANG']->getLL('list.tableHead.linkmessage');
-               $makerTableHead['tablehead_lastcheck'] = $GLOBALS['LANG']->getLL('list.tableHead.lastCheck');
+               $makerTableHead = array(
+                       'tablehead_path' => $this->getLanguageService()->getLL('list.tableHead.path'),
+                       'tablehead_element' => $this->getLanguageService()->getLL('list.tableHead.element'),
+                       'tablehead_headlink' => $this->getLanguageService()->getLL('list.tableHead.headlink'),
+                       'tablehead_linktarget' => $this->getLanguageService()->getLL('list.tableHead.linktarget'),
+                       'tablehead_linkmessage' => $this->getLanguageService()->getLL('list.tableHead.linkmessage'),
+                       'tablehead_lastcheck' => $this->getLanguageService()->getLL('list.tableHead.lastCheck'),
+               );
+
                // Add CSH to the header of each column
                foreach ($makerTableHead as $column => $label) {
-                       $label = BackendUtility::wrapInHelp('linkvalidator', $column, $label);
-                       $makerTableHead[$column] = $label;
+                       $makerTableHead[$column] = BackendUtility::wrapInHelp('linkvalidator', $column, $label);
                }
                // Add section header
-               $makerTableHead['list_header'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header'));
+               $makerTableHead['list_header'] = $this->doc->sectionHeader($this->getLanguageService()->getLL('list.header'));
                return $makerTableHead;
        }
 
@@ -509,29 +460,27 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                $fieldName = '';
                // Restore the linktype object
                $hookObj = $this->hookObjectsArr[$row['link_type']];
-               $brokenUrl = $hookObj->getBrokenUrl($row);
+
                // Construct link to edit the content element
-               $params = '&edit[' . $table . '][' . $row['record_uid'] . ']=edit';
                $requestUri = GeneralUtility::getIndpEnv('REQUEST_URI') .
                        '?id=' . $this->pObj->id .
                        '&search_levels=' . $this->searchLevel;
                $actionLink = '<a href="#" onclick="';
                $actionLink .= BackendUtility::editOnClick(
-                       $params,
+                       '&edit[' . $table . '][' . $row['record_uid'] . ']=edit',
                        $GLOBALS['BACK_PATH'],
                        $requestUri
                );
-               $actionLink .= '" title="' . $GLOBALS['LANG']->getLL('list.edit') . '">';
-               $actionLink .= \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-open');
+               $actionLink .= '" title="' . $this->getLanguageService()->getLL('list.edit') . '">';
+               $actionLink .= IconUtility::getSpriteIcon('actions-document-open');
                $actionLink .= '</a>';
                $elementHeadline = $row['headline'];
                if (empty($elementHeadline)) {
-                       $elementHeadline = '<i>' . $GLOBALS['LANG']->getLL('list.no.headline') . '</i>';
+                       $elementHeadline = '<i>' . $this->getLanguageService()->getLL('list.no.headline') . '</i>';
                }
                // Get the language label for the field from TCA
                if ($GLOBALS['TCA'][$table]['columns'][$row['field']]['label']) {
-                       $fieldName = $GLOBALS['TCA'][$table]['columns'][$row['field']]['label'];
-                       $fieldName = $GLOBALS['LANG']->sL($fieldName);
+                       $fieldName = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$row['field']]['label']);
                        // Crop colon from end if present
                        if (substr($fieldName, '-1', '1') === ':') {
                                $fieldName = substr($fieldName, '0', strlen($fieldName) - 1);
@@ -540,31 +489,32 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                // Fallback, if there is no label
                $fieldName = !empty($fieldName) ? $fieldName : $row['field'];
                // column "Element"
-               $element = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord(
+               $element = IconUtility::getSpriteIconForRecord(
                        $table,
                        $row,
                        array('title' => $table . ':' . $row['record_uid'])
                );
                $element .= $elementHeadline;
-               $element .= ' ' . sprintf($GLOBALS['LANG']->getLL('list.field'), $fieldName);
+               $element .= ' ' . sprintf($this->getLanguageService()->getLL('list.field'), $fieldName);
                $markerArray['actionlink'] = $actionLink;
                $markerArray['path'] = BackendUtility::getRecordPath($row['record_pid'], '', 0, 0);
                $markerArray['element'] = $element;
                $markerArray['headlink'] = $row['link_title'];
-               $markerArray['linktarget'] = $brokenUrl;
+               $markerArray['linktarget'] = $hookObj->getBrokenUrl($row);
                $response = unserialize($row['url_response']);
                if ($response['valid']) {
-                       $linkMessage = '<span style="color: green;">' . $GLOBALS['LANG']->getLL('list.msg.ok') . '</span>';
+                       $linkMessage = '<span class="valid">' . $this->getLanguageService()->getLL('list.msg.ok') . '</span>';
                } else {
-                       $linkMessage = '<span style="color: red;">' . $hookObj->getErrorMessage($response['errorParams']) . '</span>';
+                       $linkMessage = '<span class="error">' . $hookObj->getErrorMessage($response['errorParams']) . '</span>';
                }
                $markerArray['linkmessage'] = $linkMessage;
+
                $lastRunDate = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $row['last_check']);
                $lastRunTime = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $row['last_check']);
-               $message = sprintf($GLOBALS['LANG']->getLL('list.msg.lastRun'), $lastRunDate, $lastRunTime);
-               $markerArray['lastcheck'] = $message;
+               $markerArray['lastcheck'] = sprintf($this->getLanguageService()->getLL('list.msg.lastRun'), $lastRunDate, $lastRunTime);
+
                // Return the table html code as string
-               return \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($brokenLinksItemTemplate, $markerArray, '###|###', TRUE, TRUE);
+               return HtmlParser::substituteMarkerArray($brokenLinksItemTemplate, $markerArray, '###|###', TRUE, TRUE);
        }
 
        /**
@@ -576,41 +526,36 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
         */
        protected function getCheckOptions(array $brokenLinkOverView, $prefix = '') {
                $markerArray = array();
-               $additionalAttr = '';
                if (!empty($prefix)) {
-                       $additionalAttr = ' onclick="toggleActionButton(\'' . $prefix . '\');" class="' . $prefix . '" ';
-               } else {
-                       $additionalAttr = ' onclick="toggleActionButton(\'refresh\');" class="refresh" ';
-               }
-               $checkOptionsTemplate = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($this->doc->moduleTemplate, '###CHECKOPTIONS_SECTION###');
-               $hookSectionTemplate = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($checkOptionsTemplate, '###HOOK_SECTION###');
-               $markerArray['statistics_header'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('report.statistics.header'));
-               $totalCountLabel = $GLOBALS['LANG']->getLL('overviews.nbtotal');
-               $totalCountLabel = BackendUtility::wrapInHelp('linkvalidator', 'checkboxes', $totalCountLabel);
-               $markerArray['total_count_label'] = $totalCountLabel;
-               if (empty($brokenLinkOverView['brokenlinkCount'])) {
-                       $markerArray['total_count'] = '0';
+                       $additionalAttr = ' class="' . $prefix . '"';
                } else {
-                       $markerArray['total_count'] = $brokenLinkOverView['brokenlinkCount'];
+                       $additionalAttr = ' class="refresh"';
                }
+               $checkOptionsTemplate = HtmlParser::getSubpart($this->doc->moduleTemplate, '###CHECKOPTIONS_SECTION###');
+               $hookSectionTemplate = HtmlParser::getSubpart($checkOptionsTemplate, '###HOOK_SECTION###');
+               $markerArray['statistics_header'] = $this->doc->sectionHeader($this->getLanguageService()->getLL('report.statistics.header'));
+               $markerArray['total_count_label'] = BackendUtility::wrapInHelp('linkvalidator', 'checkboxes', $this->getLanguageService()->getLL('overviews.nbtotal'));
+               $markerArray['total_count'] = $brokenLinkOverView['brokenlinkCount'] ?: '0';
+
                $linktypes = GeneralUtility::trimExplode(',', $this->modTS['linktypes'], TRUE);
                $hookSectionContent = '';
                if (is_array($linktypes)) {
-                       if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])
-                               && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
+                       if (
+                               !empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])
+                               && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])
+                       ) {
                                foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $type => $value) {
                                        if (in_array($type, $linktypes)) {
-                                               $hookSectionMarker = array();
-                                               if (empty($brokenLinkOverView[$type])) {
-                                                       $hookSectionMarker['count'] = '0';
-                                               } else {
-                                                       $hookSectionMarker['count'] = $brokenLinkOverView[$type];
-                                               }
-                                               $translation = $GLOBALS['LANG']->getLL('hooks.' . $type);
-                                               $translation = $translation ? $translation : $type;
-                                               $option = '<input type="checkbox" ' . $additionalAttr . ' id="' . $prefix . 'SET_' . $type . '" name="' . $prefix . 'SET[' . $type . ']" value="1"' . ($this->pObj->MOD_SETTINGS[$type] ? ' checked="checked"' : '') . '/>' . '<label for="' . $prefix . 'SET[' . $type . ']">' . htmlspecialchars($translation) . '</label>';
-                                               $hookSectionMarker['option'] = $option;
-                                               $hookSectionContent .= \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray(
+                                               $hookSectionMarker = array(
+                                                       'count' => $brokenLinkOverView[$type] ?: '0',
+                                               );
+
+                                               $translation = $this->getLanguageService()->getLL('hooks.' . $type) ?: $type;
+                                               $hookSectionMarker['option'] = '<input type="checkbox"' . $additionalAttr . ' id="' . $prefix . 'SET_' . $type . '" name="' . $prefix
+                                                       . 'SET[' . $type . ']" value="1"' . ($this->pObj->MOD_SETTINGS[$type] ? ' checked="checked"' : '') . '/>' . '<label for="'
+                                                       . $prefix . 'SET[' . $type . ']">' . htmlspecialchars($translation) . '</label>';
+
+                                               $hookSectionContent .= HtmlParser::substituteMarkerArray(
                                                        $hookSectionTemplate,
                                                        $hookSectionMarker, '###|###',
                                                        TRUE,
@@ -620,21 +565,12 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
                                }
                        }
                }
-               $checkOptionsTemplate = \TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart(
+               $checkOptionsTemplate = HtmlParser::substituteSubpart(
                        $checkOptionsTemplate,
-                       '###HOOK_SECTION###', $hookSectionContent
+                       '###HOOK_SECTION###',
+                       $hookSectionContent
                );
-               return \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($checkOptionsTemplate, $markerArray, '###|###', TRUE, TRUE);
-       }
-
-       /**
-        * Loads data in the HTML head section (e.g. JavaScript or stylesheet information)
-        *
-        * @return void
-        */
-       protected function loadHeaderData() {
-               $this->doc->addStyleSheet('linkvalidator', $this->relativePath . 'Resources/Public/Css/linkvalidator.css', 'linkvalidator');
-               $this->pageRenderer->addJsFile($this->doc->backPath . 'js/extjs/ux/Ext.ux.FitToParent.js');
+               return HtmlParser::substituteMarkerArray($checkOptionsTemplate, $markerArray, '###|###', TRUE, TRUE);
        }
 
        /**
@@ -643,12 +579,11 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
         * @return array Available buttons for the docHeader
         */
        protected function getDocHeaderButtons() {
-               $buttons = array(
+               return array(
                        'csh' => BackendUtility::cshItem('_MOD_web_func', ''),
                        'shortcut' => $this->getShortcutButton(),
                        'save' => ''
                );
-               return $buttons;
        }
 
        /**
@@ -658,8 +593,8 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
         */
        protected function getShortcutButton() {
                $result = '';
-               if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
-                       $result = $this->doc->makeShortcutIcon('', 'function', $this->MCONF['name']);
+               if ($this->getBackendUser()->mayMakeShortcut()) {
+                       $result = $this->doc->makeShortcutIcon('', 'function', $this->pObj->MCONF['name']);
                }
                return $result;
        }
@@ -670,18 +605,16 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
         * @return array The filled marker array
         */
        protected function getTemplateMarkers() {
-               $markers = array(
-                       'FUNC_TITLE' => $GLOBALS['LANG']->getLL('report.func.title'),
-                       'CHECKOPTIONS_TITLE' => $GLOBALS['LANG']->getLL('report.statistics.header'),
+               return array(
+                       'FUNC_TITLE' => $this->getLanguageService()->getLL('report.func.title'),
+                       'CHECKOPTIONS_TITLE' => $this->getLanguageService()->getLL('report.statistics.header'),
                        'FUNC_MENU' => $this->getLevelSelector(),
                        'CONTENT' => $this->content,
-                       'CHECKALLLINK' => $this->checkAllHtml,
-                       'CHECKOPTIONS' => $this->checkOptHtml,
+                       'CHECKOPTIONS' => $this->checkOptionsHtml,
                        'ID' => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />',
-                       'REFRESH' => $this->refreshListHtml,
-                       'UPDATE' => ''
+                       'REFRESH' => '<input type="submit" name="refreshLinkList" id="refreshLinkList" value="' . $this->getLanguageService()->getLL('label_refresh') . '" />',
+                       'UPDATE' => '',
                );
-               return $markers;
        }
 
        /**
@@ -690,18 +623,16 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
         * @return array The filled marker array
         */
        protected function getTemplateMarkersCheck() {
-               $markers = array(
-                       'FUNC_TITLE' => $GLOBALS['LANG']->getLL('checklinks.func.title'),
-                       'CHECKOPTIONS_TITLE' => $GLOBALS['LANG']->getLL('checklinks.statistics.header'),
+               return array(
+                       'FUNC_TITLE' => $this->getLanguageService()->getLL('checklinks.func.title'),
+                       'CHECKOPTIONS_TITLE' => $this->getLanguageService()->getLL('checklinks.statistics.header'),
                        'FUNC_MENU' => $this->getLevelSelector(),
                        'CONTENT' => '',
-                       'CHECKALLLINK' => $this->checkAllHtml,
-                       'CHECKOPTIONS' => $this->checkOptHtmlCheck,
+                       'CHECKOPTIONS' => $this->checkOptionsHtmlCheck,
                        'ID' => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />',
                        'REFRESH' => '',
-                       'UPDATE' => $this->updateListHtml
+                       'UPDATE' => '<input type="submit" name="updateLinkList" id="updateLinkList" value="' . $this->getLanguageService()->getLL('label_update') . '"/>',
                );
-               return $markers;
        }
 
        /**
@@ -710,7 +641,32 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
         * @return bool Whether the current user is admin
         */
        protected function isCurrentUserAdmin() {
-               return (bool)$GLOBALS['BE_USER']->user['admin'];
+               return $this->getBackendUser()->isAdmin();
+       }
+
+       /**
+        * Returns LanguageService
+        *
+        * @return \TYPO3\CMS\Lang\LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
+       /**
+        * Returns the current BE user.
+        *
+        * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
+        */
+       protected function getBackendUser() {
+               return $GLOBALS['BE_USER'];
+       }
+
+       /**
+        * @return \TYPO3\CMS\Core\Database\DatabaseConnection
+        */
+       protected function getDatabaseConnection() {
+               return $GLOBALS['TYPO3_DB'];
        }
 
 }
index ff546c6..5685018 100644 (file)
@@ -15,7 +15,14 @@ namespace TYPO3\CMS\Linkvalidator\Task;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Mail\MailMessage;
+use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Html\HtmlParser;
+use TYPO3\CMS\Core\Utility\MailUtility;
+use TYPO3\CMS\Lang\LanguageService;
+use TYPO3\CMS\Linkvalidator\LinkAnalyzer;
 
 /**
  * This class provides Scheduler plugin implementation
@@ -232,7 +239,8 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
        public function execute() {
                $this->setCliArguments();
                $successfullyExecuted = TRUE;
-               if (!file_exists(($file = GeneralUtility::getFileAbsFileName($this->emailTemplateFile)))
+               if (
+                       !file_exists(($file = GeneralUtility::getFileAbsFileName($this->emailTemplateFile)))
                        && !empty($this->email)
                ) {
                        if ($this->emailTemplateFile === 'EXT:linkvalidator/res/mailtemplate.html') {
@@ -241,15 +249,14 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
                                $this->save();
                        } else {
                                throw new \InvalidArgumentException(
-                                       $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidEmailTemplateFile'),
+                                       $this->getLanguageService()->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidEmailTemplateFile'),
                                        '1295476972'
                                );
                        }
                }
                $htmlFile = GeneralUtility::getURL($file);
-               $this->templateMail = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($htmlFile, '###REPORT_TEMPLATE###');
+               $this->templateMail = HtmlParser::getSubpart($htmlFile, '###REPORT_TEMPLATE###');
                // The array to put the content into
-               $html = array();
                $pageSections = '';
                $this->isDifferentToLastRun = FALSE;
                $pageList = GeneralUtility::trimExplode(',', $this->page, TRUE);
@@ -282,12 +289,12 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
                $modTs = $this->loadModTsConfig($page);
                $searchFields = $this->getSearchField($modTs);
                $linkTypes = $this->getLinkTypes($modTs);
-               /** @var $processor \TYPO3\CMS\Linkvalidator\LinkAnalyzer */
-               $processor = GeneralUtility::makeInstance(\TYPO3\CMS\Linkvalidator\LinkAnalyzer::class);
+               /** @var $processor LinkAnalyzer */
+               $processor = GeneralUtility::makeInstance(LinkAnalyzer::class);
                if ($page === 0) {
                        $rootLineHidden = FALSE;
                } else {
-                       $pageRow = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'pages', 'uid=' . $page);
+                       $pageRow = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('*', 'pages', 'uid=' . $page);
                        $rootLineHidden = $processor->getRootLineIsHidden($pageRow);
                }
                if (!$rootLineHidden || $modTs['checkhidden'] == 1) {
@@ -322,10 +329,10 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
         */
        protected function loadModTsConfig($page) {
                $modTs = BackendUtility::getModTSconfig($page, 'mod.linkvalidator');
-               $parseObj = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::class);
+               $parseObj = GeneralUtility::makeInstance(TypoScriptParser::class);
                $parseObj->parse($this->configuration);
                if (count($parseObj->errors) > 0) {
-                       $parseErrorMessage = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidTSconfig') . '<br />';
+                       $parseErrorMessage = $this->getLanguageService()->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidTSconfig') . '<br />';
                        foreach ($parseObj->errors as $errorInfo) {
                                $parseErrorMessage .= $errorInfo[0] . '<br />';
                        }
@@ -335,7 +342,7 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
                $modTs = $modTs['properties'];
                $overrideTs = $tsConfig['mod.']['tx_linkvalidator.'];
                if (is_array($overrideTs)) {
-                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($modTs, $overrideTs);
+                       ArrayUtility::mergeRecursiveWithOverrule($modTs, $overrideTs);
                }
                return $modTs;
        }
@@ -387,7 +394,7 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
         * @throws \Exception if required modTsConfig settings are missing
         */
        protected function reportEmail($pageSections, array $modTsConfig) {
-               $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart($this->templateMail, '###PAGE_SECTION###', $pageSections);
+               $content = HtmlParser::substituteSubpart($this->templateMail, '###PAGE_SECTION###', $pageSections);
                /** @var array $markerArray */
                $markerArray = array();
                /** @var array $validEmailList */
@@ -410,19 +417,19 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
                                unset($params);
                        }
                }
-               $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($content, $markerArray, '###|###', TRUE, TRUE);
-               /** @var $mail \TYPO3\CMS\Core\Mail\MailMessage */
-               $mail = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
+               $content = HtmlParser::substituteMarkerArray($content, $markerArray, '###|###', TRUE, TRUE);
+               /** @var $mail MailMessage */
+               $mail = GeneralUtility::makeInstance(MailMessage::class);
                if (empty($modTsConfig['mail.']['fromemail'])) {
-                       $modTsConfig['mail.']['fromemail'] = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFromAddress();
+                       $modTsConfig['mail.']['fromemail'] = MailUtility::getSystemFromAddress();
                }
                if (empty($modTsConfig['mail.']['fromname'])) {
-                       $modTsConfig['mail.']['fromname'] = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFromName();
+                       $modTsConfig['mail.']['fromname'] = MailUtility::getSystemFromName();
                }
                if (GeneralUtility::validEmail($modTsConfig['mail.']['fromemail'])) {
                        $mail->setFrom(array($modTsConfig['mail.']['fromemail'] => $modTsConfig['mail.']['fromname']));
                } else {
-                       throw new \Exception($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidFromEmail'), '1295476760');
+                       throw new \Exception($this->getLanguageService()->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidFromEmail'), '1295476760');
                }
                if (GeneralUtility::validEmail($modTsConfig['mail.']['replytoemail'])) {
                        $mail->setReplyTo(array($modTsConfig['mail.']['replytoemail'] => $modTsConfig['mail.']['replytoname']));
@@ -430,13 +437,13 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
                if (!empty($modTsConfig['mail.']['subject'])) {
                        $mail->setSubject($modTsConfig['mail.']['subject']);
                } else {
-                       throw new \Exception($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.noSubject'), '1295476808');
+                       throw new \Exception($this->getLanguageService()->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.noSubject'), '1295476808');
                }
                if (!empty($this->email)) {
                        $emailList = GeneralUtility::trimExplode(',', $this->email);
                        foreach ($emailList as $emailAdd) {
                                if (!GeneralUtility::validEmail($emailAdd)) {
-                                       throw new \Exception($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidToEmail'), '1295476821');
+                                       throw new \Exception($this->getLanguageService()->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidToEmail'), '1295476821');
                                } else {
                                        $validEmailList[] = $emailAdd;
                                }
@@ -464,7 +471,7 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
         * @return string Content of the mail
         */
        protected function buildMail($curPage, $pageList, array $markerArray, array $oldBrokenLink) {
-               $pageSectionHtml = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($this->templateMail, '###PAGE_SECTION###');
+               $pageSectionHtml = HtmlParser::getSubpart($this->templateMail, '###PAGE_SECTION###');
                // Hook
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['buildMailMarkers'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['buildMailMarkers'] as $userFunc) {
@@ -499,7 +506,7 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
                );
                $content = '';
                if ($markerArray['brokenlinkCount'] > 0) {
-                       $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($pageSectionHtml, $markerArray, '###|###', TRUE, TRUE);
+                       $content = HtmlParser::substituteMarkerArray($pageSectionHtml, $markerArray, '###|###', TRUE, TRUE);
                }
                return $content;
        }
@@ -522,12 +529,13 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
                                $pageLabel = $pageTitle . ' (' . $page . ')';
                        }
                }
-               $additionalInformation[] = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.page') . ': ' . $pageLabel;
+               $lang = $this->getLanguageService();
+               $additionalInformation[] = $lang->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.page') . ': ' . $pageLabel;
 
                $depth = (int)$this->getDepth();
-               $additionalInformation[] = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.depth') . ': ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_' . ($depth === 999 ? 'infi' : $depth));
+               $additionalInformation[] = $lang->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.depth') . ': ' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_' . ($depth === 999 ? 'infi' : $depth));
 
-               $additionalInformation[] = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.email') . ': ' . $this->getEmail();
+               $additionalInformation[] = $lang->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.email') . ': ' . $this->getEmail();
 
                return implode(', ', $additionalInformation);
        }
@@ -552,4 +560,17 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
                );
        }
 
+       /**
+        * @return LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
+       /**
+        * @return \TYPO3\CMS\Core\Database\DatabaseConnection
+        */
+       protected function getDatabaseConnection() {
+               return $GLOBALS['TYPO3_DB'];
+       }
 }
index 1657eb9..09f2e8d 100644 (file)
@@ -15,6 +15,12 @@ namespace TYPO3\CMS\Linkvalidator\Task;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
+use TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface;
+use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
+use TYPO3\CMS\Scheduler\Task\AbstractTask;
 
 /**
  * This class provides Scheduler Additional Field plugin implementation
@@ -22,68 +28,68 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
  * @author Dimitri König <dk@cabag.ch>
  * @author Michael Miousse <michael.miousse@infoglobe.ca>
  */
-class ValidatorTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface {
+class ValidatorTaskAdditionalFieldProvider implements AdditionalFieldProviderInterface {
 
        /**
         * Render additional information fields within the scheduler backend.
         *
         * @param array $taskInfo Array information of task to return
         * @param ValidatorTask $task Task object
-        * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the BE module of the Scheduler
+        * @param SchedulerModuleController $schedulerModule Reference to the BE module of the Scheduler
         * @return array Additional fields
         * @see \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface->getAdditionalFields($taskInfo, $task, $schedulerModule)
         */
-       public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule) {
+       public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule) {
                $additionalFields = array();
                if (empty($taskInfo['configuration'])) {
-                       if ($schedulerModule->CMD == 'add') {
+                       if ($schedulerModule->CMD === 'add') {
                                $taskInfo['configuration'] = '';
-                       } elseif ($schedulerModule->CMD == 'edit') {
+                       } elseif ($schedulerModule->CMD === 'edit') {
                                $taskInfo['configuration'] = $task->getConfiguration();
                        } else {
                                $taskInfo['configuration'] = $task->getConfiguration();
                        }
                }
                if (empty($taskInfo['depth'])) {
-                       if ($schedulerModule->CMD == 'add') {
+                       if ($schedulerModule->CMD === 'add') {
                                $taskInfo['depth'] = array();
-                       } elseif ($schedulerModule->CMD == 'edit') {
+                       } elseif ($schedulerModule->CMD === 'edit') {
                                $taskInfo['depth'] = $task->getDepth();
                        } else {
                                $taskInfo['depth'] = $task->getDepth();
                        }
                }
                if (empty($taskInfo['page'])) {
-                       if ($schedulerModule->CMD == 'add') {
+                       if ($schedulerModule->CMD === 'add') {
                                $taskInfo['page'] = '';
-                       } elseif ($schedulerModule->CMD == 'edit') {
+                       } elseif ($schedulerModule->CMD === 'edit') {
                                $taskInfo['page'] = $task->getPage();
                        } else {
                                $taskInfo['page'] = $task->getPage();
                        }
                }
                if (empty($taskInfo['email'])) {
-                       if ($schedulerModule->CMD == 'add') {
+                       if ($schedulerModule->CMD === 'add') {
                                $taskInfo['email'] = '';
-                       } elseif ($schedulerModule->CMD == 'edit') {
+                       } elseif ($schedulerModule->CMD === 'edit') {
                                $taskInfo['email'] = $task->getEmail();
                        } else {
                                $taskInfo['email'] = $task->getEmail();
                        }
                }
                if (empty($taskInfo['emailOnBrokenLinkOnly'])) {
-                       if ($schedulerModule->CMD == 'add') {
+                       if ($schedulerModule->CMD === 'add') {
                                $taskInfo['emailOnBrokenLinkOnly'] = 1;
-                       } elseif ($schedulerModule->CMD == 'edit') {
+                       } elseif ($schedulerModule->CMD === 'edit') {
                                $taskInfo['emailOnBrokenLinkOnly'] = $task->getEmailOnBrokenLinkOnly();
                        } else {
                                $taskInfo['emailOnBrokenLinkOnly'] = $task->getEmailOnBrokenLinkOnly();
                        }
                }
                if (empty($taskInfo['emailTemplateFile'])) {
-                       if ($schedulerModule->CMD == 'add') {
+                       if ($schedulerModule->CMD === 'add') {
                                $taskInfo['emailTemplateFile'] = 'EXT:linkvalidator/Resources/Private/Templates/mailtemplate.html';
-                       } elseif ($schedulerModule->CMD == 'edit') {
+                       } elseif ($schedulerModule->CMD === 'edit') {
                                $taskInfo['emailTemplateFile'] = $task->getEmailTemplateFile();
                        } else {
                                $taskInfo['emailTemplateFile'] = $task->getEmailTemplateFile();
@@ -91,7 +97,8 @@ class ValidatorTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Addit
                }
                $fieldId = 'task_page';
                $fieldCode = '<input type="text" name="tx_scheduler[linkvalidator][page]" id="' . $fieldId . '" value="' . htmlspecialchars($taskInfo['page']) . '"/>';
-               $label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.page');
+               $lang = $this->getLanguageService();
+               $label = $lang->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.page');
                $label = BackendUtility::wrapInHelp('linkvalidator', $fieldId, $label);
                $additionalFields[$fieldId] = array(
                        'code' => $fieldCode,
@@ -100,12 +107,12 @@ class ValidatorTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Addit
                // input for depth
                $fieldId = 'task_depth';
                $fieldValueArray = array(
-                       '0' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_0'),
-                       '1' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_1'),
-                       '2' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_2'),
-                       '3' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_3'),
-                       '4' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_4'),
-                       '999' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_infi')
+                       '0' => $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_0'),
+                       '1' => $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_1'),
+                       '2' => $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_2'),
+                       '3' => $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_3'),
+                       '4' => $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_4'),
+                       '999' => $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_infi')
                );
                $fieldCode = '<select name="tx_scheduler[linkvalidator][depth]" id="' . $fieldId . '">';
                foreach ($fieldValueArray as $depth => $label) {
@@ -114,7 +121,7 @@ class ValidatorTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Addit
                                                '>' . $label . '</option>';
                }
                $fieldCode .= '</select>';
-               $label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.depth');
+               $label = $lang->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.depth');
                $label = BackendUtility::wrapInHelp('linkvalidator', $fieldId, $label);
                $additionalFields[$fieldId] = array(
                        'code' => $fieldCode,
@@ -123,7 +130,7 @@ class ValidatorTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Addit
                $fieldId = 'task_configuration';
                $fieldCode = '<textarea  name="tx_scheduler[linkvalidator][configuration]" id="' . $fieldId . '" >' .
                                        htmlspecialchars($taskInfo['configuration']) . '</textarea>';
-               $label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.conf');
+               $label = $lang->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.conf');
                $label = BackendUtility::wrapInHelp('linkvalidator', $fieldId, $label);
                $additionalFields[$fieldId] = array(
                        'code' => $fieldCode,
@@ -132,7 +139,7 @@ class ValidatorTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Addit
                $fieldId = 'task_email';
                $fieldCode = '<input type="text"  name="tx_scheduler[linkvalidator][email]" id="' . $fieldId . '" value="' .
                                        htmlspecialchars($taskInfo['email']) . '" />';
-               $label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.email');
+               $label = $lang->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.email');
                $label = BackendUtility::wrapInHelp('linkvalidator', $fieldId, $label);
                $additionalFields[$fieldId] = array(
                        'code' => $fieldCode,
@@ -141,7 +148,7 @@ class ValidatorTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Addit
                $fieldId = 'task_emailOnBrokenLinkOnly';
                $fieldCode = '<input type="checkbox"  name="tx_scheduler[linkvalidator][emailOnBrokenLinkOnly]" id="' . $fieldId . '" ' .
                                        (htmlspecialchars($taskInfo['emailOnBrokenLinkOnly']) ? 'checked="checked"' : '') . ' />';
-               $label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.emailOnBrokenLinkOnly');
+               $label = $lang->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.emailOnBrokenLinkOnly');
                $label = BackendUtility::wrapInHelp('linkvalidator', $fieldId, $label);
                $additionalFields[$fieldId] = array(
                        'code' => $fieldCode,
@@ -150,7 +157,7 @@ class ValidatorTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Addit
                $fieldId = 'task_emailTemplateFile';
                $fieldCode = '<input type="text"  name="tx_scheduler[linkvalidator][emailTemplateFile]" id="' . $fieldId .
                                        '" value="' . htmlspecialchars($taskInfo['emailTemplateFile']) . '" />';
-               $label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.emailTemplateFile');
+               $label = $lang->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.emailTemplateFile');
                $label = BackendUtility::wrapInHelp('linkvalidator', $fieldId, $label);
                $additionalFields[$fieldId] = array(
                        'code' => $fieldCode,
@@ -179,42 +186,43 @@ class ValidatorTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Addit
         * If the task class is not relevant, the method is expected to return TRUE.
         *
         * @param array $submittedData Reference to the array containing the data submitted by the user
-        * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the BE module of the Scheduler
+        * @param SchedulerModuleController $schedulerModule Reference to the BE module of the Scheduler
         * @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise
         */
-       public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule) {
+       public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule) {
                $isValid = TRUE;
                // @todo add validation to validate the $submittedData['configuration'] which is normally a comma separated string
+               $lang = $this->getLanguageService();
                if (!empty($submittedData['linkvalidator']['email'])) {
-                       $emailList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $submittedData['linkvalidator']['email']);
+                       $emailList = GeneralUtility::trimExplode(',', $submittedData['linkvalidator']['email']);
                        foreach ($emailList as $emailAdd) {
-                               if (!\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($emailAdd)) {
+                               if (!GeneralUtility::validEmail($emailAdd)) {
                                        $isValid = FALSE;
-                                       $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.invalidEmail'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
+                                       $schedulerModule->addMessage($lang->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.invalidEmail'), FlashMessage::ERROR);
                                }
                        }
                }
-               if ($res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'uid = ' . (int)$submittedData['linkvalidator']['page'])) {
-                       if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) == 0 && $submittedData['linkvalidator']['page'] > 0) {
+               if ($res = $this->getDatabaseConnection()->exec_SELECTquery('*', 'pages', 'uid = ' . (int)$submittedData['linkvalidator']['page'])) {
+                       if ($this->getDatabaseConnection()->sql_num_rows($res) == 0 && $submittedData['linkvalidator']['page'] > 0) {
                                $isValid = FALSE;
                                $schedulerModule->addMessage(
-                                       $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.invalidPage'),
-                                       \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
+                                       $lang->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.invalidPage'),
+                                       FlashMessage::ERROR
                                );
                        }
-                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
+                       $this->getDatabaseConnection()->sql_free_result($res);
                } else {
                        $isValid = FALSE;
                        $schedulerModule->addMessage(
-                               $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.invalidPage'),
-                               \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
+                               $lang->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.invalidPage'),
+                               FlashMessage::ERROR
                        );
                }
                if ($submittedData['linkvalidator']['depth'] < 0) {
                        $isValid = FALSE;
                        $schedulerModule->addMessage(
-                               $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.invalidDepth'),
-                               \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
+                               $lang->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.validate.invalidDepth'),
+                               FlashMessage::ERROR
                        );
                }
                return $isValid;
@@ -225,10 +233,10 @@ class ValidatorTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Addit
         * if the task class matches.
         *
         * @param array $submittedData Array containing the data submitted by the user
-        * @param \TYPO3\CMS\Scheduler\Task\AbstractTask $task Reference to the current task object
+        * @param AbstractTask $task Reference to the current task object
         * @return void
         */
-       public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task) {
+       public function saveAdditionalFields(array $submittedData, AbstractTask $task) {
                /** @var $task ValidatorTask */
                $task->setDepth($submittedData['linkvalidator']['depth']);
                $task->setPage($submittedData['linkvalidator']['page']);
@@ -242,4 +250,18 @@ class ValidatorTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\Addit
                $task->setEmailTemplateFile($submittedData['linkvalidator']['emailTemplateFile']);
        }
 
+       /**
+        * @return LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
+       /**
+        * @return \TYPO3\CMS\Core\Database\DatabaseConnection
+        */
+       protected function getDatabaseConnection() {
+               return $GLOBALS['TYPO3_DB'];
+       }
+
 }
index a8e7968..b924a5a 100644 (file)
@@ -3,6 +3,9 @@
        <file t3:id="1415814894" source-language="en" datatype="plaintext" original="messages" date="2011-10-17T20:22:34Z" product-name="linkvalidator">
                <header/>
                <body>
+                       <trans-unit id="linkvalidator" xml:space="preserve">
+                               <source>Link validator</source>
+                       </trans-unit>
                        <trans-unit id="menu.introduction" xml:space="preserve">
                                <source>Introduction</source>
                        </trans-unit>
diff --git a/typo3/sysext/linkvalidator/Resources/Private/Styles/styles.less b/typo3/sysext/linkvalidator/Resources/Private/Styles/styles.less
new file mode 100644 (file)
index 0000000..741d06c
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/* - - - - - - - - - - - - - - - - - - - - -
+Info > Linkvalidator
+- - - - - - - - - - - - - - - - - - - - - */
+
+.linkvalidator-function-menu {
+       margin-bottom: 25px;
+       margin-left: 25px;
+       margin-top: 0;
+       float: left;
+
+       input {
+               margin-left: 5px;
+       }
+
+       div {
+               margin-top: 11px;
+       }
+}
+
+.linkvalidator-check-options {
+       float: left;
+       display: block;
+       margin-top: 0px;
+       width: 225px;
+
+       div {
+               float: left;
+       }
+}
+
+.linkvalidator-button {
+       clear: both;
+}
+
+#linkvalidator-statistics-table {
+       width: 230px;
+       margin-top: 5px;
+       margin-bottom: 14px;
+
+       th {
+               td.number {
+                       padding-top: 4px;
+               }
+       }
+
+       td {
+               border-left: 1px solid white;
+               vertical-align: middle;
+       }
+
+       td:first-child {
+               border-left: none;
+       }
+
+       td.number {
+               padding-right: 6px;
+               text-align: center;
+       }
+
+       span {
+               vertical-align: middle;
+       }
+}
+
+#linkvalidator-broken-links-table {
+       td {
+               border-left: 1px solid white;
+
+               span.valid {
+                       color: green;
+               }
+
+               span.error {
+                       color: red;
+               }
+       }
+
+       td:first-child {
+               border-left: none;
+       }
+}
index 892d578..7caca38 100644 (file)
@@ -1,64 +1,65 @@
 <!-- ###FULLDOC### begin -->
-                       <div class="linkvalidator_checkoptions">
-                               ###ID###
-                               ###CHECKALLLINK###
-                               <h4>###CHECKOPTIONS_TITLE###</h4>
-                               <div>###CHECKOPTIONS###</div>
-                       </div>
-                       <div class="linkvalidator_funcmenu"><h4>###FUNC_TITLE###</h4><div>###FUNC_MENU###</div></div>
-                       <div class="linkvalidator_button">###REFRESH######UPDATE###</div>
+<div class="linkvalidator-check-options">
+       ###ID###
+       <h4>###CHECKOPTIONS_TITLE###</h4>
+       <div>###CHECKOPTIONS###</div>
+</div>
+<div class="linkvalidator-function-menu"><h4>###FUNC_TITLE###</h4><div>###FUNC_MENU###</div></div>
+<div class="linkvalidator-button">###REFRESH######UPDATE###</div>
 
-                       ###CONTENT###
+###CONTENT###
 <!-- ###FULLDOC### end -->
 
-
 <!-- ###CHECKOPTIONS_SECTION### begin -->
-       <table class="typo3-dblist" id="linkvalidator_statsTable" cellspacing="0" cellpadding="0">
-               <tr class="t3-row-header">
-                       <td>
-                               ###TOTAL_COUNT_LABEL###
-                       </td>
-                       <td class="number">###TOTAL_COUNT###</td>
+<table class="t3-table" id="linkvalidator-statistics-table">
+       <thead>
+               <tr>
+                       <th>###TOTAL_COUNT_LABEL###</th>
+                       <th class="number">###TOTAL_COUNT###</th>
                </tr>
+       </thead>
+       <tbody>
                <!-- ###HOOK_SECTION### begin -->
                <tr>
-                       <td>
-                               <div class="linkvalidator_singleOption">###OPTION###</div>
-                       </td>
-                       <td class="number">###COUNT###</td>
+                       <td>###OPTION###</td>
+                       <td class="number"><span class="badge">###COUNT###</span></td>
                </tr>
                <!-- ###HOOK_SECTION### end -->
-       </table>
+       </tbody>
+</table>
 <!-- ###CHECKOPTIONS_SECTION### end -->
 
-
 <!-- ###BROKENLINKS_CONTENT### begin -->
-       ###LIST_HEADER###
-       <table class="typo3-dblist" id="linkvalidator_brokenLinksTable" cellspacing="0" cellpadding="0">
-               <tr class="t3-row-header">
-                       <td></td>
-                       <td>###TABLEHEAD_PATH###</td>
-                       <td>###TABLEHEAD_ELEMENT###</td>
-                       <td>###TABLEHEAD_HEADLINK###</td>
-                       <td>###TABLEHEAD_LINKTARGET###</td>
-                       <td>###TABLEHEAD_LINKMESSAGE###</td>
-                       <td>###TABLEHEAD_LASTCHECK###</td>
+###LIST_HEADER###
+<table class="t3-table" id="linkvalidator-broken-links-table">
+       <thead>
+               <tr>
+                       <th>###TABLEHEAD_PATH###</th>
+                       <th>###TABLEHEAD_ELEMENT###</th>
+                       <th>###TABLEHEAD_HEADLINK###</th>
+                       <th>###TABLEHEAD_LINKTARGET###</th>
+                       <th>###TABLEHEAD_LINKMESSAGE###</th>
+                       <th>###TABLEHEAD_LASTCHECK###</th>
+                       <th></th>
                </tr>
+       </thead>
+       <tbody>
                <!-- ###BROKENLINKS_ITEM### begin -->
                <tr>
-                       <td>###ACTIONLINK###</td>
                        <td>###PATH###</td>
                        <td>###ELEMENT###</td>
                        <td>###HEADLINK###</td>
                        <td><a href="###LINKTARGET###" target="_blank">###LINKTARGET###</a></td>
                        <td>###LINKMESSAGE###</td>
                        <td>###LASTCHECK###</td>
+                       <td>###ACTIONLINK###</td>
                </tr>
                <!-- ###BROKENLINKS_ITEM### end -->
-       </table>
+       </tbody>
+</table>
 <!-- ###BROKENLINKS_CONTENT### end -->
 
 <!-- ###NOBROKENLINKS_CONTENT### begin -->
-       ###LIST_HEADER###
-       ###NO_BROKEN_LINKS###
+###LIST_HEADER###
+###NO_BROKEN_LINKS###
 <!-- ###NOBROKENLINKS_CONTENT### end -->
diff --git a/typo3/sysext/linkvalidator/Resources/Public/Css/linkvalidator.css b/typo3/sysext/linkvalidator/Resources/Public/Css/linkvalidator.css
deleted file mode 100644 (file)
index 34263e9..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-@charset "UTF-8";
-
-ul.x-tab-strip.x-tab-strip-top {
-       margin-bottom: 0;
-       list-style: none;
-       padding-left: 0;
-}
-
-#linkvalidator-main div.x-tab-panel-bwrap div div div div.x-panel-body {
-       overflow: auto;
-}
-
-.linkvalidator_funcmenu {
-       margin-bottom: 25px;
-       margin-left: 25px;
-       margin-top: 0;
-       float: left;
-}
-.linkvalidator_funcmenu input {
-       margin-left: 5px;
-}
-.linkvalidator_funcmenu div {
-       margin-top: 11px;
-}
-#linkvalidator-main .linkvalidator_funcmenu h4 {
-       clear: both;
-       padding: 0;
-}
-
-#linkvalidator-main h4 {
-       padding-top: 16px;
-}
-
-.linkvalidator_checkoptions {
-       float: left;
-       display: block;
-       margin-top: 0px;
-       width: 225px;
-}
-.linkvalidator_checkoptions div {
-       float: left;
-}
-#linkvalidator-main .linkvalidator_checkoptions h4 {
-       clear: both;
-       padding-top: 0px;
-}
-
-.linkvalidator_button {
-       clear: both;
-}
-
-#linkvalidator-main .typo3-message {
-       margin-top: 10px;
-}
-
-.linkvalidator_singleOption {
-       padding: 0;
-}
-.linkvalidator_singleOption label {
-       padding-left: 10px;
-       vertical-align: middle;
-}
-.linkvalidator_singleOption input {
-       vertical-align: middle;
-}
-.linkvalidator_singleOption .checkbox,
-.linkvalidator_singleOption .checkbox:hover {
-       margin-top: 0px;
-       margin-bottom: 0px;
-}
-.linkvalidator_singleOption-showalllinks {
-       padding-bottom: 10px;
-}
-
-#linkvalidator_statsTable {
-       width: 230px;
-       margin-top: 5px;
-       margin-bottom: 14px;
-}
-#linkvalidator_statsTable .t3-row-header td.number {
-       padding-top: 4px;
-}
-#linkvalidator_statsTable td,
-#linkvalidator_statsTable span {
-       vertical-align: middle;
-}
-#linkvalidator_statsTable td.number {
-       padding-right: 6px;
-       text-align: center;
-}
-#linkvalidator_statsTable td,
-#linkvalidator_brokenLinksTable td {
-       border-left: 1px solid white;
-}
-#linkvalidator_statsTable td:first-child,
-#linkvalidator_brokenLinksTable td:first-child {
-       border-left: none;
-}
diff --git a/typo3/sysext/linkvalidator/Resources/Public/JavaScript/Linkvalidator.js b/typo3/sysext/linkvalidator/Resources/Public/JavaScript/Linkvalidator.js
new file mode 100644 (file)
index 0000000..7e21a9c
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+define('TYPO3/CMS/Linkvalidator/Linkvalidator', ['jquery'], function($) {
+
+       var Linkvalidator = {};
+
+       Linkvalidator.toggleActionButton = function(prefix) {
+               var buttonDisable = true;
+               $('.' + prefix).each(function(index) {
+                       if ($(this).prop('checked')) {
+                               buttonDisable = false;
+                       }
+               });
+
+               if (prefix == 'check') {
+                       $('#updateLinkList').prop('disabled', buttonDisable);
+               } else {
+                       $('#refreshLinkList').prop('disabled', buttonDisable);
+               }
+       };
+
+       /**
+        * Registers listeners
+        */
+       Linkvalidator.initializeEvents = function() {
+               $('.refresh').on('click', function() {
+                       Linkvalidator.toggleActionButton('refresh');
+               });
+
+               $('.check').on('click', function() {
+                       Linkvalidator.toggleActionButton('check');
+               });
+       };
+
+       // intialize and return the Linkvalidator object
+       return function() {
+               $(document).ready(function() {
+                       Linkvalidator.initializeEvents();
+               });
+
+               TYPO3.Linkvalidator = Linkvalidator;
+               return Linkvalidator;
+       }();
+});
diff --git a/typo3/sysext/linkvalidator/Resources/Public/Styles/styles.css b/typo3/sysext/linkvalidator/Resources/Public/Styles/styles.css
new file mode 100644 (file)
index 0000000..2b72735
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+/* - - - - - - - - - - - - - - - - - - - - -
+Info > Linkvalidator
+- - - - - - - - - - - - - - - - - - - - - */
+.linkvalidator-function-menu {
+  margin-bottom: 25px;
+  margin-left: 25px;
+  margin-top: 0;
+  float: left;
+}
+.linkvalidator-function-menu input {
+  margin-left: 5px;
+}
+.linkvalidator-function-menu div {
+  margin-top: 11px;
+}
+.linkvalidator-check-options {
+  float: left;
+  display: block;
+  margin-top: 0px;
+  width: 225px;
+}
+.linkvalidator-check-options div {
+  float: left;
+}
+.linkvalidator-button {
+  clear: both;
+}
+#linkvalidator-statistics-table {
+  width: 230px;
+  margin-top: 5px;
+  margin-bottom: 14px;
+}
+#linkvalidator-statistics-table th td.number {
+  padding-top: 4px;
+}
+#linkvalidator-statistics-table td {
+  border-left: 1px solid white;
+  vertical-align: middle;
+}
+#linkvalidator-statistics-table td:first-child {
+  border-left: none;
+}
+#linkvalidator-statistics-table td.number {
+  padding-right: 6px;
+  text-align: center;
+}
+#linkvalidator-statistics-table span {
+  vertical-align: middle;
+}
+#linkvalidator-broken-links-table td {
+  border-left: 1px solid white;
+}
+#linkvalidator-broken-links-table td span.valid {
+  color: green;
+}
+#linkvalidator-broken-links-table td span.error {
+  color: red;
+}
+#linkvalidator-broken-links-table td:first-child {
+  border-left: none;
+}