AntonLV 9 лет назад
Родитель
Сommit
78127edd91

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

@@ -1871,6 +1871,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_form_forgot_password_input_caption_system_email"><![CDATA[Email]]></string>
 	<string name="_sys_form_forgot_password_input_email"><![CDATA[Email]]></string>
 	<string name="_sys_form_forgot_password_input_submit"><![CDATA[Submit]]></string>
+	<string name="_sys_form_input_age"><![CDATA[Age]]></string>
 	<string name="_sys_form_input_sys_location"><![CDATA[Location]]></string>
 	<string name="_sys_form_input_location"><![CDATA[Location]]></string>
 	<string name="_sys_form_login"><![CDATA[Log in]]></string>

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

@@ -1869,6 +1869,7 @@
 	<string name="_sys_form_forgot_password_input_caption_system_email"><![CDATA[Имейл]]></string>
 	<string name="_sys_form_forgot_password_input_email"><![CDATA[Имейл]]></string>
 	<string name="_sys_form_forgot_password_input_submit"><![CDATA[Выполнить]]></string>
+	<string name="_sys_form_input_age"><![CDATA[Возраст]]></string>
 	<string name="_sys_form_input_sys_location"><![CDATA[Расположение]]></string>
 	<string name="_sys_form_input_location"><![CDATA[Расположение]]></string>
 	<string name="_sys_form_login"><![CDATA[Вход]]></string>

+ 42 - 1
template/scripts/BxBaseFormView.php

@@ -52,6 +52,11 @@ class BxBaseFormView extends BxDolForm
      */
     protected $_bDynamicMode = false;
 
+    /**
+     * Form is displayed in view mode.
+     */
+    protected $_bViewMode = false;
+
     /**
      * Function name for generation close form section HTML.
      */
@@ -77,7 +82,9 @@ class BxBaseFormView extends BxDolForm
     {
         parent::__construct($aInfo, $oTemplate);
 
-        if (isset($this->aParams['view_mode']) && $this->aParams['view_mode']) {
+        $this->_bViewMode = isset($this->aParams['view_mode']) && $this->aParams['view_mode'];
+
+        if ($this->_bViewMode) {
             $this->_sSectionClose = 'getCloseSectionViewMode';
             $this->_sSectionOpen = 'getOpenSectionViewMode';
         }
@@ -380,6 +387,40 @@ EOS;
         return $s;
     }
 
+    protected function genCustomRowBirthday(&$aInput)
+    {
+        if(!$this->_bViewMode)
+            return $this->genRowStandard($aInput);
+
+        $aInput['caption_src'] = '_sys_form_input_age';
+        $aInput['caption'] = _t($aInput['caption_src']);
+        return $this->genViewRowWrapped($aInput);
+    }
+
+    protected function genCustomViewRowValueBirthday(&$aInput)
+    {
+        if(!isset($aInput['value']) || !$aInput['value'])
+            return null;
+
+        $sValue = $aInput['value'];
+
+        $iPosSpace = strpos($sValue, ' ');
+        if($iPosSpace !== false)
+            $sValue = trim(substr($sValue, 0, $iPosSpace));
+
+        $aDate = explode('-', $sValue);
+
+        $iCdYear = (int)date('Y');
+        $iCdMonth = (int)date('n');
+        $iCdDay = (int)date('j');
+
+        $iResult = $iCdYear - (int)$aDate[0];
+        if($iCdMonth < (int)$aDate[1] || ($iCdMonth == (int)$aDate[1] && $iCdDay < (int)$aDate[2]))
+            $iResult -= 1;           
+
+        return $iResult;
+    }
+
     /**
      * Generate standard row
      *