AntonLV 8 年之前
父節點
當前提交
39a35b1409

+ 2 - 0
inc/classes/BxDolCmts.php

@@ -1131,6 +1131,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
             'cmt_author_id' => array(
             	'type' => 'text_auto', 
             	'caption' => $aSrchCaptions['cmt_author_id'],
+        		'info' => '',
         		'value' => '',
             	'values' => '',
         		'pass' => ''
@@ -1142,6 +1143,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
                 $aResult[$aInput['name']] = array(
                 	'type' => $aInput['type'], 
                 	'caption' => !empty($aInput['caption_src']) ? $aInput['caption_src'] : (!empty($aSrchCaptions[$aInput['name']]) ? $aSrchCaptions[$aInput['name']] : ''),
+                	'info' => !empty($aInput['info_src']) ? $aInput['info_src'] : '',
                 	'value' => !empty($aInput['value']) ? $aInput['value'] : '',
                     'values' => !empty($aInput['values_src']) ? $aInput['values_src'] : '',
                 	'pass' => !empty($aInput['db']['pass']) ? $aInput['db']['pass'] : ''

+ 50 - 5
inc/classes/BxDolSearchExtendedQuery.php

@@ -42,20 +42,48 @@ class BxDolSearchExtendedQuery extends BxDolDb
             if(empty($aFields) || !is_array($aFields))
                 return array();
 
+            $oLanguage = BxDolStudioLanguagesUtils::getInstance();
+            $aLangIds = array_keys($oLanguage->getLanguages(true));
+
             $iOrder = 0;
-            foreach($aFields as $sField => $aField) 
-                $oDb->query("INSERT INTO `sys_search_extended_fields`(`object`, `name`, `type`, `caption`, `values`, `pass`, `search_type`, `search_value`, `search_operator`, `active`, `order`) VALUES(:object, :name, :type, :caption, :values, :pass, :search_type, :search_value, :search_operator, '1', :order)", array(
+            foreach($aFields as $sField => $aField) {
+                $iNow = time();
+                $sCaptionKey = (!empty($aField['caption']) ? $aField['caption'] : '_sys_form_input_' . $sField) . '_' . $iNow;
+                $sInfoKey = (!empty($aField['info']) ? $aField['info'] : '_sys_form_input_' . $sField . '_info') . '_' . $iNow;
+
+                $bResult = (int)$oDb->query("INSERT INTO `sys_search_extended_fields`(`object`, `name`, `type`, `caption`, `info`, `values`, `pass`, `search_type`, `search_value`, `search_operator`, `active`, `order`) VALUES(:object, :name, :type, :caption, :info, :values, :pass, :search_type, :search_value, :search_operator, '1', :order)", array(
                     'object' => $aObject['object'], 
                     'name' => $sField,
                     'type' => $aField['type'],
-                    'caption' => $aField['caption'],
+                    'caption' => $sCaptionKey,
+                	'info' => $sInfoKey,
                     'values' => $aField['values'],
                     'pass' => $aField['pass'],
                     'search_type' => reset(BxDolSearchExtended::$TYPE_TO_TYPE_SEARCH[$aField['type']]),
                     'search_value' => in_array($aField['type'], array('checkbox', 'switcher')) ? $aField['value'] : '', 
                     'search_operator' => reset(BxDolSearchExtended::$TYPE_TO_OPERATOR[$aField['type']]),
                     'order' => $iOrder++
-                ));
+                )) > 0;
+
+                if($bResult) {
+                    $aCaptionValues = $oLanguage->getLanguageString($aField['caption']);
+                    $aInfoValues = $oLanguage->getLanguageString($aField['info']);
+
+                    foreach($aLangIds as $iLangId) {
+                        $sCaptionValue = '';
+                        if(isset($aCaptionValues[$iLangId]) && !empty($aCaptionValues[$iLangId]['string']))
+                            $sCaptionValue = $aCaptionValues[$iLangId]['string'];
+                        $oLanguage->addLanguageString($sCaptionKey, $sCaptionValue, $iLangId, 0, false);
+
+                        $sInfoValue = '';
+                        if(isset($aInfoValues[$iLangId]) && !empty($aInfoValues[$iLangId]['string']))
+                            $sInfoValue = $aInfoValues[$iLangId]['string'];
+                        $oLanguage->addLanguageString($sInfoKey, $sInfoValue, $iLangId, 0, false);
+                    }
+                }
+            }
+
+            $oLanguage->compileLanguage(0, true);
 
             $aFields = $oDb->getAll($sQueryFields, $aQueryFieldsBindings);
         }
@@ -84,7 +112,24 @@ class BxDolSearchExtendedQuery extends BxDolDb
         if(empty($aWhere))
     		return false;
 
-        return $this->query("DELETE FROM `sys_search_extended_fields` WHERE " . $this->arrayToSQL($aWhere, ' AND '));
+        $sWhereClause = $this->arrayToSQL($aWhere, ' AND ');
+
+        $aFields = $this->getAll("SELECT * FROM `sys_search_extended_fields` WHERE " . $sWhereClause);
+        if(!empty($aFields) && is_array($aFields)) {
+            $oLanguage = BxDolStudioLanguagesUtils::getInstance();
+
+            foreach($aFields as $aField) {
+                if(!empty($aField['caption']))
+                    $oLanguage->deleteLanguageString($aField['caption'], 0, false);
+
+                if(!empty($aField['info']))
+                    $oLanguage->deleteLanguageString($aField['info'], 0, false);
+            }
+
+            $oLanguage->compileLanguage(0, true);
+        }
+
+        return $this->query("DELETE FROM `sys_search_extended_fields` WHERE " . $sWhereClause);
     }
 }
 

