Exemplo n.º 1
0
 /**
  * Initializing global variables
  *
  * @return	void
  */
 function init()
 {
     $this->MCONF = $GLOBALS['MCONF'];
     parent::init();
     // initialize IconFactory
     $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     $temp = BackendUtility::getModTSconfig($this->id, 'mod.web_modules.dmail');
     if (!is_array($temp['properties'])) {
         $temp['properties'] = array();
     }
     $this->params = $temp['properties'];
     $this->implodedParams = DirectMailUtility::implodeTSParams($this->params);
     if ($this->params['userTable'] && is_array($GLOBALS["TCA"][$this->params['userTable']])) {
         $this->userTable = $this->params['userTable'];
         $this->allowedTables[] = $this->userTable;
     }
     $this->MOD_MENU['dmail_mode'] = BackendUtility::unsetMenuItems($this->params, $this->MOD_MENU['dmail_mode'], 'menu.dmail_mode');
     // initialize backend user language
     if ($this->getLanguageService()->lang && ExtensionManagementUtility::isLoaded('static_info_tables')) {
         $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('sys_language.uid', 'sys_language LEFT JOIN static_languages ON sys_language.static_lang_isocode=static_languages.uid', 'static_languages.lg_typo3=' . $GLOBALS["TYPO3_DB"]->fullQuoteStr($this->getLanguageService()->lang, 'static_languages') . BackendUtility::BEenableFields('sys_language') . BackendUtility::deleteClause('sys_language') . BackendUtility::deleteClause('static_languages'));
         while ($row = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res)) {
             $this->sys_language_uid = $row['uid'];
         }
         $GLOBALS["TYPO3_DB"]->sql_free_result($res);
     }
     // load contextual help
     $this->cshTable = '_MOD_' . $this->MCONF['name'];
     if ($GLOBALS["BE_USER"]->uc['edit_showFieldHelp']) {
         $this->getLanguageService()->loadSingleTableDescription($this->cshTable);
     }
 }
Exemplo n.º 2
0
 /**
  * Processes the item to be rendered before the actual example content gets rendered
  * Deactivates the original example content output
  *
  * @param PageLayoutView $parentObject : The parent object that triggered this hook
  * @param boolean $drawItem : A switch to tell the parent object, if the item still must be drawn
  * @param string $headerContent : The content of the item header
  * @param string $itemContent : The content of the item itself
  * @param array $row : The current data row for this item
  *
  * @return    void
  */
 public function preProcess(PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row)
 {
     if ($row['CType']) {
         $showHidden = $parentObject->tt_contentConfig['showHidden'] ? '' : BackendUtility::BEenableFields('tt_content');
         $deleteClause = BackendUtility::deleteClause('tt_content');
         if ($GLOBALS['BE_USER']->uc['hideContentPreview']) {
             $drawItem = FALSE;
         }
         switch ($row['CType']) {
             case 'gridelements_pi1':
                 $drawItem = FALSE;
                 $itemContent .= $this->renderCTypeGridelements($parentObject, $row, $showHidden, $deleteClause);
                 $refIndexObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\ReferenceIndex');
                 /* @var $refIndexObj \TYPO3\CMS\Core\Database\ReferenceIndex */
                 $refIndexObj->updateRefIndexTable('tt_content', $row['uid']);
                 break;
             case 'shortcut':
                 $drawItem = FALSE;
                 $itemContent .= $this->renderCTypeShortcut($parentObject, $row, $showHidden, $deleteClause);
                 break;
         }
     }
     $gridType = $row['tx_gridelements_backend_layout'] ? ' t3-gridtype-' . $row['tx_gridelements_backend_layout'] : '';
     $headerContent = '<div id="ce' . $row['uid'] . '" class="t3-ctype-' . $row['CType'] . $gridType . '">' . $headerContent . '</div>';
 }
Exemplo n.º 3
0
 /**
  * @return void
  */
 public function batchCreateAction()
 {
     $categories = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_category', '1=1' . BackendUtility::BEenableFields('sys_category'), '', 'sorting', '', 'uid');
     foreach ($categories as $key => $category) {
         $level = 0;
         while ($category['parent'] > 0) {
             $category = $categories[$category['parent']];
             $level++;
         }
         $categories[$key]['title'] = str_repeat('- ', $level) . $categories[$key]['title'];
     }
     $this->view->assign('categories', $categories);
     if ($this->request->hasArgument('categories')) {
         $parents = array();
         if (!empty($this->request->getArgument('parent'))) {
             $parents[] = $this->request->getArgument('parent');
         }
         $categories = explode(chr(10), $this->request->getArgument('categories'));
         foreach ($categories as $category) {
             $category = rtrim($category);
             $depth = strlen($category) - strlen(ltrim($category, "\t"));
             $category = trim($category);
             $data = array('pid' => intval($_GET['id']), 'title' => $category, 'tstamp' => time(), 'crdate' => time(), 'parent' => isset($parents[$depth]) ? $parents[$depth] : 0);
             $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_category', $data);
             $parents[$depth + 1] = $GLOBALS['TYPO3_DB']->sql_insert_id();
         }
         $this->redirect('index');
     }
 }
Exemplo n.º 4
0
 /**
  * Runs conversion procedure.
  *
  * @return    string    Generated content
  */
 function runConversion()
 {
     $content = '';
     // Select all instances
     $res = $this->getDatabaseConnection()->exec_SELECTquery('uid,pid,pi_flexform', 'tt_content', 'list_type=\'irfaq_pi1\'' . BackendUtility::BEenableFields('tt_content') . BackendUtility::deleteClause('tt_content'));
     $results = $this->getDatabaseConnection()->sql_num_rows($res);
     $converted = 0;
     $data = array();
     $pidList = array();
     $replaceEmpty = intval(GeneralUtility::_GP('replaceEmpty'));
     /** @var \TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools $flexformtools */
     $flexformtools = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools');
     /* @var $flexformtools t3lib_flexformtools */
     $GLOBALS['TYPO3_CONF_VARS']['BE']['compactFlexFormXML'] = true;
     $GLOBALS['TYPO3_CONF_VARS']['BE']['niceFlexFormXMLtags'] = true;
     // Walk all rows
     while (false !== ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res))) {
         $ffArray = GeneralUtility::xml2array($row['pi_flexform']);
         $modified = false;
         if (is_array($ffArray) && isset($ffArray['data']['sDEF'])) {
             foreach ($ffArray['data']['sDEF'] as $sLang => $sLdata) {
                 foreach ($this->fieldSet as $sheet => $fieldList) {
                     foreach ($fieldList as $field) {
                         if (isset($ffArray['data']['sDEF'][$sLang][$field]) && isset($ffArray['data']['sDEF'][$sLang][$field]['vDEF']) && strlen($ffArray['data']['sDEF'][$sLang][$field]['vDEF']) > 0 && (!isset($ffArray['data'][$sheet][$sLang][$field]) || !isset($ffArray['data'][$sheet][$sLang][$field]['vDEF']) || $replaceEmpty && strlen($ffArray['data'][$sheet][$sLang][$field]['vDEF']) == 0)) {
                             $ffArray['data'][$sheet][$sLang][$field]['vDEF'] = $ffArray['data']['sDEF'][$sLang][$field]['vDEF'];
                             if ($row['pid'] > 0) {
                                 $pidList[$row['pid']] = $row['pid'];
                             }
                             $modified = true;
                         }
                     }
                 }
             }
         }
         if ($modified) {
             // Assemble data back
             $data['tt_content'][$row['uid']] = array('pi_flexform' => $flexformtools->flexArray2Xml($ffArray));
             $converted++;
         }
     }
     $this->getDatabaseConnection()->sql_free_result($res);
     if ($converted > 0) {
         // Update data
         /** @var \TYPO3\CMS\Core\DataHandling\DataHandler $tce */
         $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
         /* @var $tce t3lib_TCEmain */
         $tce->start($data, null);
         $tce->process_datamap();
         if (count($tce->errorLog) > 0) {
             $content .= '<p>' . $this->lang->getLL('errors') . '</p><ul><li>' . implode('</li><li>', $tce->errorLog) . '</li></ul>';
         }
         // Clear cache
         foreach ($pidList as $pid) {
             $tce->clear_cacheCmd($pid);
         }
     }
     $content .= '<p>' . sprintf($this->lang->getLL('result'), $results, $converted) . '</p>';
     return $content;
 }
