[TASK] Fix CGL issues
authorPhilipp Gampe <forge.typo3.org@philippgampe.info>
Sat, 24 Sep 2011 14:03:43 +0000 (16:03 +0200)
committerPhilipp Gampe <forge.typo3.org@philippgampe.info>
Wed, 5 Oct 2011 21:23:46 +0000 (23:23 +0200)
 * A fix whitespace issues.
 * Add some missing $GLOBALS['TYPO3_DB']->sql_free_result($res);
 * Remove some unused variables
 * Add double (()) for assignment in condition
 * Check for FALSE after assigning sql_fetch_assoc($res)

Change-Id: I3007024ef004fc28aee6bc91ae888305f227b9ce
Resolves: #29341
Releases: 4.6

typo3/sysext/linkvalidator/ChangeLog
typo3/sysext/linkvalidator/classes/class.tx_linkvalidator_processor.php
typo3/sysext/linkvalidator/classes/linktype/class.tx_linkvalidator_linktype_external.php
typo3/sysext/linkvalidator/classes/linktype/class.tx_linkvalidator_linktype_internal.php
typo3/sysext/linkvalidator/classes/tasks/class.tx_linkvalidator_tasks_validator.php
typo3/sysext/linkvalidator/classes/tasks/class.tx_linkvalidator_tasks_validatoradditionalfieldprovider.php
typo3/sysext/linkvalidator/modfuncreport/class.tx_linkvalidator_modfuncreport.php

index 8b80b76..c15ff27 100644 (file)
@@ -1,8 +1,12 @@
-2011-08-30 Philipp Gampe <forge.typo3.org@philippgampe.info>
+2011-10-05  Philipp Gampe  <forge.typo3.org@philippgampe.info>
+
+       * [TASK] Fix CGL issues
+
+2011-08-30  Philipp Gampe  <forge.typo3.org@philippgampe.info>
 
        * [TASK] Release linkvalidator 1.0.4
 
-2011-08-26 Philipp Gampe <forge.typo3.org@philippgampe.info>
+2011-08-26  Philipp Gampe  <forge.typo3.org@philippgampe.info>
 
        * [BUGFIX] Fatal error with E_STRICT: Declaration of fetchType must be compatible with interface
        * [TASK] Fix phpdoc and method signatures
        * Fixed bug #26731: The info module does not show up in IE 7 and 8 (Michael Miousse)
        * Fixed bug #13368: Content of Tab is not scrollable (Michael Miousse)
 
-2011-04-26     Michael Miousse  <michael.miousse@infoglobe.ca>
+2011-04-26  Michael Miousse  <michael.miousse@infoglobe.ca>
 
        * Fixed bug #13757: Scheduler task does not work at all
 
-2011-04-21     Michael Miousse  <michael.miousse@infoglobe.ca>
+2011-04-21  Michael Miousse  <michael.miousse@infoglobe.ca>
 
        * Fixed bug #13953: Third-party classes cannot be checked due to dynamicConfigFile in TCA (thanks to Jan Philipp Timme)
-       
+
 2011-02-24  Michael Miousse  <michael.miousse@infoglobe.ca>
 
        * Fixed bug #13340: Regression in TYPO3 4.5.1: pid and uid database fields are always 0
        * Fixed bug #12649: Split up analyzeRecord()
        * Cleaned emconf for the release of TYPO3 4.5.1
        * Release linkvalidator 1.0.1
-       
-2011-02-15     Michael Miousse  <michael.miousse@infoglobe.ca>
 
-       * Fixed bug #12652:     If none of the link types are marked to be checked, all of them are checked
-       * Fixed bug #12650:     tx_linkvalidator_tasks_validator: exec() is too long
+2011-02-15  Michael Miousse  <michael.miousse@infoglobe.ca>
+
+       * Fixed bug #12652: If none of the link types are marked to be checked, all of them are checked
+       * Fixed bug #12650: tx_linkvalidator_tasks_validator: exec() is too long
        * Fixed bug #12454: Use setting "defaultMailFromName" and "defaultMailFromAddress"
-       
+
 2011-02-06  Christopher Stelmaszyk  <chrissitopher@gmx.de>
 
        * Fixed bug #12517: Replace exec_SELECTgetRows with exec_SELECTgetSingleRow whenever a single record is expected (thanks to Jo Hasenau)
