Bladeren bron

Ticket #5267 - Profile badge: Extend functionality. Persons.

AntonLV 11 maanden geleden
bovenliggende
commit
b3743681e2

+ 49 - 0
modules/base/profile/classes/BxBaseModProfileFormEntry.php

@@ -67,6 +67,35 @@ class BxBaseModProfileFormEntry extends BxBaseModGeneralFormEntry
             ];
             ];
         }
         }
 
 
+        if (($sKey = 'FIELD_BADGE_LINK_SELECT') && !empty($CNF[$sKey]) && isset($this->aInputs[$CNF[$sKey]])) {
+            $oProfile = BxDolProfile::getInstance();
+            $iProfile = $oProfile->id();
+
+            $aValues = [
+                ['key' => '', 'value' => _t('_sys_please_select')]
+            ];
+
+            $aContexts = bx_srv('system', 'get_modules_by_type', ['context']);
+            foreach($aContexts as $aContext) {
+                $aCpIds = bx_srv($aContext['name'], 'get_participating_profiles', [$iProfile]);
+                foreach($aCpIds as $iCpId)
+                    if(($sCpLink = $oProfile->getUrl($iCpId)) && ($sCpName = $oProfile->getDisplayName($iCpId)))
+                        $aValues[] = [
+                            'key' => $sCpLink, 
+                            'value' => $sCpName
+                        ];
+            }
+
+            $this->aInputs[$CNF[$sKey]] = array_merge($this->aInputs[$CNF[$sKey]], [
+                'values' => $aValues
+            ]);
+        }
+
+        if (($sKey = 'FIELD_BADGE_LINK_CUSTOM') && !empty($CNF[$sKey]) && isset($this->aInputs[$CNF[$sKey]])) {
+            if(!empty($this->aInputs[$CNF[$sKey]]['attrs']['placeholder']))
+                $this->aInputs[$CNF[$sKey]]['attrs']['placeholder'] = _t($this->aInputs[$CNF[$sKey]]['attrs']['placeholder']);
+        }
+
         foreach ($this->_aImageFields as $sField => $aParams) {
         foreach ($this->_aImageFields as $sField => $aParams) {
             $this->aInputs[$sField]['storage_object'] = $aParams['storage_object'];
             $this->aInputs[$sField]['storage_object'] = $aParams['storage_object'];
             $this->aInputs[$sField]['uploaders'] = !empty($this->aInputs[$sField]['value']) ? unserialize($this->aInputs[$sField]['value']) : $aParams['uploaders'];
             $this->aInputs[$sField]['uploaders'] = !empty($this->aInputs[$sField]['value']) ? unserialize($this->aInputs[$sField]['value']) : $aParams['uploaders'];
@@ -114,6 +143,22 @@ class BxBaseModProfileFormEntry extends BxBaseModGeneralFormEntry
 
 
         if(($sField = 'FIELD_STG_TABS') && !empty($CNF[$sField]) && !empty($this->aInputs[$CNF[$sField]]) && is_array($this->aInputs[$CNF[$sField]]) && ($sValue = $this->aInputs[$CNF[$sField]]['value']))
         if(($sField = 'FIELD_STG_TABS') && !empty($CNF[$sField]) && !empty($this->aInputs[$CNF[$sField]]) && is_array($this->aInputs[$CNF[$sField]]) && ($sValue = $this->aInputs[$CNF[$sField]]['value']))
             $this->aInputs[$CNF[$sField]]['value'] = !is_array($sValue) ? explode(',', $sValue) : [];
             $this->aInputs[$CNF[$sField]]['value'] = !is_array($sValue) ? explode(',', $sValue) : [];
+
+        if(($sDisplay = 'OBJECT_FORM_ENTRY_DISPLAY_EDIT_BADGE') && !empty($CNF[$sDisplay]) && $this->aParams['display'] == $CNF[$sDisplay]) {
+            $sBadgeLink = $aContentInfo[$CNF['FIELD_BADGE_LINK']] ?? '';
+
+            $bFilledIn = false;
+            if(($sKey = 'FIELD_BADGE_LINK_SELECT') && !empty($CNF[$sKey]) && isset($this->aInputs[$CNF[$sKey]]))
+                foreach($this->aInputs[$CNF[$sKey]]['values'] as $aValue)
+                    if($aValue['key'] == $sBadgeLink) {
+                        $this->aInputs[$CNF[$sKey]]['value'] = $sBadgeLink;
+                        $bFilledIn = true;
+                        break;
+                    }
+    
+            if(!$bFilledIn && ($sKey = 'FIELD_BADGE_LINK_CUSTOM') && !empty($CNF[$sKey]) && isset($this->aInputs[$CNF[$sKey]]))
+                $this->aInputs[$CNF[$sKey]]['value'] = $sBadgeLink;
+        }
     }
     }
 
 
     function update ($iContentId, $aValsToAdd = array(), &$aTrackTextFieldsChanges = null)
     function update ($iContentId, $aValsToAdd = array(), &$aTrackTextFieldsChanges = null)
