Exemplo n.º 1
0
 /**
  * Adds an edit icon to the content string. The edit icon links to EditDocumentController with proper parameters for editing the table/fields of the context.
  * This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well).
  *
  * @param string $content The content to which the edit icons should be appended
  * @param string $params The parameters defining which table and fields to edit. Syntax is [tablename]:[fieldname],[fieldname],[fieldname],... OR [fieldname],[fieldname],[fieldname],... (basically "[tablename]:" is optional, default table is the one of the "current record" used in the function). The fieldlist is sent as "&columnsOnly=" parameter to EditDocumentController
  * @param array $conf TypoScript properties for configuring the edit icons.
  * @param string $currentRecord The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW
  * @param array $dataArr Alternative data array to use. Default is $this->data
  * @param string $addUrlParamStr Additional URL parameters for the link pointing to EditDocumentController
  * @param string $table
  * @param int $editUid
  * @param string $fieldList
  * @return string The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content.
  */
 public function editIcons($content, $params, array $conf = array(), $currentRecord = '', array $dataArr = array(), $addUrlParamStr = '', $table, $editUid, $fieldList)
 {
     // Special content is about to be shown, so the cache must be disabled.
     $this->frontendController->set_no_cache('Display frontend edit icons', TRUE);
     $iconTitle = $this->cObj->stdWrap($conf['iconTitle'], $conf['iconTitle.']);
     $optionsArray = array('title' => htmlspecialchars($iconTitle, ENT_COMPAT, 'UTF-8', FALSE), 'class' => 'frontEndEditIcons', 'style' => $conf['styleAttribute'] ? htmlspecialchars($conf['styleAttribute']) : '');
     $iconImg = $conf['iconImg'] ? $conf['iconImg'] : IconUtility::getSpriteIcon('actions-document-open', $optionsArray);
     $nV = GeneralUtility::_GP('ADMCMD_view') ? 1 : 0;
     $url = BackendUtility::getModuleUrl('record_edit', array('edit[' . $table . '][' . $editUid . ']' => 'edit', 'columnsOnly' => $fieldList, 'noView' => $nV)) . $addUrlParamStr;
     $icon = $this->editPanelLinkWrap_doWrap($iconImg, $url);
     if ($conf['beforeLastTag'] < 0) {
         $content = $icon . $content;
     } elseif ($conf['beforeLastTag'] > 0) {
         $cBuf = rtrim($content);
         $secureCount = 30;
         while ($secureCount && substr($cBuf, -1) == '>' && substr($cBuf, -4) != '</a>') {
             $cBuf = rtrim(preg_replace('/<[^<]*>$/', '', $cBuf));
             $secureCount--;
         }
         $content = strlen($cBuf) && $secureCount ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : ($content = $icon . $content);
     } else {
         $content .= $icon;
     }
     return $content;
 }
Exemplo n.º 2
0
 /**
  * Adds an edit icon to the content string. The edit icon links to EditDocumentController with proper parameters for editing the table/fields of the context.
  * This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well).
  *
  * @param string $content The content to which the edit icons should be appended
  * @param string $params The parameters defining which table and fields to edit. Syntax is [tablename]:[fieldname],[fieldname],[fieldname],... OR [fieldname],[fieldname],[fieldname],... (basically "[tablename]:" is optional, default table is the one of the "current record" used in the function). The fieldlist is sent as "&columnsOnly=" parameter to EditDocumentController
  * @param array $conf TypoScript properties for configuring the edit icons.
  * @param string $currentRecord The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW
  * @param array $dataArr Alternative data array to use. Default is $this->data
  * @param string $addUrlParamStr Additional URL parameters for the link pointing to EditDocumentController
  * @param string $table
  * @param int $editUid
  * @param string $fieldList
  * @return string The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content.
  */
 public function editIcons($content, $params, array $conf = [], $currentRecord = '', array $dataArr = [], $addUrlParamStr = '', $table, $editUid, $fieldList)
 {
     // Special content is about to be shown, so the cache must be disabled.
     $this->frontendController->set_no_cache('Display frontend edit icons', true);
     $iconTitle = $this->cObj->stdWrap($conf['iconTitle'], $conf['iconTitle.']);
     $iconImg = '<span title="' . htmlspecialchars($iconTitle, ENT_COMPAT, 'UTF-8', false) . '" class="frontEndEditIcons" style="' . ($conf['styleAttribute'] ? htmlspecialchars($conf['styleAttribute']) : '') . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</span>';
     $nV = GeneralUtility::_GP('ADMCMD_view') ? 1 : 0;
     $url = BackendUtility::getModuleUrl('record_edit', ['edit[' . $table . '][' . $editUid . ']' => 'edit', 'columnsOnly' => $fieldList, 'noView' => $nV, 'feEdit' => 1]) . $addUrlParamStr;
     $icon = $this->editPanelLinkWrap_doWrap($iconImg, $url, 'content-link');
     if ($conf['beforeLastTag'] < 0) {
         $content = $icon . $content;
     } elseif ($conf['beforeLastTag'] > 0) {
         $cBuf = rtrim($content);
         $secureCount = 30;
         while ($secureCount && substr($cBuf, -1) == '>' && substr($cBuf, -4) != '</a>') {
             $cBuf = rtrim(preg_replace('/<[^<]*>$/', '', $cBuf));
             $secureCount--;
         }
         $content = strlen($cBuf) && $secureCount ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : ($content = $icon . $content);
     } else {
         $content .= $icon;
     }
     return $content;
 }
