/** * Constructor */ public function __construct() { $http = eZHTTPTool::instance(); // @todo change hasVariable to hasPostVariable if (!$http->hasVariable('key') || !$http->hasVariable('image_id') || !$http->hasVariable('image_version') || !$http->hasVariable('history_version')) { // @todo manage errors return; } $this->key = $http->variable('key'); $this->image_id = $http->variable('image_id'); $this->image_version = $http->variable('image_version'); $this->history_version = $http->variable('history_version'); // retieve the attribute image $this->original_image = eZContentObjectAttribute::fetch($this->image_id, $this->image_version)->attribute('content'); if ($this->original_image === null) { // @todo manage error (the image_id does not match any existing image) return; } // we could store the images in var/xxx/cache/public $this->working_folder = eZSys::cacheDirectory() . "/public/ezie/" . $this->key; $this->image_path = $this->working_folder . "/" . $this->history_version . "-" . $this->original_image->attributeFromOriginal('filename'); // check if file exists (that will mean the data sent is correct) $absolute_image_path = eZSys::rootDir() . "/" . $this->image_path; $handler = eZClusterFileHandler::instance(); if (!$handler->fileExists($this->image_path)) { // @todo manage error return; } $this->prepare_region(); }
public function __construct() { $this->cacheSettings = array('path' => eZSys::cacheDirectory() . '/' . static::$cacheDirectory . '/', 'ttl' => 60); $this->debugAccumulatorGroup = 'nxc_social_networks_feed_'; $this->debugAccumulatorGroup .= strtolower(str_replace(__CLASS__, '', get_called_class())); eZDebug::createAccumulatorGroup($this->debugAccumulatorGroup, static::$debugMessagesGroup); }
function eZMutex($name) { $this->Name = md5($name); $mutexPath = eZDir::path(array(eZSys::cacheDirectory(), 'ezmutex')); eZDir::mkdir($mutexPath, false, true); $this->FileName = eZDir::path(array($mutexPath, $this->Name)); $this->MetaFileName = eZDir::path(array($mutexPath, $this->Name . '_meta')); }
/** * Constructor */ function __construct() { $this->Timestamps = array(); $this->IsModified = false; $cacheDirectory = eZSys::cacheDirectory(); $this->CacheFile = eZClusterFileHandler::instance($cacheDirectory . '/' . 'expiry.php'); $this->restore(); }
/** * @param string $name * @param mixed $value * @param string $cacheFileName * @return mixed|null */ public static function dailyValue( $name, $value = null, $cacheFileName = null ) { if ( $value === null && isset($memoryCache[$name]) && $cacheFileName === null ) { return self::$memoryCache[$name]; } else { if (is_null($cacheFileName)) { $cacheFileName = self::DAILY_CACHE_FILE . '_' . ClusterTool::clusterIdentifier(); } $cache = new eZPHPCreator( eZSys::cacheDirectory(), $cacheFileName . '.php', '', array() ); $expiryTime = time() - 24 * 3600; // reading if ($cache->canRestore($expiryTime)) { $values = $cache->restore(array('cacheTable' => 'cacheTable')); if (is_null($value)) { if (isset($values['cacheTable'][$name])) { return $values['cacheTable'][$name]; } else { return null; } } } else { $values = array('cacheTable' => array()); } $values['cacheTable'][$name] = $value; if ( $cacheFileName == self::DAILY_CACHE_FILE . '_' . ClusterTool::clusterIdentifier() ) self::$memoryCache = $values['cacheTable']; // writing $cache->addVariable('cacheTable', $values['cacheTable']); $cache->store(true); $cache->close(); } return null; }
/** * Creates a new cache storage for a given location through eZ Publish cluster mechanism * Options can contain the 'ttl' ( Time-To-Life ). This is per default set * to 1 day. * * @param string $location Path to the cache location inside the cluster * @param array(string=>string) $options Options for the cache. */ public function __construct($location, $options = array()) { $path = eZSys::cacheDirectory() . '/rest/' . $location; if (!file_exists($path)) { if (!eZDir::mkdir($path, false, true)) { throw new ezcBaseFilePermissionException($path, ezcBaseFileException::WRITE, 'Cache location is not writeable.'); } } parent::__construct($path); $this->properties['options'] = new ezpCacheStorageClusterOptions($options); }
public static function save_token($SettingsBlock, $Token, $TokenSuffix = false) { $ngpush_cache = eZSys::cacheDirectory() . (self::ngpush_cache_dir ? '/' . self::ngpush_cache_dir : ''); $token_file = $ngpush_cache . '/' . (self::token_prefix ? '_' . self::token_prefix : '') . $SettingsBlock . ($TokenSuffix ? '_' . $TokenSuffix : '') . '.txt'; $fileHandler = eZClusterFileHandler::instance($token_file); $fileHandler->storeContents($Token); $storedToken = $fileHandler->fetchContents(); if ($storedToken !== false) { return true; } return false; }
/** * Regression test for issue #18613 : * Empty ezcontentlanguage_cache.php not being regenerated. * This cache file should always exist, but if for some reason it's empty (lost sync with cluster for instance), * it should be at least properly regenerated * * @link http://issues.ez.no/18613 * @group issue18613 */ public function testFetchListWithBlankCacheFile() { // First simulate a problem generating the language cache file (make it blank) $cachePath = eZSys::cacheDirectory() . '/ezcontentlanguage_cache.php'; $clusterFileHandler = eZClusterFileHandler::instance($cachePath); $clusterFileHandler->storeContents('', 'content', 'php'); unset($GLOBALS['eZContentLanguageList']); // Language list should never be empty self::assertNotEmpty(eZContentLanguage::fetchList()); // Remove the test language cache file $clusterFileHandler->delete(); $clusterFileHandler->purge(); }
function handleFile(&$upload, &$result, $filePath, $originalFilename, $mimeinfo, $location, $existingNode) { $tmpDir = getcwd() . "/" . eZSys::cacheDirectory(); $originalFilename = basename($originalFilename); $tmpFile = $tmpDir . "/" . $originalFilename; copy($filePath, $tmpFile); $import = new eZOOImport(); $tmpResult = $import->import($tmpFile, $location, $originalFilename, 'import', $upload); $result['contentobject'] = $tmpResult['Object']; $result['contentobject_main_node'] = $tmpResult['MainNode']; unlink($tmpFile); return true; }
/** * Test scenario for issue #014897: Object/class name pattern and cache issues [patch] * * @result $phpCache->canRestore() returns true * @expected $phpCache->canRestore() should return false * * @link http://issues.ez.no/14897 */ public function testCanRestore() { $db = eZDB::instance(); $dbName = md5($db->DB); $cacheDir = eZSys::cacheDirectory(); $phpCache = new eZPHPCreator($cacheDir, 'classidentifiers_' . $dbName . '.php', '', array('clustering' => 'classidentifiers')); $handler = eZExpiryHandler::instance(); $expiryTime = 0; if ($handler->hasTimestamp('class-identifier-cache')) { $expiryTime = $handler->timestamp('class-identifier-cache'); } $this->assertFalse($phpCache->canRestore($expiryTime)); }
/** * @param string $name * @param mixed $value * @return array */ public static function dailyValue( $name, $value = null) { if ( $value === null && isset($memoryCache[$name]) ) { return self::$memoryCache[$name]; } else { $cache = new eZPHPCreator( eZSys::cacheDirectory(), self::GLOBAL_CACHE_FILE . '.php', '', array() // removed clustering ); $expiryTime = time() - 24 * 3600; // reading if ($cache->canRestore($expiryTime)) { $values = $cache->restore(array('cacheTable' => 'cacheTable')); self::$memoryCache = $values['cacheTable']; if (is_null($value)) { if (isset($values['cacheTable'][$name])) { return $values['cacheTable'][$name]; } else { return null; } } } else { $values = array('cacheTable' => array()); } if ( !is_null($value) ) { $values['cacheTable'][$name] = $value; $cache->addVariable('cacheTable', $values['cacheTable']); $cache->store(true); $cache->close(); } } return null; }
/** * @return mixed */ public function getCssFilePath() { if ( is_null($this->_cssFilePath) ) { $cssDirectory = eZSys::cacheDirectory() . '/css'; $this->_cssFilePath = $cssDirectory .'/' . md5( $this->getLessFilePath() ) . '.css'; if ( !file_exists( $cssDirectory )) { eZDir::mkdir( $cssDirectory ); } } return $this->_cssFilePath; }
function parseFile($fileName) { if (!$fileName) { eZDebug::writeError("eztika cannot find the file {$fileName}; skipping", 'eztika class eZMultiParser'); return false; } $originalFileSize = filesize($fileName); $this->writeEzTikaLog('[START] eZMultiParser for File: ' . round($originalFileSize / 1024, 2) . ' KByte ' . $fileName); $binaryINI = eZINI::instance('binaryfile.ini'); $textExtractionTool = $binaryINI->variable('MultiHandlerSettings', 'TextExtractionTool'); $startTime = mktime(); $tmpName = eZSys::cacheDirectory() . eZSys::fileSeparator() . 'eztika_' . md5($startTime) . '.txt'; $handle = fopen($tmpName, "w"); fclose($handle); chmod($tmpName, 0777); $cmd = "{$textExtractionTool} {$fileName} > {$tmpName}"; $this->writeEzTikaLog('exec: ' . $cmd); // perform eztika command exec($cmd, $returnArray, $returnCode); $this->writeEzTikaLog("exec returnCode: {$returnCode}"); $metaData = ''; if (file_exists($tmpName)) { $fp = fopen($tmpName, 'r'); $fileSize = filesize($tmpName); $metaData = fread($fp, $fileSize); fclose($fp); // keep tempfile in debugmode if ($this->DebugKeepTempFiles === true) { $this->writeEzTikaLog('keep tempfile for debugging extracted metadata: ' . $tmpName); } else { $this->writeEzTikaLog('unlink tempfile: ' . $tmpName); unlink($tmpName); } if ($fileSize === false || $fileSize === 0) { $this->writeEzTikaLog("[ERROR] no metadata was extracted! Check if eztika is working correctly"); } else { $this->writeEzTikaLog('metadata read from tempfile ' . round($fileSize / 1024, 2) . ' KByte'); } } else { $this->writeEzTikaLog("[ERROR] no tempfile '{$tmpName}' for eztika output exists,\n check if eztika command is working,\n check if eztika is executeable"); } // write an error message to error.log if no data could be extracted if ($metaData == '' && $originalFileSize > 0) { eZDebug::writeError("eztika can not extract content from binaryfile for searchindex \nexec( {$cmd} )", 'eztika class eZMultiParser'); } $endTime = mktime(); $seconds = $endTime - $startTime; $this->writeEzTikaLog("[END] after {$seconds} s"); return $metaData; }
/** * Stores the current timestamps values to cache **/ function store() { if ($this->IsModified) { $cacheDirectory = eZSys::cacheDirectory(); $storeString = "<?php\n\$Timestamps = array( "; $i = 0; foreach ($this->Timestamps as $key => $value) { if ($i > 0) { $storeString .= ",\n" . str_repeat(' ', 21); } $storeString .= "'{$key}' => {$value}"; ++$i; } $storeString .= " );\n?>"; $this->CacheFile->storeContents($storeString, 'expirycache', false, true); $this->IsModified = false; } }
public static function clearCache() { eZDebug::writeNotice("Clear calendar taxonomy cache", __METHOD__); $ini = eZINI::instance(); if ($ini->hasVariable('SiteAccessSettings', 'RelatedSiteAccessList') && ($relatedSiteAccessList = $ini->variable('SiteAccessSettings', 'RelatedSiteAccessList'))) { if (!is_array($relatedSiteAccessList)) { $relatedSiteAccessList = array($relatedSiteAccessList); } $relatedSiteAccessList[] = $GLOBALS['eZCurrentAccess']['name']; $siteAccesses = array_unique($relatedSiteAccessList); } else { $siteAccesses = $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList'); } $cacheBaseDir = eZDir::path(array(eZSys::cacheDirectory(), self::cacheDirectory())); $fileHandler = eZClusterFileHandler::instance(); $fileHandler->fileDeleteByDirList($siteAccesses, $cacheBaseDir, ''); $fileHandler = eZClusterFileHandler::instance($cacheBaseDir); $fileHandler->purge(); }
/** * Creates a new cache storage for a given location through eZ Publish cluster mechanism * Options can contain the 'ttl' ( Time-To-Life ). This is per default set * to 1 day. * @param string $location Path to the cache location inside the cluster * @param array(string=>string) $options Options for the cache. */ public function __construct( $location, $options = array() ) { $apiName = ezpRestPrefixFilterInterface::getApiProviderName(); $apiVersion = ezpRestPrefixFilterInterface::getApiVersion(); $location = eZSys::cacheDirectory().'/rest/'.$location; if( !file_exists( $location ) ) { if( !eZDir::mkdir( $location, false, true ) ) { throw new ezcBaseFilePermissionException( $location, ezcBaseFileException::WRITE, 'Cache location is not writeable.' ); } } parent::__construct( $location ); $this->properties['options'] = new ezpCacheStorageClusterOptions( $options ); }
/** * * http://maps.googleapis.com/maps/api/staticmap?zoom=13&size=600x300&maptype=roadmap&markers=color:blue|{first_set( $attribute.content.latitude, '0.0')},{first_set( $attribute.content.longitude, '0.0')} * @param array $parameters * @param eZContentObjectAttribute $attribute * @return string */ public static function gmapStaticImage(array $parameters, eZContentObjectAttribute $attribute, $extraCacheFileNameStrings = array()) { $cacheParameters = array(serialize($parameters)); $cacheFile = $attribute->attribute('id') . implode('-', $extraCacheFileNameStrings) . '-' . md5(implode('-', $cacheParameters)) . '.cache'; $extraPath = eZDir::filenamePath($attribute->attribute('id')); $cacheDir = eZDir::path(array(eZSys::cacheDirectory(), 'gmap_static', $extraPath)); // cacenllo altri file con il medesimo attributo $fileList = array(); $deleteItems = eZDir::recursiveList($cacheDir, $cacheDir, $fileList); foreach ($fileList as $file) { if ($file['type'] == 'file' && $file['name'] !== $cacheFile) { unlink($file['path'] . '/' . $file['name']); } } $cachePath = eZDir::path(array($cacheDir, $cacheFile)); $args = compact('parameters', 'attribute'); $cacheFile = eZClusterFileHandler::instance($cachePath); $result = $cacheFile->processCache(array('OCOperatorsCollectionsTools', 'gmapStaticImageRetrieve'), array('OCOperatorsCollectionsTools', 'gmapStaticImageGenerate'), null, null, $args); return $result; }
static function allDesignBases($siteAccess = false) { // in memory caching if ($siteAccess) { if (isset($GLOBALS['eZTemplateDesignResourceSiteAccessBases'])) { if (isset($GLOBALS['eZTemplateDesignResourceSiteAccessBases'][$siteAccess])) { return $GLOBALS['eZTemplateDesignResourceSiteAccessBases'][$siteAccess]; } } else { $GLOBALS['eZTemplateDesignResourceSiteAccessBases'] = array(); } } else { if (isset($GLOBALS['eZTemplateDesignResourceBases'])) { return $GLOBALS['eZTemplateDesignResourceBases']; } } $designLocationCache = false; $ini = eZINI::instance('site.ini'); if ($ini->variable('DesignSettings', 'DesignLocationCache') == 'enabled') { $designLocationCache = true; } /* * We disable design cache in case of DB clustering * because it will add 2 SQL queries per HTTP request */ $ini = eZINI::instance('file.ini'); if ($ini->variable('ClusteringSettings', 'FileHandler') == 'eZDBFileHandler') { $designLocationCache = false; } if ($designLocationCache) { $siteAccessName = $GLOBALS['eZCurrentAccess']['name']; $cachePath = eZSys::cacheDirectory() . '/' . self::DESIGN_BASE_CACHE_NAME . md5($siteAccessName) . '.php'; $clusterFileHandler = eZClusterFileHandler::instance($cachePath); if ($clusterFileHandler->fileExists($cachePath)) { $designBaseList = unserialize($clusterFileHandler->fetchContents()); self::savesMemoryCache($designBaseList, $siteAccess); } else { // find design locations $designBaseList = self::findDesignBase($ini, $siteAccess); // stores it on the disk $clusterFileHandler->fileStoreContents($cachePath, serialize($designBaseList), 'designbases', 'php'); self::savesMemoryCache($designBaseList, $siteAccess); } } else { // find design locations $designBaseList = self::findDesignBase($ini, $siteAccess); self::savesMemoryCache($designBaseList, $siteAccess); } return $designBaseList; }
static function compilationDirectory() { if (isset($GLOBALS['eZTemplateCompilerSettings']['compilation-directory']) and $GLOBALS['eZTemplateCompilerSettings']['compilation-directory'] !== null) { return $GLOBALS['eZTemplateCompilerSettings']['compilation-directory']; } $compilationDirectory =& $GLOBALS['eZTemplateCompilerDirectory']; if (!isset($compilationDirectory)) { $ini = eZINI::instance(); $shareTemplates = $ini->hasVariable('TemplateSettings', 'ShareCompiledTemplates') ? $ini->variable('TemplateSettings', 'ShareCompiledTemplates') == 'enabled' : false; if ($shareTemplates && $ini->hasVariable('TemplateSettings', 'SharedCompiledTemplatesDir') && trim($ini->variable('TemplateSettings', 'SharedCompiledTemplatesDir')) != '') { $compilationDirectory = eZDir::path(array($ini->variable('TemplateSettings', 'SharedCompiledTemplatesDir'))); } else { $compilationDirectory = eZDir::path(array(eZSys::cacheDirectory(), 'template/compiled')); } } return $compilationDirectory; }
/** * Returns the class identifier hash for the current database. * If it is outdated or non-existent, the method updates/generates the file * * @static * @since Version 4.1 * @access protected * @return array Returns hash of classidentifier => classid */ protected static function classIdentifiersHash() { if (self::$identifierHash === null) { $db = eZDB::instance(); $dbName = md5($db->DB); $cacheDir = eZSys::cacheDirectory(); $phpCache = new eZPHPCreator($cacheDir, 'classidentifiers_' . $dbName . '.php', '', array('clustering' => 'classidentifiers')); eZExpiryHandler::registerShutdownFunction(); $handler = eZExpiryHandler::instance(); $expiryTime = 0; if ($handler->hasTimestamp('class-identifier-cache')) { $expiryTime = $handler->timestamp('class-identifier-cache'); } if ($phpCache->canRestore($expiryTime)) { $var = $phpCache->restore(array('identifierHash' => 'identifier_hash')); self::$identifierHash = $var['identifierHash']; } else { // Fetch identifier/id pair from db $query = "SELECT id, identifier FROM ezcontentclass where version=0"; $identifierArray = $db->arrayQuery($query); self::$identifierHash = array(); foreach ($identifierArray as $identifierRow) { self::$identifierHash[$identifierRow['identifier']] = $identifierRow['id']; } // Store identifier list to cache file $phpCache->addVariable('identifier_hash', self::$identifierHash); $phpCache->store(); } } return self::$identifierHash; }
function storeObjectAttribute($attribute) { $ini = eZINI::instance(); // Delete compiled template $siteINI = eZINI::instance(); if ($siteINI->hasVariable('FileSettings', 'CacheDir')) { $cacheDir = $siteINI->variable('FileSettings', 'CacheDir'); if ($cacheDir[0] == "/") { $cacheDir = eZDir::path(array($cacheDir)); } else { if ($siteINI->hasVariable('FileSettings', 'VarDir')) { $varDir = $siteINI->variable('FileSettings', 'VarDir'); $cacheDir = eZDir::path(array($varDir, $cacheDir)); } } } else { if ($siteINI->hasVariable('FileSettings', 'VarDir')) { $varDir = $siteINI->variable('FileSettings', 'VarDir'); $cacheDir = $ini->variable('FileSettings', 'CacheDir'); $cacheDir = eZDir::path(array($varDir, $cacheDir)); } else { $cacheDir = eZSys::cacheDirectory(); } } $compiledTemplateDir = $cacheDir . "/template/compiled"; eZDir::unlinkWildcard($compiledTemplateDir . "/", "*pagelayout*.*"); // Expire template block cache eZContentCacheManager::clearTemplateBlockCacheIfNeeded(false); }
static function storeRSSExport($Module, $http, $publish = false, $skipValuesID = null) { $valid = true; $validationErrors = array(); /* Kill the RSS cache in all siteaccesses */ $config = eZINI::instance('site.ini'); $cacheDir = eZSys::cacheDirectory(); $availableSiteAccessList = $config->variable('SiteAccessSettings', 'AvailableSiteAccessList'); foreach ($availableSiteAccessList as $siteAccess) { $cacheFilePath = $cacheDir . '/rss/' . md5($siteAccess . $http->postVariable('Access_URL')) . '.xml'; $cacheFile = eZClusterFileHandler::instance($cacheFilePath); if ($cacheFile->exists()) { $cacheFile->delete(); } } $db = eZDB::instance(); $db->begin(); /* Create the new RSS feed */ for ($itemCount = 0; $itemCount < $http->postVariable('Item_Count'); $itemCount++) { if ($skipValuesID == $http->postVariable('Item_ID_' . $itemCount)) { continue; } $rssExportItem = eZRSSExportItem::fetch($http->postVariable('Item_ID_' . $itemCount), true, eZRSSExport::STATUS_DRAFT); if ($rssExportItem == null) { continue; } // RSS is supposed to feed certain objects from the subnodes if ($http->hasPostVariable('Item_Subnodes_' . $itemCount)) { $rssExportItem->setAttribute('subnodes', 1); } else { $rssExportItem->setAttribute('subnodes', 0); } $rssExportItem->setAttribute('class_id', $http->postVariable('Item_Class_' . $itemCount)); $class = eZContentClass::fetch($http->postVariable('Item_Class_' . $itemCount)); $titleClassAttributeIdentifier = $http->postVariable('Item_Class_Attribute_Title_' . $itemCount); $descriptionClassAttributeIdentifier = $http->postVariable('Item_Class_Attribute_Description_' . $itemCount); $categoryClassAttributeIdentifier = $http->postVariable('Item_Class_Attribute_Category_' . $itemCount); if (!$class) { $validated = false; $validationErrors[] = ezpI18n::tr('kernel/rss/edit_export', 'Selected class does not exist'); } else { $dataMap = $class->attribute('data_map'); if (!isset($dataMap[$titleClassAttributeIdentifier])) { $valid = false; $validationErrors[] = ezpI18n::tr('kernel/rss/edit_export', 'Invalid selection for title class %1 does not have attribute "%2"', null, array($class->attribute('name'), $titleClassAttributeIdentifier)); } if ($descriptionClassAttributeIdentifier != '' && !isset($dataMap[$descriptionClassAttributeIdentifier])) { $valid = false; $validationErrors[] = ezpI18n::tr('kernel/rss/edit_export', 'Invalid selection for description class %1 does not have attribute "%2"', null, array($class->attribute('name'), $descriptionClassAttributeIdentifier)); } if ($categoryClassAttributeIdentifier != '' && !isset($dataMap[$categoryClassAttributeIdentifier])) { $valid = false; $validationErrors[] = ezpI18n::tr('kernel/rss/edit_export', 'Invalid selection for category class %1 does not have attribute "%2"', null, array($class->attribute('name'), $categoryClassAttributeIdentifier)); } } $rssExportItem->setAttribute('title', $http->postVariable('Item_Class_Attribute_Title_' . $itemCount)); $rssExportItem->setAttribute('description', $http->postVariable('Item_Class_Attribute_Description_' . $itemCount)); $rssExportItem->setAttribute('category', $http->postVariable('Item_Class_Attribute_Category_' . $itemCount)); if ($http->hasPostVariable('Item_Class_Attribute_Enclosure_' . $itemCount)) { $rssExportItem->setAttribute('enclosure', $http->postVariable('Item_Class_Attribute_Enclosure_' . $itemCount)); } if ($publish && $valid) { $rssExportItem->setAttribute('status', eZRSSExport::STATUS_VALID); $rssExportItem->store(); // delete drafts $rssExportItem->setAttribute('status', eZRSSExport::STATUS_DRAFT); $rssExportItem->remove(); } else { $rssExportItem->store(); } } $rssExport = eZRSSExport::fetch($http->postVariable('RSSExport_ID'), true, eZRSSExport::STATUS_DRAFT); $rssExport->setAttribute('title', $http->postVariable('title')); $rssExport->setAttribute('url', $http->postVariable('url')); // $rssExport->setAttribute( 'site_access', $http->postVariable( 'SiteAccess' ) ); $rssExport->setAttribute('description', $http->postVariable('Description')); $rssExport->setAttribute('rss_version', $http->postVariable('RSSVersion')); $rssExport->setAttribute('number_of_objects', $http->postVariable('NumberOfObjects')); $rssExport->setAttribute('image_id', $http->postVariable('RSSImageID')); if ($http->hasPostVariable('active')) { $rssExport->setAttribute('active', 1); } else { $rssExport->setAttribute('active', 0); } $rssExport->setAttribute('access_url', str_replace(array('/', '?', '&', '>', '<'), '', $http->postVariable('Access_URL'))); if ($http->hasPostVariable('MainNodeOnly')) { $rssExport->setAttribute('main_node_only', 1); } else { $rssExport->setAttribute('main_node_only', 0); } $published = false; if ($publish && $valid) { $rssExport->store(true); // remove draft $rssExport->remove(); $published = true; } else { $rssExport->store(); } $db->commit(); return array('valid' => $valid, 'published' => $published, 'validation_errors' => $validationErrors); }
static function cacheDirectory() { $cacheDirectory =& $GLOBALS['eZTemplateTreeCacheDirectory']; if (!isset($cacheDirectory)) { $cacheDirectory = eZDir::path(array(eZSys::cacheDirectory(), 'template/tree')); } return $cacheDirectory; }
/** * Returns an array with information on the wildcard cache * The array containst the following keys * - dir - The directory for the cache * - file - The base filename for the caches * - path - The entire path (including filename) for the cache * - keys - Array with key values which is used to uniquely identify the cache * @return array */ protected static function cacheInfo() { static $cacheInfo = null; if ( $cacheInfo == null ) { $cacheDir = eZSys::cacheDirectory(); $ini = eZINI::instance(); $keys = array( 'implementation' => $ini->variable( 'DatabaseSettings', 'DatabaseImplementation' ), 'server' => $ini->variable( 'DatabaseSettings', 'Server' ), 'database' => $ini->variable( 'DatabaseSettings', 'Database' ) ); $wildcardKey = md5( implode( "\n", $keys ) ); $wildcardCacheDir = "$cacheDir/wildcard"; $wildcardCacheFile = "wildcard_$wildcardKey"; $wildcardCachePath = "$wildcardCacheDir/$wildcardCacheFile"; $cacheInfo = array( 'dir' => $wildcardCacheDir, 'file' => $wildcardCacheFile, 'path' => $wildcardCachePath, 'keys' => $keys ); } return $cacheInfo; }
function removeRelatedCache($siteAccess) { // Delete compiled template $ini = eZINI::instance(); $iniPath = eZSiteAccess::findPathToSiteAccess($siteAccess); $siteINI = eZINI::instance('site.ini.append', $iniPath); if ($siteINI->hasVariable('FileSettings', 'CacheDir')) { $cacheDir = $siteINI->variable('FileSettings', 'CacheDir'); if ($cacheDir[0] == "/") { $cacheDir = eZDir::path(array($cacheDir)); } else { if ($siteINI->hasVariable('FileSettings', 'VarDir')) { $varDir = $siteINI->variable('FileSettings', 'VarDir'); $cacheDir = eZDir::path(array($varDir, $cacheDir)); } } } else { if ($siteINI->hasVariable('FileSettings', 'VarDir')) { $varDir = $siteINI->variable('FileSettings', 'VarDir'); $cacheDir = $ini->variable('FileSettings', 'CacheDir'); $cacheDir = eZDir::path(array($varDir, $cacheDir)); } else { $cacheDir = eZSys::cacheDirectory(); } } $compiledTemplateDir = $cacheDir . "/template/compiled"; eZDir::unlinkWildcard($compiledTemplateDir . "/", "*pagelayout*.*"); eZCache::clearByTag('template-block'); // Expire content view cache eZContentCacheManager::clearAllContentCache(); }
/** * Creates the cache path if it doesn't exist, and returns the cache * directory. The $userId parameter is used to create multi-level directory names * * @params int $userId * @return string Cache directory for the user */ static function getCacheDir($userId = 0) { $dir = eZSys::cacheDirectory() . '/user-info' . eZDir::createMultilevelPath($userId, 5); if (!is_dir($dir)) { eZDir::mkdir($dir, false, true); } return $dir; }
static function allDesignBases($siteAccess = false) { // in memory caching if ($siteAccess) { if (isset($GLOBALS['eZTemplateDesignResourceSiteAccessBases'])) { if (isset($GLOBALS['eZTemplateDesignResourceSiteAccessBases'][$siteAccess])) { return $GLOBALS['eZTemplateDesignResourceSiteAccessBases'][$siteAccess]; } } else { $GLOBALS['eZTemplateDesignResourceSiteAccessBases'] = array(); } } else { if (isset($GLOBALS['eZTemplateDesignResourceBases'])) { return $GLOBALS['eZTemplateDesignResourceBases']; } } if (eZINI::instance('site.ini')->variable('DesignSettings', 'DesignLocationCache') === 'enabled') { // Using current SA if none given $siteAccessName = $siteAccess !== false ? $siteAccess : $GLOBALS['eZCurrentAccess']['name']; $cachePath = eZSys::cacheDirectory() . '/' . self::DESIGN_BASE_CACHE_NAME . md5($siteAccessName) . '.php'; $clusterFileHandler = eZClusterFileHandler::instance($cachePath); if ($clusterFileHandler->fileExists($cachePath)) { $designBaseList = unserialize($clusterFileHandler->fetchContents()); self::savesMemoryCache($designBaseList, $siteAccess); } else { // find design locations $designBaseList = self::findDesignBase(eZINI::instance('file.ini'), $siteAccess); // stores it on the disk $clusterFileHandler->fileStoreContents($cachePath, serialize($designBaseList), 'designbases', 'php'); self::savesMemoryCache($designBaseList, $siteAccess); } } else { // find design locations $designBaseList = self::findDesignBase(eZINI::instance('file.ini'), $siteAccess); self::savesMemoryCache($designBaseList, $siteAccess); } return $designBaseList; }
static function rootCacheDirectory() { $internalCharset = eZTextCodec::internalCharset(); $ini = eZINI::instance(); $translationRepository = $ini->variable('RegionalSettings', 'TranslationRepository'); $translationExtensions = $ini->variable('RegionalSettings', 'TranslationExtensions'); $uniqueParts = array($internalCharset, $translationRepository, implode(';', $translationExtensions)); $sharedTsCacheDir = $ini->hasVariable('RegionalSettings', 'SharedTranslationCacheDir') ? trim($ini->variable('RegionalSettings', 'SharedTranslationCacheDir')) : ''; if ($sharedTsCacheDir !== '') { $rootCacheDirectory = eZDir::path(array($sharedTsCacheDir, md5(implode('-', $uniqueParts)))); } else { $rootCacheDirectory = eZDir::path(array(eZSys::cacheDirectory(), 'translation', md5(implode('-', $uniqueParts)))); } return $rootCacheDirectory; }
function eZImageManager() { $this->SupportedFormats = array(); $this->SupportedMIMEMap = array(); $this->ImageHandlers = array(); $this->AliasList = array(); $this->Factories = array(); $this->ImageFilters = array(); $this->MIMETypeSettings = array(); $this->MIMETypeSettingsMap = array(); $this->QualityValues = array(); $this->QualityValueMap = array(); $ini = eZINI::instance( 'image.ini' ); $this->TemporaryImageDirPath = eZSys::cacheDirectory() . '/' . $ini->variable( 'FileSettings', 'TemporaryDir' ); }
static function removeAllExpiryCacheFromDisk() { eZSubtreeCache::removeExpiryCacheFromDisk(eZSys::cacheDirectory() . '/template-block-expiry'); }