
7 changed files with 247 additions and 0 deletions
@ -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']); |
|||
} |
|||
|
|||
?> |
@ -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> |
@ -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> |
Loading…
Reference in new issue