[TASK] Use t3lib_BEfunc instead of date()
[Packages/TYPO3.CMS.git] / typo3 / sysext / recycler / classes / view / class.tx_recycler_view_deletedRecords.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009-2011 Julian Kleinhans <typo3@kj187.de>
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 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 require_once(t3lib_extMgm::extPath('recycler', 'classes/helper/class.tx_recycler_helper.php'));
26
27 /**
28 * Deleted Records View
29 *
30 * @author Erik Frister <erik_frister@otq-solutions.com>
31 * @author Julian Kleinhans <typo3@kj187.de>
32 * @package TYPO3
33 * @subpackage tx_recycler
34 **/
35 class tx_recycler_view_deletedRecords {
36
37 /**
38 * Transforms the rows for the deleted Records into the Array View necessary for ExtJS Ext.data.ArrayReader
39 *
40 * @param array $rows Array with table as key and array with all deleted rows
41 * @param integer $totalDeleted: Number of deleted records in total, for PagingToolbar
42 * @return string JSON Array
43 **/
44 public function transform ($deletedRowsArray, $totalDeleted) {
45 $total = 0;
46
47 $jsonArray = array(
48 'rows' => array(),
49 );
50
51 // iterate
52 if (is_array($deletedRowsArray) && count($deletedRowsArray) > 0) {
53 foreach($deletedRowsArray as $table => $rows) {
54 $total += count($deletedRowsArray[$table]);
55
56 foreach($rows as $row) {
57 $backendUser = t3lib_BEfunc::getRecord('be_users', $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']], 'username', '', FALSE);
58 $jsonArray['rows'][] = array(
59 'uid' => $row['uid'],
60 'pid' => $row['pid'],
61 'table' => $table,
62 'crdate' => t3lib_BEfunc::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['crdate']]),
63 'tstamp' => t3lib_BEfunc::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['tstamp']]),
64 'owner' => htmlspecialchars($backendUser['username']),
65 'owner_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']],
66 'tableTitle' => tx_recycler_helper::getUtf8String(
67 $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title'])
68 ),
69 'title' => htmlspecialchars(tx_recycler_helper::getUtf8String(
70 t3lib_BEfunc::getRecordTitle($table, $row)
71 )),
72 'path' => tx_recycler_helper::getRecordPath($row['pid']),
73 );
74 }
75 }
76 }
77
78 $jsonArray['total'] = $totalDeleted;
79 return json_encode($jsonArray);
80 }
81 }
82
83 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/recycler/classes/view/class.tx_recycler_view_deletedRecords.php'])) {
84 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/recycler/classes/view/class.tx_recycler_view_deletedRecords.php']);
85 }
86
87 ?>