function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
 {
     switch ($operatorName) {
         case 'ngurl':
             if (empty($namedParameters['siteaccess'])) {
                 return;
             }
             $ini = eZSiteAccess::getIni($namedParameters['siteaccess'], 'site.ini');
             $destinationLocale = $ini->variable('RegionalSettings', 'ContentObjectLocale');
             $siteLanguageList = $ini->variable('RegionalSettings', 'SiteLanguageList');
             $nodeID = eZURLAliasML::fetchNodeIDByPath($operatorValue);
             $destinationElement = eZURLAliasML::fetchByAction('eznode', $nodeID, $destinationLocale, false);
             if (empty($destinationElement) || !isset($destinationElement[0]) && !$destinationElement[0] instanceof eZURLAliasML) {
                 if ($this->isModuleUrl($operatorValue) || $this->isCurrentLocaleAvailable($siteLanguageList)) {
                     $destinationUrl = $operatorValue;
                 } else {
                     $destinationUrl = '';
                 }
             } else {
                 $destinationUrl = $destinationElement[0]->getPath($destinationLocale, $siteLanguageList);
             }
             $siteaccessUrlMapping = eZINI::instance('nglanguageswitcher.ini')->variable('LanguageSwitcher', 'SiteAccessUrlMapping');
             $destinationUrl = eZURI::encodeURL($destinationUrl);
             $operatorValue = rtrim($siteaccessUrlMapping[$namedParameters['siteaccess']], '/') . '/' . ltrim($destinationUrl, '/');
             break;
     }
 }
 /**
  * Get instance siteaccess specific site.ini
  *
  * @param string $sa
  * @return void
  */
 protected function getSiteAccessIni()
 {
     if ($this->destinationSiteAccessIni === null) {
         $this->destinationSiteAccessIni = eZSiteAccess::getIni($this->destinationSiteAccess, 'site.ini');
     }
     return $this->destinationSiteAccessIni;
 }
Exemplo n.º 3
0
 /**
  * Test that global siteaccess is untouched when asking for a specific siteaccess settings
  * & reading settings from plain siteaccess
  */
 public function testGetINI()
 {
     $current = eZSiteAccess::current();
     $ini = eZSiteAccess::getIni('plain');
     self::assertEquals($current, eZSiteAccess::current());
     // this is not totally correct way of testing, but one way of making "sure" we got correct sa
     self::assertEquals('plain', $ini->variable('DesignSettings', 'SiteDesign'));
 }
Exemplo n.º 4
0
 public function getSettings()
 {
     // Copied from settings/view
     $rootDir = 'settings';
     $iniFiles = eZDir::recursiveFindRelative($rootDir, '', '.ini');
     // find all .ini files in active extensions
     // Note: is this the same algorithm used by ezini? mmm...
     foreach (eZINI::globalOverrideDirs() as $iniDataSet) {
         $iniPath = $iniDataSet[1] ? $iniDataSet[0] : 'settings/' . $iniDataSet[0];
         $iniFiles = array_merge($iniFiles, eZDir::recursiveFindRelative($iniPath, '', '.ini'));
         $iniFiles = array_merge($iniFiles, eZDir::recursiveFindRelative($iniPath, '', '.ini.append.php'));
     }
     // extract all .ini files without path
     $iniFiles = preg_replace('%.*/%', '', $iniFiles);
     // remove *.ini[.append.php] from file name
     $iniFiles = preg_replace('%\\.ini.*%', '.ini', $iniFiles);
     $iniFiles = array_unique($iniFiles);
     sort($iniFiles);
     $siteIni = null;
     foreach ($iniFiles as $key => $ini) {
         if ($this->currentSiteAccess != '' && $GLOBALS['eZCurrentAccess']['name'] !== $this->currentSiteAccess) {
             // create a site ini instance using $useLocalOverrides
             if ($siteIni === null) {
                 $siteIni = eZSiteAccess::getIni($this->currentSiteAccess, 'site.ini');
             }
             // load settings file with $useLocalOverrides = true
             $iniFile = new eZINI($ini, 'settings', null, false, true, false, false, false);
             $iniFile->setOverrideDirs($siteIni->overrideDirs(false));
             $iniFile->load();
         } else {
             $iniFile = new eZINI($ini);
         }
         $iniFiles[$ini] = $iniFile->groups();
         unset($iniFiles[$key]);
     }
     return $iniFiles;
 }
