Order = $order; $this->AddAllVars(); $this->processQueryString(); ini_set("magic_quotes_gpc", 0); } /** * All all requested vars to * common storage place * * @access private */ function AddAllVars() { for ($i=0; $i < strlen($this->Order); $i++) { $current = $this->Order[$i]; switch ($current) { case 'G': $this->Get =$this->AddVars($_GET); break; case 'P': $my_post = $this->post_convert($_POST); // needed ? $this->Post = $this->AddVars($_POST); break; case 'C': $this->Cookie = $this->AddVars($_COOKIE); break; case 'E'; $this->Env = $this->AddVars($_ENV); break; case 'S'; $this->Server = $this->AddVars($_SERVER); break; case 'F'; $this->Files = $this->AddVars($_FILES); break; } } } /** * Process QueryString only, create * events, ids, based on config * set template name and sid in * desired application variables. * * @access private */ function processQueryString() { // env=SID:TEMPLATE:m-1-1-1-1:l0-0-0:n-0-0-0:bb-0-0-1-1-1-0 $env_var =& $this->Get(ENV_VAR_NAME); if($env_var) { $parts=explode(':',$env_var); // Save Session ID $sid=array_shift($parts); if($sid) $this->Set('sid',$sid); // Save Template Name $t=$this->getTemplateName( array_shift($parts) ); if(!$t) $t='index'; $this->Set('t',$t); if($parts) { $query_maps=Array(); $event_manger =& $this->Application->recallObject('EventManager'); foreach($parts as $mixed_part) { $mixed_part=explode('-',$mixed_part); $prefix_special=array_shift($mixed_part); // l.pick, l list($prefix)=explode('.',$prefix_special); $query_maps[$prefix_special]=$this->Application->getUnitOption($prefix,'QueryString'); foreach($query_maps[$prefix_special] as $index => $var_name) { // l_id, l_page, l_bla-bla-bla $this->Set($prefix_special.'_'.$var_name,$mixed_part[$index-1]); } } $event_manger->setQueryMaps($query_maps); } } else { $t=$this->getTemplateName('index'); $this->Set('t',$t); } } /** * Decides what template name to * use from $_GET or from $_POST * * @param string $querystring_template * @return string * @access private */ function getTemplateName($querystring_template) { $t_from_post=$this->Get('t'); $t=$t_from_post?$t_from_post:$querystring_template; return $t; } function post_convert($array) { $out = Array(); foreach ($array as $key => $val) { if ( ereg("\|\|",$key)) { $key = str_replace("||",".",$key); } else $out[$key] = $val; } } /** * Saves variables from array specified * into common variable storage place * * @param Array $array * @return Array * @access private */ function AddVars($array) { foreach ($array as $key => $val) { if (get_magic_quotes_gpc()) { if ( is_array($val) ) { foreach ($val as $key_array => $val_array) { if( is_array($val_array) ) { $array[$key][$key_array] = $this->AddVars($val_array); } else { $array[$key][$key_array] = stripslashes($val_array); } } $this->Set($key, $array[$key]); } else { $array[$key] = stripslashes($val); $this->Set($key, $array[$key]); } } else { $this->Set($key, $val); } } return $array; } /** * Returns the hash of http params * matching the mask with values * * @param string $mask * @return Array * @access public */ function GetSelectedValues($mask) { return $this->Application->ExtractByMask($this->Vars, $mask); } /** * Returns the sprintf'ed by format list of * http params matching the mask and set to on * * @param string $mask * @param string $format * @return string * @access public */ function GetSelectedIDs($mask, $format) { if ($mask == '') return; $result = ''; foreach ($this->GetParams() as $name => $val) { if (eregi($mask, $name, $regs) && $val == 'on') { $result.= sprintf($format, $regs[1]); } } return $result; } /** * Returns the sprintf'ed by format list of * http params matching the mask and set to on * * @param string $mask * @param string $value_mask * @return Array * @access public */ function GetSelectedIDsArray($mask, $value_mask="%s,") { $str = $this->GetSelectedIDs($mask, $value_mask); $str = rtrim($str, ','); if (!empty($str)) { $ids = split(',', $str); if ($ids !== false) return $ids; else return Array(); } else return Array(); } } ?>