Fix Bug #800663: Add a RSS feed of recently added documents

This commit is contained in:
Sebastian Meyer 2011-08-27 18:52:55 +02:00
parent 5f170a254b
commit 1892821bee
13 changed files with 426 additions and 3 deletions

View File

@ -41,6 +41,7 @@ return array (
'tx_dlf_tcemain' => $extensionPath.'hooks/class.tx_dlf_tcemain.php',
'tx_dlf_modindexing' => $extensionPath.'modules/indexing/index.php',
'tx_dlf_collection' => $extensionPath.'plugins/collection/class.tx_dlf_collection.php',
'tx_dlf_feeds' => $extensionPath.'plugins/feeds/class.tx_dlf_feeds.php',
'tx_dlf_metadata' => $extensionPath.'plugins/metadata/class.tx_dlf_metadata.php',
'tx_dlf_navigation' => $extensionPath.'plugins/navigation/class.tx_dlf_navigation.php',
'tx_dlf_oai' => $extensionPath.'plugins/oai/class.tx_dlf_oai.php',

View File

@ -27,6 +27,8 @@ if (!defined ('TYPO3_MODE')) die ('Access denied.');
// Register plugins.
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/collection/class.tx_dlf_collection.php', '_collection', 'list_type', TRUE);
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/feeds/class.tx_dlf_feeds.php', '_feeds', 'list_type', FALSE);
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/listview/class.tx_dlf_listview.php', '_listview', 'list_type', FALSE);
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/metadata/class.tx_dlf_metadata.php', '_metadata', 'list_type', TRUE);

View File

@ -201,6 +201,15 @@ t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang_db.xml:tt_content.dlf_colle
t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_collection', 'FILE:EXT:'.$_EXTKEY.'/plugins/collection/flexform.xml');
// Plugin "feeds".
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_feeds'] = 'layout,select_key,pages,recursive';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_feeds'] = 'pi_flexform';
t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang_db.xml:tt_content.dlf_feeds', $_EXTKEY.'_feeds'), 'list_type');
t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_feeds', 'FILE:EXT:'.$_EXTKEY.'/plugins/feeds/flexform.xml');
// Plugin "listview".
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_listview'] = 'layout,select_key,pages,recursive';

View File

@ -111,6 +111,7 @@
<label index="tx_dlf_toolbox.toolsDfgviewer">Link to DFG Viewer</label>
<label index="tx_dlf_toolbox.toolsPdf">PDF Download</label>
<label index="tt_content.dlf_collection">DLF: Collection</label>
<label index="tt_content.dlf_feeds">DLF: Feeds</label>
<label index="tt_content.dlf_listview">DLF: List View</label>
<label index="tt_content.dlf_metadata">DLF: Metadata</label>
<label index="tt_content.dlf_navigation">DLF: Navigation</label>
@ -227,6 +228,7 @@
<label index="tx_dlf_toolbox.toolsDfgviewer">Link zum DFG-Viewer</label>
<label index="tx_dlf_toolbox.toolsPdf">PDF-Download</label>
<label index="tt_content.dlf_collection">DLF: Kollektion</label>
<label index="tt_content.dlf_feeds">DLF: Feeds</label>
<label index="tt_content.dlf_listview">DLF: Listenansicht</label>
<label index="tt_content.dlf_metadata">DLF: Metadaten</label>
<label index="tt_content.dlf_navigation">DLF: Navigation</label>

View File