Exemplo n.º 5
0
 /**
  * Enable fields for BE and FE
  *
  * @param string $table
  *
  * @return string
  */
 public function enableFields($table)
 {
     $where = '';
     if (TYPO3_MODE === 'FE') {
         $where .= GeneralUtility::getTsFe()->sys_page->enableFields($table);
     } else {
         $where .= BackendUtility::BEenableFields($table);
         $where .= BackendUtility::deleteClause($table);
     }
     return $where;
 }
Exemplo n.º 6
0
 /**
  * Returns available language records.
  * The method stores the records in the property to speed up the process as the method can be often called.
  *
  * @return array
  */
 public function getLanguages()
 {
     if (is_null($this->languages)) {
         $tableName = 'sys_language';
         $clause = '1 = 1';
         $clause .= BackendUtility::deleteClause($tableName);
         $clause .= BackendUtility::BEenableFields($tableName);
         $this->languages = $this->getDatabaseConnection()->exec_SELECTgetRows('*', $tableName, $clause);
     }
     return $this->languages;
 }
Exemplo n.º 7
0
 /**
  * add cities to selectbox.
  *
  * @param array                              $parentArray
  * @param \TYPO3\CMS\Backend\Form\FormEngine $fObj
  */
 public function addCityItems(array $parentArray, \TYPO3\CMS\Backend\Form\FormEngine $fObj)
 {
     $this->init();
     $rows = $this->database->exec_SELECTgetRows('city', 'tx_clubdirectory_domain_model_address', '1=1 ' . BackendUtility::BEenableFields('tx_clubdirectory_domain_model_address') . BackendUtility::deleteClause('tx_clubdirectory_domain_model_address'), 'city', 'city', '');
     foreach ($rows as $row) {
         $item = array();
         $item[0] = $row['city'];
         $item[1] = $row['city'];
         $item[2] = null;
         $parentArray['items'][] = $item;
     }
 }
 /**
  * When the extend to subpages flag was set, we determine the affected subpages and return them.
  *
  * @param int $pageId
  * @return array
  */
 protected function getSubPageIds($pageId)
 {
     /** @var $queryGenerator \TYPO3\CMS\Core\Database\QueryGenerator */
     $queryGenerator = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\QueryGenerator');
     // here we retrieve only the subpages of this page because the permission clause is not evaluated
     // on the root node.
     $permissionClause = ' 1 ' . BackendUtility::BEenableFields('pages');
     $treePageIdList = $queryGenerator->getTreeList($pageId, 20, 0, $permissionClause);
     $treePageIds = array_map('intval', explode(',', $treePageIdList));
     // the first one can be ignored because this is the page isself
     array_shift($treePageIds);
     return $treePageIds;
 }
Exemplo n.º 9
0
 /**
  * Looks for all external calendars on a certain pid-list
  * 
  * @param string $pidList
  *        	to search in
  * @return array array of array (array of $rows)
  */
 function findAll($pidList)
 {
     $enableFields = '';
     $orderBy = \TYPO3\CMS\Cal\Utility\Functions::getOrderBy('tx_cal_calendar');
     if (TYPO3_MODE == 'BE') {
         $enableFields = BackendUtility::BEenableFields('tx_cal_calendar') . ' AND tx_cal_calendar.deleted = 0';
     } else {
         $enableFields = $this->cObj->enableFields('tx_cal_calendar');
     }
     $return = array();
     if ($pidList == '') {
         $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_cal_calendar', ' type IN (1,2) ' . $enableFields, '', $orderBy);
     } else {
         $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_cal_calendar', ' type IN (1,2) AND pid IN (' . $pidList . ') ' . $enableFields, '', $orderBy);
     }
     if ($result) {
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
             $return[] = $row;
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($result);
     }
     return $return;
 }
Exemplo n.º 10
0
 public function run($time, $notificationEmail, $testRunner)
 {
     $this->isTestRunner = $testRunner;
     $timestamp = $this->convertToTimeStamp($time);
     $this->sendNotificationEmail = !empty($notificationEmail);
     // update alle user
     // welche NICHT Administratoren sind
     // und einen lastlogin kleiner/gleich $timestamp haben
     // und lastlogin NICHT 0 ist -> die haben sich noch nicht eingeloggt
     // und nicht mit '_cli' beginnen
     $normalUser = '******' . ' AND lastLogin <=' . (int) $timestamp . ' AND lastLogin!=0' . ' AND username NOT LIKE "_cli_%"' . BackendUtility::deleteClause('be_users') . BackendUtility::BEenableFields('be_users');
     $this->disableUser($normalUser);
     // update alle user
     // welche NICHT Administratoren sind
     // und einen lastlogin GLEICH 0 haben -> die haben sich noch nicht eingeloggt
     // UND ein Erstellungsdatum kleiner/gleich $timestamp haben
     // und nicht mit '_cli' beginnen
     $userNeverLoggedIn = '  admin=0
                             AND lastLogin = 0' . ' AND donotdisable=0' . ' AND crdate <=' . (int) $timestamp . ' AND username NOT LIKE "_cli_%"' . BackendUtility::deleteClause('be_users') . BackendUtility::BEenableFields('be_users');
     $this->disableUser($userNeverLoggedIn);
     return $this->manageMailTransport($notificationEmail);
 }
