/**
  * Creates $this->sysPage if it does not exist yet
  *
  * @return void
  */
 protected function createSysPageIfNecessary()
 {
     if (!is_object($this->sysPage)) {
         $this->sysPage = $this->apiWrapper->getPageRepository();
         $this->sysPage->init($GLOBALS['TSFE']->showHiddenPage || $this->pObj->isBEUserLoggedIn());
     }
 }
 /**
  * Creates $this->sysPage if it does not exist yet
  *
  * @return void
  */
 protected function createSysPageIfNecessary()
 {
     if (!is_object($this->sysPage)) {
         $this->sysPage = t3lib_div::makeInstance('t3lib_pageSelect');
         $this->sysPage->init($GLOBALS['TSFE']->showHiddenPage || $this->pObj->isBEUserLoggedIn());
     }
 }
 /**
  * Get the localization of the select field items (right-hand part of form)
  * Referenced by TCA
  *
  * @param	array		$params: array of searched translation
  * @return	void		...
  */
 public function get_localized_categories($params)
 {
     /*
     		$params['items'] = &$items;
     		$params['config'] = $config;
     		$params['TSconfig'] = $iArray;
     		$params['table'] = $table;
     		$params['row'] = $row;
     		$params['field'] = $field;
     */
     $items = $params['items'];
     $config = $params['config'];
     $table = $config['itemsProcFunc_config']['table'];
     // initialize backend user language
     if ($GLOBALS['LANG']->lang && t3lib_extMgm::isLoaded('static_info_tables')) {
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('sys_language.uid', 'sys_language LEFT JOIN static_languages ON sys_language.static_lang_isocode=static_languages.uid', 'static_languages.lg_typo3=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['LANG']->lang, 'static_languages') . t3lib_pageSelect::enableFields('sys_language') . t3lib_pageSelect::enableFields('static_languages'));
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $this->sys_language_uid = $row['uid'];
             $this->collate_locale = $row['lg_collate_locale'];
         }
     }
     if (is_array($params['items'])) {
         reset($params['items']);
         while (list($k, $item) = each($params['items'])) {
             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid=' . intval($item[1]));
             while ($rowCat = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 $localizedRowCat = tx_srfeuserregister_dmstatic::getRecordOverlay($table, $rowCat, $this->sys_language_uid, '');
                 if ($localizedRowCat) {
                     $params['items'][$k][0] = $localizedRowCat['category'];
                 }
             }
         }
     }
 }
 /**
  * Performs workspace and language overlay on the given row array. The language and workspace id is automatically
  * detected (depending on FE or BE context). You can also explicitly set the language/workspace id.
  *
  * @param Tx_Extbase_Persistence_QOM_SourceInterface $source The source (selector od join)
  * @param array $row The row array (as reference)
  * @param string $languageUid The language id
  * @param string $workspaceUidUid The workspace id
  * @return void
  */
 protected function doLanguageAndWorkspaceOverlay(Tx_Extbase_Persistence_QOM_SourceInterface $source, array $rows, $languageUid = NULL, $workspaceUid = NULL)
 {
     $overlayedRows = array();
     foreach ($rows as $row) {
         if (!$this->pageSelectObject instanceof t3lib_pageSelect) {
             if (TYPO3_MODE == 'FE') {
                 if (is_object($GLOBALS['TSFE'])) {
                     $this->pageSelectObject = $GLOBALS['TSFE']->sys_page;
                 } else {
                     require_once PATH_t3lib . 'class.t3lib_page.php';
                     $this->pageSelectObject = t3lib_div::makeInstance('t3lib_pageSelect');
                 }
             } else {
                 require_once PATH_t3lib . 'class.t3lib_page.php';
                 $this->pageSelectObject = t3lib_div::makeInstance('t3lib_pageSelect');
             }
         }
         if (is_object($GLOBALS['TSFE'])) {
             if ($languageUid === NULL) {
                 $languageUid = $GLOBALS['TSFE']->sys_language_uid;
                 $languageMode = $GLOBALS['TSFE']->sys_language_mode;
             }
             if ($workspaceUid !== NULL) {
                 $this->pageSelectObject->versioningWorkspaceId = $workspaceUid;
             }
         } else {
             if ($languageUid === NULL) {
                 $languageUid = intval(t3lib_div::_GP('L'));
             }
             if ($workspaceUid === NULL) {
                 $workspaceUid = $GLOBALS['BE_USER']->workspace;
             }
             $this->pageSelectObject->versioningWorkspaceId = $workspaceUid;
         }
         if ($source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) {
             $tableName = $source->getSelectorName();
         } elseif ($source instanceof Tx_Extbase_Persistence_QOM_JoinInterface) {
             $tableName = $source->getLeft()->getSelectorName();
         }
         $this->pageSelectObject->versionOL($tableName, $row, TRUE);
         if (isset($GLOBALS['TCA'][$tableName]['ctrl']['languageField']) && $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] !== '') {
             if (in_array($row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']], array(-1, 0))) {
                 $overlayMode = $languageMode === 'strict' ? 'hideNonTranslated' : '';
                 $row = $this->pageSelectObject->getRecordOverlay($tableName, $row, $languageUid, $overlayMode);
             }
         }
         if ($row !== NULL) {
             $overlayedRows[] = $row;
         }
     }
     return $overlayedRows;
 }
 /**
  * Wrapper function for t3lib_pageSelect::enableFields() since it is no
  * longer accessible statically.
  *
  * Returns a part of a WHERE clause which will filter out records with
  * start/end times or deleted/hidden/fe_groups fields set to values that
  * should de-select them according to the current time, preview settings or
  * user login.
  * Is using the $TCA arrays "ctrl" part where the key "enablefields"
  * determines for each table which of these features applies to that table.
  *
  * @param string $tableName
  *        table name found in the $TCA array
  * @param integer $showHidden
  *        If $showHidden is set (0/1), any hidden-fields in records are
  *        ignored. NOTICE: If you call this function, consider what to do
  *        with the show_hidden parameter.
  * @param array $ignoreArray
  *        Array you can pass where keys can be "disabled", "starttime",
  *        "endtime", "fe_group" (keys from "enablefields" in TCA) and if set
  *        they will make sure that part of the clause is not added. Thus
  *        disables the specific part of the clause. For previewing etc.
  * @param boolean $noVersionPreview
  *        If set, enableFields will be applied regardless of any versioning
  *        preview settings which might otherwise disable enableFields.
  *
  * @return string the WHERE clause starting like " AND ...=... AND ...=..."
  *
  * @throws InvalidArgumentException
  */
 public static function enableFields($tableName, $showHidden = -1, array $ignoreArray = array(), $noVersionPreview = FALSE)
 {
     if (!in_array($showHidden, array(-1, 0, 1))) {
         throw new InvalidArgumentException('$showHidden may only be -1, 0 or 1, but actually is ' . $showHidden, 1331315445);
     }
     // maps $showHidden (-1..1) to (0..2) which ensures valid array keys
     $showHiddenKey = $showHidden + 1;
     $ignoresKey = serialize($ignoreArray);
     $previewKey = intval($noVersionPreview);
     if (!isset(self::$enableFieldsCache[$tableName][$showHiddenKey][$ignoresKey][$previewKey])) {
         self::retrievePageForEnableFields();
         self::$enableFieldsCache[$tableName][$showHiddenKey][$ignoresKey][$previewKey] = self::$pageForEnableFields->enableFields($tableName, $showHidden, $ignoreArray, $noVersionPreview);
     }
     return self::$enableFieldsCache[$tableName][$showHiddenKey][$ignoresKey][$previewKey];
 }
Beispiel #6
0
 /**
  * Automatically render a menu
  *
  * @param array $menu
  * @param integer $level
  * @return string
  */
 protected function autoRender($menu, $level = 1)
 {
     $tagName = $this->arguments['tagNameChildren'];
     $substElementUid = $this->arguments['substElementUid'];
     $linkCurrent = (bool) $this->arguments['linkCurrent'];
     $linkActive = (bool) $this->arguments['linkActive'];
     $showCurrent = (bool) $this->arguments['showCurrent'];
     $html = array();
     foreach ($menu as $page) {
         if ($page['current'] && !$showCurrent) {
             continue;
         }
         $class = trim($page['class']) != '' ? ' class="' . $page['class'] . '"' : '';
         $elementId = $substElementUid ? ' id="elem_' . $page['uid'] . '"' : '';
         $target = $page['target'] != '' ? ' target="' . $page['target'] . '"' : '';
         $html[] = '<' . $tagName . $elementId . $class . '>';
         if ($page['current'] && $linkCurrent === FALSE) {
             $html[] = $page['title'];
         } elseif ($page['active'] && $linkActive === FALSE) {
             $html[] = $page['title'];
         } else {
             $html[] = '<a href="' . $page['link'] . '"' . $class . $target . '>' . $page['title'] . '</a>';
         }
         if (($page['active'] || $this->arguments['expandAll']) && $page['hasSubPages'] && $level < $this->arguments['levels']) {
             $rootLine = $this->pageSelect->getRootLine($page['uid']);
             $rootLine = $this->parseMenu($rootLine, $rootLine);
             $subMenu = $this->pageSelect->getMenu($page['uid']);
             $subMenu = $this->parseMenu($subMenu, $rootLine);
             $renderedSubMenu = $this->autoRender($subMenu, $level + 1);
             $this->tag->setTagName($this->arguments['tagName']);
             $this->tag->setContent($renderedSubMenu);
             $this->tag->addAttribute('class', ($this->arguments['class'] ? $this->arguments['class'] . ' lvl-' : 'lvl-') . strval($level));
             $html[] = $this->tag->render();
             $this->tag->addAttribute('class', $this->arguments['class']);
         }
         $html[] = '</' . $tagName . '>';
     }
     return implode(LF, $html);
 }
 /**
  * Init function, setting the input vars in the global space.
  *
  * @return	void
  */
 function init()
 {
     // Loading internal vars with the GET/POST parameters from outside:
     $this->file = t3lib_div::_GP('file');
     $this->width = t3lib_div::_GP('width');
     $this->height = t3lib_div::_GP('height');
     $this->sample = t3lib_div::_GP('sample');
     $this->alternativeTempPath = t3lib_div::_GP('alternativeTempPath');
     $this->effects = t3lib_div::_GP('effects');
     $this->frame = t3lib_div::_GP('frame');
     $this->bodyTag = t3lib_div::_GP('bodyTag');
     $this->title = t3lib_div::_GP('title');
     $this->wrap = t3lib_div::_GP('wrap');
     $this->md5 = t3lib_div::_GP('md5');
     $this->contentHash = t3lib_div::_GP('contentHash');
     // ***********************
     // Check parameters
     // ***********************
     // If no file-param is given, we must exit
     if (!$this->file) {
         die('Parameter Error: No file given.');
     }
     // Chech md5-checksum: If this md5-value does not match the one submitted, then we fail... (this is a kind of security that somebody don't just hit the script with a lot of different parameters
     $md5_value = md5($this->file . '|' . $this->width . '|' . $this->height . '|' . $this->effects . '|' . $this->bodyTag . '|' . $this->title . '|' . $this->wrap . '|' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] . '|');
     if ($md5_value != $this->md5) {
         die('Parameter Error: Wrong parameters sent.');
     }
     // Need to connect to database, because this is used (typo3temp_db_tracking, cached image dimensions).
     $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password);
     $GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db);
     if (TYPO3_UseCachingFramework) {
         $GLOBALS['typo3CacheManager'] = t3lib_div::makeInstance('t3lib_cache_Manager');
         $GLOBALS['typo3CacheFactory'] = t3lib_div::makeInstance('t3lib_cache_Factory');
         $GLOBALS['typo3CacheFactory']->setCacheManager($GLOBALS['typo3CacheManager']);
         t3lib_cache::initPageCache();
         t3lib_cache::initPageSectionCache();
         t3lib_cache::initContentHashCache();
     }
     // Check for the new content cache hash
     if (strlen(t3lib_div::_GP('contentHash')) > 0) {
         $this->content = t3lib_pageSelect::getHash($this->contentHash);
         if (is_null($this->content)) {
             die('Parameter Error: Content not available.');
         }
     }
     // ***********************
     // Check the file. If must be in a directory beneath the dir of this script...
     // $this->file remains unchanged, because of the code in stdgraphic, but we do check if the file exists within the current path
     // ***********************
     $test_file = PATH_site . $this->file;
     if (!t3lib_div::validPathStr($test_file)) {
         die('Parameter Error: No valid filepath');
     }
     if (!@is_file($test_file)) {
         die('The given file was not found');
     }
 }
 /**
  * Creates language-overlay for records in general (where translation is found in records from the same table)
  *
  * @param	string		Table name
  * @param	array		Record to overlay. Must containt uid, pid and $table]['ctrl']['languageField']
  * @param	integer		Pointer to the sys_language uid for content on the site.
  * @param	string		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 = '')
 {
     //echo $table.'--'.$row['uid'].'--'.$sys_language_content.'--'.$OLmode;
     //echo '<hr>';
     //return parent::getRecordOverlay($table,$row,$sys_language_content,$OLmode);
     global $TCA;
     //echo $row['uid'].'-';  //39348
     //unset olmode
     $OLmode = '';
     //	die('���');
     //call service to know if element is visible and which overlay language to use
     try {
         $element = tx_languagevisibility_feservices::getElement($row['uid'], $table);
         $overlayLanguage = tx_languagevisibility_feservices::getOverlayLanguageIdForElement($element, $sys_language_content);
     } catch (Exception $e) {
         //for any other tables:
         return parent::getRecordOverlay($table, $row, $sys_language_content, $OLmode);
     }
     //debug($overlayLanguage);
     if ($overlayLanguage === false) {
         //echo 'unset  '.$table.'  / '.$row['uid'];
         //not visible:
         unset($row);
         return $row;
     } else {
         //visible:
         if ($overlayLanguage != 0) {
             if ($element instanceof tx_languagevisibility_fceelement) {
                 //for FCE the overlay processing is handled by templavoila module, so mark the row with additional infos:
                 $languageRep = t3lib_div::makeInstance('tx_languagevisibility_languagerepository');
                 $overlayLanguageObj = $languageRep->getLanguageById($overlayLanguage);
                 $row['_OVERLAYLANGUAGEISOCODE'] = $overlayLanguageObj->getIsoCode();
                 return $row;
             } elseif ($element instanceof tx_languagevisibility_fceoverlayelement) {
                 //now its getting tricky: we need to return overlay record with merged XML
                 $olrow = $this->_getDatabaseTranslationOverlayRecord('tt_content', $row, $overlayLanguage);
                 if ($GLOBALS['TSFE']) {
                     $GLOBALS['TSFE']->includeTCA('tt_content');
                 }
                 //parse fce xml, and where a xml field is empty in olrow -> use default one
                 $flexObj = t3lib_div::makeInstance('t3lib_flexformtools');
                 $this->_callbackVar_defaultXML = t3lib_div::xml2array($row['tx_templavoila_flex']);
                 $this->_callbackVar_overlayXML = t3lib_div::xml2array($olrow['tx_templavoila_flex']);
                 if (!is_array($this->_callbackVar_overlayXML)) {
                     $this->_callbackVar_overlayXML = array();
                 }
                 $return = $flexObj->traverseFlexFormXMLData('tt_content', 'tx_templavoila_flex', $row, $this, '_callback_checkXMLFieldsForFallback');
                 $row = parent::getRecordOverlay($table, $row, $overlayLanguage, $OLmode);
                 $row['tx_templavoila_flex'] = t3lib_div::array2xml($this->_callbackVar_overlayXML);
                 return $row;
             } else {
                 //for default elements just do TYPO3 default overlay
                 return parent::getRecordOverlay($table, $row, $overlayLanguage, $OLmode);
             }
         } else {
             return $row;
         }
     }
 }
 /**
  * Generates the API or reads it from cache
  *
  * @param  array $filterNamespaces
  * @param bool $checkGetParam
  * @return string $javascriptNamespaces
  */
 protected function getExtDirectApi(array $filterNamespaces)
 {
     // Check GET-parameter no_cache and extCache setting
     $noCache = isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache']) && ($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] === 0 || $GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] === '0');
     $noCache = t3lib_div::_GET('no_cache') ? TRUE : $noCache;
     // look up into the cache
     $cacheIdentifier = 'ExtDirectApi';
     $cacheHash = md5($cacheIdentifier . implode(',', $filterNamespaces) . t3lib_div::getIndpEnv('TYPO3_SSL') . serialize($this->settings) . TYPO3_MODE . t3lib_div::getIndpEnv('HTTP_HOST'));
     // with no_cache always generate the javascript content
     $cacheContent = $noCache ? '' : t3lib_pageSelect::getHash($cacheHash);
     // generate the javascript content if it wasn't found inside the cache and cache it!
     if (!$cacheContent) {
         $javascriptNamespaces = $this->generateAPI($filterNamespaces);
         if (count($javascriptNamespaces)) {
             t3lib_pageSelect::storeHash($cacheHash, serialize($javascriptNamespaces), $cacheIdentifier);
         }
     } else {
         $javascriptNamespaces = unserialize($cacheContent);
     }
     return $javascriptNamespaces;
 }
