* Fixed bug #12652: If none of the link types are marked to be checked, all of them...
authormichael.miousse <michael.miousse@infoglobe.ca>
Tue, 15 Feb 2011 16:16:38 +0000 (16:16 +0000)
committermichael.miousse <michael.miousse@infoglobe.ca>
Tue, 15 Feb 2011 16:16:38 +0000 (16:16 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/linkvalidator/trunk@43646 735d13b6-9817-0410-8766-e36946ffe9aa

typo3/sysext/linkvalidator/ChangeLog
typo3/sysext/linkvalidator/classes/class.tx_linkvalidator_processor.php
typo3/sysext/linkvalidator/modfuncreport/class.tx_linkvalidator_modfuncreport.php
typo3/sysext/linkvalidator/res/linkvalidator.css

index 5f16bf1..860b853 100644 (file)
@@ -1,3 +1,5 @@
+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
 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 1ad30d3..b0d739a 100644 (file)
@@ -121,81 +121,82 @@ class tx_linkvalidator_Processor {
                if(count($checkOptions) > 0) {
                        $checkKeys = array_keys($checkOptions);
                        $checlLinkTypeCondition = ' 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\')) ' . $checlLinkTypeCondition);
-               
-                       // let's traverse all configured tables
-               foreach ($this->searchFields as $table => $fields) {
-                       if($table == 'pages'){
-                               $where = 'deleted = 0 AND uid IN (' . $this->pidList . ')';
-                       }
-                       else{
-                               $where = 'deleted = 0 AND pid IN (' . $this->pidList . ')';
-                       }
-                       if (!$considerHidden) {
-                               $where .= t3lib_BEfunc::BEenableFields($table);
-                       }
-                               // if table is not configured, we assume the ext is not installed and therefore no need to check it
-                       if (!is_array($GLOBALS['TCA'][$table])) continue;
-
-                               // 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)) {
-                               // Analyse each record
-                               $this->analyzeRecord($results, $table, $fields, $row);
+
+                       $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_linkvalidator_link', '(record_pid in (' . $this->pidList . ') or ( record_uid IN (' . $this->pidList . ') and table_name like \'pages\')) ' . $checlLinkTypeCondition);
+
+                               // let's traverse all configured tables
+                       foreach ($this->searchFields as $table => $fields) {
+                               if($table == 'pages'){
+                                       $where = 'deleted = 0 AND uid IN (' . $this->pidList . ')';
+                               }
+                               else{
+                                       $where = 'deleted = 0 AND pid IN (' . $this->pidList . ')';
+                               }
+                               if (!$considerHidden) {
+                                       $where .= t3lib_BEfunc::BEenableFields($table);
+                               }
+                                       // if table is not configured, we assume the ext is not installed and therefore no need to check it
+                               if (!is_array($GLOBALS['TCA'][$table])) continue;
+
+                                       // 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)) {
+                                       // Analyse each record
+                                       $this->analyzeRecord($results, $table, $fields, $row);
+                               }
                        }
-               }
 
-               foreach ($this->hookObjectsArr as $key => $hookObj) {
-                       if ((is_array($results[$key])) && empty($checkOptions) || (is_array($results[$key]) && $checkOptions[$key])) {
-                                       //  check'em!
-                               foreach ($results[$key] as $entryKey => $entryValue) {
-                                       $table = $entryValue['table'];
-                                       $record = array();
-                                       $record['headline'] = $entryValue['row'][$GLOBALS['TCA'][$table]['ctrl']['label']];
-                                       $record['record_pid'] = $entryValue['row']['pid'];
-                                       $record['record_uid'] = $entryValue['uid'];
-                                       $record['table_name'] = $table;
-                                       $record['link_title'] = $entryValue['link_title'];
-                                       $record['field'] = $entryValue['field'];
-                                       $record['last_check'] = time();
-
-                                       $this->recordReference = $entryValue['substr']['recordRef'];
-
-                                       $this->pageWithAnchor = $entryValue['pageAndAnchor'];
-                                       
-                                       if (!empty($this->pageWithAnchor)) {
-                                                       // page with anchor, e.g. 18#1580
-                                               $url = $this->pageWithAnchor;
-                                       } else {
-                                               $url = $entryValue['substr']['tokenValue'];
-                                       }
+                       foreach ($this->hookObjectsArr as $key => $hookObj) {
+                               if ((is_array($results[$key])) && empty($checkOptions) || (is_array($results[$key]) && $checkOptions[$key])) {
+                                               //  check'em!
+                                       foreach ($results[$key] as $entryKey => $entryValue) {
+                                               $table = $entryValue['table'];
+                                               $record = array();
+                                               $record['headline'] = $entryValue['row'][$GLOBALS['TCA'][$table]['ctrl']['label']];
+                                               $record['record_pid'] = $entryValue['row']['pid'];
+                                               $record['record_uid'] = $entryValue['uid'];
+                                               $record['table_name'] = $table;
+                                               $record['link_title'] = $entryValue['link_title'];
+                                               $record['field'] = $entryValue['field'];
+                                               $record['last_check'] = time();
+
+                                               $this->recordReference = $entryValue['substr']['recordRef'];
+
+                                               $this->pageWithAnchor = $entryValue['pageAndAnchor'];
+
+                                               if (!empty($this->pageWithAnchor)) {
+                                                               // page with anchor, e.g. 18#1580
+                                                       $url = $this->pageWithAnchor;
+                                               } else {
+                                                       $url = $entryValue['substr']['tokenValue'];
+                                               }
 
-                                       $this->linkCounts[$table]++;
-                                       $checkURL = $hookObj->checkLink($url, $entryValue, $this);
-                                               // broken link found!
-                                       if (!$checkURL) {
-                                               $response = array();
-                                               $response['valid'] = FALSE;
-                                               $response['errorParams'] = $hookObj->getErrorParams();
-                                               $this->brokenLinkCounts[$table]++;
-                                               $record['link_type'] = $key;
-                                               $record['url'] = $url;
-                                               $record['url_response'] = serialize($response);
-                                               $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_linkvalidator_link', $record);
-                                       } elseif (t3lib_div::_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->linkCounts[$table]++;
+                                               $checkURL = $hookObj->checkLink($url, $entryValue, $this);
+                                                       // broken link found!
+                                               if (!$checkURL) {
+                                                       $response = array();
+                                                       $response['valid'] = FALSE;
+                                                       $response['errorParams'] = $hookObj->getErrorParams();
+                                                       $this->brokenLinkCounts[$table]++;
+                                                       $record['link_type'] = $key;
+                                                       $record['url'] = $url;
+                                                       $record['url_response'] = serialize($response);
+                                                       $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_linkvalidator_link', $record);
+                                               } elseif (t3lib_div::_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);
+                                               }
                                        }
                                }
                        }
@@ -213,7 +214,7 @@ class tx_linkvalidator_Processor {
         * @return      void
         */
        public function analyzeRecord(&$results, $table, $fields, $record) {
-               
+
                        // array to store urls from relevant field contents
                $urls = array();
 
@@ -223,20 +224,20 @@ class tx_linkvalidator_Processor {
 
                        // flag whether row contains a broken link in some field or not
                $rowContainsBrokenLink = FALSE;
-               
+
                        // put together content of all relevant fields
                $haystack = '';
                $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml');
-               
+
                $idRecord = $record['uid'];
-               
+
                        // get all references
                foreach ($fields as $field) {
                        $haystack .= $record[$field] . ' --- ';
                        $conf = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
-                       
+
                        $valueField = $record[$field];
-                       
+
                                // Check if a TCA configured field has softreferences defined (see TYPO3 Core API document)
                        if ($conf['softref'] && strlen($valueField)) {
                                        // Explode the list of softreferences/parameters
@@ -345,7 +346,7 @@ class tx_linkvalidator_Processor {
                }
                return $markerArray;
        }
-       
+
        /**
         * Calls t3lib_tsfeBeUserAuth::extGetTreeList.
         * Although this duplicates the function t3lib_tsfeBeUserAuth::extGetTreeList
@@ -387,7 +388,7 @@ class tx_linkvalidator_Processor {
                }
                return $theList;
        }
-       
+
 
 }
 
index 4792ae5..3942b77 100644 (file)
@@ -113,8 +113,8 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
         * @var string
         */
        protected $checkOptHtml;
-       
-       
+
+
        /**
         * Html for the Statistics table with the checkboxes of the link types and the numbers of broken links for Check links tab.
         *
@@ -184,16 +184,35 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                $labels = tx_em_Tools::getArrayFromLocallang(t3lib_extMgm::extPath('linkvalidator', 'modfuncreport/locallang.xml'));
                $this->pageRenderer->addInlineLanguageLabelArray($labels);
 
+       $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 . '../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" 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" 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();
@@ -237,7 +256,8 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                        ' . $panelCheck . '
                        ]
 
-               });';
+               });
+               ';
                $this->pageRenderer->addExtOnReadyCode($js);
        }
 
@@ -569,7 +589,13 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
         */
        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 = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###CHECKOPTIONS_SECTION###');
 
                $hookSectionContent = '';
@@ -604,7 +630,7 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                                                }
                                                $translation = $GLOBALS['LANG']->getLL('hooks.' . $type);
                                                $translation = $translation ? $translation : $type;
-                                               $option =  '<input type="checkbox" id="' . $prefix . 'SET[' . $type . ']" name="' . $prefix . 'SET[' . $type . ']" value="1"' . ($this->pObj->MOD_SETTINGS[$type]  ? ' checked="checked"' : '') .
+                                               $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);
index d9fd98e..fe323c3 100644 (file)
@@ -89,4 +89,8 @@
 #linkvalidator_statsTable td:first-child,
 #linkvalidator_brokenLinksTable td:first-child {
        border-left: none;
+}
+
+input#updateLinkList:disabled, input#refreshLinkList:disabled {
+       color: graytext;
 }
\ No newline at end of file