Exemplo n.º 11
0
 /**
  * Return an acronym array for the Acronym plugin
  *
  * @return 	string		acronym Javascript array
  * @todo Define visibility
  */
 public function buildJSAcronymArray($languageUid)
 {
     $button = 'acronym';
     $acronymArray = array();
     $abbrArray = array();
     $tableA = 'tx_rtehtmlarea_acronym';
     $tableB = 'static_languages';
     $fields = $tableA . '.type,' . $tableA . '.term,' . $tableA . '.acronym,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2';
     $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
     $whereClause = '1=1';
     // Get all acronyms on pages to which the user has access
     $lockBeUserToDBmounts = isset($this->thisConfig['buttons.'][$button . '.']['lockBeUserToDBmounts']) ? $this->thisConfig['buttons.'][$button . '.']['lockBeUserToDBmounts'] : $GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts'];
     if (!$GLOBALS['BE_USER']->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts'] && $lockBeUserToDBmounts) {
         // Temporarily setting alternative web browsing mounts
         $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
         if ($altMountPoints) {
             $savedGroupDataWebmounts = $GLOBALS['BE_USER']->groupData['webmounts'];
             $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $altMountPoints)));
             $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
         }
         $webMounts = $GLOBALS['BE_USER']->returnWebmounts();
         $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
         $recursive = isset($this->thisConfig['buttons.'][$button . '.']['recursive']) ? intval($this->thisConfig['buttons.'][$button . '.']['recursive']) : 0;
         if (trim($this->thisConfig['buttons.'][$button . '.']['pages'])) {
             $pids = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->thisConfig['buttons.'][$button . '.']['pages'], 1);
             foreach ($pids as $key => $val) {
                 if (!$GLOBALS['BE_USER']->isInWebMount($val, $perms_clause)) {
                     unset($pids[$key]);
                 }
             }
         } else {
             $pids = $webMounts;
         }
         // Restoring webmounts
         if ($altMountPoints) {
             $GLOBALS['BE_USER']->groupData['webmounts'] = $savedGroupDataWebmounts;
             $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
         }
         $queryGenerator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\QueryGenerator');
         foreach ($pids as $key => $val) {
             if ($pageTree) {
                 $pageTreePrefix = ',';
             }
             $pageTree .= $pageTreePrefix . $queryGenerator->getTreeList($val, $recursive, $begin = 0, $perms_clause);
         }
         $whereClause .= ' AND ' . $tableA . '.pid IN (' . $GLOBALS['TYPO3_DB']->fullQuoteStr($pageTree ? $pageTree : '', $tableA) . ')';
     }
     // Restrict to acronyms applicable to the language of current content element
     if ($this->htmlAreaRTE->contentLanguageUid > -1) {
         $whereClause .= ' AND (' . $tableA . '.sys_language_uid=' . $this->htmlAreaRTE->contentLanguageUid . ' OR ' . $tableA . '.sys_language_uid=-1) ';
     }
     // Restrict to acronyms in certain languages
     if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['language.']) && isset($this->thisConfig['buttons.']['language.']['restrictToItems'])) {
         $languageList = implode('\',\'', \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_DB']->fullQuoteStr(strtoupper($this->thisConfig['buttons.']['language.']['restrictToItems']), $tableB)));
         $whereClause .= ' AND ' . $tableB . '.lg_iso_2 IN (' . $languageList . ') ';
     }
     $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($tableA);
     $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableA);
     $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($tableB);
     $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableB);
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $tableAB, $whereClause);
     while ($acronymRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
         $item = array('term' => $acronymRow['term'], 'abbr' => $acronymRow['acronym'], 'language' => strtolower($acronymRow['lg_iso_2']) . ($acronymRow['lg_country_iso_2'] ? '-' . $acronymRow['lg_country_iso_2'] : ''));
         if ($acronymRow['type'] == 1) {
             $acronymArray[] = $item;
         } elseif ($acronymRow['type'] == 2) {
             $abbrArray[] = $item;
         }
     }
     $this->acronymIndex = count($acronymArray);
     $this->abbreviationIndex = count($abbrArray);
     return json_encode(array('abbr' => $abbrArray, 'acronym' => $acronymArray));
 }
Exemplo n.º 12
0
 /**
  * Creates HTML for inserting/moving content elements.
  *
  * @param int $pid page id onto which to insert content element.
  * @param int $moveUid Move-uid (tt_content element uid?)
  * @param string $colPosList List of columns to show
  * @param bool $showHidden If not set, then hidden/starttime/endtime records are filtered out.
  * @param string $R_URI Request URI
  * @return string HTML
  */
 public function printContentElementColumns($pid, $moveUid, $colPosList, $showHidden, $R_URI)
 {
     $this->R_URI = $R_URI;
     $this->moveUid = $moveUid;
     $colPosArray = GeneralUtility::trimExplode(',', $colPosList, TRUE);
     $lines = array();
     foreach ($colPosArray as $kk => $vv) {
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . (int) $pid . ($showHidden ? '' : BackendUtility::BEenableFields('tt_content')) . ' AND colPos=' . (int) $vv . ((string) $this->cur_sys_language !== '' ? ' AND sys_language_uid=' . (int) $this->cur_sys_language : '') . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'sorting');
         $lines[$vv] = array();
         $lines[$vv][] = $this->insertPositionIcon('', $vv, $kk, $moveUid, $pid);
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             BackendUtility::workspaceOL('tt_content', $row);
             if (is_array($row)) {
                 $lines[$vv][] = $this->wrapRecordHeader($this->getRecordHeader($row), $row);
                 $lines[$vv][] = $this->insertPositionIcon($row, $vv, $kk, $moveUid, $pid);
             }
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($res);
     }
     return $this->printRecordMap($lines, $colPosArray, $pid);
 }
Exemplo n.º 13
0
 /**
  * Getting all languages into an array
  * where the key is the ISO alpha-2 code of the language
  * and where the value are the name of the language in the current language
  * Note: we exclude sacred and constructed languages
  *
  * @return array An array of names of languages
  */
 protected function getLanguages()
 {
     $databaseConnection = $this->getDatabaseConnection();
     $nameArray = array();
     if (ExtensionManagementUtility::isLoaded('static_info_tables')) {
         $where = '1=1';
         $table = 'static_languages';
         $lang = LocalizationUtility::getCurrentLanguage();
         $titleFields = LocalizationUtility::getLabelFields($table, $lang);
         $prefixedTitleFields = array();
         foreach ($titleFields as $titleField) {
             $prefixedTitleFields[] = $table . '.' . $titleField;
         }
         $labelFields = implode(',', $prefixedTitleFields);
         // Restrict to certain languages
         if (is_array($this->configuration['thisConfig']['buttons.']) && is_array($this->configuration['thisConfig']['buttons.']['language.']) && isset($this->configuration['thisConfig']['buttons.']['language.']['restrictToItems'])) {
             $languageList = implode('\',\'', GeneralUtility::trimExplode(',', $databaseConnection->fullQuoteStr(strtoupper($this->configuration['thisConfig']['buttons.']['language.']['restrictToItems']), $table)));
             $where .= ' AND ' . $table . '.lg_iso_2 IN (' . $languageList . ')';
         }
         $res = $databaseConnection->exec_SELECTquery($table . '.lg_iso_2,' . $table . '.lg_country_iso_2,' . $labelFields, $table, $where . ' AND lg_constructed = 0 ' . BackendUtility::BEenableFields($table) . BackendUtility::deleteClause($table));
         $prefixLabelWithCode = (bool) $this->configuration['thisConfig']['buttons.']['language.']['prefixLabelWithCode'];
         $postfixLabelWithCode = (bool) $this->configuration['thisConfig']['buttons.']['language.']['postfixLabelWithCode'];
         while ($row = $databaseConnection->sql_fetch_assoc($res)) {
             $code = strtolower($row['lg_iso_2']) . ($row['lg_country_iso_2'] ? '-' . strtoupper($row['lg_country_iso_2']) : '');
             foreach ($titleFields as $titleField) {
                 if ($row[$titleField]) {
                     $nameArray[$code] = $prefixLabelWithCode ? $code . ' - ' . $row[$titleField] : ($postfixLabelWithCode ? $row[$titleField] . ' - ' . $code : $row[$titleField]);
                     break;
                 }
             }
         }
         $databaseConnection->sql_free_result($res);
         uasort($nameArray, 'strcoll');
     }
     return $nameArray;
 }
 /**
  * This method checks the status of the '_cli_scheduler' user
  * It will differentiate between a non-existing user and an existing,
  * but disabled user (as per enable fields)
  *
  * @return integer	-1	if user doesn't exist
  */
 protected function checkSchedulerUser()
 {
     $schedulerUserStatus = -1;
     // Assemble base WHERE clause
     $where = 'username = \'_cli_scheduler\' AND admin = 0' . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('be_users');
     // Check if user exists at all
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('1', 'be_users', $where);
     if ($GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
         $schedulerUserStatus = 0;
         // Check if user exists and is enabled
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('1', 'be_users', $where . \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('be_users'));
         if ($GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $schedulerUserStatus = 1;
         }
     }
     $GLOBALS['TYPO3_DB']->sql_free_result($res);
     return $schedulerUserStatus;
 }
 /**
  * This method fetches list of all group that have been registered with the Scheduler
  *
  * @return array List of registered groups
  */
 protected function getRegisteredTaskGroups()
 {
     $list = array();
     // Get all registered task groups
     $query = array('SELECT' => '*', 'FROM' => 'tx_scheduler_task_group', 'WHERE' => '1=1' . BackendUtility::BEenableFields('tx_scheduler_task_group') . BackendUtility::deleteClause('tx_scheduler_task_group'), 'ORDERBY' => 'sorting');
     $res = $this->getDatabaseConnection()->exec_SELECT_queryArray($query);
     while (($groupRecord = $this->getDatabaseConnection()->sql_fetch_assoc($res)) !== false) {
         $list[] = $groupRecord;
     }
     $this->getDatabaseConnection()->sql_free_result($res);
     return $list;
 }
 /**
  * @param $uid
  * @param bool $localizations
  * @return string
  */
 protected function buildQuery($uid, $localizations = false)
 {
     $constraints = ['1'];
     $tcaCtrl = $GLOBALS['TCA'][$this->tableName]['ctrl'];
     // only with doktype page
     if ($this->tableName == 'pages') {
         $constraints[] = 'doktype = 1';
     }
     // check localization
     if ($localizations) {
         if ($tcaCtrl['transForeignTable']) {
             $this->tableName = $tcaCtrl['transForeignTable'];
             $tcaCtrl['transOrigPointerField'] = 'pid';
         } else {
             $constraints[] = $tcaCtrl['languageField'] . ' > 0';
         }
     }
     // if single uid
     if ($uid > 0) {
         if ($localizations) {
             $constraints[] = $tcaCtrl['transOrigPointerField'] . ' = ' . $uid;
         } else {
             $constraints[] = 'uid = ' . $uid;
         }
     }
     return implode($constraints, ' AND ') . BackendUtility::BEenableFields($this->tableName);
 }
