Fixed bug #13828: checkhidden has no effect for some configurations (Michael Miousse)
authortypo3.lists <typo3.lists@philippgampe.info>
Wed, 18 May 2011 15:39:22 +0000 (15:39 +0000)
committertypo3.lists <typo3.lists@philippgampe.info>
Wed, 18 May 2011 15:39:22 +0000 (15:39 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/linkvalidator/trunk@47877 735d13b6-9817-0410-8766-e36946ffe9aa

typo3/sysext/linkvalidator/ChangeLog
typo3/sysext/linkvalidator/classes/class.tx_linkvalidator_processor.php
typo3/sysext/linkvalidator/classes/tasks/class.tx_linkvalidator_tasks_validator.php
typo3/sysext/linkvalidator/modfuncreport/class.tx_linkvalidator_modfuncreport.php

index 69233b9..ba95ed0 100644 (file)
@@ -1,6 +1,10 @@
+2011-05-18  Philipp Gampe  <forge.typo3.org@philippgampe.info>
+
+       * Fixed bug #13828: checkhidden has no effect for some configurations (Michael Miousse)
+
 2011-04-26     Michael Miousse  <michael.miousse@infoglobe.ca>
 
-       * Fixed bug #13757 Scheduler task does not work at all
+       * Fixed bug #13757: Scheduler task does not work at all
 
 2011-04-21     Michael Miousse  <michael.miousse@infoglobe.ca>
 
index e00f74c..1c675c4 100644 (file)
@@ -390,7 +390,7 @@ class tx_linkvalidator_Processor {
         * @param       string          Perms clause
         * @return      string          Returns the list with a comma in the end (if any pages selected!)
         */
-       public function extGetTreeList($id, $depth, $begin = 0, $permsClause) {
+       public function extGetTreeList($id, $depth, $begin = 0, $permsClause,  $considerHidden = FALSE) {
                $depth = intval($depth);
                $begin = intval($begin);
                $id = intval($id);
@@ -398,23 +398,48 @@ class tx_linkvalidator_Processor {
 
                if ($depth > 0) {
                        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                               'uid,title',
+                               'uid,title,hidden,extendToSubpages',
                                'pages',
                                'pid=' . $id . ' AND deleted=0 AND ' . $permsClause
                        );
+                       
                        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                               if ($begin <= 0) {
+                               if ($begin <= 0 && ($row['hidden']==0 || $considerHidden == 1)) {
                                        $theList .= $row['uid'] . ',';
                                        $this->extPageInTreeInfo[] = array($row['uid'], htmlspecialchars($row['title'], $depth));
                                }
-                               if ($depth > 1) {
-                                       $theList .= $this->extGetTreeList($row['uid'], $depth - 1, $begin - 1, $permsClause);
+                               if ($depth > 1 && (!($row['hidden']==1 && $row['extendToSubpages']==1) || $considerHidden == 1)) {
+                                       $theList .= $this->extGetTreeList($row['uid'], $depth - 1, $begin - 1, $permsClause, $considerHidden);
                                }
                        }
                }
                return $theList;
        }
 
+       public function getRootLineIsHidden($pageInfo){
+               $hidden = FALSE;
+               if($pageInfo['extendToSubpages'] == 1 && $pageInfo['hidden'] == 1){
+                       $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)) {
+                                       $hidden = $this->getRootLineIsHidden($row);
+                               }
+                       }
+                       else {
+                               $hidden = FALSE;
+                       }
+               }
+               return $hidden;
+                       
+       }
 
 }
 
