Beispiel #1
0
 /**
  * Initializes the Module
  * @return    void
  */
 function init()
 {
     /*{{{*/
     global $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
     parent::init();
     $this->enableFields_tickets = t3lib_BEfunc::deleteClause($this->tickets_table) . t3lib_BEfunc::BEenableFields($this->tickets_table);
     $this->enableFields_fe_users = t3lib_BEfunc::deleteClause($this->users_table) . t3lib_BEfunc::BEenableFields($this->users_table);
     $this->enableFields_category = t3lib_BEfunc::deleteClause($this->category_table) . t3lib_BEfunc::BEenableFields($this->category_table);
     $this->enableFields_address = t3lib_BEfunc::deleteClause($this->address_table) . t3lib_BEfunc::BEenableFields($this->address_table);
     $this->enableFields_pages = t3lib_BEfunc::deleteClause($this->pages_table) . t3lib_BEfunc::BEenableFields($this->pages_table);
     $this->lib = t3lib_div::makeInstance('tx_ketroubletickets_lib');
     // get the page ts config
     $this->pageTSConfig = t3lib_BEfunc::getPagesTSconfig($this->id);
     /*
     if (t3lib_div::_GP('clear_all_cache'))    {
         $this->include_once[] = PATH_t3lib.'class.t3lib_tcemain.php';
     }
     */
 }
 /**
  * Import from t3lib_page in order to eate backend version
  * Creates language-overlay for records in general (where translation is found in records from the same table)
  *
  * @param	string		$table: Table name
  * @param	array		$row: Record to overlay. Must containt uid, pid and $table]['ctrl']['languageField']
  * @param	integer		$sys_language_content: Pointer to the sys_language uid for content on the site.
  * @param	string		$OLmode: Overlay mode. If "hideNonTranslated" then records without translation will not be returned un-translated but unset (and return value is false)
  * @return	mixed		Returns the input record, possibly overlaid with a translation. But if $OLmode is "hideNonTranslated" then it will return false if no translation is found.
  */
 function getRecordOverlay($table, $row, $sys_language_content, $OLmode = '')
 {
     global $TCA, $TYPO3_DB;
     if ($row['uid'] > 0 && $row['pid'] > 0) {
         if ($TCA[$table] && $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField']) {
             if (!$TCA[$table]['ctrl']['transOrigPointerTable']) {
                 // Will try to overlay a record only if the sys_language_content value is larger that zero.
                 if ($sys_language_content > 0) {
                     // Must be default language or [All], otherwise no overlaying:
                     if ($row[$TCA[$table]['ctrl']['languageField']] <= 0) {
                         // Select overlay record:
                         $res = $TYPO3_DB->exec_SELECTquery('*', $table, 'pid=' . intval($row['pid']) . ' AND ' . $TCA[$table]['ctrl']['languageField'] . '=' . intval($sys_language_content) . ' AND ' . $TCA[$table]['ctrl']['transOrigPointerField'] . '=' . intval($row['uid']) . t3lib_BEfunc::BEenableFields($table) . t3lib_BEfunc::deleteClause($table), '', '', '1');
                         $olrow = $TYPO3_DB->sql_fetch_assoc($res);
                         // Merge record content by traversing all fields:
                         if (is_array($olrow)) {
                             foreach ($row as $fN => $fV) {
                                 if ($fN != 'uid' && $fN != 'pid' && isset($olrow[$fN])) {
                                     if ($TCA[$table]['l10n_mode'][$fN] != 'exclude' && ($TCA[$table]['l10n_mode'][$fN] != 'mergeIfNotBlank' || strcmp(trim($olrow[$fN]), ''))) {
                                         $row[$fN] = $olrow[$fN];
                                     }
                                 }
                             }
                         } elseif ($OLmode === 'hideNonTranslated' && $row[$TCA[$table]['ctrl']['languageField']] == 0) {
                             // Unset, if non-translated records should be hidden. ONLY done if the source record really is default language and not [All] in which case it is allowed.
                             unset($row);
                         }
                         // Otherwise, check if sys_language_content is different from the value of the record - that means a japanese site might try to display french content.
                     } elseif ($sys_language_content != $row[$TCA[$table]['ctrl']['languageField']]) {
                         unset($row);
                     }
                 } else {
                     // When default language is displayed, we never want to return a record carrying another language!:
                     if ($row[$TCA[$table]['ctrl']['languageField']] > 0) {
                         unset($row);
                     }
                 }
             }
         }
     }
     return $row;
 }
 /**
  * Make sure a backend user exists and is configured properly.
  *
  * @access	protected
  *
  * @param	boolean		$checkOnly: Just check the user or change it, too?
  * @param	integer		$groupUid: UID of the corresponding usergroup
  *
  * @return	integer		UID of user or 0 if something is wrong
  */
 protected function checkCliUser($checkOnly, $groupUid)
 {
     // Set default return value.
     $usrUid = 0;
     // Check if user "_cli_dlf" exists, is no admin and is not disabled.
     $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,admin,usergroup', 'be_users', 'username='******'TYPO3_DB']->fullQuoteStr('_cli_dlf', 'be_users') . t3lib_BEfunc::deleteClause('be_users'));
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
         $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
         // Explode comma-separated list.
         $resArray['usergroup'] = explode(',', $resArray['usergroup']);
         // Check if user is not disabled.
         $result2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('1', 'be_users', 'uid=' . intval($resArray['uid']) . t3lib_BEfunc::BEenableFields('be_users'));
         // Check if user is configured properly.
         if (count(array_diff(array($groupUid), $resArray['usergroup'])) == 0 && !$resArray['admin'] && $GLOBALS['TYPO3_DB']->sql_num_rows($result2) > 0) {
             $usrUid = $resArray['uid'];
             $message = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('cliUserGroup.usrOkayMsg'), $GLOBALS['LANG']->getLL('cliUserGroup.usrOkay'), t3lib_FlashMessage::OK, FALSE);
         } else {
             if (!$checkOnly && $groupUid) {
                 // Keep exisiting values and add the new ones.
                 $usergroup = array_unique(array_merge(array($groupUid), $resArray['usergroup']));
                 // Try to configure user.
                 $data['be_users'][$resArray['uid']] = array('admin' => 0, 'usergroup' => implode(',', $usergroup), $GLOBALS['TCA']['be_users']['ctrl']['enablecolumns']['disabled'] => 0, $GLOBALS['TCA']['be_users']['ctrl']['enablecolumns']['starttime'] => 0, $GLOBALS['TCA']['be_users']['ctrl']['enablecolumns']['endtime'] => 0);
                 tx_dlf_helper::processDBasAdmin($data);
                 // Check if configuration was successful.
                 if ($this->checkCliUser(TRUE, $groupUid)) {
                     $usrUid = $resArray['uid'];
                     $message = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('cliUserGroup.usrConfiguredMsg'), $GLOBALS['LANG']->getLL('cliUserGroup.usrConfigured'), t3lib_FlashMessage::INFO, FALSE);
                 } else {
                     $message = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('cliUserGroup.usrNotConfiguredMsg'), $GLOBALS['LANG']->getLL('cliUserGroup.usrNotConfigured'), t3lib_FlashMessage::ERROR, FALSE);
                 }
             } else {
                 $message = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('cliUserGroup.usrNotConfiguredMsg'), $GLOBALS['LANG']->getLL('cliUserGroup.usrNotConfigured'), t3lib_FlashMessage::ERROR, FALSE);
             }
         }
     } else {
         if (!$checkOnly && $groupUid) {
             // Try to create user.
             $tempUid = uniqid('NEW');
             $data['be_users'][$tempUid] = array('pid' => 0, 'username' => '_cli_dlf', 'password' => md5($tempUid), 'realName' => $GLOBALS['LANG']->getLL('cliUserGroup.usrRealName'), 'usergroup' => intval($groupUid));
             $substUid = tx_dlf_helper::processDBasAdmin($data);
             // Check if creation was successful.
             if (!empty($substUid[$tempUid])) {
                 $usrUid = $substUid[$tempUid];
                 $message = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('cliUserGroup.usrCreatedMsg'), $GLOBALS['LANG']->getLL('cliUserGroup.usrCreated'), t3lib_FlashMessage::INFO, FALSE);
             } else {
                 $message = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('cliUserGroup.usrNotCreatedMsg'), $GLOBALS['LANG']->getLL('cliUserGroup.usrNotCreated'), t3lib_FlashMessage::ERROR, FALSE);
             }
         } else {
             $message = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('cliUserGroup.usrNotCreatedMsg'), $GLOBALS['LANG']->getLL('cliUserGroup.usrNotCreated'), t3lib_FlashMessage::ERROR, FALSE);
         }
     }
     $this->content = $message->render();
     return $usrUid;
 }