@@ -126,6 +171,10 @@ class BxBaseModProfileFormEntry extends BxBaseModGeneralFormEntry
                 self::setSubmittedValue($CNF[$sField], implode(',', $mixedValue), $this->aFormAttrs['method']);
                 self::setSubmittedValue($CNF[$sField], implode(',', $mixedValue), $this->aFormAttrs['method']);
         }
         }
 
 
+        if((($sFldS = 'FIELD_BADGE_LINK_SELECT') && !empty($CNF[$sFldS]) && ($sValS = $this->getCleanValue($CNF[$sFldS]))) || (($sFldC = 'FIELD_BADGE_LINK_CUSTOM') && !empty($CNF[$sFldC]) && ($sValC = $this->getCleanValue($CNF[$sFldC])))) {
+            $aValsToAdd[$CNF['FIELD_BADGE_LINK']] = $sValS ?: ($sValC ?: '');
+        }
+
         return parent::update($iContentId, $aValsToAdd, $aTrackTextFieldsChanges);
         return parent::update($iContentId, $aValsToAdd, $aTrackTextFieldsChanges);
     }
     }
 
 

+ 2 - 0
modules/boonex/persons/classes/BxPersonsConfig.php

@@ -52,6 +52,8 @@ class BxPersonsConfig extends BxBaseModProfileConfig
             'FIELD_COVER_POSITION' => 'cover_data',
             'FIELD_COVER_POSITION' => 'cover_data',
             'FIELD_BADGE' => 'badge',
             'FIELD_BADGE' => 'badge',
             'FIELD_BADGE_LINK' => 'badge_link',
             'FIELD_BADGE_LINK' => 'badge_link',
+            'FIELD_BADGE_LINK_SELECT' => 'badge_link_select',
+            'FIELD_BADGE_LINK_CUSTOM' => 'badge_link_custom',
             'FIELD_BIRTHDAY' => 'birthday',
             'FIELD_BIRTHDAY' => 'birthday',
             'FIELD_ALLOW_VIEW_TO' => 'allow_view_to',
             'FIELD_ALLOW_VIEW_TO' => 'allow_view_to',
             'FIELD_ALLOW_POST_TO' => 'allow_post_to',
             'FIELD_ALLOW_POST_TO' => 'allow_post_to',

+ 6 - 2
modules/boonex/persons/install/langs/en.xml

@@ -29,6 +29,7 @@
     <string name="_bx_persons_form_profile_display_add"><![CDATA[Add Person]]></string>
     <string name="_bx_persons_form_profile_display_add"><![CDATA[Add Person]]></string>
     <string name="_bx_persons_form_profile_display_edit"><![CDATA[Edit Person]]></string>
     <string name="_bx_persons_form_profile_display_edit"><![CDATA[Edit Person]]></string>
     <string name="_bx_persons_form_profile_display_edit_cover"><![CDATA[Edit Cover]]></string>
     <string name="_bx_persons_form_profile_display_edit_cover"><![CDATA[Edit Cover]]></string>
+    <string name="_bx_persons_form_profile_display_edit_badge"><![CDATA[Edit Badge]]></string>
     <string name="_bx_persons_form_profile_display_delete"><![CDATA[Delete Person]]></string>
     <string name="_bx_persons_form_profile_display_delete"><![CDATA[Delete Person]]></string>
     <string name="_bx_persons_form_profile_display_view"><![CDATA[View Person]]></string>
     <string name="_bx_persons_form_profile_display_view"><![CDATA[View Person]]></string>
     <string name="_bx_persons_form_profile_display_view_full"><![CDATA[Full View Person]]></string>
     <string name="_bx_persons_form_profile_display_view_full"><![CDATA[Full View Person]]></string>