index 2a7ae59..07f830c 100644 (file)
@@ -121,20 +121,20 @@ class tx_linkvalidator_Processor {
         */
        public function getLinkStatistics($checkOptions = array(), $considerHidden = FALSE) {
                $results = array();
-               if(count($checkOptions) > 0) {
+               if (count($checkOptions) > 0) {
                        $checkKeys = array_keys($checkOptions);
-                       $checkLinkTypeCondition = ' and link_type in (\'' . implode('\',\'',$checkKeys) . '\')';
+                       $checkLinkTypeCondition = ' and link_type in (\'' . implode('\',\'', $checkKeys) . '\')';
 
                        $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_linkvalidator_link',
-                               '(record_pid in (' . $this->pidList . ') or ( record_uid IN (' . $this->pidList . ') and table_name like \'pages\')) '
-                               . $checkLinkTypeCondition);
+                                                                       '(record_pid in (' . $this->pidList . ')'
+                                                                       . ' or ( record_uid IN (' . $this->pidList . ') and table_name like \'pages\')) '
+                                                                       . $checkLinkTypeCondition);
 
                                // Traverse all configured tables
                        foreach ($this->searchFields as $table => $fields) {
-                               if($table == 'pages'){
+                               if ($table === 'pages') {
                                        $where = 'deleted = 0 AND uid IN (' . $this->pidList . ')';
-                               }
-                               else{
+                               } else {
                                        $where = 'deleted = 0 AND pid IN (' . $this->pidList . ')';
                                }
                                if (!$considerHidden) {
@@ -150,10 +150,11 @@ class tx_linkvalidator_Processor {
                                        // 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)) {
-                                       // Analyse each record
+                               while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) !== FALSE) {
+                                               // Analyse each record
                                        $this->analyzeRecord($results, $table, $fields, $row);
                                }
+                               $GLOBALS['TYPO3_DB']->sql_free_result($res);
                        }
 
                        foreach ($this->hookObjectsArr as $key => $hookObj) {
@@ -284,9 +285,8 @@ class tx_linkvalidator_Processor {
        private function analyseLinks(array $resultArray, array &$results, array $record, $field, $table) {
                foreach ($resultArray['elements'] as $element) {
                        $r = $element['subst'];
-                       $title = '';
                        $type = '';
-                       $idRecord = $record['uid'];
+                       $idRecord = $record['uid'];
                        if (!empty($r)) {
                                        // Parse string for special TYPO3 <link> tag:
                                foreach ($this->hookObjectsArr as $keyArr => $hookObj) {
@@ -319,29 +319,29 @@ class tx_linkvalidator_Processor {
                $idRecord = $record['uid'];
                for ($i = 1; $i < count($linkTags); $i += 2) {
                        $referencedRecordType = '';
-                       foreach($resultArray['elements'] as $element) {
-                                       $type = '';
-                                       $r = $element['subst'];
-
-                                       if (!empty($r['tokenID'])) {
-                                               if (substr_count($linkTags[$i], $r['tokenID'])) {
-                                                               // Type of referenced record
-                                                       if (strpos($r['recordRef'], 'pages') !== FALSE) {
-                                                               $currentR = $r;
-                                                                       // Contains number of the page
-                                                               $referencedRecordType = $r['tokenValue'];
-                                                               $wasPage = TRUE;
-                                                       }
-                                                               // Append number of content element to the page saved in the last loop
-                                                       elseif ((strpos($r['recordRef'], 'tt_content') !== FALSE) && ($wasPage === TRUE)) {
-                                                               $referencedRecordType = $referencedRecordType . '#c' . $r['tokenValue'];
-                                                               $wasPage = FALSE;
-                                                       } else {
-                                                               $currentR = $r;
-                                                       }
-                                                       $title = strip_tags($linkTags[$i]);
+                       foreach ($resultArray['elements'] as $element) {
+                               $type = '';
+                               $r = $element['subst'];
+
+                               if (!empty($r['tokenID'])) {
+                                       if (substr_count($linkTags[$i], $r['tokenID'])) {
+                                                       // Type of referenced record
+                                               if (strpos($r['recordRef'], 'pages') !== FALSE) {
+                                                       $currentR = $r;
+                                                               // Contains number of the page
+                                                       $referencedRecordType = $r['tokenValue'];
+                                                       $wasPage = TRUE;
+
+                                                       // Append number of content element to the page saved in the last loop
+                                               } elseif ((strpos($r['recordRef'], 'tt_content') !== FALSE) && (isset($wasPage) && $wasPage === TRUE)) {
+                                                       $referencedRecordType = $referencedRecordType . '#c' . $r['tokenValue'];
+                                                       $wasPage = FALSE;
+                                               } else {
+                                                       $currentR = $r;
                                                }
+                                               $title = strip_tags($linkTags[$i]);
                                        }
+                               }
                        }
                        foreach ($this->hookObjectsArr as $keyArr => $hookObj) {
                                $type = $hookObj->fetchType($currentR, $type, $keyArr);
@@ -367,16 +367,18 @@ class tx_linkvalidator_Processor {
        public function getLinkCounts($curPage) {
                $markerArray = array();
                if (($res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                               '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))) {
+                       '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) {
                                $markerArray[$row['link_type']] = $row['nbBrokenLinks'];
                                $markerArray['brokenlinkCount'] += $row['nbBrokenLinks'];
                        }
                }
+               $GLOBALS['TYPO3_DB']->sql_free_result($res);
                return $markerArray;
        }
 
@@ -395,7 +397,7 @@ class tx_linkvalidator_Processor {
         * @param boolean $considerHidden Whether to consider hidden pages or not
         * @return string Returns the list with a comma in the end (if any pages selected!)
         */
-       public function extGetTreeList($id, $depth, $begin = 0, $permsClause,  $considerHidden = FALSE) {
+       public function extGetTreeList($id, $depth, $begin = 0, $permsClause, $considerHidden = FALSE) {
                $depth = intval($depth);
                $begin = intval($begin);
                $id = intval($id);
@@ -408,16 +410,17 @@ class tx_linkvalidator_Processor {
                                'pid=' . $id . ' AND deleted=0 AND ' . $permsClause
                        );
 
-                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                               if ($begin <= 0 && ($row['hidden']==0 || $considerHidden == 1)) {
+                       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)) {
+                               if ($depth > 1 && (!($row['hidden'] == 1 && $row['extendToSubpages'] == 1) || $considerHidden == 1)) {
                                        $theList .= $this->extGetTreeList($row['uid'], $depth - 1, $begin - 1, $permsClause, $considerHidden);
                                }
                        }
                }
+               $GLOBALS['TYPO3_DB']->sql_free_result($res);
                return $theList;
        }
 
@@ -425,9 +428,9 @@ class tx_linkvalidator_Processor {
         * @param array $pageInfo Array with uid, title, hidden, extendToSubpages from pages table
         * @return boolean TRUE if rootline contains a hidden page, FALSE if not
         */
-       public function getRootLineIsHidden(array $pageInfo){
+       public function getRootLineIsHidden(array $pageInfo) {
                $hidden = FALSE;
-               if ($pageInfo['extendToSubpages'] == 1 && $pageInfo['hidden'] == 1){
+               if ($pageInfo['extendToSubpages'] == 1 && $pageInfo['hidden'] == 1) {
                        $hidden = TRUE;
                } else {
                        if ($pageInfo['pid'] > 0) {
@@ -437,11 +440,11 @@ class tx_linkvalidator_Processor {
                                        'uid=' . $pageInfo['pid']
                                );
 
-                               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                               while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) !== FALSE) {
                                        $hidden = $this->getRootLineIsHidden($row);
                                }
-                       }
-                       else {
+                               $GLOBALS['TYPO3_DB']->sql_free_result($res);
+                       else {
                                $hidden = FALSE;
                        }
                }
@@ -454,4 +457,4 @@ class tx_linkvalidator_Processor {
 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/linkvalidator/classes/class.tx_linkvalidator_processor.php'])) {
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/linkvalidator/classes/class.tx_linkvalidator_processor.php']);
 }
-?>
+?>
\ No newline at end of file
index d5324cd..6e717e4 100644 (file)
@@ -68,7 +68,7 @@ class tx_linkvalidator_linktype_External extends tx_linkvalidator_linktype_Abstr
                $isValidUrl = TRUE;
 
                if (isset($this->urlReports[$url])) {
-                       if(!$this->urlReports[$url]) {
+                       if (!$this->urlReports[$url]) {
                                if(is_array($this->urlErrorParams[$url])) {
                                    $this->setErrorParams($this->urlErrorParams[$url]);
                                }
@@ -121,7 +121,7 @@ class tx_linkvalidator_linktype_External extends tx_linkvalidator_linktype_Abstr
                        $errorParams['message'] = $response->getReasonPhrase();
                }
 
-               if(!$isValidUrl) {
+               if (!$isValidUrl) {
                        $this->setErrorParams($errorParams);
                }
 
index 41ae15c..13a3b11 100644 (file)
@@ -67,9 +67,7 @@ class tx_linkvalidator_linktype_Internal extends tx_linkvalidator_linktype_Abstr
         * @return boolean TRUE on success or FALSE on error
         */
        public function checkLink($url, array $softRefEntry, tx_linkvalidator_Processor $reference) {
-               $page = '';
                $anchor = '';
-               $response = TRUE;
                $this->responseContent = TRUE;
 
                        // Might already contain values - empty it
index 5499c04..b3ec5a9 100644 (file)
@@ -132,7 +132,7 @@ class tx_linkvalidator_tasks_Validator extends tx_scheduler_Task {
         * @return void
         */
        public function setEmail($email) {
-               $this->email=$email;
+               $this->email = $email;
        }
 
        /**
@@ -170,7 +170,7 @@ class tx_linkvalidator_tasks_Validator extends tx_scheduler_Task {
         * @return void
         */
        public function setPage($page) {
-               $this->page =$page;
+               $this->page = $page;
        }
 
        /**
@@ -318,9 +318,9 @@ class tx_linkvalidator_tasks_Validator extends tx_scheduler_Task {
                $modTS = t3lib_BEfunc::getModTSconfig($page, 'mod.linkvalidator');
                $parseObj = t3lib_div::makeInstance('t3lib_TSparser');
                $parseObj->parse($this->configuration);
-               if(count($parseObj->errors) > 0){
+               if (count($parseObj->errors) > 0) {
                        $parseErrorMessage = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.error.invalidTSconfig') . '<br />';
-                       foreach($parseObj->errors as $errorInfo){
+                       foreach ($parseObj->errors as $errorInfo) {
                                $parseErrorMessage .= $errorInfo[0] . '<br />';
                        }
                        throw new Exception(
@@ -344,7 +344,7 @@ class tx_linkvalidator_tasks_Validator extends tx_scheduler_Task {
         * @return array $searchFields List of fields
         */
        protected function getSearchField(array $modTS) {
-                       // Get the searchFields from TypoScript
+               // Get the searchFields from TypoScript
                foreach ($modTS['searchFields.'] as $table => $fieldList) {
                        $fields = t3lib_div::trimExplode(',', $fieldList);
                        foreach ($fields as $field) {
@@ -365,7 +365,7 @@ class tx_linkvalidator_tasks_Validator extends tx_scheduler_Task {
                $typesTmp = t3lib_div::trimExplode(',', $modTS['linktypes'], 1);
                if (is_array($typesTmp)) {
                        if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])
-                                       && is_array($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, $typesTmp)) {
                                                $linkTypes[$type] = 1;
@@ -385,38 +385,38 @@ class tx_linkvalidator_tasks_Validator extends tx_scheduler_Task {
         */
        protected function reportEmail($pageSections, array $modTS) {
                $content = t3lib_parsehtml::substituteSubpart($this->templateMail, '###PAGE_SECTION###', $pageSections);
-                       /** @var array $markerArray */
+               /** @var array $markerArray */
                $markerArray = array();
-                       /** @var array $validEmailList */
+               /** @var array $validEmailList */
                $validEmailList = array();
-                       /** @var boolean $sendEmail */
+               /** @var boolean $sendEmail */
                $sendEmail = TRUE;
 
                $markerArray['totalBrokenLink'] = $this->totalBrokenLink;
                $markerArray['totalBrokenLink_old'] = $this->oldTotalBrokenLink;
                $content = t3lib_parsehtml::substituteMarkerArray($content, $markerArray, '###|###', TRUE, TRUE);
 
-                       /** @var t3lib_mail_Message $mail */
+               /** @var t3lib_mail_Message $mail */
                $mail = t3lib_div::makeInstance('t3lib_mail_Message');
-               if(empty($modTS['mail.']['fromemail'])) {
+               if (empty($modTS['mail.']['fromemail'])) {
                        $modTS['mail.']['fromemail'] = t3lib_utility_Mail::getSystemFromAddress();
                }
-               if(empty($modTS['mail.']['fromname'])) {
+               if (empty($modTS['mail.']['fromname'])) {
                        $modTS['mail.']['fromname'] = t3lib_utility_Mail::getSystemFromName();
                }
                if (t3lib_div::validEmail($modTS['mail.']['fromemail'])) {
                        $mail->setFrom(array($modTS['mail.']['fromemail'] => $modTS['mail.']['fromname']));
-               }  else {
+               } else {
                        throw new Exception(
                                $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.error.invalidFromEmail'),
                                '1295476760'
                        );
                }
-               if(t3lib_div::validEmail($modTS['mail.']['replytoemail'])) {
+               if (t3lib_div::validEmail($modTS['mail.']['replytoemail'])) {
                        $mail->setReplyTo(array($modTS['mail.']['replytoemail'] => $modTS['mail.']['replytoname']));
                }
 
-               if(!empty($modTS['mail.']['subject'])) {
+               if (!empty($modTS['mail.']['subject'])) {
                        $mail->setSubject($modTS['mail.']['subject']);
                } else {
                        throw new Exception(
@@ -443,8 +443,8 @@ class tx_linkvalidator_tasks_Validator extends tx_scheduler_Task {
                        $sendEmail = FALSE;
                }
 
-               if($sendEmail) {
-                       $mail->setBody($content,'text/html');
+               if ($sendEmail) {
+                       $mail->setBody($content, 'text/html');
                        $mail->send();
                }
 
index ba96b75..776a6ab 100644 (file)
@@ -102,7 +102,8 @@ class tx_linkvalidator_tasks_ValidatorAdditionalFieldProvider implements tx_sche
 
 
                $fieldID = 'task_page';
-               $fieldCode = '<input type="text" name="tx_scheduler[linkvalidator][page]"  id="' . $fieldID . '" value="' . htmlspecialchars($taskInfo['page']) . '"/>';
+               $fieldCode = '<input type="text" name="tx_scheduler[linkvalidator][page]"  id="' . $fieldID . '" value="'
+                                        . htmlspecialchars($taskInfo['page']) . '"/>';
                $label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.validate.page');
                $label = t3lib_BEfunc::wrapInHelp('linkvalidator', $fieldID, $label);
                $additionalFields[$fieldID] = array(
@@ -123,7 +124,9 @@ class tx_linkvalidator_tasks_ValidatorAdditionalFieldProvider implements tx_sche
                $fieldCode = '<select name="tx_scheduler[linkvalidator][depth]" id="' . $fieldID . '">';
 
                foreach ($fieldValueArray as $depth => $label) {
-                       $fieldCode .= "\t" . '<option value="' .  htmlspecialchars($depth) . '"' . (($depth ==$taskInfo['depth']) ? ' selected="selected"' : '') . '>' . $label . '</option>';
+                       $fieldCode .= "\t" . '<option value="' . htmlspecialchars($depth) . '"'
+                                                 . (($depth == $taskInfo['depth']) ? ' selected="selected"' : '')
+                                                 . '>' . $label . '</option>';
                }
 
                $fieldCode .= '</select>';
@@ -135,7 +138,8 @@ class tx_linkvalidator_tasks_ValidatorAdditionalFieldProvider implements tx_sche
                );
 
                $fieldID = 'task_configuration';
-               $fieldCode = '<textarea  name="tx_scheduler[linkvalidator][configuration]" id="' . $fieldID . '" >' . htmlspecialchars($taskInfo['configuration']) . '</textarea>';
+               $fieldCode = '<textarea  name="tx_scheduler[linkvalidator][configuration]" id="' . $fieldID . '" >'
+                                        . htmlspecialchars($taskInfo['configuration']) . '</textarea>';
                $label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.validate.conf');
                $label = t3lib_BEfunc::wrapInHelp('linkvalidator', $fieldID, $label);
                $additionalFields[$fieldID] = array(
@@ -144,7 +148,8 @@ class tx_linkvalidator_tasks_ValidatorAdditionalFieldProvider implements tx_sche
                );
 
                $fieldID = 'task_email';
-               $fieldCode = '<input type="text"  name="tx_scheduler[linkvalidator][email]" id="' . $fieldID . '" value="' . htmlspecialchars($taskInfo['email']) . '" />';
+               $fieldCode = '<input type="text"  name="tx_scheduler[linkvalidator][email]" id="' . $fieldID . '" value="'
+                                        . htmlspecialchars($taskInfo['email']) . '" />';
                $label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.validate.email');
                $label = t3lib_BEfunc::wrapInHelp('linkvalidator', $fieldID, $label);
                $additionalFields[$fieldID] = array(
@@ -152,7 +157,8 @@ class tx_linkvalidator_tasks_ValidatorAdditionalFieldProvider implements tx_sche
                        'label' => $label
                );
                $fieldID = 'task_emailOnBrokenLinkOnly';
-               $fieldCode = '<input type="checkbox"  name="tx_scheduler[linkvalidator][emailOnBrokenLinkOnly]" id="' . $fieldID . '" ' . (htmlspecialchars($taskInfo['emailOnBrokenLinkOnly']) ? 'checked="checked"' : '') . ' />';
+               $fieldCode = '<input type="checkbox"  name="tx_scheduler[linkvalidator][emailOnBrokenLinkOnly]" id="' . $fieldID . '" '
+                                        . (htmlspecialchars($taskInfo['emailOnBrokenLinkOnly']) ? 'checked="checked"' : '') . ' />';
                $label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.validate.emailOnBrokenLinkOnly');
                $label = t3lib_BEfunc::wrapInHelp('linkvalidator', $fieldID, $label);
                $additionalFields[$fieldID] = array(
@@ -161,7 +167,8 @@ class tx_linkvalidator_tasks_ValidatorAdditionalFieldProvider implements tx_sche
                );
 
                $fieldID = 'task_emailTemplateFile';
-               $fieldCode = '<input type="text"  name="tx_scheduler[linkvalidator][emailTemplateFile]" id="' . $fieldID . '" value="' . htmlspecialchars($taskInfo['emailTemplateFile']) . '" />';
+               $fieldCode = '<input type="text"  name="tx_scheduler[linkvalidator][emailTemplateFile]" id="' . $fieldID
+                                        . '" value="' . htmlspecialchars($taskInfo['emailTemplateFile']) . '" />';
                $label = $GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.validate.emailTemplateFile');
                $label = t3lib_BEfunc::wrapInHelp('linkvalidator', $fieldID, $label);
                $additionalFields[$fieldID] = array(
@@ -202,7 +209,7 @@ class tx_linkvalidator_tasks_ValidatorAdditionalFieldProvider implements tx_sche
        public function validateAdditionalFields(array &$submittedData, tx_scheduler_Module $schedulerModule) {
                $isValid = TRUE;
 
-               //TODO add validation to validate the $submittedData['configuration'] which is normally a comma separated string
+                       //TODO add validation to validate the $submittedData['configuration'] which is normally a comma separated string
                if (!empty($submittedData['linkvalidator']['email'])) {
                        $emailList = t3lib_div::trimExplode(',', $submittedData['linkvalidator']['email']);
                        foreach ($emailList as $emailAdd) {
@@ -224,6 +231,7 @@ class tx_linkvalidator_tasks_ValidatorAdditionalFieldProvider implements tx_sche
                                        t3lib_FlashMessage::ERROR
                                );
                        }
+                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
                } else {
                        $isValid = FALSE;
                        $schedulerModule->addMessage(
@@ -256,10 +264,9 @@ class tx_linkvalidator_tasks_ValidatorAdditionalFieldProvider implements tx_sche
                $task->setDepth($submittedData['linkvalidator']['depth']);
                $task->setPage($submittedData['linkvalidator']['page']);
                $task->setEmail($submittedData['linkvalidator']['email']);
-               if($submittedData['linkvalidator']['emailOnBrokenLinkOnly']){
+               if ($submittedData['linkvalidator']['emailOnBrokenLinkOnly']) {
                        $task->setEmailOnBrokenLinkOnly(1);
-               }
-               else{
+               } else {
                        $task->setEmailOnBrokenLinkOnly(0);
                }
                $task->setConfiguration($submittedData['linkvalidator']['configuration']);
index fb87bde..9e7d54e 100644 (file)
@@ -108,7 +108,8 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
        protected $refreshListHtml;
 
        /**
-        * Html for the statistics table with the checkboxes of the link types and the numbers of broken links for report tab
+        * Html for the statistics table with the checkboxes of the link types
+        * and the numbers of broken links for report tab
         *
         * @var string
         */
@@ -116,7 +117,8 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
 
 
        /**
-        * Html for the statistics table with the checkboxes of the link types and the numbers of broken links for check links tab
+        * Html for the statistics table with the checkboxes of the link types
+        * and the numbers of broken links for check links tab
         *
         * @var string
         */
@@ -129,6 +131,9 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
         */
        protected $content;
 
+       /** @var t3lib_pageRenderer $pageRenderer */
+       protected $pageRenderer;
+
        /**
         * Main method of modfuncreport
         *
@@ -151,7 +156,7 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                $set = t3lib_div::_GP($prefix . 'SET');
                $this->pObj->handleExternalFunctionValue();
 
-               if(isset($this->searchLevel)) {
+               if (isset($this->searchLevel)) {
                        $this->pObj->MOD_SETTINGS['searchlevel'] = $this->searchLevel;
                } else {
                        $this->searchLevel = $this->pObj->MOD_SETTINGS['searchlevel'];
@@ -178,42 +183,41 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                $this->initialize();
                        // Setting up the context sensitive menu
                $this->resPath = $this->doc->backPath . t3lib_extMgm::extRelPath('linkvalidator') . 'res/';
-                       /** @var t3lib_pageRenderer $pageRenderer */
                $this->pageRenderer = $this->doc->getPageRenderer();
 
                        // Localization
                $this->pageRenderer->addInlineLanguageLabelFile(t3lib_extMgm::extPath('linkvalidator', 'modfuncreport/locallang.xml'));
 
 
-       $this->pageRenderer->addJsInlineCode('linkvalidator','function toggleActionButton(prefix) {
+               $this->pageRenderer->addJsInlineCode('linkvalidator', 'function toggleActionButton(prefix) {
                        var buttonDisable = true;
                        Ext.select(\'.\' + prefix ,false).each(function(checkBox,i){
                        checkDom = checkBox.dom;
-                       if(checkDom.checked){
+                       if (checkDom.checked){
                                buttonDisable = false;
                        }
 
                        });
-                       if(prefix == \'check\'){
+                       if (prefix == \'check\'){
                                checkSub = document.getElementById(\'updateLinkList\');
-                       }
-                       else{
+                       } else {
                                checkSub = document.getElementById(\'refreshLinkList\');
                        }
                        checkSub.disabled = buttonDisable;
-
-
                }');
+
                        // Add JS
                $this->pageRenderer->addJsFile($this->doc->backPath . '../t3lib/js/extjs/ux/Ext.ux.FitToParent.js');
                $this->pageRenderer->addJsFile($this->doc->backPath . '../t3lib/js/extjs/ux/flashmessages.js');
                $this->pageRenderer->addJsFile($this->doc->backPath . 'js/extjs/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="'
+                                                                       . $GLOBALS['LANG']->getLL('label_update') . '"/>';
                }
 
-               $this->refreshListHtml = '<input type="submit" name="refreshLinkList" id="refreshLinkList"  value="' . $GLOBALS['LANG']->getLL('label_refresh') . '"/>';
+               $this->refreshListHtml = '<input type="submit" name="refreshLinkList" id="refreshLinkList"  value="'
+                                                                . $GLOBALS['LANG']->getLL('label_refresh') . '"/>';
 
                $this->processor = t3lib_div::makeInstance('tx_linkvalidator_Processor');
                $this->updateBrokenLinks();
@@ -234,8 +238,8 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                $panelCheck = '';
                if ($this->modTS['showCheckLinkTab'] == 1) {
                        $panelCheck = "{
-                      title: TYPO3.l10n.localize('CheckLink'),
-                      html: " . json_encode($this->flush()) . ",
+                               title: TYPO3.l10n.localize('CheckLink'),
+                               html: " . json_encode($this->flush()) . ",
                        }";
                }
 
@@ -266,7 +270,7 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
         * @return array Module menu
         */
        public function modMenu() {
-               $modMenu = array (
+               $modMenu = array(
                        'checkAllLink' => 0,
                );
 
@@ -342,7 +346,7 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                        );
 
 
-                       if ($this->pObj->pageinfo['hidden'] == 0 || $this->modTS['checkhidden'] == 1){
+                       if ($this->pObj->pageinfo['hidden'] == 0 || $this->modTS['checkhidden'] == 1) {
                                $pageList .= $this->pObj->id;
                        }
 
@@ -389,7 +393,7 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                $content = $this->doc->moduleBody(
                        $this->pageRecord,
                        $this->getDocHeaderButtons(),
-                       ($form) ? $this->getTemplateMarkers(): $this->getTemplateMarkersCheck()
+                       ($form) ? $this->getTemplateMarkers() : $this->getTemplateMarkersCheck()
                );
 
                return $content;
@@ -413,7 +417,11 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                );
 
                foreach ($parts as $kv => $label) {
-                       $opt[] = '<option value="' . $kv . '"' . ($kv == intval($this->searchLevel) ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>';
+                       $opt[] = '<option value="' . $kv . '"'
+                                       . ($kv == intval($this->searchLevel)
+                                       ? ' selected="selected"'
+                                       : '') . '>' . htmlspecialchars($label)
+                                       . '</option>';
                }
                $lMenu = '<select name="search_levels">' . implode('', $opt) . '</select>';
                return $lMenu;
@@ -442,7 +450,7 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                                $GLOBALS['BE_USER']->getPagePermsClause(1),
                                $this->modTS['checkhidden']
                        );
-                       if ($this->pObj->pageinfo['hidden'] == 0 || $this->modTS['checkhidden'] == 1){
+                       if ($this->pObj->pageinfo['hidden'] == 0 || $this->modTS['checkhidden'] == 1) {
                                $pageList .= $this->pObj->id;
                        }
 
@@ -463,7 +471,7 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                                        $brokenLinksMarker = $this->startTable();
 
                                                // Table rows containing the broken links
-                                       while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
+                                       while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) !== FALSE) {
                                                $items[] = $this->renderTableRow($row['table_name'], $row, $brokenLinksItemTemplate);
                                        }
                                        $brokenLinkItems = implode(chr(10), $items);
@@ -483,7 +491,7 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                return $content;
        }
 
-       protected  function getNoBrokenLinkMessage($brokenLinksMarker){
+       protected function getNoBrokenLinkMessage($brokenLinksMarker) {
                $brokenLinksMarker['LIST_HEADER'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header'));
                $message = t3lib_div::makeInstance(
                        't3lib_FlashMessage',
@@ -514,7 +522,7 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                $makerTableHead['tablehead_lastcheck'] = $GLOBALS['LANG']->getLL('list.tableHead.lastCheck');
 
                        // Add CSH to the header of each column
-               foreach($makerTableHead as $column => $label) {
+               foreach ($makerTableHead as $column => $label) {
                        $label = t3lib_BEfunc::wrapInHelp('linkvalidator', $column, $label);
                        $makerTableHead[$column] = $label;
                }
@@ -544,13 +552,13 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
 
                $params = '&edit[' . $table . '][' . $row['record_uid'] . ']=edit';
                $actionLinks = '<a href="#" onclick="' .
-                               t3lib_BEfunc::editOnClick(
-                                       $params,
-                                       $GLOBALS['BACK_PATH'],
-                                       t3lib_div::getIndpEnv('REQUEST_URI') . '?id=' . $this->pObj->id . '&search_levels=' . $this->searchLevel
-                               ) . '"' .
-                               ' title="' . $GLOBALS['LANG']->getLL('list.edit') . '">' .
-                               t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>';
+                                          t3lib_BEfunc::editOnClick(
+                                                  $params,
+                                                  $GLOBALS['BACK_PATH'],
+                                                  t3lib_div::getIndpEnv('REQUEST_URI') . '?id=' . $this->pObj->id . '&search_levels=' . $this->searchLevel
+                                          ) . '"' .
+                                          ' title="' . $GLOBALS['LANG']->getLL('list.edit') . '">' .
+                                          t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>';
 
                $elementHeadline = $row['headline'];
                if (empty($elementHeadline)) {
@@ -563,7 +571,7 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                        $fieldName = $GLOBALS['LANG']->sL($fieldName);
                                // Crop colon from end if present
                        if (substr($fieldName, '-1', '1') === ':') {
-                               $fieldName = substr($fieldName, '0', strlen($fieldName)-1);
+                               $fieldName = substr($fieldName, '0', strlen($fieldName) - 1);
                        }
                }
                        // Fallback, if there is no label
@@ -608,7 +616,7 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
        protected function getCheckOptions(array $brokenLinkOverView, $prefix = '') {
                $markerArray = array();
                $additionalAttr = '';
-               if(!empty($prefix)) {
+               if (!empty($prefix)) {
                        $additionalAttr = ' onclick="toggleActionButton(\'' . $prefix . '\');" class="' . $prefix . '" ';
                }
                else {
@@ -616,7 +624,6 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                }
                $checkOptionsTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###CHECKOPTIONS_SECTION###');
 
-               $hookSectionContent = '';
                $hookSectionTemplate = t3lib_parsehtml::getSubpart($checkOptionsTemplate, '###HOOK_SECTION###');
 
                $markerArray['statistics_header'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('report.statistics.header'));
@@ -648,8 +655,10 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                                                }
                                                $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>';
+                                               $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 .= t3lib_parsehtml::substituteMarkerArray($hookSectionTemplate, $hookSectionMarker, '###|###', TRUE, TRUE);
                                        }
@@ -710,15 +719,15 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
         */
        protected function getTemplateMarkers() {
                $markers = array(
-                       'FUNC_TITLE'            => $GLOBALS['LANG']->getLL('report.func.title'),
-                       'CHECKOPTIONS_TITLE'    => $GLOBALS['LANG']->getLL('report.statistics.header'),
-                       'FUNC_MENU'             => $this->getLevelSelector(),
-                       'CONTENT'               => $this->content,
-                       'CHECKALLLINK'          => $this->checkAllHtml,
-                       'CHECKOPTIONS'          => $this->checkOptHtml,
-                       'ID'                    => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />',
-                       'REFRESH'               => $this->refreshListHtml,
-                       'UPDATE'                => ''
+                       'FUNC_TITLE' => $GLOBALS['LANG']->getLL('report.func.title'),
+                       'CHECKOPTIONS_TITLE' => $GLOBALS['LANG']->getLL('report.statistics.header'),
+                       'FUNC_MENU' => $this->getLevelSelector(),
+                       'CONTENT' => $this->content,
+                       'CHECKALLLINK' => $this->checkAllHtml,
+                       'CHECKOPTIONS' => $this->checkOptHtml,
+                       'ID' => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />',
+                       'REFRESH' => $this->refreshListHtml,
+                       'UPDATE' => ''
                );
 
                return $markers;
@@ -731,15 +740,15 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
         */
        protected function getTemplateMarkersCheck() {
                $markers = array(
-                       'FUNC_TITLE'                    =>$GLOBALS['LANG']->getLL('checklinks.func.title'),
-                       'CHECKOPTIONS_TITLE'    =>$GLOBALS['LANG']->getLL('checklinks.statistics.header'),
-                       'FUNC_MENU'             => $this->getLevelSelector(),
-                       'CONTENT'               => '',
-                       'CHECKALLLINK'          => $this->checkAllHtml,
-                       'CHECKOPTIONS'          => $this->checkOptHtmlCheck,
-                       'ID'                    => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />',
-                       'REFRESH'               => '',
-                       'UPDATE'                => $this->updateListHtml
+                       'FUNC_TITLE' => $GLOBALS['LANG']->getLL('checklinks.func.title'),
+                       'CHECKOPTIONS_TITLE' => $GLOBALS['LANG']->getLL('checklinks.statistics.header'),
+                       'FUNC_MENU' => $this->getLevelSelector(),
+                       'CONTENT' => '',
+                       'CHECKALLLINK' => $this->checkAllHtml,
+                       'CHECKOPTIONS' => $this->checkOptHtmlCheck,
+                       'ID' => '<input type="hidden" name="id" value="' . $this->pObj->id . '" />',
+                       'REFRESH' => '',
+                       'UPDATE' => $this->updateListHtml
                );
 
                return $markers;
@@ -752,7 +761,7 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
         * @return boolean Whether the current user is admin
         */
        protected function isCurrentUserAdmin() {
-               return ((bool) $GLOBALS['BE_USER']->user['admin']);
+               return ((bool)$GLOBALS['BE_USER']->user['admin']);
        }
 }