Esempio n. 1
0
 /**
  * Get tables for menu example
  *
  * @param int $startUid UID from selected page
  * @param int $depth How many levels recursive
  * @return string The tables to be displayed
  */
 public function getTables($startUid, $depth = 0)
 {
     $deletedRecordsTotal = 0;
     $lang = $this->getLanguageService();
     $tables = array();
     foreach (RecyclerUtility::getModifyableTables() as $tableName) {
         $deletedField = RecyclerUtility::getDeletedField($tableName);
         if ($deletedField) {
             // Determine whether the table has deleted records:
             $deletedCount = $this->getDatabaseConnection()->exec_SELECTcountRows('uid', $tableName, $deletedField . '<>0');
             if ($deletedCount) {
                 /* @var $deletedDataObject \TYPO3\CMS\Recycler\Domain\Model\DeletedRecords */
                 $deletedDataObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Recycler\Domain\Model\DeletedRecords::class);
                 $deletedData = $deletedDataObject->loadData($startUid, $tableName, $depth)->getDeletedRows();
                 if (isset($deletedData[$tableName])) {
                     if ($deletedRecordsInTable = count($deletedData[$tableName])) {
                         $deletedRecordsTotal += $deletedRecordsInTable;
                         $tables[] = array($tableName, $deletedRecordsInTable, RecyclerUtility::getUtf8String($lang->sL($GLOBALS['TCA'][$tableName]['ctrl']['title'])));
                     }
                 }
             }
         }
     }
     $jsonArray = $tables;
     array_unshift($jsonArray, array('', $deletedRecordsTotal, $lang->sL('LLL:EXT:recycler/mod1/locallang.xlf:label_allrecordtypes')));
     return $jsonArray;
 }
Esempio n. 2
0
 /**
  * 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 = \TYPO3\CMS\Recycler\Utility\RecyclerUtility::getDeletedField($tableName);
         if ($deletedField) {
             // Determine whether the table has deleted records:
             $deletedCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', $tableName, $deletedField . '<>0');
             if ($deletedCount) {
                 $deletedDataObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Recycler\\Domain\\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, \TYPO3\CMS\Recycler\Utility\RecyclerUtility::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.xlf: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 = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('be_users', $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']], 'username', '', FALSE);
                 $jsonArray['rows'][] = array('uid' => $row['uid'], 'pid' => $row['pid'], 'table' => $table, 'crdate' => \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['crdate']]), 'tstamp' => \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['tstamp']]), 'owner' => htmlspecialchars($backendUser['username']), 'owner_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']], 'tableTitle' => \TYPO3\CMS\Recycler\Utility\RecyclerUtility::getUtf8String($GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title'])), 'title' => htmlspecialchars(\TYPO3\CMS\Recycler\Utility\RecyclerUtility::getUtf8String(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($table, $row))), 'path' => \TYPO3\CMS\Recycler\Utility\RecyclerUtility::getRecordPath($row['pid']));
             }
         }
     }
     $jsonArray['total'] = $totalDeleted;
     return json_encode($jsonArray);
 }
 /**
  * Transforms the rows for the deleted records
  *
  * @param array $deletedRowsArray Array with table as key and array with all deleted rows
  * @param int $totalDeleted Number of deleted records in total
  * @return string JSON array
  */
 public function transform($deletedRowsArray, $totalDeleted)
 {
     $total = 0;
     $jsonArray = array('rows' => array());
     if (is_array($deletedRowsArray)) {
         $lang = $this->getLanguageService();
         $backendUser = $this->getBackendUser();
         foreach ($deletedRowsArray as $table => $rows) {
             $total += count($deletedRowsArray[$table]);
             foreach ($rows as $row) {
                 $pageTitle = $this->getPageTitle((int) $row['pid']);
                 $backendUser = BackendUtility::getRecord('be_users', $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']], 'username', '', FALSE);
                 $jsonArray['rows'][] = array('uid' => $row['uid'], 'pid' => $row['pid'], 'icon' => IconUtility::getSpriteIconForRecord($table, $row), 'pageTitle' => RecyclerUtility::getUtf8String($pageTitle), 'table' => $table, 'crdate' => BackendUtility::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['crdate']]), 'tstamp' => BackendUtility::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['tstamp']]), 'owner' => htmlspecialchars($backendUser['username']), 'owner_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']], 'tableTitle' => RecyclerUtility::getUtf8String($lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'])), 'title' => htmlspecialchars(RecyclerUtility::getUtf8String(BackendUtility::getRecordTitle($table, $row))), 'path' => RecyclerUtility::getRecordPath($row['pid']));
             }
         }
     }
     $jsonArray['total'] = $totalDeleted;
     return $jsonArray;
 }