/**
  * divides the bodytext field of a news single view to pages and returns the part of the bodytext
  * that is choosen by piVars[$pointerName]
  *
  * @param	string		the text with 'pageBreakTokens' in it
  * @param	array		config array for the single view
  * @return	string		the current bodytext part wrapped with stdWrap
  */
 function makeMultiPageSView($bodytext, $lConf)
 {
     $pointerName = $this->pObj->config['singleViewPointerName'];
     $pagenum = $this->pObj->piVars[$pointerName] ? $this->pObj->piVars[$pointerName] : 0;
     $textArr = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode($this->pObj->config['pageBreakToken'], $bodytext, 1);
     $pagecount = count($textArr);
     $pagebrowser = '';
     // render a pagebrowser for the single view
     if ($pagecount > 1) {
         // configure pagebrowser vars
         $this->pObj->internal['res_count'] = $pagecount;
         $this->pObj->internal['results_at_a_time'] = 1;
         $this->pObj->internal['maxPages'] = $this->pObj->conf['pageBrowser.']['maxPages'];
         if (!$this->pObj->conf['pageBrowser.']['showPBrowserText']) {
             $this->pObj->LOCAL_LANG[$this->pObj->LLkey]['pi_list_browseresults_page'] = '';
         }
         $pbConf = $this->pObj->conf['singleViewPageBrowser.'];
         $markerArray = array();
         $markerArray = $this->pObj->getPagebrowserContent($markerArray, $pbConf, $pointerName);
         $pagebrowser = $markerArray['###BROWSE_LINKS###'];
     }
     return array($this->pObj->formatStr($this->pObj->local_cObj->stdWrap($textArr[$pagenum], $lConf['content_stdWrap.'])), $pagebrowser);
 }
Esempio n. 2
0
// finding the script path from the variable
$ajaxID = (string) GeneralUtility::_GP('ajaxID');
require_once ExtensionManagementUtility::extPath('tt_news') . 'pi/class.tx_ttnews.php';
require_once ExtensionManagementUtility::extPath('tt_news') . 'lib/class.tx_ttnews_helpers.php';
require_once ExtensionManagementUtility::extPath('tt_news') . 'lib/class.tx_ttnews_typo3ajax.php';
/**
 * TODO: 24.11.2009
 *
 *
 * use \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance
 */