index bc874d3..3b97fa5 100644 (file)
@@ -283,12 +283,27 @@ class tx_linkvalidator_tasks_Validator extends tx_scheduler_Task {
                $searchFields = $this->getSearchField($modTS);
                $linkTypes = $this->getLinkTypes($modTS);
                $processor = t3lib_div::makeInstance('tx_linkvalidator_Processor');
-               $pageIds = $processor->extGetTreeList($page, $this->depth, 0, '1=1');
-               $pageIds .= $page;
-               $processor->init($searchFields, $pageIds);
-               if (!empty($this->email)) {
-                       $oldLinkCounts = $processor->getLinkCounts($page);
-                       $this->oldTotalBrokenLink += $oldLinkCounts['brokenlinkCount'];
+               $pageRow = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'pages', 'uid=' . $page);
+               $rootLineHidden = $processor->getRootLineIsHidden($pageRow);
+               if(!$rootLineHidden || $modTS['checkhidden']==1) {
+                       $pageIds = $processor->extGetTreeList($page, $this->depth, 0, '1=1', $modTS['checkhidden']);
+                       if($pageRow['hidden'] == 0 || $modTS['checkhidden']==1){
+                               $pageIds .= $page;
+                       }
+               
+                       $processor->init($searchFields, $pageIds);
+                       if (!empty($this->email)) {
+                               $oldLinkCounts = $processor->getLinkCounts($page);
+                               $this->oldTotalBrokenLink += $oldLinkCounts['brokenlinkCount'];
+                       }
+       
+                       $processor->getLinkStatistics($array, $modTS['checkhidden']);
+       
+                       if (!empty($this->email)) {
+                               $linkCounts = $processor->getLinkCounts($page);
+                               $this->totalBrokenLink += $linkCounts['brokenlinkCount'];
+                               $pageSections = $this->buildMail($page, $pageIds, $linkCounts, $oldLinkCounts);
+                       }
                }
 
                $processor->getLinkStatistics($linkTypes, $modTS['checkhidden']);
@@ -337,30 +352,11 @@ class tx_linkvalidator_tasks_Validator extends tx_scheduler_Task {
         * @return      array   $searchFields: list of fields.
         */
        protected function getSearchField($modTS) {
-                       // get the searchFields from TCA
-               foreach ($GLOBALS['TCA'] as $tableName => $table) {
-                       if (!empty($table['columns'])) {
-                               foreach ($table['columns'] as $columnName => $column) {
-                                       if ($column['config']['type'] == 'text' || $column['config']['type'] == 'input') {
-                                               if (!empty($column['config']['softref']) && (stripos($column['config']['softref'], "typolink")
-                                                               !== FALSE || stripos($column['config']['softref'], "url") !== FALSE)) {
-
-                                                       $searchFields[$tableName][] = $columnName;
-                                               }
-                                       }
-                               }
-                       }
-               }
-
                        // get the searchFields from TypoScript
                foreach ($modTS['searchFields.'] as $table => $fieldList) {
                        $fields = t3lib_div::trimExplode(',', $fieldList);
                        foreach ($fields as $field) {
-                               if (is_array($searchFields[$table])) {
-                                       if (array_search($field, $searchFields[$table]) === FALSE) {
-                                               $searchFields[$table][] = $field;
-                                       }
-                               }
+                               $searchFields[$table][] = $field;
                        }
                }
                return $searchFields;
index 8261d29..a7d651b 100644 (file)
@@ -332,26 +332,34 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
                                }
                        }
                }
-                       // get children pages
-               $pageList = $this->processor->extGetTreeList(
-                       $this->pObj->id,
-                       $this->searchLevel,
-                       0,
-                       $GLOBALS['BE_USER']->getPagePermsClause(1)
-               );
-               $pageList .= $this->pObj->id;
-
-               $this->processor->init($searchFields, $pageList);
-
-                       // check if button press
-               $update = t3lib_div::_GP('updateLinkList');
-
-               if (!empty($update)) {
-                       $this->processor->getLinkStatistics($this->checkOpt, $this->modTS['checkhidden']);
+               $rootLineHidden = $this->processor->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->pObj->id;
+                       }
+               
+
+                       $this->processor->init($searchFields, $pageList);
+       
+                               // check if button press
+                       $update = t3lib_div::_GP('updateLinkList');
+               
+                       if (!empty($update)) {
+                               $this->processor->getLinkStatistics($this->checkOpt, $this->modTS['checkhidden']);
+                       }
                }
        }
 