@ -196,6 +196,19 @@ class tx_dlf_collection extends tx_dlf_plugin {
// Link collection's title to list view.
$markerArray[$resArray['uid']]['###TITLE###'] = $this->cObj->typoLink(htmlspecialchars($resArray['label']), $conf);
// Add feed link if applicable.
if (!empty($this->conf['targetFeed'])) {
$_img = '<img src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/icon_txdlffeeds.png" alt="'.$this->pi_getLL('feedAlt', '', TRUE).'" title="'.$this->pi_getLL('feedTitle', '', TRUE).'" />';
$markerArray[$resArray['uid']]['###FEED###'] = $this->pi_linkTP($_img, array ($this->prefixId => array ('collection' => $resArray['uid'])), FALSE, $this->conf['targetFeed']);
} else {
$markerArray[$resArray['uid']]['###FEED###'] = '';
}
// Add description.
$markerArray[$resArray['uid']]['###DESCRIPTION###'] = $this->pi_RTEcssText($resArray['description']);

View File

@ -66,6 +66,20 @@
</config>
</TCEforms>
</targetPid>
<targetFeed>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/collection/locallang.xml:tt_content.pi_flexform.targetFeed</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
</config>
</TCEforms>
</targetFeed>
<templateFile>
<TCEforms>
<exclude>1</exclude>

View File

@ -10,22 +10,28 @@
<label index="tt_content.pi_flexform.collections">Show only these collections</label>
<label index="tt_content.pi_flexform.show_userdefined">Show user-defined collections?</label>
<label index="tt_content.pi_flexform.targetPid">Target page (with "DLF: List View" plugin)</label>
<label index="tt_content.pi_flexform.targetFeed">Target page (with "DLF: Feeds" plugin)</label>
<label index="tt_content.pi_flexform.templateFile">Template file</label>
<label index="title"> title</label>
<label index="titles"> titles</label>
<label index="volume"> volume</label>
<label index="volumes"> volumes</label>
<label index="feedAlt">RSS feed</label>
<label index="feedTitle">Subscribe to the RSS feed of this collection!</label>
</languageKey>
<languageKey index="de" type="array">
<label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
<label index="tt_content.pi_flexform.collections">Nur diese Kollektionen anzeigen</label>
<label index="tt_content.pi_flexform.show_userdefined">Benutzerdefinierte Kollektionen anzeigen?</label>
<label index="tt_content.pi_flexform.targetPid">Zielseite (mit Plugin "DLF: Listenansicht")</label>
<label index="tt_content.pi_flexform.targetFeed">Zielseite (mit Plugin "DLF: Feeds")</label>
<label index="tt_content.pi_flexform.templateFile">HTML-Template</label>
<label index="title"> Titel</label>
<label index="titles"> Titel</label>
<label index="volume"> Band</label>
<label index="volumes"> Bände</label>
<label index="feedAlt">RSS-Feed</label>
<label index="feedTitle">Abonnieren Sie den RSS-Feed dieser Kollektion!</label>
</languageKey>
</data>
</T3locallang>

View File

@ -2,7 +2,7 @@
<ul>
<!-- ###ENTRY### -->
<li>
<h2>###TITLE###</h2>
<h2>###TITLE### <span>###FEED###</span></h2>
###DESCRIPTION###
<p class="counts">(###COUNT_TITLES###/###COUNT_VOLUMES###)</p>
</li>

View File

@ -0,0 +1,221 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2011 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* 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!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Plugin 'DLF: Feeds' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2011, Sebastian Meyer, SLUB Dresden
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_feeds extends tx_dlf_plugin {
public $scriptRelPath = 'plugins/feeds/class.tx_dlf_feeds.php';
/**
* The main method of the PlugIn
*
* @access public
*
* @param string $content: The PlugIn content
* @param array $conf: The PlugIn configuration
*
* @return string The content that is displayed on the website
*/
public function main($content, $conf) {
$this->init($conf);
// Don't cache the output.
$this->setCache(FALSE);
// Create XML document.
$rss = new DOMDocument('1.0', 'utf-8');
// Add mandatory root element.
$root = $rss->createElement('rss');
$root->setAttribute('version', '2.0');
// Add channel element.
$channel = $rss->createElement('channel');
$channel->appendChild($rss->createElement('title', htmlspecialchars($this->conf['title'], ENT_NOQUOTES, 'UTF-8')));
$channel->appendChild($rss->createElement('link', htmlspecialchars(t3lib_div::locationHeaderUrl($this->pi_linkTP_keepPIvars_url()), ENT_NOQUOTES, 'UTF-8')));
if (!empty($this->conf['description'])) {
$channel->appendChild($rss->createElement('description', htmlspecialchars($this->conf['description'], ENT_QUOTES, 'UTF-8')));
}
$_result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_libraries.label AS label',
'tx_dlf_libraries',
'tx_dlf_libraries.pid='.intval($this->conf['pages']).' AND tx_dlf_libraries.uid='.intval($this->conf['library']).tx_dlf_helper::whereClause('tx_dlf_libraries'),
'',
'',
'1'
);
if ($GLOBALS['TYPO3_DB']->sql_num_rows($_result)) {
$_resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($_result);
$channel->appendChild($rss->createElement('copyright', htmlspecialchars($_resArray['label'], ENT_NOQUOTES, 'UTF-8')));
}
$channel->appendChild($rss->createElement('pubDate', date('r', $GLOBALS['EXEC_TIME'])));
// Load extension configuration
$_extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']);
$channel->appendChild($rss->createElement('generator', htmlspecialchars($_extconf['useragent'], ENT_NOQUOTES, 'UTF-8')));
// Add item elements.
if (!$this->conf['excludeOther'] || empty($this->piVars['collection']) || t3lib_div::inList($this->conf['collections'], $this->piVars['collection'])) {
$additionalWhere = '';
// Check for pre-selected collections.
if (!empty($this->piVars['collection'])) {
$additionalWhere = ' AND tx_dlf_collections.uid='.intval($this->piVars['collection']);
} elseif (!empty($this->conf['collections'])) {
$additionalWhere = ' AND tx_dlf_collections.uid IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']).')';
}
$result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(
'tx_dlf_documents.title AS title,tx_dlf_documents.volume AS volume,tx_dlf_documents.uid AS uid,tx_dlf_documents.author AS author,tx_dlf_documents.record_id AS guid,tx_dlf_documents.tstamp AS tstamp,tx_dlf_documents.crdate AS crdate',
'tx_dlf_documents',
'tx_dlf_relations',
'tx_dlf_collections',
'AND tx_dlf_documents.pid='.intval($this->conf['pages']).' AND tx_dlf_collections.pid='.intval($this->conf['pages']).$additionalWhere.tx_dlf_helper::whereClause('tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_collections'),
'tx_dlf_documents.uid',
'tx_dlf_documents.tstamp DESC',
intval($this->conf['limit'])
);
if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
// Add each record as item element.
while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
$item = $rss->createElement('item');
if ($resArray['crdate'] == $resArray['tstamp']) {
$title = $this->pi_getLL('new');
} else {
$title = $this->pi_getLL('update');
}
if (!empty($resArray['title'])) {
$title .= $resArray['title'];
} else {
$title .= $this->pi_getLL('noTitle');
}
if (!empty($resArray['volume'])) {
$title .= ', '.$this->pi_getLL('volume').' '.$resArray['volume'];
}
$item->appendChild($rss->createElement('title', htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8')));
$item->appendChild($rss->createElement('link', htmlspecialchars(t3lib_div::locationHeaderUrl($this->pi_getPageLink($this->conf['targetPid'], '', array ($this->prefixId => array ('id' => $resArray['uid'])))), ENT_NOQUOTES, 'UTF-8')));
if (!empty($resArray['author'])) {
$item->appendChild($rss->createElement('author', htmlspecialchars($resArray['author'], ENT_NOQUOTES, 'UTF-8')));
}
$item->appendChild($rss->createElement('pubDate', date('r', $resArray['crdate'])));
$item->appendChild($rss->createElement('guid', htmlspecialchars($resArray['guid'], ENT_NOQUOTES, 'UTF-8')));
$channel->appendChild($item);
}
}
}
$root->appendChild($channel);
// Build XML output.
$rss->appendChild($root);
$content = $rss->saveXML();
// Send headers.
header('HTTP/1.1 200 OK');
header('Cache-Control: no-cache');
header('Content-Length: '.strlen($content));
header('Content-Type: application/rss+xml; charset=utf-8');
header('Date: '.date('r', $GLOBALS['EXEC_TIME']));
header('Expires: '.date('r', $GLOBALS['EXEC_TIME']));
echo $content;
// Flush output buffer and end script processing.
ob_end_flush();
exit;
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/feeds/class.tx_dlf_feeds.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/feeds/class.tx_dlf_feeds.php']);
}
?>

