本文整理汇总了PHP中eZContentLanguage::expireCache方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentLanguage::expireCache方法的具体用法?PHP eZContentLanguage::expireCache怎么用?PHP eZContentLanguage::expireCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentLanguage
的用法示例。
在下文中一共展示了eZContentLanguage::expireCache方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMapLanguage
/**
* Test that fetching the language listing, works after languages
* have been altered in database, and then later refetched.
*
* @link http://issues.ez.no/15484
*/
public function testMapLanguage()
{
$db = eZDB::instance();
eZContentLanguage::addLanguage('nno-NO', 'Nynorsk');
$localeToChangeInto = 'dan-DK';
$languageNameToChangeInto = 'Danish';
$langObject = eZContentLanguage::fetchByLocale('nno-NO');
$langId = (int) $langObject->attribute('id');
$updateSql = <<<END
UPDATE ezcontent_language
SET
locale='{$localeToChangeInto}',
name='{$languageNameToChangeInto}'
WHERE
id={$langId}
END;
$db->query($updateSql);
eZContentLanguage::expireCache();
$newLangObject = eZContentLanguage::fetchByLocale($localeToChangeInto);
if (!$newLangObject instanceof eZContentLanguage) {
self::fail("Language object not returned. Old version provided by cache?");
}
$newLangId = (int) $newLangObject->attribute('id');
self::assertEquals($langId, $newLangId, "New language not mapped to existing language");
}
示例2: testIssue13497
/**
* Test for regression #13497:
* attribute operator throws a PHP fatal error on a node without parent in a displayable language
*
* Situation:
* - siteaccess with one language (fre-FR) and ShowUntranslatedObjects disabled
* - parent content node in another language (eng-GB) with always available disabled
* - content node in the siteaccess' language (fre-FR)
* - fetch this fre-FR node from anywhere, and call attribute() on it
*
* Result:
* - Fatal error: Call to a member function attribute() on a non-object in
* kernel/classes/ezcontentobjecttreenode.php on line 4225
*
* Explanation: the error actually comes from the can_remove_location attribute
*/
public function testIssue13497()
{
$bkpLanguages = eZContentLanguage::prioritizedLanguageCodes();
// Create a folder in english only
$folder = new ezpObject("folder", 2, 14, 1, 'eng-GB');
$folder->setAlwaysAvailableLanguageID(false);
$folder->name = "Parent for " . __FUNCTION__;
$folder->publish();
$locale = eZLocale::instance('fre-FR');
$translation = eZContentLanguage::addLanguage($locale->localeCode(), $locale->internationalLanguageName());
// Create an article in french only, as a subitem of the previously created folder
$article = new ezpObject("article", $folder->attribute('main_node_id'), 14, 1, 'fre-FR');
$article->title = "Object for " . __FUNCTION__;
$article->short_description = "Description of test for " . __FUNCTION__;
$article->publish();
$articleNodeID = $article->attribute('main_node_id');
// INi changes: set language to french only, untranslatedobjects disabled
ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'ContentObjectLocale', 'fre-FR');
// ezpINIHelper::setINISetting( 'site.ini', 'RegionalSettings', 'SiteLanguageList', array( 'fre-FR' ) );
eZContentLanguage::setPrioritizedLanguages(array('fre-FR'));
ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'ShowUntranslatedObjects', 'disabled');
eZContentLanguage::expireCache();
// This should crash
eZContentObjectTreeNode::fetch($articleNodeID)->attribute('can_remove_location');
ezpINIHelper::restoreINISettings();
// re-expire cache for further tests
eZContentLanguage::setPrioritizedLanguages($bkpLanguages);
$article->remove();
$translation->removeThis();
eZContentLanguage::expireCache();
ezpINIHelper::restoreINISettings();
}
示例3: tearDown
public function tearDown()
{
$this->folder->remove();
$this->article->remove();
eZPendingActions::removeByAction('index_object');
$this->nodeIds = array();
$this->objectIds = array();
$anonymousUser = eZUser::fetchByName('anonymous');
eZUser::setCurrentlyLoggedInUser($anonymousUser, $anonymousUser->attribute('contentobject_id'));
eZContentLanguage::expireCache();
parent::tearDown();
}
示例4: __construct
public function __construct($theClass = '', $name = '')
{
parent::__construct($theClass, $name);
if (!self::$script instanceof eZScript) {
self::$script = eZScript::instance(array('description' => "eZ Publish Test Runner\n\nsets up an eZ Publish testing environment\n", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
// Override INI override folder from settings/override to
// tests/settings to not read local override settings
$ini = eZINI::instance();
$ini->setOverrideDirs(array(array('tests/settings', true)), 'override');
$ini->loadCache();
// Be sure to have clean content language data
eZContentLanguage::expireCache();
self::$script->startup();
self::$script->initialize();
// Avoids Fatal error: eZ Publish did not finish its request if die() is used.
eZExecution::setCleanExit();
}
}
示例5: initializePackage
//.........这里部分代码省略.........
array(),
$typeFunctionality['required'] );
$extraFunctionality = array_unique( $extraFunctionality );
*/
// Add a policy to permit editors using OE
eZPolicy::createNew(3, array('ModuleName' => 'ezoe', 'FunctionName' => '*'));
// Install site package and it's required packages
$sitePackageName = $this->chosenSitePackage();
$sitePackage = eZPackage::fetch($sitePackageName);
if (!is_object($sitePackage)) {
$resultArray['errors'][] = array('code' => 'EZSW-041', 'text' => " Could not fetch site package: '{$sitePackageName}'");
return false;
}
$dependecies = $sitePackage->attribute('dependencies');
$requires = $dependecies['requires'];
$requiredPackages = array();
// Include setting files
$settingsFiles = $sitePackage->attribute('settings-files');
foreach ($settingsFiles as $settingsFileName) {
if (file_exists($sitePackage->path() . '/settings/' . $settingsFileName)) {
include_once $sitePackage->path() . '/settings/' . $settingsFileName;
}
}
// Call user function for additional setup tasks.
if (function_exists('eZSitePreInstall')) {
eZSitePreInstall($siteType);
}
// Make sure objects use the selected main language instead of eng-GB
if ($primaryLanguageLocaleCode != 'eng-GB') {
$engLanguageObj = eZContentLanguage::fetchByLocale('eng-GB');
$engLanguageID = (int) $engLanguageObj->attribute('id');
$updateSql = "UPDATE ezcontent_language\nSET\nlocale='{$primaryLanguageLocaleCode}',\nname='{$primaryLanguageName}'\nWHERE\nid={$engLanguageID}";
$db->query($updateSql);
eZContentLanguage::expireCache();
$primaryLanguageObj = eZContentLanguage::fetchByLocale($primaryLanguageLocaleCode);
// Add it if it is missing (most likely)
if (!$primaryLanguageObj) {
$primaryLanguageObj = eZContentLanguage::addLanguage($primaryLanguageLocaleCode, $primaryLanguageName);
}
$primaryLanguageID = (int) $primaryLanguageObj->attribute('id');
// Find objects which are always available
if ($db->databaseName() == 'oracle') {
$sql = "SELECT id\nFROM\nezcontentobject\nWHERE\nbitand( language_mask, 1 ) = 1";
} else {
$sql = "SELECT id\nFROM\nezcontentobject\nWHERE\nlanguage_mask & 1 = 1";
}
$objectList = array();
$list = $db->arrayQuery($sql);
foreach ($list as $row) {
$objectList[] = (int) $row['id'];
}
$inSql = 'IN ( ' . implode(', ', $objectList) . ')';
// Updates databases that have eng-GB data to the new locale.
$updateSql = "UPDATE ezcontentobject_name\nSET\ncontent_translation='{$primaryLanguageLocaleCode}',\nreal_translation='{$primaryLanguageLocaleCode}',\nlanguage_id={$primaryLanguageID}\nWHERE\ncontent_translation='eng-GB' OR\nreal_translation='eng-GB'";
$db->query($updateSql);
// Fix always available
$updateSql = "UPDATE ezcontentobject_name\nSET\nlanguage_id=language_id+1\nWHERE\ncontentobject_id {$inSql}";
$db->query($updateSql);
// attributes
$updateSql = "UPDATE ezcontentobject_attribute\nSET\nlanguage_code='{$primaryLanguageLocaleCode}',\nlanguage_id={$primaryLanguageID}\nWHERE\nlanguage_code='eng-GB'";
$db->query($updateSql);
// Fix always available
$updateSql = "UPDATE ezcontentobject_attribute\nSET\nlanguage_id=language_id+1\nWHERE\ncontentobject_id {$inSql}";
$db->query($updateSql);
// version
$updateSql = "UPDATE ezcontentobject_version\nSET\ninitial_language_id={$primaryLanguageID},\nlanguage_mask={$primaryLanguageID}\nWHERE\ninitial_language_id={$engLanguageID}";
示例6: setUp
public function setUp()
{
eZDir::recursiveDelete(eZINI::instance()->variable('FileSettings', 'VarDir'));
eZContentLanguage::expireCache();
}
示例7: foreach
$autoloadArray = (include 'autoload/ezp_kernel.php');
foreach ($autoloadArray as $class => $file) {
// Exclude files from the tests directory
if (strpos($file, 'tests') !== 0) {
// PHPUnit_Util_Filter::addFileToWhitelist( "{$baseDir}/{$file}" ); //fixme
}
}
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "eZ Publish Test Runner\n\n" . "sets up an eZ Publish testing environment" . "\n", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
// Override INI override folder from settings/override to
// tests/settings to not read local override settings
$ini = eZINI::instance();
$ini->setOverrideDirs(array(array('tests/settings', true)), 'override');
$ini->loadCache();
// Be sure to have clean content language data
eZContentLanguage::expireCache();
$script->startup();
// $options = $script->getOptions();
$script->initialize();
// Avoids Fatal error: eZ Publish did not finish its request if die() is used.
eZExecution::setCleanExit();
$version = PHPUnit_Runner_Version::id();
if (version_compare($version, '3.5.0') == -1 && $version !== '@package_version@') {
die("PHPUnit 3.5.0 (or later) is required to run this test suite.\n");
}
require_once 'PHP/CodeCoverage.php';
$codeCoverage = new PHP_CodeCoverage();
$codeCoverage->filter()->addFileToBlacklist(__FILE__, 'PHPUNIT');
//require_once 'bootstrap.php';
try {
$runner = ezpTestRunner::instance();
示例8: change
/**
* Changes the site access to what's defined in $access. It will change the
* access path in eZSys and prepend an override dir to eZINI
* Note: does not load extensions, use {@link eZSiteAccess::load()} if you want that
*
* @since 4.4
* @param array $access An associative array with 'name' (string), 'type' (int) and 'uri_part' (array).
* See {@link eZSiteAccess::match()} for array structure definition
* @param eZINI|null $siteINI Optional parameter to be able to only do change on specific instance of site.ini
* hence skip changing eZSys access paths (but not siteaccess, see {@link eZSiteAccess::load()})
* @return array The $access parameter
*/
static function change(array $access, eZINI $siteINI = null)
{
$name = $access['name'];
$GLOBALS['eZCurrentAccess'] =& $access;
if ($siteINI !== null) {
$ini = $siteINI;
} else {
$ini = eZINI::instance();
}
$ini->prependOverrideDir("siteaccess/{$name}", false, 'siteaccess', 'siteaccess');
/* Make sure extension siteaccesses are prepended */
eZExtension::prependExtensionSiteAccesses($name, $ini);
$ini->loadCache();
// change some global settings if $siteINI is null
if ($siteINI === null) {
eZSys::clearAccessPath();
if (empty($access['uri_part']) || $access['uri_part'] === null) {
if ($ini->hasVariable('SiteSettings', 'SiteUriParts')) {
$access['uri_part'] = $ini->variable('SiteSettings', 'SiteUriParts');
} else {
if (isset($access['type']) && $access['type'] === eZSiteAccess::TYPE_URI) {
$access['uri_part'] = array($access['name']);
} else {
$access['uri_part'] = array();
}
}
} else {
$access['uri_part'] = self::washName($access['uri_part']);
}
eZSys::setAccessPath($access['uri_part'], $name);
eZContentLanguage::expireCache(false);
eZUpdateDebugSettings();
eZDebugSetting::writeDebug('kernel-siteaccess', "Updated settings to use siteaccess '{$name}'", __METHOD__);
}
return $access;
}
示例9: createMFSitemap
public static function createMFSitemap()
{
eZDebug::writeDebug("Generating Standard Sitemap with images ...", __METHOD__);
$cli = $GLOBALS['cli'];
global $cli, $isQuiet;
if (!$isQuiet) {
$cli->output("Generating Sitemap for Siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " \n");
}
$ini = eZINI::instance('site.ini');
$googlesitemapsINI = eZINI::instance('xrowsitemap.ini');
// Get the Sitemap's root node
$contentINI = eZINI::instance('content.ini');
$rootNode = eZContentObjectTreeNode::fetch($contentINI->variable('NodeSettings', 'RootNode'));
if (!$rootNode instanceof eZContentObjectTreeNode) {
$cli->output("Invalid RootNode for Siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " \n");
continue;
}
// Settings variables
if ($googlesitemapsINI->hasVariable('MFSitemapSettings', 'ClassFilterType') and $googlesitemapsINI->hasVariable('MFSitemapSettings', 'ClassFilterArray')) {
$params2 = array('ClassFilterType' => $googlesitemapsINI->variable('MFSitemapSettings', 'ClassFilterType'), 'ClassFilterArray' => $googlesitemapsINI->variable('MFSitemapSettings', 'ClassFilterArray'));
}
$max = 49997;
// max. amount of links in 1 sitemap
$limit = 50;
// Fetch the content tree
$params = array('SortBy' => array(array('depth', true), array('published', false)));
if (isset($params2)) {
$params = array_merge($params, $params2);
}
$subtreeCount = eZContentObjectTreeNode::subTreeCountByNodeID($params, $rootNode->NodeID);
if ($subtreeCount == 1) {
$cli->output("No Items found under node #" . $contentINI->variable('NodeSettings', 'RootNode') . ".");
}
if (!$isQuiet) {
$amount = $subtreeCount + 1;
// +1 is root node
$cli->output("Adding {$amount} nodes to the sitemap.");
$output = new ezcConsoleOutput();
$bar = new ezcConsoleProgressbar($output, $amount);
}
$addPrio = false;
if ($googlesitemapsINI->hasVariable('MFSitemapSettings', 'AddPriorityToSubtree') and $googlesitemapsINI->variable('MFSitemapSettings', 'AddPriorityToSubtree') == 'true') {
$addPrio = true;
}
$sitemap = new xrowSitemap();
// Generate Sitemap
/** START Adding the root node **/
$object = $rootNode->object();
$meta = xrowMetaDataFunctions::fetchByObject($object);
$extensions = array();
$extensions[] = new xrowSitemapItemModified($rootNode->attribute('modified_subnode'));
$url = $rootNode->attribute('url_alias');
eZURI::transformURI($url, true);
if ($ini->variable('SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess') == 'enabled') {
$url = 'http://' . xrowSitemapTools::domain() . $url;
} else {
$url = 'http://' . xrowSitemapTools::domain() . '/' . $GLOBALS['eZCurrentAccess']['name'] . $url;
}
if ($meta and $meta->googlemap != '0') {
$extensions[] = new xrowSitemapItemFrequency($meta->change);
$extensions[] = new xrowSitemapItemPriority($meta->priority);
$sitemap->add($url, $extensions);
} elseif ($meta === false and $googlesitemapsINI->variable('Settings', 'AlwaysAdd') == 'enabled') {
if ($addPrio) {
$extensions[] = new xrowSitemapItemPriority('1');
}
$sitemap->add($url, $extensions);
}
if (isset($bar)) {
$bar->advance();
}
/** END Adding the root node **/
$max = min($max, $subtreeCount);
$params['Limit'] = min($max, $limit);
$params['Offset'] = 0;
while ($params['Offset'] < $max) {
$nodeArray = eZContentObjectTreeNode::subTreeByNodeID($params, $rootNode->NodeID);
foreach ($nodeArray as $subTreeNode) {
eZContentLanguage::expireCache();
$object = $subTreeNode->object();
$images = array();
$meta = xrowMetaDataFunctions::fetchByObject($object);
$extensions = array();
$extensions[] = new xrowSitemapItemModified($subTreeNode->attribute('modified_subnode'));
$url = $subTreeNode->attribute('url_alias');
eZURI::transformURI($url, true);
if ($ini->variable('SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess') == 'enabled') {
$url = 'http://' . xrowSitemapTools::domain() . $url;
} else {
$url = 'http://' . xrowSitemapTools::domain() . '/' . $GLOBALS['eZCurrentAccess']['name'] . $url;
}
if ($meta and $meta->googlemap != '0') {
$extensions[] = new xrowSitemapItemFrequency($meta->change);
$extensions[] = new xrowSitemapItemPriority($meta->priority);
} elseif ($meta === false and $googlesitemapsINI->variable('Settings', 'AlwaysAdd') == 'enabled') {
if ($addPrio) {
$rootDepth = $rootNode->attribute('depth');
$prio = 1 - ($subTreeNode->attribute('depth') - $rootDepth) / 10;
if ($prio > 0) {
$extensions[] = new xrowSitemapItemPriority($prio);
//.........这里部分代码省略.........
示例10: createMobileSitemap
public static function createMobileSitemap()
{
eZDebug::writeDebug("Generating mobile sitemap ...", __METHOD__);
$cli = eZCLI::instance();
if (!$isQuiet) {
$cli->output("Generating mobile sitemap for siteaccess " . $GLOBALS['eZCurrentAccess']['name'] . " \n");
}
$ini = eZINI::instance('site.ini');
$xrowsitemapINI = eZINI::instance('xrowsitemap.ini');
// Get the Sitemap's root node
$rootNode = self::rootNode();
// Settings variables
if ($xrowsitemapINI->hasVariable('MobileSitemapSettings', 'ClassFilterType') and $xrowsitemapINI->hasVariable('MobileSitemapSettings', 'ClassFilterArray')) {
$params2 = array('ClassFilterType' => $xrowsitemapINI->variable('MobileSitemapSettings', 'ClassFilterType'), 'ClassFilterArray' => $xrowsitemapINI->variable('MobileSitemapSettings', 'ClassFilterArray'));
}
$max = self::MAX_PER_FILE;
$limit = 50;
// Fetch the content tree
$params = array('SortBy' => array(array('depth', true), array('published', true)));
if (isset($params2)) {
$params = array_merge($params, $params2);
}
$subtreeCount = eZContentObjectTreeNode::subTreeCountByNodeID($params, $rootNode->NodeID);
if ($subtreeCount == 1) {
$cli->output("No Items found under RootNode {$rootNode->NodeID}.");
}
if (!$isQuiet) {
$amount = $subtreeCount + 1;
// +1 is root node
$cli->output("Adding {$amount} nodes to the sitemap for RootNode {$rootNode->NodeID}.");
$output = new ezcConsoleOutput();
$bar = new ezcConsoleProgressbar($output, $amount);
}
$addPrio = false;
if ($xrowsitemapINI->hasVariable('Settings', 'AddPriorityToSubtree') and $xrowsitemapINI->variable('Settings', 'AddPriorityToSubtree') == 'true') {
$addPrio = true;
}
$sitemap = new xrowMobileSitemap();
// Generate Sitemap
/** START Adding the root node **/
$object = $rootNode->object();
$meta = xrowMetaDataFunctions::fetchByObject($object);
$extensions = array();
$extensions[] = new xrowSitemapItemModified($rootNode->attribute('modified_subnode'));
$url = $rootNode->attribute('url_alias');
eZURI::transformURI($url);
if ($xrowsitemapINI->hasVariable('SitemapSettings', 'MobileDomainName') && $xrowsitemapINI->hasVariable('SitemapSettings', 'MobileDomainName') != '') {
$mobileDomain = $xrowsitemapINI->variable('SitemapSettings', 'MobileDomainName');
} else {
$mobileDomain = self::domain();
}
$url = 'http://' . $mobileDomain . $url;
if ($meta and $meta->sitemap_use != '0') {
$extensions[] = new xrowSitemapItemFrequency($meta->change);
$extensions[] = new xrowSitemapItemPriority($meta->priority);
$sitemap->add($url, $extensions);
} elseif ($meta === false and $xrowsitemapINI->variable('Settings', 'AlwaysAdd') == 'enabled') {
if ($addPrio) {
$extensions[] = new xrowSitemapItemPriority('1');
}
$sitemap->add($url, $extensions);
}
if (isset($bar)) {
$bar->advance();
}
/** END Adding the root node **/
$max = min($max, $subtreeCount);
$params['Limit'] = min($max, $limit);
$params['Offset'] = 0;
while ($params['Offset'] < $max) {
$nodeArray = eZContentObjectTreeNode::subTreeByNodeID($params, $rootNode->NodeID);
foreach ($nodeArray as $subTreeNode) {
eZContentLanguage::expireCache();
$meta = xrowMetaDataFunctions::fetchByNode($subTreeNode);
$extensions = array();
$extensions[] = new xrowSitemapItemModified($subTreeNode->attribute('modified_subnode'));
$url = $subTreeNode->attribute('url_alias');
eZURI::transformURI($url);
$url = 'http://' . $mobileDomain . $url;
if ($meta and $meta->sitemap_use != '0') {
$extensions[] = new xrowSitemapItemFrequency($meta->change);
$extensions[] = new xrowSitemapItemPriority($meta->priority);
$sitemap->add($url, $extensions);
} elseif ($meta === false and $xrowsitemapINI->variable('Settings', 'AlwaysAdd') == 'enabled') {
if ($addPrio) {
$rootDepth = $rootNode->attribute('depth');
$prio = 1 - ($subTreeNode->attribute('depth') - $rootDepth) / 10;
if ($prio > 0) {
$extensions[] = new xrowSitemapItemPriority($prio);
}
}
$sitemap->add($url, $extensions);
}
if (isset($bar)) {
$bar->advance();
}
}
eZContentObject::clearCache();
$params['Offset'] += $params['Limit'];
}
//.........这里部分代码省略.........