Exemplo n.º 17
0
 /**
  * Update page record array with count of news & category records
  *
  * @param array $row page record
  * @return void
  */
 private function countRecordsOnPage(array &$row)
 {
     $pageUid = (int) $row['row']['uid'];
     /* @var $db \TYPO3\CMS\Core\Database\DatabaseConnection */
     $db = $GLOBALS['TYPO3_DB'];
     $row['countNews'] = $db->exec_SELECTcountRows('*', 'tx_news_domain_model_news', 'pid=' . $pageUid . BackendUtilityCore::BEenableFields('tx_news_domain_model_news'));
     $row['countCategories'] = $db->exec_SELECTcountRows('*', 'sys_category', 'pid=' . $pageUid . BackendUtilityCore::BEenableFields('sys_category'));
     $row['countNewsAndCategories'] = $row['countNews'] + $row['countCategories'];
 }
Exemplo n.º 18
0
 /**
  * Getting a template with all Templatenames in the Mailtemplaterecords
  * according to the given mailkind and pid
  *
  * @param int $mailkind Move the Order in the Orderfolder
  * @param int $pid The PID of the order to move
  * @param int $orderSysLanguageUid Order language uid
  *
  * @return array of templatenames found in Filelist
  */
 protected function generateTemplateArray($mailkind, $pid, $orderSysLanguageUid)
 {
     /**
      * Page repository
      *
      * @var \TYPO3\CMS\Frontend\Page\PageRepository $pageRepository
      */
     $pageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
     $rows = $this->getDatabaseConnection()->exec_SELECTgetRows('*', $this->tablename, 'sys_language_uid = 0 AND pid = ' . $pid . ' AND mailkind = ' . $mailkind . \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($this->tablename));
     $templates = array();
     foreach ($rows as $row) {
         $templates[] = $pageRepository->getRecordOverlay($this->tablename, $row, $orderSysLanguageUid);
     }
     return $templates;
 }
Exemplo n.º 19
0
 /**
  * Initialize a couple of language related local properties
  *
  * @return void
  */
 public function initializeLanguageRelatedProperties()
 {
     $database = $this->getDatabaseConnection();
     $this->language = $GLOBALS['LANG']->lang;
     if ($this->language === 'default' || !$this->language) {
         $this->language = 'en';
     }
     $currentLanguageUid = $this->data['databaseRow']['sys_language_uid'];
     if (is_array($currentLanguageUid)) {
         $currentLanguageUid = $currentLanguageUid[0];
     }
     $this->contentLanguageUid = (int) max($currentLanguageUid, 0);
     if ($this->contentLanguageUid) {
         $this->contentISOLanguage = $this->language;
         if (ExtensionManagementUtility::isLoaded('static_info_tables')) {
             $tableA = 'sys_language';
             $tableB = 'static_languages';
             $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2';
             $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
             $whereClause = $tableA . '.uid = ' . intval($this->contentLanguageUid);
             $whereClause .= BackendUtility::BEenableFields($tableA);
             $whereClause .= BackendUtility::deleteClause($tableA);
             $res = $database->exec_SELECTquery($selectFields, $tableAB, $whereClause);
             while ($languageRow = $database->sql_fetch_assoc($res)) {
                 $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']) . (trim($languageRow['lg_country_iso_2']) ? '_' . trim($languageRow['lg_country_iso_2']) : ''));
             }
             $database->sql_free_result($res);
         }
     } else {
         $this->contentISOLanguage = trim($this->processedRteConfiguration['defaultContentLanguage']) ?: 'en';
         $languageCodeParts = explode('_', $this->contentISOLanguage);
         $this->contentISOLanguage = strtolower($languageCodeParts[0]) . ($languageCodeParts[1] ? '_' . strtoupper($languageCodeParts[1]) : '');
         // Find the configured language in the list of localization locales
         /** @var $locales Locales */
         $locales = GeneralUtility::makeInstance(Locales::class);
         // If not found, default to 'en'
         if (!in_array($this->contentISOLanguage, $locales->getLocales())) {
             $this->contentISOLanguage = 'en';
         }
     }
     $this->contentTypo3Language = $this->contentISOLanguage === 'en' ? 'default' : $this->contentISOLanguage;
 }