Beispiel #4
0
 /**
  * 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()
 {
     global $BE_USER, $LANG, $BACK_PATH;
     // *******************************************************************************
     // If admin, allow simulation of another user
     // *******************************************************************************
     $this->simUser = 0;
     $this->simulateSelector = '';
     unset($this->OLD_BE_USER);
     if ($BE_USER->isAdmin()) {
         $this->simUser = intval(t3lib_div::_GP('simUser'));
         // Make user-selector:
         $users = t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName', t3lib_BEfunc::BEenableFields('be_users'));
         $opt = array();
         foreach ($users as $rr) {
             if ($rr['uid'] != $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 id="field_simulate" name="simulateUser" onchange="window.location.href=\'index.php?simUser=\'+this.options[this.selectedIndex].value;"><option></option>' . implode('', $opt) . '</select>';
         }
     }
     if ($this->simUser > 0) {
         // This can only be set if the previous code was executed.
         $this->OLD_BE_USER = $BE_USER;
         // Save old user...
         unset($BE_USER);
         // Unset current
         $BE_USER = t3lib_div::makeInstance('t3lib_beUserAuth');
         // New backend user object
         $BE_USER->OS = TYPO3_OS;
         $BE_USER->setBeUserByUid($this->simUser);
         $BE_USER->fetchGroupData();
         $BE_USER->backendSetUC();
         $GLOBALS['BE_USER'] = $BE_USER;
         // Must do this, because unsetting $BE_USER before apparently unsets the reference to the global variable by this name!
     }
 }
	/**
	 *
	 * @param	array	$conf
	 */
	protected function getDsRecords($conf) {
		$updateMessage = '';
		$writeDsIds = array();
		$writeIds = t3lib_div::_GP('staticDSwizard');
		$options = t3lib_div::_GP('staticDSwizardoptions');
		$checkAll = t3lib_div::_GP('sdw-checkall');

		if (count($writeIds)) {
			$writeDsIds = array_keys($writeIds);
		}
		$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
			'*',
			'tx_templavoila_datastructure',
			'deleted=0',
			'',
			'scope, title'
		);
		$out = '<table id="staticDSwizard_getdsrecords"><thead>
			<tr class="bgColor5">
				<td style="vertical-align:middle;">' . $GLOBALS['LANG']->sL('LLL:EXT:templavoila/res1/language/template_conf.xml:staticDS.wizard.uid') . '</td>
				<td style="vertical-align:middle;">' . $GLOBALS['LANG']->sL('LLL:EXT:templavoila/res1/language/template_conf.xml:staticDS.wizard.pid') . '</td>
				<td style="vertical-align:middle;">' . $GLOBALS['LANG']->sL('LLL:EXT:templavoila/res1/language/template_conf.xml:staticDS.wizard.title') . '</td>
				<td style="vertical-align:middle;">' . $GLOBALS['LANG']->sL('LLL:EXT:templavoila/res1/language/template_conf.xml:staticDS.wizard.scope') . '</td>
				<td style="vertical-align:middle;">' . $GLOBALS['LANG']->sL('LLL:EXT:templavoila/res1/language/template_conf.xml:staticDS.wizard.usage') . '</td>
			<td>
				<label for="sdw-checkall">' . $GLOBALS['LANG']->sL('LLL:EXT:templavoila/res1/language/template_conf.xml:staticDS.wizard.selectall') . '</label>
				<input type="checkbox" class="checkbox" id="sdw-checkall" name="sdw-checkall" onclick="$$(\'.staticDScheck\').each(function(e){e.checked=$(\'sdw-checkall\').checked;});" value="1" ' . ($checkAll
				? 'checked="checked"' : '') . ' /></td>
		</tr></thead><tbody>';
		foreach ($rows as $row) {
			$dirPath = t3lib_div::getFileAbsFileName($row['scope'] == 2 ? $conf['path_fce'] : $conf['path_page']);
			$dirPath = $dirPath . (substr($dirPath, -1) == '/' ? '' : '/');
			$title = preg_replace('|[/,\."\']+|', '_', $row['title']);
			$path = $dirPath . $title . ' (' . ($row['scope'] == 1 ? 'page' : 'fce') . ').xml';
			$outPath = substr($path, strlen(PATH_site));

			$usage = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
				'count(*)',
				'tx_templavoila_tmplobj',
				'datastructure=' . (int)$row['uid'] . t3lib_BEfunc::BEenableFields('tx_templavoila_tmplobj')
			);
			if (count($writeDsIds) && in_array($row['uid'], $writeDsIds)) {
				t3lib_div::writeFile($path, $row['dataprot']);
				if ($row['previewicon']) {
					copy(t3lib_div::getFileAbsFileName('uploads/tx_templavoila/' . $row['previewicon']), $dirPath . $title . ' (' . ($row['scope'] == 1
							? 'page' : 'fce') . ').gif');
				}
				if ($options['updateRecords']) {
					// remove DS records
					$GLOBALS['TYPO3_DB']->exec_UPDATEquery(
						'tx_templavoila_datastructure',
						'uid="' . $row['uid'] . '"',
						array('deleted' => 1)
					);
					// update TO records
					$GLOBALS['TYPO3_DB']->exec_UPDATEquery(
						'tx_templavoila_tmplobj',
						'datastructure="' . $row['uid'] . '"',
						array('datastructure' => $outPath)
					);
					// update page records
					$GLOBALS['TYPO3_DB']->exec_UPDATEquery(
						'pages',
						'tx_templavoila_ds="' . $row['uid'] . '"',
						array('tx_templavoila_ds' => $outPath)
					);
					$GLOBALS['TYPO3_DB']->exec_UPDATEquery(
						'pages',
						'tx_templavoila_next_ds="' . $row['uid'] . '"',
						array('tx_templavoila_next_ds' => $outPath)
					);
					// update tt_content records
					$GLOBALS['TYPO3_DB']->exec_UPDATEquery(
						'tt_content',
						'tx_templavoila_ds="' . $row['uid'] . '"',
						array('tx_templavoila_ds' => $outPath)
					);
					// delete DS records
					$GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_templavoila_datastructure', 'uid=' . $row['uid'], array('deleted' => 1));
					$updateMessage = $GLOBALS['LANG']->sL('LLL:EXT:templavoila/res1/language/template_conf.xml:staticDS.wizard.updated');
					$this->step = 3;
				}


			}
			$out .= '<tr class="bgColor' . ($row['scope'] == 1 ? 3 : 6) . '">
			<td style="text-align: center;padding: 0,3px;">' . $row['uid'] . '</td>
			<td style="text-align: center;padding: 0,3px;">' . $row['pid'] . '</td>
			<td style="padding: 0,3px;">' . htmlspecialchars($row['title']) . '</td>
			<td style="padding: 0,3px;">' . ($row['scope'] == 1 ? 'Page' : 'FCE') . '</td>
			<td style="text-align: center;padding: 0,3px;">' . $usage[0]['count(*)'] . '</td>';
			if (count($writeDsIds) && in_array($row['uid'], $writeDsIds)) {
				$out .= '<td class="nobr" style="text-align: right;padding: 0,3px;">written to "' . $outPath . '"</td>';
			} else {
				$out .= '<td class="nobr" style="text-align: right;padding: 0,3px;"><input type="checkbox" class="checkbox staticDScheck" name="staticDSwizard[' . $row['uid'] . ']" value="1" /></td>';
			}
			$out .= '</tr>';
		}
		$out .= '</tbody></table>';

		if ($conf['enable']) {
			if ($updateMessage) {
				$out .= '<p>' . $updateMessage . '</p><p><strong>' . $GLOBALS['LANG']->sL('LLL:EXT:templavoila/res1/language/template_conf.xml:staticDS.wizard.clearcache') . '</strong></p>';
			} else {
				$out .= '<h4>' . $GLOBALS['LANG']->sL('LLL:EXT:templavoila/res1/language/template_conf.xml:staticDS.wizard.description2.1') . '</h4>';
				$out .= '<p>
				<input type="checkbox" class="checkbox" name="staticDSwizardoptions[updateRecords]" id="sdw-updateRecords" value="1" />
				<label for="sdw-updateRecords">' . $GLOBALS['LANG']->sL('LLL:EXT:templavoila/res1/language/template_conf.xml:staticDS.wizard.updaterecords') . '</label><br />
				</p>';
			}
		}
		return $out;
	}
 /**
  * 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
  */
 function getLanguages()
 {
     $where = '1=1';
     $table = 'static_languages';
     $lang = tx_staticinfotables_div::getCurrentLanguage();
     $nameArray = array();
     $titleFields = tx_staticinfotables_div::getTCAlabelField($table, TRUE, $lang);
     $prefixedTitleFields = array();
     foreach ($titleFields as $titleField) {
         $prefixedTitleFields[] = $table . '.' . $titleField;
     }
     $labelFields = implode(',', $prefixedTitleFields);
     // Restrict to certain languages
     if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['language.']) && isset($this->thisConfig['buttons.']['language.']['restrictToItems'])) {
         $languageList = implode("','", t3lib_div::trimExplode(',', $GLOBALS['TYPO3_DB']->fullQuoteStr(strtoupper($this->thisConfig['buttons.']['language.']['restrictToItems']), $table)));
         $where .= ' AND ' . $table . '.lg_iso_2 IN (' . $languageList . ')';
     }
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($table . '.lg_iso_2,' . $table . '.lg_country_iso_2,' . $labelFields, $table, $where . ' AND lg_constructed = 0 ' . ($this->htmlAreaRTE->is_FE() ? $GLOBALS['TSFE']->sys_page->enableFields($table) : t3lib_BEfunc::BEenableFields($table) . t3lib_BEfunc::deleteClause($table)));
     $prefixLabelWithCode = !$this->thisConfig['buttons.']['language.']['prefixLabelWithCode'] ? false : true;
     $postfixLabelWithCode = !$this->thisConfig['buttons.']['language.']['postfixLabelWithCode'] ? false : true;
     while ($row = $GLOBALS['TYPO3_DB']->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;
             }
         }
     }
     $GLOBALS['TYPO3_DB']->sql_free_result($res);
     if ($this->htmlAreaRTE->is_FE()) {
         $GLOBALS['TSFE']->csConvObj->convArray($nameArray, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['static_info_tables']['charset'], $this->htmlAreaRTE->OutputCharset);
     } else {
         $GLOBALS['LANG']->csConvObj->convArray($nameArray, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['static_info_tables']['charset'], $GLOBALS['LANG']->charSet);
     }
     uasort($nameArray, 'strcoll');
     return $nameArray;
 }
    /**
     * Indexing records from a table
     *
     * @param	array		Indexing Configuration Record
     * @param	array		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		Parameters from the log queue.
     * @param	object		Parent object (from "crawler" extension!)
     * @return	void
     */
    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 = intval($cfgRec['alternative_source_pid']) ? intval($cfgRec['alternative_source_pid']) : $cfgRec['pid'];
            $numberOfRecords = $cfgRec['recordsbatch'] ? t3lib_div::intInRange($cfgRec['recordsbatch'], 1) : 100;
            // Get root line:
            $rl = $this->getUidRootLineForClosestTemplate($cfgRec['pid']);
            // Select
            $recs = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $cfgRec['table2index'], 'pid = ' . intval($pid) . '
							AND uid > ' . intval($session_data['uid']) . t3lib_BEfunc::deleteClause($cfgRec['table2index']) . t3lib_BEfunc::BEenableFields($cfgRec['table2index']), '', 'uid', $numberOfRecords);
            // Traverse:
            if (count($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']);
            }
        }
    }
 /**
  * Returns the title for the input record. If blank, a "no title" label (localized) will be returned.
  * Do NOT htmlspecialchar the string from this function - has already been done.
  *
  * @param	array		The input row array (where the key "title" is used for the title)
  * @param	integer		Title length (30)
  * @return	string		The title.
  */
 function getTitleStr($row, $titleLen = 30)
 {
     // get the basic title from the parent implementation in t3lib_treeview
     $title = parent::getTitleStr($row, $titleLen);
     if (isset($row['is_siteroot']) && $row['is_siteroot'] != 0 && $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showDomainNameWithTitle')) {
         $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('domainName,sorting', 'sys_domain', 'pid=' . $GLOBALS['TYPO3_DB']->quoteStr($row['uid'] . t3lib_BEfunc::deleteClause('sys_domain') . t3lib_BEfunc::BEenableFields('sys_domain'), 'sys_domain'), '', 'sorting', 1);
         if (is_array($rows) && count($rows) > 0) {
             $title = sprintf('%s [%s]', $title, htmlspecialchars($rows[0]['domainName']));
         }
     }
     return $title;
 }
 /**
  * Creates HTML for inserting/moving content elements.
  *
  * @param	integer		page id onto which to insert content element.
  * @param	integer		Move-uid (tt_content element uid?)
  * @param	string		List of columns to show
  * @param	boolean		If not set, then hidden/starttime/endtime records are filtered out.
  * @param	string		Request URI
  * @return	string		HTML
  */
 function printContentElementColumns($pid, $moveUid, $colPosList, $showHidden, $R_URI)
 {
     $this->R_URI = $R_URI;
     $this->moveUid = $moveUid;
     $colPosArray = t3lib_div::trimExplode(',', $colPosList, 1);
     $lines = array();
     foreach ($colPosArray as $kk => $vv) {
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . intval($pid) . ($showHidden ? '' : t3lib_BEfunc::BEenableFields('tt_content')) . ' AND colPos=' . intval($vv) . (strcmp($this->cur_sys_language, '') ? ' AND sys_language_uid=' . intval($this->cur_sys_language) : '') . t3lib_BEfunc::deleteClause('tt_content') . t3lib_BEfunc::versioningPlaceholderClause('tt_content'), '', 'sorting');
         $lines[$kk] = array();
         $lines[$kk][] = $this->insertPositionIcon('', $vv, $kk, $moveUid, $pid);
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             t3lib_BEfunc::workspaceOL('tt_content', $row);
             if (is_array($row)) {
                 $lines[$kk][] = $this->wrapRecordHeader($this->getRecordHeader($row), $row);
                 $lines[$kk][] = $this->insertPositionIcon($row, $vv, $kk, $moveUid, $pid);
             }
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($res);
     }
     return $this->printRecordMap($lines, $colPosArray);
 }
