[ Index ]
 

Code source de Typo3 4.1.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/typo3/sysext/lowlevel/clmods/ -> class.deleted.php (source)

   1  <?php
   2  /***************************************************************
   3  *  Copyright notice
   4  *
   5  *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
   6  *  All rights reserved
   7  *
   8  *  This script is part of the TYPO3 project. The TYPO3 project is
   9  *  free software; you can redistribute it and/or modify
  10  *  it under the terms of the GNU General Public License as published by
  11  *  the Free Software Foundation; either version 2 of the License, or
  12  *  (at your option) any later version.
  13  *
  14  *  The GNU General Public License can be found at
  15  *  http://www.gnu.org/copyleft/gpl.html.
  16  *  A copy is found in the textfile GPL.txt and important notices to the license
  17  *  from the author is found in LICENSE.txt distributed with these scripts.
  18  *
  19  *
  20  *  This script is distributed in the hope that it will be useful,
  21  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  22  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23  *  GNU General Public License for more details.
  24  *
  25  *  This copyright notice MUST APPEAR in all copies of the script!
  26  ***************************************************************/
  27  /**
  28   * Cleaner module: Deleted records
  29   * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
  30   *
  31   * @author    Kasper Skårhøj <kasperYYYY@typo3.com>
  32   */
  33  /**
  34   * [CLASS/FUNCTION INDEX of SCRIPT]
  35   *
  36   *
  37   *
  38   *   56: class tx_lowlevel_deleted extends tx_lowlevel_cleaner_core
  39   *   63:     function tx_lowlevel_deleted()
  40   *   88:     function main()
  41   *  116:     function main_autoFix($resultArray)
  42   *
  43   * TOTAL FUNCTIONS: 3
  44   * (This index is automatically created/updated by the extension "extdeveval")
  45   *
  46   */
  47  
  48  
  49  /**
  50   * Looking for Deleted records
  51   *
  52   * @author    Kasper Skårhøj <kasperYYYY@typo3.com>
  53   * @package TYPO3
  54   * @subpackage tx_lowlevel
  55   */
  56  class tx_lowlevel_deleted extends tx_lowlevel_cleaner_core {
  57  
  58      /**
  59       * Constructor
  60       *
  61       * @return    [type]        ...
  62       */
  63  	function tx_lowlevel_deleted()    {
  64          parent::tx_lowlevel_cleaner_core();
  65  
  66              // Setting up help:
  67          $this->cli_options[] = array('--echotree level', 'When "level" is set to 1 or higher you will see the page of the page tree outputted as it is traversed. A value of 2 for "level" will show even more information.');
  68          $this->cli_options[] = array('--pid id', 'Setting start page in page tree. Default is the page tree root, 0 (zero)');
  69          $this->cli_options[] = array('--depth int', 'Setting traversal depth. 0 (zero) will only analyse start page (see --pid), 1 will traverse one level of subpages etc.');
  70  
  71          $this->cli_help['name'] = 'deleted -- To find and flush deleted records in the page tree';
  72          $this->cli_help['description'] = trim('
  73  Traversing page tree and finding deleted records
  74  
  75  Automatic Repair:
  76  Although deleted records are not errors to be repaired, this tool allows you to flush the deleted records completely from the system as an automatic action. Limiting this lookup by --pid and --depth can help you to narrow in the operation to a part of the page tree.
  77  ');
  78  
  79          $this->cli_help['examples'] = '';
  80      }
  81  
  82      /**
  83       * Find orphan records
  84       * VERY CPU and memory intensive since it will look up the whole page tree!
  85       *
  86       * @return    array
  87       */
  88  	function main() {
  89          global $TYPO3_DB;
  90  
  91              // Initialize result array:
  92          $resultArray = array(
  93              'message' => $this->cli_help['name'].chr(10).chr(10).$this->cli_help['description'],
  94              'headers' => array(
  95                  'deleted' => array('Index of deleted records','These are records from the page tree having the deleted-flag set. The --AUTOFIX option will flush them completely!',1),
  96              ),
  97              'deleted' => array(),
  98          );
  99  
 100          $startingPoint = $this->cli_isArg('--pid') ? t3lib_div::intInRange($this->cli_argValue('--pid'),0) : 0;
 101          $depth = $this->cli_isArg('--depth') ? t3lib_div::intInRange($this->cli_argValue('--depth'),0) : 1000;
 102          $this->genTree($startingPoint,$depth,(int)$this->cli_argValue('--echotree'));
 103  
 104          $resultArray['deleted'] = $this->recStats['deleted'];
 105  
 106          return $resultArray;
 107      }
 108  
 109      /**
 110       * Mandatory autofix function
 111       * Will run auto-fix on the result array. Echos status during processing.
 112       *
 113       * @param    array        Result array from main() function
 114       * @return    void
 115       */
 116  	function main_autoFix($resultArray)    {
 117  
 118              // Putting "tx_templavoila_datastructure" table in the bottom:
 119          if (isset($resultArray['deleted']['tx_templavoila_datastructure']))    {
 120              $_tx_templavoila_datastructure = $resultArray['deleted']['tx_templavoila_datastructure'];
 121              unset($resultArray['deleted']['tx_templavoila_datastructure']);
 122              $resultArray['deleted']['tx_templavoila_datastructure'] = $_tx_templavoila_datastructure;
 123          }
 124  
 125              // Putting "pages" table in the bottom:
 126          if (isset($resultArray['deleted']['pages']))    {
 127              $_pages = $resultArray['deleted']['pages'];
 128              unset($resultArray['deleted']['pages']);
 129              $resultArray['deleted']['pages'] = array_reverse($_pages);    // To delete sub pages first assuming they are accumulated from top of page tree.
 130          }
 131  
 132              // Traversing records:
 133          foreach($resultArray['deleted'] as $table => $list)    {
 134              echo 'Flushing deleted records from table "'.$table.'":'.chr(10);
 135              foreach($list as $uid)    {
 136                  echo '    Flushing record "'.$table.':'.$uid.'": ';
 137                  if ($bypass = $this->cli_noExecutionCheck($table.':'.$uid))    {
 138                      echo $bypass;
 139                  } else {
 140  
 141                          // Execute CMD array:
 142                      $tce = t3lib_div::makeInstance('t3lib_TCEmain');
 143                      $tce->stripslashes_values = FALSE;
 144                      $tce->start(array(),array());
 145                      $tce->deleteRecord($table,$uid, TRUE, TRUE);    // Notice, we are deleting pages with no regard to subpages/subrecords - we do this since they should also be included in the set of deleted pages of course (no un-deleted record can exist under a deleted page...)
 146  
 147                          // Return errors if any:
 148                      if (count($tce->errorLog))    {
 149                          echo '    ERROR from "TCEmain":'.chr(10).'TCEmain:'.implode(chr(10).'TCEmain:',$tce->errorLog);
 150                      } else echo "DONE";
 151                  }
 152                  echo chr(10);
 153              }
 154          }
 155      }
 156  }
 157  
 158  ?>


Généré le : Sun Nov 25 17:13:16 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics