RomanL 7 ani în urmă
părinte
comite
18dec321cd

+ 8 - 7
modules/base/text/classes/BxBaseModTextFormEntry.php

@@ -180,7 +180,8 @@ class BxBaseModTextFormEntry extends BxBaseModGeneralFormEntry
         $sJsObject = $this->_oModule->_oConfig->getJsObject('categories');
 		$aValuesForSelect = BxDolCategories::getInstance()->getData(array('type' => 'by_module_and_author', 'module' => $this->_oModule->getName(), 'author' => bx_get_logged_profile_id()));
    
-        $aSelectedItems = array();        
+        $aSelectedItems = array();
+		$aInput['value'] = array_filter($aInput['value']);
         if(!empty($aInput['value'])) {
             if (!is_array($aInput['value']))
                 $aValues = BxDolCategories::getInstance()->getData(array('type' => 'by_module_and_object', 'module' => $this->_oModule->getName(), 'object_id' => (!empty($aInput['content_id']) ? (int)$aInput['content_id'] : 0 )));
@@ -199,8 +200,10 @@ class BxBaseModTextFormEntry extends BxBaseModGeneralFormEntry
             }
         }
         else{
-            $aSelectedItems = array();
-        } 
+            $aSelectedItems = array(
+                array('js_object' => $sJsObject, 'select_cat' => $this->genCustomInputMulticatSelect($aInput, $aValuesForSelect))
+            );
+        }
         return $this->_oModule->_oTemplate->parseHtmlByName('form_categories.html', array(
             'bx_repeat:items' => $aSelectedItems,
             'js_object' => $sJsObject, 
@@ -236,11 +239,10 @@ class BxBaseModTextFormEntry extends BxBaseModGeneralFormEntry
     
     protected function genCustomInputMulticatButton($aInput)
     {
-        $CNF = &$this->_oModule->_oConfig->CNF;
         $sName = $aInput['name'];
         $aInput['type'] = 'button';
         $aInput['name'] .= '_add';
-        $aInput['value'] = _t($CNF['T']['txt_multicat_button_caption_add']);
+        $aInput['value'] = _t('_sys_txt_categories_button_caption_add');
         $aInput['attrs']['class'] = 'bx-def-margin-right bx-def-margin-sec-top';
         $aInput['attrs']['onclick'] = $this->_oModule->_oConfig->getJsObject('categories') . ".categoryAdd(this, '" . $sName . "');";
         return $this->genInputButton($aInput);
@@ -248,11 +250,10 @@ class BxBaseModTextFormEntry extends BxBaseModGeneralFormEntry
     
     protected function genCustomInputMulticatButtonNew($aInput)
     {
-        $CNF = &$this->_oModule->_oConfig->CNF;
         $sName = $aInput['name'];
         $aInput['type'] = 'button';
         $aInput['name'] .= '_add';
-        $aInput['value'] = _t($CNF['T']['txt_multicat_button_caption_addnew']);
+        $aInput['value'] = _t('_sys_txt_categories_button_caption_addnew');
         $aInput['attrs']['class'] = 'bx-def-margin-sec-top';
         $aInput['attrs']['onclick'] = $this->_oModule->_oConfig->getJsObject('categories') . ".categoryAddNew(this, '" . $sName . "');";
         return $this->genInputButton($aInput);

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

@@ -2782,7 +2782,9 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_txt_account_unconfirmed_phone"><![CDATA[Your phone is unconfirmed. Please, confirm it on <a href="{0}">verification page</a>.]]></string>
 	<string name="_sys_txt_account_profile_system"><![CDATA[Please <a href="{0}">create a profile</a> to start using the site.]]></string>
 	<string name="_sys_txt_captcha_not_available"><![CDATA[CAPTCHA not available]]></string>
-    <string name="_sys_txt_change_image"><![CDATA[Change Picture]]></string>
+  <string name="_sys_txt_categories_button_caption_add"><![CDATA[Add]]></string>
+  <string name="_sys_txt_categories_button_caption_addnew"><![CDATA[Create own category]]></string>
+  <string name="_sys_txt_change_image"><![CDATA[Change Picture]]></string>
     <string name="_sys_txt_cmt_loading"><![CDATA[Loading...]]></string>
 	<string name="_sys_txt_confirm_email_already_confirmed"><![CDATA[Your email address is already confirmed.]]></string>
 	<string name="_sys_txt_confirm_email_desc"><![CDATA[Please enter confirmation code which was sent to your email address, or just click confirmation link in the same email message.]]></string>

+ 1 - 3
modules/boonex/posts/classes/BxPostsConfig.php

@@ -190,9 +190,7 @@ class BxPostsConfig extends BxBaseModTextConfig
                 'txt_poll_menu_view_' => '_bx_posts_txt_poll_view_',
                 'txt_poll_answer_vote_do_by' => '_bx_posts_txt_poll_answer_vote_do_by',
                 'txt_poll_answer_vote_counter' => '_bx_posts_txt_poll_answer_vote_counter',
-                'txt_poll_answer_vote_percent' => '_bx_posts_txt_poll_answer_vote_percent',
-                'txt_multicat_button_caption_add' => '_bx_posts_form_entry_input_category_add',
-                'txt_multicat_button_caption_addnew' => '_bx_posts_form_entry_input_category_add_new',
+                'txt_poll_answer_vote_percent' => '_bx_posts_txt_poll_answer_vote_percent'
             ),
         ));
         

+ 0 - 2
modules/boonex/posts/install/langs/en.xml

@@ -32,8 +32,6 @@
     <string name="_bx_posts_form_entry_input_sys_multicat"><![CDATA[Categories]]></string>
     <string name="_bx_posts_form_entry_input_multicat"><![CDATA[Categories]]></string>
     <string name="_bx_posts_form_entry_input_multicat_err"><![CDATA[Please select category]]></string>
-    <string name="_bx_posts_form_entry_input_category_add"><![CDATA[Add]]></string>
-    <string name="_bx_posts_form_entry_input_category_add_new"><![CDATA[Create own category]]></string>
     <string name="_bx_posts_form_entry_input_sys_text"><![CDATA[Text]]></string>
     <string name="_bx_posts_form_entry_input_text"><![CDATA[Text]]></string>
     <string name="_bx_posts_form_entry_input_text_err"><![CDATA[Text field can't be empty]]></string>

+ 18 - 10
studio/template/scripts/BxBaseStudioFormsCategories.php

@@ -14,16 +14,24 @@ class BxStudioFormsCategoriesCheckerHelper extends BxDolFormCheckerHelper
 {
     public function checkAvailUnique($s, $aExclude = array())
     {
-        $aCategory = BxDolCategories::getInstance()->getData(array(
-            'type' => 'value_and_module',
-            'module' => bx_get('module'),
-            'value' => $s
-        ));
-
         if(!is_array($aExclude))
             $aExclude = array($aExclude);
-
-        return empty($aCategory) || !is_array($aCategory) || in_array($aCategory['id'], $aExclude);
+        
+        $aLanguages = BxDolStudioLanguagesUtils::getInstance()->getLanguages();
+        
+        foreach($aLanguages as $sLangName => $sLangTitle) {
+            $sValue = BxDolForm::getSubmittedValue('value' . '-' . $sLangName, BX_DOL_STUDIO_METHOD_DEFAULT);
+            $aCategory = BxDolCategories::getInstance()->getData(array(
+                'type' => 'value_and_module',
+                'module' => bx_get('module'),
+                'value' => $sValue
+            ));
+            $bNoInUsers = empty($aCategory) || !is_array($aCategory) || in_array($aCategory['id'], $aExclude);
+            // also need check uniq in system categories to
+            if(!$bNoInUsers)
+                return false;
+        }
+        return true;
     }
 }
 
@@ -102,7 +110,7 @@ class BxBaseStudioFormsCategories extends BxDolStudioFormsCategories
             echoJson($aRes);
         }
         else {
-            $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-form-categories-edit-popup', _t('_adm_form_txt_labels_edit_popup', $aCategory['value']), $this->_oTemplate->parseHtmlByName('form_add_category.html', array(
+            $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-form-categories-edit-popup', _t('_adm_form_txt_labels_edit_popup', _t($aCategory['value'])), $this->_oTemplate->parseHtmlByName('form_add_category.html', array(
                'form_id' => $oForm->aFormAttrs['id'],
                'form' => $oForm->getCode(true),
                'object' => $this->_sObject,
@@ -212,7 +220,7 @@ class BxBaseStudioFormsCategories extends BxDolStudioFormsCategories
                     ),
                 ),
                 'value' => array(
-                    'type' => 'text',
+                    'type' => 'text_translatable',
                     'name' => 'value',
                     'caption' => _t('_adm_form_txt_categories_value'),
                     'info' => '',