Beispiel #10
0
 /**
  * Gets news from sys_news and converts them into a format suitable for
  * showing them at the login screen.
  *
  * @return	array	An array of login news.
  */
 protected function getSystemNews()
 {
     $systemNewsTable = 'sys_news';
     $systemNews = array();
     $systemNewsRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('title, content, crdate', $systemNewsTable, '1=1' . t3lib_BEfunc::BEenableFields($systemNewsTable) . t3lib_BEfunc::deleteClause($systemNewsTable), '', 'crdate DESC');
     foreach ($systemNewsRecords as $systemNewsRecord) {
         $systemNews[] = array('date' => date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $systemNewsRecord['crdate']), 'header' => $systemNewsRecord['title'], 'content' => $systemNewsRecord['content']);
     }
     return $systemNews;
 }
    /**
     * 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!
     */
    function drawRTE($parentObject, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue)
    {
        global $BE_USER, $LANG, $TYPO3_DB, $TYPO3_CONF_VARS;
        $this->TCEform = $parentObject;
        $inline = $this->TCEform->inline;
        $LANG->includeLLFile('EXT:' . $this->ID . '/locallang.xml');
        $this->client = $this->clientInfo();
        $this->typoVersion = t3lib_div::int_from_ver(TYPO3_version);
        $this->userUid = 'BE_' . $BE_USER->user['uid'];
        // Draw form element:
        if ($this->debugMode) {
            // Draws regular text area (debug mode)
            $item = parent::drawRTE($this->TCEform, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
        } else {
            // Draw real RTE
            /* =======================================
             * INIT THE EDITOR-SETTINGS
             * =======================================
             */
            // Set backPath
            $this->backPath = $this->TCEform->backPath;
            // Get the path to this extension:
            $this->extHttpPath = $this->backPath . t3lib_extMgm::extRelPath($this->ID);
            // Get the site URL
            $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
            // Get the host URL
            $this->hostURL = $this->siteURL . TYPO3_mainDir;
            // Element ID + pid
            $this->elementId = $PA['itemFormElName'];
            // Form element name
            $this->elementParts = explode('][', preg_replace('/\\]$/', '', preg_replace('/^(TSFE_EDIT\\[data\\]\\[|data\\[)/', '', $this->elementId)));
            // Find the page PIDs:
            list($this->tscPID, $this->thePid) = t3lib_BEfunc::getTSCpid(trim($this->elementParts[0]), trim($this->elementParts[1]), $thePidValue);
            // Record "types" field value:
            $this->typeVal = $RTEtypeVal;
            // TCA "types" value for record
            // Find "thisConfig" for record/editor:
            unset($this->RTEsetup);
            $this->RTEsetup = $BE_USER->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($this->tscPID));
            $this->thisConfig = $thisConfig;
            // Special configuration 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);
            }
            /* =======================================
             * LANGUAGES & CHARACTER SETS
             * =======================================
             */
            // Languages: interface and content
            $this->language = $LANG->lang;
            if ($this->language == 'default' || !$this->language) {
                $this->language = 'en';
            }
            $this->contentTypo3Language = $this->language;
            $this->contentISOLanguage = 'en';
            $this->contentLanguageUid = $row['sys_language_uid'] > 0 ? $row['sys_language_uid'] : 0;
            if (t3lib_extMgm::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 .= t3lib_BEfunc::BEenableFields($tableA);
                    $whereClause .= t3lib_BEfunc::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 = trim($this->thisConfig['defaultContentLanguage']) ? trim($this->thisConfig['defaultContentLanguage']) : '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']));
                    }
                }
            }
            // Character sets: interface and content
            $this->charset = $LANG->charSet;
            $this->OutputCharset = $this->charset;
            $this->contentCharset = $LANG->csConvObj->charSetArray[$this->contentTypo3Language];
            $this->contentCharset = $this->contentCharset ? $this->contentCharset : 'iso-8859-1';
            $this->origContentCharSet = $this->contentCharset;
            $this->contentCharset = trim($TYPO3_CONF_VARS['BE']['forceCharset']) ? trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->contentCharset;
            /* =======================================
             * TOOLBAR CONFIGURATION
             * =======================================
             */
            $this->initializeToolbarConfiguration();
            /* =======================================
             * SET STYLES
             * =======================================
             */
            $RTEWidth = isset($BE_USER->userTS['options.']['RTESmallWidth']) ? $BE_USER->userTS['options.']['RTESmallWidth'] : '530';
            $RTEHeight = isset($BE_USER->userTS['options.']['RTESmallHeight']) ? $BE_USER->userTS['options.']['RTESmallHeight'] : '380';
            $RTEWidth = $RTEWidth + ($this->TCEform->docLarge ? isset($BE_USER->userTS['options.']['RTELargeWidthIncrement']) ? $BE_USER->userTS['options.']['RTELargeWidthIncrement'] : '150' : 0);
            $RTEWidth -= $inline->getStructureDepth() > 0 ? ($inline->getStructureDepth() + 1) * $inline->getLevelMargin() : 0;
            if (isset($this->thisConfig['RTEWidthOverride'])) {
                if (strstr($this->thisConfig['RTEWidthOverride'], '%')) {
                    if ($this->client['browser'] != 'msie') {
                        $RTEWidth = intval($this->thisConfig['RTEWidthOverride']) > 0 ? $this->thisConfig['RTEWidthOverride'] : '100%';
                    }
                } else {
                    $RTEWidth = intval($this->thisConfig['RTEWidthOverride']) > 0 ? intval($this->thisConfig['RTEWidthOverride']) : $RTEWidth;
                }
            }
            $RTEWidth = strstr($RTEWidth, '%') ? $RTEWidth : $RTEWidth . 'px';
            $RTEHeight = $RTEHeight + ($this->TCEform->docLarge ? isset($BE_USER->userTS['options.']['RTELargeHeightIncrement']) ? $BE_USER->userTS['options.']['RTELargeHeightIncrement'] : 0 : 0);
            $RTEHeightOverride = intval($this->thisConfig['RTEHeightOverride']);
            $RTEHeight = $RTEHeightOverride > 0 ? $RTEHeightOverride : $RTEHeight;
            $editorWrapWidth = '99%';
            $editorWrapHeight = '100%';
            $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:' . $RTEHeight . 'px; width:' . $RTEWidth . '; border: 1px solid black; padding: 2px 2px 2px 2px;';
            /* =======================================
             * LOAD CSS AND JAVASCRIPT
             * =======================================
             */
            // Preloading the pageStyle and including RTE skin stylesheets
            $this->addPageStyle();
            $this->addSkin();
            // Loading JavaScript files and code
            if ($this->TCEform->RTEcounter == 1) {
                $this->TCEform->additionalJS_pre['rtehtmlarea-loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter);
            }
            $this->TCEform->additionalCode_pre['rtehtmlarea-loadJSfiles'] = $this->loadJSfiles($this->TCEform->RTEcounter);
            $pageRenderer = $GLOBALS['SOBE']->doc->getPageRenderer();
            $pageRenderer->enableExtJSQuickTips();
            if (!$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->ID]['enableCompressedScripts']) {
                $pageRenderer->enableExtJsDebug();
            }
            /* =======================================
             * 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);
                }
            }
            // Register RTE windows
            $this->TCEform->RTEwindows[] = $PA['itemFormElName'];
            $textAreaId = htmlspecialchars($PA['itemFormElName']);
            // Check if wizard_rte called this for fullscreen edtition; if so, change the size of the RTE to fullscreen using JS
            if (basename(PATH_thisScript) == 'wizard_rte.php') {
                $this->fullScreen = true;
                $editorWrapWidth = '100%';
                $editorWrapHeight = '100%';
                $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:100%; width:100%; border: 1px solid black; padding: 2px 0px 2px 2px;';
            }
            // Register RTE in JS:
            $this->TCEform->additionalJS_post[] = $this->registerRTEinJS($this->TCEform->RTEcounter, $table, $row['uid'], $field, $textAreaId);
            // Set the save option for the RTE:
            $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
            $this->TCEform->additionalJS_delete[] = $this->setDeleteRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
            // Draw the textarea
            $visibility = 'hidden';
            $item = $this->triggerField($PA['itemFormElName']) . '
				<div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $LANG->getLL('Please wait') . '</div>
				<div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; width:' . $editorWrapWidth . '; height:' . $editorWrapHeight . ';">
				<textarea id="RTEarea' . $textAreaId . '" name="' . htmlspecialchars($PA['itemFormElName']) . '" style="' . t3lib_div::deHSCentities(htmlspecialchars($this->RTEdivStyle)) . '">' . t3lib_div::formatForTextarea($value) . '</textarea>
				</div>' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableDebugMode'] ? '<div id="HTMLAreaLog"></div>' : '') . '
				';
        }
        // Return form item:
        return $item;
    }
Beispiel #12
0
 /**
  * Returns the number of hidden elements (including those hidden by start/end times) on the current page (for the current sys_language)
  *
  * @return	void
  */
 function getNumberOfHiddenElements()
 {
     return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'tt_content', 'pid=' . intval($this->id) . ' AND sys_language_uid=' . intval($this->current_sys_language) . t3lib_BEfunc::BEenableFields('tt_content', 1) . t3lib_BEfunc::deleteClause('tt_content') . t3lib_BEfunc::versioningPlaceholderClause('tt_content'));
 }
