Index: branches/unlabeled/unlabeled-1.5.48/kernel/units/general/custom_fields.php =================================================================== diff -u -r2286 -r5263 --- branches/unlabeled/unlabeled-1.5.48/kernel/units/general/custom_fields.php (.../custom_fields.php) (revision 2286) +++ branches/unlabeled/unlabeled-1.5.48/kernel/units/general/custom_fields.php (.../custom_fields.php) (revision 5263) @@ -6,14 +6,13 @@ * @todo rewrite */ class InpCustomFieldsHelper extends kHelper { - + function GetValuesHash($values_list) { - $optionValuesStr = $this->ParseConfigSQL($values_list); - $optionValuesTmp = explode(',', $optionValuesStr); + $optionValuesStr = trim($this->ParseConfigSQL($values_list), ','); + $optionValuesTmp = explode(',', $optionValuesStr); $optionValues = Array(); - foreach($optionValuesTmp as $optionValue) - { + foreach ($optionValuesTmp as $optionValue) { list($key, $val) = explode('=', $optionValue); $val = (substr($val,0,1) == '+') ? substr($val, 1) : $this->Application->Phrase($val); $optionValues[$key] = $val; @@ -26,75 +25,49 @@ * * @param string $valueString * @return string - * @todo Fully rewrite !!! + * @todo Apply refactoring to embedded vars stuff */ function ParseConfigSQL($valueString) { $string = trim( str_replace('', TABLE_PREFIX, $valueString) ); preg_match_all("|\{(.*)\}|U", $string, $embedded_vars, PREG_SET_ORDER); - + /* in ValueList now can use globally available variables. Usage: {$_POST['variable']|what to output if $_POST['variable'] is set} e.g. $_POST['variable']='Hello' Will output: what to output if Hello is set */ - - if($embedded_vars) - { - for($i = 0; $i < count($embedded_vars); $i++) - { + + if ($embedded_vars) { + for ($i = 0; $i < count($embedded_vars); $i++) { $embedded_var = $embedded_vars[$i][1]; $embedded_var_src = $embedded_vars[$i][0]; - + list($var_name, $pattern) = explode('|', $embedded_var); eval('$var_value = (isset('.$var_name.')?'.$var_name.':false);'); - - if ($var_value !== false) - { + + if ($var_value !== false) { $pattern = str_replace($var_name, $var_value, $pattern); $string = str_replace($embedded_var_src, $pattern, $string); } - else - { + else { $string = str_replace($embedded_var_src, '', $string); } } - } - - $start = strpos($string,''); - if(!$end) - { - $end = strlen($string); + } + + if (preg_match_all('/(.*?)<\/SQL>/', $string, $regs)) { + $i = 0; + $sql_count = count($regs[0]); + while ($i < $sql_count) { + $string = str_replace(''.$regs[2][$i].'', $this->QueryConfigSQL($regs[2][$i], $regs[1][$i]), $string); + $i++; } - $len = $end - $start; - $sql = substr($string,$start+$skip_length,$len-$skip_length); - - $sql_val = $this->QueryConfigSQL($sql, $plus); - - /*if ($start>0 && $sql_val!='') - $sql_val=",".$sql_val;*/ - if ($end < strlen($string)-$skip_length-1 && $sql_val!='') - $sql_val.=","; - - $chunk1=substr($string,0,$start); - $chunk2=substr($string,$end+$skip_length+1); - $s = $chunk1.$sql_val.$chunk2; - - $string = $s; - - $start = strpos($string, 'Conn->Query($sql); for($i=0; $i \ No newline at end of file Index: branches/unlabeled/unlabeled-1.3.2/admin/install/upgrades/inportal_upgrade_v1.2.0.sql =================================================================== diff -u -r5112 -r5263 --- branches/unlabeled/unlabeled-1.3.2/admin/install/upgrades/inportal_upgrade_v1.2.0.sql (.../inportal_upgrade_v1.2.0.sql) (revision 5112) +++ branches/unlabeled/unlabeled-1.3.2/admin/install/upgrades/inportal_upgrade_v1.2.0.sql (.../inportal_upgrade_v1.2.0.sql) (revision 5263) @@ -103,4 +103,6 @@ INSERT INTO Permissions (Permission, GroupId, PermissionValue, Type, CatId) VALUES ('in-portal:server_info.view', 11, 1, 1, 0); INSERT INTO Permissions (Permission, GroupId, PermissionValue, Type, CatId) VALUES ('in-portal:help.view', 11, 1, 1, 0); +UPDATE ConfigurationAdmin SET ValueList = 'Name=la_Category_Name,Description=la_Category_Description,CreatedOn=la_Category_Date,EditorsPick=la_Category_Pick,SELECT Prompt AS OptionName, CONCAT("cust_", FieldName) AS OptionValue FROM CustomField WHERE (Type = 1) AND (IsSystem = 0)' WHERE VariableName IN ('Category_Sortfield', 'Category_Sortfield2'); + UPDATE Modules SET Version = '1.2.0' WHERE Name = 'In-Portal'; \ No newline at end of file Index: branches/unlabeled/unlabeled-1.5.48/core/units/general/custom_fields.php =================================================================== diff -u -r2286 -r5263 --- branches/unlabeled/unlabeled-1.5.48/core/units/general/custom_fields.php (.../custom_fields.php) (revision 2286) +++ branches/unlabeled/unlabeled-1.5.48/core/units/general/custom_fields.php (.../custom_fields.php) (revision 5263) @@ -6,14 +6,13 @@ * @todo rewrite */ class InpCustomFieldsHelper extends kHelper { - + function GetValuesHash($values_list) { - $optionValuesStr = $this->ParseConfigSQL($values_list); - $optionValuesTmp = explode(',', $optionValuesStr); + $optionValuesStr = trim($this->ParseConfigSQL($values_list), ','); + $optionValuesTmp = explode(',', $optionValuesStr); $optionValues = Array(); - foreach($optionValuesTmp as $optionValue) - { + foreach ($optionValuesTmp as $optionValue) { list($key, $val) = explode('=', $optionValue); $val = (substr($val,0,1) == '+') ? substr($val, 1) : $this->Application->Phrase($val); $optionValues[$key] = $val; @@ -26,75 +25,49 @@ * * @param string $valueString * @return string - * @todo Fully rewrite !!! + * @todo Apply refactoring to embedded vars stuff */ function ParseConfigSQL($valueString) { $string = trim( str_replace('', TABLE_PREFIX, $valueString) ); preg_match_all("|\{(.*)\}|U", $string, $embedded_vars, PREG_SET_ORDER); - + /* in ValueList now can use globally available variables. Usage: {$_POST['variable']|what to output if $_POST['variable'] is set} e.g. $_POST['variable']='Hello' Will output: what to output if Hello is set */ - - if($embedded_vars) - { - for($i = 0; $i < count($embedded_vars); $i++) - { + + if ($embedded_vars) { + for ($i = 0; $i < count($embedded_vars); $i++) { $embedded_var = $embedded_vars[$i][1]; $embedded_var_src = $embedded_vars[$i][0]; - + list($var_name, $pattern) = explode('|', $embedded_var); eval('$var_value = (isset('.$var_name.')?'.$var_name.':false);'); - - if ($var_value !== false) - { + + if ($var_value !== false) { $pattern = str_replace($var_name, $var_value, $pattern); $string = str_replace($embedded_var_src, $pattern, $string); } - else - { + else { $string = str_replace($embedded_var_src, '', $string); } } - } - - $start = strpos($string,''); - if(!$end) - { - $end = strlen($string); + } + + if (preg_match_all('/(.*?)<\/SQL>/', $string, $regs)) { + $i = 0; + $sql_count = count($regs[0]); + while ($i < $sql_count) { + $string = str_replace(''.$regs[2][$i].'', $this->QueryConfigSQL($regs[2][$i], $regs[1][$i]), $string); + $i++; } - $len = $end - $start; - $sql = substr($string,$start+$skip_length,$len-$skip_length); - - $sql_val = $this->QueryConfigSQL($sql, $plus); - - /*if ($start>0 && $sql_val!='') - $sql_val=",".$sql_val;*/ - if ($end < strlen($string)-$skip_length-1 && $sql_val!='') - $sql_val.=","; - - $chunk1=substr($string,0,$start); - $chunk2=substr($string,$end+$skip_length+1); - $s = $chunk1.$sql_val.$chunk2; - - $string = $s; - - $start = strpos($string, 'Conn->Query($sql); for($i=0; $i \ No newline at end of file Index: branches/unlabeled/unlabeled-1.62.2/admin/install/inportal_data.sql =================================================================== diff -u -r5112 -r5263 --- branches/unlabeled/unlabeled-1.62.2/admin/install/inportal_data.sql (.../inportal_data.sql) (revision 5112) +++ branches/unlabeled/unlabeled-1.62.2/admin/install/inportal_data.sql (.../inportal_data.sql) (revision 5263) @@ -2,9 +2,9 @@ INSERT INTO ConfigurationAdmin VALUES ('Site_Path', 'la_Text_Website', 'la_config_web_address', 'text', '', '', 6, 1); INSERT INTO ConfigurationAdmin VALUES ('Backup_Path', 'la_Text_BackupPath', 'la_config_backup_path', 'text', '', '', 6, 1); INSERT INTO ConfigurationAdmin VALUES ('Domain_Detect', 'la_Text_Website', 'la_config_detect_domain', 'text', '', '', 8, 1); -INSERT INTO ConfigurationAdmin VALUES ('Category_Sortfield', 'la_Text_General', 'la_category_sortfield_prompt', 'select', '', 'Name=la_Category_Name,Description=la_Category_Description,CreatedOn=la_Category_Date,EditorsPick=la_Category_Pick,Pop=la_Category_Pop,SELECT FieldLabel as OptionName, FieldName as OptionValue FROM CustomField WHERE Type=0', 1, 1); +INSERT INTO ConfigurationAdmin VALUES ('Category_Sortfield', 'la_Text_General', 'la_category_sortfield_prompt', 'select', '', 'Name=la_Category_Name,Description=la_Category_Description,CreatedOn=la_Category_Date,EditorsPick=la_Category_Pick,SELECT Prompt AS OptionName, CONCAT("cust_", FieldName) AS OptionValue FROM CustomField WHERE (Type = 1) AND (IsSystem = 0)', 1, 1); INSERT INTO ConfigurationAdmin VALUES ('Category_Sortorder', 'la_Text_General', 'la_category_sortfield_prompt', 'select', '', 'asc=la_common_ascending,desc=la_common_descending', 2, 1); -INSERT INTO ConfigurationAdmin VALUES ('Category_Sortfield2', 'la_Text_General', 'la_category_sortfield2_prompt', 'select', '', 'Name=la_Category_Name,Description=la_Category_Description,CreatedOn=la_Category_Date,EditorsPick=la_Category_Pick,Pop=la_Category_Pop,SELECT FieldLabel as OptionName, FieldName as OptionValue FROM CustomField WHERE Type=0', 3, 1); +INSERT INTO ConfigurationAdmin VALUES ('Category_Sortfield2', 'la_Text_General', 'la_category_sortfield2_prompt', 'select', '', 'Name=la_Category_Name,Description=la_Category_Description,CreatedOn=la_Category_Date,EditorsPick=la_Category_Pick,SELECT Prompt AS OptionName, CONCAT("cust_", FieldName) AS OptionValue FROM CustomField WHERE (Type = 1) AND (IsSystem = 0)', 3, 1); INSERT INTO ConfigurationAdmin VALUES ('Category_Sortorder2', 'la_Text_General', 'la_category_sortfield2_prompt', 'select', '', 'asc=la_common_ascending,desc=la_common_descending', 4, 1); INSERT INTO ConfigurationAdmin VALUES ('Perpage_Category', 'la_Text_General', 'la_category_perpage_prompt', 'text', '', '', 5, 1); INSERT INTO ConfigurationAdmin VALUES ('Category_DaysNew', 'la_Text_General', 'la_category_daysnew_prompt', 'text', '', '', 6, 1);