-
        /**
         * Renders the content of the module.
         *
@@ -421,64 +429,75 @@ class tx_linkvalidator_ModFuncReport extends t3lib_extobjbase {
        protected function renderBrokenLinksTable() {
                $items = $brokenLinksMarker = array();
                $brokenLinkItems = $brokenLinksTemplate = '';
+               $brokenLinksTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###NOBROKENLINKS_CONTENT###');
                $keyOpt = array();
 
                if (is_array($this->checkOpt)) {
                        $keyOpt = array_keys($this->checkOpt);
                }
-
-               $pageList = $this->processor->extGetTreeList(
-                       $this->pObj->id,
-                       $this->searchLevel,
-                       0,
-                       $GLOBALS['BE_USER']->getPagePermsClause(1)
-               );
-               $pageList .= $this->pObj->id;
-
-               if (($res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                       '*',
-                       'tx_linkvalidator_link',
-                       'record_pid in (' . $pageList . ') and link_type in (\'' . implode("','", $keyOpt) . '\')',
-                       '',
-                       'record_uid ASC, uid ASC')
-               )) {
+               $rootLineHidden = $this->processor->getRootLineIsHidden($this->pObj->pageinfo);
+               if(!$rootLineHidden || $this->modTS['checkhidden']==1) {
+                       $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->pObj->id;
+                       }
+               
+                       if (($res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                               '*',
+                               'tx_linkvalidator_link',
+                               'record_pid in (' . $pageList . ') and link_type in (\'' . implode("','", $keyOpt) . '\')',
+                               '',
+                               'record_uid ASC, uid ASC')
+                       )) {
                                // Display table with broken links
-                       if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
-                               $brokenLinksTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_CONTENT###');
-
-                               $brokenLinksItemTemplate = t3lib_parsehtml::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))) {
-                                       $items[] = $this->renderTableRow($row['table_name'], $row, $brokenLinksItemTemplate);
+                               if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
+                                       $brokenLinksTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###BROKENLINKS_CONTENT###');
+       
+                                       $brokenLinksItemTemplate = t3lib_parsehtml::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))) {
+                                               $items[] = $this->renderTableRow($row['table_name'], $row, $brokenLinksItemTemplate);
+                                       }                                       
+                                       $brokenLinkItems = implode(chr(10), $items);
+       
+                                       // Display note that there are no broken links to display
+                               } else {
+                                       $brokenLinksMarker = $this->getNoBrokenLinkMessage($brokenLinksMarker);
                                }
-                               $brokenLinkItems = implode(chr(10), $items);
-
-                               // Display note that there are no broken links to display
-                       } else {
-                               $brokenLinksTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###NOBROKENLINKS_CONTENT###');
-
-                               $brokenLinksMarker['LIST_HEADER'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header'));
-                               $message = t3lib_div::makeInstance(
-                                       't3lib_FlashMessage',
-                                       $GLOBALS['LANG']->getLL('list.no.broken.links'),
-                                       $GLOBALS['LANG']->getLL('list.no.broken.links.title'),
-                                       t3lib_FlashMessage::OK
-                               );
-                               $brokenLinksMarker['NO_BROKEN_LINKS'] = $message->render();
                        }
                }
+               else{
+                       
+                       $brokenLinksMarker = $this->getNoBrokenLinkMessage($brokenLinksMarker);
+               }
                $brokenLinksTemplate = t3lib_parsehtml::substituteMarkerArray($brokenLinksTemplate, $brokenLinksMarker, '###|###', TRUE);
-
                $content = t3lib_parsehtml::substituteSubpart($brokenLinksTemplate, '###BROKENLINKS_ITEM', $brokenLinkItems);
 
                return $content;
        }
 
-
+       protected  function getNoBrokenLinkMessage($brokenLinksMarker){ 
+               $brokenLinksMarker['LIST_HEADER'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('list.header'));
+               $message = t3lib_div::makeInstance(
+                       't3lib_FlashMessage',
+                       $GLOBALS['LANG']->getLL('list.no.broken.links'),
+                       $GLOBALS['LANG']->getLL('list.no.broken.links.title'),
+                       t3lib_FlashMessage::OK
+               );
+               $brokenLinksMarker['NO_BROKEN_LINKS'] = $message->render();
+               
+               return $brokenLinksMarker;
+       }
 
        /**
         * Displays the table header of the table with the broken links.