+ 1 - 0
install/sql/system.sql

@@ -1000,6 +1000,7 @@ CREATE TABLE `sys_search_extended_fields` (
   `name` varchar(255) NOT NULL  default '',
   `type` varchar(32) NOT NULL default '',
   `caption` varchar(255) NOT NULL default '',
+  `info` varchar(255) NOT NULL default '',
   `values` text NOT NULL default '',
   `pass` varchar(32) NOT NULL,
   `search_type` varchar(32) NOT NULL  default '',

+ 2 - 0
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -147,6 +147,7 @@ class BxBaseModGeneralModule extends BxDolModule
             $aResult[$CNF['FIELD_AUTHOR']] = array(
                 'type' => 'text_auto', 
                 'caption' => $CNF['T']['form_field_author'],
+                'info' => '',
             	'value' => '',
                 'values' => '',
                 'pass' => ''
@@ -157,6 +158,7 @@ class BxBaseModGeneralModule extends BxDolModule
                 $aResult[$aInput['name']] = array(
                     'type' => $aInput['type'], 
                     'caption' => $aInput['caption_src'],
+                	'info' => $aInput['info_src'],
                 	'value' => !empty($aInput['value']) ? $aInput['value'] : '',
                     'values' => !empty($aInput['values_src']) ? $aInput['values_src'] : '',
                     'pass' => !empty($aInput['db']['pass']) ? $aInput['db']['pass'] : '',

+ 1 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -876,6 +876,7 @@
     <string name="_adm_form_txt_search_forms_fields"><![CDATA[Fields]]></string>
     <string name="_adm_form_txt_search_forms_fields_type"><![CDATA[Type]]></string>
     <string name="_adm_form_txt_search_forms_fields_caption"><![CDATA[Caption]]></string>
+    <string name="_adm_form_txt_search_forms_fields_info"><![CDATA[Description]]></string>
     <string name="_adm_form_txt_search_forms_fields_search_type"><![CDATA[Search Type]]></string>
     <string name="_adm_form_txt_search_forms_fields_select_object"><![CDATA[Select Form...]]></string>
     <string name="_adm_form_txt_search_forms_fields_edit_popup"><![CDATA[Edit "{0}" Search Field]]></string>

+ 1 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -874,6 +874,7 @@
     <string name="_adm_form_txt_search_forms_fields"><![CDATA[Поля]]></string>
     <string name="_adm_form_txt_search_forms_fields_type"><![CDATA[Тип]]></string>
     <string name="_adm_form_txt_search_forms_fields_caption"><![CDATA[Заголовок]]></string>
+    <string name="_adm_form_txt_search_forms_fields_info"><![CDATA[Описание]]></string>
     <string name="_adm_form_txt_search_forms_fields_search_type"><![CDATA[Тип поиска]]></string>
     <string name="_adm_form_txt_search_forms_fields_select_object"><![CDATA[Выбрать форму...]]></string>
     <string name="_adm_form_txt_search_forms_fields_edit_popup"><![CDATA[Редактировать "{0}" поле формы поиска]]></string>

+ 2 - 0
studio/classes/BxDolStudioFormsSearchFields.php

@@ -7,6 +7,8 @@
  * @{
  */
 
+require_once(BX_DOL_DIR_STUDIO_INC . 'utils.inc.php');
+
 class BxDolStudioFormsSearchFields extends BxTemplStudioGrid
 {
     protected $sModule = '';

+ 39 - 26
studio/template/scripts/BxBaseStudioFormsSearchFields.php

@@ -76,21 +76,24 @@ class BxBaseStudioFormsSearchFields extends BxDolStudioFormsSearchFields
                         'pass' => 'Int',
                     ),
                 ),
-                'search_type' => array(
-                    'type' => 'select',
-                    'name' => 'search_type',
-                    'caption' => _t('_adm_form_txt_search_forms_fields_search_type'),
-                    'info' => _t('_adm_form_dsc_search_forms_fields_search_type'),
-                    'values' => array(),
-                    'value' => $aField['search_type'],
-                    'required' => '1',
+                'caption' => array(
+                    'type' => 'text_translatable',
+                    'name' => 'caption',
+                    'caption' => _t('_adm_form_txt_search_forms_fields_caption'),
+                    'value' => $aField['caption'],
+                    'required' => '0',
                     'db' => array (
                         'pass' => 'Xss',
                     ),
-                    'checker' => array (
-                        'func' => 'Avail',
-                        'params' => array(),
-                        'error' => _t('_adm_form_err_search_forms_essential'),
+                ),
+                'info' => array(
+                    'type' => 'text_translatable',
+                    'name' => 'info',
+                    'caption' => _t('_adm_form_txt_search_forms_fields_info'),
+                    'value' => $aField['info'],
+                    'required' => '0',
+                    'db' => array (
+                        'pass' => 'Xss',
                     ),
                 ),
                 'controls' => array(
@@ -114,8 +117,30 @@ class BxBaseStudioFormsSearchFields extends BxDolStudioFormsSearchFields
             )
         );
 
-        foreach(BxDolSearchExtended::$TYPE_TO_TYPE_SEARCH[$aField['type']] as $sType)
-            $aForm['inputs']['search_type']['values'][] = array('key' => $sType, 'value' => _t('_adm_form_txt_field_type_' . $sType));
+        $aSearchTypes = BxDolSearchExtended::$TYPE_TO_TYPE_SEARCH[$aField['type']];
+        if(is_array($aSearchTypes) && count($aSearchTypes) >= 2) {
+            $aForm['inputs'] = bx_array_insert_before(array(
+            	'search_type' => array(
+                    'type' => 'select',
+                    'name' => 'search_type',
+                    'caption' => _t('_adm_form_txt_search_forms_fields_search_type'),
+                    'info' => _t('_adm_form_dsc_search_forms_fields_search_type'),
+                    'values' => array(),
+                    'value' => $aField['search_type'],
+                    'required' => '1',
+                    'db' => array (
+                        'pass' => 'Xss',
+                    ),
+                    'checker' => array (
+                        'func' => 'Avail',
+                        'params' => array(),
+                        'error' => _t('_adm_form_err_search_forms_essential'),
+                    ),
+                )), $aForm['inputs'], 'controls');
+
+            foreach($aSearchTypes as $sType)
+                $aForm['inputs']['search_type']['values'][] = array('key' => $sType, 'value' => _t('_adm_form_txt_field_type_' . $sType));
+        }
 
         $oForm = new BxTemplStudioFormView($aForm);
         $oForm->initChecker();
@@ -230,18 +255,6 @@ class BxBaseStudioFormsSearchFields extends BxDolStudioFormsSearchFields
         return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
     }
 
-    protected function _getActionEdit ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
-    {
-        if($sType == 'single' && !$this->_isEditable($aRow))
-            return '';
-
-        $aSearchTypes = BxDolSearchExtended::$TYPE_TO_TYPE_SEARCH[$aRow['type']];
-        if(!is_array($aSearchTypes) || count($aSearchTypes) < 2)
-    	    return '';
-
-        return  parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
-    }
-
     protected function _getActionReset ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
     {
         if(!$this->_isResetable($aRow))

+ 1 - 0
template/scripts/BxBaseSearchExtended.php

@@ -151,6 +151,7 @@ class BxBaseSearchExtended extends BxDolSearchExtended
                 'type' => $aField['search_type'],
                 'name' => $aField['name'],
                 'caption' => _t($aField['caption']),
+            	'info' => _t($aField['info']),
                 'values' => $aField['values'],
                 'value' => $aField['search_value'],
                 'db' => array(