Exemplo n.º 20
0
 /**
  * @param $edit_record array
  *
  * @return array
  */
 protected function makeQuickEditMenu($edit_record)
 {
     $lang = $this->getLanguageService();
     $databaseConnection = $this->getDatabaseConnection();
     $beUser = $this->getBackendUser();
     $quickEditMenu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
     $quickEditMenu->setIdentifier('quickEditMenu');
     $quickEditMenu->setLabel('');
     // Setting close url/return url for exiting this script:
     // Goes to 'Columns' view if close is pressed (default)
     $this->closeUrl = $this->local_linkThisScript(array('SET' => array('function' => 1)));
     if ($this->returnUrl) {
         $this->closeUrl = $this->returnUrl;
     }
     $retUrlStr = $this->returnUrl ? '&returnUrl=' . rawurlencode($this->returnUrl) : '';
     // Creating the selector box, allowing the user to select which element to edit:
     $isSelected = 0;
     $languageOverlayRecord = '';
     if ($this->current_sys_language) {
         list($languageOverlayRecord) = BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $this->id, 'AND sys_language_uid=' . (int) $this->current_sys_language);
     }
     if (is_array($languageOverlayRecord)) {
         $inValue = 'pages_language_overlay:' . $languageOverlayRecord['uid'];
         $isSelected += (int) $edit_record == $inValue;
         $menuItem = $quickEditMenu->makeMenuItem()->setTitle('[ ' . $lang->getLL('editLanguageHeader', true) . ' ]')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $inValue . $retUrlStr)->setActive($edit_record == $inValue);
         $quickEditMenu->addMenuItem($menuItem);
     } else {
         $inValue = 'pages:' . $this->id;
         $isSelected += (int) $edit_record == $inValue;
         $menuItem = $quickEditMenu->makeMenuItem()->setTitle('[ ' . $lang->getLL('editPageProperties', true) . ' ]')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $inValue . $retUrlStr)->setActive($edit_record == $inValue);
         $quickEditMenu->addMenuItem($menuItem);
     }
     // Selecting all content elements from this language and allowed colPos:
     $whereClause = 'pid=' . (int) $this->id . ' AND sys_language_uid=' . (int) $this->current_sys_language . ' AND colPos IN (' . $this->colPosList . ')' . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : BackendUtility::BEenableFields('tt_content')) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content');
     if (!$this->getBackendUser()->user['admin']) {
         $whereClause .= ' AND editlock = 0';
     }
     $res = $databaseConnection->exec_SELECTquery('*', 'tt_content', $whereClause, '', 'colPos,sorting');
     $colPos = null;
     $first = 1;
     // Page is the pid if no record to put this after.
     $prev = $this->id;
     while ($cRow = $databaseConnection->sql_fetch_assoc($res)) {
         BackendUtility::workspaceOL('tt_content', $cRow);
         if (is_array($cRow)) {
             if ($first) {
                 if (!$edit_record) {
                     $edit_record = 'tt_content:' . $cRow['uid'];
                 }
                 $first = 0;
             }
             if (!isset($colPos) || $cRow['colPos'] !== $colPos) {
                 $colPos = $cRow['colPos'];
                 $menuItem = $quickEditMenu->makeMenuItem()->setTitle(' ')->setHref('#');
                 $quickEditMenu->addMenuItem($menuItem);
                 $menuItem = $quickEditMenu->makeMenuItem()->setTitle('__' . $lang->sL(BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $colPos), true) . ':__')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=_EDIT_COL:' . $colPos . $retUrlStr);
                 $quickEditMenu->addMenuItem($menuItem);
             }
             $inValue = 'tt_content:' . $cRow['uid'];
             $isSelected += (int) $edit_record == $inValue;
             $menuItem = $quickEditMenu->makeMenuItem()->setTitle(htmlspecialchars(GeneralUtility::fixed_lgd_cs($cRow['header'] ? $cRow['header'] : '[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title') . '] ' . strip_tags($cRow['bodytext']), $beUser->uc['titleLen'])))->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $inValue . $retUrlStr)->setActive($edit_record == $inValue);
             $quickEditMenu->addMenuItem($menuItem);
             $prev = -$cRow['uid'];
         }
     }
     // If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element:
     if (!$edit_record) {
         $edit_record = 'tt_content:new/' . $prev . '/' . $colPos;
         $inValue = 'tt_content:new/' . $prev . '/' . $colPos;
         $isSelected += (int) $edit_record == $inValue;
         $menuItem = $quickEditMenu->makeMenuItem()->setTitle('[ ' . $lang->getLL('newLabel', 1) . ' ]')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $inValue . $retUrlStr)->setActive($edit_record == $inValue);
         $quickEditMenu->addMenuItem($menuItem);
     }
     // If none is yet selected...
     if (!$isSelected) {
         $menuItem = $quickEditMenu->makeMenuItem()->setTitle('__________')->setHref('#');
         $quickEditMenu->addMenuItem($menuItem);
         $menuItem = $quickEditMenu->makeMenuItem()->setTitle('[ ' . $lang->getLL('newLabel', true) . ' ]')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $edit_record . $retUrlStr)->setActive($edit_record == $inValue);
         $quickEditMenu->addMenuItem($menuItem);
     }
     $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($quickEditMenu);
     return $edit_record;
 }
