function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters) { switch ($operatorName) { case $this->ININameHasVariable: case $this->ININame: if (count($operatorParameters) > 0) { $iniGroup = $tpl->elementValue($operatorParameters[0], $rootNamespace, $currentNamespace); if (count($operatorParameters) == 1) { $tpl->error($operatorName, "Missing variable name parameter"); return; } $iniVariable = $tpl->elementValue($operatorParameters[1], $rootNamespace, $currentNamespace); $iniName = isset($operatorParameters[2]) ? $tpl->elementValue($operatorParameters[2], $rootNamespace, $currentNamespace) : false; $iniPath = isset($operatorParameters[3]) ? $tpl->elementValue($operatorParameters[3], $rootNamespace, $currentNamespace) : false; // If we should check for existence of variable. // You can use like: // ezini( <BlockName>, <SettingName>, <FileName>, <IniPath>, _use under template compiling mode_ , <Should We Check for existence: 'hasVariable' or true()> ) // ezini_hasvariable( <BlockName>, <SettingName>, <FileName>, <IniPath>... ) if ($operatorName == $this->ININameHasVariable) { $checkExistence = true; } else { $checkExistence = isset($operatorParameters[5]) ? ($tpl->elementValue($operatorParameters[5], $rootNamespace, $currentNamespace) === true or $tpl->elementValue($operatorParameters[5], $rootNamespace, $currentNamespace) == 'hasVariable') ? true : false : false; } if ($iniPath !== false) { $ini = eZINI::instance($iniName, $iniPath, null, null, null, true); } elseif ($iniName !== false) { $ini = eZINI::instance($iniName); } else { $ini = eZINI::instance(); } if ($ini->hasVariable($iniGroup, $iniVariable)) { $operatorValue = !$checkExistence ? $ini->variable($iniGroup, $iniVariable) : true; } else { if ($checkExistence) { $operatorValue = false; return; } if ($iniPath !== false) { // Return empty string instead of displaying error when using 'path' parameter // and DirectAccess mode for ezini. $operatorValue = ''; } else { if ($iniName === false) { $iniName = 'site.ini'; } $tpl->error($operatorName, "!!!No such variable '{$iniVariable}' in group '{$iniGroup}' for {$iniName}"); } } return; } else { $tpl->error($operatorName, "Missing group name parameter"); } break; case $this->HTTPNameHasVariable: case $this->HTTPName: $http = eZHTTPTool::instance(); if (count($operatorParameters) > 0) { $httpType = eZURLOperator::HTTP_OPERATOR_TYPE_POST; $httpName = $tpl->elementValue($operatorParameters[0], $rootNamespace, $currentNamespace); if (count($operatorParameters) > 1) { $httpTypeName = strtolower($tpl->elementValue($operatorParameters[1], $rootNamespace, $currentNamespace)); if ($httpTypeName == 'post') { $httpType = eZURLOperator::HTTP_OPERATOR_TYPE_POST; } else { if ($httpTypeName == 'get') { $httpType = eZURLOperator::HTTP_OPERATOR_TYPE_GET; } else { if ($httpTypeName == 'session') { $httpType = eZURLOperator::HTTP_OPERATOR_TYPE_SESSION; } else { if ($httpTypeName == 'cookie') { $httpType = eZURLOperator::HTTP_OPERATOR_TYPE_COOKIE; } else { $tpl->warning($operatorName, "Unknown http type '{$httpTypeName}'"); } } } } } // If we should check for existence of http variable // You can use like: // ezhttp( <Variable>, <Method: post, get, session>, <Should We Check for existence: 'hasVariable' or true()> ) // ezhttp_hasvariable( <Variable>, <Method> ) if ($operatorName == $this->HTTPNameHasVariable) { $checkExistence = true; } else { $checkExistence = isset($operatorParameters[2]) ? ($tpl->elementValue($operatorParameters[2], $rootNamespace, $currentNamespace) === true or $tpl->elementValue($operatorParameters[2], $rootNamespace, $currentNamespace) == 'hasVariable') ? true : false : false; } switch ($httpType) { case eZURLOperator::HTTP_OPERATOR_TYPE_POST: if ($http->hasPostVariable($httpName)) { $operatorValue = !$checkExistence ? $http->postVariable($httpName) : true; } else { // If only check for existence - return false if ($checkExistence) { $operatorValue = false; return; } $tpl->error($operatorName, "Unknown post variable '{$httpName}'"); } break; case eZURLOperator::HTTP_OPERATOR_TYPE_GET: if ($http->hasGetVariable($httpName)) { $operatorValue = !$checkExistence ? $http->getVariable($httpName) : true; } else { if ($checkExistence) { $operatorValue = false; return; } $tpl->error($operatorName, "Unknown get variable '{$httpName}'"); } break; case eZURLOperator::HTTP_OPERATOR_TYPE_SESSION: if ($http->hasSessionVariable($httpName)) { $operatorValue = !$checkExistence ? $http->sessionVariable($httpName) : true; } else { if ($checkExistence) { $operatorValue = false; return; } $tpl->error($operatorName, "Unknown session variable '{$httpName}'"); } break; case eZURLOperator::HTTP_OPERATOR_TYPE_COOKIE: if (array_key_exists($httpName, $_COOKIE)) { $operatorValue = !$checkExistence ? $_COOKIE[$httpName] : true; } else { if ($checkExistence) { $operatorValue = false; return; } $tpl->error($operatorName, "Unknown cookie variable '{$httpName}'"); } break; } } else { $operatorValue = $http; } return; break; case $this->URLName: eZURI::transformURI($operatorValue, false, $namedParameters['server_url']); break; case $this->URLRootName: if (preg_match("#^[a-zA-Z0-9]+:#", $operatorValue) or substr($operatorValue, 0, 2) == '//') { break; } if (strlen($operatorValue) > 0 and $operatorValue[0] != '/') { $operatorValue = '/' . $operatorValue; } // Same as "ezurl" without "index.php" and the siteaccess name in the returned address. eZURI::transformURI($operatorValue, true, $namedParameters['server_url']); break; case $this->SysName: if (count($operatorParameters) == 0) { $tpl->warning('eZURLOperator' . $operatorName, 'Requires attributename'); } else { $sysAttribute = $tpl->elementValue($operatorParameters[0], $rootNamespace, $currentNamespace); if (!$this->Sys->hasAttribute($sysAttribute)) { $tpl->warning('eZURLOperator' . $operatorName, "No such attribute '{$sysAttribute}' for eZSys"); } else { $operatorValue = $this->Sys->attribute($sysAttribute); } } return; break; case $this->ImageName: if (count($operatorParameters) == 2 && $tpl->elementValue($operatorParameters[1], $rootNamespace, $currentNamespace) == true && strlen($this->Sys->wwwDir()) == 0) { $skipSlash = true; } else { $skipSlash = false; } $operatorValue = $this->eZImage($tpl, $operatorValue, $operatorName, $skipSlash); break; case $this->ExtName: $urlMD5 = md5($operatorValue); $url = eZURL::urlByMD5($urlMD5); if ($url === false) { eZURL::registerURL($operatorValue); } else { $operatorValue = $url; } break; case $this->DesignName: $operatorValue = $this->eZDesign($tpl, $operatorValue, $operatorName); break; } $quote = "\""; $val = $namedParameters['quote_val']; if ($val == 'single') { $quote = "'"; } else { if ($val == 'no') { $quote = false; } } $http = eZHTTPTool::instance(); if (isset($http->UseFullUrl) and $http->UseFullUrl and strncasecmp($operatorValue, '/', 1) === 0) { $operatorValue = $http->createRedirectUrl($operatorValue, array('pre_url' => false)); } if ($quote !== false) { $operatorValue = $quote . $operatorValue . $quote; } }