Exemplo n.º 5
0
            $valueArray[] = "[{$param}]={$key}";
        } else {
            $valueArray[] = "={$key}";
        }
    }
    $value = implode($separator, $valueArray);
    return $value;
}
function getVariable($block, $settingName, $iniFile, $path)
{
    $ini = new eZINI($iniFile, $path, null, null, null, true, true);
    $result = $ini->hasVariable($block, $settingName) ? $ini->variable($block, $settingName) : false;
    $result = parseArrayToStr($result, '<br>');
    return $result;
}
$ini = eZSiteAccess::getIni($siteAccess, $iniFile);
$value = $settingName != '' ? $ini->variable($block, $settingName) : '';
// Do modifications to the value before it's sent to the template
if (is_array($value) || $value and !isset($settingType)) {
    $settingType = $ini->settingType($value);
    if ($settingType == 'array') {
        $value = parseArrayToStr($value, "\n");
    }
}
// Init value from ini (default\override\extensions\siteaccess)
$values = array();
$values['default'] = getVariable($block, $settingName, $iniFile, 'settings/');
$values['siteaccess'] = getVariable($block, $settingName, $iniFile, "settings/siteaccess/{$siteAccess}");
$values['override'] = getVariable($block, $settingName, $iniFile, "settings/override/");
// Get values from extensions
$ini = eZINI::instance();
Exemplo n.º 6
0
            // if eZINI::instance() is called twice instance will be fetched from GLOBAL variable.
            // Without reference there will be a inconsistency with GLOBAL instance and stored ini file.
            $iniTemp = eZINI::create( $settingFile . '.append.php', $path, null, null, null );
            $iniTemp->removeSetting( $block, $setting );
            $iniTemp->save();
        }
    }
}