Beispiel #10
0
 /**
  * Get content records based on column and pid
  *
  * @return array
  */
 protected function getContentRecords()
 {
     $loadRegister = FALSE;
     if (empty($this->arguments['loadRegister']) === FALSE) {
         $this->contentObject->cObjGetSingle('LOAD_REGISTER', $this->arguments['loadRegister']);
         $loadRegister = TRUE;
     }
     $pid = $this->arguments['pageUid'] ? $this->arguments['pageUid'] : $GLOBALS['TSFE']->id;
     $order = $this->arguments['order'] . ' ' . $this->arguments['sortDirection'];
     $colPos = $this->arguments['column'];
     $contentUids = $this->arguments['contentUids'];
     $slide = $this->arguments['slide'] ? $this->arguments['slide'] : FALSE;
     $slideCollect = $this->arguments['slideCollect'] ? $this->arguments['slideCollect'] : FALSE;
     if ($slideCollect !== FALSE) {
         $slide = min($slide, $slideCollect);
     }
     $slideCollectReverse = $this->arguments['slideCollectReverse'];
     $rootLine = NULL;
     if ($slide) {
         $pageSelect = new t3lib_pageSelect();
         $rootLine = $pageSelect->getRootLine($pid);
         if ($slideCollectReverse) {
             $rootLine = array_reverse($rootLine);
         }
     }
     $content = array();
     do {
         if ($slide) {
             $page = array_shift($rootLine);
             if (!$page) {
                 break;
             }
             $pid = $page['uid'];
         }
         if (is_array($contentUids)) {
             $conditions = 'uid IN (' . implode(',', $contentUids) . ')';
         } else {
             $conditions = "pid = '" . $pid . "' AND colPos = '" . $colPos . "' AND (tx_flux_column = '' OR tx_flux_column IS NULL) " . $GLOBALS['TSFE']->cObj->enableFields('tt_content') . " AND (sys_language_uid IN (-1,0) OR (sys_language_uid = '" . $GLOBALS['TSFE']->sys_language_uid . "' AND l18n_parent = '0'))";
         }
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tt_content', $conditions, 'uid', $order, $this->arguments['limit']);
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $conf = array('tables' => 'tt_content', 'source' => $row['uid'], 'dontCheckPid' => 0);
             array_push($content, $GLOBALS['TSFE']->cObj->RECORDS($conf));
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($res);
         if (count($content) && !$slideCollect) {
             break;
         }
     } while ($slide !== FALSE && --$slide !== -1);
     if ($loadRegister) {
         $this->contentObject->cObjGetSingle('RESTORE_REGISTER', '');
     }
     return $content;
 }
	/**
	 * Fetch the page path (in the correct language)
	 * Return it in an array like:
	 *   array(
	 *     'pagepath' => 'product_omschrijving/another_page_title/',
	 *     'langID' => '2',
	 *   );
	 *
	 * @param	integer		Page ID
	 * @param	string		MP variable string
	 * @param	integer		Language id
	 * @return	array		The page path etc.
	 */
	function IDtoPagePathSegments($id, $mpvar, $langID) {
		// Check to see if we already built this one in this session
		$cacheKey = $id . '.' . $mpvar . '.' . $langID;
		if (!isset($this->IDtoPagePathCache[$cacheKey])) {

			// Get rootLine for current site (overlaid with any language overlay records).
			if (!is_object($this->sys_page)) { // Create object if not found before:
				// Initialize the page-select functions.
				$this->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
				$this->sys_page->init($GLOBALS['TSFE']->showHiddenPage || $this->pObj->isBEUserLoggedIn());
			}
			$this->sys_page->sys_language_uid = $langID;
			$rootLine = $this->sys_page->getRootLine($id, $mpvar);
			$cc = count($rootLine);
			$newRootLine = array();
			$rootFound = FALSE;
			if (!$GLOBALS['TSFE']->tmpl->rootLine) {
				$GLOBALS['TSFE']->tmpl->start($GLOBALS['TSFE']->rootLine);
			}
			// Pass #1 -- check if linking a page in subdomain inside main domain
			$innerSubDomain = false;
			for ($a = $cc - 1; $a >= 0; $a--) {
				if ($rootLine[$a]['is_siteroot']) {
					if ($this->pObj->enableDevLog) {
						t3lib_div::devLog('Found siteroot in the rootline for id=' . $id, 'realurl', 0);
					}
					$rootFound = true;
					$innerSubDomain = true;
					for ( ; $a < $cc; $a++) {
						$newRootLine[] = $rootLine[$a];
					}
					break;
				}
			}
			if (!$rootFound) {
				// Pass #2 -- check normal page
				if ($this->pObj->enableDevLog) {
					t3lib_div::devLog('Starting to walk rootline for id=' . $id . ' from index=' . $a, 'realurl', 0, $rootLine);
				}
				for ($a = 0; $a < $cc; $a++) {
					if ($GLOBALS['TSFE']->tmpl->rootLine[0]['uid'] == $rootLine[$a]['uid']) {
						if ($this->pObj->enableDevLog) {
							t3lib_div::devLog('Found rootline', 'realurl', 0, array('uid' => $id, 'rootline start pid' => $rootLine[$a]['uid']));
						}
						$rootFound = true;
						for ( ; $a < $cc; $a++) {
							$newRootLine[] = $rootLine[$a];
						}
						break;
					}
				}
			}
			if ($rootFound) {
				// Translate the rootline to a valid path (rootline contains localized titles at this point!):
				$pagepath = $this->rootLineToPath($newRootLine, $langID);
				if ($this->pObj->enableDevLog) {
					t3lib_div::devLog('Got page path', 'realurl', 0, array('uid' => $id, 'pagepath' => $pagepath));
				}
				$rootpage_id = $this->conf['rootpage_id'];
				if ($innerSubDomain) {
					$parts = parse_url($pagepath);
					if ($this->pObj->enableDevLog) {
						t3lib_div::devLog('$innerSubDomain=true, showing page path parts', 'realurl', 0, $parts);
					}
					if ($parts['host'] == '') {
						$domain = '';
						foreach ($newRootLine as $rl) {
							$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('domainName', 'sys_domain', 'pid=' . $rl['uid'] . ' AND redirectTo=\'\' AND hidden=0', '', 'sorting');
							if (count($rows)) {
								$domain = $rows[0]['domainName'];
								if ($this->pObj->enableDevLog) {
									t3lib_div::devLog('Found domain', 'realurl', 0, $domain);
								}
								$rootpage_id = $rl['uid'];
							}
						}
					}
				}
				$this->IDtoPagePathCache[$cacheKey] = array(
						'pagepath' => $pagepath,
						'langID' => $langID,
						'rootpage_id' => $rootpage_id,
					);
			}
			else { // Outside of root line:
				$this->IDtoPagePathCache[$cacheKey] = false;
			}
		}

		return $this->IDtoPagePathCache[$cacheKey];
	}
 /**
  * @test
  */
 public function getExtUrlForDokType3AndUrlType0PrependsSiteUrl()
 {
     $this->assertEquals(t3lib_div::getIndpEnv('TYPO3_SITE_URL') . 'hello/world/', $this->pageSelectObject->getExtURL(array('doktype' => 3, 'urltype' => 0, 'url' => 'hello/world/')));
 }
    /**
     * Wraps the input string in link-tags that opens the image in a new window.
     *
     * @param	string		String to wrap, probably an <img> tag
     * @param	string		The original image file
     * @param	array		TypoScript properties for the "imageLinkWrap" function
     * @return	string		The input string, $string, wrapped as configured.
     * @see cImage()
     * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=316&cHash=2848266da6
     */
    function imageLinkWrap($string, $imageFile, $conf)
    {
        $a1 = '';
        $a2 = '';
        $content = $string;
        if ($this->stdWrap($conf['enable'], $conf['enable.'])) {
            $content = $this->typolink($string, $conf['typolink.']);
            $imageFile = $this->stdWrap($imageFile, $conf['file.']);
            // imageFileLink:
            if ($content == $string && @is_file($imageFile)) {
                $params = '';
                if ($conf['width']) {
                    $params .= '&width=' . rawurlencode($conf['width']);
                }
                if ($conf['height']) {
                    $params .= '&height=' . rawurlencode($conf['height']);
                }
                if ($conf['effects']) {
                    $params .= '&effects=' . rawurlencode($conf['effects']);
                }
                if ($conf['sample']) {
                    $params .= '&sample=1';
                }
                if ($conf['alternativeTempPath']) {
                    $params .= '&alternativeTempPath=' . rawurlencode($conf['alternativeTempPath']);
                }
                // includes lines above in cache
                $showPicContent = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>' . htmlspecialchars($conf['title'] ? $conf['title'] : 'Image') . '</title>
	' . ($conf['title'] ? '' : '<meta name="robots" content="noindex,follow" />') . '
</head>
		' . ($conf['bodyTag'] ? $conf['bodyTag'] : '<body>');
                $wrapParts = explode('|', $conf['wrap']);
                $showPicContent .= trim($wrapParts[0]) . '###IMAGE###' . trim($wrapParts[1]);
                $showPicContent .= '
		</body>
		</html>';
                $contentHash = md5('showpic' . $showPicContent);
                t3lib_pageSelect::storeHash($contentHash, $showPicContent, 'showpic');
                $md5_value = md5($imageFile . '|' . $conf['width'] . '|' . $conf['height'] . '|' . $conf['effects'] . '||||' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] . '|');
                $params .= '&md5=' . $md5_value . '&contentHash=' . $contentHash;
                $url = $GLOBALS['TSFE']->absRefPrefix . 'index.php?eID=tx_cms_showpic&file=' . rawurlencode($imageFile) . $params;
                if ($conf['JSwindow.']['altUrl'] || $conf['JSwindow.']['altUrl.']) {
                    $altUrl = $this->stdWrap($conf['JSwindow.']['altUrl'], $conf['JSwindow.']['altUrl.']);
                    if ($altUrl) {
                        $url = $altUrl . ($conf['JSwindow.']['altUrl_noDefaultParams'] ? '' : '?file=' . rawurlencode($imageFile) . $params);
                    }
                }
                // Create TARGET-attribute only if the right doctype is used
                if (!t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype)) {
                    if (isset($conf['target'])) {
                        $target = sprintf(' target="%s"', $conf['target']);
                    } else {
                        $target = ' target="thePicture"';
                    }
                } else {
                    $target = '';
                }
                if ($conf['JSwindow']) {
                    $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
                    $gifCreator->init();
                    $gifCreator->mayScaleUp = 0;
                    $dims = $gifCreator->getImageScale($gifCreator->getImageDimensions($imageFile), $conf['width'], $conf['height'], '');
                    $offset = t3lib_div::intExplode(',', $conf['JSwindow.']['expand'] . ',');
                    $a1 = '<a href="' . htmlspecialchars($url) . '" onclick="' . htmlspecialchars('openPic(\'' . $GLOBALS['TSFE']->baseUrlWrap($url) . '\',\'' . ($conf['JSwindow.']['newWindow'] ? md5($url) : 'thePicture') . '\',\'width=' . ($dims[0] + $offset[0]) . ',height=' . ($dims[1] + $offset[1]) . ',status=0,menubar=0\'); return false;') . '"' . $target . $GLOBALS['TSFE']->ATagParams . '>';
                    $a2 = '</a>';
                    $GLOBALS['TSFE']->setJS('openPic');
                } else {
                    $a1 = '<a href="' . htmlspecialchars($url) . '"' . $target . $GLOBALS['TSFE']->ATagParams . '>';
                    $a2 = '</a>';
                }
                $string = $this->stdWrap($string, $conf['stdWrap.']);
                $content = $a1 . $string . $a2;
            }
        }
        return $content;
    }
 /**
  *
  * @param unknown_type $table
  * @param unknown_type $row
  * @param unknown_type $sys_language_content
  * @param unknown_type $OLmode
  * @param t3lib_pageSelect $parent
  * @return void
  */
 public function getRecordOverlay_postProcess($table, &$row, &$sys_language_content, $OLmode, t3lib_pageSelect $parent)
 {
     if (!is_array($row) || !isset($row['uid']) || $sys_language_content == 0) {
         return;
     }
     try {
         $element = tx_languagevisibility_feservices::getElement($row['uid'], $table);
         $overlayLanguage = tx_languagevisibility_feservices::getOverlayLanguageIdForElement($element, $sys_language_content);
     } catch (Exception $e) {
         return;
     }
     if ($element instanceof tx_languagevisibility_fceelement) {
         //for FCE the overlay processing is handled by templavoila module, so mark the row with additional infos:
         $languageRep = t3lib_div::makeInstance('tx_languagevisibility_languagerepository');
         $overlayLanguageObj = $languageRep->getLanguageById($overlayLanguage);
         $row['_OVERLAYLANGUAGEISOCODE'] = $overlayLanguageObj->getIsoCode();
     } elseif ($element instanceof tx_languagevisibility_fceoverlayelement) {
         //now its getting tricky: we need to return overlay record with merged XML
         $row['tx_templavoila_flex'] = $row['_ORIG_tx_templavoila_flex'];
         unset($row['_ORIG_tx_templavoila_flex']);
         $olrow = $this->_getDatabaseTranslationOverlayRecord('tt_content', $row, $overlayLanguage);
         if ($GLOBALS['TSFE']) {
             $GLOBALS['TSFE']->includeTCA('tt_content');
         }
         //parse fce xml, and where a xml field is empty in olrow -> use default one
         $flexObj = t3lib_div::makeInstance('t3lib_flexformtools');
         $this->_callbackVar_defaultXML = t3lib_div::xml2array($row['tx_templavoila_flex']);
         $this->_callbackVar_overlayXML = t3lib_div::xml2array($olrow['tx_templavoila_flex']);
         if (!is_array($this->_callbackVar_overlayXML)) {
             $this->_callbackVar_overlayXML = array();
         }
         $return = $flexObj->traverseFlexFormXMLData('tt_content', 'tx_templavoila_flex', $row, $this, '_callback_checkXMLFieldsForFallback');
         if ($sys_language_content != $overlayLanguage) {
             $row = $parent->getRecordOverlay($table, $row, $overlayLanguage, $OLmode);
         }
         $row['tx_templavoila_flex'] = t3lib_div::array2xml($this->_callbackVar_overlayXML);
     }
 }
 /**
  * This is all about fetching the right TypoScript template structure. If it's not cached then it must be generated and cached!
  * The method traverses the rootline structure from out to in, fetches the hierarchy of template records and based on this either finds the cached TypoScript template structure or parses the template and caches it for next time.
  * Sets $this->setup to the parsed TypoScript template array
  *
  * @param	array		The rootline of the current page (going ALL the way to tree root)
  * @return	void
  * @see tslib_fe::getConfigArray()
  */
 function start($theRootLine)
 {
     if (is_array($theRootLine)) {
         $setupData = '';
         $hash = '';
         // Flag that indicates that the existing data in cache_pagesection
         // could be used (this is the case if $TSFE->all is set, and the
         // rowSum still matches). Based on this we decide if cache_pagesection
         // needs to be updated...
         $isCached = false;
         $this->runThroughTemplates($theRootLine);
         if ($GLOBALS['TSFE']->all) {
             $cc = $GLOBALS['TSFE']->all;
             // The two rowSums must NOT be different from each other - which they will be if start/endtime or hidden has changed!
             if (strcmp(serialize($this->rowSum), serialize($cc['rowSum']))) {
                 unset($cc);
                 // If the two rowSums differ, we need to re-make the current page data and therefore clear the existing values.
             } else {
                 // If $TSFE->all contains valid data, we don't need to update cache_pagesection (because this data was fetched from there already)
                 if (!strcmp(serialize($this->rootLine), serialize($cc['rootLine']))) {
                     $isCached = true;
                 }
                 // When the data is serialized below (ROWSUM hash), it must not contain the rootline by concept. So this must be removed (and added again later)...
                 unset($cc['rootLine']);
             }
         }
         // This is about getting the hash string which is used to fetch the cached TypoScript template.
         // If there was some cached currentPageData ($cc) then that's good (it gives us the hash).
         if (is_array($cc)) {
             // If currentPageData was actually there, we match the result (if this wasn't done already in $TSFE->getFromCache()...)
             if (!$cc['match']) {
                 // TODO: check if this can ever be the case - otherwise remove
                 $cc = $this->matching($cc);
                 ksort($cc);
             }
             $hash = md5(serialize($cc));
         } else {
             // If currentPageData was not there, we first find $rowSum (freshly generated). After that we try to see, if it is stored with a list of all conditions. If so we match the result.
             $rowSumHash = md5('ROWSUM:' . serialize($this->rowSum));
             $result = t3lib_pageSelect::getHash($rowSumHash);
             if ($result) {
                 $cc = array();
                 $cc['all'] = unserialize($result);
                 $cc['rowSum'] = $this->rowSum;
                 $cc = $this->matching($cc);
                 ksort($cc);
                 $hash = md5(serialize($cc));
             }
         }
         if ($hash) {
             // Get TypoScript setup array
             $setupData = t3lib_pageSelect::getHash($hash);
         }
         if ($setupData && !$this->forceTemplateParsing) {
             // If TypoScript setup structure was cached we unserialize it here:
             $this->setup = unserialize($setupData);
         } else {
             // Make configuration
             $this->generateConfig();
             // This stores the template hash thing
             $cc = array();
             $cc['all'] = $this->sections;
             // All sections in the template at this point is found
             $cc['rowSum'] = $this->rowSum;
             // The line of templates is collected
             $cc = $this->matching($cc);
             ksort($cc);
             $hash = md5(serialize($cc));
             // This stores the data.
             t3lib_pageSelect::storeHash($hash, serialize($this->setup), 'TS_TEMPLATE');
             if ($this->tt_track) {
                 $GLOBALS['TT']->setTSlogMessage('TS template size, serialized: ' . strlen(serialize($this->setup)) . ' bytes');
             }
             $rowSumHash = md5('ROWSUM:' . serialize($this->rowSum));
             t3lib_pageSelect::storeHash($rowSumHash, serialize($cc['all']), 'TMPL_CONDITIONS_ALL');
         }
         // Add rootLine
         $cc['rootLine'] = $this->rootLine;
         ksort($cc);
         // Make global and save
         $GLOBALS['TSFE']->all = $cc;
         // Matching must be executed for every request, so this must never be part of the pagesection cache!
         unset($cc['match']);
         if (!$isCached && !$this->simulationHiddenOrTime && !$GLOBALS['TSFE']->no_cache) {
             // Only save the data if we're not simulating by hidden/starttime/endtime
             $mpvarHash = t3lib_div::md5int($GLOBALS['TSFE']->MP);
             if (TYPO3_UseCachingFramework) {
                 $pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
                 /* @var $pageSectionCache t3lib_cache_AbstractCache */
                 $pageSectionCache->set(intval($GLOBALS['TSFE']->id) . '_' . $mpvarHash, serialize($cc), array('pageId_' . intval($GLOBALS['TSFE']->id), 'mpvarHash_' . $mpvarHash));
             } else {
                 $dbFields = array('content' => serialize($cc), 'tstamp' => $GLOBALS['EXEC_TIME']);
                 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('cache_pagesection', 'page_id=' . intval($GLOBALS['TSFE']->id) . ' AND mpvar_hash=' . $mpvarHash, $dbFields);
                 if ($GLOBALS['TYPO3_DB']->sql_affected_rows() == 0) {
                     $dbFields['page_id'] = intval($GLOBALS['TSFE']->id);
                     $dbFields['mpvar_hash'] = $mpvarHash;
                     $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pagesection', $dbFields);
                 }
             }
         }
         // If everything OK.
         if ($this->rootId && $this->rootLine && $this->setup) {
             $this->loaded = 1;
         }
     }
 }
    /**
     * Parses the ExtDirect configuration array "$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect']"
     * and feeds the given typo3ajax instance with the resulting information. The get parameter
     * "namespace" will be used to filter the configuration.
     *
     * This method makes usage of the reflection mechanism to fetch the methods inside the
     * defined classes together with their amount of parameters. This information are building
     * the API and are required by ExtDirect. The result is cached to improve the overall
     * performance.
     *
     * @param array $ajaxParams ajax parameters
     * @param TYPO3AJAX $ajaxObj typo3ajax instance
     * @return void
     */
    public function getAPI($ajaxParams, TYPO3AJAX $ajaxObj)
    {
        $filterNamespace = t3lib_div::_GET('namespace');
        // Check GET-parameter no_cache and extCache setting
        $extCache = isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache']) && ($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] === 0 || $GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] === '0');
        $noCache = t3lib_div::_GET('no_cache') ? TRUE : $extCache;
        // look up into the cache
        $cacheIdentifier = 'ExtDirectApi';
        $cacheHash = md5($cacheIdentifier . $filterNamespace . serialize($this->settings));
        // with no_cache always generate the javascript content
        $cacheContent = $noCache ? '' : t3lib_pageSelect::getHash($cacheHash);
        // generate the javascript content if it wasn't found inside the cache and cache it!
        if (!$cacheContent) {
            $javascriptNamespaces = $this->generateAPI($filterNamespace);
            if (!empty($javascriptNamespaces)) {
                t3lib_pageSelect::storeHash($cacheHash, serialize($javascriptNamespaces), $cacheIdentifier);
            }
        } else {
            $javascriptNamespaces = unserialize($cacheContent);
        }
        // return the generated javascript API configuration
        if (count($javascriptNamespaces)) {
            $setup = '
				if (typeof Ext.app.ExtDirectAPI !== "object") {
					Ext.app.ExtDirectAPI = {};
				}

				if (typeof Object.extend !== "function") {
					Object.extend = function(destination, source) {
						for (var property in source) {
							destination[property] = source[property];
						}
						return destination;
					};
				}
			';
            $ajaxObj->setContent($javascriptNamespaces);
            $ajaxObj->setContentFormat('javascript');
            $ajaxObj->setJavascriptCallbackWrap($setup . 'Ext.app.ExtDirectAPI = Object.extend(Ext.app.ExtDirectAPI, |);');
        } else {
            if ($filterNamespace) {
                // namespace error
                $errorMessage = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:ExtDirect.namespaceError'), __CLASS__, $filterNamespace);
            } else {
                // no namespace given
                $errorMessage = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:ExtDirect.noNamespace'), __CLASS__);
            }
            // make js multiline message
            $msg = t3lib_div::trimExplode(LF, str_replace('"', '\\"', $errorMessage), TRUE);
            $errorMessage = '';
            foreach ($msg as $line) {
                $errorMessage .= '"' . $line . '" + ' . LF;
            }
            $errorMessage = substr(trim($errorMessage), 0, -1);
            //generate the javascript
            $ajaxObj->setContentFormat('javascript');
            $ajaxObj->setJavascriptCallbackWrap('
				errorMessage = ' . $errorMessage . ';
				if (typeof console === "object") {
					console.log(errorMessage);
				} else {
					alert(errorMessage);
				}
			');
        }
    }
 /**
  * Returns the pages TSconfig array based on the currect ->rootLine
  *
  * @return	array
  */
 function getPagesTSconfig()
 {
     if (!is_array($this->pagesTSconfig)) {
         $TSdataArray = array();
         $TSdataArray[] = $this->TYPO3_CONF_VARS['BE']['defaultPageTSconfig'];
         // Setting default configuration:
         foreach ($this->rootLine as $k => $v) {
             $TSdataArray[] = $v['TSconfig'];
         }
         // Parsing the user TS (or getting from cache)
         $TSdataArray = t3lib_TSparser::checkIncludeLines_array($TSdataArray);
         $userTS = implode(LF . '[GLOBAL]' . LF, $TSdataArray);
         $hash = md5('pageTS:' . $userTS);
         $cachedContent = $this->sys_page->getHash($hash);
         if (isset($cachedContent)) {
             $this->pagesTSconfig = unserialize($cachedContent);
         } else {
             $parseObj = t3lib_div::makeInstance('t3lib_TSparser');
             $parseObj->parse($userTS);
             $this->pagesTSconfig = $parseObj->setup;
             $this->sys_page->storeHash($hash, serialize($this->pagesTSconfig), 'PAGES_TSconfig');
         }
     }
     return $this->pagesTSconfig;
 }
 /**
  * Converts an XML string to a PHP array.
  * This is the reverse function of array2xml()
  * This is a wrapper for xml2arrayProcess that adds a two-level cache
  *
  * @param string $string XML content to convert into an array
  * @param string $NSprefix The tag-prefix resolve, eg. a namespace like "T3:"
  * @param boolean $reportDocTag If set, the document tag will be set in the key "_DOCUMENT_TAG" of the output array
  * @return mixed If the parsing had errors, a string with the error message is returned. Otherwise an array with the content.
  * @see array2xml(),xml2arrayProcess()
  */
 public static function xml2array($string, $NSprefix = '', $reportDocTag = FALSE)
 {
     static $firstLevelCache = array();
     $identifier = md5($string . $NSprefix . ($reportDocTag ? '1' : '0'));
     // look up in first level cache
     if (!empty($firstLevelCache[$identifier])) {
         $array = $firstLevelCache[$identifier];
     } else {
         // look up in second level cache
         $cacheContent = t3lib_pageSelect::getHash($identifier, 0);
         $array = unserialize($cacheContent);
         if ($array === FALSE) {
             $array = self::xml2arrayProcess($string, $NSprefix, $reportDocTag);
             t3lib_pageSelect::storeHash($identifier, serialize($array), 'ident_xml2array');
         }
         // store content in first level cache
         $firstLevelCache[$identifier] = $array;
     }
     return $array;
 }
 /**
  * Returns true if there is a submenu with items for the page id, $uid
  * Used by the item states "IFSUB", "ACTIFSUB" and "CURIFSUB" to check if there is a submenu
  *
  * @param	integer		Page uid for which to search for a submenu
  * @return	boolean		Returns true if there was a submenu with items found
  * @access private
  */
 function isSubMenu($uid)
 {
     // Looking for a mount-pid for this UID since if that exists we should look for a subpages THERE and not in the input $uid;
     $mount_info = $this->sys_page->getMountPointInfo($uid);
     if (is_array($mount_info)) {
         $uid = $mount_info['mount_pid'];
     }
     $recs = $this->sys_page->getMenu($uid, 'uid,pid,doktype,mount_pid,mount_pid_ol,nav_hide,shortcut,shortcut_mode');
     foreach ($recs as $theRec) {
         if (!t3lib_div::inList($this->doktypeExcludeList, $theRec['doktype']) && (!$theRec['nav_hide'] || $this->conf['includeNotInMenu'])) {
             // If a menu item seems to be another type than 'Not in menu', then return true (there were items!)
             return TRUE;
         }
     }
 }