Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1161196
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Sep 20, 1:04 AM
Size
6 KB
Mime Type
text/x-diff
Expires
Mon, Sep 22, 1:04 AM (1 h, 1 m)
Engine
blob
Format
Raw Data
Handle
751116
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/unlabeled/unlabeled-1.7.2/kernel/units/general/custom_fields.php
===================================================================
--- branches/unlabeled/unlabeled-1.7.2/kernel/units/general/custom_fields.php (revision 5780)
+++ branches/unlabeled/unlabeled-1.7.2/kernel/units/general/custom_fields.php (revision 5781)
@@ -1,88 +1,93 @@
<?php
/**
* Enter description here...
*
* @todo rewrite
*/
class InpCustomFieldsHelper extends kHelper {
function GetValuesHash($values_list)
{
- $optionValuesStr = trim($this->ParseConfigSQL($values_list), ',');
+ $optionValuesStr = trim($this->ParseConfigSQL($values_list), ',');
+ if (!$optionValuesStr) {
+ // no options, then return empty array
+ return Array();
+ }
+
$optionValuesTmp = explode(',', $optionValuesStr);
$optionValues = Array();
foreach ($optionValuesTmp as $optionValue) {
list($key, $val) = explode('=', $optionValue);
$val = (substr($val,0,1) == '+') ? substr($val, 1) : $this->Application->Phrase($val);
$optionValues[$key] = $val;
}
return $optionValues;
}
/**
* Replace SQL's in valueList with appropriate queried values
*
* @param string $valueString
* @return string
* @todo Apply refactoring to embedded vars stuff
*/
function ParseConfigSQL($valueString)
{
$string = trim( str_replace('<PREFIX>', TABLE_PREFIX, $valueString) );
preg_match_all("|\{(.*)\}|U", $string, $embedded_vars, PREG_SET_ORDER);
/*
<SQL> 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++) {
$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) {
$pattern = str_replace($var_name, $var_value, $pattern);
$string = str_replace($embedded_var_src, $pattern, $string);
}
else {
$string = str_replace($embedded_var_src, '', $string);
}
}
}
if (preg_match_all('/<SQL([+]{0,1})>(.*?)<\/SQL>/', $string, $regs)) {
$i = 0;
$sql_count = count($regs[0]);
while ($i < $sql_count) {
$string = str_replace('<SQL'.$regs[1][$i].'>'.$regs[2][$i].'</SQL>', $this->QueryConfigSQL($regs[2][$i], $regs[1][$i]), $string);
$i++;
}
$string = preg_replace('/(,){2,}/', ',', $string); // trim trailing commas inside string
}
return $string;
}
function QueryConfigSQL($sql, $plus = '')
{
$valArray = $this->Conn->Query($sql);
for($i=0; $i<sizeof($valArray); $i++)
{
$valArray[$i] = $valArray[$i]['OptionValue'].'='.$plus.$valArray[$i]['OptionName'];
$valArray[$i] = str_replace(',', ';', $valArray[$i]);
}
return implode(',', $valArray);
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.7.2/kernel/units/general/custom_fields.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7
\ No newline at end of property
+1.7.2.1
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.7.2/core/units/general/custom_fields.php
===================================================================
--- branches/unlabeled/unlabeled-1.7.2/core/units/general/custom_fields.php (revision 5780)
+++ branches/unlabeled/unlabeled-1.7.2/core/units/general/custom_fields.php (revision 5781)
@@ -1,88 +1,93 @@
<?php
/**
* Enter description here...
*
* @todo rewrite
*/
class InpCustomFieldsHelper extends kHelper {
function GetValuesHash($values_list)
{
- $optionValuesStr = trim($this->ParseConfigSQL($values_list), ',');
+ $optionValuesStr = trim($this->ParseConfigSQL($values_list), ',');
+ if (!$optionValuesStr) {
+ // no options, then return empty array
+ return Array();
+ }
+
$optionValuesTmp = explode(',', $optionValuesStr);
$optionValues = Array();
foreach ($optionValuesTmp as $optionValue) {
list($key, $val) = explode('=', $optionValue);
$val = (substr($val,0,1) == '+') ? substr($val, 1) : $this->Application->Phrase($val);
$optionValues[$key] = $val;
}
return $optionValues;
}
/**
* Replace SQL's in valueList with appropriate queried values
*
* @param string $valueString
* @return string
* @todo Apply refactoring to embedded vars stuff
*/
function ParseConfigSQL($valueString)
{
$string = trim( str_replace('<PREFIX>', TABLE_PREFIX, $valueString) );
preg_match_all("|\{(.*)\}|U", $string, $embedded_vars, PREG_SET_ORDER);
/*
<SQL> 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++) {
$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) {
$pattern = str_replace($var_name, $var_value, $pattern);
$string = str_replace($embedded_var_src, $pattern, $string);
}
else {
$string = str_replace($embedded_var_src, '', $string);
}
}
}
if (preg_match_all('/<SQL([+]{0,1})>(.*?)<\/SQL>/', $string, $regs)) {
$i = 0;
$sql_count = count($regs[0]);
while ($i < $sql_count) {
$string = str_replace('<SQL'.$regs[1][$i].'>'.$regs[2][$i].'</SQL>', $this->QueryConfigSQL($regs[2][$i], $regs[1][$i]), $string);
$i++;
}
$string = preg_replace('/(,){2,}/', ',', $string); // trim trailing commas inside string
}
return $string;
}
function QueryConfigSQL($sql, $plus = '')
{
$valArray = $this->Conn->Query($sql);
for($i=0; $i<sizeof($valArray); $i++)
{
$valArray[$i] = $valArray[$i]['OptionValue'].'='.$plus.$valArray[$i]['OptionName'];
$valArray[$i] = str_replace(',', ';', $valArray[$i]);
}
return implode(',', $valArray);
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.7.2/core/units/general/custom_fields.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7
\ No newline at end of property
+1.7.2.1
\ No newline at end of property
Event Timeline
Log In to Comment