if ( $http->hasPostVariable( 'ChangeINIFile' ) or
     ( $Params['SiteAccess'] and $Params['INIFile'] ) )
{
    if ( $GLOBALS['eZCurrentAccess']['name'] !== $currentSiteAccess )
    {
        // create a site ini instance using $useLocalOverrides
        $siteIni = eZSiteAccess::getIni( $currentSiteAccess, 'site.ini' );

        // load settings file with $useLocalOverrides = true & $addArrayDefinition = true
        $ini = new eZINI( /*$fileName =*/ $settingFile,
                          /*$rootDir =*/ 'settings',
                          /*$useTextCodec =*/ null,
                          /*$useCache =*/ false,
                          /*$useLocalOverrides =*/ true,
                          /*$directAccess =*/ false,
                          /*$addArrayDefinition =*/ true,
                          /*$load =*/ false );
        $ini->setOverrideDirs( $siteIni->overrideDirs( false ) );
        $ini->load();
    }
    else
    {
 /**
  * Get an array of all the current templates and overrides for them.
  * The current siteaccess is used if none is specified.
  *
  * @static
  * @return array
  */
 static function overrideArray($siteAccess = false)
 {
     if ($siteAccess === false and self::$overrideArrayCache !== null) {
         return self::$overrideArrayCache;
     }
     $bases = eZTemplateDesignResource::allDesignBases($siteAccess);
     // fetch the override array from a specific siteacces
     if ($siteAccess) {
         $overrideINI = eZSiteAccess::getIni($siteAccess, 'override.ini');
     } else {
         $overrideINI = eZINI::instance('override.ini');
     }
     $designStartPath = eZTemplateDesignResource::designStartPath();
     // Generate match cache for all templates
     // Build arrays of available files, start with standard design and end with most prefered design
     $matchFileArray = array();
     $reverseBases = array_reverse($bases);
     foreach ($reverseBases as $base) {
         $templateResource = $base . '/templates';
         $sourceFileArray = eZDir::recursiveFindRelative($templateResource, "", "tpl");
         foreach ($sourceFileArray as $source) {
             $matchFileArray[$source]['base_dir'] = $templateResource;
             $matchFileArray[$source]['template'] = $source;
         }
     }
     // Load override templates
     $overrideSettingGroups = $overrideINI->groups();
     if (isset($GLOBALS['eZDesignOverrides'])) {
         $overrideSettingGroups = array_merge($overrideSettingGroups, $GLOBALS['eZDesignOverrides']);
     }
     foreach ($overrideSettingGroups as $overrideName => $overrideSetting) {
         if (!isset($overrideSetting['Source'])) {
             continue;
         }
         $overrideSource = "/" . $overrideSetting['Source'];
         $overrideMatchFile = $overrideSetting['MatchFile'];
         // Find the matching file in the available resources
         $triedFiles = array();
         $fileInfo = eZTemplateDesignResource::fileMatch($bases, 'override/templates', $overrideMatchFile, $triedFiles);
         $resourceInUse = is_array($fileInfo) ? $fileInfo['resource'] : false;
         $overrideMatchFilePath = is_array($fileInfo) ? $fileInfo['path'] : false;
         // if the override template is not found
         // then we probably shouldn't use it
         // there should be added a check around the following code
         // if ( $overrideMatchFilePath )
         // {
         $customMatchArray = array();
         $customMatchArray['conditions'] = isset($overrideSetting['Match']) ? $overrideSetting['Match'] : null;
         $customMatchArray['match_file'] = $overrideMatchFilePath;
         $customMatchArray['override_name'] = $overrideName;
         $matchFileArray[$overrideSource]['custom_match'][] = $customMatchArray;
         // }
         // if overriding a non-existing template
         // then we use the override template as main template
         // this code should probably be removed
         // because we should not allow an override if the main template is missing
         if ($resourceInUse && !isset($matchFileArray[$overrideSource]['base_dir'])) {
             $matchFileArray[$overrideSource]['base_dir'] = $resourceInUse;
             $matchFileArray[$overrideSource]['template'] = $overrideSource;
         }
         if (!$overrideMatchFilePath) {
             eZDebug::writeError("Custom match file: path '{$overrideMatchFile}' not found in any resource. Check the template settings in settings/override.ini", __METHOD__);
             eZDebug::writeError(implode(', ', $triedFiles), __METHOD__ . ' tried files');
         }
     }
     if ($siteAccess === false) {
         self::$overrideArrayCache = $matchFileArray;
     }
     return $matchFileArray;
 }
Exemplo n.º 8
0
            $Module->redirectToView('view', array('full', $node->attribute('parent_node_id')));
        } else {
            $Module->redirectToView('view', array('sitemap', 2));
        }
    }
    return;
}
$contentObject->setAttribute('current_version', $EditVersion);
$ini = eZINI::instance();
$siteaccess = false;
if ($Module->hasActionParameter('SiteAccess')) {
    $siteaccess = $Module->actionParameter('SiteAccess');
}
// Find ContentObjectLocale for all site accesses in RelatedSiteAccessList
foreach ($ini->variable('SiteAccessSettings', 'RelatedSiteAccessList') as $relatedSA) {
    $relatedSALocale = eZSiteAccess::getIni($relatedSA, 'site.ini')->variable('RegionalSettings', 'ContentObjectLocale');
    $siteaccessLocaleMap[$relatedSA] = $relatedSALocale;
    if (!$siteaccess && $LanguageCode && $LanguageCode === $relatedSALocale) {
        $siteaccess = $relatedSA;
    }
}
if (!$siteaccess) {
    $siteaccess = $ini->variable('SiteSettings', 'DefaultAccess');
}
// Try to find a version that has the language we want, by going backwards in the version history
// Also, gether unique list of translations in all versions up until this one
$foundTranslationList = array();
$viewVersion = $EditVersion;
$viewVersionObject = false;
foreach (array_reverse($contentObject->versions(false)) as $versionHash) {
    $viewVersion = $versionHash['version'];
Exemplo n.º 9
0
 /**
  * Creates an array of corresponding language switcher links and logical names.
  *
  * This mapping is set up in site.ini.[RegionalSettings].TranslationSA.
  * The purpose of this method is to assist creation of language switcher
  * links into the available translation siteaccesses on the system.
  *
  * This is used by the language_switcher template operator.
  *
  * @param string $url
  * @return void
  */
 public static function setupTranslationSAList($url = null)
 {
     $ini = eZINI::instance();
     if (!$ini->hasVariable('RegionalSettings', 'TranslationSA')) {
         return array();
     }
     $ret = array();
     $translationSiteAccesses = $ini->variable('RegionalSettings', 'TranslationSA');
     foreach ($translationSiteAccesses as $siteAccessName => $translationName) {
         $switchLanguageLink = "/switchlanguage/to/{$siteAccessName}/";
         if ($url !== null && (is_string($url) || is_numeric($url))) {
             $switchLanguageLink .= $url;
         }
         $ret[$siteAccessName] = array('url' => $switchLanguageLink, 'text' => $translationName, 'locale' => eZSiteAccess::getIni($siteAccessName)->variable('RegionalSettings', 'ContentObjectLocale'));
     }
     return $ret;
 }
Exemplo n.º 10
0
 /**
  * A helper method used to create directory parts array
  *
  * @param string $dir
  * @param string $siteAccess
  * @return array
  */
 private function buildCacheDirPart( $dir, $siteAccess )
 {
     return array( 'dir' => $dir,
                   'access_name' => $siteAccess,
                   'site_url' => eZSiteAccess::getIni( $siteAccess, 'site.ini' )->variable( 'SiteSettings', 'SiteURL' ) );
 }
Exemplo n.º 11
0
 /**
  * Returns a siteaccess list where the content object can be viewed. This
  * list is based on the locale settings and/or on the always available
  * flag of the content object.
  *
  * @param mixed $locale
  * @param eZContentObject $object
  * @return array( siteaccessName1 => siteaccessName1, ... )
  */
 protected static function getSiteaccessList($locale, eZContentObject $object)
 {
     $ini = eZINI::instance('site.ini');
     $availableSA = $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList');
     if ($object->attribute('always_available')) {
         return $availableSA;
     }
     $result = array();
     foreach ($availableSA as $sa) {
         $saINI = eZSiteAccess::getIni($sa, 'site.ini');
         if ($locale === $saINI->variable('RegionalSettings', 'ContentObjectLocale') || in_array($locale, $saINI->variable('RegionalSettings', 'SiteLanguageList')) || $saINI->variable('RegionalSettings', 'ShowUntranslatedObjects') === 'enabled') {
             $result[$sa] = $sa;
         }
     }
     return $result;
 }
Exemplo n.º 12
0
 function readImageAliasesFromOverrideINI($siteAccess = false, $iniFile = false)
 {
     if (!$iniFile) {
         $iniFile = 'image.ini';
     }
     $ini = eZSiteAccess::getIni($siteAccess, $iniFile . '.append.php');
     $ini = eZINI::instance($iniFile, 'settings/siteaccess/' . $siteAccess, null, null, null, true);
     // print_r($ini->variable( 'AliasSettings', 'AliasList' ) );
     if (!$ini) {
         return false;
     }
     $aliasNames = $ini->variable('AliasSettings', 'AliasList');
     foreach ($aliasNames as $aliasName) {
         $alias = $this->createAliasFromOverrideINI($siteAccess, $iniFile, $aliasName);
         if ($alias) {
             $this->appendImageAlias($alias);
         } else {
             eZDebug::writeWarning("Failed reading Image Alias {$aliasName} from {$iniFile}", __METHOD__);
         }
     }
     $aliasName = 'original';
     if (!in_array($aliasName, $aliasNames)) {
         $ini = eZINI::instance('image.ini');
         if ($ini->hasGroup($aliasName)) {
             $alias = $this->createAliasFromOverrideINI($siteAccess, $iniFile, $aliasName);
             if ($alias) {
                 $alias['reference'] = false;
                 $this->appendImageAlias($alias);
             } else {
                 eZDebug::writeWarning("Failed reading Image Alias {$aliasName} from {$iniFile}", __METHOD__);
             }
         }
     }
 }
 /**
  * Returns a siteaccess list where the content object can be viewed. This
  * list is based on the locale settings and/or on the always available
  * flag of the content object.
  *
  * @param mixed $locale
  * @param eZContentObject $object
  * @return array( siteaccessName1 => siteaccessName1, ... )
  */
 protected static function getSiteaccessList($locale, eZContentObject $object)
 {
     $ini = eZINI::instance('site.ini');
     $availableSA = array_unique($ini->variable('SiteAccessSettings', 'RelatedSiteAccessList'));
     $alwaysAvailable = $object->attribute('always_available');
     $dedicatedSA = array();
     $canShowSA = array();
     $showAllSA = array();
     foreach ($availableSA as $sa) {
         $saINI = eZSiteAccess::getIni($sa, 'site.ini');
         $saLanguagesList = $saINI->variable('RegionalSettings', 'SiteLanguageList');
         if ($locale === $saINI->variable('RegionalSettings', 'ContentObjectLocale') || is_array($saLanguagesList) && $saLanguagesList[0] === $locale) {
             $dedicatedSA[$sa] = $sa;
         } else {
             if (in_array($locale, $saINI->variable('RegionalSettings', 'SiteLanguageList'))) {
                 $canShowSA[$sa] = $sa;
             } else {
                 if ($saINI->variable('RegionalSettings', 'ShowUntranslatedObjects') === 'enabled' || $alwaysAvailable) {
                     $showAllSA[$sa] = $sa;
                 }
             }
         }
     }
     return $dedicatedSA + $canShowSA + $showAllSA;
 }