public function runPreRoutingFilters( ezcMvcRequest $request ) { $prefixFilterOptions = new ezpExtensionOptions(); $prefixFilterOptions->iniFile = 'rest.ini'; $prefixFilterOptions->iniSection = 'System'; $prefixFilterOptions->iniVariable = 'PrefixFilterClass'; $prefixFilterOptions->handlerParams = array( $request, $this->apiPrefix ); $prefixFilter = eZExtension::getHandlerClass( $prefixFilterOptions ); $prefixFilter->filter(); // We call this method here, so that implementors won't have to remember // adding this call to their own filter() implementation. $prefixFilter->filterRequestUri(); try { $this->runCustomFilters( self::FILTER_TYPE_PREROUTING, array( 'request' => $request ) ); } catch ( Exception $e ) { $request->variables['exception'] = $e; $request->uri = $this->apiPrefix . '/fatal'; return new ezcMvcInternalRedirect( $request ); } }
/** * Returns an ajaxuploader handler instance from the ezjscore function * arguments. * * @param array $args the arguments of the ezjscore ajax function * @return ezpAjaxUploaderHandlerInterface * * @throws InvalidArgumentException if the handler cannot be instanciated */ private static function getHandler( array $args ) { if ( !isset( $args[0] ) ) { throw new InvalidArgumentException( ezpI18n::tr( 'extension/ezjscore/ajaxuploader', 'Unable to find the identifier of ajax upload handler' ) ); } $http = eZHTTPTool::instance(); $handlerData = $http->postVariable( 'AjaxUploadHandlerData', array() ); $handlerOptions = new ezpExtensionOptions(); $handlerOptions->iniFile = 'ezjscore.ini'; $handlerOptions->iniSection = 'AjaxUploader'; $handlerOptions->iniVariable = 'AjaxUploadHandler'; $handlerOptions->handlerIndex = $args[0]; $handlerOptions->handlerParams = $handlerData; $handler = eZExtension::getHandlerClass( $handlerOptions ); if ( !$handler instanceof ezpAjaxUploaderHandlerInterface ) { throw new InvalidArgumentException( ezpI18n::tr( 'extension/ezjscore/ajaxuploader', 'Unable to load the ajax upload handler' ) ); } return $handler; }
/** * Constructor. * * $filePath File path. If specified, file metadata is fetched in the constructor. */ function __construct( $filePath = false ) { $filePath = eZDBFileHandler::cleanPath( $filePath ); eZDebugSetting::writeDebug( 'kernel-clustering', "db::ctor( '$filePath' )" ); if ( self::$dbbackend === null ) { $optionArray = array( 'iniFile' => 'file.ini', 'iniSection' => 'ClusteringSettings', 'iniVariable' => 'DBBackend' ); $options = new ezpExtensionOptions( $optionArray ); self::$dbbackend = eZExtension::getHandlerClass( $options ); self::$dbbackend->_connect( false ); // connection failed if( self::$dbbackend->db === false ) throw new eZClusterHandlerDBNoConnectionException( self::$dbbackend->dbparams['host'], self::$dbbackend->dbparams['user'], self::$dbbackend->dbparams['pass'] ); } $this->filePath = $filePath; if ( !isset( $GLOBALS['eZDBFileHandler_Settings'] ) ) { $fileINI = eZINI::instance( 'file.ini' ); $GLOBALS['eZDBFileHandler_Settings']['NonExistantStaleCacheHandling'] = $fileINI->variable( "ClusteringSettings", "NonExistantStaleCacheHandling" ); unset( $fileINI ); } $this->nonExistantStaleCacheHandling = $GLOBALS['eZDBFileHandler_Settings']['NonExistantStaleCacheHandling']; $this->filePermissionMask = octdec( eZINI::instance()->variable( 'FileSettings', 'StorageFilePermissions' ) ); }
/** * Gets an instance of the StaticCacheHandler and ask it for the user hash. * * @return string */ static function getUserHash() { $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler'); $options = new ezpExtensionOptions($optionArray); $staticCacheHandler = eZExtension::getHandlerClass($options); return $staticCacheHandler->getUserHash(); }
/** * Constructor * * If provided with $filePath, will use this file for further operations. * If not given, the file* methods must be used instead * * @param string $filePath Path of the file to handle * * @throws eZDBNoConnectionException DB connection failed */ function __construct($filePath = false) { if (self::$nonExistantStaleCacheHandling === null) { $fileINI = eZINI::instance('file.ini'); self::$nonExistantStaleCacheHandling = $fileINI->variable("ClusteringSettings", "NonExistantStaleCacheHandling"); unset($fileINI); } // DB Backend init if (self::$dbbackend === null) { self::$dbbackend = eZExtension::getHandlerClass(new ezpExtensionOptions(array('iniFile' => 'file.ini', 'iniSection' => 'eZDFSClusteringSettings', 'iniVariable' => 'DBBackend'))); self::$dbbackend->_connect(false); $fileINI = eZINI::instance('file.ini'); if ($fileINI->variable('ClusterEventsSettings', 'ClusterEvents') === 'enabled' && self::$dbbackend instanceof eZClusterEventNotifier) { $listener = eZExtension::getHandlerClass(new ezpExtensionOptions(array('iniFile' => 'file.ini', 'iniSection' => 'ClusterEventsSettings', 'iniVariable' => 'Listener', 'handlerParams' => array(new eZClusterEventLoggerEzdebug())))); if ($listener instanceof eZClusterEventListener) { self::$dbbackend->registerListener($listener); $listener->initialize(); } } } if ($filePath !== false) { $filePath = self::cleanPath($filePath); eZDebugSetting::writeDebug('kernel-clustering', "dfs::ctor( '{$filePath}' )"); } else { eZDebugSetting::writeDebug('kernel-clustering', "dfs::ctor()"); } $this->filePath = $filePath; }
/** * Constructor * * If provided with $filePath, will use this file for further operations. * If not given, the file* methods must be used instead * * @param string $filePath Path of the file to handle * * @throws eZDBNoConnectionException DB connection failed */ function __construct( $filePath = false ) { if ( self::$nonExistantStaleCacheHandling === null ) { $fileINI = eZINI::instance( 'file.ini' ); self::$nonExistantStaleCacheHandling = $fileINI->variable( "ClusteringSettings", "NonExistantStaleCacheHandling" ); unset( $fileINI ); } // DB Backend init if ( self::$dbbackend === null ) { self::$dbbackend = eZExtension::getHandlerClass( new ezpExtensionOptions( array( 'iniFile' => 'file.ini', 'iniSection' => 'eZDFSClusteringSettings', 'iniVariable' => 'DBBackend' ) ) ); self::$dbbackend->_connect( false ); } if ( $filePath !== false ) { $filePath = eZDBFileHandler::cleanPath( $filePath ); eZDebugSetting::writeDebug( 'kernel-clustering', "dfs::ctor( '$filePath' )" ); } else { eZDebugSetting::writeDebug( 'kernel-clustering', "dfs::ctor()" ); } $this->filePath = $filePath; }
/** * Update block pool for block with given $blockID * * @static * @param string $blockID * @param integer $publishedBeforeOrAt * @return integer */ public static function updateBlockPoolByBlockID($block, $publishedBeforeOrAt = false) { $db = eZDB::instance(); $blockINI = eZINI::instance('block.ini'); if (!$publishedBeforeOrAt) { $publishedBeforeOrAt = time(); } if (!$blockINI->hasVariable($block['block_type'], 'FetchClass')) { // Pure manual block, nothing is going to be fetched, but we need to update last_update as it is used for rotations if ($block['rotation_type'] != self::ROTATION_NONE) { $db->query("UPDATE ezm_block SET last_update={$publishedBeforeOrAt} WHERE id='" . $block['id'] . "'"); } return 0; } $fetchClassOptions = new ezpExtensionOptions(); $fetchClassOptions->iniFile = 'block.ini'; $fetchClassOptions->iniSection = $block['block_type']; $fetchClassOptions->iniVariable = 'FetchClass'; $fetchInstance = eZExtension::getHandlerClass($fetchClassOptions); if (!$fetchInstance instanceof eZFlowFetchInterface) { eZDebug::writeWarning("Can't create an instance of the {$fetchClass} class", "eZFlowOperations::updateBlockPoolByBlockID('" . $block['id'] . "')"); return false; } $fetchFixedParameters = array(); if ($blockINI->hasVariable($block['block_type'], 'FetchFixedParameters')) { $fetchFixedParameters = $blockINI->variable($block['block_type'], 'FetchFixedParameters'); } $fetchParameters = unserialize($block['fetch_params']); if (!is_array($fetchParameters)) { // take care of blocks existing in db where ini definition changed eZDebug::writeWarning("Found existing block which has no necessary parameters serialized in the db (block needs updating)", "eZFlowOperations::updateBlockPoolByBlockID('" . $block['id'] . "')"); $fetchParameters = array(); } $parameters = array_merge($fetchFixedParameters, $fetchParameters); $newItems = array(); foreach ($fetchInstance->fetch($parameters, $block['last_update'], $publishedBeforeOrAt) as $item) { $newItems[] = array('blockID' => $block['id'], 'objectID' => $item['object_id'], 'nodeID' => $item['node_id'], 'priority' => 0, 'timestamp' => $item['ts_publication']); } $itemsToRemove = 0; if (isset($parameters['Limit'])) { $count = $db->arrayQuery("SELECT count(*) as count FROM ezm_pool WHERE block_id='" . $block['id'] . "'"); $itemsToRemove = (int) $count[0]['count'] + count($newItems) - (int) $parameters['Limit']; } if (!empty($newItems) || $itemsToRemove > 0) { $db->begin(); if ($itemsToRemove > 0) { $db->query("DELETE FROM ezm_pool WHERE block_id='" . $block['id'] . "' ORDER BY ts_publication ASC LIMIT " . $itemsToRemove); } if (!empty($newItems)) { eZFlowPool::insertItems($newItems); } $db->query("UPDATE ezm_block SET last_update={$publishedBeforeOrAt} WHERE id='" . $block['id'] . "'"); $db->commit(); } return count($newItems); }
/** * Returns the currently configured class for handling Route security. * * @static * @throws ezpRestRouteSecurityFilterNotFoundException * @return ezpRestRouteFilterInterface */ public static function getRouteFilter() { $opt = new ezpExtensionOptions(); $opt->iniFile = 'rest.ini'; $opt->iniSection = 'RouteSettings'; $opt->iniVariable = 'RouteSettingImpl'; $routeSecurityFilterInstance = eZExtension::getHandlerClass($opt); if (!$routeSecurityFilterInstance instanceof self) { throw new ezpRestRouteSecurityFilterNotFoundException(); } return $routeSecurityFilterInstance; }
static function send(eZMail $mail) { $ini = eZINI::instance(); $transportType = trim($ini->variable('MailSettings', 'Transport')); $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'MailSettings', 'iniVariable' => 'TransportAlias', 'handlerIndex' => strtolower($transportType)); $options = new ezpExtensionOptions($optionArray); $transportClass = eZExtension::getHandlerClass($options); if (!is_object($transportClass)) { eZDebug::writeError("No class available for mail transport type '{$transportType}', cannot send mail", __METHOD__); } return $transportClass->sendMail($mail); }
/** * Searches for the output formatter handler class for a given format * * @static * @param string $format * @return ezpAttributeOperatorFormatterInterface */ protected static function createFormatter($format) { $formatterOptions = new ezpExtensionOptions(); $formatterOptions->iniFile = 'template.ini'; $formatterOptions->iniSection = 'AttributeOperator'; $formatterOptions->iniVariable = 'OutputFormatter'; $formatterOptions->handlerIndex = $format; $formatterInstance = eZExtension::getHandlerClass($formatterOptions); if (!$formatterInstance instanceof ezpAttributeOperatorFormatterInterface) { eZDebug::writeError("Undefined output formatter for '{$format}'", __METHOD__); } return $formatterInstance; }
public function runPreRoutingFilters(ezcMvcRequest $request) { $prefixFilterOptions = new ezpExtensionOptions(); $prefixFilterOptions->iniFile = 'rest.ini'; $prefixFilterOptions->iniSection = 'System'; $prefixFilterOptions->iniVariable = 'PrefixFilterClass'; $prefixFilterOptions->handlerParams = array($request, $this->apiPrefix); $prefixFilter = eZExtension::getHandlerClass($prefixFilterOptions); $prefixFilter->filter(); // We call this method here, so that implementors won't have to remember // adding this call to their own filter() implementation. $prefixFilter->filterRequestUri(); }
/** * @param string $provider * @return ezpRestProviderInterface */ protected static function createProvider($provider) { $providerOptions = new ezpExtensionOptions(); $providerOptions->iniFile = 'rest.ini'; $providerOptions->iniSection = 'ApiProvider'; $providerOptions->iniVariable = 'ProviderClass'; $providerOptions->handlerIndex = $provider; $providerInstance = eZExtension::getHandlerClass($providerOptions); if (!$providerInstance instanceof ezpRestProviderInterface) { throw new ezpRestProviderNotFoundException($provider); } return $providerInstance; }
public function filter() { if ( eZINI::instance( 'rest.ini' )->variable( 'Authentication', 'RequireHTTPS') === 'enabled' && $this->req->isEncrypted === false ) { // When an unencrypted connection is identified, we have to alter the // flag to avoid infinite loop, when the request is rerouted to the error controller. // This should be improved in the future. $this->req->isEncrypted = true; throw new ezpRestHTTPSRequiredException(); } // 0. Check if the given route needs authentication. if ( !$this->shallAuthenticate() ) { $this->filter = new ezpRestNoAuthStyle(); } else if ( $this->filter === null ) { $opt = new ezpExtensionOptions(); $opt->iniFile = 'rest.ini'; $opt->iniSection = 'Authentication'; $opt->iniVariable = 'AuthenticationStyle'; $authFilter = eZExtension::getHandlerClass( $opt ); if ( !$authFilter instanceof ezpRestAuthenticationStyle ) { throw new ezpRestAuthStyleNotFoundException(); } $this->filter = $authFilter; } // 1. Initialize the context needed for authenticating the user. $auth = $this->filter->setup( $this->req ); if ( $auth instanceof ezcMvcInternalRedirect ) return $auth; // 2.Perform the authentication // Result of authentication filter can be a valid ezp user (auth succeeded) or an internal redirect (ezcMvcInternalRedirect) $user = $this->filter->authenticate( $auth, $this->req ); if ( $user instanceof eZUser ) { eZUser::setCurrentlyLoggedInUser( $user, $user->attribute( 'contentobject_id' ) ); $this->filter->setUser( $user ); } else if ( $user instanceof ezcMvcInternalRedirect ) { return $user; } }
/** * Returns ezpRestContentProviderInterface object for requested renderer * * @param string $renderer * @param ezpContent $content * @return ezpRestContentProviderInterface */ protected static function createRenderer($renderer, ezpContent $content, ezpRestMvcController $controller) { $rendererOptions = new ezpExtensionOptions(); $rendererOptions->iniFile = 'rest.ini'; $rendererOptions->iniSection = 'OutputSettings'; $rendererOptions->iniVariable = 'RendererClass'; $rendererOptions->handlerIndex = $renderer; $rendererOptions->handlerParams = array($content, $controller); $rendererInstance = eZExtension::getHandlerClass($rendererOptions); if (!$rendererInstance instanceof ezpRestContentRendererInterface) { throw new ezpRestContentRendererNotFoundException($renderer); } return $rendererInstance; }
/** * Returns a connection to the cluster db handler - which might be implemented using different php classes... * Null if not clustered * * @return eZClusterFileHandlerInterface|... */ public static function clusterDBHandler() { $ini = eZINI::instance('file.ini'); $handler = $ini->variable('ClusteringSettings', 'FileHandler'); if ($handler == 'ezdb' || $handler == 'eZDBFileHandler') { return eZClusterFileHandler::instance(); } else { if ($handler == 'eZDFSFileHandler') { // This is even worse: we have no right to know if db connection is ok. // So we replicate some code here... return eZExtension::getHandlerClass(new ezpExtensionOptions(array('iniFile' => 'file.ini', 'iniSection' => 'eZDFSClusteringSettings', 'iniVariable' => 'DBBackend'))); } } return null; }
/** * @expected If version not found fall back to version 1 */ public function testApiVersionFallback() { self::markTestIncomplete(); $request = new ezcMvcRequest(); // We don't specify version token in the URI $request->uri = '/api/foo'; $versionTokenOptions = new ezpExtensionOptions(); $versionTokenOptions->iniFile = 'rest.ini'; $versionTokenOptions->iniSection = 'System'; $versionTokenOptions->iniVariable = 'VersionTokenClass'; $versionTokenOptions->handlerParams = array($request, '/api'); $versionInfo = eZExtension::getHandlerClass($versionTokenOptions); $versionInfo->filter(); $versionInfo->filterRequestUri(); self::assertSame(1, ezpRestVersionTokenInterface::getApiVersion()); }
/** * Returns the configured instance of an eZClusterFileHandlerInterface * See ClusteringSettings.FileHandler in file.ini * * @param string|bool $filename * Optional filename the handler should be initialized with * * @return eZClusterFileHandlerInterface */ static function instance( $filename = false ) { if ( self::$isShutdownFunctionRegistered !== true ) { eZExecution::addCleanupHandler( array( __CLASS__, 'cleanupGeneratingFiles' ) ); self::$isShutdownFunctionRegistered = true; } if( $filename !== false ) { $optionArray = array( 'iniFile' => 'file.ini', 'iniSection' => 'ClusteringSettings', 'iniVariable' => 'FileHandler', 'handlerParams'=> array( $filename ) ); $options = new ezpExtensionOptions( $optionArray ); $handler = eZExtension::getHandlerClass( $options ); return $handler; } else { // return Filehandler from GLOBALS based on ini setting. if ( self::$globalHandler === null ) { $optionArray = array( 'iniFile' => 'file.ini', 'iniSection' => 'ClusteringSettings', 'iniVariable' => 'FileHandler' ); $options = new ezpExtensionOptions( $optionArray ); $handler = eZExtension::getHandlerClass( $options ); self::$globalHandler = $handler; } else $handler = self::$globalHandler; return $handler; } }
/** * Returns the configured instance of an eZClusterFileHandlerInterface * See ClusteringSettings.FileHandler in php.ini * * @param string|bool $filename * Optional filename the handler should be initialized with * * @return eZClusterFileHandlerInterface */ static function instance($filename = false) { if ($filename !== false) { $optionArray = array('iniFile' => 'file.ini', 'iniSection' => 'ClusteringSettings', 'iniVariable' => 'FileHandler', 'handlerParams' => array($filename)); $options = new ezpExtensionOptions($optionArray); $handler = eZExtension::getHandlerClass($options); return $handler; } else { // return Filehandler from GLOBALS based on ini setting. if (!isset($GLOBALS['eZClusterFileHandler_chosen_handler'])) { $optionArray = array('iniFile' => 'file.ini', 'iniSection' => 'ClusteringSettings', 'iniVariable' => 'FileHandler'); $options = new ezpExtensionOptions($optionArray); $handler = eZExtension::getHandlerClass($options); $GLOBALS['eZClusterFileHandler_chosen_handler'] = $handler; } else { $handler = $GLOBALS['eZClusterFileHandler_chosen_handler']; } return $handler; } }
/** * Constructor. * * $filePath File path. If specified, file metadata is fetched in the constructor. */ function eZDBFileHandler($filePath = false) { $filePath = eZDBFileHandler::cleanPath($filePath); eZDebugSetting::writeDebug('kernel-clustering', "db::ctor( '{$filePath}' )"); $optionArray = array('iniFile' => 'file.ini', 'iniSection' => 'ClusteringSettings', 'iniVariable' => 'DBBackend'); $options = new ezpExtensionOptions($optionArray); $this->backend = eZExtension::getHandlerClass($options); $this->backend->_connect(false); // connection failed if ($this->backend->db === false) { throw new eZDBNoConnectionException($this->backend->dbparams['host']); } $this->backendVerify = null; $this->filePath = $filePath; if (!isset($GLOBALS['eZDBFileHandler_Settings'])) { $fileINI = eZINI::instance('file.ini'); $GLOBALS['eZDBFileHandler_Settings']['NonExistantStaleCacheHandling'] = $fileINI->variable("ClusteringSettings", "NonExistantStaleCacheHandling"); unset($fileINI); } $this->nonExistantStaleCacheHandling = $GLOBALS['eZDBFileHandler_Settings']['NonExistantStaleCacheHandling']; }
static function instance($package, $handlerName, $installItem) { // if no installItem is given, then this is the whole package installer /*if ( $installItem == null ) { include_once( $package->path() . '/' . $package->installerDirectory() . '/' . $package->installerFileName() ); $handlerClassName = $package->installerFileName(); $handler =& new $handlerClassName( $package, null, null ); return $handler; }*/ $handlers =& $GLOBALS['eZPackageCreationInstallers']; if (!isset($handlers)) { $handlers = array(); } $handler = false; if (isset($handlers[$handlerName])) { $handler =& $handlers[$handlerName]; $handler->reset(); } else { $optionArray = array('iniFile' => 'package.ini', 'iniSection' => 'InstallerSettings', 'iniVariable' => 'HandlerAlias', 'handlerIndex' => $handlerName, 'handlerParams' => array($package, $handlerName, $installItem)); $options = new ezpExtensionOptions($optionArray); $handler = eZExtension::getHandlerClass($options); if ($handler !== null and $handler !== false) { $handlers[$handlerName] =& $handler; // if custom install handler is available in the package, we use it $customInstallHandler = $handler->customInstallHandlerInfo($package, $installItem); if ($customInstallHandler) { unset($handler); $handlerClassName = $customInstallHandler['classname']; $handlerFile = $customInstallHandler['file-path']; include_once $handlerFile; $handler = new $handlerClassName($package, $handlerName, $installItem); } } } return $handler; }
/** * Returns a shared instance of the eZPackageCreationHandler class * pr $handlerName as defined in package.ini[CreationSettings]HandlerAlias * * @param string $handlerName * @return eZPackageCreationHandler */ static function instance($handlerName) { $handlers =& $GLOBALS['eZPackageCreationHandlers']; if (!isset($handlers)) { $handlers = array(); } $handler = false; if (isset($handlers[$handlerName])) { $handler = $handlers[$handlerName]; $handler->reset(); } else { $optionArray = array('iniFile' => 'package.ini', 'iniSection' => 'CreationSettings', 'iniVariable' => 'HandlerAlias', 'handlerIndex' => $handlerName, 'handlerParams' => array($handlerName)); $options = new ezpExtensionOptions($optionArray); $handler = eZExtension::getHandlerClass($options); $handlers[$handlerName] = $handler; } return $handler; }
function removeThis() { $ini = eZINI::instance(); $object = $this->object(); $nodeID = $this->attribute('node_id'); $objectID = $object->attribute('id'); if (eZAudit::isAuditEnabled()) { // Set audit params. $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') { $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler'); $options = new ezpExtensionOptions($optionArray); $staticCacheHandler = eZExtension::getHandlerClass($options); $staticCacheHandler->removeURL("/" . $urlAlias); $staticCacheHandler->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) { $staticCacheHandler->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($objectID); eZUser::purgeUserCacheByUserId($objectID); } $parentNode = $this->attribute('parent'); if (is_object($parentNode)) { eZContentCacheManager::clearContentCacheIfNeeded($parentNode->attribute('contentobject_id')); $parentNode->updateAndStoreModified(); eZNodeAssignment::purgeByParentAndContentObjectID($parentNode->attribute('node_id'), $objectID); } // 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 packageHandler($handlerName) { if (!isset($GLOBALS['eZPackageHandlers'])) { $handlers = array(); } else { $handlers = $GLOBALS['eZPackageHandlers']; } $handler = false; if (isset($handlers[$handlerName])) { $handler = $handlers[$handlerName]; $handler->reset(); } else { $optionArray = array('iniFile' => 'package.ini', 'iniSection' => 'PackageSettings', 'iniVariable' => 'HandlerAlias', 'handlerIndex' => $handlerName); $options = new ezpExtensionOptions($optionArray); $handler = eZExtension::getHandlerClass($options); $handlers[$handlerName] = $handler; } $GLOBALS['eZPackageHandlers'] = $handlers; return $handler; }
/** * Returns a shared instance of the eZDBInterface class aka database object. * If you want to change the current database values you should use $forceNewInstance. * * @param string|false $databaseImplementation * @param array|false $databaseParameters If array, then key 'use_defaults' (bool) is used. * @param bool $forceNewInstance * @return eZDBInterface */ static function instance($databaseImplementation = false, $databaseParameters = false, $forceNewInstance = false) { $impl =& $GLOBALS['eZDBGlobalInstance']; $fetchInstance = false; if (!$impl instanceof eZDBInterface) { $fetchInstance = true; } if ($forceNewInstance) { unset($impl); $impl = false; $fetchInstance = true; } $useDefaults = true; if (is_array($databaseParameters) and isset($databaseParameters['use_defaults'])) { $useDefaults = $databaseParameters['use_defaults']; } if ($fetchInstance) { $ini = eZINI::instance(); if ($databaseImplementation === false and $useDefaults) { $databaseImplementation = $ini->variable('DatabaseSettings', 'DatabaseImplementation'); } $server = $user = $pwd = $db = $usePersistentConnection = $port = false; if ($useDefaults) { list($server, $port, $user, $pwd, $db, $usePersistentConnection) = $ini->variableMulti('DatabaseSettings', array('Server', 'Port', 'User', 'Password', 'Database', 'UsePersistentConnection')); } $socketPath = false; if ($useDefaults) { $socket = $ini->variable('DatabaseSettings', 'Socket'); if (trim($socket != "") and $socket != "disabled") { $socketPath = $socket; } } // Check slave servers $slaveServer = null; $slaveServerPort = null; $slaveServerUser = null; $slaveServerPassword = null; $slaveServerDatabase = null; $useSlave = $ini->variable('DatabaseSettings', 'UseSlaveServer'); if ($useSlave == "enabled") { $slaveServers = $ini->variable('DatabaseSettings', 'SlaveServerArray'); $slaveServerPorts = $ini->variable('DatabaseSettings', 'SlaveServerPort'); $slaveServerUsers = $ini->variable('DatabaseSettings', 'SlaverServerUser'); $slaveServerPasswords = $ini->variable('DatabaseSettings', 'SlaverServerPassword'); $slaveServerDatabases = $ini->variable('DatabaseSettings', 'SlaverServerDatabase'); $numberServers = count($slaveServers); if ($numberServers > 1) { $index = mt_rand(1, $numberServers) - 1; } else { $index = 0; } $slaveServer = $slaveServers[$index]; $slaveServerPort = $slaveServerPorts[$index]; $slaveServerUser = $slaveServerUsers[$index]; $slaveServerPassword = $slaveServerPasswords[$index]; $slaveServerDatabase = $slaveServerDatabases[$index]; } list($charset, $retries) = $ini->variableMulti('DatabaseSettings', array('Charset', 'ConnectRetries')); $isInternalCharset = false; if (trim($charset) == '') { $charset = eZTextCodec::internalCharset(); $isInternalCharset = true; } $builtinEncoding = $ini->variable('DatabaseSettings', 'UseBuiltinEncoding') == 'true'; $impl = null; $useSlaveServer = false; if ($useSlave == "enabled") { $useSlaveServer = true; } $defaultDatabaseParameters = array('server' => $server, 'port' => $port, 'user' => $user, 'password' => $pwd, 'database' => $db, 'use_slave_server' => $useSlaveServer, 'slave_server' => $slaveServer, 'slave_port' => $slaveServerPort, 'slave_user' => $slaveServerUser, 'slave_password' => $slaveServerPassword, 'slave_database' => $slaveServerDatabase, 'charset' => $charset, 'is_internal_charset' => $isInternalCharset, 'socket' => $socketPath, 'builtin_encoding' => $builtinEncoding, 'connect_retries' => $retries, 'use_persistent_connection' => $usePersistentConnection, 'show_errors' => true); /* This looks funny, but is needed to fix a crash in PHP */ $b = $databaseParameters; $databaseParameters = $defaultDatabaseParameters; if (isset($b['server'])) { $databaseParameters['server'] = $b['server']; } if (isset($b['port'])) { $databaseParameters['port'] = $b['port']; } if (isset($b['user'])) { $databaseParameters['user'] = $b['user']; } if (isset($b['password'])) { $databaseParameters['password'] = $b['password']; } if (isset($b['database'])) { $databaseParameters['database'] = $b['database']; } if (isset($b['use_slave_server'])) { $databaseParameters['use_slave_server'] = $b['use_slave_server']; } if (isset($b['slave_server'])) { $databaseParameters['slave_server'] = $b['slave_server']; } if (isset($b['slave_port'])) { $databaseParameters['slave_port'] = $b['slave_port']; } if (isset($b['slave_user'])) { $databaseParameters['slave_user'] = $b['slave_user']; } if (isset($b['slave_password'])) { $databaseParameters['slave_password'] = $b['slave_password']; } if (isset($b['slave_database'])) { $databaseParameters['slave_database'] = $b['slave_database']; } if (isset($b['charset'])) { $databaseParameters['charset'] = $b['charset']; $databaseParameters['is_internal_charset'] = false; } if (isset($b['socket'])) { $databaseParameters['socket'] = $b['socket']; } if (isset($b['builtin_encoding'])) { $databaseParameters['builtin_encoding'] = $b['builtin_encoding']; } if (isset($b['connect_retries'])) { $databaseParameters['connect_retries'] = $b['connect_retries']; } if (isset($b['use_persistent_connection'])) { $databaseParameters['use_persistent_connection'] = $b['use_persistent_connection']; } if (isset($b['show_errors'])) { $databaseParameters['show_errors'] = $b['show_errors']; } $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'DatabaseSettings', 'iniVariable' => 'ImplementationAlias', 'handlerIndex' => $databaseImplementation, 'handlerParams' => array($databaseParameters)); $options = new ezpExtensionOptions($optionArray); $impl = eZExtension::getHandlerClass($options); if (!$impl) { $impl = new eZNullDB($databaseParameters); $impl->ErrorMessage = "No database handler was found for '{$databaseImplementation}'"; $impl->ErrorNumber = -1; if ($databaseParameters['show_errors']) { eZDebug::writeError('Database implementation not supported: ' . $databaseImplementation, __METHOD__); } } $impl->setErrorHandling(self::$errorHandling); } return $impl; }
/** * Returns a shared instance of the eZBinaryFileHandler class * pr $handlerName as defined in file.ini[BinaryFileSettings]Handler * * @param string|false $identifier Uses file.ini[BinaryFileSettings]Handler if false * @return eZBinaryFileHandler */ static function instance($identifier = false) { if ($identifier === false) { $fileINI = eZINI::instance('file.ini'); $identifier = $fileINI->variable('BinaryFileSettings', 'Handler'); } $instance =& $GLOBALS['eZBinaryFileHandlerInstance-' . $identifier]; if (!isset($instance)) { $optionArray = array('iniFile' => 'file.ini', 'iniSection' => 'BinaryFileSettings', 'iniVariable' => 'Handler'); $options = new ezpExtensionOptions($optionArray); $instance = eZExtension::getHandlerClass($options); if ($instance === false) { eZDebug::writeError("Could not find binary file handler '{$identifier}'", __METHOD__); } } return $instance; }
/** * Get curren session handler * * @since 4.4 * @return ezpSessionHandler */ public static function getHandlerInstance() { if (self::$handlerInstance === null) { $ini = eZINI::instance(); if ($ini->variable('Session', 'Handler') !== '') { $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'Session', 'iniVariable' => 'Handler', 'handlerParams' => array(self::$hasSessionCookie)); $options = new ezpExtensionOptions($optionArray); self::$handlerInstance = eZExtension::getHandlerClass($options); } if (!self::$handlerInstance instanceof ezpSessionHandler) { self::$handlerInstance = new ezpSessionHandlerPHP(self::$hasSessionCookie); } } return self::$handlerInstance; }
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; } } if (eZINI::instance('site.ini')->variable('ContentSettings', 'StaticCache') == 'enabled') { $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler'); $options = new ezpExtensionOptions($optionArray); $staticCacheHandler = eZExtension::getHandlerClass($options); $staticCacheHandler::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);
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' => false, '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'), eZUser::NO_SESSION_REGENERATE); // Cache the current node $cacheFileArray = eZNodeviewfunctions::generateViewCacheFile($previewCacheUser, $node->attribute('node_id'), false, false, $language, $viewMode, $viewParameters, $cachedViewPreferences); $tmpRes = eZNodeviewfunctions::generateNodeView($tpl, $node, $node->attribute('object'), $language, $viewMode, false, $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'), eZUser::NO_SESSION_REGENERATE); // restore siteaccess eZSiteAccess::load($currentSiteAccess); } } if ($ini->variable('ContentSettings', 'StaticCache') == 'enabled') { $nodes = array(); $ini = eZINI::instance(); $useURLAlias =& $GLOBALS['eZContentObjectTreeNodeUseURLAlias']; $pathPrefix = $ini->variable('SiteAccessSettings', 'PathPrefix'); // get staticCacheHandler instance $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler'); $options = new ezpExtensionOptions($optionArray); $staticCacheHandler = eZExtension::getHandlerClass($options); 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; } $staticCacheHandler->cacheURL('/' . $urlAlias, $nodeID); } $staticCacheHandler->generateAlwaysUpdatedCache(); } } eZDebug::accumulatorStop('generate_cache'); }
function factoryFor( $factoryName, $iniFile = false, $converterName = false ) { if ( !$iniFile ) $iniFile = 'image.ini'; if ( isset( $this->Factories[$factoryName] ) ) { return $this->Factories[$factoryName]; } else { $optionArray = array( 'iniFile' => $iniFile, 'iniSection' => $converterName, 'iniVariable' => 'Handler' ); $options = new ezpExtensionOptions( $optionArray ); $factory = eZExtension::getHandlerClass( $options ); return $this->Factories[$factoryName] = $factory; } return false; }
/** * File containing the switchlanguage module * * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved. * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 * @version //autogentag// * @package kernel */ $handlerOptions = new ezpExtensionOptions(); $handlerOptions->iniFile = 'site.ini'; $handlerOptions->iniSection = 'RegionalSettings'; $handlerOptions->iniVariable = 'LanguageSwitcherClass'; if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING']) { $Params['QueryString'] = $_SERVER['QUERY_STRING']; } // 0. Module params are sent to constructor to process the request. $handlerOptions->handlerParams = array($Params); $langSwitch = eZExtension::getHandlerClass($handlerOptions); $Module = $Params['Module']; $destinationSiteAccess = $Params['SiteAccess']; // Steps for language switcher classes // 1. destination siteaccess is set $langSwitch->setDestinationSiteAccess($destinationSiteAccess); // 2. The process hook is called, it is up to each class what this step involves. $langSwitch->process(); // 3. The final URL is fetched from the language switcher class. This URL must // point to the correct full URL including host (for host based mapping) and // translated URL alias where applicable. $destinationUrl = $langSwitch->destinationUrl(); // 4. The browser is redirected to the URL of the translated content. $Module->redirectTo($destinationUrl);