PageRenderTime 61ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 2ms

/ext/tt_news/pi/class.tx_ttnews.php

https://github.com/elhakim22003/TypoFlash
PHP | 3397 lines | 2322 code | 408 blank | 667 comment | 603 complexity | 66f5651fea5a2e86956d79600f52c27d MD5 | raw file
Possible License(s): GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /***************************************************************
  3. * Copyright notice
  4. *
  5. * (c) 1999-2004 Kasper Skårhøj (kasper@typo3.com)
  6. * (c) 2004-2007 Rupert Germann (rupi@gmx.li)
  7. * All rights reserved
  8. *
  9. * This script is part of the TYPO3 project. The TYPO3 project is
  10. * free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * The GNU General Public License can be found at
  16. * http://www.gnu.org/copyleft/gpl.html.
  17. * A copy is found in the textfile GPL.txt and important notices to the license
  18. * from the author is found in LICENSE.txt distributed with these scripts.
  19. *
  20. *
  21. * This script is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * This copyright notice MUST APPEAR in all copies of the script!
  27. ***************************************************************/
  28. /**
  29. * class.tx_ttnews.php
  30. *
  31. * versatile news system for TYPO3.
  32. * $Id: class.tx_ttnews.php 8605 2008-03-15 20:03:19Z rupertgermann $
  33. *
  34. * TypoScript setup:
  35. * @See static/ts_new/setup.txt
  36. * @See tt_news Manual: http://typo3.org/documentation/document-library/extension-manuals/tt_news/current/
  37. * @See TSref: http://typo3.org/documentation/document-library/references/doc_core_tsref/current/
  38. *
  39. * @author Rupert Germann <rupi@gmx.li>
  40. * @co-author Ingo Renner <typo3@ingo-renner.com>
  41. */
  42. /**
  43. * [CLASS/FUNCTION INDEX of SCRIPT]
  44. *
  45. *
  46. *
  47. * 112: class tx_ttnews extends tslib_pibase
  48. * 143: function main_news($content, $conf)
  49. * 219: function init($conf)
  50. * 373: function newsArchiveMenu()
  51. * 523: function displaySingle()
  52. * 606: function displayVersionPreview ()
  53. * 659: function displayList($excludeUids = 0)
  54. * 1003: function getListContent($itemparts, $selectConf, $prefix_display)
  55. * 1172: function getSelectConf($where, $noPeriod = 0)
  56. * 1419: function generatePageArray()
  57. * 1440: function getItemMarkerArray ($row, $textRenderObj = 'displaySingle')
  58. * 1723: function insertPagebreaks($text,$firstPageWordCrop)
  59. * 1773: function makeMultiPageSView($bodytext,$lConf)
  60. * 1803: function makePageBrowser($showResultCount=1,$tableParams='',$pointerName='pointer')
  61. * 1885: function getCategories($uid, $getAll=false)
  62. * 1958: function getCategoryPath($categoryArray)
  63. * 2015: function getSubCategories($catlist, $cc = 0)
  64. * 2044: function displayCatMenu()
  65. * 2157: function getCatMenuContent($array_in,$lConf, $l=0)
  66. * 2209: function getSubCategoriesForMenu ($catlist, $fields, $addWhere, $cc = 0)
  67. * 2240: function getCatMarkerArray($markerArray, $row, $lConf)
  68. * 2380: function getImageMarkers($markerArray, $row, $lConf, $textRenderObj)
  69. * 2448: function getRelated($uid)
  70. * 2608: function userProcess($mConfKey, $passVar)
  71. * 2623: function spMarker($subpartMarker)
  72. * 2641: function searchWhere($sw)
  73. * 2652: function formatStr($str)
  74. * 2667: function getLayouts($templateCode, $alternatingLayouts, $marker)
  75. * 2685: function initLanguages ()
  76. * 2705: function initCategoryVars()
  77. * 2775: function checkRecords($recordlist)
  78. * 2807: function initTemplate()
  79. * 2832: function initPidList ()
  80. * 2857: function getXmlHeader()
  81. * 2958: function getW3cDate($datetime)
  82. * 2983: function main_xmlnewsfeed($content, $conf)
  83. * 2998: function getStoriesResult()
  84. * 3020: function cleanXML($str)
  85. * 3034: function convertDates()
  86. * 3073: function getHrDateSingle($tstamp)
  87. * 3086: function displayFEHelp()
  88. * 3107: function validateFields($fieldlist)
  89. * 3128: function getNewsSubpart($myTemplate, $myKey, $row = Array())
  90. *
  91. * SECTION: DB Functions
  92. * 3149: function exec_getQuery($table, $conf)
  93. * 3167: function getQuery($table, $conf, $returnQueryArray=FALSE)
  94. * 3249: function getWhere($table,$conf, $returnQueryArray=FALSE)
  95. *
  96. * TOTAL FUNCTIONS: 45
  97. * (This index is automatically created/updated by the extension "extdeveval")
  98. *
  99. */
  100. require_once(PATH_t3lib . 'class.t3lib_xml.php');
  101. require_once(PATH_t3lib . 'class.t3lib_htmlmail.php');
  102. require_once(PATH_tslib . 'class.tslib_pibase.php');
  103. require_once(t3lib_extMgm::extPath('tt_news') . 'class.tx_ttnews_catmenu.php');
  104. /**
  105. * Plugin 'news' for the 'tt_news' extension.
  106. *
  107. * @author Rupert Germann <rupi@gmx.li>
  108. * @package TYPO3
  109. * @subpackage tt_news
  110. */
  111. class tx_ttnews extends tslib_pibase {
  112. // Default plugin variables:
  113. var $prefixId = 'tx_ttnews'; // Same as class name
  114. var $scriptRelPath = 'pi/class.tx_ttnews.php'; // Path to this script relative to the extension dir.
  115. var $extKey = 'tt_news'; // The extension key.
  116. var $tt_news_uid; // the uid of the current news record in SINGLE view
  117. var $config; // the processed TypoScript configuration array
  118. var $langArr; // the languages found in the tt_news sysfolder
  119. var $sys_language_mode;
  120. var $alternatingLayouts;
  121. var $allowCaching;
  122. var $catExclusive;
  123. var $arcExclusive;
  124. var $searchFieldList = 'short,bodytext,author,keywords,links,imagecaption,title';
  125. var $theCode = '';
  126. var $rdfToc = '';
  127. var $versioningEnabled = false; // is the extension 'version' loaded
  128. var $vPrev = false; // do we display a versioning preview
  129. var $categories = array(); // Is initialized with the categories of the news system
  130. var $pageArray = array(); // Is initialized with an array of the pages in the pid-list
  131. /**
  132. * Main news function: calls the init_news() function and decides by the given CODEs which of the
  133. * functions to display news should by called.
  134. *
  135. * @param string $content : function output is added to this
  136. * @param array $conf : configuration array
  137. * @return string $content: complete content generated by the tt_news plugin
  138. */
  139. function main_news($content, $conf) {
  140. $this->local_cObj = t3lib_div::makeInstance('tslib_cObj'); // Local cObj.
  141. $this->init($conf);
  142. if ($this->conf['displayCurrentRecord']) {
  143. $this->config['code'] = $this->conf['defaultCode']?trim($this->conf['defaultCode']):'SINGLE';
  144. $this->tt_news_uid = $this->cObj->data['uid'];
  145. }
  146. // get codes and decide which function is used to process the content
  147. $codes = t3lib_div::trimExplode(',', $this->config['code']?$this->config['code']:$this->conf['defaultCode'], 1);
  148. if (!count($codes)) { // no code at all
  149. $codes = array();
  150. $noCode = true;
  151. }
  152. while (list(, $theCode) = each($codes)) {
  153. $theCode = (string)strtoupper(trim($theCode));
  154. $this->theCode = $theCode;
  155. switch ($theCode) {
  156. case 'SINGLE':
  157. $content .= $this->displaySingle();
  158. break;
  159. case 'VERSION_PREVIEW':
  160. $content .= $this->displayVersionPreview();
  161. break;
  162. case 'LATEST':
  163. case 'LIST':
  164. case 'SEARCH':
  165. case 'XML':
  166. $content .= $this->displayList();
  167. break;
  168. case 'AMENU':
  169. $content .= $this->newsArchiveMenu();
  170. break;
  171. case 'CATMENU':
  172. $content .= $this->displayCatMenu();
  173. break;
  174. default:
  175. // Adds hook for processing of extra codes
  176. if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['extraCodesHook'])) {
  177. foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['extraCodesHook'] as $_classRef) {
  178. $_procObj = & t3lib_div::getUserObj($_classRef);
  179. $content .= $_procObj->extraCodesProcessor($this);
  180. }
  181. } else {
  182. $langKey = strtoupper($GLOBALS['TSFE']->config['config']['language']);
  183. $helpTemplate = $this->cObj->fileResource('EXT:tt_news/pi/news_help.tmpl');
  184. // Get language version of the help-template
  185. $helpTemplate_lang = '';
  186. if ($langKey) {
  187. $helpTemplate_lang = $this->getNewsSubpart($helpTemplate, "###TEMPLATE_" . $langKey . '###');
  188. }
  189. $helpTemplate = $helpTemplate_lang ? $helpTemplate_lang :
  190. $this->getNewsSubpart($helpTemplate, '###TEMPLATE_DEFAULT###');
  191. // Markers and substitution:
  192. $markerArray['###CODE###'] = $this->theCode;
  193. $markerArray['###EXTPATH###'] = $GLOBALS['TYPO3_LOADED_EXT']['tt_news']['siteRelPath'];
  194. $content .= $this->displayFEHelp();
  195. }
  196. break;
  197. }
  198. }
  199. if($noCode) {
  200. $content .= $this->displayFEHelp();
  201. }
  202. return $content;
  203. }
  204. /**
  205. * Init Function: here all the needed configuration values are stored in class variables..
  206. *
  207. * @param array $conf : configuration array from TS
  208. * @return void
  209. */
  210. function init($conf) {
  211. $this->conf = $conf; //store configuration
  212. $this->pi_loadLL(); // Loading language-labels
  213. $this->pi_setPiVarDefaults(); // Set default piVars from TS
  214. $this->pi_initPIflexForm(); // Init FlexForm configuration for plugin
  215. $this->enableFields = $this->cObj->enableFields('tt_news');
  216. $this->tt_news_uid = intval($this->piVars['tt_news']); // Get the submitted uid of a news (if any)
  217. if (!isset($this->conf['compatVersion']) || !preg_match('/^\d+\.\d+\.\d+$/', $this->conf['compatVersion'])) {
  218. $this->conf['compatVersion'] = $this->getCurrentVersion();
  219. }
  220. if (t3lib_extMgm::isLoaded('version')) {
  221. $this->versioningEnabled = true;
  222. }
  223. // load available syslanguages
  224. $this->initLanguages();
  225. // sys_language_mode defines what to do if the requested translation is not found
  226. $this->sys_language_mode = $this->conf['sys_language_mode']?$this->conf['sys_language_mode'] : $GLOBALS['TSFE']->sys_language_mode;
  227. // "CODE" decides what is rendered: codes can be set by TS or FF with priority on FF
  228. $code = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'what_to_display', 'sDEF');
  229. $this->config['code'] = $code ? $code : $this->cObj->stdWrap($this->conf['code'], $this->conf['code.']);
  230. // initialize category vars
  231. $this->initCategoryVars();
  232. // get fieldnames from the tt_news db-table
  233. $this->fieldNames = array_keys($GLOBALS['TYPO3_DB']->admin_get_fields('tt_news'));
  234. if ($this->conf['searchFieldList']) {
  235. $searchFieldList = $this->validateFields($this->conf['searchFieldList']);
  236. if ($searchFieldList) {
  237. $this->searchFieldList = $searchFieldList;
  238. }
  239. }
  240. // Archive:
  241. $this->config['archiveMode'] = trim($this->conf['archiveMode']) ; // month, quarter or year listing in AMENU
  242. $this->config['archiveMode'] = $this->config['archiveMode']?$this->config['archiveMode']:'month';
  243. // arcExclusive : -1=only non-archived; 0=don't care; 1=only archived
  244. $arcExclusive = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'archive', 'sDEF');
  245. $this->arcExclusive = $arcExclusive?$arcExclusive:$this->conf['archive'];
  246. $this->config['datetimeDaysToArchive'] = intval($this->conf['datetimeDaysToArchive']);
  247. $this->config['datetimeHoursToArchive'] = intval($this->conf['datetimeHoursToArchive']);
  248. $this->config['datetimeMinutesToArchive'] = intval($this->conf['datetimeMinutesToArchive']);
  249. if ($this->conf['useHRDates']) {
  250. $this->convertDates();
  251. }
  252. // list of pages where news records will be taken from
  253. if (!$this->conf['dontUsePidList']) {
  254. $this->initPidList();
  255. }
  256. // itemLinkTarget is only used for categoryLinkMode 3 (catselector) in framesets
  257. $this->config['itemLinkTarget'] = trim($this->conf['itemLinkTarget']);
  258. // id of the page where the search results should be displayed
  259. $this->config['searchPid'] = intval($this->conf['searchPid']);
  260. // pages in Single view will be divided by this token
  261. $this->config['pageBreakToken'] = trim($this->conf['pageBreakToken'])?trim($this->conf['pageBreakToken']):'<---newpage--->';
  262. $this->config['singleViewPointerName'] = trim($this->conf['singleViewPointerName'])?trim($this->conf['singleViewPointerName']):'sViewPointer';
  263. $maxWordsInSingleView = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'maxWordsInSingleView', 's_misc'));
  264. $maxWordsInSingleView = $maxWordsInSingleView?$maxWordsInSingleView:intval($this->conf['maxWordsInSingleView']);
  265. $this->config['maxWordsInSingleView'] = $maxWordsInSingleView?$maxWordsInSingleView:0;
  266. $this->config['useMultiPageSingleView'] = $maxWordsInSingleView>1?1:$this->conf['useMultiPageSingleView'];
  267. // pid of the page with the single view. the old var PIDitemDisplay is still processed if no other value is found
  268. $singlePid = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'PIDitemDisplay', 's_misc');
  269. $singlePid = $singlePid?$singlePid:intval($this->cObj->stdWrap($this->conf['singlePid'],$this->conf['singlePid.']));
  270. $this->config['singlePid'] = $singlePid ? $singlePid:intval($this->conf['PIDitemDisplay']);
  271. // pid to return to when leaving single view
  272. $backPid = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'backPid', 's_misc'));
  273. $backPid = $backPid?$backPid:intval($this->conf['backPid']);
  274. $backPid = $backPid?$backPid:intval($this->piVars['backPid']);
  275. $backPid = $backPid?$backPid:$GLOBALS['TSFE']->id ;
  276. $this->config['backPid'] = $backPid;
  277. // max items per page
  278. $FFlimit = t3lib_div::intInRange($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'listLimit', 's_misc'), 0, 1000);
  279. $limit = t3lib_div::intInRange($this->cObj->stdWrap($this->conf['limit'],$this->conf['limit.']), 0, 1000);
  280. $limit = $limit?$limit: 50;
  281. $this->config['limit'] = $FFlimit?$FFlimit: $limit;
  282. $latestLimit = t3lib_div::intInRange($this->cObj->stdWrap($this->conf['latestLimit'],$this->conf['latestLimit.']), 0, 1000);
  283. $latestLimit = $latestLimit?$latestLimit:10;
  284. $this->config['latestLimit'] = $FFlimit?$FFlimit:$latestLimit;
  285. // orderBy and groupBy statements for the list Query
  286. $orderBy = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'listOrderBy', 'sDEF');
  287. $orderByTS = trim($this->conf['listOrderBy']);
  288. $orderBy = $orderBy?$orderBy:$orderByTS;
  289. $this->config['orderBy'] = $orderBy;
  290. if ($orderBy) {
  291. $ascDesc = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'ascDesc', 'sDEF');
  292. $this->config['ascDesc'] = $ascDesc;
  293. if ($this->config['ascDesc']) {
  294. // remove ASC/DESC from 'orderBy' if it is already set from TS
  295. $this->config['orderBy'] = preg_replace('/( DESC| ASC)\b/i','',$this->config['orderBy']);
  296. }
  297. }
  298. $this->config['groupBy'] = trim($this->conf['listGroupBy']);
  299. // if this is set, the first image is handled as preview image, which is only shown in list view
  300. $fImgPreview = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'firstImageIsPreview', 's_misc');
  301. $this->config['firstImageIsPreview'] = $fImgPreview?$fImgPreview : $this->conf['firstImageIsPreview'];
  302. $forcefImgPreview = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'forceFirstImageIsPreview', 's_misc');
  303. $this->config['forceFirstImageIsPreview'] = $forcefImgPreview?$fImgPreview : $this->conf['forceFirstImageIsPreview'];
  304. // List start id
  305. $listStartId = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'listStartId', 's_misc'));
  306. $this->config['listStartId'] = $listStartId?$listStartId:intval($this->conf['listStartId']);
  307. // supress pagebrowser
  308. $noPageBrowser = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'noPageBrowser', 's_misc');
  309. $this->config['noPageBrowser'] = $noPageBrowser?$noPageBrowser: $this->conf['noPageBrowser'];
  310. // image sizes given from FlexForms
  311. $this->config['FFimgH'] = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'imageMaxHeight', 's_template'));
  312. $this->config['FFimgW'] = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'imageMaxWidth', 's_template'));
  313. // Get number of alternative Layouts (loop layout in LATEST and LIST view) default is 2:
  314. $altLayouts = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'alternatingLayouts', 's_template'));
  315. $altLayouts = $altLayouts?$altLayouts:intval($this->conf['alternatingLayouts']);
  316. $this->alternatingLayouts = $altLayouts?$altLayouts:2;
  317. // Get cropping lenght
  318. $this->config['croppingLenght'] = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'croppingLenght', 's_template'));
  319. $this->initTemplate();
  320. // Configure caching
  321. $this->allowCaching = $this->conf['allowCaching']?1:0;
  322. if (!$this->allowCaching) {
  323. $GLOBALS['TSFE']->set_no_cache();
  324. }
  325. // get siteUrl for links in rss feeds. the 'dontInsert' option seems to be needed in some configurations depending on the baseUrl setting
  326. if (!$this->conf['displayXML.']['dontInsertSiteUrl']) {
  327. $this->config['siteUrl'] = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
  328. }
  329. }
  330. /**
  331. * generates the News archive menu
  332. *
  333. * @return string html code of the archive menu
  334. */
  335. function newsArchiveMenu() {
  336. $this->arcExclusive = 1;
  337. $selectConf = $this->getSelectConf('', 1);
  338. // Finding maximum and minimum values:
  339. $selectConf['selectFields'] = 'max(tt_news.datetime) as maxval, min(tt_news.datetime) as minval';
  340. $res = $this->exec_getQuery('tt_news', $selectConf);
  341. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  342. if ($row['minval'] || $row['maxval']) {
  343. // if ($row['minval']) {
  344. $dateArr = array();
  345. $arcMode = $this->config['archiveMode'];
  346. $c = 0;
  347. do {
  348. switch ($arcMode) {
  349. case 'month':
  350. $theDate = mktime (0, 0, 0, date('m', $row['minval']) + $c, 1, date('Y', $row['minval']));
  351. break;
  352. case 'quarter':
  353. $theDate = mktime (0, 0, 0, floor(date('m', $row['minval']) / 3) + 1 + (3 * $c), 1, date('Y', $row['minval']));
  354. break;
  355. case 'year':
  356. $theDate = mktime (0, 0, 0, 1, 1, date('Y', $row['minval']) + $c);
  357. break;
  358. }
  359. $dateArr[] = $theDate;
  360. $c++;
  361. if ($c > 1000) break;
  362. }
  363. while ($theDate < $GLOBALS['SIM_EXEC_TIME']);
  364. reset($dateArr);
  365. $periodAccum = array();
  366. $selectConf2['where'] = $selectConf['where'];
  367. while (list($k, $v) = each($dateArr)) {
  368. if (!isset($dateArr[$k + 1])) {
  369. break;
  370. }
  371. $periodInfo = array();
  372. $periodInfo['start'] = $dateArr[$k];
  373. $periodInfo['stop'] = $dateArr[$k + 1]-1;
  374. $periodInfo['HRstart'] = date('d-m-Y', $periodInfo['start']);
  375. $periodInfo['HRstop'] = date('d-m-Y', $periodInfo['stop']);
  376. $periodInfo['quarter'] = floor(date('m', $dateArr[$k]) / 3) + 1;
  377. // execute a query to count the archive periods
  378. $selectConf['selectFields'] = 'count(distinct(tt_news.uid))';
  379. $selectConf['where'] = $selectConf2['where'] . ' AND tt_news.datetime>=' . $periodInfo['start'] . ' AND tt_news.datetime<' . $periodInfo['stop'];
  380. $res = $this->exec_getQuery('tt_news', $selectConf);
  381. $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
  382. $periodInfo['count'] = $row[0];
  383. if (!$this->conf['archiveMenuNoEmpty'] || $periodInfo['count']) {
  384. $periodAccum[] = $periodInfo;
  385. }
  386. }
  387. // get template subpart
  388. $t['total'] = $this->getNewsSubpart($this->templateCode, $this->spMarker('###TEMPLATE_ARCHIVE###'));
  389. $t['item'] = $this->getLayouts($t['total'], $this->alternatingLayouts, 'MENUITEM');
  390. $cc = 0;
  391. $veryLocal_cObj = t3lib_div::makeInstance('tslib_cObj');
  392. // reverse amenu order if 'reverseAMenu' is given
  393. if ($this->conf['reverseAMenu']) {
  394. arsort($periodAccum);
  395. }
  396. $archiveLink = $this->conf['archiveTypoLink.']['parameter'];
  397. $this->conf['parent.']['addParams'] = $this->conf['archiveTypoLink.']['addParams'];
  398. reset($periodAccum);
  399. $itemsOutArr = array();
  400. while (list(, $pArr) = each($periodAccum)) {
  401. // Print Item Title
  402. $wrappedSubpartArray = array();
  403. if (!$this->conf['disableCategoriesInAmenuLinks']) {
  404. if ($this->config['catSelection'] && $this->config['amenuWithCatSelector']) {
  405. // use the catSelection from GPvars only if 'amenuWithCatSelector' is given.
  406. $amenuLinkCat = $this->config['catSelection'];
  407. } else {
  408. $amenuLinkCat = $this->catExclusive;
  409. }
  410. }
  411. if ($this->conf['useHRDates']) {
  412. $year = date('Y',$pArr['start']);
  413. $month = date('m',$pArr['start']);
  414. if ($arcMode == 'year') {
  415. $archLinkArr = $this->pi_linkTP_keepPIvars('|', array('cat' => ($amenuLinkCat?$amenuLinkCat:null), 'year' => $year), $this->allowCaching, 1, ($archiveLink?$archiveLink:$GLOBALS['TSFE']->id));
  416. } else {
  417. $archLinkArr = $this->pi_linkTP_keepPIvars('|', array('cat' => ($amenuLinkCat?$amenuLinkCat:null), 'year' => $year, 'month' => $month), $this->allowCaching, 1, ($archiveLink?$archiveLink:$GLOBALS['TSFE']->id));
  418. }
  419. $wrappedSubpartArray['###LINK_ITEM###'] = explode('|', $archLinkArr);
  420. } else {
  421. $wrappedSubpartArray['###LINK_ITEM###'] = explode('|', $this->pi_linkTP_keepPIvars('|', array('cat' => ($amenuLinkCat?$amenuLinkCat:null), 'pS' => $pArr['start'], 'pL' => ($pArr['stop'] - $pArr['start']), 'arc' => 1), $this->allowCaching, 1, ($archiveLink?$archiveLink:$GLOBALS['TSFE']->id)));
  422. }
  423. $markerArray = array();
  424. $veryLocal_cObj->start($pArr, '');
  425. $markerArray['###ARCHIVE_TITLE###'] = $veryLocal_cObj->cObjGetSingle($this->conf['archiveTitleCObject'], $this->conf['archiveTitleCObject.'], 'archiveTitle');
  426. $markerArray['###ARCHIVE_COUNT###'] = $pArr['count'];
  427. $markerArray['###ARCHIVE_ITEMS###'] = $this->pi_getLL('archiveItems');
  428. // fill the generated data to an array to pass it to a userfuction as a single variable
  429. $itemsOutArr[] = array('html' => $this->cObj->substituteMarkerArrayCached($t['item'][($cc % count($t['item']))], $markerArray, array(), $wrappedSubpartArray), 'data' => $pArr);
  430. $cc++;
  431. }
  432. // Pass to user defined function
  433. if ($this->conf['newsAmenuUserFunc']) {
  434. $itemsOutArr = $this->userProcess('newsAmenuUserFunc', $itemsOutArr);
  435. }
  436. foreach ($itemsOutArr as $itemHtml) {
  437. $tmpItemsArr[] = $itemHtml['html'];
  438. }
  439. if (is_array($tmpItemsArr)) {
  440. $itemsOut = implode('', $tmpItemsArr);
  441. }
  442. // Reset:
  443. $subpartArray = array();
  444. $wrappedSubpartArray = array();
  445. $markerArray = array();
  446. $markerArray['###ARCHIVE_HEADER###'] = $this->local_cObj->stdWrap($this->pi_getLL('archiveHeader'), $this->conf['archiveHeader_stdWrap.']);
  447. // Set content
  448. $subpartArray['###CONTENT###'] = $itemsOut;
  449. $content = $this->cObj->substituteMarkerArrayCached($t['total'], $markerArray, $subpartArray, $wrappedSubpartArray);
  450. } else {
  451. // if nothing is found in the archive display the TEMPLATE_ARCHIVE_NOITEMS message
  452. $markerArray['###ARCHIVE_HEADER###'] = $this->local_cObj->stdWrap($this->pi_getLL('archiveHeader'), $this->conf['archiveHeader_stdWrap.']);
  453. $markerArray['###ARCHIVE_EMPTY_MSG###'] = $this->local_cObj->stdWrap($this->pi_getLL('archiveEmptyMsg'), $this->conf['archiveEmptyMsg_stdWrap.']);
  454. $noItemsMsg = $this->getNewsSubpart($this->templateCode, $this->spMarker('###TEMPLATE_ARCHIVE_NOITEMS###'));
  455. $content = $this->cObj->substituteMarkerArrayCached($noItemsMsg, $markerArray);
  456. }
  457. return $content;
  458. }
  459. /**
  460. * Displays the "single view" of a news article. Is also used when displaying single news records with the "insert records" content element.
  461. *
  462. * @return string html-code for the "single view"
  463. */
  464. function displaySingle() {
  465. $singleWhere = 'tt_news.uid=' . intval($this->tt_news_uid);
  466. $singleWhere .= ' AND type NOT IN(1,2)' . $this->enableFields; // only real news -> type=0
  467. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
  468. '*',
  469. 'tt_news',
  470. $singleWhere);
  471. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  472. // get the translated record if the content language is not the default language
  473. if ($GLOBALS['TSFE']->sys_language_content) {
  474. $OLmode = ($this->sys_language_mode == 'strict'?'hideNonTranslated':'');
  475. $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay('tt_news', $row, $GLOBALS['TSFE']->sys_language_content, $OLmode);
  476. }
  477. if ($this->versioningEnabled) {
  478. // get workspaces Overlay
  479. $GLOBALS['TSFE']->sys_page->versionOL('tt_news',$row);
  480. // fix pid for record from workspace
  481. $GLOBALS['TSFE']->sys_page->fixVersioningPid('tt_news',$row);
  482. }
  483. $GLOBALS['TSFE']->displayedNews[]=$row['uid'];
  484. if (is_array($row) && ($row['pid'] > 0 || $this->vPrev)) { // never display versions of a news record (having pid=-1) for normal website users
  485. // Get the subpart code
  486. if ($this->conf['displayCurrentRecord']) {
  487. $item = trim($this->getNewsSubpart($this->templateCode, $this->spMarker('###TEMPLATE_SINGLE_RECORDINSERT###'), $row));
  488. }
  489. if (!$item) {
  490. $item = $this->getNewsSubpart($this->templateCode, $this->spMarker('###TEMPLATE_SINGLE###'), $row);
  491. }
  492. // reset marker array
  493. $wrappedSubpartArray = array();
  494. // build the backToList link
  495. if ($this->conf['useHRDates']) {
  496. $pointerName = 'pointer';
  497. $wrappedSubpartArray['###LINK_ITEM###'] = explode('|', $this->pi_linkTP_keepPIvars('|', array(
  498. 'tt_news' => null,
  499. 'backPid' => null,
  500. $this->config['singleViewPointerName'] => null,
  501. 'pS' => null,
  502. 'pL' => null), $this->allowCaching, ($this->conf['dontUseBackPid']?1:0), $this->config['backPid']));
  503. } else {
  504. $wrappedSubpartArray['###LINK_ITEM###'] = explode('|', $this->pi_linkTP_keepPIvars('|', array(
  505. 'tt_news' => null,
  506. 'backPid' => null,
  507. $this->config['singleViewPointerName'] => null), $this->allowCaching, ($this->conf['dontUseBackPid']?1:0), $this->config['backPid']));
  508. }
  509. // set the title of the single view page to the title of the news record
  510. if ($this->conf['substitutePagetitle']) {
  511. $GLOBALS['TSFE']->page['title'] = $row['title'];
  512. // set pagetitle for indexed search to news title
  513. $GLOBALS['TSFE']->indexedDocTitle = $row['title'];
  514. }
  515. if ($this->conf['displaySingle.']['catOrderBy']) {
  516. $this->config['catOrderBy'] = $this->conf['displaySingle.']['catOrderBy'];
  517. }
  518. $markerArray = $this->getItemMarkerArray($row, 'displaySingle');
  519. // Substitute
  520. $content = $this->cObj->substituteMarkerArrayCached($item, $markerArray, array(), $wrappedSubpartArray);
  521. } elseif ($this->sys_language_mode == 'strict' && $this->tt_news_uid && $GLOBALS['TSFE']->sys_language_content) { // not existing translation
  522. $noTranslMsg = $this->local_cObj->stdWrap($this->pi_getLL('noTranslMsg'), $this->conf['noNewsIdMsg_stdWrap.']);
  523. $content = $noTranslMsg;
  524. } elseif ($row['pid'] < 0) { // a non-public version of a record was requested
  525. $nonPlublicVersion = $this->local_cObj->stdWrap($this->pi_getLL('nonPlublicVersionMsg'), $this->conf['nonPlublicVersionMsg_stdWrap.']);
  526. $content = $nonPlublicVersion;
  527. } else { // if singleview is shown with no tt_news uid given from GETvars (&tx_ttnews[tt_news]=) an error message is displayed.
  528. $noNewsIdMsg = $this->local_cObj->stdWrap($this->pi_getLL('noNewsIdMsg'), $this->conf['noNewsIdMsg_stdWrap.']);
  529. $content = $noNewsIdMsg;
  530. }
  531. return $content;
  532. }
  533. /**
  534. * Displays the "versioning preview".
  535. * The functions checks:
  536. * - if the extension "version" is loaded
  537. * - if a BE_user is logged in
  538. * - the plausibility of the requested "version preview".
  539. * If this is all OK, "displaySingle()" is executed to display the "versioning preview".
  540. *
  541. * @return string html code for the "versioning preview"
  542. */
  543. function displayVersionPreview () {
  544. if ($this->versioningEnabled) {
  545. $vPrev = t3lib_div::_GP('ADMCMD_vPrev');
  546. if ($this->piVars['ADMCMD_vPrev']) {
  547. $piADMCMD = unserialize(rawurldecode($this->piVars['ADMCMD_vPrev']));
  548. }
  549. if ((is_array($vPrev) || is_array($piADMCMD)) && is_object($GLOBALS['BE_USER'])) { // check if ADMCMD_vPrev is set and if a BE_user is logged in. $this->piVars['ADMCMD_vPrev'] is needed for previewing a "single view with pagebrowser"
  550. if (!is_array($vPrev)) { $vPrev = $piADMCMD; }
  551. list($table,$t3ver_oid) = explode(':',key($vPrev));
  552. if ($table == 'tt_news') {
  553. if ($testrec = $this->pi_getRecord('tt_news', intval($vPrev[key($vPrev)]))) { // check if record exists before doing anything
  554. if ($testrec['t3ver_oid'] == intval($t3ver_oid) && $testrec['pid']==-1) { // check if requested t3ver_oid is the t3ver_oid of the requested tt_news record, and if the pid of the record is -1 (=non-plublic version)
  555. $GLOBALS['TSFE']->set_no_cache(); // version preview will never be cached
  556. // make version preview message with a link to the public version of hte record which is previewed
  557. $vPrevHeader = $this->local_cObj->stdWrap(
  558. $this->pi_getLL('versionPreviewMessage').
  559. $this->local_cObj->typolink(
  560. $this->local_cObj->stdWrap(
  561. $this->pi_getLL('versionPreviewMessageLinkToOriginal'),$this->conf['versionPreviewMessageLinkToOriginal_stdWrap.']
  562. ),
  563. array(
  564. 'parameter' => $this->config['singlePid'].' _blank',
  565. 'additionalParams' => '&tx_ttnews[tt_news]='.$t3ver_oid,
  566. 'no_cache' => 1
  567. )
  568. ),
  569. $this->conf['versionPreviewMessage_stdWrap.']
  570. );
  571. $this->tt_news_uid = intval($vPrev[key($vPrev)]);
  572. $this->piVars['tt_news'] = $this->tt_news_uid;
  573. $this->piVars['ADMCMD_vPrev'] = rawurlencode(serialize(array($table.':'.$t3ver_oid => $this->tt_news_uid)));
  574. $this->theCode = 'SINGLE';
  575. $this->vPrev = true;
  576. $content = $vPrevHeader.$this->displaySingle();
  577. } else { // error: t3ver_oid mismatch
  578. $GLOBALS['TT']->setTSlogMessage('tt_news: ERROR! The "t3ver_oid" of requested tt_news record and the "t3ver_oid" from GPvars doesn\'t match.');
  579. }
  580. }
  581. }
  582. }
  583. }
  584. return $content;
  585. }
  586. /**
  587. * Display LIST,LATEST or SEARCH
  588. * Things happen: determine the template-part to use, get the query parameters (add where if search was performed),
  589. * exec count query to get the number of results, check if a browsebox should be displayed,
  590. * get the general Markers for each item and fill the content array, check if a browsebox should be displayed
  591. *
  592. * @param string $excludeUids : commaseparated list of tt_news uids to exclude from display
  593. * @return string html-code for the plugin content
  594. */
  595. function displayList($excludeUids = 0) {
  596. $theCode = $this->theCode;
  597. $where = '';
  598. $content = '';
  599. switch ($theCode) {
  600. case 'LATEST':
  601. $prefix_display = 'displayLatest';
  602. $templateName = 'TEMPLATE_LATEST';
  603. if (!$this->conf['displayArchivedInLatest']) {
  604. // if this is set, latest will do the same as list
  605. $this->arcExclusive = -1; // Only latest, non archive news
  606. }
  607. $this->config['limit'] = $this->config['latestLimit'];
  608. break;
  609. case 'LIST':
  610. $prefix_display = 'displayList';
  611. $templateName = 'TEMPLATE_LIST';
  612. break;
  613. case 'SEARCH':
  614. $prefix_display = 'displayList';
  615. $templateName = 'TEMPLATE_LIST';
  616. // Make markers for the searchform
  617. $searchMarkers = array(
  618. '###FORM_URL###' => $this->pi_linkTP_keepPIvars_url(array('pointer' => null, 'cat' => null), 0, 1, $this->config['searchPid']),
  619. '###SWORDS###' => htmlspecialchars($this->piVars['swords']),
  620. '###SEARCH_BUTTON###' => $this->pi_getLL('searchButtonLabel'),
  621. );
  622. // Hook for any additional form fields
  623. if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['additionalFormSearchFields'])) {
  624. foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['additionalFormSearchFields'] as $_classRef) {
  625. $_procObj = & t3lib_div::getUserObj($_classRef);
  626. $searchMarkers = $_procObj->additionalFormSearchFields($this, $searchMarkers);
  627. }
  628. }
  629. // Add to content
  630. $searchSub = $this->getNewsSubpart($this->templateCode, $this->spMarker('###TEMPLATE_SEARCH###'));
  631. $content .= $this->cObj->substituteMarkerArray($searchSub, $searchMarkers);
  632. unset($searchSub);
  633. unset($searchMarkers);
  634. // do the search and add the result to the $where string
  635. if ($this->piVars['swords']) {
  636. $where = $this->searchWhere(trim($this->piVars['swords']));
  637. $theCode = 'SEARCH';
  638. } else {
  639. $where = ($this->conf['emptySearchAtStart']?'AND 1=0':''); // display an empty list, if 'emptySearchAtStart' is set.
  640. }
  641. break;
  642. // xml news export
  643. case 'XML':
  644. $prefix_display = 'displayXML';
  645. // $this->arcExclusive = -1; // Only latest, non archive news
  646. $this->allowCaching = $this->conf['displayXML.']['xmlCaching'];
  647. $this->config['limit'] = $this->conf['displayXML.']['xmlLimit']?$this->conf['displayXML.']['xmlLimit']:
  648. $this->config['limit'];
  649. switch ($this->conf['displayXML.']['xmlFormat']) {
  650. case 'rss091':
  651. $templateName = 'TEMPLATE_RSS091';
  652. $this->templateCode = $this->cObj->fileResource($this->conf['displayXML.']['rss091_tmplFile']);
  653. break;
  654. case 'rss2':
  655. $templateName = 'TEMPLATE_RSS2';
  656. $this->templateCode = $this->cObj->fileResource($this->conf['displayXML.']['rss2_tmplFile']);
  657. break;
  658. case 'rdf':
  659. $templateName = 'TEMPLATE_RDF';
  660. $this->templateCode = $this->cObj->fileResource($this->conf['displayXML.']['rdf_tmplFile']);
  661. break;
  662. case 'atom03':
  663. $templateName = 'TEMPLATE_ATOM03';
  664. $this->templateCode = $this->cObj->fileResource($this->conf['displayXML.']['atom03_tmplFile']);
  665. break;
  666. case 'atom1':
  667. $templateName = 'TEMPLATE_ATOM1';
  668. $this->templateCode = $this->cObj->fileResource($this->conf['displayXML.']['atom1_tmplFile']);
  669. break;
  670. }
  671. break;
  672. }
  673. // process extra codes from $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']
  674. $userCodes = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['what_to_display'];
  675. if ($userCodes && !$prefix_display && !$templateName) {
  676. while (list(, $ucode) = each($userCodes)) {
  677. if ($theCode == $ucode[0]) {
  678. $prefix_display = 'displayList';
  679. $templateName = 'TEMPLATE_' . $ucode[0] ;
  680. }
  681. }
  682. }
  683. $noPeriod = 0; // used to call getSelectConf without a period lenght (pL) at the first archive page
  684. $pointerName = $this->pointerName = 'pointer';
  685. if (!$this->conf['emptyArchListAtStart']) {
  686. // if this is true, we're listing from the archive for the first time (no pS set), to prevent an empty list page we set the pS value to the archive start
  687. if (($this->arcExclusive > 0 && !$this->piVars['pS'] && $theCode != 'SEARCH')) {
  688. // set pS to time minus archive startdate
  689. if ($this->config['datetimeMinutesToArchive']) {
  690. $this->piVars['pS'] = ($GLOBALS['SIM_EXEC_TIME'] - ($this->config['datetimeMinutesToArchive'] * 60));
  691. } elseif ($this->config['datetimeHoursToArchive']) {
  692. $this->piVars['pS'] = ($GLOBALS['SIM_EXEC_TIME'] - ($this->config['datetimeHoursToArchive'] * 3600));
  693. } else {
  694. $this->piVars['pS'] = ($GLOBALS['SIM_EXEC_TIME'] - ($this->config['datetimeDaysToArchive'] * 86400));
  695. }
  696. }
  697. }
  698. if ($this->piVars['pS'] && !$this->piVars['pL']) {
  699. $noPeriod = 1; // override the period lenght checking in getSelectConf
  700. }
  701. // Allowed to show the listing? periodStart must be set, when listing from the archive.
  702. if (!($this->arcExclusive > -1 && !$this->piVars['pS'] && $theCode != 'SEARCH')) {
  703. if ($this->conf['displayCurrentRecord'] && $this->tt_news_uid) {
  704. $this->pid_list = $this->cObj->data['pid'];
  705. $where = 'AND tt_news.uid=' . $this->tt_news_uid;
  706. }
  707. if ($excludeUids) {
  708. $where = ' AND tt_news.uid NOT IN ('.$excludeUids.')';
  709. }
  710. // build parameter Array for List query
  711. $selectConf = $this->getSelectConf($where, $noPeriod);
  712. // performing query to count all news (we need to know it for browsing):
  713. $selectConf['selectFields'] = 'COUNT(DISTINCT(tt_news.uid))';
  714. $newsCount = 0;
  715. if (($res = $this->exec_getQuery('tt_news', $selectConf))) {
  716. list($newsCount) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
  717. $GLOBALS['TYPO3_DB']->sql_free_result($res);
  718. }
  719. // Only do something if the query result is not empty
  720. if ($newsCount > 0) {
  721. // Init Templateparts: $t['total'] is complete template subpart (TEMPLATE_LATEST f.e.)
  722. // $t['item'] is an array with the alternative subparts (NEWS, NEWS_1, NEWS_2 ...)
  723. $t = array();
  724. $t['total'] = $this->getNewsSubpart($this->templateCode, $this->spMarker('###' . $templateName . '###'));
  725. $t['item'] = $this->getLayouts($t['total'], $this->alternatingLayouts, 'NEWS');
  726. // build query for display:
  727. $selectConf['selectFields'] = 'DISTINCT(tt_news.uid),tt_news.*';
  728. if ($this->config['groupBy']) {
  729. $selectConf['groupBy'] = $this->config['groupBy'];
  730. }
  731. // else {
  732. // $selectConf['groupBy'] = 'tt_news.uid';
  733. // }
  734. if ($this->config['orderBy']) {
  735. if (strtoupper($this->config['orderBy']) == 'RANDOM') {
  736. $selectConf['orderBy'] = 'RAND()';
  737. } else {
  738. $selectConf['orderBy'] = $this->config['orderBy'] . ($this->config['ascDesc']?' ' . $this->config['ascDesc']:'');
  739. }
  740. } else {
  741. $selectConf['orderBy'] = 'datetime DESC';
  742. }
  743. // overwrite the groupBy value for categories
  744. if (!$this->catExclusive && $selectConf['groupBy'] == 'category') {
  745. $selectConf['leftjoin'] = 'tt_news_cat_mm ON tt_news.uid = tt_news_cat_mm.uid_local';
  746. $selectConf['groupBy'] = 'tt_news_cat_mm.uid_foreign';
  747. // $selectConf['selectFields'] = 'DISTINCT(tt_news.uid),tt_news.*';
  748. }
  749. // exclude the LATEST template from changing its content with the pagebrowser. This can be overridden by setting the conf var latestWithPagebrowser
  750. if ($theCode != 'LATEST' || $this->conf['latestWithPagebrowser']) {
  751. $selectConf['begin'] = $this->piVars[$pointerName] * $this->config['limit'];
  752. }
  753. if (!$this->conf['excludeAlreadyDisplayedNews']) {
  754. // exclude news-records shown in LATEST from the LIST template
  755. if ($theCode == 'LIST' && $this->conf['excludeLatestFromList'] && !$this->piVars[$pointerName] && !$this->piVars['cat']) {
  756. if ($this->config['latestLimit']) {
  757. $selectConf['begin'] += $this->config['latestLimit'];
  758. $newsCount -= $this->config['latestLimit'];
  759. } else {
  760. $selectConf['begin'] += $newsCount;
  761. // this will clean the display of LIST view when 'latestLimit' is unset because all the news have been shown in LATEST already
  762. }
  763. }
  764. // List start ID
  765. if (($theCode == 'LIST' || $theCode == 'LATEST') && $this->config['listStartId'] && !$this->piVars[$pointerName] && !$this->piVars['cat']) {
  766. $selectConf['begin'] = $this->config['listStartId'];
  767. }
  768. }
  769. // Reset:
  770. $subpartArray = array();
  771. $wrappedSubpartArray = array();
  772. $markerArray = array();
  773. // get the list of news items and fill them in the CONTENT subpart
  774. $subpartArray['###CONTENT###'] = $this->getListContent($t['item'], $selectConf, $prefix_display);
  775. $markerArray['###NEWS_CATEGORY_ROOTLINE###'] = '';
  776. if($this->conf['catRootline.']['showCatRootline'] && $this->piVars['cat'] && !strpos($this->piVars['cat'],',')) {
  777. $markerArray['###NEWS_CATEGORY_ROOTLINE###'] = $this->getCategoryPath(array(array('catid' => intval($this->piVars['cat']))));
  778. }
  779. if ($theCode == 'XML') {
  780. $markerArray = $this->getXmlHeader();
  781. $subpartArray['###HEADER###'] = $this->cObj->substituteMarkerArray($this->getNewsSubpart($t['total'], '###HEADER###'), $markerArray);
  782. if($this->conf['displayXML.']['xmlFormat']) {
  783. if(!empty($this->rdfToc)) {
  784. $markerArray['###NEWS_RDF_TOC###'] = '<rdf:Seq>'."\n".$this->rdfToc."\t\t\t".'</rdf:Seq>';
  785. } else {
  786. $markerArray['###NEWS_RDF_TOC###'] = '';
  787. }
  788. }
  789. $subpartArray['###HEADER###'] = $this->cObj->substituteMarkerArray($this->getNewsSubpart($t['total'], '###HEADER###'), $markerArray);
  790. }
  791. $markerArray['###GOTOARCHIVE###'] = $this->pi_getLL('goToArchive');
  792. $markerArray['###LATEST_HEADER###'] = $this->pi_getLL('latestHeader');
  793. $wrappedSubpartArray['###LINK_ARCHIVE###'] = $this->local_cObj->typolinkWrap($this->conf['archiveTypoLink.']);
  794. // unset pagebrowser markers
  795. $markerArray['###LINK_PREV###'] = '';
  796. $markerArray['###LINK_NEXT###'] = '';
  797. $markerArray['###BROWSE_LINKS###'] = '';
  798. // render a pagebrowser if needed
  799. if ($newsCount > $this->config['limit'] && !$this->config['noPageBrowser']) {
  800. // configure pagebrowser vars
  801. $this->internal['res_count'] = $newsCount;
  802. $this->internal['results_at_a_time'] = $this->config['limit'];
  803. $this->internal['maxPages'] = $this->conf['pageBrowser.']['maxPages'];
  804. if (!$this->conf['pageBrowser.']['showPBrowserText']) {
  805. $this->LOCAL_LANG[$this->LLkey]['pi_list_browseresults_page'] = '';
  806. }
  807. if ($this->conf['userPageBrowserFunc']) {
  808. $markerArray = $this->userProcess('userPageBrowserFunc', $markerArray);
  809. } else {
  810. if ($this->conf['usePiBasePagebrowser']) {
  811. $this->internal['pagefloat'] = $this->conf['pageBrowser.']['pagefloat'];
  812. $this->internal['showFirstLast'] = $this->conf['pageBrowser.']['showFirstLast'];
  813. $this->internal['showRange'] = $this->conf['pageBrowser.']['showRange'];
  814. $this->internal['dontLinkActivePage'] = $this->conf['pageBrowser.']['dontLinkActivePage'];
  815. $wrapArrFields = explode(',', 'disabledLinkWrap,inactiveLinkWrap,activeLinkWrap,browseLinksWrap,showResultsWrap,showResultsNumbersWrap,browseBoxWrap');
  816. $wrapArr = array();
  817. foreach($wrapArrFields as $key) {
  818. if ($this->conf['pageBrowser.'][$key]) {
  819. $wrapArr[$key] = $this->conf['pageBrowser.'][$key];
  820. }
  821. }
  822. if ($wrapArr['showResultsNumbersWrap'] && strpos($this->LOCAL_LANG[$this->LLkey]['pi_list_browseresults_displays'],'%s')) {
  823. // if the advanced pagebrowser is enabled and the "pi_list_browseresults_displays" label contains %s it will be replaced with the content of the label "pi_list_browseresults_displays_advanced"
  824. $this->LOCAL_LANG[$this->LLkey]['pi_list_browseresults_displays'] = $this->LOCAL_LANG[$this->LLkey]['pi_list_browseresults_displays_advanced'];
  825. }
  826. $this->pi_alwaysPrev = $this->conf['pageBrowser.']['alwaysPrev'];
  827. if ($this->conf['useHRDates']) {
  828. // prevent adding pS & pL to pagebrowser links if useHRDates is enabled
  829. $tmpPS = $this->piVars['pS'];
  830. unset($this->piVars['pS']);
  831. $tmpPL = $this->piVars['pL'];
  832. unset($this->piVars['pL']);
  833. }
  834. // if there is a GETvar in the URL that is not in this list, caching will be disabled for the pagebrowser links
  835. $this->pi_isOnlyFields = $pointerName.',tt_news,year,month,day,pS,pL,arc,cat';
  836. // pi_lowerThan limits the amount of cached pageversions for the list view. Caching will be disabled if one of the vars in $this->pi_isOnlyFields has a value greater than $this->pi_lowerThan
  837. // $this->pi_lowerThan = ceil($this->internal['res_count']/$this->internal['results_at_a_time']);
  838. $pi_isOnlyFieldsArr = explode(',',$this->pi_isOnlyFields);
  839. $highestVal = 0;
  840. foreach ($pi_isOnlyFieldsArr as $k => $v) {
  841. if ($this->piVars[$v] > $highestVal) {
  842. $highestVal = $this->piVars[$v];
  843. }
  844. }
  845. $this->pi_lowerThan = $highestVal+1;
  846. // render pagebrowser
  847. $markerArray['###BROWSE_LINKS###'] = $this->pi_list_browseresults($this->conf['pageBrowser.']['showResultCount'], $this->conf['pageBrowser.']['tableParams'],$wrapArr, $pointerName, $this->conf['pageBrowser.']['hscText']);
  848. if ($this->conf['useHRDates']) {
  849. // restore pS & pL
  850. if ($tmpPS) $this->piVars['pS'] = $tmpPS;
  851. if ($tmpPL) $this->piVars['pL'] = $tmpPL;
  852. }
  853. } else {
  854. $markerArray['###BROWSE_LINKS###'] = $this->makePageBrowser($this->conf['pageBrowser.']['showResultCount'], $this->conf['pageBrowser.']['tableParams'],$pointerName);
  855. }
  856. }
  857. }
  858. // Adds hook for processing of extra global markers
  859. if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['extraGlobalMarkerHook'])) {
  860. foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['extraGlobalMarkerHook'] as $_classRef) {
  861. $_procObj = & t3lib_div::getUserObj($_classRef);
  862. $markerArray = $_procObj->extraGlobalMarkerProcessor($this, $markerArray);
  863. }
  864. }
  865. $content .= $this->cObj->substituteMarkerArrayCached($t['total'], $markerArray, $subpartArray, $wrappedSubpartArray);
  866. } elseif (strpos($where,'1=0')) {
  867. // first view of the search page with the parameter 'emptySearchAtStart' set
  868. $markerArray['###SEARCH_EMPTY_MSG###'] = $this->local_cObj->stdWrap($this->pi_getLL('searchEmptyMsg'), $this->conf['searchEmptyMsg_stdWrap.']);
  869. $searchEmptyMsg = $this->getNewsSubpart($this->templateCode, $this->spMarker('###TEMPLATE_SEARCH_EMPTY###'));
  870. $content .= $this->cObj->substituteMarkerArrayCached($searchEmptyMsg, $markerArray);
  871. } elseif ($this->piVars['swords']) {
  872. // no results
  873. $markerArray['###SEARCH_EMPTY_MSG###'] = $this->local_cObj->stdWrap($this->pi_getLL('noResultsMsg'), $this->conf['searchEmptyMsg_stdWrap.']);
  874. $searchEmptyMsg = $this->getNewsSubpart($this->templateCode, $this->spMarker('###TEMPLATE_SEARCH_EMPTY###'));
  875. $content .= $this->cObj->substituteMarkerArrayCached($searchEmptyMsg, $markerArray);
  876. } elseif ($theCode == 'XML') {
  877. // fill at least the template header
  878. // Init Templateparts: $t['total'] is complete template subpart (TEMPLATE_LATEST f.e.)
  879. $t = array();
  880. $t['total'] = $this->getNewsSubpart($this->templateCode, $this->spMarker('###' . $templateName . '###'));
  881. // Reset:
  882. $subpartArray = array();
  883. $wrappedSubpartArray = array();
  884. $markerArray = array();
  885. // header data
  886. $markerArray = $this->getXmlHeader();
  887. $subpartArray['###HEADER###'] = $this->cObj->substituteMarkerArray($this->getNewsSubpart($t['total'], '###HEADER###'), $markerArray);
  888. // substitute the xml declaration (it's not included in the subpart ###HEADER###)
  889. $t['total'] = $this->cObj->substituteMarkerArray($t['total'], array('###XML_DECLARATION###' => $markerArray['###XML_DECLARATION###']));
  890. $t['total'] = $this->cObj->substituteMarkerArray($t['total'], array('###SITE_LANG###' => $markerArray['###SITE_LANG###']));
  891. $t['total'] = $this->cObj->substituteSubpart($t['total'], '###HEADER###', $subpartArray['###HEADER###'], 0);
  892. $t['total'] = $this->cObj->substituteSubpart($t['total'], '###CONTENT###', '', 0);
  893. $content .= $t['total'];
  894. } elseif ($this->arcExclusive && $this->piVars['pS'] && $GLOBALS['TSFE']->sys_language_content) {
  895. // this matches if a user has switched languages within a archive period that contains no items in the desired language
  896. $content .= $this->local_cObj->stdWrap($this->pi_getLL('noNewsForArchPeriod', 'Sorry, there are no translated news-articles in this Archive period'), $this->conf['noNewsToListMsg_stdWrap.']);
  897. } else {
  898. $content .= $this->local_cObj->stdWrap($this->pi_getLL('noNewsToListMsg'), $this->conf['noNewsToListMsg_stdWrap.']);
  899. }
  900. }
  901. return $content;
  902. }
  903. /**
  904. * get the content for a news item NOT displayed as single item (List & Latest)
  905. *
  906. * @param array $itemparts : parts of the html template
  907. * @param array $selectConf : quety parameters in an array
  908. * @param string $prefix_display : the part of the TS-setup
  909. * @return string $itemsOut: itemlist as htmlcode
  910. */
  911. function getListContent($itemparts, $selectConf, $prefix_display) {
  912. $res = $this->exec_getQuery('tt_news', $selectConf); //get query for list contents
  913. $itemsOut = '';
  914. $itempartsCount = count($itemparts);
  915. $pTmp = $GLOBALS['TSFE']->ATagParams;
  916. $cc = 0;
  917. $token = md5(microtime());
  918. // Getting elements
  919. while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
  920. $GLOBALS['TSFE']->displayedNews[]=$row['uid'];
  921. $wrappedSubpartArray = array();
  922. $lConf = $this->conf[$prefix_display.'.'];
  923. $titleField = $lConf['linkTitleField']?$lConf['linkTitleField']:'';
  924. if ($GLOBALS['TSFE']->sys_language_content) {
  925. // prevent link targets from being changed in localized records
  926. $tmpPage = $row['page'];
  927. $tmpExtURL = $row['ext_url'];
  928. $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay('tt_news', $row, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL, '');
  929. $row['page'] = $tmpPage;
  930. $row['ext_url'] = $tmpExtURL;
  931. }
  932. if ($this->versioningEnabled) {
  933. // get workspaces Overlay
  934. $GLOBALS['TSFE']->sys_page->versionOL('tt_news',$row);
  935. }
  936. $GLOBALS['TSFE']->ATagParams = $pTmp.' title="'.$this->local_cObj->stdWrap(trim(htmlspecialchars($row[$titleField])), $lConf['linkTitleField.']).'"';
  937. if ($this->conf[$prefix_display.'.']['catOrderBy']) {
  938. $this->config['catOrderBy'] = $this->conf[$prefix_display.'.']['catOrderBy'];
  939. }
  940. $this->categories[$row['uid']] = $this->getCategories($row['uid']);
  941. if ($row['type'] == 1 || $row['type'] == 2) {
  942. // News type article or external url
  943. $this->local_cObj->setCurrentVal($row['type'] == 1 ? $row['page']:$row['ext_url']);
  944. $wrappedSubpartArray['###LINK_ITEM###'] = $this->local_cObj->typolinkWrap($this->conf['pageTypoLink.']);
  945. // fill the link string in a register to access it from TS
  946. $this->local_cObj->LOAD_REGISTER(array('newsMoreLink' => $this->local_cObj->typolink($this->pi_getLL('more'), $this->conf['pageTypoLink.'])), '');
  947. } else {
  948. // Overwrite the singlePid from config-array with a singlePid given from the first entry in $this->categories
  949. if ($this->conf['useSPidFromCategory'] && is_array($this->categories)) {
  950. $tmpcats = $this->categories;
  951. $catSPid = array_shift($tmpcats[$row['uid']]);
  952. }
  953. $singlePid = $catSPid['single_pid']?$catSPid['single_pid']:$this->config['singlePid'];
  954. if ($this->conf['useHRDates'] && !$this->conf['useHRDatesSingle']) {
  955. $piVarsArray = array(
  956. 'tt_news' => $row['uid'],
  957. 'backPid' => ($this->conf['dontUseBackPid']?null:$this->config['backPid']),
  958. 'year' => ($this->conf['dontUseBackPid']?null:($this->piVars['year']?$this->piVars['year']:null)),
  959. 'month' => ($this->conf['dontUseBackPid']?null:($this->piVars['month']?$this->piVars['month']:null)),
  960. 'pS' => null,
  961. 'pL' => null,
  962. 'arc' => null,
  963. );
  964. $wrappedSubpartArray['###LINK_ITEM###'] = explode($token, $this->pi_linkTP_keepPIvars($token, $piVarsArray, $this->allowCaching, ($this->conf['dontUseBackPid']?1:0), $singlePid));
  965. $this->local_cObj->LOAD_REGISTE

Large files files are truncated, but you can click here to view the full file