Add plugin "statistics"

This commit is contained in:
Sebastian Meyer 2011-08-19 18:25:11 +02:00
parent e3612d65f0
commit c8c7d3eb8f
7 changed files with 247 additions and 0 deletions

View File

@ -46,6 +46,7 @@ return array (
'tx_dlf_oai' => $extensionPath.'plugins/oai/class.tx_dlf_oai.php',
'tx_dlf_pageview' => $extensionPath.'plugins/pageview/class.tx_dlf_pageview.php',
'tx_dlf_search' => $extensionPath.'plugins/search/class.tx_dlf_search.php',
'tx_dlf_statistics' => $extensionPath.'plugins/statistics/class.tx_dlf_statistics.php',
'tx_dlf_toc' => $extensionPath.'plugins/toc/class.tx_dlf_toc.php',
'tx_dlf_toolbox' => $extensionPath.'plugins/toolbox/class.tx_dlf_toolbox.php',
'tx_dlf_toolsDfgviewer' => $extensionPath.'plugins/toolbox/tools/dfgviewer/class.tx_dlf_toolsDfgviewer.php',

View File

@ -39,6 +39,8 @@ t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/pageview/class.tx_dlf_pageview.php'
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/search/class.tx_dlf_search.php', '_search', 'list_type', TRUE);
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/statistics/class.tx_dlf_statistics.php', '_statistics', 'list_type', TRUE);
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/toc/class.tx_dlf_toc.php', '_toc', 'list_type', TRUE);
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/toolbox/class.tx_dlf_toolbox.php', '_toolbox', 'list_type', FALSE);

View File

@ -255,6 +255,15 @@ t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang_db.xml:tt_content.dlf_searc
t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_search', 'FILE:EXT:'.$_EXTKEY.'/plugins/search/flexform.xml');
// Plugin "statistics".
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_statistics'] = 'layout,select_key,pages,recursive';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_statistics'] = 'pi_flexform';
t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang_db.xml:tt_content.dlf_statistics', $_EXTKEY.'_statistics'), 'list_type');
t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_statistics', 'FILE:EXT:'.$_EXTKEY.'/plugins/statistics/flexform.xml');
// Plugin "table of contents".
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_toc'] = 'layout,select_key,pages,recursive';

View File

@ -117,6 +117,7 @@
<label index="tt_content.dlf_oai">DLF: OAI-PMH Interface</label>
<label index="tt_content.dlf_pageview">DLF: Page View</label>
<label index="tt_content.dlf_search">DLF: Search</label>
<label index="tt_content.dlf_statistics">DLF: Statistics</label>
<label index="tt_content.dlf_toc">DLF: Table of Contents</label>
<label index="tt_content.dlf_toolbox">DLF: Toolbox</label>
</languageKey>
@ -232,6 +233,7 @@
<label index="tt_content.dlf_oai">DLF: OAI-PMH-Schnittstelle</label>
<label index="tt_content.dlf_pageview">DLF: Seitenansicht</label>
<label index="tt_content.dlf_search">DLF: Suche</label>
<label index="tt_content.dlf_statistics">DLF: Statistik</label>
<label index="tt_content.dlf_toc">DLF: Inhaltsverzeichnis</label>
<label index="tt_content.dlf_toolbox">DLF: Werkzeugkasten</label>
</languageKey>

View File

@ -0,0 +1,144 @@
<?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: Statistics' 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_statistics extends tx_dlf_plugin {
public $scriptRelPath = 'plugins/statistics/class.tx_dlf_statistics.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);
// Quit without doing anything if required configuration variables are not set.
if (!$this->conf['pages']) {
return $content;
}
// Get description.
$content = $this->pi_RTEcssText($conf['description']);
// Check for selected collections.
if ($this->conf['collections']) {
// Include all collections.
$resultTitles = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_documents.uid AS uid',
'tx_dlf_documents',
'tx_dlf_documents.pid='.intval($this->conf['pages']).' AND tx_dlf_documents.partof=0'.tx_dlf_helper::whereClause('tx_dlf_documents'),
'',
'',
''
);
$resultVolumes = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_documents.uid AS uid',
'tx_dlf_documents',
'tx_dlf_documents.pid='.intval($this->conf['pages']).' AND NOT tx_dlf_documents.uid IN (SELECT DISTINCT tx_dlf_documents.partof FROM tx_dlf_documents WHERE NOT tx_dlf_documents.partof=0'.tx_dlf_helper('tx_dlf_documents').')'.tx_dlf_helper::whereClause('tx_dlf_documents'),
'',
'',
''
);
} else {
// Include only selected collections.
$resultTitles = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(
'tx_dlf_documents.uid AS uid',
'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['page']).' AND tx_dlf_documents.partof=0 AND tx_dlf_collections.uid IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']).')'.tx_dlf_helper::whereClause('tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_collections'),
'tx_dlf_documents.uid',
'',
''
);
$resultVolumes = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(
'tx_dlf_documents.uid AS uid',
'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['page']).' AND NOT tx_dlf_documents.uid IN (SELECT DISTINCT tx_dlf_documents.partof FROM tx_dlf_documents WHERE NOT tx_dlf_documents.partof=0'.tx_dlf_helper('tx_dlf_documents').') AND tx_dlf_collections.uid IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']).')'.tx_dlf_helper::whereClause('tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_collections'),
'tx_dlf_documents.uid',
'',
''
);
}
$countTitles = $GLOBALS['TYPO3_DB']->sql_num_rows($resultTitles);
$countVolumes = $GLOBALS['TYPO3_DB']->sql_num_rows($resultVolumes);
// Set replacements.
$replace = array (
'key' => array (
'###TITLES###',
'###VOLUMES###'
),
'value' => array (
$countTitles.($countTitles > 1 ? $this->pi_getLL('titles', '', TRUE) : $this->pi_getLL('title', '', TRUE)),
$countVolumes.($countVolumes > 1 ? $this->pi_getLL('volumes', '', TRUE) : $this->pi_getLL('volume', '', TRUE))
)
);
// Apply replacements.
$content = str_replace($replace['key'], $replace['value'], $content);
return $this->pi_wrapInBaseClass($content);
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/statistics/class.tx_dlf_statistics.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/statistics/class.tx_dlf_statistics.php']);
}
?>

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:dlf/plugins/statistics/locallang.xml:tt_content.pi_flexform.sheet_general</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<pages>
<TCEforms>
<onChange>reload</onChange>
<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/statistics/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>
<description>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/statistics/locallang.xml:tt_content.pi_flexform.description</label>
<config>
<type>text</type>
<cols>30</cols>
<rows>10</rows>
<wrap>virtual</wrap>
</config>
<defaultExtras>richtext[undo,redo,cut,copy,paste,link,image,line,acronym,chMode,blockstylelabel,formatblock,blockstyle,textstylelabel,textstyle,bold,italic,unorderedlist,orderedlist]:rte_transform[mode=ts_css]</defaultExtras>
</TCEforms>
</description>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for plugin tx_dlf_statistics</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">Include only these collections</label>
<label index="tt_content.pi_flexform.description">Description (Placeholders: ###TITLES### and ###VOLUMES###)</label>
<label index="title"> title</label>
<label index="titles"> titles</label>
<label index="volume"> volume</label>
<label index="volumes"> volumes</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 berücksichtigen</label>
<label index="tt_content.pi_flexform.description">Beschreibung (Platzhalter: ###TITLES### und ###VOLUMES###)</label>
<label index="title"> Titel</label>
<label index="titles"> Titel</label>
<label index="volume"> Band</label>
<label index="volumes"> Bände</label>
</languageKey>
</data>
</T3locallang>