View File

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:dlf/plugins/feeds/locallang.xml:tt_content.pi_flexform.sheet_general</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<pages>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:lang/locallang_general.xml:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</pages>
<collections>
<TCEforms>
<displayCond>FIELD:pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/feeds/locallang.xml:tt_content.pi_flexform.collections</label>
<config>
<type>select</type>
<items type="array"></items>
<itemsProcFunc>tx_dlf_tceforms->itemsProcFunc_collectionList</itemsProcFunc>
<size>5</size>
<autoSizeMax>15</autoSizeMax>
<maxitems>1024</maxitems>
<minitems>0</minitems>
</config>
</TCEforms>
</collections>
<excludeOther>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/feeds/locallang.xml:tt_content.pi_flexform.excludeOther</label>
<config>
<type>check</type>
<default>0</default>
</config>
</TCEforms>
</excludeOther>
<library>
<TCEforms>
<displayCond>FIELD:pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/feeds/locallang.xml:tt_content.pi_flexform.library</label>
<config>
<type>select</type>
<items type="array"></items>
<itemsProcFunc>tx_dlf_tceforms->itemsProcFunc_libraryList</itemsProcFunc>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
</config>
</TCEforms>
</library>
<limit>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/feeds/locallang.xml:tt_content.pi_flexform.limit</label>
<config>
<type>input</type>
<eval>required,num,int</eval>
<default>50</default>
</config>
</TCEforms>
</limit>
<targetPid>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/feeds/locallang.xml:tt_content.pi_flexform.targetPid</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</targetPid>
<title>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/feeds/locallang.xml:tt_content.pi_flexform.title</label>
<config>
<type>input</type>
<eval>required,trim</eval>
</config>
</TCEforms>
</title>
<description>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/feeds/locallang.xml:tt_content.pi_flexform.description</label>
<config>
<type>input</type>
<eval>trim</eval>
</config>
</TCEforms>
</description>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for plugin tx_dlf_feeds</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="tt_content.pi_flexform.sheet_general">Options</label>
<label index="tt_content.pi_flexform.collections">Collections</label>
<label index="tt_content.pi_flexform.excludeOther">Show only documents from the selected collection(s)</label>
<label index="tt_content.pi_flexform.library">Providing library</label>
<label index="tt_content.pi_flexform.limit">Number of documents</label>
<label index="tt_content.pi_flexform.targetPid">Target page (with "DLF: Page View" plugin)</label>
<label index="tt_content.pi_flexform.title">Feed's title</label>
<label index="tt_content.pi_flexform.description">Feed's description</label>
<label index="new">NEW: </label>
<label index="update">UPDATE: </label>
<label index="noTitle">[no title]</label>
<label index="volume">Volume</label>
</languageKey>
<languageKey index="de" type="array">
<label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
<label index="tt_content.pi_flexform.collections">Kollektionen</label>
<label index="tt_content.pi_flexform.excludeOther">Nur Dokumente der ausgewählten Kollektion(en) berücksichtigen</label>
<label index="tt_content.pi_flexform.library">Mandant</label>
<label index="tt_content.pi_flexform.limit">Anzahl der Dokumente</label>
<label index="tt_content.pi_flexform.targetPid">Zielseite (mit Plugin "DLF: Seitenansicht")</label>
<label index="tt_content.pi_flexform.title">Titel des Feeds</label>
<label index="tt_content.pi_flexform.description">Beschreibung des Feeds</label>
<label index="new">NEU: </label>
<label index="update">UPDATE: </label>
<label index="noTitle">[kein Titel]</label>
<label index="volume">Band</label>
</languageKey>
</data>
</T3locallang>

View File

@ -1,6 +1,6 @@
<!-- ###TEMPLATE### -->
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="###STYLESHEET###" ?>
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="###STYLESHEET###"?>
<OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/

BIN
dlf/res/icon_txdlffeeds.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B