/**
  * Render statistics about lostrecords
  *
  * @return	array		array($countTotal, $content)
  */
 function statisticsLostRecords()
 {
     global $LANG, $TCA;
     $content = '';
     $countTotal = 0;
     // init table layout
     $tableLayout = array('table' => array('<table border="0" cellspacing="1" cellpadding="2" style="width:auto;">', '</table>'), '0' => array('tr' => array('<tr class="bgColor2">', '</tr>'), 'defCol' => array('<td align="center">', '</td>')), 'defRow' => array('tr' => array('<tr class="bgColor3-20">', '</tr>'), '1' => array('<td align="center">', '</td>'), 'defCol' => array('<td>', '</td>')));
     $tableOutput = array();
     $tr = 0;
     // add header row
     $tableOutput[$tr][] = 'Table';
     $tableOutput[$tr][] = 'Count';
     $mediaTables = tx_dam::register_getEntries('mediaTable');
     foreach ($mediaTables as $table) {
         $count = 0;
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('COUNT(uid) as count', $table, $table . '.pid NOT IN (' . tx_dam_db::getPidList() . ')');
         if ($res) {
             $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
             $count = $row['count'];
             $countTotal += $count;
         }
         $title = is_array($TCA[$table]) ? $GLOBALS['LANG']->sl($TCA[$table]['ctrl']['title']) : $table;
         $icon = t3lib_iconWorks::getIconImage($table, array(), $GLOBALS['BACK_PATH'], ' align="top"');
         // add row to table
         $tr++;
         $tableOutput[$tr][] = $icon . $title . ' (' . $table . ')';
         $tableOutput[$tr][] = $count;
     }
     $content .= $this->pObj->doc->table($tableOutput, $tableLayout);
     return array($countTotal, $content);
 }
 /**
  * Move lost DAM records to the DAM sysfolder.
  * This is a maintance function.
  *
  * @param	integer		$pid If set this PID will be used as storage sysfolder for the lost folder.
  * @param	boolean		$forceAll If true (default) all DAM records will be moved not only the ony with pid=0.
  * @return	void
  */
 function collectLostRecords($pid = NULL, $forceAll = true)
 {
     $pid = $pid ? $pid : tx_dam_db::getPid();
     if ($pid) {
         $mediaTables = tx_dam::register_getEntries('mediaTable');
         $values = array('pid' => $pid);
         if ($forceAll) {
             foreach ($mediaTables as $table) {
                 $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, $table . '.pid NOT IN (' . tx_dam_sysfolder::getPidList() . ')', $values);
             }
         } else {
             foreach ($mediaTables as $table) {
                 $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, $table . '.pid=0', $values);
             }
         }
     }
 }