Exemplo n.º 3
0
 /**
  * Init Function: here all the needed configuration values are stored in class variables..
  */
 function init()
 {
     $this->db = $GLOBALS['TYPO3_DB'];
     $this->tsfe = $GLOBALS['TSFE'];
     $this->pi_loadLL();
     // Loading language-labels
     $this->pi_setPiVarDefaults();
     // Set default piVars from TS
     $this->SIM_ACCESS_TIME = $GLOBALS['SIM_ACCESS_TIME'];
     // fallback for TYPO3 < 4.2
     if (!$this->SIM_ACCESS_TIME) {
         $simTime = $GLOBALS['SIM_EXEC_TIME'];
         $this->SIM_ACCESS_TIME = $simTime - $simTime % 60;
     }
     $this->initCaching();
     $this->local_cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
     // Local cObj.
     $this->enableFields = $this->getEnableFields('tt_news');
     if ($this->tt_news_uid === 0) {
         // no tt_news_uid set by displayCurrentRecord
         $this->tt_news_uid = intval($this->piVars['tt_news']);
         // Get the submitted uid of a news (if any)
     }
     if (!isset($this->conf['compatVersion']) || !preg_match('/^\\d+\\.\\d+\\.\\d+$/', $this->conf['compatVersion'])) {
         $this->conf['compatVersion'] = $this->hObj->getCurrentVersion();
     }
     $this->token = md5(microtime());
     if (TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('version')) {
         $this->versioningEnabled = true;
     }
     // load available syslanguages
     $this->initLanguages();
     // sys_language_mode defines what to do if the requested translation is not found
     $this->sys_language_mode = $this->conf['sys_language_mode'] ? $this->conf['sys_language_mode'] : $this->tsfe->sys_language_mode;
     if ($this->conf['searchFieldList']) {
         // get fieldnames from the tt_news db-table
         $this->fieldNames = array_keys($this->db->admin_get_fields('tt_news'));
         $searchFieldList = $this->hObj->validateFields($this->conf['searchFieldList'], $this->fieldNames);
         if ($searchFieldList) {
             $this->searchFieldList = $searchFieldList;
         }
     }
     // Archive:
     $archiveMode = trim($this->conf['archiveMode']);
     // month, quarter or year listing in AMENU
     $this->config['archiveMode'] = $archiveMode ? $archiveMode : 'month';
     // arcExclusive : -1=only non-archived; 0=don't care; 1=only archived
     $arcExclusive = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'archive', 'sDEF');
     $this->arcExclusive = $arcExclusive ? $arcExclusive : intval($this->conf['archive']);
     $this->config['datetimeDaysToArchive'] = intval($this->conf['datetimeDaysToArchive']);
     $this->config['datetimeHoursToArchive'] = intval($this->conf['datetimeHoursToArchive']);
     $this->config['datetimeMinutesToArchive'] = intval($this->conf['datetimeMinutesToArchive']);
     if ($this->conf['useHRDates']) {
         $this->hObj->convertDates();
     }
     // list of pages where news records will be taken from
     if (!$this->conf['dontUsePidList']) {
         $this->initPidList();
     }
     // itemLinkTarget is only used for categoryLinkMode 3 (catselector) in framesets
     $this->conf['itemLinkTarget'] = trim($this->conf['itemLinkTarget']);
     // id of the page where the search results should be displayed
     $this->config['searchPid'] = intval($this->conf['searchPid']);
     // pages in Single view will be divided by this token
     $this->config['pageBreakToken'] = trim($this->conf['pageBreakToken']) ? trim($this->conf['pageBreakToken']) : '<---newpage--->';
     $this->config['singleViewPointerName'] = trim($this->conf['singleViewPointerName']) ? trim($this->conf['singleViewPointerName']) : 'sViewPointer';
     $maxWordsInSingleView = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'maxWordsInSingleView', 's_misc'));
     $maxWordsInSingleView = $maxWordsInSingleView ? $maxWordsInSingleView : intval($this->conf['maxWordsInSingleView']);
     $this->config['maxWordsInSingleView'] = $maxWordsInSingleView ? $maxWordsInSingleView : 0;
     $this->config['useMultiPageSingleView'] = $this->conf['useMultiPageSingleView'];
     // pid of the page with the single view. the old var PIDitemDisplay is still processed if no other value is found
     $singlePid = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'PIDitemDisplay', 's_misc');
     $this->config['singlePid'] = $singlePid ? $singlePid : intval($this->cObj->stdWrap($this->conf['singlePid'], $this->conf['singlePid.']));
     if (!$this->config['singlePid']) {
         $this->errors[] = 'No singlePid defined';
     }
     // pid to return to when leaving single view
     $backPid = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'backPid', 's_misc'));
     $backPid = $backPid ? $backPid : intval($this->conf['backPid']);
     $backPid = $backPid ? $backPid : intval($this->piVars['backPid']);
     $backPid = $backPid ? $backPid : $this->tsfe->id;
     $this->config['backPid'] = $backPid;
     // max items per page
     $FFlimit = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'listLimit', 's_template'), 0, 1000);
     $limit = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cObj->stdWrap($this->conf['limit'], $this->conf['limit.']), 0, 1000);
     $limit = $limit ? $limit : 50;
     $this->config['limit'] = $FFlimit ? $FFlimit : $limit;
     $latestLimit = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cObj->stdWrap($this->conf['latestLimit'], $this->conf['latestLimit.']), 0, 1000);
     $latestLimit = $latestLimit ? $latestLimit : 10;
     $this->config['latestLimit'] = $FFlimit ? $FFlimit : $latestLimit;
     // orderBy and groupBy statements for the list Query
     $orderBy = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'listOrderBy', 'sDEF');
     $orderByTS = trim($this->conf['listOrderBy']);
     $orderBy = $orderBy ? $orderBy : $orderByTS;
     $this->config['orderBy'] = $orderBy;
     if ($orderBy) {
         $ascDesc = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'ascDesc', 'sDEF');
         $this->config['ascDesc'] = $ascDesc;
         if ($this->config['ascDesc']) {
             // remove ASC/DESC from 'orderBy' if it is already set from TS
             $this->config['orderBy'] = preg_replace('/( DESC| ASC)\\b/i', '', $this->config['orderBy']);
         }
     }
     $this->config['groupBy'] = trim($this->conf['listGroupBy']);
     // if this is set, the first image is handled as preview image, which is only shown in list view
     $fImgPreview = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'firstImageIsPreview', 's_misc');
     $this->config['firstImageIsPreview'] = $fImgPreview ? $fImgPreview : $this->conf['firstImageIsPreview'];
     $forcefImgPreview = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'forceFirstImageIsPreview', 's_misc');
     $this->config['forceFirstImageIsPreview'] = $forcefImgPreview ? $fImgPreview : $this->conf['forceFirstImageIsPreview'];
     // List start id
     //		$listStartId = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'listStartId', 's_misc'));
     //		$this->config['listStartId'] = /*$listStartId?$listStartId:*/intval($this->conf['listStartId']);
     // supress pagebrowser
     $noPageBrowser = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'noPageBrowser', 's_template');
     $this->config['noPageBrowser'] = $noPageBrowser ? $noPageBrowser : $this->conf['noPageBrowser'];
     // image sizes/optionSplit given from FlexForms
     $this->config['FFimgH'] = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'imageMaxHeight', 's_template'));
     $this->config['FFimgW'] = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'imageMaxWidth', 's_template'));
     // Get number of alternative Layouts (loop layout in LATEST and LIST view) default is 2:
     $altLayouts = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'alternatingLayouts', 's_template'));
     $altLayouts = $altLayouts ? $altLayouts : intval($this->conf['alternatingLayouts']);
     $this->alternatingLayouts = $altLayouts ? $altLayouts : 2;
     $altLayouts = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'altLayoutsOptionSplit', 's_template'));
     $this->config['altLayoutsOptionSplit'] = $altLayouts ? $altLayouts : trim($this->conf['altLayoutsOptionSplit']);
     // Get cropping length
     $croppingLenghtOptionSplit = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'croppingLenghtOptionSplit', 's_template'));
     $this->config['croppingLenghtOptionSplit'] = $croppingLenghtOptionSplit ? $croppingLenghtOptionSplit : trim($this->conf['croppingLenghtOptionSplit']);
     $this->config['croppingLenght'] = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'croppingLenght', 's_template'));
     $this->initTemplate();
     // Configure caching
     $this->allowCaching = $this->conf['allowCaching'] ? 1 : 0;
     if (!$this->allowCaching) {
         $this->tsfe->set_no_cache();
     }
     // get siteUrl for links in rss feeds. the 'dontInsert' option seems to be needed in some configurations depending on the baseUrl setting
     if (!$this->conf['displayXML.']['dontInsertSiteUrl']) {
         $this->config['siteUrl'] = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
     }
     if ($this->debugTimes) {
         $this->hObj->getParsetime(__METHOD__);
     }
 }