/**
  * @todo Move to a common extension testing class
  */
 private static function clearActiveExtensionsCache()
 {
     eZCache::clearByID('active_extensions');
     // currently required so that cache will actually be considered expired
     // this is a design issue in eZExpiryHandler we need to address soon as it deeply impacts testing any feature
     // that relies on it, and also impacts runtime on high-trafic sites.
     sleep(2);
 }
/**
 * @param array $action
 */
function generateJson( $action )
{
    $jsPath = "extension/{$action['identifier']}/design/oscar/javascript/";

    if ( is_dir( $jsPath ) )
    {
        $convert = new ConvertTsToJSON( $jsPath . "com.lang.js", null, $action['param'] );
        $convert->process();

        eZCache::clearByID( array('ezjscore-packer'), 'template-block' );
    }
}
 public function testPurgeImageAliasForObject()
 {
     $imageObject = $this->createImage("Original image");
     // generate a couple aliases
     $dataMap = $imageObject->dataMap();
     $aliasHandler = $dataMap['image']->attribute('content');
     foreach (array('small', 'medium', 'large') as $aliasName) {
         $alias = $aliasHandler->attribute($aliasName);
         $aliasFiles[] = $alias['url'];
     }
     // create a new version
     $imageObject = $this->createNewVersionWithImage($imageObject);
     // generate a couple aliases
     $dataMap = $imageObject->dataMap();
     $imageAttribute = $dataMap['image'];
     $imageAttributeId = $imageAttribute->attribute('id');
     $aliasHandler = $imageAttribute->attribute('content');
     $aliasFiles = array();
     foreach (array('small', 'medium', 'large') as $aliasName) {
         $alias = $aliasHandler->attribute($aliasName);
         $aliasFiles[] = $alias['url'];
     }
     // we will check that the original alias wasn't removed
     $originalAlias = $aliasHandler->attribute('original');
     $originalAliasFile = $originalAlias['url'];
     unset($originalAlias);
     $aliasFiles = array_unique($aliasFiles);
     foreach ($aliasFiles as $aliasFile) {
         self::assertImageFileExists($imageAttributeId, $aliasFile);
     }
     self::assertImageFileExists($imageAttributeId, $originalAliasFile);
     eZCache::purgeImageAlias(array('reporter' => function () {
     }));
     foreach ($aliasFiles as $aliasFile) {
         self::assertImageFileNotExists($imageAttributeId, $aliasFile);
     }
     self::assertImageFileExists($imageAttributeId, $originalAliasFile);
 }
 function initializePackage($siteType, &$accessMap, $charset, &$extraLanguageCodes, &$allLanguages, &$primaryLanguage, &$admin, &$resultArray)
 {
     // Time limit #3:
     // We set the time limit to 5 minutes to ensure we have enough time
     // to initialize the site. However we only set if the current limit
     // is too small
     $maxTime = ini_get('max_execution_time');
     if ($maxTime != 0 and $maxTime < 5 * 60) {
         @set_time_limit(5 * 60);
     }
     switch ($siteType['access_type']) {
         case 'port':
             $userSiteaccessName = $siteType['identifier'] . '_' . 'user';
             $adminSiteaccessName = $siteType['identifier'] . '_' . 'admin';
             $accessMap['port'][$siteType['access_type_value']] = $userSiteaccessName;
             $accessMap['port'][$siteType['admin_access_type_value']] = $adminSiteaccessName;
             break;
         case 'hostname':
             $userSiteaccessName = $siteType['identifier'] . '_' . 'user';
             $adminSiteaccessName = $siteType['identifier'] . '_' . 'admin';
             $accessMap['hostname'][$siteType['access_type_value']] = $userSiteaccessName;
             $accessMap['hostname'][$siteType['admin_access_type_value']] = $adminSiteaccessName;
             break;
         case 'url':
         default:
             $userSiteaccessName = $siteType['access_type_value'];
             $adminSiteaccessName = $siteType['admin_access_type_value'];
             $accessMap['url'][$siteType['access_type_value']] = $userSiteaccessName;
             $accessMap['url'][$siteType['admin_access_type_value']] = $adminSiteaccessName;
             break;
     }
     $accessMap['accesses'][] = $userSiteaccessName;
     $accessMap['accesses'][] = $adminSiteaccessName;
     $accessMap['sites'][] = $userSiteaccessName;
     $userDesignName = $siteType['identifier'];
     $languageObjects = $allLanguages;
     $databaseMap = eZSetupDatabaseMap();
     $databaseInfo = $this->PersistenceList['database_info'];
     $databaseInfo['info'] = $databaseMap[$databaseInfo['type']];
     $dbServer = $databaseInfo['server'];
     $dbPort = $databaseInfo['port'];
     //        $dbName = $databaseInfo['dbname'];
     $dbSocket = $databaseInfo['socket'];
     $dbUser = $databaseInfo['user'];
     $dbPwd = $databaseInfo['password'];
     $dbCharset = $charset;
     $dbDriver = $databaseInfo['info']['driver'];
     $dbName = $siteType['database'];
     $dbParameters = array('server' => $dbServer, 'port' => $dbPort, 'user' => $dbUser, 'password' => $dbPwd, 'socket' => $dbSocket, 'database' => $dbName, 'charset' => $dbCharset);
     $db = eZDB::instance($dbDriver, $dbParameters, true);
     if (!$db->isConnected()) {
         $resultArray['errors'][] = array('code' => 'EZSW-005', 'text' => "Failed connecting to database {$dbName}\n" . $db->errorMessage());
         return false;
     }
     eZDB::setInstance($db);
     $result = true;
     // Initialize the database by inserting schema and data
     if (!isset($siteType['existing_database'])) {
         $siteType['existing_database'] = false;
     }
     if ($siteType['existing_database'] == eZStepInstaller::DB_DATA_REMOVE) {
         eZDBTool::cleanup($db);
     }
     if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) {
         $result = true;
         $schemaArray = eZDbSchema::read('share/db_schema.dba', true);
         if (!$schemaArray) {
             $resultArray['errors'][] = array('code' => 'EZSW-001', 'message' => "Failed loading database schema file share/db_schema.dba");
             $result = false;
         }
         if ($result) {
             $result = true;
             $dataArray = eZDbSchema::read('share/db_data.dba', true);
             if (!$dataArray) {
                 $resultArray['errors'][] = array('code' => 'EZSW-002', 'text' => "Failed loading database data file share/db_data.dba");
                 $result = false;
             }
             if ($result) {
                 $schemaArray = array_merge($schemaArray, $dataArray);
                 $schemaArray['type'] = strtolower($db->databaseName());
                 $schemaArray['instance'] = $db;
                 $result = true;
                 $dbSchema = eZDbSchema::instance($schemaArray);
                 if (!$dbSchema) {
                     $resultArray['errors'][] = array('code' => 'EZSW-003', 'text' => "Failed loading " . $db->databaseName() . " schema handler");
                     $result = false;
                 }
                 if ($result) {
                     $result = true;
                     // This will insert the schema, then the data and
                     // run any sequence value correction SQL if required
                     $params = array('schema' => true, 'data' => true);
                     if ($db->databaseName() == 'mysql') {
                         $engines = $db->arrayQuery('SHOW ENGINES');
                         foreach ($engines as $engine) {
                             if ($engine['Engine'] == 'InnoDB' && in_array($engine['Support'], array('YES', 'DEFAULT'))) {
                                 $params['table_type'] = 'innodb';
                                 break;
                             }
                         }
                     }
                     if (!$dbSchema->insertSchema($params)) {
                         $resultArray['errors'][] = array('code' => 'EZSW-004', 'text' => "Failed inserting data to " . $db->databaseName() . "\n" . $db->errorMessage());
                         $result = false;
                     }
                 }
             }
         }
         if ($result) {
             // Inserting data from the dba-data files of the datatypes
             eZDataType::loadAndRegisterAllTypes();
             $registeredDataTypes = eZDataType::registeredDataTypes();
             foreach ($registeredDataTypes as $dataType) {
                 if (!$dataType->importDBDataFromDBAFile()) {
                     $resultArray['errors'][] = array('code' => 'EZSW-002', 'text' => "Failed importing datatype related data into database: \n" . 'datatype - ' . $dataType->DataTypeString . ", \n" . 'dba-data file - ' . $dataType->getDBAFilePath());
                 }
             }
         }
     }
     if (!$result) {
         return false;
     }
     // Database initialization done
     // Prepare languages
     $primaryLanguageLocaleCode = $primaryLanguage->localeCode();
     $primaryLanguageName = $primaryLanguage->languageName();
     $prioritizedLanguages = array_merge(array($primaryLanguageLocaleCode), $extraLanguageCodes);
     $installParameters = array('path' => '.');
     $installParameters['ini'] = array();
     $siteINIChanges = array();
     $url = $siteType['url'];
     if (preg_match("#^[a-zA-Z0-9]+://(.*)\$#", $url, $matches)) {
         $url = $matches[1];
     }
     $siteINIChanges['SiteAccessSettings'] = array('RelatedSiteAccessList' => $accessMap['accesses']);
     $siteINIChanges['ContentSettings'] = array('TranslationList' => implode(';', $extraLanguageCodes));
     $siteINIChanges['SiteSettings'] = array('SiteName' => $siteType['title'], 'SiteURL' => $url);
     $siteINIChanges['DatabaseSettings'] = array('DatabaseImplementation' => $dbDriver, 'Server' => $dbServer, 'Port' => $dbPort, 'Database' => $dbName, 'User' => $dbUser, 'Password' => $dbPwd, 'Charset' => false);
     $siteINIChanges['FileSettings'] = array('VarDir' => 'var/' . $siteType['identifier']);
     if (trim($dbSocket) != '') {
         $siteINIChanges['DatabaseSettings']['Socket'] = $dbSocket;
     } else {
         $siteINIChanges['DatabaseSettings']['Socket'] = 'disabled';
     }
     if ($admin['email']) {
         $siteINIChanges['InformationCollectionSettings'] = array('EmailReceiver' => false);
         $siteINIChanges['UserSettings'] = array('RegistrationEmail' => false);
         $siteINIChanges['MailSettings'] = array('AdminEmail' => $admin['email'], 'EmailSender' => false);
     }
     $siteINIChanges['RegionalSettings'] = array('Locale' => $primaryLanguage->localeFullCode(), 'ContentObjectLocale' => $primaryLanguage->localeCode(), 'SiteLanguageList' => $prioritizedLanguages);
     if ($primaryLanguage->localeCode() == 'eng-GB') {
         $siteINIChanges['RegionalSettings']['TextTranslation'] = 'disabled';
     } else {
         $siteINIChanges['RegionalSettings']['TextTranslation'] = 'enabled';
     }
     $installParameters['ini']['siteaccess'][$adminSiteaccessName]['site.ini.append'] = $siteINIChanges;
     $installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini.append'] = $siteINIChanges;
     $installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini']['DesignSettings'] = array('SiteDesign' => $userDesignName);
     $installParameters['variables']['user_siteaccess'] = $userSiteaccessName;
     $installParameters['variables']['admin_siteaccess'] = $adminSiteaccessName;
     $installParameters['variables']['design'] = $userDesignName;
     $tmpSiteINI = eZINI::create('site.ini');
     // Set ReadOnlySettingsCheck to false: towards
     // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
     $tmpSiteINI->setReadOnlySettingsCheck(false);
     $tmpSiteINI->setVariable('FileSettings', 'VarDir', $siteINIChanges['FileSettings']['VarDir']);
     // Change the current translation variables, before other parts start using them
     $tmpSiteINI->setVariable('RegionalSettings', 'Locale', $siteINIChanges['RegionalSettings']['Locale']);
     $tmpSiteINI->setVariable('RegionalSettings', 'ContentObjectLocale', $siteINIChanges['RegionalSettings']['ContentObjectLocale']);
     $tmpSiteINI->setVariable('RegionalSettings', 'TextTranslation', $siteINIChanges['RegionalSettings']['TextTranslation']);
     $tmpSiteINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}");
     /*
     $typeFunctionality = eZSetupFunctionality( $siteType['identifier'] );
     $extraFunctionality = array_merge( isset( $this->PersistenceList['additional_packages'] ) ?
                                        $this->PersistenceList['additional_packages'] :
                                        array(),
                                        $typeFunctionality['required'] );
     $extraFunctionality = array_unique( $extraFunctionality );
     */
     // Add a policy to permit editors using OE
     eZPolicy::createNew(3, array('ModuleName' => 'ezoe', 'FunctionName' => '*'));
     // Install site package and it's required packages
     $sitePackageName = $this->chosenSitePackage();
     $sitePackage = eZPackage::fetch($sitePackageName);
     if (!is_object($sitePackage)) {
         $resultArray['errors'][] = array('code' => 'EZSW-041', 'text' => " Could not fetch site package: '{$sitePackageName}'");
         return false;
     }
     $dependecies = $sitePackage->attribute('dependencies');
     $requires = $dependecies['requires'];
     $requiredPackages = array();
     // Include setting files
     $settingsFiles = $sitePackage->attribute('settings-files');
     foreach ($settingsFiles as $settingsFileName) {
         if (file_exists($sitePackage->path() . '/settings/' . $settingsFileName)) {
             include_once $sitePackage->path() . '/settings/' . $settingsFileName;
         }
     }
     // Call user function for additional setup tasks.
     if (function_exists('eZSitePreInstall')) {
         eZSitePreInstall($siteType);
     }
     // Make sure objects use the selected main language instead of eng-GB
     if ($primaryLanguageLocaleCode != 'eng-GB') {
         $engLanguageObj = eZContentLanguage::fetchByLocale('eng-GB');
         $engLanguageID = (int) $engLanguageObj->attribute('id');
         $updateSql = "UPDATE ezcontent_language\nSET\nlocale='{$primaryLanguageLocaleCode}',\nname='{$primaryLanguageName}'\nWHERE\nid={$engLanguageID}";
         $db->query($updateSql);
         eZContentLanguage::expireCache();
         $primaryLanguageObj = eZContentLanguage::fetchByLocale($primaryLanguageLocaleCode);
         // Add it if it is missing (most likely)
         if (!$primaryLanguageObj) {
             $primaryLanguageObj = eZContentLanguage::addLanguage($primaryLanguageLocaleCode, $primaryLanguageName);
         }
         $primaryLanguageID = (int) $primaryLanguageObj->attribute('id');
         // Find objects which are always available
         if ($db->databaseName() == 'oracle') {
             $sql = "SELECT id\nFROM\nezcontentobject\nWHERE\nbitand( language_mask, 1 ) = 1";
         } else {
             $sql = "SELECT id\nFROM\nezcontentobject\nWHERE\nlanguage_mask & 1 = 1";
         }
         $objectList = array();
         $list = $db->arrayQuery($sql);
         foreach ($list as $row) {
             $objectList[] = (int) $row['id'];
         }
         $inSql = 'IN ( ' . implode(', ', $objectList) . ')';
         // Updates databases that have eng-GB data to the new locale.
         $updateSql = "UPDATE ezcontentobject_name\nSET\ncontent_translation='{$primaryLanguageLocaleCode}',\nreal_translation='{$primaryLanguageLocaleCode}',\nlanguage_id={$primaryLanguageID}\nWHERE\ncontent_translation='eng-GB' OR\nreal_translation='eng-GB'";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject_name\nSET\nlanguage_id=language_id+1\nWHERE\ncontentobject_id {$inSql}";
         $db->query($updateSql);
         // attributes
         $updateSql = "UPDATE ezcontentobject_attribute\nSET\nlanguage_code='{$primaryLanguageLocaleCode}',\nlanguage_id={$primaryLanguageID}\nWHERE\nlanguage_code='eng-GB'";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject_attribute\nSET\nlanguage_id=language_id+1\nWHERE\ncontentobject_id {$inSql}";
         $db->query($updateSql);
         // version
         $updateSql = "UPDATE ezcontentobject_version\nSET\ninitial_language_id={$primaryLanguageID},\nlanguage_mask={$primaryLanguageID}\nWHERE\ninitial_language_id={$engLanguageID}";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject_version\nSET\nlanguage_mask=language_mask+1\nWHERE\ncontentobject_id {$inSql}";
         $db->query($updateSql);
         // object
         $updateSql = "UPDATE ezcontentobject\nSET\ninitial_language_id={$primaryLanguageID},\nlanguage_mask={$primaryLanguageID}\nWHERE\ninitial_language_id={$engLanguageID}";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject\nSET\nlanguage_mask=language_mask+1\nWHERE\nid {$inSql}";
         $db->query($updateSql);
         // content object state groups & states
         $mask = $primaryLanguageID | 1;
         $db->query("UPDATE ezcobj_state_group\n                         SET language_mask = {$mask}, default_language_id = {$primaryLanguageID}\n                         WHERE default_language_id = {$engLanguageID}");
         $db->query("UPDATE ezcobj_state\n                         SET language_mask = {$mask}, default_language_id = {$primaryLanguageID}\n                         WHERE default_language_id = {$engLanguageID}");
         $db->query("UPDATE ezcobj_state_group_language\n                         SET language_id = {$primaryLanguageID}\n                         WHERE language_id = {$engLanguageID}");
         $db->query("UPDATE ezcobj_state_language\n                         SET language_id = {$primaryLanguageID}\n                         WHERE language_id = {$engLanguageID}");
         // ezcontentclass_name
         $updateSql = "UPDATE ezcontentclass_name\nSET\nlanguage_locale='{$primaryLanguageLocaleCode}'\nWHERE\nlanguage_locale='eng-GB'";
         $db->query($updateSql);
         // use high-level api, because it's impossible to update serialized names with direct sqls.
         // use direct access to 'NameList' to avoid unnecessary sql-requests and because
         // we do 'replacement' of existing language(with some 'id') with another language code.
         $contentClassList = eZContentClass::fetchList();
         foreach ($contentClassList as $contentClass) {
             $classAttributes = $contentClass->fetchAttributes();
             foreach ($classAttributes as $classAttribute) {
                 $classAttribute->NameList->setName($classAttribute->NameList->name('eng-GB'), $primaryLanguageLocaleCode);
                 $classAttribute->NameList->setAlwaysAvailableLanguage($primaryLanguageLocaleCode);
                 $classAttribute->NameList->removeName('eng-GB');
                 $classAttribute->store();
             }
             $contentClass->NameList->setName($contentClass->NameList->name('eng-GB'), $primaryLanguageLocaleCode);
             $contentClass->NameList->setAlwaysAvailableLanguage($primaryLanguageLocaleCode);
             $contentClass->NameList->removeName('eng-GB');
             $contentClass->NameList->setHasDirtyData(false);
             // to not update 'ezcontentclass_name', because we've already updated it.
             $contentClass->store();
         }
     }
     // Setup all languages
     foreach ($allLanguages as $languageObject) {
         $primaryLanguageObj = eZContentLanguage::fetchByLocale($languageObject->localeCode());
         // Add it if it is missing (most likely)
         if (!$primaryLanguageObj) {
             $primaryLanguageObj = eZContentLanguage::addLanguage($languageObject->localeCode(), $languageObject->internationalLanguageName());
         }
     }
     eZContentLanguage::expireCache();
     // Make sure priority list is changed to the new chosen languages
     eZContentLanguage::setPrioritizedLanguages($prioritizedLanguages);
     if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) {
         $user = eZUser::instance(14);
         // Must be initialized to make node assignments work correctly
         if (!is_object($user)) {
             $resultArray['errors'][] = array('code' => 'EZSW-020', 'text' => "Could not fetch administrator user object");
             return false;
         }
         // Make sure Admin is the currently logged in user
         // This makes sure all new/changed objects get this as creator
         $user->loginCurrent();
         // by default(if 'language_map' is not set) create all necessary languages
         $languageMap = isset($this->PersistenceList['package_info']) && isset($this->PersistenceList['package_info']['language_map']) ? $this->PersistenceList['package_info']['language_map'] : true;
         if (is_array($languageMap) && count($languageMap) > 0) {
             //
             // Create necessary languages and set them as "prioritized languages" to avoid
             // drawbacks in fetch functions, like eZContentObjectTreeNode::fetch().
             //
             $prioritizedLanguageObjects = eZContentLanguage::prioritizedLanguages();
             // returned objects
             foreach ($languageMap as $fromLanguage => $toLanguage) {
                 if ($toLanguage != 'skip') {
                     $prioritizedLanguageObjects[] = eZContentLanguage::fetchByLocale($toLanguage, true);
                 }
             }
             $prioritizedLanguageLocales = array();
             foreach ($prioritizedLanguageObjects as $language) {
                 $locale = $language->attribute('locale');
                 if (!in_array($locale, $prioritizedLanguageLocales)) {
                     $prioritizedLanguageLocales[] = $locale;
                 }
             }
             eZContentLanguage::setPrioritizedLanguages($prioritizedLanguageLocales);
         }
         foreach ($requires as $require) {
             if ($require['type'] != 'ezpackage') {
                 continue;
             }
             $packageName = $require['name'];
             $package = eZPackage::fetch($packageName, false, false, false);
             if (is_object($package)) {
                 $requiredPackages[] = $package;
                 if ($package->attribute('install_type') == 'install') {
                     $installParameters = array('use_dates_from_package' => true, 'site_access_map' => array('*' => $userSiteaccessName), 'top_nodes_map' => array('*' => 2), 'design_map' => array('*' => $userDesignName), 'language_map' => $languageMap, 'restore_dates' => true, 'user_id' => $user->attribute('contentobject_id'), 'non-interactive' => true);
                     $status = $package->install($installParameters);
                     if (!$status) {
                         $errorText = "Unable to install package '{$packageName}'";
                         if (isset($installParameters['error']['description'])) {
                             $errorText .= ": " . $installParameters['error']['description'];
                         }
                         $resultArray['errors'][] = array('code' => 'EZSW-051', 'text' => $errorText);
                         return false;
                     }
                 }
             } else {
                 $resultArray['errors'][] = array('code' => 'EZSW-050', 'text' => "Could not fetch required package: '{$packageName}'");
                 return false;
             }
             unset($package);
         }
     }
     $GLOBALS['eZContentObjectDefaultLanguage'] = $primaryLanguageLocaleCode;
     $nodeRemoteMap = array();
     $rows = $db->arrayQuery("SELECT node_id, remote_id FROM ezcontentobject_tree");
     foreach ($rows as $row) {
         $remoteID = $row['remote_id'];
         if (strlen(trim($remoteID)) > 0) {
             $nodeRemoteMap[$remoteID] = $row['node_id'];
         }
     }
     $objectRemoteMap = array();
     $rows = $db->arrayQuery("SELECT id, remote_id FROM ezcontentobject");
     foreach ($rows as $row) {
         $remoteID = $row['remote_id'];
         if (strlen(trim($remoteID)) > 0) {
             $objectRemoteMap[$remoteID] = $row['id'];
         }
     }
     $classRemoteMap = array();
     $rows = $db->arrayQuery("SELECT id, identifier, remote_id FROM ezcontentclass");
     foreach ($rows as $row) {
         $remoteID = $row['remote_id'];
         if (strlen(trim($remoteID)) > 0) {
             $classRemoteMap[$remoteID] = array('id' => $row['id'], 'identifier' => $row['identifier']);
         }
     }
     $siteCSS = false;
     $classesCSS = false;
     foreach ($requiredPackages as $package) {
         if ($package->attribute('type') == 'sitestyle') {
             $fileList = $package->fileList('default');
             foreach ($fileList as $file) {
                 $fileIdentifier = $file["variable-name"];
                 if ($fileIdentifier == 'sitecssfile') {
                     $siteCSS = $package->fileItemPath($file, 'default');
                 } else {
                     if ($fileIdentifier == 'classescssfile') {
                         $classesCSS = $package->fileItemPath($file, 'default');
                     }
                 }
             }
         }
     }
     $parameters = array('node_remote_map' => $nodeRemoteMap, 'object_remote_map' => $objectRemoteMap, 'class_remote_map' => $classRemoteMap, 'preview_design' => $userDesignName, 'design_list' => array($userDesignName, 'admin2', 'admin'), 'user_siteaccess' => $userSiteaccessName, 'admin_siteaccess' => $adminSiteaccessName, 'package_object' => $sitePackage, 'siteaccess_urls' => $this->siteaccessURLs(), 'access_map' => $accessMap, 'site_type' => $siteType, 'all_language_codes' => $prioritizedLanguages);
     $siteINIStored = false;
     $siteINIAdminStored = false;
     $designINIStored = false;
     if (function_exists('eZSiteINISettings')) {
         $extraSettings = eZSiteINISettings($parameters);
     } else {
         $extraSettings = array();
     }
     if (function_exists('eZSiteAdminINISettings')) {
         $extraAdminSettings = eZSiteAdminINISettings($parameters);
     } else {
         $extraAdminSettings = array();
     }
     if (function_exists('eZSiteCommonINISettings')) {
         $extraCommonSettings = eZSiteCommonINISettings($parameters);
     } else {
         $extraCommonSettings = array();
     }
     $isUntranslatedSettingAdded = false;
     foreach ($extraAdminSettings as $key => $extraAdminSetting) {
         if ($extraAdminSetting['name'] == 'site.ini') {
             $extraAdminSettings[$key]['settings']['RegionalSettings']['ShowUntranslatedObjects'] = 'enabled';
             $isUntranslatedSettingAdded = true;
             break;
         }
     }
     if (!$isUntranslatedSettingAdded) {
         $extraAdminSettings[] = array('name' => 'site.ini', 'settings' => array('RegionalSettings' => array('ShowUntranslatedObjects' => 'enabled')));
     }
     // Enable OE and ODF extensions by default
     $extensionsToEnable = array();
     // Included in "fat" install, needs to override $extraCommonSettings extensions
     $extensionsPrepended = array('ezjscore', 'ezoe', 'ezformtoken');
     foreach (array('ezie', 'ezodf', 'ezprestapiprovider', 'ezmultiupload', 'eztags', 'ezautosave', 'ez_network', 'ez_network_demo') as $extension) {
         if (file_exists("extension/{$extension}")) {
             $extensionsToEnable[] = $extension;
         }
     }
     $settingAdded = false;
     foreach ($extraCommonSettings as $key => $extraCommonSetting) {
         if ($extraCommonSetting['name'] == 'site.ini' && isset($extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'])) {
             $settingAdded = true;
             $extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'] = array_merge($extensionsPrepended, $extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'], $extensionsToEnable);
             break;
         }
     }
     if (!$settingAdded) {
         $extraCommonSettings[] = array('name' => 'site.ini', 'settings' => array('ExtensionSettings' => array('ActiveExtensions' => array_merge($extensionsPrepended, $extensionsToEnable))));
     }
     // Enable dynamic tree menu for the admin interface by default
     $enableDynamicTreeMenuAdded = false;
     foreach ($extraAdminSettings as $key => $extraSetting) {
         if ($extraSetting['name'] == 'contentstructuremenu.ini') {
             if (isset($extraSetting['settings']['TreeMenu'])) {
                 $extraAdminSettings[$key]['settings']['TreeMenu']['Dynamic'] = 'enabled';
             } else {
                 $extraAdminSettings[$key]['settings'] = array('TreeMenu' => array('Dynamic' => 'enabled'));
             }
             $enableDynamicTreeMenuAdded = true;
             break;
         }
     }
     if (!$enableDynamicTreeMenuAdded) {
         $extraAdminSettings[] = array('name' => 'contentstructuremenu.ini', 'settings' => array('TreeMenu' => array('Dynamic' => 'enabled')));
     }
     $resultArray['common_settings'] = $extraCommonSettings;
     foreach ($extraSettings as $extraSetting) {
         if ($extraSetting === false) {
             continue;
         }
         $iniName = $extraSetting['name'];
         $settings = $extraSetting['settings'];
         $resetArray = false;
         if (isset($extraSetting['reset_arrays'])) {
             $resetArray = $extraSetting['reset_arrays'];
         }
         $tmpINI = eZINI::create($iniName);
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $tmpINI->setReadOnlySettingsCheck(false);
         $tmpINI->setVariables($settings);
         if ($iniName == 'site.ini') {
             $siteINIStored = true;
             $tmpINI->setVariables($siteINIChanges);
             $tmpINI->setVariable('DesignSettings', 'SiteDesign', $userDesignName);
             $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('base'));
         } else {
             if ($iniName == 'design.ini') {
                 if ($siteCSS) {
                     $tmpINI->setVariable('StylesheetSettings', 'SiteCSS', $siteCSS);
                 }
                 if ($classesCSS) {
                     $tmpINI->setVariable('StylesheetSettings', 'ClassesCSS', $classesCSS);
                 }
                 $designINIStored = true;
             }
         }
         $tmpINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}", $resetArray);
         if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) {
             // setting up appropriate data in look&feel object
             $templateLookClass = eZContentClass::fetchByIdentifier('template_look', true);
             if ($templateLookClass) {
                 $objectList = $templateLookClass->objectList();
                 if ($objectList and count($objectList) > 0) {
                     $templateLookObject = current($objectList);
                     $dataMap = $templateLookObject->fetchDataMap();
                     if (isset($dataMap['title'])) {
                         $dataMap['title']->setAttribute('data_text', $siteINIChanges['SiteSettings']['SiteName']);
                         $dataMap['title']->store();
                     }
                     if (isset($dataMap['siteurl'])) {
                         $dataMap['siteurl']->setAttribute('data_text', $siteINIChanges['SiteSettings']['SiteURL']);
                         $dataMap['siteurl']->store();
                     }
                     if (isset($dataMap['email'])) {
                         $dataMap['email']->setAttribute('data_text', $siteINIChanges['MailSettings']['AdminEmail']);
                         $dataMap['email']->store();
                     }
                     $objectName = $templateLookClass->contentObjectName($templateLookObject);
                     $templateLookObject->setName($objectName);
                     $templateLookObject->store();
                 }
             }
         }
     }
     foreach ($extraAdminSettings as $extraSetting) {
         if ($extraSetting === false) {
             continue;
         }
         $iniName = $extraSetting['name'];
         $settings = $extraSetting['settings'];
         $resetArray = false;
         if (isset($extraSetting['reset_arrays'])) {
             $resetArray = $extraSetting['reset_arrays'];
         }
         $tmpINI = eZINI::create($iniName);
         $tmpINI->setVariables($settings);
         if ($iniName == 'site.ini') {
             $siteINIAdminStored = true;
             $tmpINI->setVariables($siteINIChanges);
             $tmpINI->setVariable('SiteAccessSettings', 'RequireUserLogin', 'true');
             $tmpINI->setVariable('DesignSettings', 'SiteDesign', 'admin2');
             $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('admin'));
             $tmpINI->setVariable('SiteSettings', 'LoginPage', 'custom');
             $tmpINI->setVariable('SiteSettings', 'DefaultPage', 'content/dashboard');
         }
         $tmpINI->save(false, '.append.php', false, true, "settings/siteaccess/{$adminSiteaccessName}", $resetArray);
     }
     if (!$siteINIAdminStored) {
         $siteINI = eZINI::create('site.ini');
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $siteINI->setReadOnlySettingsCheck(false);
         $siteINI->setVariables($siteINIChanges);
         $siteINI->setVariable('SiteAccessSettings', 'RequireUserLogin', 'true');
         $siteINI->setVariable('DesignSettings', 'SiteDesign', 'admin2');
         $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('admin'));
         $siteINI->setVariable('SiteSettings', 'LoginPage', 'custom');
         $siteINI->setVariable('SiteSettings', 'DefaultPage', 'content/dashboard');
         $siteINI->save(false, '.append.php', false, false, "settings/siteaccess/{$adminSiteaccessName}", true);
     }
     if (!$siteINIStored) {
         $siteINI = eZINI::create('site.ini');
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $siteINI->setReadOnlySettingsCheck(false);
         $siteINI->setVariables($siteINIChanges);
         $siteINI->setVariable('DesignSettings', 'SiteDesign', $userDesignName);
         $siteINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('base'));
         $siteINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}", true);
     }
     if (!$designINIStored) {
         $designINI = eZINI::create('design.ini');
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $designINI->setReadOnlySettingsCheck(false);
         if ($siteCSS) {
             $designINI->setVariable('StylesheetSettings', 'SiteCSS', $siteCSS);
         }
         if ($classesCSS) {
             $designINI->setVariable('StylesheetSettings', 'ClassesCSS', $classesCSS);
         }
         $designINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}");
     }
     eZDir::mkdir("design/" . $userDesignName);
     eZDir::mkdir("design/" . $userDesignName . "/templates");
     eZDir::mkdir("design/" . $userDesignName . "/stylesheets");
     eZDir::mkdir("design/" . $userDesignName . "/images");
     eZDir::mkdir("design/" . $userDesignName . "/override");
     eZDir::mkdir("design/" . $userDesignName . "/override/templates");
     if ($siteType['existing_database'] == eZStepInstaller::DB_DATA_KEEP) {
         return true;
     }
     // Try and remove user/login without limitation from the anonymous user
     $anonRole = eZRole::fetchByName('Anonymous');
     if (is_object($anonRole)) {
         $anonPolicies = $anonRole->policyList();
         foreach ($anonPolicies as $anonPolicy) {
             if ($anonPolicy->attribute('module_name') == 'user' and $anonPolicy->attribute('function_name') == 'login') {
                 $anonPolicy->removeThis();
                 break;
             }
         }
     }
     // Setup all roles according to site chosen and addons
     if (function_exists('eZSiteRoles')) {
         $extraRoles = eZSiteRoles($parameters);
         foreach ($extraRoles as $extraRole) {
             if (!$extraRole) {
                 continue;
             }
             $extraRoleName = $extraRole['name'];
             $role = eZRole::fetchByName($extraRoleName);
             if (!is_object($role)) {
                 $role = eZRole::create($extraRoleName);
                 $role->store();
             }
             $roleID = $role->attribute('id');
             if (isset($extraRole['policies'])) {
                 $extraPolicies = $extraRole['policies'];
                 foreach ($extraPolicies as $extraPolicy) {
                     if (isset($extraPolicy['limitation'])) {
                         $role->appendPolicy($extraPolicy['module'], $extraPolicy['function'], $extraPolicy['limitation']);
                     } else {
                         $role->appendPolicy($extraPolicy['module'], $extraPolicy['function']);
                     }
                 }
             }
             if (isset($extraRole['assignments'])) {
                 $roleAssignments = $extraRole['assignments'];
                 foreach ($roleAssignments as $roleAssignment) {
                     $assignmentIdentifier = false;
                     $assignmentValue = false;
                     if (isset($roleAssignment['limitation'])) {
                         $assignmentIdentifier = $roleAssignment['limitation']['identifier'];
                         $assignmentValue = $roleAssignment['limitation']['value'];
                     }
                     $role->assignToUser($roleAssignment['user_id'], $assignmentIdentifier, $assignmentValue);
                 }
             }
         }
     }
     // Setup user preferences based on the site chosen and addons
     if (function_exists('eZSitePreferences')) {
         $prefs = eZSitePreferences($parameters);
         foreach ($prefs as $prefEntry) {
             if (!$prefEntry) {
                 continue;
             }
             $prefUserID = $prefEntry['user_id'];
             foreach ($prefEntry['preferences'] as $pref) {
                 $prefName = $pref['name'];
                 $prefValue = $pref['value'];
                 if (!eZPreferences::setValue($prefName, $prefValue, $prefUserID)) {
                     $resultArray['errors'][] = array('code' => 'EZSW-070', 'text' => "Could not create ezpreference '{$prefValue}' for {$prefUserID}");
                     return false;
                 }
             }
         }
     }
     $publishAdmin = false;
     $userAccount = eZUser::fetch(14);
     if (!is_object($userAccount)) {
         $resultArray['errors'][] = array('code' => 'EZSW-020', 'text' => "Could not fetch administrator user object");
         return false;
     }
     $userObject = $userAccount->attribute('contentobject');
     if (!is_object($userObject)) {
         $resultArray['errors'][] = array('code' => 'EZSW-021', 'text' => "Could not fetch administrator content object");
         return false;
     }
     $newUserObject = $userObject->createNewVersion(false, false);
     if (!is_object($newUserObject)) {
         $resultArray['errors'][] = array('code' => 'EZSW-022', 'text' => "Could not create new version of administrator content object");
         return false;
     }
     $dataMap = $newUserObject->attribute('data_map');
     $error = false;
     if (trim($admin['email'])) {
         if (!isset($dataMap['user_account'])) {
             $resultArray['errors'][] = array('code' => 'EZSW-023', 'text' => "Administrator content object does not have a 'user_account' attribute");
             return false;
         }
         $userAccount->setInformation(14, 'admin', $admin['email'], $admin['password'], $admin['password']);
         $dataMap['user_account']->setContent($userAccount);
         $dataMap['user_account']->store();
         $publishAdmin = true;
         $userAccount->store();
     }
     if (trim($admin['first_name']) or trim($admin['last_name'])) {
         if (!isset($dataMap['first_name'])) {
             $resultArray['errors'][] = array('code' => 'EZSW-023', 'text' => "Administrator content object does not have a 'first_name' field");
             $error = true;
         }
         if (!isset($dataMap['last_name'])) {
             $resultArray['errors'][] = array('code' => 'EZSW-024', 'text' => "Administrator content object does not have a 'last_name' field");
             $error = true;
         }
         if ($error) {
             return false;
         }
         $dataMap['first_name']->setAttribute('data_text', $admin['first_name']);
         $dataMap['first_name']->store();
         $dataMap['last_name']->setAttribute('data_text', $admin['last_name']);
         $dataMap['last_name']->store();
         $newUserObject->store();
         $publishAdmin = true;
     }
     if ($publishAdmin) {
         $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $newUserObject->attribute('contentobject_id'), 'version' => $newUserObject->attribute('version')));
         if ($operationResult['status'] != eZModuleOperationInfo::STATUS_CONTINUE) {
             $resultArray['errors'][] = array('code' => 'EZSW-025', 'text' => "Failed to properly publish the administrator object");
             return false;
         }
     }
     // Call user function for additional setup tasks.
     if (function_exists('eZSitePostInstall')) {
         eZSitePostInstall($parameters);
     }
     // get all siteaccesses. do it via 'RelatedSiteAccessesList' settings.
     $adminSiteINI = eZINI::instance('site.ini' . '.append.php', "settings/siteaccess/{$adminSiteaccessName}");
     $relatedSiteAccessList = $adminSiteINI->variable('SiteAccessSettings', 'RelatedSiteAccessList');
     // Adding override for 'tiny_image' view for 'multi-option2' datatype
     foreach ($relatedSiteAccessList as $siteAccess) {
         $tmpOverrideINI = new eZINI('override.ini' . '.append.php', "settings/siteaccess/{$siteAccess}", null, null, null, true, true);
         $tmpOverrideINI->setVariable('tiny_image', 'Source', 'content/view/tiny.tpl');
         $tmpOverrideINI->setVariable('tiny_image', 'MatchFile', 'tiny_image.tpl');
         $tmpOverrideINI->setVariable('tiny_image', 'Subdir', 'templates');
         $tmpOverrideINI->setVariable('tiny_image', 'Match', array('class_identifier' => 'image'));
         $tmpOverrideINI->save();
     }
     $accessMap = $parameters['access_map'];
     // Call user function for some text which will be displayed at 'Finish' screen
     if (function_exists('eZSiteFinalText')) {
         $text = eZSiteFinalText($parameters);
         if (!isset($this->PersistenceList['final_text'])) {
             $this->PersistenceList['final_text'] = array();
         }
         $this->PersistenceList['final_text'][] = $text;
     }
     // ensure that evaluated policy wildcards in the user info cache
     // will be up to date with the currently activated modules
     eZCache::clearByID('user_info_cache');
     return true;
 }
    /**
     * @param string$clusterIdentifier
     * @param bool $backupExisting
     * @param bool $includeTimestamp
     * @return array
     * @throws Exception
     */
    public function generateSpriteForCluster($clusterIdentifier, $backupExisting = true, $includeTimestamp = true)
    {
        $outputFile = $this->buildFilePath($this->outputPath, array($clusterIdentifier));
        $timestampOutputFile = $this->generateFileName($outputFile, $includeTimestamp);
        $generatedSpriteName = substr($timestampOutputFile, strrpos($timestampOutputFile, '/') + 1);

        ClusterTool::setCurrentCluster( $clusterIdentifier );

        $lessPath = "extension/{$clusterIdentifier}/design/oscar/stylesheets/";
        $icoSprite = "/ico_sprite.png";
        $offsetStep = 95;
        $crop = $offsetStep * 2;
        $mobileStep = 83;
        $spriteConvertOptions = " -crop x{$crop}+0+0 ";
        $globalConvertOptions = " -append -quality 80%";

        $applicationList = CacheApplicationTool::clusterApplications();
        $cssList = array();
        $icoList = array();
        foreach( $applicationList as $application )
        {
            $icoCss = 'ico_'.SolrSafeOperatorHelper::getAppIdentifierForIcon( $application->applicationObject->identifier );
            $icoFile = StaticData::clusterFilePath( $clusterIdentifier, 'apps/'.$application->applicationObject->identifier.$icoSprite, true, true );

            if ( ! file_exists( $icoFile ) )
            {
                $icoFile = StaticData::clusterFilePath( 'default', 'apps/'.$application->applicationObject->identifier.$icoSprite, true, true );
            }
            if ( file_exists( $icoFile ) && ! in_array( $icoCss, $cssList ) )
            {
                $cssList[] = $icoCss;
                $icoList[] = $icoFile;
            }
        }

        if (empty($icoList))
        {
            throw new \Exception("No icons found for cluster {$clusterIdentifier}", 0);
        }
        if ($backupExisting && file_exists($outputFile))
        {
            rename($outputFile, $outputFile . '.bak');
        }
        $convertBinPath = $this->convertBinPath;

        $cmd = 'export PATH=$PATH:' . $convertBinPath . '; convert ' . implode( $spriteConvertOptions, $icoList ) . "{$spriteConvertOptions} {$globalConvertOptions} {$outputFile}";
        $cmdStatus = 0;
        $cmdOutput = array();
        exec($cmd, $cmdOutput, $cmdStatus);
        if ($cmdStatus != 0)
        {
            return array(
                'errorCode' => $cmdStatus,
                'generateSpriteCommand' => $cmd,
                'error' => implode('\n', $cmdOutput),
            );
        }

        $css = "
#app-catalog a.app-bar-access-app-library .poster{
    background-image: none !important;
}
#app-catalog a .poster,
#hide-app a .poster,
.item-apps .batch .wrap > a .poster,
.item-related-app .batch .wrap > a .poster{
      background-image:url(/esibuild/static/{$clusterIdentifier}/{$generatedSpriteName});
      background-repeat: no-repeat;
}
";
        $cssMobile = "
