Просмотр исходного кода

Merge branch 'master' of https://github.com/unaio/una

AntonLV 2 лет назад
Родитель
Сommit
d76014cd4a

+ 14 - 1
modules/boonex/invites/classes/BxInvModule.php

@@ -179,11 +179,20 @@ class BxInvModule extends BxDolModule
         $oForm = $this->getFormObjectInvite();
         $oForm->aInputs['text']['value'] = _t('_bx_invites_msg_invitation');
 
+       
+        
         $sResult = '';
         $oForm->initChecker();
-        if($oForm->isSubmittedAndValid())
+        if($oForm->isSubmittedAndValid()){
             $sResult = MsgBox($this->processFormObjectInvite($oForm));
+            if (bx_is_api()){
+                return [bx_api_get_msg($sResult)];
+            }
+        }
 
+        if (bx_is_api())
+            return [bx_api_get_block('form', $oForm->getCodeAPI(), ['ext' => ['name' => $this->getName(), 'request' => ['url' => '/api.php?r=' . $this->getName() . '/get_block_form_invite', 'immutable' => true]]])];
+        
         return [
             'content' => $sResult . $oForm->getCode()
         ];
@@ -209,6 +218,10 @@ class BxInvModule extends BxDolModule
     public function serviceGetBlockFormRequest()
     {
         $mixedResult = $this->_oTemplate->getBlockFormRequest();
+        
+        if (bx_is_api())
+            return $mixedResult;
+        
         if(is_array($mixedResult)) {
             echoJson($mixedResult);
             exit;

+ 8 - 8
modules/boonex/invites/classes/BxInvTemplate.php

@@ -116,11 +116,11 @@ class BxInvTemplate extends BxBaseModGeneralTemplate
     public function getBlockFormRequest()
     {
         if(!$this->_oConfig->isRequestInvite())
-            return MsgBox(_t('_bx_invites_err_not_available'));
+            return bx_is_api() ? [bx_api_get_msg(_t('_bx_invites_err_not_available'))] : MsgBox(_t('_bx_invites_err_not_available'));
 
         $mixedAllowed = $this->getModule()->isAllowedRequest(0);
         if($mixedAllowed !== true)
-            return MsgBox($mixedAllowed);
+            return bx_is_api() ? [bx_api_get_msg($mixedAllowed)] : MsgBox($mixedAllowed);
 
         $CNF = &$this->_oConfig->CNF;
 
@@ -138,7 +138,7 @@ class BxInvTemplate extends BxBaseModGeneralTemplate
             $sForm = $oForm->getCode();
             if(!$oForm->isSubmitted()) {
                 $this->getCssJs();
-                return $this->parseHtmlByName('block_request_form.html', array(
+                return bx_is_api() ? [bx_api_get_block('form', $oForm->getCodeAPI(), ['ext' => ['name' => $this->getName(), 'request' => ['url' => '/api.php?r=' . $this->_oModule->getName() . '/get_block_form_request', 'immutable' => true]]])] : $this->parseHtmlByName('block_request_form.html', array(
                     'style_prefix' => $this->_oConfig->getPrefix('style'),
                     'js_object' => $sJsObject,
                     'js_code' => $this->getJsCode('main'),
@@ -148,22 +148,22 @@ class BxInvTemplate extends BxBaseModGeneralTemplate
             }
 
             if(!$oForm->isValid())
-                return array('content' => $sForm, 'content_id' => $sFormId, 'eval' => $sEval);
+                return bx_is_api() ? [bx_api_get_block('form', $oForm->getCodeAPI(), ['ext' => ['name' => $this->getName(), 'request' => ['url' => '/api.php?r=' . $this->_oModule->getName() . '/get_block_form_request', 'immutable' => true]]])] : array('content' => $sForm, 'content_id' => $sFormId, 'eval' => $sEval);
         }
         
         $sEmail = $oForm->getCleanValue('email');
         $oAccountQuery = BxDolAccountQuery::getInstance();
         $iAccount = $oAccountQuery->getIdByEmail($sEmail);
         if ($iAccount > 0)
-            return array('content' => MsgBox(_t('_bx_invites_err_already_registed', bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=forgot-password')))), 'content_id' => $sFormId, 'eval' => $sEval);
+            return bx_is_api() ? [bx_api_get_msg(_t('_bx_invites_err_already_registed', bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=forgot-password'))))] : array('content' => MsgBox(_t('_bx_invites_err_already_registed', bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=forgot-password')))), 'content_id' => $sFormId, 'eval' => $sEval);
         $iCountByEmail = $this->_oDb->getRequests(array('type' => 'count_by_email', 'value' => $sEmail));
         if ($iCountByEmail > 0)
-            return array('content' => MsgBox(_t('_bx_invites_err_already_send')), 'content_id' => $sFormId, 'eval' => $sEval);
+            return  bx_is_api() ? [bx_api_get_msg(_t('_bx_invites_err_already_send'))] : array('content' => MsgBox(_t('_bx_invites_err_already_send')), 'content_id' => $sFormId, 'eval' => $sEval);
        
         $sIp = getVisitorIP();
         $iId = (int)$oForm->insert(array('nip' => ip2long($sIp),'date' => time()));
         if(!$iId)
-            return array('content' => MsgBox(_t('_bx_invites_err_cannot_perform')), 'content_id' => $sFormId, 'eval' => $sEval);
+            return bx_is_api() ? [bx_api_get_msg(_t('_bx_invites_err_cannot_perform'))] : array('content' => MsgBox(_t('_bx_invites_err_cannot_perform')), 'content_id' => $sFormId, 'eval' => $sEval);
         $this->getModule()->onRequest($iId);
         $sRequestsEmail = $this->_oConfig->getRequestsEmail();
         if(!empty($sRequestsEmail)) {
@@ -182,7 +182,7 @@ class BxInvTemplate extends BxBaseModGeneralTemplate
             }
         }
 
-        return array('content' => MsgBox(_t('_bx_invites_msg_request_sent')), 'content_id' => $sFormId, 'eval' => $sEval);
+        return bx_is_api() ? [bx_api_get_msg(_t('_bx_invites_msg_request_sent'))] : array('content' => MsgBox(_t('_bx_invites_msg_request_sent')), 'content_id' => $sFormId, 'eval' => $sEval);
     }
 
     public function getLinkPopup($sLink)

+ 1 - 1
template/scripts/BxBaseEmbedIframely.php

@@ -72,7 +72,7 @@ class BxBaseEmbedIframely extends BxDolEmbed
     
     public function getDataFromApi ($sUrl, $sTheme)
     {
-        return bx_file_get_contents("https://iframe.ly/api/oembed?theme=" . $sTheme . "&url=" . $sUrl . "&api_key=" . getParam('sys_iframely_api_key'));
+        return bx_file_get_contents("https://iframe.ly/api/oembed?theme=" . $sTheme . "&url=" . $sUrl . "&api_key=" . getParam('sys_iframely_api_key') . "&card=small");
     }
     
     public function getDataHtml ($sUrl, $sTheme)

+ 31 - 21
template/scripts/BxBaseFormView.php

@@ -355,32 +355,42 @@ class BxBaseFormView extends BxDolForm
             $this->genForm();
         
         // TODO: process inputs to translate titles, alerts, etc
+        $keysToRemove = [];
         
         foreach ($this->aInputs as &$aInput) {
-            if (isset($aInput['type']) && 'files' == $aInput['type']){
-                $oStorage = BxDolStorage::getObjectInstance($aInput['storage_object']);
-                $aInput['ext_allow'] = $oStorage->getObjectData()['ext_allow'];
-                $aInput['ext_deny'] = $oStorage->getObjectData()['ext_deny'];
-                $aInput['ghost_template'] = '';
-                $aInput['value'] = '';
-                $aInput['values'] = '';
-                $aInput['values_src'] = '';
-            }
-            
-            if (isset($aInput['type']) && 'location' == $aInput['type']){
-                $aLocationIndexes = BxDolForm::$LOCATION_INDEXES;
-                $aVars = [];
-                $o = BxDolLocationField::getObjectInstance(getParam('sys_location_field_default'));
-                foreach ($aLocationIndexes as $sKey)
-                    $aVars[$sKey] = $o->getLocationVal($aInput, $sKey, $this);
-                if ($aVars['country']) {
-                    $aCountries = BxDolFormQuery::getDataItems('Country');
-                    $sLocationString = ($aVars['street_number'] ? $aVars['street_number'] . ', ' : '') . ($aVars['street'] ? $aVars['street'] . ', ' : '') . ($aVars['city'] ? $aVars['city'] . ', ' : '') . ($aVars['state'] ? $aVars['state'] . ', ' : '') . $aCountries[$aVars['country']];
-                    $aVars['location_string'] = $sLocationString;
+            if (!isset($aInput['visible_for_levels']) || self::isVisible($aInput)) {
+                if (isset($aInput['type']) && 'files' == $aInput['type']){
+                    $oStorage = BxDolStorage::getObjectInstance($aInput['storage_object']);
+                    $aInput['ext_allow'] = $oStorage->getObjectData()['ext_allow'];
+                    $aInput['ext_deny'] = $oStorage->getObjectData()['ext_deny'];
+                    $aInput['ghost_template'] = '';
+                    $aInput['value'] = '';
+                    $aInput['values'] = '';
+                    $aInput['values_src'] = '';
                 }
-                $aInput['value'] = $aVars;
+
+                if (isset($aInput['type']) && 'location' == $aInput['type']){
+                    $aLocationIndexes = BxDolForm::$LOCATION_INDEXES;
+                    $aVars = [];
+                    $o = BxDolLocationField::getObjectInstance(getParam('sys_location_field_default'));
+                    foreach ($aLocationIndexes as $sKey)
+                        $aVars[$sKey] = $o->getLocationVal($aInput, $sKey, $this);
+                    if ($aVars['country']) {
+                        $aCountries = BxDolFormQuery::getDataItems('Country');
+                        $sLocationString = ($aVars['street_number'] ? $aVars['street_number'] . ', ' : '') . ($aVars['street'] ? $aVars['street'] . ', ' : '') . ($aVars['city'] ? $aVars['city'] . ', ' : '') . ($aVars['state'] ? $aVars['state'] . ', ' : '') . $aCountries[$aVars['country']];
+                        $aVars['location_string'] = $sLocationString;
+                    }
+                    $aInput['value'] = $aVars;
+                }
+            }
+            else{
+                $keysToRemove[] = $key;
             }
         }
+        
+        foreach ($keysToRemove as $key) {
+            unset($this->aInputs[$key]);
+        }
     
         return ['inputs' => $this->aInputs, 'attrs' => $this->aFormAttrs, 'params' => $this->aParams];
     }