[TASK] Fix CGL violations against CharacterAfterPHPClosingTag
[Packages/TYPO3.CMS.git] / typo3 / sysext / sys_note / Classes / SysNote.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2012 Georg Ringer <typo3@ringerge.org>
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 /**
26 * Render sys_notes
27 *
28 * @package TYPO3
29 * @subpackage sys_note
30 * @author Georg Ringer <typo3@ringerge.org>
31 */
32 class Tx_SysNote_SysNote {
33
34 /**
35 * Render sys_notes by pid
36 *
37 * @param string $pidList comma separated list of page ids
38 * @return string
39 */
40 public function renderByPid($pidList) {
41 // Create query for selecting the notes:
42 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
43 '*',
44 'sys_note',
45 'pid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($pidList) . ')
46 AND (personal=0 OR cruser=' . intval($GLOBALS['BE_USER']->user['uid']) . ')' .
47 t3lib_BEfunc::deleteClause('sys_note'),
48 '',
49 'sorting'
50 );
51
52 $out = '';
53
54 if (count($rows) > 0) {
55 $categories = array();
56
57 // Load full table description:
58 t3lib_div::loadTCA('sys_note');
59
60 // Traverse categories
61 if ($GLOBALS['TCA']['sys_note'] && $GLOBALS['TCA']['sys_note']['columns']['category']
62 && is_array($GLOBALS['TCA']['sys_note']['columns']['category']['config']['items'])
63 ) {
64 foreach ($GLOBALS['TCA']['sys_note']['columns']['category']['config']['items'] as $el) {
65 $categories[$el[1]] = $GLOBALS['LANG']->sL($el[0]);
66 }
67 }
68
69 // For each note found, make rendering:
70 foreach ($rows as $row) {
71 if ($row['personal'] == 1 && (int) $row['cruser'] !== (int) $GLOBALS['BE_USER']->user['uid'] && $GLOBALS['BE_USER']->isAdmin() === FALSE) {
72 continue;
73 }
74 $author = t3lib_BEfunc::getRecord('be_users', $row['cruser']);
75 $authorInformation = $author['realName'];
76 if (empty($authorInformation)) {
77 $authorInformation = $author['username'];
78 }
79 $title = !(empty($categories[$row['category']])) ? $categories[$row['category']] . ': ' : '';
80
81 $headerParts = array();
82 if (!empty($authorInformation)) {
83 $headerParts[] = '<span>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.author', TRUE) . '</span> ' . $authorInformation;
84 }
85 $headerParts[] = '<span>' . $GLOBALS['LANG']->sL('LLL:EXT:sys_note/locallang.xlf:date', TRUE) . ':</span> ' . t3lib_BEfunc::date($row['tstamp']);
86 if ($row['personal'] == 1) {
87 $headerParts[] = '<span>' . rtrim($GLOBALS['LANG']->sL('LLL:EXT:sys_note/locallang_tca.xlf:sys_note.personal', TRUE), ':') . '</span>';
88 }
89
90 // Compile content:
91 $out .= '
92 <div class="single-note category-' . $row['category'] . '">
93 <div class="header">
94 ' . implode(' &middot; ', $headerParts) . '
95 <div class="right">
96 <a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[sys_note][' . $row['uid'] . ']=edit', $GLOBALS['BACK_PATH'])) . '">' .
97 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
98 '</a>
99 </div>
100 </div>
101 <div class="content">
102 <div class="title">' . htmlspecialchars($title) . htmlspecialchars($row['subject']) . '</div>
103 ' . nl2br(htmlspecialchars($row['message'])) . '
104 </div>
105 </div>';
106 }
107
108 $out = '<div id="typo3-dblist-sysnotes">' . $out . '</div>';
109 }
110
111 return $out;
112 }
113 }
114
115 ?>