Beispiel #13
0
 /**
  * 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
  *						 0	if user exists, but is disabled
  *						 1	if user exists and is not disabled
  */
 protected function checkSchedulerUser()
 {
     $schedulerUserStatus = -1;
     // Assemble base WHERE clause
     $where = 'username = \'_cli_scheduler\' AND admin = 0' . t3lib_BEfunc::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 . t3lib_BEfunc::BEenableFields('be_users'));
         if ($GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $schedulerUserStatus = 1;
         }
     }
     $GLOBALS['TYPO3_DB']->sql_free_result($res);
     return $schedulerUserStatus;
 }
 /**
  * This method is called by a hook in the TYPO3 Core Engine (TCEmain) when a command was executed (copy,move,delete...).
  * For tt_news it is used to disable saving of the current record if it has an editlock or if it has categories assigned that are not allowed for the current BE user.
  *
  * @param	string		$command: The TCEmain command, fx. 'delete'
  * @param	string		$table: The table TCEmain is currently processing
  * @param	string		$id: The records id (if any)
  * @param	array		$value: The new value of the field which has been changed
  * @param	object		$pObj: Reference to the parent object (TCEmain)
  * @return	void
  * @access public
  */
 function processCmdmap_preProcess($command, &$table, &$id, $value, &$pObj)
 {
     if ($table == 'tt_news' && !$GLOBALS['BE_USER']->isAdmin()) {
         $rec = t3lib_BEfunc::getRecord($table, $id, 'editlock');
         // get record to check if it has an editlock
         if ($rec['editlock']) {
             $pObj->log($table, $id, 2, 0, 1, "processCmdmap [editlock]: Attempt to " . $command . " a record from table '%s' which is locked by an 'editlock' (= record can only be edited by admins).", 1, array($table));
             $error = true;
         }
         if (is_int($id)) {
             // get categories from the (untranslated) record in db
             $res = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tt_news_cat.uid, tt_news_cat.deleted, tt_news_cat_mm.sorting AS mmsorting', 'tt_news', 'tt_news_cat_mm', 'tt_news_cat', ' AND tt_news_cat.deleted=0 AND tt_news_cat_mm.uid_local=' . (is_int($id) ? $id : 0) . t3lib_BEfunc::BEenableFields('tt_news_cat'));
             $categories = array();
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 $categories[] = $row['uid'];
             }
             $GLOBALS['TYPO3_DB']->sql_free_result($res);
             $notAllowedItems = array();
             if ($categories[0]) {
                 // original record has no categories
                 $treeIDs = tx_ttnews_div::getAllowedTreeIDs();
                 if (count($treeIDs)) {
                     $allowedItems = $treeIDs;
                 } else {
                     $allowedItems = t3lib_div::intExplode(',', $GLOBALS['BE_USER']->getTSConfigVal('tt_newsPerms.tt_news_cat.allowedItems'));
                 }
                 foreach ($categories as $k) {
                     if (!in_array($k, $allowedItems)) {
                         $notAllowedItems[] = $k;
                     }
                 }
             }
             if ($notAllowedItems[0]) {
                 $pObj->log($table, $id, 2, 0, 1, "tt_news processCmdmap: Attempt to " . $command . " a record from table '%s' without permission. Reason: the record has one or more categories assigned that are not defined in your BE usergroup (tablename.allowedItems).", 1, array($table));
                 $error = true;
             }
             if ($error) {
                 $table = '';
                 // unset table to prevent saving
             }
         }
     }
 }
 /**
  * Returns the first configured domain name for a page
  *
  * @static
  * @param integer $uid
  * @return string
  */
 public static function getDomainName($uid)
 {
     $whereClause = $GLOBALS['TYPO3_DB']->quoteStr('pid=' . intval($uid) . t3lib_BEfunc::deleteClause('sys_domain') . t3lib_BEfunc::BEenableFields('sys_domain'), 'sys_domain');
     $domain = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('domainName', 'sys_domain', $whereClause, '', 'sorting');
     return htmlspecialchars($domain['domainName']);
 }
    /**
     * 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!
     */
    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 = t3lib_div::int_from_ver(TYPO3_version);
        /* =======================================
         * INIT THE EDITOR-SETTINGS
         * =======================================
         */
        // Get the path to this extension:
        $this->extHttpPath = t3lib_extMgm::siteRelPath($this->ID);
        // Get the site URL
        $this->siteURL = $GLOBALS['TSFE']->absRefPrefix ? $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;
        } else {
            if (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 = t3lib_div::readLLfile('EXT:' . $this->ID . '/locallang.xml', $this->language);
        if ($this->language == 'default' || !$this->language) {
            $this->language = 'en';
        }
        $this->contentLanguageUid = $row['sys_language_uid'] > 0 ? $row['sys_language_uid'] : 0;
        if (t3lib_extMgm::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 .= t3lib_BEfunc::BEenableFields($tableA);
                $whereClause .= t3lib_BEfunc::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 ? $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 ? $this->contentISOLanguage : ($GLOBALS['TSFE']->sys_language_isocode ? $GLOBALS['TSFE']->sys_language_isocode : 'en');
        $this->contentTypo3Language = $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->metaCharset : $TSFE->renderCharset;
        // Set the charset of the content
        $this->contentCharset = $TSFE->csConvObj->charSetArray[$this->contentTypo3Language];
        $this->contentCharset = $this->contentCharset ? $this->contentCharset : 'iso-8859-1';
        $this->contentCharset = trim($TSFE->config['config']['metaCharset']) ? trim($TSFE->config['config']['metaCharset']) : $this->contentCharset;
        /* =======================================
         * TOOLBAR CONFIGURATION
         * =======================================
         */
        $this->initializeToolbarConfiguration();
        /* =======================================
         * SET STYLES
         * =======================================
         */
        $width = 460 + ($this->TCEform->docLarge ? 150 : 0);
        if (isset($this->thisConfig['RTEWidthOverride'])) {
            if (strstr($this->thisConfig['RTEWidthOverride'], '%')) {
                if ($this->client['browser'] != 'msie') {
                    $width = intval($this->thisConfig['RTEWidthOverride']) > 0 ? $this->thisConfig['RTEWidthOverride'] : '100%';
                }
            } else {
                $width = intval($this->thisConfig['RTEWidthOverride']) > 0 ? intval($this->thisConfig['RTEWidthOverride']) : $width;
            }
        }
        $RTEWidth = strstr($width, '%') ? $width : $width . 'px';
        $editorWrapWidth = strstr($width, '%') ? $width : $width + 2 . 'px';
        $height = 380;
        $RTEHeightOverride = intval($this->thisConfig['RTEHeightOverride']);
        $height = $RTEHeightOverride > 0 ? $RTEHeightOverride : $height;
        $RTEHeight = $height . 'px';
        $editorWrapHeight = $height + 2 . 'px';
        $this->RTEWrapStyle = $this->RTEWrapStyle ? $this->RTEWrapStyle : ($this->RTEdivStyle ? $this->RTEdivStyle : 'height:' . $editorWrapHeight . '; width:' . $editorWrapWidth . ';');
        $this->RTEdivStyle = $this->RTEdivStyle ? $this->RTEdivStyle : 'position:relative; left:0px; top:0px; height:' . $RTEHeight . '; width:' . $RTEWidth . '; border: 1px solid black;';
        /* =======================================
         * LOAD JS, CSS and more
         * =======================================
         */
        $pageRenderer = $this->getPageRenderer();
        // Preloading the pageStyle and including RTE skin stylesheets
        $this->addPageStyle();
        $this->addSkin();
        // Re-initialize the scripts array so that only the cumulative set of plugins of the last RTE on the page is used
        $this->cumulativeScripts[$this->TCEform->RTEcounter] = array();
        $this->includeScriptFiles($this->TCEform->RTEcounter);
        $this->buildJSMainLangFile($this->TCEform->RTEcounter);
        // 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 (!$GLOBALS['TSFE']->isINTincScript() || !is_array($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.'])) {
            $pageRenderer->loadExtJs();
            $pageRenderer->enableExtJSQuickTips();
            if (!$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->ID]['enableCompressedScripts']) {
                $pageRenderer->enableExtJsDebug();
            }
        }
        $pageRenderer->addCssFile($this->siteURL . 't3lib/js/extjs/ux/resize.css');
        $pageRenderer->addJsFile($this->siteURL . 't3lib/js/extjs/ux/ext.resizable.js');
        $pageRenderer->addJsFile($this->siteURL . '/t3lib/js/extjs/notifications.js');
        if ($this->TCEform->RTEcounter == 1) {
            $this->TCEform->additionalJS_pre['rtehtmlarea-loadJScode'] = $this->wrapCDATA($this->loadJScode($this->TCEform->RTEcounter));
        }
        $this->TCEform->additionalJS_initial = $this->loadJSfiles($this->TCEform->RTEcounter);
        if ($GLOBALS['TSFE']->isINTincScript()) {
            $GLOBALS['TSFE']->additionalHeaderData['rtehtmlarea'] = $pageRenderer->render();
        }
        /* =======================================
         * 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) . '">' . t3lib_div::formatForTextarea($value) . '</textarea>
			</div>' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableDebugMode'] ? '<div id="HTMLAreaLog"></div>' : '') . '
			';
        return $item;
    }
 /**
  * Return an acronym array for the Acronym plugin
  *
  * @return	string		acronym Javascript array
  */
 function buildJSAcronymArray($languageUid)
 {
     $charset = $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] : 'iso-8859-1';
     $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(t3lib_div::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 = t3lib_div::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 = t3lib_div::makeInstance('t3lib_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("','", t3lib_div::trimExplode(',', $GLOBALS['TYPO3_DB']->fullQuoteStr(strtoupper($this->thisConfig['buttons.']['language.']['restrictToItems']), $tableB)));
         $whereClause .= ' AND ' . $tableB . '.lg_iso_2 IN (' . $languageList . ') ';
     }
     $whereClause .= t3lib_BEfunc::BEenableFields($tableA);
     $whereClause .= t3lib_BEfunc::deleteClause($tableA);
     $whereClause .= t3lib_BEfunc::BEenableFields($tableB);
     $whereClause .= t3lib_BEfunc::deleteClause($tableB);
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $tableAB, $whereClause);
     while ($acronymRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
         $item = array('term' => $GLOBALS['LANG']->csConvObj->utf8_encode($acronymRow['term'], $charset), 'abbr' => $GLOBALS['LANG']->csConvObj->utf8_encode($acronymRow['acronym'], $charset), 'language' => $GLOBALS['LANG']->csConvObj->utf8_encode(strtolower($acronymRow['lg_iso_2']), $charset) . ($acronymRow['lg_country_iso_2'] ? '-' . $acronymRow['lg_country_iso_2'] : ''));
         if ($acronymRow['type'] == 1) {
             $acronymArray[] = $item;
         } else {
             if ($acronymRow['type'] == 2) {
                 $abbrArray[] = $item;
             }
         }
     }
     $this->acronymIndex = count($acronymArray);
     $this->abbreviationIndex = count($abbrArray);
     return json_encode(array('abbr' => $abbrArray, 'acronym' => $acronymArray));
 }
 /**
  * get content of current page and save data to db
  * @param $uid page-UID that has to be indexed
  */
 public function getPageContent($uid)
 {
     $flex = $this->pageRecords[$uid]['tx_templavoila_flex'];
     if (empty($flex)) {
         return '';
     }
     if (TYPO3_VERSION_INTEGER >= 7000000) {
         $flex = TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($flex);
     } else {
         $flex = t3lib_div::xml2array($flex);
     }
     // TODO: Maybe I need a more detailed collection of retrieving CE UIDS
     $contentElementUids = array();
     if (!$this->indexerConfig['tvpath']) {
         $tvPaths = 'field_content';
     } else {
         $tvPaths = $this->indexerConfig['tvpath'];
     }
     if (TYPO3_VERSION_INTEGER >= 7000000) {
         $tvPaths = TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $tvPaths);
     } else {
         $tvPaths = t3lib_div::trimExplode(',', $tvPaths);
     }
     foreach ($tvPaths as $tvPath) {
         $contentElementUids[] = $flex['data']['sDEF']['lDEF'][$tvPath]['vDEF'];
     }
     if (TYPO3_VERSION_INTEGER >= 7000000) {
         $contentElementUids = TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList(implode(',', $contentElementUids));
     } else {
         $contentElementUids = t3lib_div::uniqueList(implode(',', $contentElementUids));
     }
     if (empty($contentElementUids)) {
         return '';
     }
     // TODO: Maybe it's good to check comma seperated list for int values
     // get content elements for this page
     $fields = '*';
     $table = 'tt_content';
     $where = 'uid IN (' . $contentElementUids . ')';
     $where .= ' AND (' . $this->whereClauseForCType . ')';
     if (TYPO3_VERSION_INTEGER >= 7000000) {
         $where .= TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table);
         $where .= TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table);
     } else {
         $where .= t3lib_BEfunc::BEenableFields($table);
         $where .= t3lib_BEfunc::deleteClause($table);
     }
     // if indexing of content elements with restrictions is not allowed
     // get only content elements that have empty group restrictions
     if ($this->indexerConfig['index_content_with_restrictions'] != 'yes') {
         $where .= ' AND (fe_group = "" OR fe_group = "0") ';
     }
     $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fields, $table, $where);
     if (count($rows)) {
         $this->counter++;
         foreach ($rows as $row) {
             // header
             // add header only if not set to "hidden"
             if ($row['header_layout'] != 100) {
                 $pageContent[$row['sys_language_uid']] .= strip_tags($row['header']) . "\n";
             }
             // bodytext
             $bodytext = $row['bodytext'];
             if ($row['CType'] == 'table') {
                 // replace table dividers with whitespace
                 $bodytext = str_replace('|', ' ', $bodytext);
             }
             if ($row['CType'] == 'templavoila_pi1') {
                 //$bodytext = $this->getContentForTV($row);
                 $bodytext = $this->tv->renderElement($row, 'tt_content');
             }
             // following lines prevents having words one after the other like: HelloAllTogether
             $bodytext = str_replace('<td', ' <td', $bodytext);
             $bodytext = str_replace('<br', ' <br', $bodytext);
             $bodytext = str_replace('<p', ' <p', $bodytext);
             $bodytext = str_replace('<li', ' <li', $bodytext);
             $bodytext = strip_tags($bodytext);
             $pageContent[$row['sys_language_uid']] .= $bodytext . "\n";
         }
     }
     // get Tags for current page
     $tags = $this->pageRecords[intval($uid)]['tags'];
     // make it possible to modify the indexerConfig via hook
     $indexerConfig = $this->indexerConfig;
     // hook for custom modifications of the indexed data, e. g. the tags
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyTemplaVoilaIndexEntry'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyTemplaVoilaIndexEntry'] as $_classRef) {
             if (TYPO3_VERSION_INTEGER >= 7000000) {
                 $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
             } else {
                 $_procObj =& t3lib_div::getUserObj($_classRef);
             }
             $_procObj->modifyPagesIndexEntry($uid, $pageContent, $tags, $this->cachedPageRecords, $additionalFields, $indexerConfig);
         }
     }
     // store record in index table
     foreach ($pageContent as $langKey => $content) {
         $this->pObj->storeInIndex($indexerConfig['storagepid'], $this->cachedPageRecords[$langKey][$uid]['title'], 'templavoila', $uid, $content, $tags, '', '', $langKey, $this->cachedPageRecords[$langKey][$uid]['starttime'], $this->cachedPageRecords[$langKey][$uid]['endtime'], $this->cachedPageRecords[$langKey][$uid]['fe_group'], false, $additionalFields);
     }
 }
    /**
     * Renders Content Elements from the tt_content table from page id
     *
     * @param	integer		Page id
     * @return	string		HTML for the listing
     */
    function getTable_tt_content($id)
    {
        global $TCA;
        $this->initializeLanguages();
        // Initialize:
        $RTE = $GLOBALS['BE_USER']->isRTE();
        $lMarg = 1;
        $showHidden = $this->tt_contentConfig['showHidden'] ? '' : t3lib_BEfunc::BEenableFields('tt_content');
        $pageTitleParamForAltDoc = '&recTitle=' . rawurlencode(t3lib_BEfunc::getRecordTitle('pages', t3lib_BEfunc::getRecordWSOL('pages', $id), TRUE));
        $GLOBALS['SOBE']->doc->getPageRenderer()->loadExtJs();
        $GLOBALS['SOBE']->doc->getPageRenderer()->addJsFile($GLOBALS['BACK_PATH'] . 'sysext/cms/layout/js/typo3pageModule.js');
        // Get labels for CTypes and tt_content element fields in general:
        $this->CType_labels = array();
        foreach ($TCA['tt_content']['columns']['CType']['config']['items'] as $val) {
            $this->CType_labels[$val[1]] = $GLOBALS['LANG']->sL($val[0]);
        }
        $this->itemLabels = array();
        foreach ($TCA['tt_content']['columns'] as $name => $val) {
            $this->itemLabels[$name] = $GLOBALS['LANG']->sL($val['label']);
        }
        // Select display mode:
        if (!$this->tt_contentConfig['single']) {
            // MULTIPLE column display mode, side by side:
            // Setting language list:
            $langList = $this->tt_contentConfig['sys_language_uid'];
            if ($this->tt_contentConfig['languageMode']) {
                if ($this->tt_contentConfig['languageColsPointer']) {
                    $langList = '0,' . $this->tt_contentConfig['languageColsPointer'];
                } else {
                    $langList = implode(',', array_keys($this->tt_contentConfig['languageCols']));
                }
                $languageColumn = array();
            }
            $langListArr = explode(',', $langList);
            $defLanguageCount = array();
            $defLangBinding = array();
            // For EACH languages... :
            foreach ($langListArr as $lP) {
                // If NOT languageMode, then we'll only be through this once.
                $showLanguage = $this->defLangBinding && $lP == 0 ? ' AND sys_language_uid IN (0,-1)' : ' AND sys_language_uid=' . $lP;
                $cList = explode(',', $this->tt_contentConfig['cols']);
                $content = array();
                $head = array();
                // For EACH column, render the content into a variable:
                foreach ($cList as $key) {
                    if (!$lP) {
                        $defLanguageCount[$key] = array();
                    }
                    // Select content elements from this column/language:
                    $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos=' . intval($key) . $showHidden . $showLanguage);
                    $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
                    // If it turns out that there are not content elements in the column, then display a big button which links directly to the wizard script:
                    if ($this->doEdit && $this->option_showBigButtons && !intval($key) && !$GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
                        $onClick = "window.location.href='db_new_content_el.php?id=" . $id . '&colPos=' . intval($key) . '&sys_language_uid=' . $lP . '&uid_pid=' . $id . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . "';";
                        $theNewButton = $GLOBALS['SOBE']->doc->t3Button($onClick, $GLOBALS['LANG']->getLL('newPageContent'));
                        $content[$key] .= '<img src="clear.gif" width="1" height="5" alt="" /><br />' . $theNewButton;
                    }
                    // Traverse any selected elements and render their display code:
                    $rowArr = $this->getResult($result);
                    foreach ($rowArr as $rKey => $row) {
                        if (is_array($row) && (int) $row['t3ver_state'] != 2) {
                            $singleElementHTML = '';
                            if (!$lP) {
                                $defLanguageCount[$key][] = $row['uid'];
                            }
                            $editUidList .= $row['uid'] . ',';
                            $singleElementHTML .= $this->tt_content_drawHeader($row, $this->tt_contentConfig['showInfo'] ? 15 : 5, $this->defLangBinding && $lP > 0, TRUE);
                            $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext');
                            $singleElementHTML .= '<div ' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . '>' . $this->tt_content_drawItem($row, $isRTE) . '</div>';
                            // NOTE: this is the end tag for <div class="t3-page-ce-body">
                            // because of bad (historic) conception, starting tag has to be placed inside tt_content_drawHeader()
                            $singleElementHTML .= '</div>';
                            $statusHidden = $this->isDisabled('tt_content', $row) ? ' t3-page-ce-hidden' : '';
                            $singleElementHTML = '<div class="t3-page-ce' . $statusHidden . '">' . $singleElementHTML . '</div>';
                            if ($this->defLangBinding && $this->tt_contentConfig['languageMode']) {
                                $defLangBinding[$key][$lP][$row[$lP ? 'l18n_parent' : 'uid']] = $singleElementHTML;
                            } else {
                                $content[$key] .= $singleElementHTML;
                            }
                        } else {
                            unset($rowArr[$rKey]);
                        }
                    }
                    // Add new-icon link, header:
                    $newP = $this->newContentElementOnClick($id, $key, $lP);
                    $head[$key] .= $this->tt_content_drawColHeader(t3lib_BEfunc::getProcessedValue('tt_content', 'colPos', $key), $this->doEdit && count($rowArr) ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc : '', $newP);
                    $editUidList = '';
                }
                // For EACH column, fit the rendered content into a table cell:
                $out = '';
                foreach ($cList as $k => $key) {
                    if (!$k) {
                        $out .= '
							<td><img src="clear.gif" width="' . $lMarg . '" height="1" alt="" /></td>';
                    } else {
                        $out .= '
							<td><img src="clear.gif" width="4" height="1" alt="" /></td>
							<td bgcolor="#cfcfcf"><img src="clear.gif" width="1" height="1" alt="" /></td>
							<td><img src="clear.gif" width="4" height="1" alt="" /></td>';
                    }
                    $out .= '
							<td class="t3-page-column t3-page-column-' . $key . '">' . $head[$key] . $content[$key] . '</td>';
                    // Storing content for use if languageMode is set:
                    if ($this->tt_contentConfig['languageMode']) {
                        $languageColumn[$key][$lP] = $head[$key] . $content[$key];
                        if (!$this->defLangBinding) {
                            $languageColumn[$key][$lP] .= '<br /><br />' . $this->newLanguageButton($this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP), $lP);
                        }
                    }
                }
                // Wrap the cells into a table row:
                $out = '
					<table border="0" cellpadding="0" cellspacing="0" class="t3-page-columns">
						<tr>' . $out . '
						</tr>
					</table>';
                // CSH:
                $out .= t3lib_BEfunc::cshItem($this->descrTable, 'columns_multi', $GLOBALS['BACK_PATH']);
            }
            // If language mode, then make another presentation:
            // Notice that THIS presentation will override the value of $out! But it needs the code above to execute since $languageColumn is filled with content we need!
            if ($this->tt_contentConfig['languageMode']) {
                // Get language selector:
                $languageSelector = $this->languageSelector($id);
                // Reset out - we will make new content here:
                $out = '';
                // Separator between language columns (black thin line)
                $midSep = '
						<td><img src="clear.gif" width="4" height="1" alt="" /></td>
						<td bgcolor="black"><img src="clear.gif" width="1" height="1" alt="" /></td>
						<td><img src="clear.gif" width="4" height="1" alt="" /></td>';
                // Traverse languages found on the page and build up the table displaying them side by side:
                $cCont = array();
                $sCont = array();
                foreach ($langListArr as $lP) {
                    // Header:
                    $cCont[$lP] = '
						<td valign="top" align="center" class="bgColor6"><strong>' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '</strong></td>';
                    // "View page" icon is added:
                    $viewLink = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id, $this->backPath, t3lib_BEfunc::BEgetRootLine($this->id), '', '', '&L=' . $lP)) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-view') . '</a>';
                    // Language overlay page header:
                    if ($lP) {
                        list($lpRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . intval($lP));
                        t3lib_BEfunc::workspaceOL('pages_language_overlay', $lpRecord);
                        $params = '&edit[pages_language_overlay][' . $lpRecord['uid'] . ']=edit&overrideVals[pages_language_overlay][sys_language_uid]=' . $lP;
                        $lPLabel = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon(t3lib_iconWorks::getSpriteIconForRecord('pages_language_overlay', $lpRecord), $lpRecord['uid']) . $viewLink . ($GLOBALS['BE_USER']->check('tables_modify', 'pages_language_overlay') ? '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath)) . '" title="' . $GLOBALS['LANG']->getLL('edit', TRUE) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>' : '') . htmlspecialchars(t3lib_div::fixed_lgd_cs($lpRecord['title'], 20));
                    } else {
                        $lPLabel = $viewLink;
                    }
                    $sCont[$lP] = '
						<td nowrap="nowrap">' . $lPLabel . '</td>';
                }
                // Add headers:
                $out .= '
					<tr class="bgColor5">' . implode($midSep, $cCont) . '
					</tr>';
                $out .= '
					<tr class="bgColor5">' . implode($midSep, $sCont) . '
					</tr>';
                // Traverse previously built content for the columns:
                foreach ($languageColumn as $cKey => $cCont) {
                    $out .= '
					<tr>
						<td valign="top">' . implode('</td>' . $midSep . '
						<td valign="top">', $cCont) . '</td>
					</tr>';
                    if ($this->defLangBinding) {
                        // "defLangBinding" mode
                        foreach ($defLanguageCount[$cKey] as $defUid) {
                            $cCont = array();
                            foreach ($langListArr as $lP) {
                                $cCont[] = $defLangBinding[$cKey][$lP][$defUid] . '<br/>' . $this->newLanguageButton($this->getNonTranslatedTTcontentUids(array($defUid), $id, $lP), $lP);
                            }
                            $out .= '
							<tr>
								<td valign="top">' . implode('</td>' . $midSep . '
								<td valign="top">', $cCont) . '</td>
							</tr>';
                        }
                        // Create spacer:
                        $cCont = array();
                        foreach ($langListArr as $lP) {
                            $cCont[] = '&nbsp;';
                        }
                        $out .= '
						<tr>
							<td valign="top">' . implode('</td>' . $midSep . '
							<td valign="top">', $cCont) . '</td>
						</tr>';
                    }
                }
                // Finally, wrap it all in a table and add the language selector on top of it:
                $out = $languageSelector . '
					<table border="0" cellpadding="0" cellspacing="0" width="480" class="typo3-page-langMode">
						' . $out . '
					</table>';
                // CSH:
                $out .= t3lib_BEfunc::cshItem($this->descrTable, 'language_list', $GLOBALS['BACK_PATH']);
            }
        } else {
            // SINGLE column mode (columns shown beneath each other):
            #debug('single column');
            if ($this->tt_contentConfig['sys_language_uid'] == 0 || !$this->defLangBinding) {
                // Initialize:
                if ($this->defLangBinding && $this->tt_contentConfig['sys_language_uid'] == 0) {
                    $showLanguage = ' AND sys_language_uid IN (0,-1)';
                    $lP = 0;
                } else {
                    $showLanguage = ' AND sys_language_uid=' . $this->tt_contentConfig['sys_language_uid'];
                    $lP = $this->tt_contentConfig['sys_language_uid'];
                }
                $cList = explode(',', $this->tt_contentConfig['showSingleCol']);
                $content = array();
                $out = '';
                // Expand the table to some preset dimensions:
                $out .= '
					<tr>
						<td><img src="clear.gif" width="' . $lMarg . '" height="1" alt="" /></td>
						<td valign="top"><img src="clear.gif" width="150" height="1" alt="" /></td>
						<td><img src="clear.gif" width="10" height="1" alt="" /></td>
						<td valign="top"><img src="clear.gif" width="300" height="1" alt="" /></td>
					</tr>';
                // Traverse columns to display top-on-top
                foreach ($cList as $counter => $key) {
                    // Select content elements:
                    $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos=' . intval($key) . $showHidden . $showLanguage);
                    $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
                    $c = 0;
                    $rowArr = $this->getResult($result);
                    $rowOut = '';
                    // If it turns out that there are not content elements in the column, then display a big button which links directly to the wizard script:
                    if ($this->doEdit && $this->option_showBigButtons && !intval($key) && !$GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
                        $onClick = "window.location.href='db_new_content_el.php?id=" . $id . '&colPos=' . intval($key) . '&sys_language_uid=' . $lP . '&uid_pid=' . $id . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . "';";
                        $theNewButton = $GLOBALS['SOBE']->doc->t3Button($onClick, $GLOBALS['LANG']->getLL('newPageContent'));
                        $theNewButton = '<img src="clear.gif" width="1" height="5" alt="" /><br />' . $theNewButton;
                    } else {
                        $theNewButton = '';
                    }
                    // Traverse any selected elements:
                    foreach ($rowArr as $rKey => $row) {
                        if (is_array($row) && (int) $row['t3ver_state'] != 2) {
                            $c++;
                            $editUidList .= $row['uid'] . ',';
                            $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext');
                            // Create row output:
                            $rowOut .= '
								<tr>
									<td></td>
									<td valign="top">' . $this->tt_content_drawHeader($row) . '</td>
									<td>&nbsp;</td>
									<td' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . ' valign="top">' . $this->tt_content_drawItem($row, $isRTE) . '</td>
								</tr>';
                            // If the element was not the last element, add a divider line:
                            if ($c != $GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
                                $rowOut .= '
								<tr>
									<td></td>
									<td colspan="3"><img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/stiblet_medium2.gif', 'width="468" height="1"') . ' class="c-divider" alt="" /></td>
								</tr>';
                            }
                        } else {
                            unset($rowArr[$rKey]);
                        }
                    }
                    // Add spacer between sections in the vertical list
                    if ($counter) {
                        $out .= '
							<tr>
								<td></td>
								<td colspan="3"><br /><br /><br /><br /></td>
							</tr>';
                    }
                    // Add section header:
                    $newP = $this->newContentElementOnClick($id, $key, $this->tt_contentConfig['sys_language_uid']);
                    $out .= '

						<!-- Column header: -->
						<tr>
							<td></td>
							<td valign="top" colspan="3">' . $this->tt_content_drawColHeader(t3lib_BEfunc::getProcessedValue('tt_content', 'colPos', $key), $this->doEdit && count($rowArr) ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc : '', $newP) . $theNewButton . '<br /></td>
						</tr>';
                    // Finally, add the content from the records in this column:
                    $out .= $rowOut;
                }
                // Finally, wrap all table rows in one, big table:
                $out = '
					<table border="0" cellpadding="0" cellspacing="0" width="400" class="typo3-page-columnsMode">
						' . $out . '
					</table>';
                // CSH:
                $out .= t3lib_BEfunc::cshItem($this->descrTable, 'columns_single', $GLOBALS['BACK_PATH']);
            } else {
                $out = '<br/><br/>' . $GLOBALS['SOBE']->doc->icons(1) . 'Sorry, you cannot view a single language in this localization mode (Default Language Binding is enabled)<br/><br/>';
            }
        }
        // Add the big buttons to page:
        if ($this->option_showBigButtons) {
            $bArray = array();
            if (!$GLOBALS['SOBE']->current_sys_language) {
                if ($this->ext_CALC_PERMS & 2) {
                    $bArray[0] = $GLOBALS['SOBE']->doc->t3Button(t3lib_BEfunc::editOnClick('&edit[pages][' . $id . "]=edit", $this->backPath, ''), $GLOBALS['LANG']->getLL('editPageProperties'));
                }
            } else {
                if ($this->doEdit && $GLOBALS['BE_USER']->check('tables_modify', 'pages_language_overlay')) {
                    list($languageOverlayRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . intval($GLOBALS['SOBE']->current_sys_language));
                    $bArray[0] = $GLOBALS['SOBE']->doc->t3Button(t3lib_BEfunc::editOnClick('&edit[pages_language_overlay][' . $languageOverlayRecord['uid'] . "]=edit", $this->backPath, ''), $GLOBALS['LANG']->getLL('editPageProperties_curLang'));
                }
            }
            if ($this->ext_CALC_PERMS & 4 || $this->ext_CALC_PERMS & 2) {
                $bArray[1] = $GLOBALS['SOBE']->doc->t3Button("window.location.href='" . $this->backPath . "move_el.php?table=pages&uid=" . $id . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . "';", $GLOBALS['LANG']->getLL('move_page'));
            }
            if ($this->ext_CALC_PERMS & 8) {
                $bArray[2] = $GLOBALS['SOBE']->doc->t3Button("window.location.href='" . $this->backPath . "db_new.php?id=" . $id . '&pagesOnly=1&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . "';", $GLOBALS['LANG']->getLL('newPage2'));
            }
            if ($this->doEdit && $this->ext_function == 1) {
                $bArray[3] = $GLOBALS['SOBE']->doc->t3Button("window.location.href='db_new_content_el.php?id=" . $id . '&sys_language_uid=' . $GLOBALS['SOBE']->current_sys_language . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . "';", $GLOBALS['LANG']->getLL('newPageContent2'));
            }
            $out = '
				<table border="0" cellpadding="4" cellspacing="0" class="typo3-page-buttons">
					<tr>
						<td>' . implode('</td>
						<td>', $bArray) . '</td>
						<td>' . t3lib_BEfunc::cshItem($this->descrTable, 'button_panel', $GLOBALS['BACK_PATH']) . '</td>
					</tr>
				</table>
				<br />
				' . $out;
        }
        // Return content:
        return $out;
    }
 function checkTicketAdmin()
 {
     // get cobj from db
     $where = 'uid=' . $this->cObjId;
     $where .= t3lib_BEfunc::BEenableFields('tt_content');
     $where .= t3lib_befunc::deleteClause('tt_content');
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pi_flexform', 'tt_content', $where, '', '', $limit = 1);
     $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
     if (!empty($row['pi_flexform'])) {
         $ffData = t3lib_div::xml2array($row['pi_flexform']);
     }
     $ticketAdmins = $ffData['data']['sheetUsers']['lDEF']['ticket_administrators']['vDEF'];
     if ($ticketAdmins) {
         if (t3lib_div::inList($ticketAdmins, $this->feUserObj->user['ses_userid'])) {
             return true;
         }
     } else {
         return false;
     }
 }
 /**
  * This saves the document to the database and index
  *
  * @access	public
  *
  * @param	integer		$pid: The PID of the saved record
  * @param	integer		$core: The UID of the Solr core for indexing
  *
  * @return	boolean		TRUE on success or FALSE on failure
  */
 public function save($pid = 0, $core = 0)
 {
     // Save parameters for logging purposes.
     $_pid = $pid;
     $_core = $core;
     if (TYPO3_MODE !== 'BE') {
         if (TYPO3_DLOG) {
             t3lib_div::devLog('[tx_dlf_document->save(' . $_pid . ', ' . $_core . ')] Saving a document is only allowed in the backend', self::$extKey, SYSLOG_SEVERITY_ERROR);
         }
         return FALSE;
     }
     // Make sure $pid is a non-negative integer.
     $pid = max(intval($pid), 0);
     // Make sure $core is a non-negative integer.
     $core = max(intval($core), 0);
     // If $pid is not given, try to get it elsewhere.
     if (!$pid && $this->pid) {
         // Retain current PID.
         $pid = $this->pid;
     } elseif (!$pid) {
         if (TYPO3_DLOG) {
             t3lib_div::devLog('[tx_dlf_document->save(' . $_pid . ', ' . $_core . ')] Invalid PID "' . $pid . '" for document saving', self::$extKey, SYSLOG_SEVERITY_ERROR);
         }
         return FALSE;
     }
     // Set PID for metadata definitions.
     $this->cPid = $pid;
     // Set UID placeholder if not updating existing record.
     if ($pid != $this->pid) {
         $this->uid = uniqid('NEW');
     }
     // Get metadata array.
     $metadata = $this->getTitledata($pid);
     // Check for record identifier.
     if (empty($metadata['record_id'][0])) {
         if (TYPO3_DLOG) {
             t3lib_div::devLog('[tx_dlf_document->save(' . $_pid . ', ' . $_core . ')] No record identifier found to avoid duplication', self::$extKey, SYSLOG_SEVERITY_ERROR);
         }
         return FALSE;
     }
     // Load plugin configuration.
     $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
     // Get UID for user "_cli_dlf".
     $be_user = 0;
     $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('be_users.uid AS uid', 'be_users', 'username='******'TYPO3_DB']->fullQuoteStr('_cli_dlf', 'be_users') . t3lib_BEfunc::BEenableFields('be_users') . t3lib_BEfunc::deleteClause('be_users'), '', '', '1');
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
         list($be_user) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
     } else {
         if (TYPO3_DLOG) {
             t3lib_div::devLog('[tx_dlf_document->save(' . $_pid . ', ' . $_core . ')] Backend user "_cli_dlf" not found or disabled', self::$extKey, SYSLOG_SEVERITY_ERROR);
         }
         return FALSE;
     }
     // Get UID for structure type.
     $structure = 0;
     $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_structures.uid AS uid', 'tx_dlf_structures', 'tx_dlf_structures.pid=' . intval($pid) . ' AND tx_dlf_structures.index_name=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($metadata['type'][0], 'tx_dlf_structures') . tx_dlf_helper::whereClause('tx_dlf_structures'), '', '', '1');
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
         list($structure) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
     } else {
         if (TYPO3_DLOG) {
             t3lib_div::devLog('[tx_dlf_document->save(' . $_pid . ', ' . $_core . ')] Could not identify document/structure type', self::$extKey, SYSLOG_SEVERITY_ERROR);
         }
         return FALSE;
     }
     $metadata['type'][0] = $structure;
     // Get UIDs for collections.
     $collections = array();
     $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_collections.index_name AS index_name,tx_dlf_collections.uid AS uid', 'tx_dlf_collections', 'tx_dlf_collections.pid=' . intval($pid) . ' AND tx_dlf_collections.cruser_id=' . intval($be_user) . ' AND tx_dlf_collections.fe_cruser_id=0' . tx_dlf_helper::whereClause('tx_dlf_collections'), '', '', '');
     for ($i = 0, $j = $GLOBALS['TYPO3_DB']->sql_num_rows($result); $i < $j; $i++) {
         $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
         $collUid[$resArray['index_name']] = $resArray['uid'];
     }
     foreach ($metadata['collection'] as $collection) {
         if (!empty($collUid[$collection])) {
             // Add existing collection's UID.
             $collections[] = $collUid[$collection];
         } else {
             // Insert new collection.
             $collNewUid = uniqid('NEW');
             $collData['tx_dlf_collections'][$collNewUid] = array('pid' => $pid, 'label' => $collection, 'index_name' => $collection, 'oai_name' => !empty($conf['publishNewCollections']) ? $collection : '', 'description' => '', 'documents' => 0, 'owner' => 0, 'status' => 0);
             $substUid = tx_dlf_helper::processDB($collData);
             // Prevent double insertion.
             unset($collData);
             // Add new collection's UID.
             $collections[] = $substUid[$collNewUid];
             if (!defined('TYPO3_cliMode')) {
                 $message = t3lib_div::makeInstance('t3lib_FlashMessage', htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.newCollection'), $collection, $substUid[$collNewUid])), tx_dlf_helper::getLL('flash.attention', TRUE), t3lib_FlashMessage::INFO, TRUE);
                 t3lib_FlashMessageQueue::addMessage($message);
             }
         }
     }
     // Preserve user-defined collections.
     $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_collections.uid AS uid', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_documents.pid=' . intval($pid) . ' AND tx_dlf_collections.pid=' . intval($pid) . ' AND tx_dlf_documents.uid=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->uid, 'tx_dlf_documents') . ' AND NOT (tx_dlf_collections.cruser_id=' . intval($be_user) . ' AND tx_dlf_collections.fe_cruser_id=0) AND tx_dlf_relations.ident=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations'), '', '', '');
     for ($i = 0, $j = $GLOBALS['TYPO3_DB']->sql_num_rows($result); $i < $j; $i++) {
         list($collections[]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
     }
     $metadata['collection'] = $collections;
     // Get UID for owner.
     $owner = 0;
     $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_libraries.uid AS uid', 'tx_dlf_libraries', 'tx_dlf_libraries.pid=' . intval($pid) . ' AND tx_dlf_libraries.index_name=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($metadata['owner'][0], 'tx_dlf_libraries') . tx_dlf_helper::whereClause('tx_dlf_libraries'), '', '', '1');
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
         list($owner) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
     } else {
         // Insert new library.
         $libNewUid = uniqid('NEW');
         $libData['tx_dlf_libraries'][$libNewUid] = array('pid' => $pid, 'label' => $metadata['owner'][0], 'index_name' => $metadata['owner'][0], 'website' => '', 'contact' => '', 'image' => '', 'oai_label' => '', 'oai_base' => '', 'opac_label' => '', 'opac_base' => '', 'union_label' => '', 'union_base' => '');
         $substUid = tx_dlf_helper::processDB($libData);
         // Add new library's UID.
         $owner = $substUid[$libNewUid];
         if (!defined('TYPO3_cliMode')) {
             $message = t3lib_div::makeInstance('t3lib_FlashMessage', htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.newLibrary'), $metadata['owner'][0], $owner)), tx_dlf_helper::getLL('flash.attention', TRUE), t3lib_FlashMessage::INFO, TRUE);
             t3lib_FlashMessageQueue::addMessage($message);
         }
     }
     $metadata['owner'][0] = $owner;
     // Load table of contents.
     $this->_getTableOfContents();
     // Get UID of superior document.
     $partof = 0;
     if (!empty($this->tableOfContents[0]['points']) && $this->tableOfContents[0]['points'] != $this->location && !tx_dlf_helper::testInt($this->tableOfContents[0]['points'])) {
         $superior =& tx_dlf_document::getInstance($this->tableOfContents[0]['points'], $pid);
         if ($superior->ready) {
             if ($superior->pid != $pid) {
                 $superior->save($pid, $core);
             }
             $partof = $superior->uid;
         }
     }
     // Use the date of publication as alternative sorting metric for parts of multi-part works.
     if (!empty($partof)) {
         if (empty($metadata['volume'][0]) && !empty($metadata['year'][0])) {
             $metadata['volume'] = $metadata['year'];
         }
         if (empty($metadata['volume_sorting'][0])) {
             if (!empty($metadata['year_sorting'][0])) {
                 $metadata['volume_sorting'][0] = $metadata['year_sorting'][0];
             } elseif (!empty($metadata['year'][0])) {
                 $metadata['volume_sorting'][0] = $metadata['year'][0];
             }
         }
     }
     // Get metadata for lists and sorting.
     $listed = array();
     $sortable = array();
     $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_metadata.index_name AS index_name,tx_dlf_metadata.is_listed AS is_listed,tx_dlf_metadata.is_sortable AS is_sortable', 'tx_dlf_metadata', '(tx_dlf_metadata.is_listed=1 OR tx_dlf_metadata.is_sortable=1) AND tx_dlf_metadata.pid=' . intval($pid) . tx_dlf_helper::whereClause('tx_dlf_metadata'), '', '', '');
     while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
         if (!empty($metadata[$resArray['index_name']])) {
             if ($resArray['is_listed']) {
                 $listed[$resArray['index_name']] = $metadata[$resArray['index_name']];
             }
             if ($resArray['is_sortable']) {
                 $sortable[$resArray['index_name']] = $metadata[$resArray['index_name']][0];
             }
         }
     }
     // Fill data array.
     $data['tx_dlf_documents'][$this->uid] = array('pid' => $pid, $GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['starttime'] => 0, $GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['endtime'] => 0, 'prod_id' => $metadata['prod_id'][0], 'location' => $this->location, 'record_id' => $metadata['record_id'][0], 'opac_id' => $metadata['opac_id'][0], 'union_id' => $metadata['union_id'][0], 'urn' => $metadata['urn'][0], 'purl' => $metadata['purl'][0], 'title' => $metadata['title'][0], 'title_sorting' => $metadata['title_sorting'][0], 'author' => implode('; ', $metadata['author']), 'year' => implode('; ', $metadata['year']), 'place' => implode('; ', $metadata['place']), 'thumbnail' => $this->_getThumbnail(TRUE), 'metadata' => serialize($listed), 'metadata_sorting' => serialize($sortable), 'structure' => $metadata['type'][0], 'partof' => $partof, 'volume' => $metadata['volume'][0], 'volume_sorting' => $metadata['volume_sorting'][0], 'collections' => $metadata['collection'], 'owner' => $metadata['owner'][0], 'solrcore' => $core, 'status' => 0);
     // Unhide hidden documents.
     if (!empty($conf['unhideOnIndex'])) {
         $data['tx_dlf_documents'][$this->uid][$GLOBALS['TCA']['tx_dlf_documents']['ctrl']['enablecolumns']['disabled']] = 0;
     }
     // Process data.
     $newIds = tx_dlf_helper::processDB($data);
     // Replace placeholder with actual UID.
     if (strpos($this->uid, 'NEW') === 0) {
         $this->uid = $newIds[$this->uid];
         $this->pid = $pid;
         $this->parentId = $partof;
     }
     if (!defined('TYPO3_cliMode')) {
         $message = t3lib_div::makeInstance('t3lib_FlashMessage', htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.documentSaved'), $metadata['title'][0], $this->uid)), tx_dlf_helper::getLL('flash.done', TRUE), t3lib_FlashMessage::OK, TRUE);
         t3lib_FlashMessageQueue::addMessage($message);
     }
     // Add document to index.
     if ($core) {
         tx_dlf_indexing::add($this, $core);
     } else {
         if (TYPO3_DLOG) {
             t3lib_div::devLog('[tx_dlf_document->save(' . $_pid . ', ' . $_core . ')] Invalid UID "' . $core . '" for Solr core', self::$extKey, SYSLOG_SEVERITY_NOTICE);
         }
     }
     return TRUE;
 }