#app-catalog a.app-bar-access-app-library .poster{
    background-image: none !important;
}
#app-catalog a .poster,
#hide-app a .poster,
.item-apps .batch .wrap > a .poster,
.item-related-app .batch .wrap > a .poster{
      background-image:url(/esibuild/static/{$clusterIdentifier}/{$generatedSpriteName});
      background-repeat: no-repeat;
      background-size: {$mobileStep}px auto !important;
}
";
        $offset = 0;
        $offsetMobile = 0;
        foreach( $cssList as $key => $cssStyle )
        {
            $css .= "
#app-catalog a .poster.$cssStyle,
#hide-app a .poster.$cssStyle,
.item-apps .batch .wrap > a .poster.$cssStyle,
.item-related-app .batch .wrap > a .poster.$cssStyle{
      background-position: 0 -{$offset}px !important;
}
";
            $cssMobile .= "
#app-catalog a .poster.$cssStyle,
#hide-app a .poster.$cssStyle,
.item-apps .batch .wrap > a .poster.$cssStyle{
      background-position: 0 -{$offsetMobile}px !important;
}
";
            $offset += $offsetStep;
            $offsetMobile += $mobileStep;
            $css .= "
#app-catalog a:hover .poster.$cssStyle,
#app-catalog a:active .poster.$cssStyle,
#app-catalog a.active .poster.$cssStyle,
#hide-app a:active .poster.$cssStyle,
#hide-app a.active .poster.$cssStyle,
.item-apps .batch:hover .wrap > a .poster.$cssStyle,
.item-related-app .batch:hover .wrap > a .poster.$cssStyle{
      background-position: 0 -{$offset}px !important;
}
";
            $cssMobile .= "
#app-catalog a:hover .poster.$cssStyle,
#app-catalog a:active .poster.$cssStyle,
#app-catalog a.active .poster.$cssStyle,
#hide-app a:active .poster.$cssStyle,
#hide-app a.active .poster.$cssStyle,
.item-apps .batch:hover .wrap > a .poster.$cssStyle,
.item-related-app .batch:hover .wrap > a .poster.$cssStyle{
      background-position: 0 -{$offsetMobile}px !important;
}
";
            $offset += $offsetStep;
            $offsetMobile += $mobileStep;
        }

        if ( ! file_exists( $lessPath ) )
        {
            mkdir( $lessPath, 0755 );
        }
        if ( is_dir( $lessPath ) )
        {
            $lessFile = $lessPath."mod.icosprite.less";
            file_put_contents( $lessFile, $css );
            $lessFileMobile = $lessPath."mod.icosprite.mobile.less";
            file_put_contents( $lessFileMobile, $cssMobile );
            eZCache::clearByID( array('ezjscore-packer'), 'template-block' );
        }

        return array(
            'errorCode' => 0,
            'generateSpriteCommand' => $cmd
        );
    }
