/**
  * Get tables for menu example
  *
  * @param	string		$format: Return format (example: json)
  * @param	boolean		$withAllOption: 0 no, 1 return tables with a "all" option
  * @param	integer		$id: UID from selected page
  * @param	integer		$depth: How many levels recursive
  * @return	string		The tables to be displayed
  */
 public function getTables($format, $withAllOption = 0, $startUid, $depth = 0)
 {
     $deletedRecordsTotal = 0;
     $tables = array();
     foreach (array_keys($GLOBALS['TCA']) as $tableName) {
         $deletedField = tx_recycler_helper::getDeletedField($tableName);
         if ($deletedField) {
             // Determine whether the table has deleted records:
             $deletedCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', $tableName, $deletedField . '!=0');
             if ($deletedCount) {
                 $deletedDataObject = t3lib_div::makeInstance('tx_recycler_model_deletedRecords');
                 $deletedData = $deletedDataObject->loadData($startUid, $tableName, $depth)->getDeletedRows();
                 if (isset($deletedData[$tableName])) {
                     if ($deletedRecordsInTable = count($deletedData[$tableName])) {
                         $deletedRecordsTotal += $deletedRecordsInTable;
                         $tables[] = array($tableName, $deletedRecordsInTable, $tableName, tx_recycler_helper::getUtf8String($GLOBALS['LANG']->sL($GLOBALS['TCA'][$tableName]['ctrl']['title'])));
                     }
                 }
             }
         }
     }
     $jsonArray = $tables;
     if ($withAllOption) {
         array_unshift($jsonArray, array('', $deletedRecordsTotal, '', $GLOBALS['LANG']->sL('LLL:EXT:recycler/mod1/locallang.xml:label_alltables')));
     }
     $output = json_encode($jsonArray);
     return $output;
 }
 /**
  * Transforms the rows for the deleted Records into the Array View necessary for ExtJS Ext.data.ArrayReader
  *
  * @param array     $rows   Array with table as key and array with all deleted rows
  * @param integer	$totalDeleted: Number of deleted records in total, for PagingToolbar
  * @return string   JSON Array
  **/
 public function transform($deletedRowsArray, $totalDeleted)
 {
     $total = 0;
     $jsonArray = array('rows' => array());
     // iterate
     if (is_array($deletedRowsArray) && count($deletedRowsArray) > 0) {
         foreach ($deletedRowsArray as $table => $rows) {
             $total += count($deletedRowsArray[$table]);
             foreach ($rows as $row) {
                 $backendUser = t3lib_BEfunc::getRecord('be_users', $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']], 'username', '', FALSE);
                 $jsonArray['rows'][] = array('uid' => $row['uid'], 'pid' => $row['pid'], 'table' => $table, 'crdate' => date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $row[$GLOBALS['TCA'][$table]['ctrl']['crdate']]), 'tstamp' => date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $row[$GLOBALS['TCA'][$table]['ctrl']['tstamp']]), 'owner' => $backendUser['username'], 'owner_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']], 'tableTitle' => tx_recycler_helper::getUtf8String($GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title'])), 'title' => tx_recycler_helper::getUtf8String(t3lib_BEfunc::getRecordTitle($table, $row)), 'path' => tx_recycler_helper::getRecordPath($row['pid']));
             }
         }
     }
     $jsonArray['total'] = $totalDeleted;
     return json_encode($jsonArray);
 }
 /**
  * Checks whether the current backend user has access to the given records.
  *
  * @param	string		$table: Name of the table
  * @param	array		$rows: Record row
  * @return	void
  */
 protected function checkRecordAccess($table, array $rows)
 {
     foreach ($rows as $key => $row) {
         if (tx_recycler_helper::checkAccess($table, $row)) {
             $this->setDeletedRows($table, $row);
         }
     }
 }