Beispiel #22
0
 function getConfigurationsForBranch($rootid, $depth)
 {
     $configurationsForBranch = array();
     $pageTSconfig = $this->getPageTSconfigForId($rootid);
     if (is_array($pageTSconfig) && is_array($pageTSconfig['tx_crawler.']['crawlerCfg.']) && is_array($pageTSconfig['tx_crawler.']['crawlerCfg.']['paramSets.'])) {
         $sets = $pageTSconfig['tx_crawler.']['crawlerCfg.']['paramSets.'];
         if (is_array($sets)) {
             foreach ($sets as $key => $value) {
                 if (!is_array($value)) {
                     continue;
                 }
                 $configurationsForBranch[] = substr($key, -1) == '.' ? substr($key, 0, -1) : $key;
             }
         }
     }
     $pids = array();
     $rootLine = t3lib_BEfunc::BEgetRootLine($rootid);
     foreach ($rootLine as $node) {
         $pids[] = $node['uid'];
     }
     /* @var t3lib_pageTree */
     $tree = t3lib_div::makeInstance('t3lib_pageTree');
     $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
     $tree->init('AND ' . $perms_clause);
     $tree->getTree($rootid, $depth, '');
     foreach ($tree->tree as $node) {
         $pids[] = $node['row']['uid'];
     }
     $res = $this->db->exec_SELECTquery('*', 'tx_crawler_configuration', 'pid IN (' . implode(',', $pids) . ') ' . t3lib_BEfunc::BEenableFields('tx_crawler_configuration') . t3lib_BEfunc::deleteClause('tx_crawler_configuration') . ' ' . t3lib_BEfunc::versioningPlaceholderClause('tx_crawler_configuration') . ' ');
     while ($row = $this->db->sql_fetch_assoc($res)) {
         $configurationsForBranch[] = $row['name'];
     }
     $this->db->sql_free_result($res);
     return $configurationsForBranch;
 }
 /**
  * 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 . ')';
     if (TYPO3_VERSION_INTEGER >= 7000000) {
         $where .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table);
         $where .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table);
     } else {
         $where .= t3lib_BEfunc::BEenableFields($table);
         $where .= t3lib_BEfunc::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) {
             if (TYPO3_VERSION_INTEGER >= 7000000) {
                 $_procObj =& \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
             } else {
                 $_procObj =& t3lib_div::getUserObj($_classRef);
             }
             $_procObj->modifyPagesIndexEntry($uid, $pageContent, $tags, $this->cachedPageRecords, $additionalFields, $indexerConfig, $indexEntryDefaultValues);
         }
     }
     // 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;
 }
 /**
  * Find all supported broken links and store them in tx_linkvalidator_link.
  *
  * @param	array		$checkOptions: list of hook object to activate
  * @param	boolean		$considerHidden: defines whether to look into hidden fields or not
  * @return	void
  */
 public function getLinkStatistics($checkOptions = array(), $considerHidden = FALSE)
 {
     $results = array();
     $checlLinkTypeCondition = '';
     if (count($checkOptions) > 0) {
         $checkKeys = array_keys($checkOptions);
         $checlLinkTypeCondition = ' and link_type in (\'' . implode('\',\'', $checkKeys) . '\')';
         $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_linkvalidator_link', '(record_pid in (' . $this->pidList . ') or ( record_uid IN (' . $this->pidList . ') and table_name like \'pages\')) ' . $checlLinkTypeCondition);
         // let's traverse all configured tables
         foreach ($this->searchFields as $table => $fields) {
             if ($table == 'pages') {
                 $where = 'deleted = 0 AND uid IN (' . $this->pidList . ')';
             } else {
                 $where = 'deleted = 0 AND pid IN (' . $this->pidList . ')';
             }
             if (!$considerHidden) {
                 $where .= t3lib_BEfunc::BEenableFields($table);
             }
             // if table is not configured, we assume the ext is not installed and therefore no need to check it
             if (!is_array($GLOBALS['TCA'][$table])) {
                 continue;
             }
             // re-init selectFields for table
             $selectFields = 'uid, pid';
             $selectFields .= ', ' . $GLOBALS['TCA'][$table]['ctrl']['label'] . ', ' . implode(', ', $fields);
             // TODO: only select rows that have content in at least one of the relevant fields (via OR)
             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selectFields, $table, $where);
             // Get record rows of table
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 // Analyse each record
                 $this->analyzeRecord($results, $table, $fields, $row);
             }
         }
         foreach ($this->hookObjectsArr as $key => $hookObj) {
             if (is_array($results[$key]) && empty($checkOptions) || is_array($results[$key]) && $checkOptions[$key]) {
                 //  check'em!
                 foreach ($results[$key] as $entryKey => $entryValue) {
                     $table = $entryValue['table'];
                     $record = array();
                     $record['headline'] = $entryValue['row'][$GLOBALS['TCA'][$table]['ctrl']['label']];
                     $record['record_pid'] = $entryValue['row']['pid'];
                     $record['record_uid'] = $entryValue['uid'];
                     $record['table_name'] = $table;
                     $record['link_title'] = $entryValue['link_title'];
                     $record['field'] = $entryValue['field'];
                     $record['last_check'] = time();
                     $this->recordReference = $entryValue['substr']['recordRef'];
                     $this->pageWithAnchor = $entryValue['pageAndAnchor'];
                     if (!empty($this->pageWithAnchor)) {
                         // page with anchor, e.g. 18#1580
                         $url = $this->pageWithAnchor;
                     } else {
                         $url = $entryValue['substr']['tokenValue'];
                     }
                     $this->linkCounts[$table]++;
                     $checkURL = $hookObj->checkLink($url, $entryValue, $this);
                     // broken link found!
                     if (!$checkURL) {
                         $response = array();
                         $response['valid'] = FALSE;
                         $response['errorParams'] = $hookObj->getErrorParams();
                         $this->brokenLinkCounts[$table]++;
                         $record['link_type'] = $key;
                         $record['url'] = $url;
                         $record['url_response'] = serialize($response);
                         $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_linkvalidator_link', $record);
                     } elseif (t3lib_div::_GP('showalllinks')) {
                         $response = array();
                         $response['valid'] = TRUE;
                         $this->brokenLinkCounts[$table]++;
                         $record['url'] = $url;
                         $record['link_type'] = $key;
                         $record['url_response'] = serialize($response);
                         $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_linkvalidator_link', $record);
                     }
                 }
             }
         }
     }
 }