Exemplo n.º 21
0
 /**
  * Gets the Solr connections applicaple for a page.
  *
  * The connections include the default connection and connections to be used
  * for translations of a page.
  *
  * @param Item $item An index queue item
  * @return array An array of ApacheSolrForTypo3\Solr\SolrService connections, the array's keys are the sys_language_uid of the language of the connection
  */
 protected function getSolrConnectionsByItem(Item $item)
 {
     $solrConnections = parent::getSolrConnectionsByItem($item);
     $page = $item->getRecord();
     // may use \TYPO3\CMS\Core\Utility\GeneralUtility::hideIfDefaultLanguage($page['l18n_cfg']) with TYPO3 4.6
     if ($page['l18n_cfg'] & 1) {
         // page is configured to hide the default translation -> remove Solr connection for default language
         unset($solrConnections[0]);
     }
     if (GeneralUtility::hideIfNotTranslated($page['l18n_cfg'])) {
         $accessibleSolrConnections = array();
         if (isset($solrConnections[0])) {
             $accessibleSolrConnections[0] = $solrConnections[0];
         }
         $translationOverlays = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('pid, sys_language_uid', 'pages_language_overlay', 'pid = ' . $page['uid'] . BackendUtility::deleteClause('pages_language_overlay') . BackendUtility::BEenableFields('pages_language_overlay'));
         foreach ($translationOverlays as $overlay) {
             $languageId = $overlay['sys_language_uid'];
             $accessibleSolrConnections[$languageId] = $solrConnections[$languageId];
         }
         $solrConnections = $accessibleSolrConnections;
     }
     return $solrConnections;
 }
 /**
  * get content of current page and save data to db
  * @param $uid page-UID that has to be indexed
  */
 public function getPageContent($uid)
 {
     // get content elements for this page
     $fields = 'uid, pid, header, bodytext, CType, sys_language_uid, header_layout, fe_group';
     $table = 'tt_content';
     $where = 'pid = ' . intval($uid);
     $where .= ' AND (' . $this->whereClauseForCType . ')';
     $where .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table);
     $where .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table);
     // Get access restrictions for this page, this access restrictians apply to all
     // content elements of this pages. Individuel access restrictions
     // set for the content elements will be ignored. Use the content
     // element indexer if you need that feature!
     $pageAccessRestrictions = $this->getInheritedAccessRestrictions($uid);
     // get Tags for current page
     $tags = $this->pageRecords[intval($uid)]['tags'];
     // Compile content for this page from individual content elements with
     // respect to the language.
     // While doing so, fetch also content from attached files and write
     // their content directly to the index.
     $ttContentRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fields, $table, $where);
     $pageContent = array();
     if (count($ttContentRows)) {
         foreach ($ttContentRows as $ttContentRow) {
             $content = '';
             // index header
             // add header only if not set to "hidden"
             if ($ttContentRow['header_layout'] != 100) {
                 $content .= strip_tags($ttContentRow['header']) . "\n";
             }
             // index content of this content element and find attached or linked files.
             // Attached files are saved as file references, the RTE links directly to
             // a file, thus we get file objects.
             // Files go into the index no matter if "index_content_with_restrictions" is set
             // or not, that means even if protected content elements do not go into the index,
             // files do. Since each file gets it's own index entry with correct access
             // restrictons, that's no problem from a access permission perspective (in fact, it's a feature).
             if (in_array($ttContentRow['CType'], $this->fileCTypes)) {
                 $fileObjects = $this->findAttachedFiles($ttContentRow);
             } else {
                 $fileObjects = $this->findLinkedFilesInRte($ttContentRow);
                 $content .= $this->getContentFromContentElement($ttContentRow) . "\n";
             }
             // index the files fond
             $this->indexFiles($fileObjects, $ttContentRow, $pageAccessRestrictions['fe_group'], $tags) . "\n";
             // add content from this content element to page content
             // ONLY if this content element is not access protected
             // or protected content elements should go into the index
             // by configuration.
             if ($this->indexerConfig['index_content_with_restrictions'] == 'yes' || $ttContentRow['fe_group'] == '' || $ttContentRow['fe_group'] == '0') {
                 $pageContent[$ttContentRow['sys_language_uid']] .= $content;
             }
         }
     } else {
         $this->counterWithoutContent++;
         return;
     }
     // make it possible to modify the indexerConfig via hook
     $indexerConfig = $this->indexerConfig;
     // make it possible to modify the default values via hook
     $indexEntryDefaultValues = array('type' => 'page', 'uid' => $uid, 'params' => '', 'feGroupsPages' => $pageAccessRestrictions['fe_group'], 'debugOnly' => FALSE);
     // hook for custom modifications of the indexed data, e. g. the tags
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyPagesIndexEntry'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyPagesIndexEntry'] as $_classRef) {
             $_procObj =& \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
             $_procObj->modifyPagesIndexEntry($uid, $pageContent, $tags, $this->cachedPageRecords, $additionalFields, $indexerConfig, $indexEntryDefaultValues, $this);
         }
     }
     // store record in index table
     if (count($pageContent)) {
         foreach ($pageContent as $language_uid => $content) {
             if (!$pageAccessRestrictions['hidden'] && $this->checkIfpageShouldBeIndexed($uid, $language_uid)) {
                 // overwrite access restrictions with language overlay values
                 $accessRestrictionsLanguageOverlay = $pageAccessRestrictions;
                 $pageAccessRestrictions['fe_group'] = $indexEntryDefaultValues['feGroupsPages'];
                 if ($language_uid > 0) {
                     if ($this->cachedPageRecords[$language_uid][$uid]['fe_group']) {
                         $accessRestrictionsLanguageOverlay['fe_group'] = $this->cachedPageRecords[$language_uid][$uid]['fe_group'];
                     }
                     if ($this->cachedPageRecords[$language_uid][$uid]['starttime']) {
                         $accessRestrictionsLanguageOverlay['starttime'] = $this->cachedPageRecords[$language_uid][$uid]['starttime'];
                     }
                     if ($this->cachedPageRecords[$language_uid][$uid]['endtime']) {
                         $accessRestrictionsLanguageOverlay['endtime'] = $this->cachedPageRecords[$language_uid][$uid]['endtime'];
                     }
                 }
                 $this->pObj->storeInIndex($indexerConfig['storagepid'], $this->cachedPageRecords[$language_uid][$uid]['title'], $indexEntryDefaultValues['type'], $indexEntryDefaultValues['uid'], $content, $tags, $indexEntryDefaultValues['params'], $this->cachedPageRecords[$language_uid][$uid]['abstract'], $language_uid, $accessRestrictionsLanguageOverlay['starttime'], $accessRestrictionsLanguageOverlay['endtime'], $accessRestrictionsLanguageOverlay['fe_group'], $indexEntryDefaultValues['debugOnly'], $additionalFields);
                 $this->counter++;
             }
         }
     }
     return;
 }
Exemplo n.º 23
0
 /**
  * Return be_users that should be notified on stage change from input list.
  * previously called notifyStageChange_getEmails() in tcemain
  *
  * @param string $listOfUsers List of backend users, on the form "be_users_10,be_users_2" or "10,2" in case noTablePrefix is set.
  * @param bool $noTablePrefix If set, the input list are integers and not strings.
  * @return array Array of emails
  */
 protected function getEmailsForStageChangeNotification($listOfUsers, $noTablePrefix = FALSE)
 {
     $users = GeneralUtility::trimExplode(',', $listOfUsers, TRUE);
     $emails = array();
     foreach ($users as $userIdent) {
         if ($noTablePrefix) {
             $id = (int) $userIdent;
         } else {
             list($table, $id) = GeneralUtility::revExplode('_', $userIdent, 2);
         }
         if ($table === 'be_users' || $noTablePrefix) {
             if ($userRecord = BackendUtility::getRecord('be_users', $id, 'uid,email,lang,realName', BackendUtility::BEenableFields('be_users'))) {
                 if (trim($userRecord['email']) !== '') {
                     $emails[$id] = $userRecord;
                 }
             }
         }
     }
     return $emails;
 }
Exemplo n.º 24
0
 /**
  * Returns the first configured domain name for a page
  *
  * @param int $uid
  * @return string
  */
 public static function getDomainName($uid)
 {
     $whereClause = 'pid=' . (int) $uid . BackendUtility::deleteClause('sys_domain') . BackendUtility::BEenableFields('sys_domain');
     $domain = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('domainName', 'sys_domain', $whereClause, '', 'sorting');
     return is_array($domain) ? htmlspecialchars($domain['domainName']) : '';
 }
