Index: trunk/kernel/include/config.php =================================================================== diff -u -N -r6093 -r8009 --- trunk/kernel/include/config.php (.../config.php) (revision 6093) +++ trunk/kernel/include/config.php (.../config.php) (revision 8009) @@ -196,12 +196,21 @@ var $TabIndex = 0; + /** + * Application instance + * + * @var kApplication + */ + var $Application = null; + function clsConfigAdminItem($config_name=NULL) { + $this->Application =& kApplication::Instance(); $this->adodbConnection = &GetADODBConnection(); - if($config_name) + if ($config_name) { $this->LoadSetting($config_name); } + } function LoadSetting($config_name) { @@ -221,57 +230,14 @@ } } - function explode_sql($sql) + function GetValues($string) { - $s = ""; - - $rs = $this->adodbConnection->Execute($sql); - - while ($rs && !$rs->EOF) - { - if(strlen(trim($rs->fields["OptionName"]))>0 && strlen(trim($rs->fields["OptionValue"]))>0) - { - if(strlen($s)) - $s .= ","; - $s .= $rs->fields["OptionValue"]."="."+".$rs->fields["OptionName"]; - } - $rs->MoveNext(); - } - return $s; + $cf_helper =& $this->Application->recallObject('InpCustomFieldsHelper'); + /* @var $cf_helper InpCustomFieldsHelper */ + + return $cf_helper->GetValuesHash($string); } - function replace_sql($string, $start_mark = '') - { - $mark_length = strlen($start_mark); - $string = str_replace("",GetTablePrefix(),$string); - - $start = strpos($string, $start_mark); - - while($start) - { - $end = strpos($string,""); - if(!$end) - { - $end = strlen($string); - } - $len = $end - $start; - $sql = substr($string,$start + $mark_length,$len - $mark_length); - - $sql_val = $this->explode_sql($sql); - $s = substr($string, 0, $start) . $sql_val . substr($string, $end + $mark_length + 1); - - $string = $s; - $start = strpos($string, $start_mark); - } - - if ($start_mark == '') { - // to prevent recursion. check new style of sqls too - $string = $this->replace_sql($string, ''); - } - - return preg_replace('/(.*)$,/','\\1', $string); - } - function ItemFormElement($StartFrom=1) { global $objConfig; @@ -328,44 +294,23 @@ case 'radio': $radioname = $this->name; - $ValList = $this->replace_sql($this->ValueList); - $this->TabIndex++; - $val = explode(',',$ValList); - for($i=0;$i<=count($val);$i++) - { - if(strlen($val[$i])) - { - $parts = explode('=',$val[$i]); - $s = $parts[1]; - if(strlen($s)==0) - $s = ''; - $o .= 'default_value == $parts[0]) ? ' checked>' : '>'; - - $o .= (substr($s,0,1)=="+") ? substr($s,1) : prompt_language($s); - } + $values = $this->GetValues($this->ValueList); + foreach ($values as $option_id => $option_name) { + $o .= 'default_value == $option_id) ? ' checked>' : '>'; + $o .= $option_name; } $this->TabIndex++; break; case 'select': $o .= ''; break;