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

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

RomanL пре 7 година
родитељ
комит
a9eb53bc24

+ 12 - 4
inc/classes/BxDolService.php

@@ -103,14 +103,22 @@ class BxDolService extends BxDol
 
         $aParams = array();
         if (!empty($aMatches[2]))
-            $aParams = json_decode($aMatches[2]);
-        if (!$aParams)
-            $aParams = array();
+            $aParams = json_decode($aMatches[2], true);
+        if (null === $aParams)
+            return _t('_sys_macros_malformed');
 
         if (!self::call($a[0], 'is_safe_service', array($a[1])))
             return _t('_sys_macros_unsafe');
 
-        return self::call($a[0], $a[1], $aParams, isset($a[3]) ? $a[3] : 'Module', isset($a[4]) && 'ignore_cache' == $a[4] ? true : false);
+        $mixed = self::call($a[0], $a[1], $aParams, isset($a[3]) ? $a[3] : 'Module', isset($a[4]) && 'ignore_cache' == $a[4] ? true : false);
+
+        if (is_object($mixed))
+            return _t('_sys_macros_output_not_displayable');
+        if (is_array($mixed) && !isset($mixed['content']))
+            return _t('_sys_macros_output_not_displayable');
+        if (is_array($mixed) && isset($mixed['content']))
+            return $mixed['content'];
+        return $mixed;
     }
 
     /**

+ 2 - 2
inc/utils.inc.php

@@ -241,7 +241,7 @@ function bx_process_output ($mixedData, $iDataType = BX_DATA_TEXT, $mixedParams
 
 function bx_is_macros_in_content (&$s) 
 {
-    return false === strpos($s, '{{!') ? false : true; 
+    return false === strpos($s, '{{~') ? false : true; 
 }
 
 /**
@@ -265,7 +265,7 @@ function bx_process_macros ($s)
         return $s;
 
     return preg_replace_callback(
-        "/{{!(.*?)}}/", 
+        "/{{\~(.*?)\~}}/", 
         function ($aMatches) {
             return BxDolService::callMacro($aMatches[1]); 
         }, 

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

@@ -235,11 +235,11 @@ class BxBaseModGeneralModule extends BxDolModule
      * @subsection bx_base_general-browsing Browsing
      * @subsubsection bx_base_general-get_search_result_unit get_search_result_unit
      * 
-     * @code bx_srv('bx_posts', 'get_search_result_unit', [...]); @endcode
+     * @code bx_srv('bx_posts', 'get_search_result_unit', [3,"unit_gallery.html"]); @endcode
      * 
      * Get browsing unit for the specified content
      * @param $iContentId content id
-     * @param $sUnitTemplate unit template, such as: full, extended, gallery, showcase
+     * @param $sUnitTemplate unit template, such as: unit_full.html, unit_gallery.html, unit_live_search.html
      * 
      * @see BxBaseModGeneralModule::serviceGetSearchResultUnit
      */
@@ -660,7 +660,7 @@ class BxBaseModGeneralModule extends BxDolModule
      * @subsection bx_base_general-forms Forms
      * @subsubsection bx_base_general-get_create_post_form get_create_post_form
      * 
-     * @code bx_srv('bx_posts', 'get_create_post_form', [...]); @endcode
+     * @code bx_srv('bx_posts', 'get_create_post_form'); @endcode
      * 
      * Get content creation form
      * @param $aParams additional parameters array: 

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

@@ -2326,7 +2326,8 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_location_geolocation_not_supported_by_browser"><![CDATA[Geolocation is not supported by this browser]]></string>
 	<string name="_sys_location_undefined"><![CDATA[Location off]]></string>
     <string name="_sys_macros_malformed"><![CDATA[Error: malformed macros]]></string>
-    <string name="_sys_macros_unsafe"><![CDATA[Error: unsafe macros]]></string> 
+    <string name="_sys_macros_unsafe"><![CDATA[Error: unsafe macros]]></string>
+    <string name="_sys_macros_output_not_displayable"><![CDATA[Error: output isn't displayable]]></string>
 	<string name="_sys_menu_item_title_about"><![CDATA[About]]></string>
         <string name="_sys_menu_item_title_copyright"><![CDATA[Copyright]]></string>
 	<string name="_sys_menu_item_title_privacy"><![CDATA[Privacy]]></string>

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

@@ -2265,6 +2265,7 @@
 	<string name="_sys_location_undefined"><![CDATA[Отключить местоположение]]></string>
     <string name="_sys_macros_malformed"><![CDATA[Ошибка: некорректный макрос]]></string>
     <string name="_sys_macros_unsafe"><![CDATA[Ошибка: небезопасный макрос]]></string>
+    <string name="_sys_macros_output_not_displayable"><![CDATA[Error: некорректный вывод макроса]]></string>
 	<string name="_sys_menu_item_title_about"><![CDATA[О нас]]></string>
         <string name="_sys_menu_item_title_copyright"><![CDATA[Копирайт]]></string>
 	<string name="_sys_menu_item_title_privacy"><![CDATA[Конфиденциальность]]></string>

+ 1 - 1
samples/macros.php

@@ -60,7 +60,7 @@ function PageCompMainCode()
             $sModule = isset($aBaseClasses[$sDeclaringClass]) ? $aBaseClasses[$sDeclaringClass] : $aModule['name'];
 
             echo '<a href="https://ci.una.io/docs/service.html#' . $sModule . '-' . $sService . '">';
-            echo '{{!' . $aModule['name']  . ':' . $sService . '[...]}}';
+            echo '{{~' . $aModule['name']  . ':' . $sService . '[...]~}}';
             echo '</a><br />';
         }
         echo '</p>';

+ 12 - 3
template/scripts/BxBasePage.php

@@ -345,7 +345,10 @@ class BxBasePage extends BxDolPage
      */
     protected function _getBlockRaw ($aBlock)
     {
-        return '<div class="bx-page-raw-container">' . $this->_replaceMarkers(BxDolTemplate::getInstance()->parseHtmlByContent($aBlock['content'], array())) . '</div>';
+        $s = '<div class="bx-page-raw-container">' . BxDolTemplate::getInstance()->parseHtmlByContent($aBlock['content'], array()) . '</div>';
+        $s = $this->_replaceMarkers($s);
+        $s = bx_process_macros($s);
+        return $s;
     }
 
     /**
@@ -354,7 +357,10 @@ class BxBasePage extends BxDolPage
      */
     protected function _getBlockHtml ($aBlock)
     {
-        return '<div class="bx-page-html-container">' . $this->_replaceMarkers($aBlock['content']) . '</div>';
+        $s = '<div class="bx-page-html-container">' . $aBlock['content'] . '</div>';
+        $s = $this->_replaceMarkers($s);
+        $s = bx_process_macros($s);
+        return $s;
     }
 
     /**
@@ -363,7 +369,10 @@ class BxBasePage extends BxDolPage
      */
     protected function _getBlockLang ($aBlock)
     {
-        return '<div class="bx-page-lang-container">' . $this->_replaceMarkers(_t(trim($aBlock['content']))) . '</div>';
+        $s = '<div class="bx-page-lang-container">' . _t(trim($aBlock['content'])) . '</div>';
+        $s = $this->_replaceMarkers($s);
+        $s = bx_process_macros($s);
+        return $s;
     }
 
     /**