コード例 #1
0
 /**
  * Switch the siteaccess during runtime.
  *
  * WARNING: eZ publish does not support unloading extensions very well. Using this method might
  *          leave the system with partly registered extensions!
  *
  * @param  string  $requested_siteaccess The name of an existing real siteaccess.
  * @param  string  $virtual_siteaccess   The name of an optional virtual siteaccess.
  * @return boolean true on success - otherwise false
  * @access private
  * @author ymc-dabe
  */
 private function switchSiteaccessInternally($requested_siteaccess = false, $virtual_siteaccess = false)
 {
     if (self::getCurrentSiteaccess() === null) {
         return false;
     }
     //We might simply want to switch back to the original siteaccess...
     if ($requested_siteaccess === false and $virtual_siteaccess === false) {
         $requested_siteaccess = $this->attribute('original_non_virtual_siteaccess');
         $virtual_siteaccess = $this->attribute('original_virtual_siteaccess');
     }
     if (!$this->attribute('is_enabled')) {
         eZDebug::writeError("The ymcExtensionLoader is disabled, but " . __METHOD__ . " has just been called (which really shouldn't be done)!", __METHOD__);
         return false;
     }
     //no switching needed. bye.
     if ($requested_siteaccess == self::getCurrentNonVirtualSiteaccess() and $virtual_siteaccess == self::getCurrentVirtualSiteaccess()) {
         return true;
     }
     //Reset the loaded extensions...
     self::$earlyLoadingCompleted = false;
     $this->standardLoadingCompleted = false;
     $this->virtualLoadingCompleted = false;
     $this->loadingCompleted = false;
     $this->registeredExtensions = array();
     $this->non_virtual_siteaccess_name = false;
     //Reset all loaded INIs
     unset($GLOBALS["eZINIOverrideDirList"]);
     //Set no siteaccess
     self::setInternalSiteaccess(null);
     //Initialise INI (using site.ini)
     $ini = eZINI::instance();
     //FLush the INI-Cache (of site.ini)
     $ini->loadCache();
     //Activate basic extensions
     $this->registerExtensions();
     //Set the requested siteaccess and load it
     self::setInternalSiteaccess($requested_siteaccess);
     //Advice new INI-files to use (as it is done by eZ publish on startup
     if (file_exists("settings/siteaccess/{$requested_siteaccess}")) {
         $ini->prependOverrideDir("siteaccess/{$requested_siteaccess}", false, 'siteaccess');
     }
     eZExtension::prependExtensionSiteAccesses($requested_siteaccess);
     //FLush the INI-Cache (of site.ini)
     $ini->loadCache();
     //Register access-extensions
     $this->registerExtensions();
     //Activate the virtual_siteaccess if needed
     if ($virtual_siteaccess !== false) {
         $this->registerExtensions($virtual_siteaccess);
     }
     return true;
 }
コード例 #2
0
 /**
  * @param  object  $contentObjectAttribute An eZContentObjectAttribute object
  * @param  eZContentObject $contentObject
  * @param  array $publishedNodes
  * @return void
  * @see    eZDataType
  * @access public
  * @author ymc-dabe
  */
 function onPublish($contentObjectAttribute, $contentObject, $publishedNodes)
 {
     $contentClassAttribute = $contentObjectAttribute->attribute('contentclass_attribute');
     $type = (int) $contentClassAttribute->attribute(self::CLASS_TYPE_FIELD);
     $filename = $contentClassAttribute->attribute(self::CLASS_FILE_FIELD);
     $section = $contentClassAttribute->attribute(self::CLASS_SECTION_FIELD);
     $parameter = $contentClassAttribute->attribute(self::CLASS_PARAMETER_FIELD);
     $makeEmptyArray = $contentObjectAttribute->attribute('data_int');
     $json_data = $contentObjectAttribute->attribute('data_text');
     $data = json_decode($json_data, true);
     if (is_array($data)) {
         if ($contentObjectAttribute->attribute('data_int') == 1 and $type === ymcDynamicIniSetting::TYPE_ARRAY) {
             $dynamicIniSetting = ymcDynamicIniSetting::create($contentClassAttribute->attribute('id'), $contentObjectAttribute->attribute('id'), $contentObjectAttribute->attribute('version'), $contentObjectAttribute->attribute('contentobject_id'), $type, $filename, $section, $parameter, '', '');
             $dynamicIniSetting->store();
         }
         foreach ($data as $key => $value) {
             $dynamicIniSetting = ymcDynamicIniSetting::create($contentClassAttribute->attribute('id'), $contentObjectAttribute->attribute('id'), $contentObjectAttribute->attribute('version'), $contentObjectAttribute->attribute('contentobject_id'), $type, $filename, $section, $parameter, $key, $value);
             $dynamicIniSetting->store();
         }
     }
     ymcDynamicIniSetting::dropUnneededByContentObjectAttributeIdAndVersion($contentObjectAttribute->attribute('id'), $contentObjectAttribute->attribute('version'));
     $dynamicIniSettings = ymcDynamicIniSetting::fetchListByObjectAttributeID($contentObjectAttribute->attribute('id'));
     foreach ($dynamicIniSettings as $dynamicIniSetting) {
         $ymcExtensionLoader = ymcExtensionLoader::getInstance();
         $dynamicIniCacheDirToDrop = $ymcExtensionLoader->attribute('global_cache_directory') . '/openvolano/dynamic_ini/' . $dynamicIniSetting->attribute('contentobject_id');
         eZDebug::writeNotice("Dropping cached dynamic-INI-dir: {$dynamicIniCacheDirToDrop}", 'ymcExtensionLoader::prependDynamicINI()');
         $fileHandler = eZClusterFileHandler::instance();
         $fileHandler->fileDelete($dynamicIniCacheDirToDrop);
     }
 }