Index: trunk/kernel/include/searchconfig.php
===================================================================
diff -u -r3534 -r3537
--- trunk/kernel/include/searchconfig.php (.../searchconfig.php) (revision 3534)
+++ trunk/kernel/include/searchconfig.php (.../searchconfig.php) (revision 3537)
@@ -49,8 +49,19 @@
$field = $this->Get("ForeignField");
}
else
+ {
$field = $this->Get("FieldName");
-
+ }
+
+ if (is_array($value))
+ {
+ foreach ($value as $value_item) {
+ $where .= '('.$field.' = '.$this->adodbConnection->qstr($value_item).') OR ';
+ }
+
+ return preg_replace('/(.*) OR $/', '\\1', $where);
+ }
+
switch($verb)
{
case "is":
@@ -94,135 +105,235 @@
global $objConfig, $objSession, $objUsers, $objCatList, $var_list_update, $var_list,
$bb_var_list_update, $m_var_list_update,$FormValues;
- $extra_attribs = ExtraAttributes($element->attributes);
- if(strtolower($element->name)==$this->TagPrefix)
+ $extra_attribs = ExtraAttributes($element->attributes);
+ if (strtolower($element->name)==$this->TagPrefix)
{
- $field = strtolower($element->attributes["_field"]);
+ $field = strtolower($element->attributes["_field"]);
switch($field)
{
- case "name":
- $ret = $this->Get("FieldName");
- break;
- case "lang_name":
- $ret = language($this->Get("DisplayName"));
- break;
- case "id":
- $ret = $this->Get("SearchConfigId");
- break;
- case "header":
- $hdr = $this->Get("ConfigHeader");
- if(strlen($hdr))
- $ret = language($hdr);
- break;
- case "table":
- $ret = $this->Get("TableName");
- break;
- case "simple":
- $ret = (int)$this->Get("SimpleSearch");
- if($ret)
- {
- if(strlen($element->attributes["_text"]))
- $ret = language($element->attributes["_text"]);
- if(strlen($element->attributes["_plaintext"]))
- $ret = $element->attributes["_plaintext"];
- }
- break;
- case "advanced":
- $ret = (int)$this->Get("AdvancedSearch");
- if($ret)
- {
- if(strlen($element->attributes["_text"]))
- $ret = language($element->attributes["_text"]);
- if(strlen($element->attributes["_plaintext"]))
- $ret = $element->attributes["_plaintext"];
- }
-
- break;
- case "verb_select":
- $datatype = $this->Get("FieldType");
- switch($datatype)
- {
- case "text":
- $fieldname = "verb[".$this->Get("FieldName")."]";
- $ret = "";
- break;
- case "boolean":
- $ret = "";
- break;
- }
- break;
- case "form_input":
- $datatype = $this->Get("FieldType");
- $name = $this->Get("FieldName");
- switch($datatype)
- {
- case "text":
- $ret = "";
- break;
- case "boolean":
- $ret = "
'.
- language('lu_from').': |
- |
'.
- language('lu_to').': |
- |
';
- break;
- }
- break;
- case "andor_radio":
- $name = $this->Get("FieldName");
- $Field = "andor[$name]";
- $checked = Array(1 => '', 2 => '');
- $checked[ $FormValues[$Field] ] = ' checked';
- if(!$FormValues[$Field]) $checked[1] = ' checked';
-
- $ret = "".language("lu_and");
- $ret .= "".language("lu_or");
- return $ret;
+ case "name":
+ $ret = $this->Get("FieldName");
+ break;
+
+ case "lang_name":
+ $ret = language($this->Get("DisplayName"));
+ break;
+
+ case "id":
+ $ret = $this->Get("SearchConfigId");
+ break;
+
+ case "header":
+ $hdr = $this->Get("ConfigHeader");
+ if ($hdr) $ret = language($hdr);
+ break;
+
+ case "table":
+ $ret = $this->Get("TableName");
+ break;
+
+ case "simple":
+ $ret = (int)$this->Get("SimpleSearch");
+ if($ret)
+ {
+ if(strlen($element->attributes["_text"]))
+ $ret = language($element->attributes["_text"]);
+ if(strlen($element->attributes["_plaintext"]))
+ $ret = $element->attributes["_plaintext"];
+ }
+ break;
+
+ case "advanced":
+ $ret = (int)$this->Get("AdvancedSearch");
+ if($ret)
+ {
+ if(strlen($element->attributes["_text"]))
+ $ret = language($element->attributes["_text"]);
+ if(strlen($element->attributes["_plaintext"]))
+ $ret = $element->attributes["_plaintext"];
+ }
+
+ break;
+
+ case "verb_select":
+ $datatype = $this->Get("FieldType");
+ switch($datatype)
+ {
+ case "text":
+ case 'textarea':
+ $fieldname = "verb[".$this->Get("FieldName")."]";
+ $ret = "";
+ break;
+
+ case "boolean":
+ $ret = "";
+ break;
+
+ case 'select':
+ case 'radio':
+ case 'checkbox':
+// $ret = '';
+ $fieldname = 'verb['.$this->Get('FieldName').']';
+ $ret = '";
+ break;
+ }
+ break;
+
+ case 'form_input':
+ $datatype = $this->Get("FieldType");
+ $name = $this->Get("FieldName");
+ switch($datatype)
+ {
+ case "text":
+ case 'textarea':
+ $ret = "";
+ break;
+
+ case 'select':
+ $current_value = $FormValues[$name];
+ $values = $this->parseValuesList();
+
+ $ret = '';
+ break;
+
+ case 'radio':
+ $current_value = $FormValues[$name];
+ $values = $this->parseValuesList();
+
+ $ret = '';
+ $option_tpl = ' %s ';
+ foreach ($values as $value_key => $value_name) {
+ $selected = ($current_value == $value_key) ? ' checked' : '';
+ $ret .= sprintf($option_tpl, $value_key, $selected, $value_name);
+ }
+ break;
+
+ case 'checkbox':
+ $current_value = $FormValues[$name];
+ $values = $this->parseValuesList();
+
+ $ret = '';
+ $option_tpl = ' %s ';
+ foreach ($values as $value_key => $value_name) {
+ $selected = ($current_value == $value_key) ? ' checked' : '';
+ $ret .= sprintf($option_tpl, $value_key, $selected, $value_name);
+ }
+ break;
+
+ /*case 'password':
+ break;*/
+
+ case "boolean":
+ $ret = "'.
+ language('lu_from').': |
+ |
'.
+ language('lu_to').': |
+ |
';
+ break;
+ }
+ break;
+
+ case "andor_radio":
+ $name = $this->Get("FieldName");
+ $Field = "andor[$name]";
+ $checked = Array(1 => '', 2 => '');
+ $checked[ $FormValues[$Field] ] = ' checked';
+ if(!$FormValues[$Field]) $checked[1] = ' checked';
+
+ $ret = "".language("lu_and");
+ $ret .= "".language("lu_or");
+ return $ret;
+ break;
}
}
return $ret;
}
+
+ /**
+ * If custom field contains values list, then parse it into array
+ *
+ * @return Array
+ */
+ function parseValuesList()
+ {
+ $sql = 'SELECT ValueList
+ FROM '.GetTablePrefix().'CustomField
+ WHERE CustomFieldId = '.$this->Get('CustomFieldId');
+ $list = $this->adodbConnection->GetOne($sql);
+ if (!$list) return Array();
+
+ $ret = Array();
+ $values = explode(',', $list);
+ foreach ($values as $mixed_value) {
+ list($value_key, $value_name) = explode('=', $mixed_value);
+ $value_key = trim($value_key);
+ $value_name = trim($value_name);
+
+ if (substr($value_name, 0, 1) == '+')
+ {
+ $ret[$value_key] = substr($value_name, 1, strlen($value_name));
+ }
+ else {
+ $ret[$value_key] = language($value_name);
+ }
+ }
+ return $ret;
+ }
}
class clsSearchConfigList