aParameters[$Name] = array("Value" => $Value, "Id" => $Id, "IsConstant" => $IsConstant); } // Completely clear the collection function Clear() { // This option will not clear any items marked with IsConstant $tmp = array(); while (list($Name, $Value) = each($this->aParameters)) { if ($Value['IsConstant'] == 1) $tmp[$Name] = $Value; } $this->aParameters = $tmp; } // Return a count of how many elements are in the collection function Count() { return count($this->aParameters); } // Retrieves all get and post variables function DefineCollection($Collection, $ParameterPrefix = '', $IncludeByPrefix = '0', $ExcludeByPrefix = '0') { $ParameterPrefix = ForceString($ParameterPrefix, ''); $IncludeByPrefix = ForceBool($IncludeByPrefix, 0); $ExcludeByPrefix = ForceBool($ExcludeByPrefix, 0); $Add = 1; while (list($key, $value) = each($Collection)) { $Add = 1; if ($ParameterPrefix != '') { $PrefixMatchLocation = strstr($key, $ParameterPrefix); // If the prefix isn't found or the location is anywhere other than 0 (the start of the variable name) if ($PrefixMatchLocation === false || $PrefixMatchLocation != 0) { if ($IncludeByPrefix) $Add = 0; } else { if ($ExcludeByPrefix) $Add = 0; } } if ($Add) $this->Add($key, $value); } } function GetHiddenInputs() { $sReturn = ''; $Id = ''; $Value = ''; while (list($key, $val) = each($this->aParameters)) { $Value = $val['Value']; $Id = $val['Id']; if(is_array($Value)) { $nmrows = count($Value); $i = 0; for ($i = 0; $i < $nmrows; ++$i) { // Repetitive values cannot have an unique id, so ignore the id param $sReturn .= ' '; } } else { $sReturn .= ' '; } } reset($this->aParameters); return '
'.$sReturn.'
'; } // Return the collection as a string in querystring name/value pair format function GetQueryString($IncludeQuestionMark = '0') { $sReturn = ''; $Value = ''; while (list($key, $val) = each($this->aParameters)) { $Value = $val['Value']; if(is_array($Value)) { $nmrows = count($Value); for ($i = 0; $i < $nmrows; ++$i) { $sReturn .= $key .'[]=' . $Value[$i] . '&'; } } else { $sReturn .= $key . '=' . $Value . '&'; } } // remove trailing ampersand $sReturn = substr($sReturn,0,strlen($sReturn) - 5); if ($sReturn != '' && $IncludeQuestionMark) $sReturn = '?'.$sReturn; reset($this->aParameters); return $sReturn; } // Remove an element from the collection function Remove($Name) { $key_index = array_keys(array_keys($this->aParameters), $Name); if (count($key_index) > 0) array_splice($this->aParameters, $key_index[0], 1); } // Set a value. If it already exists, overwrite it. function Set($Name, $Value, $EncodeValue = 1, $Id = '', $IsConstant = 0) { $this->Remove($Name); $this->Add($Name, $Value, $EncodeValue, $Id, 1, $IsConstant); } } ?>