本文整理汇总了PHP中eZPreferences::values方法的典型用法代码示例。如果您正苦于以下问题:PHP eZPreferences::values方法的具体用法?PHP eZPreferences::values怎么用?PHP eZPreferences::values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZPreferences
的用法示例。
在下文中一共展示了eZPreferences::values方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateViewCacheFile
static function generateViewCacheFile($user, $nodeID, $offset, $layout, $language, $viewMode, $viewParameters = false, $cachedViewPreferences = false, $viewCacheTweak = '')
{
$cacheNameExtra = '';
$ini = eZINI::instance();
if (!$language) {
$language = false;
}
if (!$viewCacheTweak && $ini->hasVariable('ContentSettings', 'ViewCacheTweaks')) {
$viewCacheTweaks = $ini->variable('ContentSettings', 'ViewCacheTweaks');
if (isset($viewCacheTweaks[$nodeID])) {
$viewCacheTweak = $viewCacheTweaks[$nodeID];
} else {
if (isset($viewCacheTweaks['global'])) {
$viewCacheTweak = $viewCacheTweaks['global'];
}
}
}
// should we use current siteaccess or let several siteaccesse share cache?
if (strpos($viewCacheTweak, 'ignore_siteaccess_name') === false) {
$currentSiteAccess = $GLOBALS['eZCurrentAccess']['name'];
} else {
$currentSiteAccess = $ini->variable('SiteSettings', 'DefaultAccess');
}
$cacheHashArray = array($nodeID, $viewMode, $language, $offset, $layout);
// several user related cache tweaks
if (strpos($viewCacheTweak, 'ignore_userroles') === false) {
$cacheHashArray[] = implode('.', $user->roleIDList());
}
if (strpos($viewCacheTweak, 'ignore_userlimitedlist') === false) {
$cacheHashArray[] = implode('.', $user->limitValueList());
}
if (strpos($viewCacheTweak, 'ignore_discountlist') === false) {
$cacheHashArray[] = implode('.', eZUserDiscountRule::fetchIDListByUserID($user->attribute('contentobject_id')));
}
$cacheHashArray[] = eZSys::indexFile();
// Add access type to cache hash if current access is uri type (so uri and host doesn't share cache)
if (strpos($viewCacheTweak, 'ignore_siteaccess_type') === false && $GLOBALS['eZCurrentAccess']['type'] === eZSiteAccess::TYPE_URI) {
$cacheHashArray[] = eZSiteAccess::TYPE_URI;
}
// Make the cache unique for every logged in user
if (strpos($viewCacheTweak, 'pr_user') !== false and !$user->isAnonymous()) {
$cacheNameExtra = $user->attribute('contentobject_id') . '-';
}
// Make the cache unique for every case of view parameters
if (strpos($viewCacheTweak, 'ignore_viewparameters') === false && $viewParameters) {
$vpString = '';
ksort($viewParameters);
foreach ($viewParameters as $key => $value) {
if (!$key || $key === '_custom') {
continue;
}
$vpString .= 'vp:' . $key . '=' . $value;
}
$cacheHashArray[] = $vpString;
}
// Make the cache unique for every case of the preferences
if ($cachedViewPreferences === false) {
$depPreferences = $ini->variable('ContentSettings', 'CachedViewPreferences');
} else {
$depPreferences = $cachedViewPreferences;
}
if (strpos($viewCacheTweak, 'ignore_userpreferences') === false && isset($depPreferences[$viewMode])) {
$depPreferences = explode(';', $depPreferences[$viewMode]);
$pString = '';
// Fetch preferences for the specified user
$preferences = eZPreferences::values($user);
foreach ($depPreferences as $pref) {
$pref = explode('=', $pref);
if (isset($pref[0])) {
if (isset($preferences[$pref[0]])) {
$pString .= 'p:' . $pref[0] . '=' . $preferences[$pref[0]] . ';';
} else {
if (isset($pref[1])) {
$pString .= 'p:' . $pref[0] . '=' . $pref[1] . ';';
}
}
}
}
$cacheHashArray[] = $pString;
}
$cacheFile = $nodeID . '-' . $cacheNameExtra . md5(implode('-', $cacheHashArray)) . '.cache';
$extraPath = eZDir::filenamePath($nodeID);
$cacheDir = eZDir::path(array(eZSys::cacheDirectory(), $ini->variable('ContentSettings', 'CacheDir'), $currentSiteAccess, $extraPath));
$cachePath = eZDir::path(array($cacheDir, $cacheFile));
return array('cache_path' => $cachePath, 'cache_dir' => $cacheDir, 'cache_file' => $cacheFile);
}
示例2: setCookie
public static function setCookie()
{
$ini = eZINI::instance('scachecookie.ini');
$siteIni = eZINI::instance('site.ini');
$hasUserData = false;
$displayedData = $ini->variable('CacheCookieSettings', 'DisplayedData');
$cookieValue = $ini->variable('CacheCookieSettings', 'CookieValue') || 'true';
if ($cookieValue === true) {
$cookieValue = 'true';
}
$useDetailedValue = $ini->variable('CacheCookieSettings', 'DetailedCookieValue') == 'enabled';
$detailedValue = '';
if (in_array('basket', $displayedData)) {
$http = eZHTTPTool::instance();
$sessionID = $http->sessionID();
$basket = eZBasket::fetch($sessionID);
if ($basket) {
if (!$basket->isEmpty()) {
$hasUserData = true;
if ($useDetailedValue) {
$detailedValue .= ',basket';
}
}
}
}
if ((!$hasUserData || $useDetailedValue) && in_array('wishlist', $displayedData)) {
$user = eZUser::currentUser();
$userID = $user->attribute('contentobject_id');
$WishListArray = eZPersistentObject::fetchObjectList(eZWishList::definition(), null, array("user_id" => $userID), null, null, true);
if (count($WishListArray) > 0) {
if ($WishListArray[0]->itemCount() > 0) {
$hasUserData = true;
if ($useDetailedValue) {
$detailedValue .= ',wishlist';
}
}
}
}
if (!$hasUserData || $useDetailedValue) {
$prefs = eZPreferences::values();
$hasPrefs = false;
foreach ($prefs as $key => $val) {
if ($key != '') {
if (in_array('preferences', $displayedData) || in_array($key, $displayedData)) {
if ($val != '') {
$hasUserData = true;
if ($useDetailedValue) {
if (in_array('preferences', $displayedData) && !$hasPrefs) {
$detailedValue .= ',preferences';
}
if (in_array($key, $displayedData)) {
$detailedValue .= ",{$key}:{$val}";
}
}
$hasPrefs = true;
}
}
}
}
}
$value = $hasUserData ? $cookieValue . $detailedValue : false;
$wwwDir = eZSys::wwwDir();
$cookiePath = $wwwDir != '' ? $wwwDir : '/';
setcookie($ini->variable('CacheCookieSettings', 'CookieName'), $value, time() + (int) $siteIni->variable('Session', 'SessionTimeout'), $cookiePath);
}