Procházet zdrojové kódy

#3327 - Spaces: add 'template' parameter for 'serviceEntityChilds' and 'serviceEntityParent' methods

RomanL před 4 roky
rodič
revize
dd035b7d86

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

@@ -2851,8 +2851,10 @@ class BxBaseModGeneralModule extends BxDolModule
 
         list($iContentId, $aContentInfo) = $mixedContent;
 
-        if (isset($aParams['template_name']) && !empty($aParams['template_name']))
-            return $this->_oTemplate->$sFunc($aContentInfo, array('template_name' => $aParams['template_name']));
+        unset($aParams['function_get_content']);
+        
+        if (!empty($aParams))
+            return $this->_oTemplate->$sFunc($aContentInfo, $aParams);
         else
             return $this->_oTemplate->$sFunc($aContentInfo);
     }

+ 4 - 6
modules/boonex/channels/classes/BxCnlModule.php

@@ -202,16 +202,15 @@ class BxCnlModule extends BxBaseModGroupsModule
      * 
      * Display block with parent channel
      * @param $iContentId channel content ID
-     * @param $sTemplateName html template name
      * 
      * @see BxCnlModule::serviceEntityParent
      */
     /** 
      * @ref bx_channels-entity_parent "entity_parent"
      */
-    public function serviceEntityParent($iContentId = 0, $sTemplateName = '')
+    public function serviceEntityParent($iContentId = 0)
     {
-        return $this->_serviceTemplateFuncEx('entryParent', $iContentId, array('template_name' =>$sTemplateName));
+        return $this->_serviceTemplateFunc('entryParent', $iContentId);
     }
 
     /**
@@ -224,16 +223,15 @@ class BxCnlModule extends BxBaseModGroupsModule
      * 
      * Display block with child channels
      * @param $iContentId channel content ID
-     * @param $sTemplateName html template name
      * 
      * @see BxCnlModule::serviceEntityChilds
      */
     /** 
      * @ref bx_channels-entity_childs "entity_childs"
      */
-    public function serviceEntityChilds($iContentId = 0, $sTemplateName = '')
+    public function serviceEntityChilds($iContentId = 0)
     {
-        return $this->_serviceTemplateFuncEx('entryChilds', $iContentId, array('template_name' =>$sTemplateName));
+        return $this->_serviceTemplateFunc('entryChilds', $iContentId);
     }
 
     /**

+ 4 - 4
modules/boonex/spaces/classes/BxSpacesModule.php

@@ -42,14 +42,14 @@ class BxSpacesModule extends BxBaseModGroupsModule
         return $this->_serviceEntityForm ('deleteDataForm', $iContentId);
     }
     
-    public function serviceEntityParent ($iContentId = 0)
+    public function serviceEntityParent ($iContentId = 0, $aParams = [])
     {
-        return $this->_serviceTemplateFunc ('entryParent', $iContentId);
+        return $this->_serviceTemplateFuncEx ('entryParent', $iContentId, $aParams);
     }
     
-    public function serviceEntityChilds ($iContentId = 0)
+    public function serviceEntityChilds ($iContentId = 0, $aParams = [])
     {
-        return $this->_serviceTemplateFunc ('entryChilds', $iContentId);
+        return $this->_serviceTemplateFuncEx ('entryChilds', $iContentId, $aParams);
     }
     
     public function serviceBrowseTopLevel ($bDisplayEmptyMsg = false)

+ 11 - 12
modules/boonex/spaces/classes/BxSpacesTemplate.php

@@ -28,32 +28,31 @@ class BxSpacesTemplate extends BxBaseModGroupsTemplate
         if (count($aChild) == 0)
             return false;
         
-        if (!isset($aParams['template_name']))
-            $aParams['template_name'] = 'entry-childs.html';
-
-        return $this->parseHtmlByName($aParams['template_name'], array('content' => $this->getBrowseQuick($aChild)));
+        if (!isset($aParams['template']))
+            $aParams['template'] = 'unit_wo_cover';
+        
+        return $this->parseHtmlByName('entry-childs.html', array('content' => $this->getBrowseQuick($aChild, $aParams['template'])));
     }
     
-    public function entryParent($aData)
+    public function entryParent($aData, $aParams = array())
     {
         $CNF = $this->_oConfig->CNF;
         if ($aData[$CNF['FIELD_PARENT']] == 0)
             return false;
-        
-        if (!isset($aParams['template_name']))
-            $aParams['template_name'] = 'entry-parent.html';
-        
-        return $this->parseHtmlByName($aParams['template_name'], array('content' => $this->getBrowseQuick(array($aData[$CNF['FIELD_PARENT']]))));
+
+        if (!isset($aParams['template']))
+            $aParams['template'] = 'unit_wo_cover';
+        return $this->parseHtmlByName('entry-parent.html', array('content' => $this->getBrowseQuick(array($aData[$CNF['FIELD_PARENT']]), $aParams['template'])));
     }
     
-    private function getBrowseQuick($aProfiles)
+    private function getBrowseQuick($aProfiles, $sTemplate = 'unit_wo_cover')
     {
         $sRv = '';
         foreach ($aProfiles as $iProfileId) {
             $oProfile = BxDolProfile::getInstance($iProfileId);
             if(!$oProfile)
                 continue;
-            $sRv .= $oProfile->getUnit(false, array('template' => 'unit_wo_cover'));
+            $sRv .= $oProfile->getUnit(false, array('template' => $sTemplate));
         }
         return $sRv;
     }