Exemplo n.º 25
0
    /**
     * Draws the RTE as an iframe
     *
     * @param 	object		Reference to parent object, which is an instance of the TCEforms.
     * @param 	string		The table name
     * @param 	string		The field name
     * @param 	array		The current row from which field is being rendered
     * @param 	array		Array of standard content for rendering form fields from TCEforms. See TCEforms for details on this. Includes for instance the value and the form field name, java script actions and more.
     * @param 	array		"special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
     * @param 	array		Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
     * @param 	string		Record "type" field value.
     * @param 	string		Relative path for images/links in RTE; this is used when the RTE edits content from static files where the path of such media has to be transformed forth and back!
     * @param 	integer		PID value of record (true parent page id)
     * @return 	string		HTML code for RTE!
     * @todo Define visibility
     */
    public function drawRTE(&$parentObject, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue)
    {
        global $TSFE, $TYPO3_CONF_VARS, $TYPO3_DB;
        $this->TCEform = $parentObject;
        $this->client = $this->clientInfo();
        $this->typoVersion = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version);
        /* =======================================
         * INIT THE EDITOR-SETTINGS
         * =======================================
         */
        // Get the path to this extension:
        $this->extHttpPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->ID);
        // Get the site URL
        $this->siteURL = $GLOBALS['TSFE']->absRefPrefix ?: '';
        // Get the host URL
        $this->hostURL = '';
        // Element ID + pid
        $this->elementId = $PA['itemFormElName'];
        $this->elementParts[0] = $table;
        $this->elementParts[1] = $row['uid'];
        $this->tscPID = $thePidValue;
        $this->thePid = $thePidValue;
        // Record "type" field value:
        $this->typeVal = $RTEtypeVal;
        // TCA "type" value for record
        // RTE configuration
        $pageTSConfig = $TSFE->getPagesTSconfig();
        if (is_array($pageTSConfig) && is_array($pageTSConfig['RTE.'])) {
            $this->RTEsetup = $pageTSConfig['RTE.'];
        }
        if (is_array($thisConfig) && !empty($thisConfig)) {
            $this->thisConfig = $thisConfig;
        } elseif (is_array($this->RTEsetup['default.']) && is_array($this->RTEsetup['default.']['FE.'])) {
            $this->thisConfig = $this->RTEsetup['default.']['FE.'];
        }
        // Special configuration (line) and default extras:
        $this->specConf = $specConf;
        if ($this->thisConfig['forceHTTPS']) {
            $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath);
            $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
            $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
        }
        // Register RTE windows:
        $this->TCEform->RTEwindows[] = $PA['itemFormElName'];
        $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']);
        $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId)) . '_' . strval($this->TCEform->RTEcounter);
        /* =======================================
         * LANGUAGES & CHARACTER SETS
         * =======================================
         */
        // Language
        $TSFE->initLLvars();
        $this->language = $TSFE->lang;
        $this->LOCAL_LANG = \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile('EXT:' . $this->ID . '/locallang.xml', $this->language);
        if ($this->language == 'default' || !$this->language) {
            $this->language = 'en';
        }
        $this->contentLanguageUid = max($row['sys_language_uid'], 0);
        if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) {
            if ($this->contentLanguageUid) {
                $tableA = 'sys_language';
                $tableB = 'static_languages';
                $languagesUidsList = $this->contentLanguageUid;
                $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
                $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
                $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
                $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($tableA);
                $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableA);
                $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                    $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']) . (trim($languageRow['lg_country_iso_2']) ? '_' . trim($languageRow['lg_country_iso_2']) : ''));
                    $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
                }
            } else {
                $this->contentISOLanguage = $GLOBALS['TSFE']->sys_language_isocode ?: 'en';
                $selectFields = 'lg_iso_2, lg_typo3';
                $tableAB = 'static_languages';
                $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB);
                $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                    $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
                }
            }
        }
        $this->contentISOLanguage = $this->contentISOLanguage ?: ($GLOBALS['TSFE']->sys_language_isocode ?: 'en');
        $this->contentTypo3Language = $this->contentTypo3Language ?: $GLOBALS['TSFE']->lang;
        if ($this->contentTypo3Language == 'default') {
            $this->contentTypo3Language = 'en';
        }
        // Character set
        $this->charset = $TSFE->renderCharset;
        $this->OutputCharset = $TSFE->metaCharset ?: $TSFE->renderCharset;
        // Set the charset of the content
        $this->contentCharset = $TSFE->csConvObj->charSetArray[$this->contentTypo3Language];
        $this->contentCharset = $this->contentCharset ?: 'utf-8';
        $this->contentCharset = trim($TSFE->config['config']['metaCharset']) ?: $this->contentCharset;
        /* =======================================
         * TOOLBAR CONFIGURATION
         * =======================================
         */
        $this->initializeToolbarConfiguration();
        /* =======================================
         * SET STYLES
         * =======================================
         */
        $width = 610;
        if (isset($this->thisConfig['RTEWidthOverride'])) {
            if (strstr($this->thisConfig['RTEWidthOverride'], '%')) {
                if ($this->client['browser'] != 'msie') {
                    $width = (int) $this->thisConfig['RTEWidthOverride'] > 0 ? $this->thisConfig['RTEWidthOverride'] : '100%';
                }
            } else {
                $width = (int) $this->thisConfig['RTEWidthOverride'] > 0 ? (int) $this->thisConfig['RTEWidthOverride'] : $width;
            }
        }
        $RTEWidth = strstr($width, '%') ? $width : $width . 'px';
        $editorWrapWidth = strstr($width, '%') ? $width : $width + 2 . 'px';
        $height = 380;
        $RTEHeightOverride = (int) $this->thisConfig['RTEHeightOverride'];
        $height = $RTEHeightOverride > 0 ? $RTEHeightOverride : $height;
        $RTEHeight = $height . 'px';
        $editorWrapHeight = $height + 2 . 'px';
        $this->RTEWrapStyle = $this->RTEWrapStyle ?: ($this->RTEdivStyle ?: 'height:' . $editorWrapHeight . '; width:' . $editorWrapWidth . ';');
        $this->RTEdivStyle = $this->RTEdivStyle ?: 'position:relative; left:0px; top:0px; height:' . $RTEHeight . '; width:' . $RTEWidth . '; border: 1px solid black;';
        /* =======================================
         * LOAD JS, CSS and more
         * =======================================
         */
        $this->getPageRenderer();
        // Register RTE in JS
        $this->TCEform->additionalJS_post[] = $this->wrapCDATA($this->registerRTEinJS($this->TCEform->RTEcounter, '', '', '', $textAreaId));
        // Set the save option for the RTE:
        $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
        // Loading ExtJs JavaScript files and inline code, if not configured in TS setup
        if (!is_array($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.'])) {
            $this->pageRenderer->loadExtJs();
            $this->pageRenderer->enableExtJSQuickTips();
        }
        $this->pageRenderer->addJsFile($this->getFullFileName('typo3/js/extjs/ux/ext.resizable.js'));
        $this->pageRenderer->addJsFile('sysext/backend/Resources/Public/JavaScript/notifications.js');
        // Preloading the pageStyle and including RTE skin stylesheets
        $this->addPageStyle();
        $this->pageRenderer->addCssFile($this->siteURL . 'typo3/contrib/extjs/resources/css/ext-all-notheme.css');
        $this->pageRenderer->addCssFile($this->siteURL . 'typo3/sysext/t3skin/extjs/xtheme-t3skin.css');
        $this->addSkin();
        $this->pageRenderer->addCssFile($this->siteURL . 'typo3/js/extjs/ux/resize.css');
        // Add RTE JavaScript
        $this->addRteJsFiles($this->TCEform->RTEcounter);
        $this->pageRenderer->addJsFile($this->buildJSMainLangFile($this->TCEform->RTEcounter));
        $this->pageRenderer->addJsInlineCode('HTMLArea-init', $this->getRteInitJsCode(), TRUE);
        /* =======================================
         * DRAW THE EDITOR
         * =======================================
         */
        // Transform value:
        $value = $this->transformContent('rte', $PA['itemFormElValue'], $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $thePidValue);
        // Further content transformation by registered plugins
        foreach ($this->registeredPlugins as $pluginId => $plugin) {
            if ($this->isPluginEnabled($pluginId) && method_exists($plugin, 'transformContent')) {
                $value = $plugin->transformContent($value);
            }
        }
        // draw the textarea
        $item = $this->triggerField($PA['itemFormElName']) . '
			<div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $TSFE->csConvObj->conv($TSFE->getLLL('Please wait', $this->LOCAL_LANG), $this->charset, $TSFE->renderCharset) . '</div>
			<div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; ' . htmlspecialchars($this->RTEWrapStyle) . '">
			<textarea id="RTEarea' . $textAreaId . '" name="' . htmlspecialchars($PA['itemFormElName']) . '" rows="0" cols="0" style="' . htmlspecialchars($this->RTEdivStyle) . '">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($value) . '</textarea>
			</div>' . LF;
        return $item;
    }
