/**
* Reloads extensions and changes siteaccess globally
* If you only want changes on a instance of ini, use {@link eZSiteAccess::getIni()}
*
* - clears all in-memory caches used by the INI system
* - re-builds the list of paths where INI files are searched for
* - runs {@link eZSiteAccess::change()}
* - re-searches module paths {@link eZModule::setGlobalPathList()}
*
* @since 4.4
* @param array $access An associative array with 'name' (string), 'type' (int) and 'uri_part' (array).
* See {@link eZSiteAccess::match()} for array structure definition
* @param eZINI|null $siteINI Optional parameter to be able to only do change on specific instance of site.ini
* If set, then global siteacceess will not be changed as well.
* @return array The $access parameter
*/
static function load( array $access, eZINI $siteINI = null )
{
$currentSiteAccess = $GLOBALS['eZCurrentAccess'];
unset( $GLOBALS['eZCurrentAccess'] );
// Clear all ini override dirs
if ( $siteINI instanceof eZINI )
{
$siteINI->resetOverrideDirs();
}
else
{
eZINI::resetAllInstances();
eZExtension::clearActiveExtensionsMemoryCache();
eZTemplateDesignResource::clearInMemoryCache();
}
// Reload extensions, siteaccess and access extensions
eZExtension::activateExtensions( 'default', $siteINI );
$access = self::change( $access, $siteINI );
eZExtension::activateExtensions( 'access', $siteINI );
// Restore current (old) siteacces if changes where only to be applied to locale instance of site.ini
if ( $siteINI instanceof eZINI )
{
$GLOBALS['eZCurrentAccess'] = $currentSiteAccess;
}
else
{
$moduleRepositories = eZModule::activeModuleRepositories();
eZModule::setGlobalPathList( $moduleRepositories );
}
return $access;
}
include_once "kernel/setup/ezsetuptests.php";
include_once 'kernel/setup/ezsetup_summary.php';
// Initialize template
$tpl = eZTemplate::instance();
//$tpl->registerFunction( "section", new eZTemplateSectionFunction( "section" ) );
//$tpl->registerFunction( "include", new eZTemplateIncludeFunction() );
$ini = eZINI::instance();
if ($ini->variable('TemplateSettings', 'Debug') == 'enabled') {
eZTemplate::setIsDebugEnabled(true);
}
//eZDebug::setLogOnly( true );
//$ini->setVariable( 'RegionalSettings', 'TextTranslation', 'disabled' );
$Module = $Params['Module'];
$tpl->setAutoloadPathList($ini->variable('TemplateSettings', 'AutoloadPathList'));
$tpl->autoload();
$tpl->registerResource(eZTemplateDesignResource::instance());
// Initialize HTTP variables
$http = eZHTTPTool::instance();
$baseDir = 'kernel/setup/';
// Load step list data. See this file for install step references.
$stepDataFile = $baseDir . "steps/ezstep_data.php";
$stepData = null;
if (file_exists($stepDataFile)) {
include_once $stepDataFile;
$stepData = new eZStepData();
}
if ($stepData == null) {
print "<h1>Setup step data file not found. Setup is exiting...</h1>";
//TODO : i18n translate
eZDisplayResult($templateResult);
eZExecution::cleanExit();
开发者ID:legende91,项目名称:ez,代码行数:31,代码来源:ezsetup.php
示例9: load
/**
* Reloads extensions and changes siteaccess globally
* If you only want changes on a instance of ini, use {@link eZSiteAccess::getIni()}
*
* - clears all in-memory caches used by the INI system
* - re-builds the list of paths where INI files are searched for
* - runs {@link eZSiteAccess::change()}
* - re-searches module paths {@link eZModule::setGlobalPathList()}
*
* @since 4.4
* @param array $access An associative array with 'name' (string), 'type' (int) and 'uri_part' (array).
* See {@link eZSiteAccess::match()} for array structure definition
* @param eZINI|null $siteINI Optional parameter to be able to only do change on specific instance of site.ini
* If set, then global siteacceess will not be changed as well.
* @return array The $access parameter
*/
static function load( array $access, eZINI $siteINI = null )
{
$currentSiteAccess = $GLOBALS['eZCurrentAccess'];
unset( $GLOBALS['eZCurrentAccess'] );
// Clear all ini override dirs
if ( $siteINI instanceof eZINI )
{
$siteINI->resetOverrideDirs();
}
else
{
eZINI::resetAllInstances();
eZExtension::clearActiveExtensionsMemoryCache();
eZTemplateDesignResource::clearInMemoryCache();
}
// Reload extensions, siteaccess and access extensions
eZExtension::activateExtensions( 'default', $siteINI );
$access = self::change( $access, $siteINI );
eZExtension::activateExtensions( 'access', $siteINI );
// Reload Extenion ordering to reorder eZINI Global Override Dirs.
// @TODO : Améliorer la gestion globale (éviter des appels multiples !!!)
if ( $siteINI instanceof eZINI && $siteINI->variable( 'ExtensionSettings', 'ExtensionOrdering' ) === 'enabled' )
{
eZINI::removeGlobalOverrideDirsByScope( 'sa-extension' );
eZINI::removeGlobalOverrideDirsByScope( 'extension' );
eZExtension::activateExtensions( false );
}
// Restore current (old) siteacces if changes where only to be applied to locale instance of site.ini
if ( $siteINI instanceof eZINI )
{
$GLOBALS['eZCurrentAccess'] = $currentSiteAccess;
}
else
{
$moduleRepositories = eZModule::activeModuleRepositories();
eZModule::setGlobalPathList( $moduleRepositories );
}
return $access;
}
/**
* Merges a collection of files togheter and returns array of paths to the files.
* js /css content is returned as string if packlevel is 0 and you use a js/ css generator.
* $fileArray can also be array of array of files, like array( 'file.js', 'file2.js', array( 'file5.js' ) )
* The name of the cached file is a md5 hash consistant of the file paths
* of the valid files in $file_array and the packlevel.
* The whole argument is used instead of file path on js/ css generators in the cache hash.
*
* @param array|string $fileArray Either array of file paths, or string with file path
* @param string $subPath In witch sub path of design folder to look for files.
* @param string $fileExtension File extension name (for use on cache file)
* @param int $packLevel Level of packing, values: 0-3
* @param bool $indexDirInCacheHash To add index path in cache hash or not
* @param string $filePostName Extra file name part, example "_screen" in case of medai use for css
*
* @return array List of css files
*/
static function packFiles($fileArray, $subPath = '', $fileExtension = '.js', $packLevel = 2, $indexDirInCacheHash = false, $filePostName = '')
{
if (!$fileArray) {
return array();
} else {
if (!is_array($fileArray)) {
$fileArray = array($fileArray);
}
}
$ezjscINI = eZINI::instance('ezjscore.ini');
$bases = eZTemplateDesignResource::allDesignBases();
$customHosts = $ezjscINI->variable('Packer', 'CustomHosts');
$data = array('http' => array(), 'www' => array(), 'locale' => array(), 'cache_name' => '', 'cache_hash' => '', 'cache_path' => '', 'last_modified' => 0, 'file_extension' => $fileExtension, 'file_post_name' => $filePostName, 'pack_level' => $packLevel, 'sub_path' => $subPath, 'cache_dir' => self::getCacheDir(), 'www_dir' => htmlspecialchars(self::getWwwDir(), ENT_COMPAT, 'UTF-8'), 'index_dir' => self::getIndexDir(), 'custom_host' => isset($customHosts[$fileExtension]) ? $customHosts[$fileExtension] : '');
// Only pack files if Packer is enabled and if not set DevelopmentMode is disabled
if ($ezjscINI->hasVariable('eZJSCore', 'Packer')) {
$packerIniValue = $ezjscINI->variable('eZJSCore', 'Packer');
if ($packerIniValue === 'disabled') {
$data['pack_level'] = 0;
} else {
if (is_numeric($packerIniValue)) {
$data['pack_level'] = (int) $packerIniValue;
}
}
} else {
if (eZINI::instance()->variable('TemplateSettings', 'DevelopmentMode') === 'enabled') {
$data['pack_level'] = 0;
}
}
// Needed for image includes to work on ezp installs with mixed access methods (virtualhost + url based setup)
if ($indexDirInCacheHash) {
$data['cache_name'] = $data['index_dir'];
}
$originalFileArray = $fileArray;
while (!empty($fileArray)) {
$file = array_shift($fileArray);
// if $file is array, concat it to the file array and continue
if ($file && is_array($file)) {
$fileArray = array_merge($file, $fileArray);
continue;
} else {
if (!$file) {
continue;
} else {
if (strpos($file, '::') !== false) {
$server = self::serverCallHelper(explode('::', $file));
if (!$server instanceof ezjscServerRouter) {
continue;
}
$fileTime = $server->getCacheTime($data);
// Generate content straight away if packing is disabled
if ($data['pack_level'] === 0) {
$data['www'][] = $server->call($fileArray);
} else {
if ($fileTime === -1) {
$data['http'][] = $server->call($fileArray);
} else {
$data['locale'][] = $server;
$data['cache_name'] .= $file . '_';
}
}
$data['last_modified'] = max($data['last_modified'], $fileTime);
continue;
} else {
if (strpos($file, 'http://') === 0 || strpos($file, 'https://') === 0) {
$data['http'][] = $file;
continue;
} else {
if (strpos($file, '://') === 0) {
if (!isset($protocol)) {
$protocol = eZSys::serverProtocol();
}
$data['http'][] = $protocol . $file;
continue;
} else {
if (strpos($file, 'var/') === 0) {
if (substr($file, 0, 2) === '//' || preg_match("#^[a-zA-Z0-9]+:#", $file)) {
$file = '/';
} else {
if (strlen($file) > 0 && $file[0] !== '/') {
$file = '/' . $file;
}
}
eZURI::transformURI($file, true, 'relative');
//.........这里部分代码省略.........
/**
* Merges a collection of files togheter and returns array of paths to the files.
* js /css content is returned as string if packlevel is 0 and you use a js/ css generator.
* $fileArray can also be array of array of files, like array( 'file.js', 'file2.js', array( 'file5.js' ) )
* The name of the cached file is a md5 hash consistant of the file paths
* of the valid files in $file_array and the packlevel.
* The whole argument is used instead of file path on js/ css generators in the cache hash.
*
* @param array|string $fileArray Either array of file paths, or string with file path
* @param string $subPath In witch sub path of design folder to look for files.
* @param string $fileExtension File extension name (for use on cache file)
* @param int $packLevel Level of packing, values: 0-3
* @param bool $wwwInCacheHash To add www path in cahce hash or not
* @return array List of css files
*/
static function packFiles($fileArray, $subPath = '', $fileExtension = '.js', $packLevel = 2, $wwwInCacheHash = false)
{
if (!$fileArray) {
return array();
} else {
if (!is_array($fileArray)) {
$fileArray = array($fileArray);
}
}
$cacheName = '';
$lastmodified = 0;
$httpFiles = array();
$validFiles = array();
$validWWWFiles = array();
$bases = eZTemplateDesignResource::allDesignBases();
// Only pack files if Packer is enabled and if not set DevelopmentMode is disabled
$ezjscINI = eZINI::instance('ezjscore.ini');
if ($ezjscINI->hasVariable('eZJSCore', 'Packer')) {
$packerIniValue = $ezjscINI->variable('eZJSCore', 'Packer');
if ($packerIniValue === 'disabled') {
$packLevel = 0;
} else {
if (is_numeric($packerIniValue)) {
$packLevel = (int) $packerIniValue;
}
}
} else {
$ini = eZINI::instance();
if ($ini->variable('TemplateSettings', 'DevelopmentMode') === 'enabled') {
$packLevel = 0;
}
}
$packerInfo = array('file_extension' => $fileExtension, 'pack_level' => $packLevel, 'sub_path' => $subPath, 'cache_dir' => self::getCacheDir(), 'www_dir' => self::getWwwDir());
// needed for image includes to work on ezp installs with mixed access methods (virtualhost + url based setup)
if ($wwwInCacheHash) {
$cacheName = $packerInfo['www_dir'];
}
while (count($fileArray) > 0) {
$file = array_shift($fileArray);
// if $file is array, concat it to the file array and continue
if ($file && is_array($file)) {
$fileArray = array_merge($file, $fileArray);
continue;
} else {
if (!$file) {
continue;
} else {
if (strpos($file, '::') !== false) {
$server = self::serverCallHelper(explode('::', $file));
$fileTime = $server->getCacheTime($packerInfo);
// generate content straight away if packing is disabled
if ($packLevel === 0) {
$validWWWFiles[] = $server->call($fileArray);
} else {
if ($fileTime === -1) {
$validFiles[] = $server->call($fileArray);
} else {
$validFiles[] = $server;
$cacheName .= $file . '_';
}
}
$lastmodified = max($lastmodified, $fileTime);
continue;
} else {
if (strpos($file, 'http://') === 0 || strpos($file, 'https://') === 0) {
$httpFiles[] = $file;
continue;
} else {
if (strpos($file, 'var/') === 0) {
if (substr($file, 0, 2) === '//' || preg_match("#^[a-zA-Z0-9]+:#", $file)) {
$file = '/';
} else {
if (strlen($file) > 0 && $file[0] !== '/') {
$file = '/' . $file;
}
}
eZURI::transformURI($file, true, 'relative');
// get file time and continue if it return false
$file = str_replace('//' . $packerInfo['www_dir'], '', '//' . $file);
$fileTime = file_exists($file) ? filemtime($file) : false;
$wwwFile = $packerInfo['www_dir'] . $file;
} else {
// allow path to be outside subpath if it starts with '/'
if ($file[0] === '/') {
$file = ltrim($file, '/');
//.........这里部分代码省略.........
请发表评论