// instantiating the AJAX object
//$ajaxClassName = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceClassName('tx_ttnews_typo3ajax');
$ajaxObj = new tx_ttnews_typo3ajax($ajaxID);
$ajaxParams = array();
$tt_newsObj = new tx_ttnews();
$tt_newsObj->hObj = new tx_ttnews_helpers($tt_newsObj);
$tt_newsObj->cObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
$tt_newsObj->local_cObj =& $tt_newsObj->cObj;
$cObjUid = intval(GeneralUtility::_GP('cObjUid'));
$tt_newsObj->cObj->data = $GLOBALS['TSFE']->sys_page->checkRecord('tt_content', $cObjUid, 1);
$tt_newsObj->pi_initPIflexForm();
$tt_newsObj->conf =& $GLOBALS['TSFE']->tmpl->setup['plugin.']['tt_news.'];
// variables needed to get the newscount per category
if (!$tt_newsObj->conf['dontUsePidList']) {
    $tt_newsObj->initPidList();
}
/**
 * For some reasons this is needed for TYPO3 6.1
 *
 * FIXME: there must be a proper way to do this
Esempio n. 3
0
 function buildCalendarArray()
 {
     // Define the list of pages to search (999 depth level).
     $this->search_list = $this->pi_getPidList($this->menuPid, $this->recursion);
     // Display only records that are active.
     $this->splitQuery = 'AND tx_newscalendar_state = 1';
     // If showAllRecors is active, display all records.
     if ($this->conf['show.']['allRecords']) {
         $this->splitQuery = '';
     }
     // gregory goidin - rvvn
     // Calculate the first and last date of the month.
     $currentTime = $this->time;
     $firstDate = $calendarStartMonth = strtotime($this->calendarYear . '-' . $this->calendarMonth . '-01');
     $lastDate = $calendarEndMonth = mktime(23, 59, 59, intval($this->calendarMonth), date('t', $calendarStartMonth), intval($this->calendarYear));
     switch ($this->displayType) {
         case 1:
             // CALENDAR
             if ($this->conf['calendar.']['hideIfInPast'] == 1 && $currentTime >= $calendarStartMonth && $currentTime <= $calendarEndMonth) {
                 $firstDate = $currentTime;
             } else {
                 if ($this->conf['calendar.']['hideIfInPast'] == 1 && $currentTime > $calendarEndMonth) {
                     $firstDate = 1;
                     $lastDate = 1;
                 }
             }
             break;
         case 2:
             // LISTVIEW
             if ($this->conf['listView.']['hideIfInPast'] == 1 && $currentTime >= $calendarStartMonth && $currentTime <= $calendarEndMonth) {
                 $firstDate = $currentTime;
             } else {
                 if ($this->conf['listView.']['hideIfInPast'] == 1 && $currentTime > $calendarEndMonth) {
                     $firstDate = 1;
                     $lastDate = 1;
                 }
             }
             break;
         case 3:
             // LISTINTERVAL
             if ($this->conf['listInterval.']['hideIfInPast'] == 1 && $currentTime >= $calendarStartMonth && $currentTime <= $calendarEndMonth) {
                 $firstDate = $currentTime;
             } else {
                 if ($this->conf['listInterval.']['hideIfInPast'] == 1 && $currentTime > $calendarEndMonth) {
                     $firstDate = 1;
                     $lastDate = 1;
                 }
             }
             break;
         case 4:
             // NEXTEVENTS
             if ($this->conf['nextEvents.']['relativeToCalendar'] == 1 && $currentTime <= $calendarStartMonth) {
                 $firstDate = $calendarStartMonth;
             } else {
                 $firstDate = $currentTime;
             }
             break;
     }
     // Language query setup
     if ($this->sys_language_mode == 'strict' && $GLOBALS['TSFE']->sys_language_content) {
         // Just news in the same language
         $langClause = 'tt_news.sys_language_uid = ' . $GLOBALS['TSFE']->sys_language_content;
     } else {
         // sys_language_mode != 'strict': If a certain language is requested, select only news-records in the default language. The translated articles (if they exist) will be overlayed later in the list or single function.
         $langClause = 'tt_news.sys_language_uid IN (0,-1)';
     }
     // gregory goidin - rvvn
     // New way of creating the sql query ( new display ).
     if ($this->displayType == 4) {
         $queryYearMonth = 'AND ( (tx_newssdf_calendardate=0 AND datetime >= ' . $firstDate . ' ) ' . 'OR ( tx_newssdf_calendardate_end=0 AND tx_newssdf_calendardate >= ' . $firstDate . ' ) ' . 'OR ( tx_newssdf_calendardate_end >= ' . $firstDate . ' ) )';
     } else {
         $queryYearMonth = 'AND ( (tx_newssdf_calendardate=0 AND datetime >= ' . $firstDate . ' AND datetime <= ' . $lastDate . ' ) ' . 'OR ( tx_newssdf_calendardate_end=0 AND tx_newssdf_calendardate >= ' . $firstDate . ' AND tx_newssdf_calendardate <= ' . $lastDate . ' ) ' . 'OR ( tx_newssdf_calendardate <= ' . $lastDate . ' AND tx_newssdf_calendardate_end >= ' . $firstDate . ' ) )';
     }
     $this->where = $langClause . ' ' . $queryYearMonth . ' ' . $this->splitQuery . ' ' . $this->cObj->enableFields('tt_news');
     // gregory goidin - rvvn
     // add the limit parameter to configure the browsebox if needed in the sql query
     if ($this->displayType == 2 && intval($this->conf['pageBrowser.']['show']) == 1 && intval($this->conf['pageBrowser.']['limit']) >= 1 && intval($this->conf['pageBrowser.']['maxPages']) >= 1) {
         $limit = "";
         $currentPage = 0;
         if (intval($this->piVars[$this->conf['pageBrowser.']['pointer']]) > 0) {
             $currentPage = intval($this->piVars[$this->conf['pageBrowser.']['pointer']]);
         }
         $limit = intval($this->conf['pageBrowser.']['limit']) * $currentPage . "," . intval($this->conf['pageBrowser.']['limit']);
     } else {
         if ($this->displayType == 4 && intval($this->conf['pageBrowser.']['show']) == 1 && intval($this->conf['pageBrowser.']['limit']) >= 1 && intval($this->conf['pageBrowser.']['maxPages']) >= 1) {
             $limit = "";
             $currentPage = 0;
             if (intval($this->piVars[$this->conf['pageBrowser.']['pointer']]) > 0) {
                 $currentPage = intval($this->piVars[$this->conf['pageBrowser.']['pointer']]);
             }
             $limitMax = intval($this->conf['pageBrowser.']['limit']);
             if (intval($this->conf['pageBrowser.']['limit']) * ($currentPage + 1) > intval($this->conf['nextEvents.']['maxItems'])) {
                 $limitMax = intval($this->conf['nextEvents.']['maxItems']) - intval($this->conf['pageBrowser.']['limit']) * $currentPage;
             }
             $limit = intval($this->conf['pageBrowser.']['limit']) * $currentPage . "," . $limitMax;
         } else {
             if ($this->displayType == 4 && intval($this->conf['pageBrowser.']['show']) == 0) {
                 $limit = "0," . intval($this->conf['nextEvents.']['maxItems']);
             }
         }
     }
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tt_news.uid,
             tt_news.pid,
             tt_news.sys_language_uid,
             tt_news.title,
             tt_news.datetime,
             tt_news.tx_newssdf_calendardate_end,
             tt_news.tx_newssdf_calendardate,
             tt_news.short,
             tt_news.image,
             tt_news.imagecaption,
             tt_news.imagealttext,
             tt_news.imagetitletext,
             tt_news.bodytext,
             tt_news.page,
             tt_news.type,
             tt_news.ext_url', 'tt_news', $this->where . ' AND tt_news.pid in (' . $this->search_list . ')', '', 'tx_newssdf_calendardate, tt_news.datetime ASC', $limit);
     $this->globalRes = $res;
     //****************************************************************//
     //gregory goidin - rvvn : start : We need the total count to initialize the pageBrowser
     /**
      * If the type of view is able to have  a page browser we need to count the events again
      * so we have the total record count for the paginator.
      * We bypass the Calendar View by default.
      */
     if ($this->displayType != 1) {
         $resCount = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'tt_news', $this->where . ' AND tt_news.pid in (' . $this->search_list . ')', '', 'tx_newssdf_calendardate, tt_news.datetime ASC', "");
         $rowCount = $GLOBALS['TYPO3_DB']->sql_fetch_row($resCount);
         if ($this->displayType == 4 && $rowCount[0] > intval($this->conf['nextEvents.']['maxItems'])) {
             $rowCount[0] = intval($this->conf['nextEvents.']['maxItems']);
         }
         $this->globalResCount = $rowCount[0];
     } else {
         // For calendar view we do not use limits or paginator browser
         $this->globalResCount = $GLOBALS['TYPO3_DB']->sql_num_rows($this->globalRes);
     }
     //gregory goidin - rvvn : stop !
     //****************************************************************//
     // Prevent interval item rendering on normal and next events list views.
     // Only this will be prepared to render selected categories.
     if ($this->displayType == 1 || $this->displayType == 3) {
         // Fill array with result set.
         // CHANGED BY RICC FROM '1' to '0'
         $arrayCounter = 0;
         if ($this->categorySelection && $this->useSubCategories) {
             $this->categorySelection .= ',' . tx_ttnews_div::getSubCategories($this->categorySelection);
         }
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             /**
              * START: News category in list if applicable
              */
             if ($this->categorySelection) {
                 $exists = false;
                 $categoryArray = explode(",", $this->categorySelection);
                 foreach ($categoryArray as $selectedCatId) {
                     $exists = array_key_exists($selectedCatId, tx_ttnews::getCategories($row['uid']));
                     if ($exists) {
                         break;
                     }
                 }
                 if (!$exists) {
                     continue;
                 }
             }
             /**
              * STOP: News category in list if applicable
              */
             // News item default types
             $resultList[$arrayCounter]['type'] = $row['type'];
             $resultList[$arrayCounter]['page'] = $row['page'];
             $resultList[$arrayCounter]['ext_url'] = $row['ext_url'];
             $resultList[$arrayCounter]['image'] = $row['image'];
             $resultList[$arrayCounter]['short'] = $row['short'];
             $auxiliar_data = $resultList;
             // get the translated record if the content language is not the default language
             if ($GLOBALS['TSFE']->sys_language_content) {
                 // $OLmode = ($this->sys_language_mode == 'strict'?'hideNonTranslated':'');
                 $OLmode = $GLOBALS['TSFE']->tmpl->setup['config.']['sys_language_overlay'];
                 $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay('tt_news', $row, $GLOBALS['TSFE']->sys_language_content, $OLmode);
             }
             // Choose startdate, preference for tx_newscalendardate over datetime.
             $finalStartDate = $row['tx_newssdf_calendardate'] ? $row['tx_newssdf_calendardate'] : $row['datetime'];
             if ($this->calendarYear == date('Y', $finalStartDate) && $this->calendarMonth == date('n', $finalStartDate)) {
                 $resultList[$arrayCounter]['uid'] = $row['uid'];
                 $resultList[$arrayCounter]['title'] = $row['title'];
                 $resultList[$arrayCounter]['monthday'] = date('j', $finalStartDate);
                 $resultList[$arrayCounter]['enddate'] = $row['tx_newssdf_calendardate_end'];
                 $resultList[$arrayCounter]['datetime'] = $finalStartDate;
                 $arrayCounter++;
             }
             if ($row['tx_newssdf_calendardate_end'] > 0) {
                 $startDate = date('Y-m-d', $finalStartDate);
                 $endDate = date('Y-m-d', $row['tx_newssdf_calendardate_end']);
                 $daysBetween = $this->GetDays($startDate, $endDate, $row['uid']);
                 while ($date = each($daysBetween)) {
                     if ($startDate != $date[1]) {
                         $timeDate = strtotime($date[1] . date(' H:i', $finalStartDate));
                         if ($this->calendarYear == date('Y', $timeDate) && $this->calendarMonth == date('n', $timeDate)) {
                             $resultList[$arrayCounter]['uid'] = $row['uid'];
                             $resultList[$arrayCounter]['title'] = $row['title'];
                             $resultList[$arrayCounter]['monthday'] = date('j', $timeDate);
                             $resultList[$arrayCounter]['enddate'] = 0;
                             $resultList[$arrayCounter]['datetime'] = $timeDate;
                             $resultList[$arrayCounter]['type'] = $row['type'];
                             $resultList[$arrayCounter]['page'] = $row['page'];
                             $resultList[$arrayCounter]['ext_url'] = $row['ext_url'];
                             $resultList[$arrayCounter]['image'] = $row['image'];
                             $resultList[$arrayCounter]['short'] = $row['short'];
                             /**
                              * Remove items when in a interval and "hideIfInPast" is on
                              * $this->conf['calendar.']['hideIfInPast']
                              * Thanks to Marvin Stobberingh for reporting.
                              */
                             if ($this->conf['calendar.']['hideIfInPast']) {
                                 if ($resultList[$arrayCounter]['datetime'] < time()) {
                                     unset($resultList[$arrayCounter - 1]);
                                 } else {
                                     $arrayCounter++;
                                 }
                             } else {
                                 $arrayCounter++;
                             }
                         }
                     }
                 }
             }
         }
         # sort alphabetically by name
         if (is_array($resultList)) {
             usort($resultList, array($this, 'compare_datetime'));
         }
         $this->resultListCount = count($resultList);
         $this->resultList = $resultList;
     }
     return;
 }