Exemplo n.º 26
0
 /**
  * Fetched fresh storage records from database because the new imported
  * ones are not in cached data of the StorageRepository
  *
  * @return bool|array
  */
 protected function fetchStorageRecords()
 {
     $whereClause = BackendUtility::BEenableFields('sys_file_storage');
     $whereClause .= BackendUtility::deleteClause('sys_file_storage');
     $rows = $this->getDatabaseConnection()->exec_SELECTgetRows('*', 'sys_file_storage', '1=1' . $whereClause, '', '', '', 'uid');
     return $rows;
 }
 /**
  * Will make the simulate-user selector if the logged in user is administrator.
  * It will also set the GLOBAL(!) BE_USER to the simulated user selected if any (and set $this->OLD_BE_USER to logged in user)
  *
  * @return void
  */
 public function simulateUser()
 {
     // If admin, allow simulation of another user
     $this->simUser = 0;
     $this->simulateSelector = '';
     unset($this->OLD_BE_USER);
     if ($GLOBALS['BE_USER']->isAdmin()) {
         $this->simUser = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('simUser'));
         // Make user-selector:
         $users = \TYPO3\CMS\Backend\Utility\BackendUtility::getUserNames('username,usergroup,usergroup_cached_list,uid,realName', \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('be_users'));
         $opt = array();
         foreach ($users as $rr) {
             if ($rr['uid'] != $GLOBALS['BE_USER']->user['uid']) {
                 $opt[] = '<option value="' . $rr['uid'] . '"' . ($this->simUser == $rr['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($rr['username'] . ' (' . $rr['realName'] . ')') . '</option>';
             }
         }
         if (count($opt)) {
             $this->simulateSelector = '<select ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' id="field_simulate" name="simulateUser" onchange="window.location.href=\'' . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('user_setup') . '&simUser=\'+this.options[this.selectedIndex].value;"><option></option>' . implode('', $opt) . '</select>';
         }
     }
     // This can only be set if the previous code was executed.
     if ($this->simUser > 0) {
         // Save old user...
         $this->OLD_BE_USER = $GLOBALS['BE_USER'];
         unset($GLOBALS['BE_USER']);
         // Unset current
         // New backend user object
         $BE_USER = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
         $BE_USER->OS = TYPO3_OS;
         $BE_USER->setBeUserByUid($this->simUser);
         $BE_USER->fetchGroupData();
         $BE_USER->backendSetUC();
         // Must do this, because unsetting $BE_USER before apparently unsets the reference to the global variable by this name!
         $GLOBALS['BE_USER'] = $BE_USER;
     }
 }
Exemplo n.º 28
0
    /**
     * Indexing records from a table
     *
     * @param array $cfgRec Indexing Configuration Record
     * @param array $session_data Session data for the indexing session spread over multiple instances of the script. Passed by reference so changes hereto will be saved for the next call!
     * @param array $params Parameters from the log queue.
     * @param object $pObj Parent object (from "crawler" extension!)
     * @return void
     */
    public function crawler_execute_type1($cfgRec, &$session_data, $params, &$pObj)
    {
        if ($cfgRec['table2index'] && isset($GLOBALS['TCA'][$cfgRec['table2index']])) {
            // Init session data array if not already:
            if (!is_array($session_data)) {
                $session_data = array('uid' => 0);
            }
            // Init:
            $pid = (int) $cfgRec['alternative_source_pid'] ?: $cfgRec['pid'];
            $numberOfRecords = $cfgRec['recordsbatch'] ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($cfgRec['recordsbatch'], 1) : 100;
            // Get root line:
            $rl = $this->getUidRootLineForClosestTemplate($cfgRec['pid']);
            // Select
            $recs = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $cfgRec['table2index'], 'pid = ' . $pid . '
							AND uid > ' . (int) $session_data['uid'] . BackendUtility::deleteClause($cfgRec['table2index']) . BackendUtility::BEenableFields($cfgRec['table2index']), '', 'uid', $numberOfRecords);
            // Traverse:
            if (!empty($recs)) {
                foreach ($recs as $r) {
                    // Index single record:
                    $this->indexSingleRecord($r, $cfgRec, $rl);
                    // Update the UID we last processed:
                    $session_data['uid'] = $r['uid'];
                }
                // Finally, set entry for next indexing of batch of records:
                $nparams = array('indexConfigUid' => $cfgRec['uid'], 'url' => 'Records from UID#' . ($r['uid'] + 1) . '-?', 'procInstructions' => array('[Index Cfg UID#' . $cfgRec['uid'] . ']'));
                $pObj->addQueueEntry_callBack($cfgRec['set_id'], $nparams, $this->callBack, $cfgRec['pid']);
            }
        }
    }
Exemplo n.º 29
0
 /**
  * Get the count of news records by month/year and
  * returns the result compiled as array
  *
  * @param DemandInterface $demand
  * @return array
  */
 public function countByDate(DemandInterface $demand)
 {
     $data = [];
     $sql = $this->findDemandedRaw($demand);
     // Get the month/year into the result
     $field = $demand->getDateField();
     $field = empty($field) ? 'datetime' : $field;
     $sql = 'SELECT FROM_UNIXTIME(' . $field . ', "%m") AS "_Month",' . ' FROM_UNIXTIME(' . $field . ', "%Y") AS "_Year" ,' . ' count(FROM_UNIXTIME(' . $field . ', "%m")) as count_month,' . ' count(FROM_UNIXTIME(' . $field . ', "%y")) as count_year' . ' FROM tx_news_domain_model_news ' . substr($sql, strpos($sql, 'WHERE '));
     if (TYPO3_MODE === 'FE') {
         $sql .= $GLOBALS['TSFE']->sys_page->enableFields('tx_news_domain_model_news');
     } else {
         $sql .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tx_news_domain_model_news') . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tx_news_domain_model_news');
     }
     // strip unwanted order by
     $sql = $GLOBALS['TYPO3_DB']->stripOrderBy($sql);
     // group by custom month/year fields
     $orderDirection = strtolower($demand->getOrder());
     if ($orderDirection !== 'desc' && $orderDirection != 'asc') {
         $orderDirection = 'asc';
     }
     $sql .= ' GROUP BY _Month, _Year ORDER BY _Year ' . $orderDirection . ', _Month ' . $orderDirection;
     $res = $GLOBALS['TYPO3_DB']->sql_query($sql);
     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
         $data['single'][$row['_Year']][$row['_Month']] = $row['count_month'];
     }
     $GLOBALS['TYPO3_DB']->sql_free_result($res);
     // Add totals
     if (is_array($data['single'])) {
         foreach ($data['single'] as $year => $months) {
             $countOfYear = 0;
             foreach ($months as $month) {
                 $countOfYear += $month;
             }
             $data['total'][$year] = $countOfYear;
         }
     }
     return $data;
 }
Exemplo n.º 30
0
 /**
  * Fetched fresh storage records from database because the new imported
  * ones are not in cached data of the StorageRepository
  *
  * @return bool|array
  */
 protected function fetchStorageRecords()
 {
     $whereClause = BackendUtility::BEenableFields('sys_file_storage');
     $whereClause .= BackendUtility::deleteClause('sys_file_storage');
     $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_file_storage', '1=1' . $whereClause, '', '', '', 'uid');
     return $rows;
 }