Procházet zdrojové kódy

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

AntonLV před 3 roky
rodič
revize
313425e8f2

+ 27 - 0
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -947,6 +947,33 @@ class BxBaseModGeneralModule extends BxDolModule
         return $this->_oTemplate->getFavoriteList($oProfile, $iStart, $iPerPage, $aParams);
     }
     
+    /**
+     * @page service Service Calls
+     * @section bx_base_general Base General
+     * @subsection bx_base_general-browsing Browsing
+     * @subsubsection bx_base_general-browse_by_category category
+     * 
+     * @code bx_srv('bx_posts', 'browse_by_category', [...]); @endcode
+     * 
+     * Display entries in category
+     * @param $sUnitView browsing unity view, 
+     *                   such as: full, extended, gallery, showcase
+     * @param $bEmptyMessage display or not "empty" message when there is no content
+     * @param $bAjaxPaginate use AJAX paginate or not
+     * 
+     * @see BxBaseModGeneralModule::serviceBrowseByCategory BxBaseModGeneralModule::serviceBrowse
+     */
+    /** 
+     * @ref bx_base_general-browse_by_category "browse_by_category"
+     */
+    public function serviceBrowseByCategory($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true, $bShowHeader = true)
+    {
+        $sType = 'category';
+        $iCategory = bx_process_input(bx_get('category'), BX_DATA_INT);
+        
+        return $this->_serviceBrowse($sType, $aParams, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
+    }
+    
     /**
      * @page service Service Calls
      * @section bx_base_general Base General

+ 7 - 0
modules/base/text/classes/BxBaseModTextPageBrowse.php

@@ -17,6 +17,13 @@ class BxBaseModTextPageBrowse extends BxBaseModGeneralPageBrowse
     public function __construct($aObject, $oTemplate = false)
     {
         parent::__construct($aObject, $oTemplate);
+        
+        $iCategory = bx_process_input(bx_get('category'), BX_DATA_INT);
+        if(!empty($iCategory))
+            $this->addMarkers(array(
+                'category_id' => $iCategory,
+                'category_name' => BxDolCategory::getObjectInstance($this->_oModule->_oConfig->CNF['OBJECT_CATEGORY'])->getCategoryTitle($iCategory),
+        ));
     }
 }
 

+ 0 - 7
modules/boonex/forum/classes/BxForumPageBrowse.php

@@ -21,13 +21,6 @@ class BxForumPageBrowse extends BxBaseModTextPageBrowse
 
         $this->_oModule->_oTemplate->addJs(array('main.js'));
 
-        $iCategory = bx_process_input(bx_get('category'), BX_DATA_INT);
-        if(!empty($iCategory))
-	        $this->addMarkers(array(
-	        	'category_id' => $iCategory,
-	        	'category_name' => BxDolCategory::getObjectInstance($this->_oModule->_oConfig->CNF['OBJECT_CATEGORY'])->getCategoryTitle($iCategory),
-	        ));
-
 		$sKeyword = bx_process_input(bx_get('keyword'));
         if(!empty($sKeyword))
 	        $this->addMarkers(array(

+ 1 - 0
modules/boonex/market/classes/BxMarketConfig.php

@@ -104,6 +104,7 @@ class BxMarketConfig extends BxBaseModTextConfig
             'URL_LICENSES_COMMON' => 'page.php?i=products-licenses',
             'URL_LICENSES_ADMINISTRATION' => 'page.php?i=products-licenses-administration',
             'URL_VIEW_ENTRY' => 'page.php?i=view-product&id=',
+            'URL_CATEGORY' => 'page.php?i=products-category',
 
             // some params
             'PARAM_AUTO_APPROVE' => 'bx_market_enable_auto_approve',

+ 14 - 0
modules/boonex/market/classes/BxMarketSearchResult.php

@@ -103,6 +103,20 @@ class BxMarketSearchResult extends BxBaseModTextSearchResult
                 $this->aCurrent['rss']['link'] = 'modules/?r=market/rss/' . $sMode;
                 $this->aCurrent['sorting'] = 'top';
                 break;
+                
+             case 'category':
+                    $iCategory = (int)$aParams['category'];
+                    $this->addMarkers(array(
+                        'category_id' => $iCategory,
+                        'category_name' => BxDolCategory::getObjectInstance($CNF['OBJECT_CATEGORY'])->getCategoryTitle($iCategory),
+                    ));
+
+                $this->aCurrent['restriction']['category']['value'] = $iCategory;
+
+                $this->sBrowseUrl = $CNF['URL_CATEGORY'] . '&category={category_id}';
+                $this->aCurrent['title'] = _t('_bx_market_page_title_browse_by_category');
+                $this->aCurrent['rss']['link'] = 'modules/?r=market/rss/' . $sMode . '/' . $iCategory;
+                break;
 
             case 'updated':
                 $this->sBrowseUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_UPDATED']);

+ 4 - 0
modules/boonex/market/install/langs/en.xml

@@ -157,6 +157,10 @@
     <string name="_bx_market_page_title_browse_keyword"><![CDATA[Products by hashtag: {0}]]></string>
     <string name="_bx_market_page_title_sys_home"><![CDATA[Market Home]]></string>
     <string name="_bx_market_page_title_home"><![CDATA[Market]]></string>
+    <string name="_bx_market_page_title_sys_entries_by_category"><![CDATA[Products in category]]></string>
+    <string name="_bx_market_page_title_entries_by_category"><![CDATA[Products in {category_name}]]></string>
+    <string name="_bx_market_page_block_title_sys_entries_by_category"><![CDATA[Products in category]]></string>
+    <string name="_bx_market_page_block_title_entries_by_category"><![CDATA[{category_name}]]></string>
     <string name="_bx_market_page_block_title_featured_entries"><![CDATA[Featured Products]]></string>
     <string name="_bx_market_page_block_title_featured_entries_view_extended"><![CDATA[Featured Products (Extended View)]]></string>
     <string name="_bx_market_page_block_title_featured_entries_view_full"><![CDATA[Featured Products (Full View)]]></string>

+ 8 - 0
modules/boonex/market/install/sql/enable.sql

@@ -102,6 +102,14 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbo
 ('bx_market_categories', 1, 'bx_market', '_bx_market_page_block_title_cats', 11, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:15:"categories_list";s:6:"params";a:2:{i:0;s:14:"bx_market_cats";i:1;a:1:{s:10:"show_empty";b:1;}}s:5:"class";s:20:"TemplServiceCategory";}', 0, 1, 1);
 
 
+-- PAGE: entries by category
+INSERT INTO `sys_objects_page`(`object`, `uri`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
+('bx_market_category', 'products-category', '_bx_market_page_title_sys_entries_by_category', '_bx_market_page_title_entries_by_category', 'bx_market', 1, 2147483647, 1, 'page.php?i=products-category', '', '', '', 0, 1, 0, 'BxMarketPageBrowse', 'modules/boonex/market/classes/BxMarketPageBrowse.php');
+
+INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
+('bx_market_category', 2, 'bx_market', '_bx_market_page_block_title_sys_entries_by_category', '_bx_market_page_block_title_entries_by_category', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:9:"bx_market";s:6:"method";s:18:"browse_by_category";s:6:"params";a:1:{i:0;s:5:"table";}}', 0, 0, 1, 1),
+('bx_market_category', 1, 'bx_market', '_bx_market_page_block_title_cats', '_bx_market_page_block_title_cats', 11, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:15:"categories_list";s:6:"params";a:2:{i:0;s:14:"bx_market_cats";i:1;a:1:{s:10:"show_empty";b:1;}}s:5:"class";s:20:"TemplServiceCategory";}', 0, 0, 1, 1);
+
 -- PAGE: latest entries
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_market_latest', '_bx_market_page_title_sys_entries_latest', '_bx_market_page_title_entries_latest', 'bx_market', 5, 2147483647, 1, 'products-latest', 'page.php?i=products-latest', '', '', '', 0, 1, 0, 'BxMarketPageBrowse', 'modules/boonex/market/classes/BxMarketPageBrowse.php');

+ 4 - 0
modules/boonex/russian/data/langs/bx_market/ru.xml

@@ -154,6 +154,10 @@
     <string name="_bx_market_page_title_browse_keyword"><![CDATA[Продукты с хэштегом: {0}]]></string>
     <string name="_bx_market_page_title_sys_home"><![CDATA[Рынок - Домой]]></string>
     <string name="_bx_market_page_title_home"><![CDATA[Рынок]]></string>
+    <string name="_bx_market_page_title_sys_entries_by_category"><![CDATA[Продукты в категории]]></string>
+    <string name="_bx_market_page_title_entries_by_category"><![CDATA[Продукты в {category_name}]]></string>
+    <string name="_bx_market_page_block_title_sys_entries_by_category"><![CDATA[Продукты в категории]]></string>
+    <string name="_bx_market_page_block_title_entries_by_category"><![CDATA[{category_name}]]></string>
     <string name="_bx_market_page_block_title_featured_entries"><![CDATA[Продвинутые продукты]]></string>
     <string name="_bx_market_page_block_title_featured_entries_view_extended"><![CDATA[Продвинутые продукты (Расширенный просмотр)]]></string>
     <string name="_bx_market_page_block_title_featured_entries_view_full"><![CDATA[Продвинутые продукты (Полный просмотр)]]></string>

+ 4 - 1
template/category_list.html

@@ -1,5 +1,8 @@
 <div class="bx-category-list">
+    <bx_if:show_all>
+        <div class="bx-category-list-item __selected_class__"><a href="__url__">__name__</a></div>
+    </bx_if:show_all>    
     <bx_repeat:cats>
-        <div class="bx-category-list-item"><a href="__url__">__name__</a> (__num__)</div>
+        <div class="bx-category-list-item __selected_class__"><a href="__url__">__name__</a> (__num__)</div>
     </bx_repeat:cats>
 </div>

+ 3 - 1
template/css/common.css

@@ -892,7 +892,9 @@ svg .gray .outer .p2 {
 .bx-category-list-item {
 	line-height: 1.5rem;
 }
-
+.bx-category-list-item-selected {
+	font-weight: bold;
+}
 
 /* --------------- Show More */
 .bx-overflow-ready {

+ 4 - 0
template/css/editor.quill.css

@@ -9,6 +9,10 @@
 }
 .ql-container.ql-snow{
     border-radius: 0 0 0.3rem 0.3rem;
+    border: 1px solid #ccc;
+}
+.dark .ql-container.ql-snow{
+    border-color: rgb(55 65 81);
 }
 .ql-mention-list li{
     padding: 0.5rem;

+ 0 - 3
template/css/editor_snow.quill.css

@@ -781,9 +781,6 @@
 .ql-snow a {
   color: #06c;
 }
-.ql-container.ql-snow {
-  border: 1px solid #ccc;
-}
 .ql-editor ol, .ql-editor ul{
     -moz-box-sizing: border-box;
     -ms-box-sizing: border-box;

+ 30 - 3
template/scripts/BxBaseCategory.php

@@ -42,7 +42,11 @@ class BxBaseCategory extends BxDolCategory
 
     public function getCategoryUrl($sValue, $aParams = [])
     {
-        $s = BX_DOL_URL_ROOT . bx_replace_markers($this->_sBrowseUrl, array(
+        $sPageUrl = $this->_sBrowseUrl;
+        if (isset($aParams['page']))
+            $sPageUrl = $aParams['page'];
+        
+        $s = BX_DOL_URL_ROOT . bx_replace_markers($sPageUrl, array(
         	'category' => rawurlencode($this->getObjectName()),
         	'keyword' => rawurlencode($sValue),
     		'sections' => $this->_aObject['search_object'] ? '&section[]=' . rawurlencode($this->_aObject['search_object']) : '',
@@ -83,8 +87,30 @@ class BxBaseCategory extends BxDolCategory
         $a = BxDolForm::getDataItems($this->_aObject['list_name']);
         if (!$a)
             return $bAsArray ? array() : '';
+        
+        $sAllCategoriesLink = '';
+        $aParams = [];
+        if($this->_aObject['module']){
+            $oModule = BxDolModule::getInstance($this->_aObject['module']);
+            $CNF = $oModule->_oConfig->CNF;
+            if (isset($CNF['URL_CATEGORY'])){
+                $aParams['page'] = bx_append_url_params(BxDolPermalinks::getInstance()->permalink($CNF['URL_CATEGORY']), ['category' => '{keyword}'
+                ], true, ['{keyword}']);
+            }
+            $sAllCategoriesLink = BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']);
+        }
 
-        $aVars = array('bx_repeat:cats' => array());
+        $aVars = [
+            'bx_repeat:cats' => [],
+            'bx_if:show_all' => [
+                'condition' => $sAllCategoriesLink != '',
+                'content' => [
+                    'url' => $sAllCategoriesLink,
+                    'name' => _t('all')
+                ]
+            ]
+        ];
+        
         foreach ($a as $sValue => $sName) {
             if (!is_numeric($sValue) && !$sValue)
                 continue;
@@ -94,10 +120,11 @@ class BxBaseCategory extends BxDolCategory
                 continue;
             
             $aVars['bx_repeat:cats'][] = array(
-                'url' => $mProfileContextId? $this->getCategoryUrl($sValue, ['context_id' => $mProfileContextId]) : $this->getCategoryUrl($sValue),
+                'url' => $mProfileContextId ? $this->getCategoryUrl($sValue, array_merge($aParams, ['context_id' => $mProfileContextId])) : $this->getCategoryUrl($sValue, $aParams),
                 'name' => $sName,
                 'value' => $sValue,
                 'num' => $iNum,
+                'selected_class' => $sValue == bx_get('category') ? 'bx-category-list-item-selected' : '',
             );
         }