Example #6
0
 function init()
 {
     eZCache::clearByID( 'global_ini' );
     return false; // Always show
 }
    $nodeID = $module->actionParameter('NodeID');
}
if ($module->hasActionParameter('ObjectID')) {
    $objectID = $module->actionParameter('ObjectID');
}
if ($cacheType == 'All') {
    eZCache::clearAll();
} elseif ($cacheType == 'Template') {
    eZCache::clearByTag('template');
} elseif ($cacheType == 'Content') {
    eZCache::clearByTag('content');
} elseif ($cacheType == 'TemplateContent') {
    eZCache::clearByTag('template');
    eZCache::clearByTag('content');
} elseif ($cacheType == 'Ini') {
    eZCache::clearByTag('ini');
} elseif ($cacheType == 'Static') {
    // get staticCacheHandler instance
    $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler');
    $options = new ezpExtensionOptions($optionArray);
    $staticCacheHandler = eZExtension::getHandlerClass($options);
    $staticCacheHandler->generateCache(true, true);
    $cacheCleared['static'] = true;
} elseif ($cacheType == 'ContentNode') {
    $contentModule = eZModule::exists('content');
    if ($contentModule instanceof eZModule) {
        $contentModule->setCurrentAction('ClearViewCache', 'action');
        $contentModule->setActionParameter('NodeID', $nodeID, 'action');
        $contentModule->setActionParameter('ObjectID', $objectID, 'action');
        $contentModule->run('action', array($nodeID, $objectID));
    }
Example #8
0
        if ($column > 0) {
            $cli->output();
        }
        backupTables('impwcard');
    }
    //    $cli->output( "Removing urlalias data which have been imported" );
    //    $db = eZDB::instance();
    //    $db->query( "DELETE FROM ezurlalias WHERE is_imported = 1" ); // Removing all aliases which have been imported
    $rows = $db->arrayQuery("SELECT count(*) AS count FROM ezurlalias WHERE is_imported = 0");
    $remaining = $rows[0]['count'];
    if ($remaining > 0) {
        $cli->output("There are {$remaining} remaining URL aliases in the old ezurlalias table, manual cleanup is needed.");
    }
    if ($importOldAliasWildcard) {
        $cli->output("Removing old wildcard caches");
        eZCache::clearByID('urlalias');
    }
    $cli->output("Import completed");
    $cli->output("Import time taken: " . $cli->stylize('emphasize', formatTime(microtime(true) - $globalStartTime)));
}
if ($updateNodeAlias) {
    $nodeGlobalStartTime = microtime(true);
    // Start updating nodes
    $topLevelNodesArray = $db->arrayQuery('SELECT node_id FROM ezcontentobject_tree WHERE depth = 1 ORDER BY node_id');
    foreach (array_keys($topLevelNodesArray) as $key) {
        $topLevelNodeID = $topLevelNodesArray[$key]['node_id'];
        $rootNode = eZContentObjectTreeNode::fetch($topLevelNodeID);
        if ($rootNode->updateSubTreePath()) {
            ++$totalChangedNodes;
        }
        $done = false;
Example #9
0
 /**
  * Finds all cache item which has ID equal to one of the IDs in $idList.
  * You can also submit a single id to $idList.
  *
  * @param array $idList The cache ID list
  * @param bool|array $cacheList The list of caches, default false
  */
 static function clearByID($idList, $cacheList = false)
 {
     if (!$cacheList) {
         $cacheList = eZCache::fetchList();
     }
     $cacheItems = array();
     if (!is_array($idList)) {
         $idList = array($idList);
     }
     foreach ($cacheList as $cacheItem) {
         if (in_array($cacheItem['id'], $idList)) {
             $cacheItems[] = $cacheItem;
         }
     }
     foreach ($cacheItems as $cacheItem) {
         eZCache::clearItem($cacheItem);
     }
     return true;
 }
    // open settings/override/site.ini.append[.php] for writing
    $writeSiteINI = eZINI::instance( 'site.ini.append', 'settings/override', null, null, false, true );
    $writeSiteINI->setVariable( "ExtensionSettings", "ActiveExtensions", $toSave );
    $writeSiteINI->save( 'site.ini.append', '.php', false, false );
    eZCache::clearByTag( 'ini' );

    eZSiteAccess::reInitialise();

    $ini = eZINI::instance( 'module.ini' );
    $currentModules = $ini->variable( 'ModuleSettings', 'ModuleList' );
    if ( $currentModules != $oldModules )
    {
        // ensure that evaluated policy wildcards in the user info cache
        // will be up to date with the currently activated modules
        eZCache::clearByID( 'user_info_cache' );
    }

    updateAutoload( $tpl );
}

// open site.ini for reading (need to do it again to take into account the changes made to site.ini after clicking "Apply changes" button above
$siteINI = eZINI::instance();
$siteINI->load();
$selectedExtensionArray       = $siteINI->variable( 'ExtensionSettings', "ActiveExtensions" );
$selectedAccessExtensionArray = $siteINI->variable( 'ExtensionSettings', "ActiveAccessExtensions" );
$selectedExtensions           = array_merge( $selectedExtensionArray, $selectedAccessExtensionArray );
$selectedExtensions           = array_unique( $selectedExtensions );

if ( $module->isCurrentAction( 'GenerateAutoloadArrays' ) )
{
Example #11
0
 function getMIBTree()
 {
     // build list of oids corresponding to order status
     $db = self::eZDBinstance();
     $orderStatusIdoids = array();
     $orderStatusNameoids = array();
     $orderStatusCountoids = array();
     $orderStatusArchiveCountoids = array();
     if ($db) {
         $status = $db->arrayQuery('select status_id, name from ezorder_status where is_active=1 order by id');
         $db->close();
         if (is_array($status)) {
             $i = 1;
             foreach ($status as $line) {
                 self::$orderstatuslist = array_merge(self::$orderstatuslist, array("2.1.5.1.1.1.{$i}" => $line['status_id'], "2.1.5.1.1.2.{$i}" => $line['name'], "2.1.5.1.1.3.{$i}" => $line['status_id'], "2.1.5.1.1.4.{$i}" => $line['status_id']));
                 $orderStatusIdoids[$i] = array('name' => 'orderStatusId' . $i, 'syntax' => 'INTEGER');
                 $orderStatusNameoids[$i] = array('name' => 'orderStatusname' . $i, 'syntax' => 'DisplayString');
                 $orderStatusCountoids[$i] = array('name' => 'orderStatusCount' . $i, 'syntax' => 'INTEGER');
                 $orderStatusArchiveCountoids[$i] = array('name' => 'orderStatusArchive' . $i, 'syntax' => 'INTEGER');
                 $i++;
             }
         }
         //var_dump($orderStatusArchiveCountoids);
         //die();
     } else {
         // what to do in this case? db is down - maybe we should raise an exception
         // instead of producing a shortened oid list...
     }
     // build list of oids corresponding to caches and store for later their config
     $i = 1;
     $cacheoids = array();
     foreach (eZCache::fetchList() as $cacheItem) {
         if ($cacheItem['path'] != false) {
             $id = $cacheItem['id'];
             self::$cachelist = array_merge(self::$cachelist, array("2.2.{$i}.1" => $id, "2.2.{$i}.2" => $id, "2.2.{$i}.3" => $id, "2.2.{$i}.4" => $id));
             $cachename = 'cache' . ucfirst(eZSNMPd::asncleanup($id));
             $cacheoids[$i] = array('name' => $cachename, 'children' => array(1 => array('name' => "{$cachename}Name", 'syntax' => 'DisplayString', 'description' => 'The name of this cache.'), 2 => array('name' => "{$cachename}Status", 'syntax' => 'INTEGER', 'description' => 'Cache status: 1 for enabled, 0 for disabled.'), 3 => array('name' => "{$cachename}Count", 'syntax' => 'INTEGER', 'description' => 'Number of files in the cache (-1 if current cluster mode not supported).'), 4 => array('name' => "{$cachename}Size", 'syntax' => 'INTEGER', 'description' => 'Sum of size of all files in the cache (-1 if current cluster mode not supported).')));
             $i++;
         }
     }
     // build list of oids corresponding to storage dirs
     /// @todo this way of finding storage dir is lame, as it depends on them having been created
     ///       it will also not work in cluster mode, as there will be no dirs on the fs...
     $storagedir = eZSys::storageDirectory();
     $files = @scandir($storagedir);
     $i = 1;
     $storagediroids = array();
     foreach ($files as $file) {
         if ($file != '.' && $file != '..' && is_dir($storagedir . '/' . $file)) {
             self::$storagedirlist = array_merge(self::$storagedirlist, array("2.3.{$i}.1" => $storagedir . '/' . $file, "2.3.{$i}.2" => $storagedir . '/' . $file, "2.3.{$i}.3" => $storagedir . '/' . $file));
             $storagedirname = 'storage' . ucfirst(eZSNMPd::asncleanup($file));
             $storagediroids[$i] = array('name' => $storagedirname, 'children' => array(1 => array('name' => "{$storagedirname}Path", 'syntax' => 'DisplayString', 'description' => 'The path of this storage dir.'), 2 => array('name' => "{$storagedirname}Count", 'syntax' => 'INTEGER', 'description' => 'Number of files in the dir (-1 if current cluster mode not supported).'), 3 => array('name' => "{$storagedirname}Size", 'syntax' => 'INTEGER', 'description' => 'Sum of size of all files in the dir (-1 if current cluster mode not supported).')));
             $i++;
         }
     }
     return array('name' => 'eZPublish', 'children' => array(2 => array('name' => 'status', 'children' => array(1 => array('name' => 'database', 'children' => array(1 => array('name' => 'dbstatus', 'syntax' => 'INTEGER', 'description' => 'Availability of the database.'), 2 => array('name' => 'content', 'children' => array(1 => array('name' => 'contentObjects', 'syntax' => 'INTEGER', 'description' => 'The number of content objects.'), 2 => array('name' => 'contentObjectAttributes', 'syntax' => 'INTEGER', 'description' => 'The number of content object attributes.'), 3 => array('name' => 'contentObjectNodes', 'syntax' => 'INTEGER', 'description' => 'The number of content nodes.'), 4 => array('name' => 'contentObjectRelations', 'syntax' => 'INTEGER', 'description' => 'The number of content object relations.'), 5 => array('name' => 'contentObjectDrafts', 'syntax' => 'INTEGER', 'description' => 'The number of content objects in DRAFT state.'), 6 => array('name' => 'contentObjectClasses', 'syntax' => 'INTEGER', 'description' => 'The number of content object classes.'), 7 => array('name' => 'contentObjectInfoCollections', 'syntax' => 'INTEGER', 'description' => 'The number of information collections.'), 8 => array('name' => 'contentObjectsPendingIndexation', 'syntax' => 'INTEGER', 'description' => 'The number of objects pending a search-engine indexation.'), 9 => array('name' => 'pendingNotificationEvents', 'syntax' => 'INTEGER', 'description' => 'The number of pending notification events.'))), 3 => array('name' => 'users', 'children' => array(1 => array('name' => 'registeredusers', 'syntax' => 'INTEGER', 'description' => 'The number of existing user accounts.'))), 4 => array('name' => 'sessions', 'children' => array(1 => array('name' => 'allSessions', 'syntax' => 'INTEGER', 'description' => 'The number of active sessions.'), 2 => array('name' => 'anonSessions', 'syntax' => 'INTEGER', 'description' => 'The number of active anonymous users sessions.'), 3 => array('name' => 'registeredSessions', 'syntax' => 'INTEGER', 'description' => 'The number of active registered users sessions.'))), 5 => array('name' => 'shop', 'children' => array(1 => array('name' => 'orderStatusTable', 'access' => eZMIBTree::access_not_accessible, 'syntax' => 'SEQUENCE OF OrderStatusEntry', 'description' => 'A table containing the number of orders per order state.', 'children' => array(0 => array('name' => 'OrderStatusEntry', 'syntax' => 'SEQUENCE', 'items' => array(1 => array('name' => 'orderStatusId', 'syntax' => 'INTEGER'), 2 => array('name' => 'orderStatusName', 'syntax' => 'DisplayString'), 3 => array('name' => 'orderStatusCount', 'syntax' => 'INTEGER'), 4 => array('name' => 'orderStatusArchiveCount', 'syntax' => 'INTEGER'))), 1 => array('name' => 'orderStatusEntry', 'access' => eZMIBTree::access_not_accessible, 'syntax' => 'OrderStatusEntry', 'description' => 'A table row describing the set of orders in status N.', 'index' => 'orderStatusId', 'children' => array(1 => array('name' => 'orderStatusId', 'syntax' => 'INTEGER (1..99)', 'description' => 'ID of this order status.', 'nochildreninmib' => true, 'children' => $orderStatusIdoids), 2 => array('name' => 'orderStatusName', 'syntax' => 'DisplayString', 'description' => 'The name of this order status.', 'nochildreninmib' => true, 'children' => $orderStatusNameoids), 3 => array('name' => 'orderStatusCount', 'syntax' => 'INTEGER', 'description' => 'Number of active orders in this status.', 'nochildreninmib' => true, 'children' => $orderStatusCountoids), 4 => array('name' => 'orderStatusArchiveCount', 'syntax' => 'INTEGER', 'description' => 'Number of archived orders in this status.', 'nochildreninmib' => true, 'children' => $orderStatusArchiveCountoids))))))), 6 => array('name' => 'asyncpublishing', 'children' => array(1 => array('name' => 'AsyncPublishingWorkingCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Working status'), 2 => array('name' => 'AsyncPublishingFinishedCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Finished status'), 3 => array('name' => 'AsyncPublishingPendingCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Pending status'), 4 => array('name' => 'AsyncPublishingDeferredCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Deferred status'), 5 => array('name' => 'AsyncPublishingUnknownCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Unknown status'))))), 2 => array('name' => 'cache', 'children' => $cacheoids), 3 => array('name' => 'storage', 'children' => $storagediroids), 4 => array('name' => 'external', 'children' => array(1 => array('name' => 'ldap', 'syntax' => 'INTEGER', 'description' => 'Connectivity to LDAP server (-1 if not configured).'), 2 => array('name' => 'web', 'syntax' => 'INTEGER', 'description' => 'Connectivity to the web. (probes a series of webservers defined in snmpd.ini, returns -1 if not configured).'), 3 => array('name' => 'email', 'syntax' => 'INTEGER', 'description' => 'Connectivity to mail server (NB: will send a test mail when probed to a recipient defined in snmpd.ini, returns -1 if not configured).'))), 5 => array('name' => 'cluster', 'children' => array(1 => array('name' => 'clusterdbstatus', 'syntax' => 'INTEGER', 'description' => 'Availability of the cluster database (-1 for NA).')))))));
 }
Example #12
0
if ( $module->isCurrentAction( 'ClearINICache' ) )
{
    eZCache::clearByTag( 'ini' );
    $cacheCleared['ini'] = true;
}

if ( $module->isCurrentAction( 'ClearTemplateCache' ) )
{
    eZCache::clearByTag( 'template' );
    $cacheCleared['template'] = true;
}

if ( $module->isCurrentAction( 'ClearCache' ) && $module->hasActionParameter( 'CacheList' ) && is_array( $module->actionParameter( 'CacheList' ) ) )
{
    $cacheClearList = $module->actionParameter( 'CacheList' );
    eZCache::clearByID( $cacheClearList );
    $cacheItemList = array();
    foreach ( $cacheClearList as $cacheClearItem )
    {
        foreach ( $cacheList as $cacheItem )
        {
            if ( $cacheItem['id'] == $cacheClearItem )
            {
                $cacheItemList[] = $cacheItem;
                break;
            }
        }
    }
    $cacheCleared['list'] = $cacheItemList;
}
Example #13
0
function purgeItems($cacheEntries, $cli, $name)
{
    global $purgeSleep, $purgeMax, $purgeExpiry;
    if ($name) {
        $name = $cli->stylize('emphasize', $name);
    }
    $cli->output('Purging ' . $name . ': ', false);
    $i = 0;
    foreach ($cacheEntries as $cacheEntry) {
        if ($i > 0) {
            $cli->output(', ', false);
        }
        $cli->output($cli->stylize('emphasize', $cacheEntry['name']), false);
        eZCache::clearItem($cacheEntry, true, 'reportProgress', $purgeSleep, $purgeMax, $purgeExpiry);
        ++$i;
    }
    $cli->output();
}
Example #14
0
 private function internalClear($purge, $cacheEntries, $name, $purgeSleep = null, $purgeMax = null, $purgeExpiry = null)
 {
     $this->cli->output(($purge ? 'Purging ' : 'Clearing ') . $this->cli->stylize('emphasize', $name ? $name : 'All cache') . ': ');
     $warnPaths = array();
     foreach ($cacheEntries as $cacheEntry) {
         $absPath = realpath(eZSys::cacheDirectory() . DIRECTORY_SEPARATOR . $cacheEntry['path']);
         $absPathElementCount = count(explode(DIRECTORY_SEPARATOR, rtrim($absPath, DIRECTORY_SEPARATOR)));
         // Refuse to delete root directory ('/' or 'C:\')
         // 2 => since one path element ('/foo') produces two exploded elements
         if ($absPath && $absPathElementCount < 2) {
             $this->cli->error('Refusing to delete root directory! Please check your cache settings. Path: ' . $absPath);
             $this->script->shutdown(1);
             exit;
         }
         // Warn if the cache entry is not function based, and the path is outside ezp root, and the path has less than 2 elements
         if ($absPath && (!$purge || !isset($cacheEntry['purge-function'])) && !isset($cacheEntry['function']) && $absPathElementCount < 3 && strpos(dirname($absPath) . DIRECTORY_SEPARATOR, realpath(eZSys::rootDir()) . DIRECTORY_SEPARATOR) === false) {
             $warnPaths[] = $absPath;
         }
     }
     if (!empty($warnPaths)) {
         $this->cli->warning('The following cache paths are outside of the eZ Publish root directory, and have less than 2 path elements. ' . 'Are you sure you want to ' . ($purge ? 'purge' : 'clear') . ' them?');
         foreach ($warnPaths as $warnPath) {
             $this->cli->output($warnPath);
         }
         if (function_exists("getUserInput")) {
             $input = getUserInput(($purge ? 'Purge' : 'Clear') . '? yes/no:', array('yes', 'no'));
         } else {
             $validInput = false;
             $readlineExists = function_exists("readline");
             while (!$validInput) {
                 if ($readlineExists) {
                     $input = readline($query);
                 } else {
                     echo $prompt . ' ';
                     $input = trim(fgets(STDIN));
                 }
                 if ($acceptValues === false || in_array($input, $acceptValues)) {
                     $validInput = true;
                 }
             }
         }
         if ($input === 'no') {
             $this->script->shutdown();
             exit;
         }
     }
     $firstItem = true;
     foreach ($cacheEntries as $cacheEntry) {
         if ($firstItem) {
             $firstItem = false;
         } else {
             $this->cli->output(', ', false);
         }
         $this->cli->output($this->cli->stylize('emphasize', $cacheEntry['name']), false);
         if ($purge) {
             eZCache::clearItem($cacheEntry, true, array($this, 'reportProgress'), $purgeSleep, $purgeMax, $purgeExpiry);
         } else {
             eZCache::clearItem($cacheEntry);
         }
     }
     $this->cli->output();
 }
Example #15
0
    $noAction = false;
    $tagName = $options['clear-tag'];
    $cacheEntries = eZCache::fetchByTag($tagName, $cacheList);
    if ($purge) {
        $helper->purgeItems($cacheEntries, $tagName, $purgeSleep, $purgeMax, $purgeExpiry);
    } else {
        $helper->clearItems($cacheEntries, $tagName);
    }
}
if ($options['clear-id']) {
    $noAction = false;
    $idName = $options['clear-id'];
    $missingIDList = array();
    $cacheEntries = array();
    foreach (explode(',', $idName) as $id) {
        $cacheEntry = eZCache::fetchByID($id, $cacheList);
        if ($cacheEntry) {
            $cacheEntries[] = $cacheEntry;
        } else {
            $missingIDList[] = $id;
        }
    }
    if (count($missingIDList) > 0) {
        $cli->warning('No such cache ID: ' . $cli->stylize('emphasize', implode(', ', $missingIDList)));
        $script->shutdown(1);
    }
    if ($options['clear-id']) {
        if ($purge) {
            $helper->purgeItems($cacheEntries, $idName, $purgeSleep, $purgeMax, $purgeExpiry);
        } else {
            $helper->clearItems($cacheEntries, $idName);
    function execute( $xml )
    {
        $settingsFileList = $xml->getElementsByTagName( 'SettingsFile' );
        foreach ( $settingsFileList as $settingsFile )
        {
            $fileName = $settingsFile->getAttribute( 'name' );
            $location = $settingsFile->getAttribute( 'location' );

            eZDir::mkdir( $location );
            $fileNamePath = $location . eZDir::separator( eZDir::SEPARATOR_LOCAL ) . $fileName;

            $this->writeMessage( "\tSetting settings: $fileNamePath", 'notice' );

            if ( !file_exists( $fileNamePath ) )
            {
                if ( !is_writeable( $location ) )
                {
                    $this->writeMessage( "\tFile $fileNamePath can not be created. Skipping.", 'notice' );
                    continue;
                }
            }
            else
            {
                if ( !is_readable( $fileName ) )
                {
                    $this->writeMessage( "\tFile $fileNamePath is not readable. Skipping.", 'notice' );
                    continue;
                }
                if ( !is_writeable( $fileName ) )
                {
                    $this->writeMessage( "\tFile $fileNamePath is not writeable. Skipping.", 'notice' );
                    continue;
                }
            }
            $ini = eZINI::instance( $fileName, $location, null, null, null, true, true );
            $settingsBlockList = $settingsFile->getElementsByTagName( 'SettingsBlock' );
            foreach ( $settingsBlockList as $settingsBlock )
            {
                $blockName = $settingsBlock->getAttribute( 'name' );
                $values = $settingsBlock->childNodes;
                $settingValue = false;
                foreach ( $values as $value )
                {
                    $variableName = $value->nodeName;
                    if ( $value->nodeName == "#text" )
                    {
                        continue;
                    }

                    if ( get_class($value) == 'DOMElement' && $value->hasAttribute( 'value' ) )
                    {
                        $settingValue = $value->getAttribute( 'value' );
                    }
                    elseif ( get_class($value) == 'DOMElement' && $value->hasChildNodes() )
                    {
                        if ( $value->firstChild->nodeName == $value->lastChild->nodeName && $value->childNodes->length>1 )
                        {
                            $variableName = $value->tagName;
                            $vals = $value->getElementsByTagName( 'value' );
                            $settingValue = array();
                            foreach ( $vals as $val )
                            {
                                $key = $val->getAttribute( 'key' );
                                if ( $key )
                                {
                                    $settingValue[$key] = $this->parseAndReplaceStringReferences( $val->textContent );
                                }
                                else
                                {
                                    $settingValue[] = $this->parseAndReplaceStringReferences( $val->textContent );
                                }
                            }
                        }
                        else
                        {
                            $settingValue  = $this->parseAndReplaceStringReferences( $value->nodeValue );
                       }
                    }
                    elseif ( $value->textContent )
                    {
                        $settingValue = $value->textContent;
                    }
                    else
                    {
                        $settingValue = $this->parseAndReplaceStringReferences( $value->textContent );
                    }
                    $existingVar = false;
                    if ( $ini->hasVariable( $blockName, $variableName ) )
                    {
                        $existingVar = $ini->variable( $blockName, $variableName );
                    }
                    if ( is_string( $existingVar ) && is_string( $settingValue ) )
                    {
                        $ini->setVariable( $blockName, $variableName, $settingValue );
                    }
                    elseif ( is_array( $existingVar ) && is_string( $settingValue ) )
                    {
                        $existingVar[] = $settingValue;
                        $ini->setVariable( $blockName, $variableName, $existingVar );
                    }
                    elseif ( is_array( $existingVar ) && is_array( $settingValue ) )
                    {
                        // an empty value in a list means a reset of the setting
                        if ( array_search( "", $settingValue, true ) !== false )
                            $mergedArray = $settingValue;
                        else
                            $mergedArray = array_merge( $existingVar, $settingValue );
                        $ini->setVariable( $blockName, $variableName, array_unique( $mergedArray ) );
                    }
                    else
                    {
                        $ini->setVariable( $blockName, $variableName, $settingValue );
                    }
                }
            }
            $ini->save( false, ".append.php" );
            unset( $ini );
        }
        eZCache::clearByID( array( 'ini', 'global_ini' ) );
    }
/**
 * @package nxcMasterPassword
 * @author  Serhey Dolgushev <*****@*****.**>
 * @date    22 Sep 2011
 **/
require 'autoload.php';
$cli = eZCLI::instance();
$scriptSettings = array('description' => 'Creates transaltion files', 'use-session' => false, 'use-modules' => false, 'use-extensions' => true);
$script = eZScript::instance($scriptSettings);
$script->startup();
$script->initialize();
$options = $script->getOptions('', '[password]', array('password' => 'New password'));
if (count($options['arguments']) < 1 || strlen($options['arguments'][0]) === 0) {
    $cli->error('Specify new password');
    $script->shutdown(1);
}
$ini = eZINI::instance('nxcmasterpassword.ini');
$password = $options['arguments'][0];
$password = md5(md5($password) . $ini->variable('General', 'Seed'));
$ini->setVariable('General', 'MasterPassword', $password);
$file = 'nxcmasterpassword.ini.append.php';
$path = eZExtension::baseDirectory() . '/nxc_master_password/settings';
$result = $ini->save($file, false, false, false, $path, false, true);
if ($result === false) {
    $cli->error('Cannot update "' . $path . '/' . $file . '" settings file');
    $script->shutdown(1);
}
eZCache::clearByTag('Ini');
$cli->output('Password stored');
$script->shutdown(0);
Example #18
0
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();
}
Example #19
0
<?php

/**
 *
 * @author G. Giunta
 * @copyright (C) G. Giunta 2008-2016
 * @license Licensed under GNU General Public License v2.0. See file license.txt
 *
 * @todo add more details, such as dates of first/last files
 * @todo add possibility to zoom in to file list going to cachesearch view
 * @todo add support for db-clustered configs - hard currently, since there is no recursive search in api...
 * @todo in ezdfs mode allow user to only show clustered data
 */
$cacheFilesList = array();
$cacheList = eZCache::fetchList();
foreach ($cacheList as $cacheItem) {
    if ($cacheItem['path'] != false && $cacheItem['enabled']) {
        $cacheFilesList[$cacheItem['name']] = array('path' => $cacheItem['path']);
        // take care: this is hardcoded from knowledge of cache structure...
        if ($cacheItem['path'] == 'var/cache/ini') {
            $cachedir = eZSys::siteDir() . '/' . $cacheItem['path'];
        } else {
            $cachedir = eZSys::cacheDirectory() . '/' . $cacheItem['path'];
        }
        $count = sysInfoTools::countFilesInDir($cachedir);
        $cacheFilesList[$cacheItem['name']]['count'] = $count;
        if ($count) {
            $cacheFilesList[$cacheItem['name']]['size'] = number_format(sysInfoTools::countFilesSizeInDir($cachedir));
        } else {
            $cacheFilesList[$cacheItem['name']]['size'] = "";
        }