Beispiel #25
0
    /**
     * Returns an array of available languages (to use for FlexForms)
     *
     * @param	integer		$id: If zero, the query will select all sys_language records from root level. If set to another value, the query will select all sys_language records that has a pages_language_overlay record on that page (and is not hidden, unless you are admin user)
     * @param	boolean		$onlyIsoCoded: If set, only languages which are paired with a static_info_table / static_language record will be returned.
     * @param	boolean		$setDefault: If set, an array entry for a default language is set.
     * @param	boolean		$setMulti: If set, an array entry for "multiple languages" is added (uid -1)
     * @return	array
     * @access protected
     */
    function getAvailableLanguages($id = 0, $onlyIsoCoded = true, $setDefault = true, $setMulti = false)
    {
        global $LANG, $TYPO3_DB, $BE_USER, $TCA, $BACK_PATH;
        t3lib_div::loadTCA('sys_language');
        $output = array();
        $excludeHidden = $BE_USER->isAdmin() ? '1=1' : 'sys_language.hidden=0';
        if ($id) {
            $excludeHidden .= ' AND pages_language_overlay.deleted=0';
            $res = $TYPO3_DB->exec_SELECTquery('DISTINCT sys_language.*, pages_language_overlay.hidden as PLO_hidden, pages_language_overlay.title as PLO_title', 'pages_language_overlay,sys_language', 'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid=' . intval($id) . ' AND ' . $excludeHidden, '', 'sys_language.title');
        } else {
            $res = $TYPO3_DB->exec_SELECTquery('sys_language.*', 'sys_language', $excludeHidden, '', 'sys_language.title');
        }
        if ($setDefault) {
            $output[0] = array('uid' => 0, 'title' => strlen($this->modSharedTSconfig['properties']['defaultLanguageLabel']) ? $this->modSharedTSconfig['properties']['defaultLanguageLabel'] : $LANG->getLL('defaultLanguage'), 'ISOcode' => 'DEF', 'flagIcon' => strlen($this->modSharedTSconfig['properties']['defaultLanguageFlag']) ? $this->modSharedTSconfig['properties']['defaultLanguageFlag'] : null);
        }
        if ($setMulti) {
            $output[-1] = array('uid' => -1, 'title' => $LANG->getLL('multipleLanguages'), 'ISOcode' => 'DEF', 'flagIcon' => 'multiple');
        }
        while (TRUE == ($row = $TYPO3_DB->sql_fetch_assoc($res))) {
            t3lib_BEfunc::workspaceOL('sys_language', $row);
            if ($id) {
                $table = 'pages_language_overlay';
                $enableFields = t3lib_BEfunc::BEenableFields($table);
                if (trim($enableFields) == 'AND') {
                    $enableFields = '';
                }
                $enableFields .= t3lib_BEfunc::deleteClause($table);
                // Selecting overlay record:
                $resP = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages_language_overlay', 'pid=' . intval($id) . '
						AND sys_language_uid=' . intval($row['uid']), '', '', '1');
                $pageRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resP);
                $GLOBALS['TYPO3_DB']->sql_free_result($resP);
                t3lib_BEfunc::workspaceOL('pages_language_overlay', $pageRow);
                $row['PLO_hidden'] = $pageRow['hidden'];
                $row['PLO_title'] = $pageRow['title'];
            }
            $output[$row['uid']] = $row;
            if ($row['static_lang_isocode']) {
                $staticLangRow = t3lib_BEfunc::getRecord('static_languages', $row['static_lang_isocode'], 'lg_iso_2');
                if ($staticLangRow['lg_iso_2']) {
                    $output[$row['uid']]['ISOcode'] = $staticLangRow['lg_iso_2'];
                }
            }
            if (strlen($row['flag'])) {
                $output[$row['uid']]['flagIcon'] = $row['flag'];
            }
            if ($onlyIsoCoded && !$output[$row['uid']]['ISOcode']) {
                unset($output[$row['uid']]);
            }
            $disableLanguages = t3lib_div::trimExplode(',', $this->modSharedTSconfig['properties']['disableLanguages'], 1);
            foreach ($disableLanguages as $language) {
                // $language is the uid of a sys_language
                unset($output[$language]);
            }
        }
        return $output;
    }
 /**
  * Builds the enable fields statement
  *
  * @param string $tableName The database table name
  * @param array &$sql The query parts
  * @return void
  */
 protected function addEnableFieldsStatement($tableName, array &$sql)
 {
     if (is_array($GLOBALS['TCA'][$tableName]['ctrl'])) {
         if (TYPO3_MODE === 'FE') {
             $statement = $GLOBALS['TSFE']->sys_page->enableFields($tableName);
         } else {
             // TYPO3_MODE === 'BE'
             $statement = t3lib_BEfunc::deleteClause($tableName);
             $statement .= t3lib_BEfunc::BEenableFields($tableName);
         }
         if (!empty($statement)) {
             $statement = substr($statement, 5);
             $sql['additionalWhereClause'][] = $statement;
         }
     }
 }
