Commit 3176f6a7 authored by Georg Ringer's avatar Georg Ringer Committed by Christian Kuhn
Browse files

[FEATURE] Redesign of sys_note

Complete redesign of the sys_notes

Resolves: #26796
Releases: 6.0
Change-Id: I7b8748c7142a1ab6615edb4567aa748d21c54a84
Reviewed-on: http://review.typo3.org/11789
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
parent da747b7c
......@@ -357,64 +357,11 @@ class recordList extends t3lib_recordList {
* Relies on the "sys_note" extension to be loaded.
*
* @return string HTML for the sys-notes (if any)
* @deprecated since 6.0, will be removed two versions later
*/
function showSysNotesForPage() {
$out = '';
// Checking if extension is loaded:
if (!t3lib_extMgm::isLoaded('sys_note')) {
return '';
}
// Create query for selecting the notes:
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_note', 'pid IN (' . $this->id . ') AND (personal=0 OR cruser=' . intval($GLOBALS['BE_USER']->user['uid']) . ')' . t3lib_BEfunc::deleteClause('sys_note') . t3lib_BEfunc::versioningPlaceholderClause('sys_note'));
// Executing query:
$dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
// If some notes were found, render them:
if ($dbCount) {
$cat = array();
// Load full table description:
t3lib_div::loadTCA('sys_note');
// Traverse note-types and get labels:
if ($GLOBALS['TCA']['sys_note'] && $GLOBALS['TCA']['sys_note']['columns']['category']
&& is_array($GLOBALS['TCA']['sys_note']['columns']['category']['config']['items'])) {
foreach($GLOBALS['TCA']['sys_note']['columns']['category']['config']['items'] as $el) {
$cat[$el[1]]=$GLOBALS['LANG']->sL($el[0]);
}
}
// For each note found, make rendering:
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
// Create content:
$iconImg = t3lib_iconWorks::getSpriteIconForRecord('sys_note', $row);
$subject = htmlspecialchars($row['subject']);
$fields = array();
$fields['Author:'] = htmlspecialchars($row['author'].($row['email'] && $row['author'] ? ', ':'').$row['email']);
$fields['Category:'] = htmlspecialchars($cat[$row['category']]);
$fields['Note:'] = nl2br(htmlspecialchars($row['message']));
// Compile content:
$out .= '
<!--
Sys-notes for list module:
-->
<table border="0" cellpadding="1" cellspacing="1" id="typo3-dblist-sysnotes">
<tr><td colspan="2" class="bgColor2">' . $iconImg . '<strong>' . $subject . '</strong></td></tr>
<tr><td class="bgColor4">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.category', 1) . '</td><td class="bgColor4">' . $fields['Category:'] . '</td></tr>
<tr><td class="bgColor4">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.author', 1) . '</td><td class="bgColor4">' . $fields['Author:'] . '</td></tr>
<tr><td class="bgColor4">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.note', 1) . '</td><td class="bgColor4">' . $fields['Note:'] . '</td></tr>
</table>
';
}
}
return $out;
t3lib_div::logDeprecatedFunction();
return '';
}
/******************************
......
......@@ -1122,12 +1122,13 @@ class SC_db_layout {
);
}
// Making display of Sys-notes (from extension "sys_note")
$dblist->id=$this->id;
$sysNotes = $dblist->showSysNotesForPage();
if ($sysNotes) {
$content .= $this->doc->spacer(10);
$content .= $this->doc->section($GLOBALS['LANG']->getLL('internalNotes'), $sysNotes, 0, 1);
// Additional footer content
$footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawFooterHook'];
if (is_array($footerContentHook)) {
foreach ($footerContentHook as $hook) {
$params = array();
$content .= t3lib_div::callUserFunction($hook, $params, $this);
}
}
// Add spacer in bottom of page:
......
......@@ -462,8 +462,14 @@ class SC_db_list {
) . '</div>';
}
// Display sys-notes, if any are found:
$this->body.=$dblist->showSysNotesForPage();
// Additional footer content
$footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['recordlist/mod1/index.php']['drawFooterHook'];
if (is_array($footerContentHook)) {
foreach ($footerContentHook as $hook) {
$params = array();
$this->body .= t3lib_div::callUserFunction($hook, $params, $this);
}
}
}
// Setting up the buttons and markers for docheader
......
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Georg Ringer <typo3@ringerge.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Hook for the page module
*
* @package TYPO3
* @subpackage sys_note
* @author Georg Ringer <typo3@ringerge.org>
*/
class Tx_SysNote_Hooks_Page {
/**
* Add sys_notes as additional content to the footer of the page module
*
* @param array $params
* @param SC_db_layout $parentObject
* @return string
*/
public function render(array $params = array(), SC_db_layout $parentObject) {
$sysNote = t3lib_div::makeInstance('Tx_SysNote_SysNote');
$content = $sysNote->renderByPid($parentObject->id);
return $content;
}
}
?>
\ No newline at end of file
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Georg Ringer <typo3@ringerge.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Hook for the list module
*
* @package TYPO3
* @subpackage sys_note
* @author Georg Ringer <typo3@ringerge.org>
*/
class Tx_SysNote_Hooks_RecordList {
/**
* Add sys_notes as additional content to the footer of the list module
*
* @param array $params
* @param SC_db_list $parentObject
* @return string
*/
public function render(array $params = array(), SC_db_list $parentObject) {
$renderer = t3lib_div::makeInstance('Tx_SysNote_SysNote');
$sysNotes = $renderer->renderByPid($parentObject->id);
return $sysNotes;
}
}
?>
\ No newline at end of file
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Georg Ringer <typo3@ringerge.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Render sys_notes
*
* @package TYPO3
* @subpackage sys_note
* @author Georg Ringer <typo3@ringerge.org>
*/
class Tx_SysNote_SysNote {
/**
* Render sys_notes by pid
*
* @param string $pidList comma separated list of page ids
* @return string
*/
public function renderByPid($pidList) {
// Create query for selecting the notes:
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
'*',
'sys_note',
'pid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($pidList) . ')
AND (personal=0 OR cruser=' . intval($GLOBALS['BE_USER']->user['uid']) . ')' .
t3lib_BEfunc::deleteClause('sys_note'),
'',
'sorting'
);
$out = '';
if (count($rows) > 0) {
$categories = array();
// Load full table description:
t3lib_div::loadTCA('sys_note');
// Traverse categories
if ($GLOBALS['TCA']['sys_note'] && $GLOBALS['TCA']['sys_note']['columns']['category']
&& is_array($GLOBALS['TCA']['sys_note']['columns']['category']['config']['items'])
) {
foreach ($GLOBALS['TCA']['sys_note']['columns']['category']['config']['items'] as $el) {
$categories[$el[1]] = $GLOBALS['LANG']->sL($el[0]);
}
}
// For each note found, make rendering:
foreach ($rows as $row) {
if ($row['personal'] == 1 && (int) $row['cruser'] !== (int) $GLOBALS['BE_USER']->user['uid'] && $GLOBALS['BE_USER']->isAdmin() === FALSE) {
continue;
}
$author = t3lib_BEfunc::getRecord('be_users', $row['cruser']);
$authorInformation = $author['realName'];
if (empty($authorInformation)) {
$authorInformation = $author['username'];
}
$title = !(empty($categories[$row['category']])) ? $categories[$row['category']] . ': ' : '';
$headerParts = array();
if (!empty($authorInformation)) {
$headerParts[] = '<span>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.author', TRUE) . '</span> ' . $authorInformation;
}
$headerParts[] = '<span>' . $GLOBALS['LANG']->sL('LLL:EXT:sys_note/locallang.xlf:date', TRUE) . ':</span> ' . t3lib_BEfunc::date($row['tstamp']);
if ($row['personal'] == 1) {
$headerParts[] = '<span>' . rtrim($GLOBALS['LANG']->sL('LLL:EXT:sys_note/locallang_tca.xlf:sys_note.personal', TRUE), ':') . '</span>';
}
// Compile content:
$out .= '
<div class="single-note category-' . $row['category'] . '">
<div class="header">
' . implode(' &middot; ', $headerParts) . '
<div class="right">
<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[sys_note][' . $row['uid'] . ']=edit', $GLOBALS['BACK_PATH'])) . '">' .
t3lib_iconWorks::getSpriteIcon('actions-document-open') .
'</a>
</div>
</div>
<div class="content">
<div class="title">' . htmlspecialchars($title) . htmlspecialchars($row['subject']) . '</div>
' . nl2br(htmlspecialchars($row['message'])) . '
</div>
</div>';
}
$out = '<div id="typo3-dblist-sysnotes">' . $out . '</div>';
}
return $out;
}
}
?>
<?php
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
$TCA['sys_note'] = array(
'ctrl' => $TCA['sys_note']['ctrl'],
'interface' => array(
'showRecordFieldList' => 'category,subject,message,personal'
),
'columns' => array(
'category' => array(
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.category',
'config' => array(
'type' => 'select',
'items' => array(
array('', '0'),
array('LLL:EXT:sys_note/locallang_tca.xlf:sys_note.category.I.1', '1', 'sysext/t3skin/icons/ext/sys_note/icon-instruction.png'),
array('LLL:EXT:sys_note/locallang_tca.xlf:sys_note.category.I.2', '3', 'sysext/t3skin/icons/ext/sys_note/icon-note.png'),
array('LLL:EXT:sys_note/locallang_tca.xlf:sys_note.category.I.3', '4', 'sysext/t3skin/icons/ext/sys_note/icon-todo.png'),
array('LLL:EXT:sys_note/locallang_tca.xlf:sys_note.category.I.4', '2', 'sysext/t3skin/icons/ext/sys_note/icon-template.png')
),
'default' => '0'
)
),
'subject' => array(
'label' => 'LLL:EXT:sys_note/locallang_tca.xlf:sys_note.subject',
'config' => array(
'type' => 'input',
'size' => '40',
'max' => '256'
)
),
'message' => array(
'label' => 'LLL:EXT:sys_note/locallang_tca.xlf:sys_note.message',
'config' => array(
'type' => 'text',
'cols' => '40',
'rows' => '15'
)
),
'personal' => array(
'label' => 'LLL:EXT:sys_note/locallang_tca.xlf:sys_note.personal',
'config' => array(
'type' => 'check'
)
)
),
'types' => array(
'0' => array('showitem' => 'category;;;;2-2-2, personal, subject;;;;3-3-3, message')
)
);
?>
\ No newline at end of file
......@@ -14,7 +14,7 @@ $EM_CONF[$_EXTKEY] = array(
'title' => 'Internal notes',
'description' => 'Records with messages which can be placed on any page and contain instructions or other information related to a page or section.',
'category' => 'be',
'shy' => 1,
'shy' => 0,
'dependencies' => '',
'conflicts' => '',
'priority' => '',
......@@ -32,7 +32,7 @@ $EM_CONF[$_EXTKEY] = array(
'author_company' => 'Curby Soft Multimedia',
'CGLcompliance' => '',
'CGLcompliance_note' => '',
'version' => '1.2.0',
'version' => '2.0.0',
'_md5_values_when_last_written' => 'a:5:{s:12:"ext_icon.gif";s:4:"bf22";s:14:"ext_tables.php";s:4:"847c";s:14:"ext_tables.sql";s:4:"18f7";s:25:"locallang_csh_sysnote.xlf";s:4:"a4f0";s:17:"locallang_tca.xlf";s:4:"44ce";}',
'constraints' => array(
'depends' => array(
......
<?php
if (!defined ('TYPO3_MODE')) {
die ('Access denied.');
}
// Hook into the list module
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['recordlist/mod1/index.php']['drawFooterHook'][$_EXTKEY] =
'EXT:' . $_EXTKEY . '/Classes/Hooks/RecordList.php:Tx_Sysnote_Hooks_RecordList->render';
// Hook into the page module
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawFooterHook'][$_EXTKEY] =
'EXT:' . $_EXTKEY . '/Classes/Hooks/Page.php:Tx_Sysnote_Hooks_Page->render';
?>
\ No newline at end of file
<?php
if (!defined ('TYPO3_MODE')) die ('Access denied.');
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
if (TYPO3_MODE=='BE') {
$TCA['sys_note'] = Array (
'ctrl' => Array (
'label' => 'subject',
'default_sortby' => 'ORDER BY crdate',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser',
'prependAtCopy' => 'LLL:EXT:lang/locallang_general.php:LGL.prependAtCopy',
'delete' => 'deleted',
'title' => 'LLL:EXT:sys_note/locallang_tca.php:sys_note',
'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY).'ext_icon.gif',
),
'interface' => Array (
'showRecordFieldList' => 'category,subject,message,author,email,personal'
),
'columns' => Array (
'category' => Array (
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.category',
'config' => Array (
'type' => 'select',
'items' => Array (
Array('', '0'),
Array('LLL:EXT:sys_note/locallang_tca.php:sys_note.category.I.1', '1'),
Array('LLL:EXT:sys_note/locallang_tca.php:sys_note.category.I.2', '3'),
Array('LLL:EXT:sys_note/locallang_tca.php:sys_note.category.I.3', '4'),
Array('LLL:EXT:sys_note/locallang_tca.php:sys_note.category.I.4', '2')
),
'default' => '0'
)
),
'subject' => Array (
'label' => 'LLL:EXT:sys_note/locallang_tca.php:sys_note.subject',
'config' => Array (
'type' => 'input',
'size' => '40',
'max' => '256'
)
),
'message' => Array (
'label' => 'LLL:EXT:sys_note/locallang_tca.php:sys_note.message',
'config' => Array (
'type' => 'text',
'cols' => '40',
'rows' => '15'
)
),
'author' => Array (
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.author',
'config' => Array (
'type' => 'input',
'size' => '20',
'eval' => 'trim',
'max' => '80'
)
),
'email' => Array (
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.email',
'config' => Array (
'type' => 'input',
'size' => '20',
'eval' => 'trim',
'max' => '80'
)
),
'personal' => Array (
'label' => 'LLL:EXT:sys_note/locallang_tca.php:sys_note.personal',
'config' => Array (
'type' => 'check'
)
)
),
'types' => Array (
'0' => Array('showitem' => 'category;;;;2-2-2, author, email, personal, subject;;;;3-3-3, message')
)
);
$TCA['sys_note'] = array(
'ctrl' => array(
'label' => 'subject',
'default_sortby' => 'ORDER BY crdate',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser',
'prependAtCopy' => 'LLL:EXT:lang/locallang_general.xlf:LGL.prependAtCopy',
'delete' => 'deleted',
'title' => 'LLL:EXT:sys_note/locallang_tca.xlf:sys_note',
'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY) . 'ext_icon.gif',
'sortby' => 'sorting',
'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY) . 'Configuration/Tca/SysNote.php',
),
);
t3lib_extMgm::allowTableOnStandardPages('sys_note');
}
t3lib_extMgm::allowTableOnStandardPages('sys_note');
t3lib_extMgm::addLLrefForTCAdescr('sys_note', 'EXT:sys_note/locallang_csh_sysnote.xlf');
t3lib_extMgm::addLLrefForTCAdescr('sys_note', 'EXT:sys_note/locallang_csh_sysnote.xml');
?>
\ No newline at end of file
......@@ -8,12 +8,11 @@ CREATE TABLE sys_note (
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
cruser int(11) unsigned DEFAULT '0' NOT NULL,
author varchar(80) DEFAULT '' NOT NULL,
email varchar(80) DEFAULT '' NOT NULL,
subject varchar(255) DEFAULT '' NOT NULL,
message text,
personal tinyint(3) unsigned DEFAULT '0' NOT NULL,
category tinyint(3) unsigned DEFAULT '0' NOT NULL,
sorting int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
);
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2011-10-17T20:22:37Z" product-name="sys_note">
<header/>
<body>
<trans-unit id="date" xml:space="preserve">
<source>Date</source>
</trans-unit>
</body>
</file>
</xliff>
table#typo3-dblist-sysnotes {
#typo3-dblist-sysnotes {
margin-top: 15px;
}
#typo3-dblist-sysnotes .single-note {
margin-bottom:10px;
}
#typo3-dblist-sysnotes .single-note .header {
background: #d7d7d7 url(../../icons/ext/sys_note/icon-default.png) no-repeat top left;
padding-left: 30px;
height:23px;
line-height: 25px;
}
#typo3-dblist-sysnotes .category-1 .header {
background-image: url(../../icons/ext/sys_note/icon-instruction.png);
}
#typo3-dblist-sysnotes .category-2 .header {
background-image: url(../../icons/ext/sys_note/icon-template.png);
}
#typo3-dblist-sysnotes .category-3 .header {
background-image: url(../../icons/ext/sys_note/icon-note.png);
}
#typo3-dblist-sysnotes .category-4 .header {
background-image: url(../../icons/ext/sys_note/icon-todo.png);
}
#typo3-dblist-sysnotes .single-note .header span {
color: #666;
}
#typo3-dblist-sysnotes .single-note .header .right {
float: right;