本文整理汇总了PHP中TYPO3\CMS\Frontend\Page\PageRepository::storeHash方法的典型用法代码示例。如果您正苦于以下问题:PHP PageRepository::storeHash方法的具体用法?PHP PageRepository::storeHash怎么用?PHP PageRepository::storeHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Frontend\Page\PageRepository
的用法示例。
在下文中一共展示了PageRepository::storeHash方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCache
/**
* @param null $data
* @param null $hashVars
* @return null
*/
public function setCache($data = null, $hashVars = null)
{
$lifetime = mktime(23, 59, 59) + 1 - time();
$cacheID = $this->getCacheID(array($hashVars));
PageRepository::storeHash($cacheID, serialize($data), $this->_extKey . '_cache', $lifetime);
return $data;
}
示例2: setCache
public function setCache($data, $funcName = null, $hashVars = null)
{
$tmp = $data;
if (!is_array($data)) {
$tmp = array('__string' => $data);
}
// Um Mitternacht endet der Cache
$lifetime = mktime(23, 59, 59) + 1 - time();
\TYPO3\CMS\Frontend\Page\PageRepository::storeHash($this->getCacheHash($hashVars, $funcName), serialize($tmp), $this->getCacheIdentifier($funcName), $lifetime);
return $data;
}
示例3: xml2array
/**
* 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
$array = \TYPO3\CMS\Frontend\Page\PageRepository::getHash($identifier, 0);
if (!is_array($array)) {
$array = self::xml2arrayProcess($string, $NSprefix, $reportDocTag);
\TYPO3\CMS\Frontend\Page\PageRepository::storeHash($identifier, $array, 'ident_xml2array');
}
// Store content in first level cache
$firstLevelCache[$identifier] = $array;
}
return $array;
}
示例4: getPagesTSconfig
/**
* Returns the pages TSconfig array based on the currect ->rootLine
*
* @return array
* @todo Define visibility
*/
public function getPagesTSconfig()
{
if (!is_array($this->pagesTSconfig)) {
$TSdataArray = array();
// Setting default configuration:
$TSdataArray[] = $this->TYPO3_CONF_VARS['BE']['defaultPageTSconfig'];
foreach ($this->rootLine as $k => $v) {
$TSdataArray[] = $v['TSconfig'];
}
// Parsing the user TS (or getting from cache)
$TSdataArray = \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::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 = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
$parseObj->parse($userTS);
$this->pagesTSconfig = $parseObj->setup;
$this->sys_page->storeHash($hash, serialize($this->pagesTSconfig), 'PAGES_TSconfig');
}
}
return $this->pagesTSconfig;
}
示例5: makeMenu
//.........这里部分代码省略.........
$temp[$c] = $recArr[$v_b];
if ($this->conf['special.'][$v_b . '.']['target']) {
$temp[$c]['target'] = $this->conf['special.'][$v_b . '.']['target'];
}
$tmpSpecialFields = $this->conf['special.'][$v_b . '.']['fields.'];
if (is_array($tmpSpecialFields)) {
foreach ($tmpSpecialFields as $fk => $val) {
$temp[$c][$fk] = $val;
}
}
$c++;
}
}
}
break;
}
if ($this->mconf['sectionIndex']) {
$sectionIndexes = array();
foreach ($temp as $page) {
$sectionIndexes = $sectionIndexes + $this->sectionIndex($altSortField, $page['uid']);
}
$temp = $sectionIndexes;
}
} elseif (is_array($this->alternativeMenuTempArray)) {
// Setting $temp array if not level 1.
$temp = $this->alternativeMenuTempArray;
} elseif ($this->mconf['sectionIndex']) {
$temp = $this->sectionIndex($altSortField);
} else {
// Default:
// gets the menu
$temp = $this->sys_page->getMenu($this->id, '*', $altSortField);
}
$c = 0;
$c_b = 0;
$minItems = intval($this->mconf['minItems'] ? $this->mconf['minItems'] : $this->conf['minItems']);
$maxItems = intval($this->mconf['maxItems'] ? $this->mconf['maxItems'] : $this->conf['maxItems']);
$begin = \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::calc($this->mconf['begin'] ? $this->mconf['begin'] : $this->conf['begin']);
$minItemsConf = isset($this->mconf['minItems.']) ? $this->mconf['minItems.'] : (isset($this->conf['minItems.']) ? $this->conf['minItems.'] : NULL);
$minItems = is_array($minItemsConf) ? $this->parent_cObj->stdWrap($minItems, $minItemsConf) : $minItems;
$maxItemsConf = isset($this->mconf['maxItems.']) ? $this->mconf['maxItems.'] : (isset($this->conf['maxItems.']) ? $this->conf['maxItems.'] : NULL);
$maxItems = is_array($maxItemsConf) ? $this->parent_cObj->stdWrap($maxItems, $maxItemsConf) : $maxItems;
$beginConf = isset($this->mconf['begin.']) ? $this->mconf['begin.'] : (isset($this->conf['begin.']) ? $this->conf['begin.'] : NULL);
$begin = is_array($beginConf) ? $this->parent_cObj->stdWrap($begin, $beginConf) : $begin;
$banUidArray = $this->getBannedUids();
// Fill in the menuArr with elements that should go into the menu:
$this->menuArr = array();
foreach ($temp as $data) {
$spacer = \TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->spacerIDList, $data['doktype']) || !strcmp($data['ITEM_STATE'], 'SPC') ? 1 : 0;
// if item is a spacer, $spacer is set
if ($this->filterMenuPages($data, $banUidArray, $spacer)) {
$c_b++;
// If the beginning item has been reached.
if ($begin <= $c_b) {
$this->menuArr[$c] = $data;
$this->menuArr[$c]['isSpacer'] = $spacer;
$c++;
if ($maxItems && $c >= $maxItems) {
break;
}
}
}
}
// Fill in fake items, if min-items is set.
if ($minItems) {
while ($c < $minItems) {
$this->menuArr[$c] = array('title' => '...', 'uid' => $GLOBALS['TSFE']->id);
$c++;
}
}
// Passing the menuArr through a user defined function:
if ($this->mconf['itemArrayProcFunc']) {
if (!is_array($this->parentMenuArr)) {
$this->parentMenuArr = array();
}
$this->menuArr = $this->userProcess('itemArrayProcFunc', $this->menuArr);
}
// Setting number of menu items
$GLOBALS['TSFE']->register['count_menuItems'] = count($this->menuArr);
$this->hash = md5(serialize($this->menuArr) . serialize($this->mconf) . serialize($this->tmpl->rootLine) . serialize($this->MP_array));
// Get the cache timeout:
if ($this->conf['cache_period']) {
$cacheTimeout = $this->conf['cache_period'];
} else {
$cacheTimeout = $GLOBALS['TSFE']->get_cache_timeout();
}
$serData = $this->sys_page->getHash($this->hash);
if (!$serData) {
$this->generate();
$this->sys_page->storeHash($this->hash, serialize($this->result), 'MENUDATA', $cacheTimeout);
} else {
$this->result = unserialize($serData);
}
// End showAccessRestrictedPages
if ($this->mconf['showAccessRestrictedPages']) {
// RESTORING where_groupAccess
$this->sys_page->where_groupAccess = $SAVED_where_groupAccess;
}
}
}
示例6: start
/**
* 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 $theRootLine The rootline of the current page (going ALL the way to tree root)
* @return void
* @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::getConfigArray()
* @todo Define visibility
*/
public 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 (serialize($this->rowSum) !== serialize($cc['rowSum'])) {
unset($cc);
} else {
// If $TSFE->all contains valid data, we don't need to update cache_pagesection (because this data was fetched from there already)
if (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 = \TYPO3\CMS\Frontend\Page\PageRepository::getHash($rowSumHash);
if (is_array($result)) {
$cc = array();
$cc['all'] = $result;
$cc['rowSum'] = $this->rowSum;
$cc = $this->matching($cc);
ksort($cc);
$hash = md5(serialize($cc));
}
}
if ($hash) {
// Get TypoScript setup array
$setupData = \TYPO3\CMS\Frontend\Page\PageRepository::getHash($hash);
}
if (is_array($setupData) && !$this->forceTemplateParsing) {
// If TypoScript setup structure was cached we unserialize it here:
$this->setup = $setupData;
if ($this->tt_track) {
$GLOBALS['TT']->setTSLogMessage('Using cached TS template data');
}
} else {
if ($this->tt_track) {
$GLOBALS['TT']->setTSLogMessage('Not using any cached TS data');
}
// Make configuration
$this->generateConfig();
// This stores the template hash thing
$cc = array();
// All sections in the template at this point is found
$cc['all'] = $this->sections;
// The line of templates is collected
$cc['rowSum'] = $this->rowSum;
$cc = $this->matching($cc);
ksort($cc);
$hash = md5(serialize($cc));
// This stores the data.
\TYPO3\CMS\Frontend\Page\PageRepository::storeHash($hash, $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));
\TYPO3\CMS\Frontend\Page\PageRepository::storeHash($rowSumHash, $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
//.........这里部分代码省略.........
示例7: getPagesTSconfig
/**
* Returns the pages TSconfig array based on the currect ->rootLine
*
* @return array
*/
public function getPagesTSconfig()
{
if (!is_array($this->pagesTSconfig)) {
$TSdataArray = array();
foreach ($this->rootLine as $k => $v) {
$TSdataArray[] = $v['TSconfig'];
}
// Adding the default configuration:
$TSdataArray[] = $this->TYPO3_CONF_VARS['BE']['defaultPageTSconfig'];
// Bring everything in the right order. Default first, then the Rootline down to the current page
$TSdataArray = array_reverse($TSdataArray);
// Parsing the user TS (or getting from cache)
$TSdataArray = TypoScriptParser::checkIncludeLines_array($TSdataArray);
$userTS = implode(LF . '[GLOBAL]' . LF, $TSdataArray);
$hash = md5('pageTS:' . $userTS);
$cachedContent = $this->sys_page->getHash($hash);
if (is_array($cachedContent)) {
$this->pagesTSconfig = $cachedContent;
} else {
$parseObj = GeneralUtility::makeInstance(TypoScriptParser::class);
$parseObj->parse($userTS);
$this->pagesTSconfig = $parseObj->setup;
$this->sys_page->storeHash($hash, $this->pagesTSconfig, 'PAGES_TSconfig');
}
}
return $this->pagesTSconfig;
}
示例8: xml2array
/**
* 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 bool $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
// @todo: Is this cache really required? It basically substitutes a little cpu work with a db query?
$array = PageRepository::getHash($identifier, 0);
if (!is_array($array)) {
$array = self::xml2arrayProcess($string, $NSprefix, $reportDocTag);
PageRepository::storeHash($identifier, $array, 'ident_xml2array');
}
// Store content in first level cache
$firstLevelCache[$identifier] = $array;
}
return $array;
}
示例9: getExtDirectApi
/**
* Generates the API or reads it from cache
*
* @param array $filterNamespaces
* @param boolean $checkGetParam
* @return string $javascriptNamespaces
*/
protected function getExtDirectApi(array $filterNamespaces)
{
$noCache = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('no_cache') ? TRUE : FALSE;
// Look up into the cache
$cacheIdentifier = 'ExtDirectApi';
$cacheHash = md5($cacheIdentifier . implode(',', $filterNamespaces) . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL') . serialize($this->settings) . TYPO3_MODE . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('HTTP_HOST'));
// With no_cache always generate the javascript content
$cacheContent = $noCache ? '' : \TYPO3\CMS\Frontend\Page\PageRepository::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)) {
\TYPO3\CMS\Frontend\Page\PageRepository::storeHash($cacheHash, serialize($javascriptNamespaces), $cacheIdentifier);
}
} else {
$javascriptNamespaces = unserialize($cacheContent);
}
return $javascriptNamespaces;
}
示例10: getExtDirectApi
/**
* Generates the API or reads it from cache
*
* @param array $filterNamespaces
* @param bool $checkGetParam
* @return string $javascriptNamespaces
*/
protected function getExtDirectApi(array $filterNamespaces)
{
$noCache = (bool) GeneralUtility::_GET('no_cache');
// Look up into the cache
$cacheIdentifier = 'ExtDirectApi';
$cacheHash = md5($cacheIdentifier . implode(',', $filterNamespaces) . GeneralUtility::getIndpEnv('TYPO3_SSL') . serialize($this->settings) . TYPO3_MODE . GeneralUtility::getIndpEnv('HTTP_HOST'));
// With no_cache always generate the javascript content
// Generate the javascript content if it wasn't found inside the cache and cache it!
if ($noCache || !is_array($javascriptNamespaces = \TYPO3\CMS\Frontend\Page\PageRepository::getHash($cacheHash))) {
$javascriptNamespaces = $this->generateAPI($filterNamespaces);
if (!empty($javascriptNamespaces)) {
\TYPO3\CMS\Frontend\Page\PageRepository::storeHash($cacheHash, $javascriptNamespaces, $cacheIdentifier);
}
}
return $javascriptNamespaces;
}
示例11: getApi
/**
* Fetches the API from cache_hash or ceates an API
*
* @param string $routeUrl
* @param string $namespace
* @param boolean $readFromCache Should the cache be used when reading the data.
* @param boolean $writeToCache Should the created api be stored in the cache.
* @return array
*/
public function getApi($routeUrl = '', $namespace = 'Ext.ux.TYPO3.app', $readFromCache = TRUE, $writeToCache = TRUE)
{
$cacheHash = md5($this->cacheStorageKey . serialize($this->frameworkConfiguration['controllerConfiguration']));
$cachedApi = $readFromCache ? \TYPO3\CMS\Frontend\Page\PageRepository::getHash($cacheHash) : FALSE;
if ($cachedApi) {
$api = unserialize(\TYPO3\CMS\Frontend\Page\PageRepository::getHash($cacheHash));
} else {
$api = $this->createApi($routeUrl, $namespace);
if ($writeToCache) {
\TYPO3\CMS\Frontend\Page\PageRepository::storeHash($cacheHash, serialize($api), $this->cacheStorageKey);
}
}
return $api;
}