Beispiel #27
0
 /**
  * Finds the alternative page language overlay records for a page based on
  * the sys_language_mode.
  *
  * Possible Language Modes:
  * 1) content_fallback --> all languages
  * 2) strict --> available languages with page overlay
  * 3) ignore --> available languages with page overlay
  * 4) unknown mode or blank --> all languages
  *
  * @param integer $pageId Page ID.
  * @return array An array of translation overlays (or fake overlays) found for the given page.
  */
 protected function getTranslationOverlaysForPage($pageId)
 {
     $translationOverlays = array();
     $pageId = intval($pageId);
     $site = Tx_Solr_Site::getSiteByPageId($pageId);
     $languageModes = array('content_fallback', 'strict', 'ignore');
     $hasOverlayMode = in_array($site->getSysLanguageMode(), $languageModes, TRUE);
     $isContentFallbackMode = $site->getSysLanguageMode() === 'content_fallback';
     if ($hasOverlayMode && !$isContentFallbackMode) {
         $translationOverlays = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('pid, sys_language_uid', 'pages_language_overlay', 'pid = ' . $pageId . t3lib_BEfunc::deleteClause('pages_language_overlay') . t3lib_BEfunc::BEenableFields('pages_language_overlay'));
     } else {
         // ! If no sys_language_mode is configured, all languages will be indexed !
         $languages = t3lib_BEfunc::getSystemLanguages();
         // remove default language (L = 0)
         array_shift($languages);
         foreach ($languages as $language) {
             $translationOverlays[] = array('pid' => $pageId, 'sys_language_uid' => $language[1]);
         }
     }
     return $translationOverlays;
 }
 /**
  * Selecting records from a table from a page which are candidates to be translated.
  *
  * @param   string   $table Table name
  * @param   integer  $pageId Page id
  * @return  array    Array of records from table (with all fields selected)
  */
 function getRecordsToTranslateFromTable($table, $pageId)
 {
     global $TCA;
     if ($this->t8Tools->isTranslationInOwnTable($table)) {
         // Check for disabled field settings
         //print "###".$GLOBALS['BE_USER']->uc['moduleData']['xMOD_tx_l10nmgr_cm1']['noHidden']."---";
         if (!empty($GLOBALS['BE_USER']->uc['moduleData']['xMOD_tx_l10nmgr_cm1']['noHidden'])) {
             $hiddenClause = t3lib_BEfunc::BEenableFields($table, $inv = 0);
         } else {
             $hiddenClause = "";
         }
         // First, select all records that are default language OR international:
         $allRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $table, 'pid=' . intval($pageId) . ' AND ' . $TCA[$table]['ctrl']['languageField'] . '<=0' . $hiddenClause . t3lib_BEfunc::deleteClause($table) . t3lib_BEfunc::versioningPlaceholderClause($table));
         return $allRows;
     }
 }
 /**
  * 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 Tx_Solr_IndexQueue_Item $item An index queue item
  * @return array An array of Tx_Solr_SolrService connections, the array's keys are the sys_language_uid of the language of the connection
  */
 protected function getSolrConnectionsByItem(Tx_Solr_IndexQueue_Item $item)
 {
     $solrConnections = parent::getSolrConnectionsByItem($item);
     $page = $item->getRecord();
     // may use t3lib_div::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 (t3lib_div::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'] . t3lib_BEfunc::deleteClause('pages_language_overlay') . t3lib_BEfunc::BEenableFields('pages_language_overlay'));
         foreach ($translationOverlays as $overlay) {
             $languageId = $overlay['sys_language_uid'];
             $accessibleSolrConnections[$languageId] = $solrConnections[$languageId];
         }
         $solrConnections = $accessibleSolrConnections;
     }
     return $solrConnections;
 }
 /**
  * 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 t3lib_DB */
     $db = $GLOBALS['TYPO3_DB'];
     $row['countNews'] = $db->exec_SELECTcountRows('*', 'tx_news_domain_model_news', 'pid=' . $pageUid . t3lib_BEfunc::BEenableFields('tx_news_domain_model_news'));
     $row['countCategories'] = $db->exec_SELECTcountRows('*', 'tx_news_domain_model_category', 'pid=' . $pageUid . t3lib_BEfunc::BEenableFields('tx_news_domain_model_category'));
     $row['countNewsAndCategories'] = $row['countNews'] + $row['countCategories'];
 }