@@ -56,8 +57,11 @@
     <string name="_bx_persons_form_profile_input_cover"><![CDATA[Upload New Cover Picture]]></string>
     <string name="_bx_persons_form_profile_input_cover"><![CDATA[Upload New Cover Picture]]></string>
     <string name="_bx_persons_form_profile_input_sys_badge"><![CDATA[Badge Image]]></string>
     <string name="_bx_persons_form_profile_input_sys_badge"><![CDATA[Badge Image]]></string>
     <string name="_bx_persons_form_profile_input_badge"><![CDATA[Upload New Badge Image]]></string>
     <string name="_bx_persons_form_profile_input_badge"><![CDATA[Upload New Badge Image]]></string>
-    <string name="_bx_persons_form_profile_input_sys_badge_link"><![CDATA[Badge Link]]></string>
-    <string name="_bx_persons_form_profile_input_badge_link"><![CDATA[Badge Link]]></string>
+    <string name="_bx_persons_form_profile_input_sys_badge_link_custom"><![CDATA[Badge Custom Link]]></string>
+    <string name="_bx_persons_form_profile_input_badge_link_custom"><![CDATA[Badge Custom Link]]></string>
+    <string name="_bx_persons_form_profile_input_badge_link_custom_placeholder"><![CDATA[or enter your own here]]></string>
+    <string name="_bx_persons_form_profile_input_sys_badge_link_select"><![CDATA[Badge Link Select]]></string>
+    <string name="_bx_persons_form_profile_input_badge_link_select"><![CDATA[Badge Link]]></string>
     <string name="_bx_persons_form_profile_input_sys_delete_confirm"><![CDATA[Delete confirmation]]></string>
     <string name="_bx_persons_form_profile_input_sys_delete_confirm"><![CDATA[Delete confirmation]]></string>
     <string name="_bx_persons_form_profile_input_delete_confirm"><![CDATA[I am sure I want to delete this profile]]></string>
     <string name="_bx_persons_form_profile_input_delete_confirm"><![CDATA[I am sure I want to delete this profile]]></string>
     <string name="_bx_persons_form_profile_input_delete_confirm_info"><![CDATA[This action can not be undone.]]></string>
     <string name="_bx_persons_form_profile_input_delete_confirm_info"><![CDATA[This action can not be undone.]]></string>

+ 5 - 3
modules/boonex/persons/install/sql/install.sql

