Index: trunk/globals.php =================================================================== diff -u -r3124 -r3145 --- trunk/globals.php (.../globals.php) (revision 3124) +++ trunk/globals.php (.../globals.php) (revision 3145) @@ -1656,23 +1656,75 @@ $update =& $GLOBALS[$prefix.'_var_list_update']; //echo "VAR: [$main]; VAR_UPDATE: [$update]
"; + // if update var count is zero, then do nothing + if( !is_array($update) || count($update) == 0 ) return ''; + // ensure that we have no empty values in enviroment variable - foreach($update as $vl_key => $vl_value) + foreach($update as $vl_key => $vl_value) { if(!$vl_value) $update[$vl_key] = '0'; // unset($update[$vl_key]); - - // if update var count is zero, then do nothing - if(count($update) == 0) return ''; + } - foreach($main as $vl_key => $vl_value) + foreach($main as $vl_key => $vl_value) { if(!$vl_value) $main[$vl_key] = '0'; // unset($main[$vl_key]); + } $ret = Array(); - foreach($var_list as $var_name) + foreach($var_list as $var_name) { $ret[] = GetEnvVar($prefix, $var_name); + } + + // Removing all var_list_udpate + $keys = array_keys($update); + foreach ($keys as $key) { + unset($update[$key]); + } return ':'.$prefix.implode('-',$ret); } +// functions for dealign with enviroment variable construction +function GenerateModuleEnv_NEW($prefix, $var_list) +{ + // globalize module varible arrays + $main =& $GLOBALS[$prefix.'_var_list']; + $update =& $GLOBALS[$prefix.'_var_list_update']; + //echo "VAR: [$main]; VAR_UPDATE: [$update]
"; + + if ( isset($update) && $update ) + { + // ensure that we have no empty values in enviroment variable + foreach($update as $vl_key => $vl_value) { + if(!$vl_value) $update[$vl_key] = '0'; // unset($update[$vl_key]); + } + + $app =& kApplication::Instance(); + $passed = $app->GetVar('prefixes_passed'); + $passed[] = $prefix; + $app->SetVar('prefixes_passed', $passed); + } + else + { + return Array(); + } + + foreach($main as $vl_key => $vl_value) { + if(!$vl_value) $main[$vl_key] = '0'; // unset($main[$vl_key]); + } + + $ret = Array(); + foreach($var_list as $src_name => $dst_name) { + $ret[$dst_name] = GetEnvVar($prefix, $src_name); + } + + // Removing all var_list_udpate + if ( isset($update) && $update ) + { + $keys = array_keys($update); + foreach ($keys as $key) unset($update[$key]); + } + return $ret; +} + function GetEnvVar($prefix, $name) { // get variable from template variable's list @@ -1891,7 +1943,7 @@ */ function set_cookie($name, $value, $expire = 0) { - $cookie_path = IsAdmin() ? BASE_PATH.'/admin' : BASE_PATH; + $cookie_path = IsAdmin() ? rtrim(BASE_PATH, '/').'/admin' : BASE_PATH; setcookie($name, $value, $expire, $cookie_path, $_SERVER['HTTP_HOST']); } @@ -1929,35 +1981,25 @@ } } - function HREF_Wrapper($t = '', $params = null, $index_file = null ) + /** + * Builds up K4 url from data supplied by in-portal + * + * @param string $t template + * @param Array $params + * @param string $index_file + * @return string + */ + function HREF_Wrapper($t = '', $params = null, $index_file = null) { - $ret = GetIndexURL(2).'?env='.BuildEnv(); - if( isset($params) ) + $url_params = BuildEnv_NEW(); + if( isset($params) ) $url_params = array_merge_recursive2($url_params, $params); + if(!$t) { - $map_link = ''; - if( is_array($params) ) - { - if( isset($params['anchor']) ) - { - $map_link = '#'.$params['anchor']; - unset($params['anchor']); - } - foreach ($params as $param_name => $param_value) - { - $ret .= '&'.$param_name.'='.urlencode($param_value); - } - } - else - { - $app =& kApplication::Instance(); - $app->Debugger->appendTrace(); - trigger_error('Incorrect HREF_Wrapper call', E_USER_WARNING); - } + $t = $url_params['t']; + unset($url_params['t']); } - return $ret.$map_link; - - /*$application =& kApplication::Instance(); - return $application->HREF($t, '', $params, $index_file);*/ + $app =& kApplication::Instance(); + return $app->HREF($t, '', $url_params, $index_file); } /**