Exemplo n.º 1
0
    /**
     * Initialize the ts translator and context if this is not already done
     *
     * @param string $context
     * @param string $locale
     * @param string $filename
     * @param bool $useCache
     * @return eZTSTranslator
     */
    static function initialize( $context, $locale, $filename, $useCache = true )
    {
        $instance = false;
        $file = $locale . '/' . $filename;
        if ( !empty( $GLOBALS['eZTSTranslationTables'][$file] ) )
        {
            $instance = $GLOBALS['eZTSTranslationTables'][$file];
            if ( $instance->hasInitializedContext( $context ) )
            {
                return $instance;
            }
        }

        eZDebug::createAccumulatorGroup( 'tstranslator', 'TS translator' );
        eZDebug::accumulatorStart( 'tstranslator_init', 'tstranslator', 'TS init' );
        if ( !$instance )
        {
            $instance = new eZTSTranslator( $locale, $filename, $useCache );
            $GLOBALS['eZTSTranslationTables'][$file] = $instance;
            $manager = eZTranslatorManager::instance();
            $manager->registerHandler( $instance );
        }
        $instance->load( $context );
        eZDebug::accumulatorStop( 'tstranslator_init' );
        return $instance;
    }
Exemplo n.º 2
0
 function eZMySQLiDB($parameters)
 {
     $this->eZDBInterface($parameters);
     if (!extension_loaded('mysqli')) {
         if (function_exists('eZAppendWarningItem')) {
             eZAppendWarningItem(array('error' => array('type' => 'ezdb', 'number' => eZDBInterface::ERROR_MISSING_EXTENSION), 'text' => 'MySQLi extension was not found, the DB handler will not be initialized.'));
             $this->IsConnected = false;
         }
         eZDebug::writeWarning('MySQLi extension was not found, the DB handler will not be initialized.', 'eZMySQLiDB');
         return;
     }
     /// Connect to master server
     if (!$this->DBWriteConnection) {
         $connection = $this->connect($this->Server, $this->DB, $this->User, $this->Password, $this->SocketPath, $this->Charset, $this->Port);
         if ($this->IsConnected) {
             $this->DBWriteConnection = $connection;
         }
     }
     // Connect to slave
     if (!$this->DBConnection) {
         if ($this->UseSlaveServer === true) {
             $connection = $this->connect($this->SlaveServer, $this->SlaveDB, $this->SlaveUser, $this->SlavePassword, $this->SocketPath, $this->Charset, $this->SlavePort);
         } else {
             $connection = $this->DBWriteConnection;
         }
         if ($connection and $this->DBWriteConnection) {
             $this->DBConnection = $connection;
             $this->IsConnected = true;
         }
     }
     // Initialize TempTableList
     $this->TempTableList = array();
     eZDebug::createAccumulatorGroup('mysqli_total', 'Mysql Total');
 }