@@ -321,7 +321,8 @@ INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `ch
 ('bx_person', 'bx_persons', 'cover', 'a:1:{i:0;s:21:"bx_persons_cover_crop";}', 'a:1:{s:21:"bx_persons_cover_crop";s:24:"_sys_uploader_crop_title";}', 0, 'files', '_bx_persons_form_profile_input_sys_cover', '_bx_persons_form_profile_input_cover', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0, ''),
 ('bx_person', 'bx_persons', 'cover', 'a:1:{i:0;s:21:"bx_persons_cover_crop";}', 'a:1:{s:21:"bx_persons_cover_crop";s:24:"_sys_uploader_crop_title";}', 0, 'files', '_bx_persons_form_profile_input_sys_cover', '_bx_persons_form_profile_input_cover', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0, ''),
 ('bx_person', 'bx_persons', 'picture', 'a:1:{i:0;s:23:"bx_persons_picture_crop";}', 'a:1:{s:23:"bx_persons_picture_crop";s:24:"_sys_uploader_crop_title";}', 0, 'files', '_bx_persons_form_profile_input_sys_picture', '_bx_persons_form_profile_input_picture', '', 0, 0, 0, '', '', '', '', '', '_bx_persons_form_profile_input_picture_err', '', '', 1, 0, ''),
 ('bx_person', 'bx_persons', 'picture', 'a:1:{i:0;s:23:"bx_persons_picture_crop";}', 'a:1:{s:23:"bx_persons_picture_crop";s:24:"_sys_uploader_crop_title";}', 0, 'files', '_bx_persons_form_profile_input_sys_picture', '_bx_persons_form_profile_input_picture', '', 0, 0, 0, '', '', '', '', '', '_bx_persons_form_profile_input_picture_err', '', '', 1, 0, ''),
 ('bx_person', 'bx_persons', 'badge', 'a:1:{i:0;s:21:"bx_persons_badge_crop";}', 'a:1:{s:21:"bx_persons_badge_crop";s:24:"_sys_uploader_crop_title";}', 0, 'files', '_bx_persons_form_profile_input_sys_badge', '_bx_persons_form_profile_input_badge', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0, ''),
 ('bx_person', 'bx_persons', 'badge', 'a:1:{i:0;s:21:"bx_persons_badge_crop";}', 'a:1:{s:21:"bx_persons_badge_crop";s:24:"_sys_uploader_crop_title";}', 0, 'files', '_bx_persons_form_profile_input_sys_badge', '_bx_persons_form_profile_input_badge', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0, ''),
-('bx_person', 'bx_persons', 'badge_link', '', '', 0, 'text', '_bx_persons_form_profile_input_sys_badge_link', '_bx_persons_form_profile_input_badge_link', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 1, 0, ''),
+('bx_person', 'bx_persons', 'badge_link_select', '', '', 0, 'select', '_bx_persons_form_profile_input_sys_badge_link_select', '_bx_persons_form_profile_input_badge_link_select', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0, ''),
+('bx_person', 'bx_persons', 'badge_link_custom', '', '', 0, 'text', '_bx_persons_form_profile_input_sys_badge_link_custom', '_bx_persons_form_profile_input_badge_link_custom', '', 0, 0, 0, 'a:1:{s:11:"placeholder";s:60:"_bx_persons_form_profile_input_badge_link_custom_placeholder";}', '', '', '', '', '', '', '', 1, 0, ''),
 ('bx_person', 'bx_persons', 'location', '', '', 0, 'location', '_sys_form_input_sys_location', '_sys_form_input_location', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0, ''),
 ('bx_person', 'bx_persons', 'location', '', '', 0, 'location', '_sys_form_input_sys_location', '_sys_form_input_location', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0, ''),
 ('bx_person', 'bx_persons', 'birthday', '0', '', 0, 'datepicker', '_bx_persons_form_profile_input_sys_birthday', '_bx_persons_form_profile_input_birthday', '', 1, 0, 0, '', '', '', 'date_range', 'a:3:{s:3:"min";i:18;s:3:"max";i:99;s:8:"required";b:0;}', '_bx_persons_form_profile_input_birthday_err', 'Date', '', 1, 0, ''),
 ('bx_person', 'bx_persons', 'birthday', '0', '', 0, 'datepicker', '_bx_persons_form_profile_input_sys_birthday', '_bx_persons_form_profile_input_birthday', '', 1, 0, 0, '', '', '', 'date_range', 'a:3:{s:3:"min";i:18;s:3:"max";i:99;s:8:"required";b:0;}', '_bx_persons_form_profile_input_birthday_err', 'Date', '', 1, 0, ''),
 ('bx_person', 'bx_persons', 'gender', '', '#!Sex', 0, 'select', '_bx_persons_form_profile_input_sys_gender', '_bx_persons_form_profile_input_gender', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 1, 0, ''),
 ('bx_person', 'bx_persons', 'gender', '', '#!Sex', 0, 'select', '_bx_persons_form_profile_input_sys_gender', '_bx_persons_form_profile_input_gender', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 1, 0, ''),
@@ -378,8 +379,9 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_person_edit_cover', 'do_submit', 2147483647, 1, 8),
 ('bx_person_edit_cover', 'do_submit', 2147483647, 1, 8),
 
 
 ('bx_person_edit_badge', 'badge', 2147483647, 1, 1),
 ('bx_person_edit_badge', 'badge', 2147483647, 1, 1),
-('bx_person_edit_badge', 'badge_link', 2147483647, 1, 2),
-('bx_person_edit_badge', 'do_submit', 2147483647, 1, 3),
+('bx_person_edit_badge', 'badge_link_select', 2147483647, 1, 2),
+('bx_person_edit_badge', 'badge_link_custom', 2147483647, 0, 3),
+('bx_person_edit_badge', 'do_submit', 2147483647, 1, 4),
 
 
 ('bx_person_view', 'gender', 2147483647, 1, 1),
 ('bx_person_view', 'gender', 2147483647, 1, 1),
 ('bx_person_view', 'birthday', 2147483647, 1, 2),
 ('bx_person_view', 'birthday', 2147483647, 1, 2),

+ 6 - 2
modules/boonex/russian/data/langs/bx_persons/ru.xml

@@ -28,6 +28,7 @@
     <string name="_bx_persons_form_profile_display_add"><![CDATA[Добавление персоны]]></string>
     <string name="_bx_persons_form_profile_display_add"><![CDATA[Добавление персоны]]></string>
     <string name="_bx_persons_form_profile_display_edit"><![CDATA[Редактирование персоны]]></string>
     <string name="_bx_persons_form_profile_display_edit"><![CDATA[Редактирование персоны]]></string>
     <string name="_bx_persons_form_profile_display_edit_cover"><![CDATA[Редактирование обложки]]></string>
     <string name="_bx_persons_form_profile_display_edit_cover"><![CDATA[Редактирование обложки]]></string>
+    <string name="_bx_persons_form_profile_display_edit_badge"><![CDATA[Редактирование значка]]></string>
     <string name="_bx_persons_form_profile_display_delete"><![CDATA[Удаление персоны]]></string>
     <string name="_bx_persons_form_profile_display_delete"><![CDATA[Удаление персоны]]></string>
     <string name="_bx_persons_form_profile_display_view"><![CDATA[Просмотр персоны]]></string>
     <string name="_bx_persons_form_profile_display_view"><![CDATA[Просмотр персоны]]></string>
     <string name="_bx_persons_form_profile_display_view_full"><![CDATA[Полный просмотр персоны]]></string>
     <string name="_bx_persons_form_profile_display_view_full"><![CDATA[Полный просмотр персоны]]></string>
@@ -53,8 +54,11 @@
     <string name="_bx_persons_form_profile_input_cover"><![CDATA[Загрузить новую картинку обложки]]></string>
     <string name="_bx_persons_form_profile_input_cover"><![CDATA[Загрузить новую картинку обложки]]></string>
     <string name="_bx_persons_form_profile_input_sys_badge"><![CDATA[Изображение значка]]></string>
     <string name="_bx_persons_form_profile_input_sys_badge"><![CDATA[Изображение значка]]></string>
     <string name="_bx_persons_form_profile_input_badge"><![CDATA[Загрузить новое изображение значка]]></string>
     <string name="_bx_persons_form_profile_input_badge"><![CDATA[Загрузить новое изображение значка]]></string>
-    <string name="_bx_persons_form_profile_input_sys_badge_link"><![CDATA[Ссылка значка]]></string>
-    <string name="_bx_persons_form_profile_input_badge_link"><![CDATA[Ссылка значка]]></string>
+    <string name="_bx_persons_form_profile_input_sys_badge_link_custom"><![CDATA[Пользовательская ссылка значка]]></string>
+    <string name="_bx_persons_form_profile_input_badge_link_custom"><![CDATA[Пользовательская ссылка для значка]]></string>
+    <string name="_bx_persons_form_profile_input_badge_link_custom_placeholder"><![CDATA[или введите свою собственную здесь]]></string>
+    <string name="_bx_persons_form_profile_input_sys_badge_link_select"><![CDATA[Выбор ссылки значка]]></string>
+    <string name="_bx_persons_form_profile_input_badge_link_select"><![CDATA[Ссылка для значка]]></string>
     <string name="_bx_persons_form_profile_input_sys_delete_confirm"><![CDATA[Удалить подтверждение]]></string>
     <string name="_bx_persons_form_profile_input_sys_delete_confirm"><![CDATA[Удалить подтверждение]]></string>
     <string name="_bx_persons_form_profile_input_delete_confirm"><![CDATA[Я уверен, что хочу удалить этот профиль]]></string>
     <string name="_bx_persons_form_profile_input_delete_confirm"><![CDATA[Я уверен, что хочу удалить этот профиль]]></string>
     <string name="_bx_persons_form_profile_input_delete_confirm_info"><![CDATA[Это действие не может быть отменено.]]></string>
     <string name="_bx_persons_form_profile_input_delete_confirm_info"><![CDATA[Это действие не может быть отменено.]]></string>