Преглед изворни кода

#5236 Content info: ability to update custom form display

Alex Trofimov пре 1 година
родитељ
комит
d003a388dc

+ 2 - 2
inc/classes/BxDolContentInfo.php

@@ -327,9 +327,9 @@ class BxDolContentInfo extends BxDolFactory implements iBxDolFactoryObject
         return $this->_call('delete_entity', $iContentId);
     }
 
-    public function updateContent ($iContentId, $aValues)
+    public function updateContent ($iContentId, $aValues, $sDisplay = false)
     {
-        return $this->_call('edit_entity', $iContentId, $aValues);
+        return $this->_call('edit_entity', $iContentId, $aValues, $sDisplay);
     }
 
     public function addContent ($aValues)

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

@@ -2213,10 +2213,10 @@ class BxBaseModGeneralModule extends BxDolModule
      * @param $aValues key value pairs to update
      * @return error message or empty string on success
      */
-    public function serviceEditEntity ($iContentId, $aValues)
+    public function serviceEditEntity ($iContentId, $aValues, $sDisplay = false)
     {
         $oFormsHelper = $this->getFormsHelper();
-        return $oFormsHelper->editData($iContentId, $aValues);
+        return $oFormsHelper->editData($iContentId, $aValues, $sDisplay);
     }
 
     /**

+ 8 - 5
template/scripts/BxBaseServiceContent.php

@@ -268,7 +268,7 @@ class BxBaseServiceContent extends BxDol
     /** 
      * @ref bx_system_general_cnt-update "Update content"
      */
-    public function serviceUpdate ($sContentObject, $iContentId, $aValues)
+    public function serviceUpdate ($sContentObject, $iContentId, $aValues, $sDisplay = false)
     {
         if ('sys_account' == $sContentObject) {
             $o = BxDolAccount::getInstance($iContentId);
@@ -289,7 +289,7 @@ class BxBaseServiceContent extends BxDol
         $o = BxDolContentInfo::getObjectInstance($sContentObject);
         if (!$o)
             return false;
-        if ($sErrorMsg = $o->updateContent($iContentId, $aValues))
+        if ($sErrorMsg = $o->updateContent($iContentId, $aValues, $sDisplay))
             return ['code' => 500, 'error' => $sErrorMsg];
         else
             return ['code' => 0];
@@ -443,7 +443,7 @@ class BxBaseServiceContent extends BxDol
     /** 
      * @ref bx_system_general_cnt-replace_file "Replace file"
      */
-    public function serviceReplaceFile ($sContentObject, $iContentId, $sField, $sFileUrl)
+    public function serviceReplaceFile ($sContentObject, $iContentId, $sField, $sFileUrl, $sDisplay = false)
     {
         // some checks
         if (!isLogged())
@@ -453,7 +453,10 @@ class BxBaseServiceContent extends BxDol
         if (!$a)
             return ['code' => 404, 'error' => _t('_sys_txt_not_found')];
 
-        $oForm = bx_srv($sContentObject, 'get_object_form', ['edit']);
+        $aParams = [];
+        if ($sDisplay !== false)
+            $aParams['display'] = $sDisplay;
+        $oForm = bx_srv($sContentObject, 'get_object_form', ['edit', $aParams]);
         if (!$oForm)
             return ['code' => 404, 'error' => _t('_sys_request_module_not_found_cpt')];
 
@@ -477,7 +480,7 @@ class BxBaseServiceContent extends BxDol
             return $a;
 
         // assign uploaded file id to the field
-        return $this->serviceUpdate($sContentObject, $iContentId, [$sField => $iFileId]);
+        return $this->serviceUpdate($sContentObject, $iContentId, [$sField => $iFileId], $sDisplay);
     }
 
     protected function getUserIds($oAccount)