$cli->output('RSSImport ' . $rssImport->attribute('name') . ': Invalid RSS version missmatch. Please reconfigure import.'); continue; } switch ($root->getAttribute('version')) { default: case '1.0': rssImport1($root, $rssImport, $cli); break; case '0.91': case '0.92': case '2.0': rssImport2($root, $rssImport, $cli); break; } } eZStaticCache::executeActions(); /*! Parse RSS 1.0 feed \param DOM root node \param RSS Import item \param cli */ function rssImport1($root, $rssImport, $cli) { $addCount = 0; // Get all items in rss feed $itemArray = $root->getElementsByTagName('item'); $channel = $root->getElementsByTagName('channel')->item(0); // Loop through all items in RSS feed foreach ($itemArray as $item) {
$script = eZScript::instance( array( 'description' => ( "eZ Publish static cache generator\n" . "\n" . "./bin/makestaticcache.php --siteaccess user" ), 'use-session' => false, 'use-modules' => true, 'use-extensions' => true ) ); $script->startup(); $options = $script->getOptions( "[f|force]", "", array( 'force' => "Force generation of cache files even if they already exist." ) ); $force = $options['force']; $script->initialize(); $staticCache = new eZStaticCache(); $staticCache->generateCache( $force, false, $cli, false ); if ( !$force ) { $staticCache->generateAlwaysUpdatedCache( false, $cli, false ); } eZStaticCache::executeActions(); $script->shutdown(); ?>
if ($module->hasActionParameter('ObjectID')) { $objectID = $module->actionParameter('ObjectID'); } if ($cacheType == 'All') { eZCache::clearAll(); } elseif ($cacheType == 'Template') { eZCache::clearByTag('template'); } elseif ($cacheType == 'Content') { eZCache::clearByTag('content'); } elseif ($cacheType == 'TemplateContent') { eZCache::clearByTag('template'); eZCache::clearByTag('content'); } elseif ($cacheType == 'Ini') { eZCache::clearByTag('ini'); } elseif ($cacheType == 'Static') { $staticCache = new eZStaticCache(); $staticCache->generateCache(true, true); $cacheCleared['static'] = true; } elseif ($cacheType == 'ContentNode') { $contentModule = eZModule::exists('content'); if ($contentModule instanceof eZModule) { $contentModule->setCurrentAction('ClearViewCache', 'action'); $contentModule->setActionParameter('NodeID', $nodeID, 'action'); $contentModule->setActionParameter('ObjectID', $objectID, 'action'); $contentModule->run('action', array($nodeID, $objectID)); } } elseif ($cacheType == 'ContentSubtree') { $contentModule = eZModule::exists('content'); if ($contentModule instanceof eZModule) { $contentModule->setCurrentAction('ClearViewCacheSubtree', 'action'); $contentModule->setActionParameter('NodeID', $nodeID, 'action');
$source = $paramList[1]; $destination = $paramList[0]; $invalid = isset($paramList[2]) ? $paramList[2] : null; if (!isset($fileContentCache[$source])) { $cli->output("Fetching URL: {$source}"); $fileContentCache[$source] = eZHTTPTool::getDataByURL($source, false, eZStaticCache::USER_AGENT); } if ($fileContentCache[$source] === false) { $cli->error("Could not grab content from \"{$source}\", is the hostname correct and Apache running?"); if ($invalid !== null) { $deleteParams[] = $param; continue; } $markInvalidParams[] = $param; } else { eZStaticCache::storeCachedFile($destination, $fileContentCache[$source]); $deleteParams[] = $param; } } if (!empty($markInvalidParams)) { $db->begin(); $db->query("UPDATE ezpending_actions SET param=( " . $db->concatString(array("param", "',invalid'")) . " ) WHERE param IN ( '" . implode("','", $markInvalidParams) . "' )"); $db->commit(); } if (!empty($deleteParams)) { $db->begin(); $db->query("DELETE FROM ezpending_actions WHERE action='static_store' AND param IN ( '" . implode("','", $deleteParams) . "' )"); $db->commit(); } else { $offset += $limit; }
/** * This function goes over the list of recorded actions and excecutes them. */ static function executeActions() { if ( empty( self::$actionList ) ) { return; } $fileContentCache = array(); $doneDestList = array(); $ini = eZINI::instance( 'staticcache.ini'); $clearByCronjob = ( $ini->variable( 'CacheSettings', 'CronjobCacheClear' ) == 'enabled' ); if ( $clearByCronjob ) { $db = eZDB::instance(); } foreach ( self::$actionList as $action ) { list( $action, $parameters ) = $action; switch( $action ) { case 'store': list( $destination, $source ) = $parameters; if ( isset( $doneDestList[$destination] ) ) continue 2; if ( $clearByCronjob ) { $param = $db->escapeString( $destination . ',' . $source ); $db->query( 'INSERT INTO ezpending_actions( action, param ) VALUES ( \'static_store\', \''. $param . '\' )' ); $doneDestList[$destination] = 1; } else { if ( !isset( $fileContentCache[$source] ) ) { if ( eZHTTPTool::getDataByURL( $source, true, eZStaticCache::USER_AGENT ) ) $fileContentCache[$source] = eZHTTPTool::getDataByURL( $source, false, eZStaticCache::USER_AGENT ); else $fileContentCache[$source] = false; } if ( $fileContentCache[$source] === false ) { eZDebug::writeError( "Could not grab content (from $source), is the hostname correct and Apache running?", 'Static Cache' ); } else { eZStaticCache::storeCachedFile( $destination, $fileContentCache[$source] ); $doneDestList[$destination] = 1; } } break; } } self::$actionList = array(); }
/** * Performs a redirection */ protected function redirect() { $GLOBALS['eZRedirection'] = true; $ini = eZINI::instance(); $automaticRedirect = true; if ($GLOBALS['eZDebugAllowed'] && ($redirUri = $ini->variable('DebugSettings', 'DebugRedirection')) !== 'disabled') { if ($redirUri == "enabled") { $automaticRedirect = false; } else { $uri = eZURI::instance(eZSys::requestURI()); $uri->toBeginning(); foreach ($ini->variableArray("DebugSettings", "DebugRedirection") as $redirUri) { $redirUri = new eZURI($redirUri); if ($redirUri->matchBase($uri)) { $automaticRedirect = false; break; } } } } $redirectURI = eZSys::indexDir(); $moduleRedirectUri = $this->module->redirectURI(); if ($ini->variable('URLTranslator', 'Translation') === 'enabled' && eZURLAliasML::urlTranslationEnabledByUri(new eZURI($moduleRedirectUri))) { $translatedModuleRedirectUri = $moduleRedirectUri; if (eZURLAliasML::translate($translatedModuleRedirectUri, true)) { $moduleRedirectUri = $translatedModuleRedirectUri; if (strlen($moduleRedirectUri) > 0 && $moduleRedirectUri[0] !== '/') { $moduleRedirectUri = '/' . $moduleRedirectUri; } } } if (preg_match('#^(\\w+:)|^//#', $moduleRedirectUri)) { $redirectURI = $moduleRedirectUri; } else { $leftSlash = strlen($redirectURI) > 0 && $redirectURI[strlen($redirectURI) - 1] === '/'; $rightSlash = strlen($moduleRedirectUri) > 0 && $moduleRedirectUri[0] === '/'; if (!$leftSlash && !$rightSlash) { // Both are without a slash, so add one $moduleRedirectUri = '/' . $moduleRedirectUri; } else { if ($leftSlash && $rightSlash) { // Both are with a slash, so we remove one $moduleRedirectUri = substr($moduleRedirectUri, 1); } } $redirectURI .= $moduleRedirectUri; } eZStaticCache::executeActions(); eZDB::checkTransactionCounter(); if ($automaticRedirect) { eZHTTPTool::redirect($redirectURI, array(), $this->module->redirectStatus()); } else { // Make sure any errors or warnings are reported if ($ini->variable('DebugSettings', 'DisplayDebugWarnings') === 'enabled') { if (isset($GLOBALS['eZDebugError']) && $GLOBALS['eZDebugError']) { eZAppendWarningItem(array('error' => array('type' => 'error', 'number' => 1, 'count' => $GLOBALS['eZDebugErrorCount']), 'identifier' => 'ezdebug-first-error', 'text' => ezpI18n::tr('index.php', 'Some errors occurred, see debug for more information.'))); } if (isset($GLOBALS['eZDebugWarning']) && $GLOBALS['eZDebugWarning']) { eZAppendWarningItem(array('error' => array('type' => 'warning', 'number' => 1, 'count' => $GLOBALS['eZDebugWarningCount']), 'identifier' => 'ezdebug-first-warning', 'text' => ezpI18n::tr('index.php', 'Some general warnings occured, see debug for more information.'))); } } $tpl = eZTemplate::factory(); $tpl->setVariable('site', $this->site); $tpl->setVariable('warning_list', !empty($this->warningList) ? $this->warningList : false); $tpl->setVariable('redirect_uri', eZURI::encodeURL($redirectURI)); $templateResult = $tpl->fetch('design:redirect.tpl'); eZDebug::addTimingPoint("Script end"); eZDisplayResult($templateResult); } eZExecution::cleanExit(); }
function removeThis() { $ini = eZINI::instance(); $object = $this->object(); $nodeID = $this->attribute('node_id'); if (eZAudit::isAuditEnabled()) { // Set audit params. $objectID = $object->attribute('id'); $objectName = $object->attribute('name'); eZAudit::writeAudit('content-delete', array('Node ID' => $nodeID, 'Object ID' => $objectID, 'Content Name' => $objectName, 'Comment' => 'Removed the current node: eZContentObjectTreeNode::removeNode()')); } $db = eZDB::instance(); $db->begin(); $nodePath = $this->attribute('path_string'); $childrensPath = $nodePath; $pathString = " path_string like '{$childrensPath}%' "; $urlAlias = $this->attribute('url_alias'); // Remove static cache if ($ini->variable('ContentSettings', 'StaticCache') == 'enabled') { $staticCache = new eZStaticCache(); $staticCache->removeURL("/" . $urlAlias); $staticCache->generateAlwaysUpdatedCache(); $parent = $this->fetchParent(); } $db->query("DELETE FROM ezcontentobject_tree\n WHERE {$pathString} OR\n path_string = '{$nodePath}'"); // Re-cache parent node if ($ini->variable('ContentSettings', 'StaticCache') == 'enabled') { if ($parent) { $staticCache->cacheURL("/" . $parent->urlAlias()); } } // Clean up URL alias entries eZURLAliasML::removeByAction('eznode', $nodeID); // Clean up content cache eZContentCacheManager::clearContentCacheIfNeeded($this->attribute('contentobject_id')); // clean up user cache if (in_array($object->attribute('contentclass_id'), eZUser::contentClassIDs())) { eZUser::removeSessionData($object->attribute('id')); eZUser::purgeUserCacheByUserId($object->attribute('id')); } $parentNode = $this->attribute('parent'); if (is_object($parentNode)) { eZContentCacheManager::clearContentCacheIfNeeded($parentNode->attribute('contentobject_id')); $parentNode->updateAndStoreModified(); } // Clean up policies and limitations eZRole::cleanupByNode($this); // Clean up recent items eZContentBrowseRecent::removeRecentByNodeID($nodeID); // Clean up bookmarks eZContentBrowseBookmark::removeByNodeID($nodeID); // Clean up tip-a-friend counter eZTipafriendCounter::removeForNode($nodeID); // Clean up view counter eZViewCounter::removeCounter($nodeID); $db->commit(); }
static function clearObjectViewCache( $objectIDList, $versionNum = true, $additionalNodeList = false ) { eZDebug::accumulatorStart( 'node_cleanup_list', '', 'Node cleanup list' ); $nodeList = array(); foreach ($objectIDList as $objectID) { $tmp = eZContentCacheManager::nodeList( $objectID, $versionNum ); if (is_array($tmp) ) { $nodeList = array_merge($nodeList, $tmp); } } if ( $nodeList === false and !is_array( $additionalNodeList ) ) { return false; } if ( $nodeList === false ) { $nodeList = array(); } if ( is_array( $additionalNodeList ) ) { array_splice( $nodeList, count( $nodeList ), 0, $additionalNodeList ); } if ( count( $nodeList ) == 0 ) { return false; } $nodeList = array_unique( $nodeList ); eZDebug::accumulatorStop( 'node_cleanup_list' ); eZDebugSetting::writeDebug( 'kernel-content-edit', count( $nodeList ), "count in nodeList" ); $ini = eZINI::instance(); if ( $ini->variable( 'ContentSettings', 'StaticCache' ) == 'enabled' ) { $staticCache = new eZStaticCache(); $staticCache->generateAlwaysUpdatedCache(); $staticCache->generateNodeListCache( $nodeList ); } eZDebug::accumulatorStart( 'node_cleanup', '', 'Node cleanup' ); eZContentObject::expireComplexViewModeCache(); $cleanupValue = eZContentCache::calculateCleanupValue( count( $nodeList ) ); if ( eZContentCache::inCleanupThresholdRange( $cleanupValue ) ) { eZContentCache::cleanup( $nodeList ); } else { eZContentObject::expireAllViewCache(); } eZDebug::accumulatorStop( 'node_cleanup' ); return true; }
static function generateObjectViewCache($objectID) { // Generate the view cache $ini = eZINI::instance(); $object = eZContentObject::fetch($objectID); $user = eZUser::currentUser(); eZDebug::accumulatorStart('generate_cache', '', 'Generating view cache'); if ($ini->variable('ContentSettings', 'PreViewCache') == 'enabled') { $preCacheSiteaccessArray = $ini->variable('ContentSettings', 'PreCacheSiteaccessArray'); $currentSiteAccess = $GLOBALS['eZCurrentAccess']; // This is the default view parameters for content/view $viewParameters = array('offset' => 0, 'year' => false, 'month' => false, 'day' => false, 'namefilter' => false); if (is_array($preCacheSiteaccessArray) && count($preCacheSiteaccessArray) > 0) { foreach ($preCacheSiteaccessArray as $changeToSiteAccess) { $newSiteAccess = $currentSiteAccess; $newSiteAccess['name'] = $changeToSiteAccess; unset($newSiteAccess['uri_part']); //eZSiteAccess::load() will take care of setting correct one eZSiteAccess::load($newSiteAccess); $tpl = eZTemplate::factory(); // Get the sitedesign and cached view preferences for this siteaccess $siteini = eZINI::instance('site.ini'); $cachedViewPreferences = $siteini->variable('ContentSettings', 'CachedViewPreferences'); $language = false; // Needs to be specified if you want to generate the cache for a specific language $viewMode = 'full'; $assignedNodes = $object->assignedNodes(); foreach ($assignedNodes as $node) { // We want to generate the cache for the specified user $previewCacheUsers = $ini->variable('ContentSettings', 'PreviewCacheUsers'); foreach ($previewCacheUsers as $previewCacheUserID) { // If the text is 'anon' we need to fetch the Anonymous user ID. if ($previewCacheUserID === 'anonymous') { $previewCacheUserID = $siteini->variable("UserSettings", "AnonymousUserID"); $previewCacheUser = eZUser::fetch($previewCacheUserID); } else { if ($previewCacheUserID === 'current') { $previewCacheUser = $user; } else { $previewCacheUser = eZUser::fetch($previewCacheUserID); } } if (!$previewCacheUser) { continue; } // Before we generate the view cache we must change the currently logged in user to $previewCacheUser // If not the templates might read in wrong personalized data (preferences etc.) eZUser::setCurrentlyLoggedInUser($previewCacheUser, $previewCacheUser->attribute('contentobject_id')); // Cache the current node $cacheFileArray = eZNodeviewfunctions::generateViewCacheFile($previewCacheUser, $node->attribute('node_id'), 0, false, $language, $viewMode, $viewParameters, $cachedViewPreferences); $tmpRes = eZNodeviewfunctions::generateNodeView($tpl, $node, $node->attribute('object'), $language, $viewMode, 0, $cacheFileArray['cache_dir'], $cacheFileArray['cache_path'], true, $viewParameters); // Cache the parent node $parentNode = $node->attribute('parent'); $objectID = $parentNode->attribute('contentobject_id'); // if parent objectID is null or is 0 we should not create cache. if ($objectID) { $cacheFileArray = eZNodeviewfunctions::generateViewCacheFile($previewCacheUser, $parentNode->attribute('node_id'), 0, false, $language, $viewMode, $viewParameters, $cachedViewPreferences); $tmpRes = eZNodeviewfunctions::generateNodeView($tpl, $parentNode, $parentNode->attribute('object'), $language, $viewMode, 0, $cacheFileArray['cache_dir'], $cacheFileArray['cache_path'], true, $viewParameters); } } } } // Restore the old user as the current one eZUser::setCurrentlyLoggedInUser($user, $user->attribute('contentobject_id')); // restore siteaccess eZSiteAccess::load($currentSiteAccess); } } if ($ini->variable('ContentSettings', 'StaticCache') == 'enabled') { $nodes = array(); $ini = eZINI::instance(); $staticCache = new eZStaticCache(); $useURLAlias =& $GLOBALS['eZContentObjectTreeNodeUseURLAlias']; $pathPrefix = $ini->variable('SiteAccessSettings', 'PathPrefix'); if (!isset($useURLAlias)) { $useURLAlias = $ini->variable('URLTranslator', 'Translation') == 'enabled'; } eZContentCacheManager::nodeListForObject($object, true, self::CLEAR_DEFAULT, $nodes, $handledObjectList); // If no nodes returns it means that ClearCacheMethod = self::CLEAR_NO_CACHE if (count($nodes)) { foreach ($nodes as $nodeID) { if ($useURLAlias) { $oNode = eZContentObjectTreeNode::fetch($nodeID, false, true); if (!isset($oNode)) { continue; } $urlAlias = $oNode->urlAlias(); if ($pathPrefix != '') { $tempAlias = substr($pathPrefix, strlen($pathPrefix) - 1) == '/' ? $urlAlias . '/' : $urlAlias; if (strncmp($tempAlias, $pathPrefix, strlen($tempAlias)) == 0) { $urlAlias = substr($tempAlias, strlen($pathPrefix)); } } } else { $urlAlias = 'content/view/full/' . $nodeID; } $staticCache->cacheURL('/' . $urlAlias, $nodeID); } $staticCache->generateAlwaysUpdatedCache(); } } eZDebug::accumulatorStop('generate_cache'); }