Exemplo n.º 3
0
 function eZMySQLDB($parameters)
 {
     $this->eZDBInterface($parameters);
     $this->CharsetMapping = array('iso-8859-1' => 'latin1', 'iso-8859-2' => 'latin2', 'iso-8859-8' => 'hebrew', 'iso-8859-7' => 'greek', 'iso-8859-9' => 'latin5', 'iso-8859-13' => 'latin7', 'windows-1250' => 'cp1250', 'windows-1251' => 'cp1251', 'windows-1256' => 'cp1256', 'windows-1257' => 'cp1257', 'utf-8' => 'utf8', 'koi8-r' => 'koi8r', 'koi8-u' => 'koi8u');
     if (!extension_loaded('mysql')) {
         if (function_exists('eZAppendWarningItem')) {
             eZAppendWarningItem(array('error' => array('type' => 'ezdb', 'number' => eZDBInterface::ERROR_MISSING_EXTENSION), 'text' => 'MySQL extension was not found, the DB handler will not be initialized.'));
             $this->IsConnected = false;
         }
         eZDebug::writeWarning('MySQL extension was not found, the DB handler will not be initialized.', 'eZMySQLDB');
         return;
     }
     /// Connect to master server
     if (!$this->DBWriteConnection) {
         $connection = $this->connect($this->Server, $this->DB, $this->User, $this->Password, $this->SocketPath, $this->Charset, $this->Port);
         if ($this->IsConnected) {
             $this->DBWriteConnection = $connection;
         }
     }
     // Connect to slave
     if (!$this->DBConnection) {
         if ($this->UseSlaveServer === true) {
             $connection = $this->connect($this->SlaveServer, $this->SlaveDB, $this->SlaveUser, $this->SlavePassword, $this->SocketPath, $this->Charset, $this->SlavePort);
         } else {
             $connection = $this->DBWriteConnection;
         }
         if ($connection and $this->DBWriteConnection) {
             $this->DBConnection = $connection;
             $this->IsConnected = true;
         }
     }
     // Initialize TempTableList
     $this->TempTableList = array();
     eZDebug::createAccumulatorGroup('mysql_total', 'Mysql Total');
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 /**
  * Constructor
  */
 function __construct()
 {
     eZDebug::createAccumulatorGroup('solr', 'Solr search plugin');
     $this->SolrINI = eZINI::instance('solr.ini');
     $this->FindINI = eZINI::instance('ezfind.ini');
     $this->SiteINI = eZINI::instance('site.ini');
     //$this->Solr = self::solrBaseFactory();
     $this->UseMultiLanguageCores = false;
     if ($this->FindINI->variable('LanguageSearch', 'MultiCore') == 'enabled') {
         $this->UseMultiLanguageCores = true;
     }
     $this->initLanguageShards();
 }
 public function execute($process, $event)
 {
     eZDebug::createAccumulatorGroup('nxc_social_networks_publish', 'NXC Social Networks Publish');
     $processParams = $process->attribute('parameter_list');
     $classIDs = unserialize($event->attribute('data_text1'));
     $object = eZContentObject::fetch($processParams['object_id']);
     if (in_array($object->attribute('contentclass_id'), $classIDs) === false) {
         return eZWorkflowType::STATUS_ACCEPTED;
     }
     $dataMap = $object->attribute('data_map');
     $handlers = $event->attribute('handlers');
     foreach ($handlers as $handler) {
         $options = $handler->getOptions();
         if (isset($options['publish_only_on_create']) && (bool) $options['publish_only_on_create'] === true && $object->attribute('current_version') != 1) {
             continue;
         }
         $classAttributeIDs = $handler->attribute('classattribute_ids');
         foreach ($classAttributeIDs as $classAttributeID) {
             $classAttribute = eZContentClassAttribute::fetch($classAttributeID, false);
             if ($classAttribute['contentclass_id'] != $object->attribute('contentclass_id')) {
                 continue;
             }
             $attributeContent = false;
             foreach ($dataMap as $objectAttribute) {
                 if ($objectAttribute->attribute('contentclassattribute_id') == $classAttributeID) {
                     $attributeContent = $objectAttribute->attribute('content');
                     break;
                 }
             }
             if ($attributeContent === false) {
                 continue;
             }
             $accumulator = 'nxc_social_networks_publish_to_' . $handler->attribute('type');
             eZDebug::accumulatorStart($accumulator, 'nxc_social_networks_publish', 'Publishing message to ' . $handler->attribute('name'));
             try {
                 $handler->publish($object, $attributeContent);
             } catch (Exception $e) {
                 eZDebug::writeError($e->getMessage(), 'NXC Social Networks Publish');
             }
             eZDebug::accumulatorStop($accumulator);
         }
     }
     return eZWorkflowType::STATUS_ACCEPTED;
 }
 /**
  * Registers the object in search engine.
  *
  * @note Transaction unsafe. If you call several transaction unsafe methods you must enclose
  *       the calls within a db transaction; thus within db->begin and db->commit.
  *
  * @param int $objectID Id of the object.
  */
 public static function registerSearchObject($objectID)
 {
     $objectID = (int) $objectID;
     eZDebug::createAccumulatorGroup('search_total', 'Search Total');
     $ini = eZINI::instance('site.ini');
     $insertPendingAction = false;
     $object = null;
     switch ($ini->variable('SearchSettings', 'DelayedIndexing')) {
         case 'enabled':
             $insertPendingAction = true;
             break;
         case 'classbased':
             $classList = $ini->variable('SearchSettings', 'DelayedIndexingClassList');
             $object = eZContentObject::fetch($objectID);
             if (is_array($classList) && in_array($object->attribute('class_identifier'), $classList)) {
                 $insertPendingAction = true;
             }
     }
     if ($insertPendingAction) {
         eZDB::instance()->query("INSERT INTO ezpending_actions( action, param ) VALUES ( 'index_object', '{$objectID}' )");
         return;
     }
     if ($object === null) {
         $object = eZContentObject::fetch($objectID);
     }
     // Register the object in the search engine.
     $needCommit = eZSearch::needCommit();
     if (eZSearch::needRemoveWithUpdate()) {
         eZDebug::accumulatorStart('remove_object', 'search_total', 'remove object');
         eZSearch::removeObject($object, $needCommit);
         eZDebug::accumulatorStop('remove_object');
     }
     eZDebug::accumulatorStart('add_object', 'search_total', 'add object');
     if (!eZSearch::addObject($object, $needCommit)) {
         eZDebug::writeError("Failed adding object ID {$object->attribute('id')} in the search engine", __METHOD__);
     }
     eZDebug::accumulatorStop('add_object');
 }
Exemplo n.º 8
0
 function eZPostgreSQLDB($parameters)
 {
     $this->eZDBInterface($parameters);
     if (!extension_loaded('pgsql')) {
         if (function_exists('eZAppendWarningItem')) {
             eZAppendWarningItem(array('error' => array('type' => 'ezdb', 'number' => eZDBInterface::ERROR_MISSING_EXTENSION), 'text' => 'PostgreSQL extension was not found, the DB handler will not be initialized.'));
             $this->IsConnected = false;
         }
         eZDebug::writeWarning('PostgreSQL extension was not found, the DB handler will not be initialized.', 'eZPostgreSQLDB');
         return;
     }
     eZDebug::createAccumulatorGroup('postgresql_total', 'Postgresql Total');
     $ini = eZINI::instance();
     $server = $this->Server;
     $port = $this->Port;
     $db = $this->DB;
     $user = $this->User;
     $password = $this->Password;
     $connectString = self::connectString($this->Server, $this->Port, $this->DB, $this->User, $this->Password);
     if ($ini->variable("DatabaseSettings", "UsePersistentConnection") == "enabled" && function_exists("pg_pconnect")) {
         eZDebugSetting::writeDebug('kernel-db-postgresql', $ini->variable("DatabaseSettings", "UsePersistentConnection"), "using persistent connection");
         // avoid automatic SQL errors
         $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
         eZDebug::accumulatorStart('postgresql_connection', 'postgresql_total', 'Database connection');
         try {
             $this->DBConnection = pg_pconnect($connectString);
         } catch (ErrorException $e) {
         }
         eZDebug::accumulatorStop('postgresql_connection');
         eZDebug::setHandleType($oldHandling);
         $maxAttempts = $this->connectRetryCount();
         $waitTime = $this->connectRetryWaitTime();
         $numAttempts = 1;
         while ($this->DBConnection == false and $numAttempts <= $maxAttempts) {
             sleep($waitTime);
             $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
             eZDebug::accumulatorStart('postgresql_connection', 'postgresql_total', 'Database connection');
             try {
                 $this->DBConnection = pg_pconnect($connectString);
             } catch (ErrorException $e) {
             }
             eZDebug::accumulatorStop('postgresql_connection');
             eZDebug::setHandleType($oldHandling);
             $numAttempts++;
         }
         if ($this->DBConnection) {
             $this->IsConnected = true;
         } else {
             throw new eZDBNoConnectionException($server, $this->ErrorMessage, $this->ErrorNumber);
         }
     } else {
         if (function_exists("pg_connect")) {
             eZDebugSetting::writeDebug('kernel-db-postgresql', "using real connection", "using real connection");
             $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
             eZDebug::accumulatorStart('postgresql_connection', 'postgresql_total', 'Database connection');
             try {
                 $this->DBConnection = pg_connect($connectString);
             } catch (ErrorException $e) {
             }
             eZDebug::accumulatorStop('postgresql_connection');
             eZDebug::setHandleType($oldHandling);
             $maxAttempts = $this->connectRetryCount();
             $waitTime = $this->connectRetryWaitTime();
             $numAttempts = 1;
             while ($this->DBConnection == false and $numAttempts <= $maxAttempts) {
                 sleep($waitTime);
                 $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
                 eZDebug::accumulatorStart('postgresql_connection', 'postgresql_total', 'Database connection');
                 try {
                     $this->DBConnection = pg_connect($connectString);
                 } catch (ErrorException $e) {
                 }
                 eZDebug::accumulatorStop('postgresql_connection');
                 eZDebug::setHandleType($oldHandling);
                 $numAttempts++;
             }
             if ($this->DBConnection) {
                 $this->IsConnected = true;
             } else {
                 $this->setError();
                 throw new eZDBNoConnectionException($server, $this->ErrorMessage, $this->ErrorNumber);
             }
         } else {
             $this->IsConnected = false;
             eZDebug::writeError("PostgreSQL support not compiled into PHP, contact your system administrator", "eZPostgreSQLDB");
         }
     }
 }
Exemplo n.º 9
0
 function eZTemplate()
 {
     $this->Tree = array(eZTemplate::NODE_ROOT, false);
     $this->LDelim = "{";
     $this->RDelim = "}";
     $this->IncludeText = array();
     $this->IncludeOutput = array();
     $this->registerLiteral("literal");
     $res = new eZTemplateFileResource();
     $this->DefaultResource = $res;
     $this->registerResource($res);
     $this->Resources = array();
     $this->Text = null;
     $this->IsCachingAllowed = true;
     $this->resetErrorLog();
     $this->AutoloadPathList = array('lib/eztemplate/classes/');
     $this->Variables = array();
     $this->LocalVariablesNamesStack = array();
     $this->CurrentLocalVariablesNames = null;
     $this->Functions = array();
     $this->FunctionAttributes = array();
     $this->TestCompile = false;
     $ini = eZINI::instance('template.ini');
     if ($ini->hasVariable('ControlSettings', 'MaxLevel')) {
         $this->MaxLevel = $ini->variable('ControlSettings', 'MaxLevel');
     }
     $this->MaxLevelWarning = ezpI18n::tr('lib/template', 'The maximum nesting level of %max has been reached. The execution is stopped to avoid infinite recursion.', '', array('%max' => $this->MaxLevel));
     eZDebug::createAccumulatorGroup('template_total', 'Template Total');
     $this->TemplatesUsageStatistics = array();
     // Array of templates which are used in a single fetch()
     $this->TemplateFetchList = array();
     $this->ForeachCounter = 0;
     $this->ForCounter = 0;
     $this->WhileCounter = 0;
     $this->DoCounter = 0;
     $this->ElseifCounter = 0;
 }
 /**
  * Creates a new eZOracleDB object and connects to the database.
  */
 function eZOracleTracing50DB($parameters)
 {
     $this->eZDBInterface($parameters);
     if (!extension_loaded('oci8')) {
         if (function_exists('eZAppendWarningItem')) {
             eZAppendWarningItem(array('error' => array('type' => 'ezdb', 'number' => eZDBInterface::ERROR_MISSING_EXTENSION), 'text' => 'Oracle extension was not found, the DB handler will not be initialized.'));
             $this->IsConnected = false;
         }
         eZDebug::writeWarning('Oracle extension was not found, the DB handler will not be initialized.', 'eZOracleDB');
         return;
     }
     //$server = $this->Server;
     $user = $this->User;
     $password = $this->Password;
     $db = $this->DB;
     $this->ErrorMessage = false;
     $this->ErrorNumber = false;
     $this->IgnoreTriggerErrors = false;
     $ini = eZINI::instance();
     if (function_exists("oci_connect")) {
         $this->Mode = OCI_COMMIT_ON_SUCCESS;
         // translate chosen charset to its Oracle analogue
         $oraCharset = null;
         if (isset($this->Charset) && $this->Charset !== '') {
             if (array_key_exists($this->Charset, $this->CharsetsMap)) {
                 $oraCharset = $this->CharsetsMap[$this->Charset];
             }
         }
         $maxAttempts = $this->connectRetryCount();
         $waitTime = $this->connectRetryWaitTime();
         $numAttempts = 1;
         if ($ini->variable("DatabaseSettings", "UsePersistentConnection") == "enabled") {
             eZDebugSetting::writeDebug('kernel-db-oracle', $ini->variable("DatabaseSettings", "UsePersistentConnection"), "using persistent connection");
             eZPerfLogger::accumulatorStart('oracle_connection', 'oracle_total', 'Database connection');
             $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
             try {
                 $this->DBConnection = oci_pconnect($user, $password, $db, $oraCharset);
             } catch (ErrorException $e) {
             }
             eZPerfLogger::accumulatorStop('oracle_connection');
             eZDebug::setHandleType($oldHandling);
             while ($this->DBConnection == false and $numAttempts <= $maxAttempts) {
                 sleep($waitTime);
                 eZPerfLogger::accumulatorStart('oracle_connection', 'oracle_total', 'Database connection');
                 $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
                 try {
                     $this->DBConnection = oci_pconnect($user, $password, $db, $oraCharset);
                 } catch (ErrorException $e) {
                 }
                 eZPerfLogger::accumulatorStop('oracle_connection');
                 eZDebug::setHandleType($oldHandling);
                 $numAttempts++;
             }
         } else {
             eZDebugSetting::writeDebug('kernel-db-oracle', "using real connection", "using real connection");
             $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
             eZPerfLogger::accumulatorStart('oracle_connection', 'oracle_total', 'Database connection');
             try {
                 $this->DBConnection = oci_connect($user, $password, $db, $oraCharset);
             } catch (ErrorException $e) {
             }
             eZPerfLogger::accumulatorStop('oracle_connection');
             eZDebug::setHandleType($oldHandling);
             while ($this->DBConnection == false and $numAttempts <= $maxAttempts) {
                 sleep($waitTime);
                 $oldHandling = eZDebug::setHandleType(eZDebug::HANDLE_EXCEPTION);
                 eZPerfLogger::accumulatorStart('oracle_connection', 'oracle_total', 'Database connection');
                 try {
                     $this->DBConnection = @oci_connect($user, $password, $db, $oraCharset);
                 } catch (ErrorException $e) {
                 }
                 eZPerfLogger::accumulatorStop('oracle_connection');
                 eZDebug::setHandleType($oldHandling);
                 $numAttempts++;
             }
         }
         //            OCIInternalDebug(1);
         if ($this->DBConnection === false) {
             $this->IsConnected = false;
         } else {
             $this->IsConnected = true;
             // make sure the decimal separator is the dot
             $this->query("ALTER SESSION SET NLS_NUMERIC_CHARACTERS='. '");
         }
         if ($this->DBConnection === false) {
             $error = oci_error();
             // workaround for bug in PHP oci8 extension
             if ($error === false && !getenv("ORACLE_HOME")) {
                 $error = array('code' => -1, 'message' => 'ORACLE_HOME environment variable is not set');
             }
             if ($error['code'] != 0) {
                 if ($error['code'] == 12541) {
                     $error['message'] = 'No listener (probably the server is down).';
                 }
                 $this->ErrorMessage = $error['message'];
                 $this->ErrorNumber = $error['code'];
                 eZDebug::writeError("Connection error(" . $error["code"] . "):\n" . $error["message"] . " ", "eZOracleDB");
             }
             throw new eZDBNoConnectionException($db, $this->ErrorMessage, $this->ErrorNumber);
         }
     } else {
         $this->ErrorMessage = "Oracle support not compiled in PHP";
         $this->ErrorNumber = -1;
         eZDebug::writeError($this->ErrorMessage, "eZOracleDB");
         $this->IsConnected = false;
     }
     eZDebug::createAccumulatorGroup('oracle_total', 'Oracle Total');
 }