Parcourir la source

#129 - no view switcher for browse entries blocks, instead operator can add different blocks with different view, also RSS link was removed and added to the "header" section of page HTML, so ti will be automatically detected by RSS readers

Alex Trofimov il y a 11 ans
Parent
commit
051d7ff1a9

+ 16 - 0
inc/classes/BxDolTemplate.php

@@ -751,6 +751,19 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton
     {
         $this->aPage['image'] = $sImageUrl;
     }
+    /**
+     * Set page rss link.
+     *
+     * @param $sTitle - rss feed title
+     * @param $sUrl - rss feed URL
+     */
+    function addPageRssLink($sTitle, $sUrl)
+    {
+        if (!isset($this->aPage['rss']))
+            $this->aPage['rss'] = array('title' => $sTitle, 'url' => $sUrl);
+        else
+            $this->aPage['rss'] = false;
+    }
     /**
      * Returns page meta info, like meta keyword, meta description, location, etc
      */
@@ -777,6 +790,9 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton
             $sRet .= BxTemplFunctions::getInstance()->getMetaIcons();
         }
 
+        if (!empty($this->aPage['rss']) && !empty($this->aPage['rss']['url']))
+            $sRet .= '<link rel="alternate" type="application/rss+xml" title="' . bx_html_attribute($this->aPage['rss']['title'], BX_ESCAPE_STR_QUOTE) . '" href="' . $this->aPage['rss']['url'] . '" />';
+
         return $sRet;
     }
     /**

+ 7 - 7
modules/base/text/classes/BxBaseModTextModule.php

@@ -53,31 +53,31 @@ class BxBaseModTextModule extends BxBaseModGeneralModule
      * Display pablic entries
      * @return HTML string
      */
-    public function serviceBrowsePublic ()
-    {
-        return $this->_serviceBrowse ('public', false, BX_DB_PADDING_DEF, true);
+    public function serviceBrowsePublic ($sUnitView = false)
+    {   
+        return $this->_serviceBrowse ('public', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, true);
     }
 
     /**
      * Display featured entries
      * @return HTML string
      */
-    public function serviceBrowsePopular ()
+    public function serviceBrowsePopular ($sUnitView = false)
     {
-        return $this->_serviceBrowse ('popular', false, BX_DB_PADDING_DEF, true);
+        return $this->_serviceBrowse ('popular', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, true);
     }
 
     /**
      * Display entries of the author
      * @return HTML string
      */
-    public function serviceBrowseAuthor ($iProfileId = 0)
+    public function serviceBrowseAuthor ($iProfileId = 0, $sUnitView = false)
     {
         if (!$iProfileId)
             $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
         if (!$iProfileId)
             return '';
-        return $this->_serviceBrowse ('author', array('author' => $iProfileId), BX_DB_PADDING_DEF, true);
+        return $this->_serviceBrowse ('author', array('author' => $iProfileId, 'unit_view' => $sUnitView ? $sUnitView : ''), BX_DB_PADDING_DEF, true);
     }
 
     /**

+ 3 - 25
modules/base/text/classes/BxBaseModTextSearchResult.php

@@ -21,6 +21,9 @@ class BxBaseModTextSearchResult extends BxBaseModGeneralSearchResult
     {
         parent::__construct($sMode, $aParams);
 
+        if (!empty($aParams['unit_view']))
+            $this->sUnitViewDefault = $aParams['unit_view'];
+
         $this->aGetParams = array($this->sUnitViewParamName);
         $this->sUnitTemplate = $this->aUnitViews[$this->sUnitViewDefault];
         if (isset($this->aUnitViews[bx_get($this->sUnitViewParamName)]))
@@ -30,31 +33,6 @@ class BxBaseModTextSearchResult extends BxBaseModGeneralSearchResult
             $this->addContainerClass (array('bx-def-margin-sec-neg', 'bx-base-text-unit-gallery-wrapper'));
     }
 
-    function getDesignBoxMenu ()
-    {
-        $aMenu = parent::getDesignBoxMenu ();
-        if (!$aMenu)
-            return false;
-
-        return array_merge(
-            array(
-                array(
-                    'name' => 'gallery', 
-                    'title' => _t('_sys_menu_title_gallery'), 
-                    'link' => $this->getCurrentUrl(array($this->sUnitViewParamName => 'gallery')), 
-                    'onclick' => $this->getCurrentOnclick(array($this->sUnitViewParamName => 'gallery')), 
-                    'icon' => 'th'),
-                array(
-                    'name' => 'extended', 
-                    'title' => _t('_sys_menu_title_extended'), 
-                    'link' => $this->getCurrentUrl(array($this->sUnitViewParamName => 'extended')), 
-                    'onclick' => $this->getCurrentOnclick(array($this->sUnitViewParamName => 'extended')), 
-                    'icon' => 'list'),
-            ),
-            $aMenu
-        );
-    }
-
     protected function getCurrentOnclick($aAdditionalParams = array(), $bReplacePagesParams = true) 
     {
         // always add UnitView as additional param

+ 7 - 4
modules/boonex/albums/classes/BxAlbumsSearchResult.php

@@ -16,7 +16,10 @@ class BxAlbumsSearchResult extends BxBaseModTextSearchResult
     function __construct($sMode = '', $aParams = array())
     {
         $this->aUnitViews = array('extended' => 'unit.html');
-        $this->sUnitViewDefault = 'extended';
+    
+        if (empty($aParams['unit_view']))
+            $aParams['unit_view'] = 'extended';
+
         parent::__construct($sMode, $aParams);
 
         $this->aCurrent = array(
@@ -101,9 +104,9 @@ class BxAlbumsSearchResult extends BxBaseModTextSearchResult
 
         // add replaceable markers and replace them
         if ($oProfileAuthor) {
-            $this->addMarkers($oProfileAuthor->getInfo()); // profile info is replacable
-            $this->addMarkers(array('profile_id' => $oProfileAuthor->id())); // profile id is replacable
-            $this->addMarkers(array('display_name' => $oProfileAuthor->getDisplayName())); // profile display name is replacable
+            $this->addMarkers($oProfileAuthor->getInfo()); // profile info is replaceable
+            $this->addMarkers(array('profile_id' => $oProfileAuthor->id())); // profile id is replaceable
+            $this->addMarkers(array('display_name' => $oProfileAuthor->getDisplayName())); // profile display name is replaceable
         }
 
         $this->sBrowseUrl = $this->_replaceMarkers($this->sBrowseUrl);

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

@@ -1832,8 +1832,6 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_menu_title_add_profile"><![CDATA[Add Profile Menu]]></string>
 	<string name="_sys_menu_title_cmts_item_actions"><![CDATA[Comment Actions]]></string>
 	<string name="_sys_menu_title_cmts_item_manage"><![CDATA[Manage Comment]]></string>
-	<string name="_sys_menu_title_extended"><![CDATA[Extended view]]></string>
-	<string name="_sys_menu_title_gallery"><![CDATA[Gallery view]]></string>
 	<string name="_sys_menu_title_footer"><![CDATA[Footer Links]]></string>
 	<string name="_sys_menu_title_main"><![CDATA[Site Navigation]]></string>
 	<string name="_sys_menu_title_profiles_create"><![CDATA[Create Profiles]]></string>

+ 2 - 0
modules/boonex/posts/install/langs/en.xml

@@ -57,6 +57,7 @@
     <string name="_bx_posts_page_title_sys_home"><![CDATA[Posts Home]]></string>
     <string name="_bx_posts_page_title_home"><![CDATA[Posts]]></string>
     <string name="_bx_posts_page_block_title_recent_entries"><![CDATA[Recent Posts]]></string>
+    <string name="_bx_posts_page_block_title_recent_entries_view_extended"><![CDATA[Recent Posts (Extended View)]]></string>
     <string name="_bx_posts_page_block_title_entry_social_sharing"><![CDATA[Share]]></string>
     <string name="_bx_posts_page_block_title_entry_author"><![CDATA[Author]]></string>
     <string name="_bx_posts_page_block_title_entry_actions"><![CDATA[Actions]]></string>
@@ -65,6 +66,7 @@
     <string name="_bx_posts_page_title_sys_entries_popular"><![CDATA[Popular Posts]]></string>
     <string name="_bx_posts_page_title_entries_popular"><![CDATA[Popular Posts]]></string>
     <string name="_bx_posts_page_block_title_popular_entries"><![CDATA[Popular Posts]]></string>
+    <string name="_bx_posts_page_block_title_popular_entries_view_extended"><![CDATA[Popular Posts (Extended View)]]></string>
     <string name="_bx_posts_page_title_sys_view_entry_comments"><![CDATA[Post Comments]]></string>
     <string name="_bx_posts_page_title_view_entry_comments"><![CDATA[Post Comments]]></string>
     <string name="_bx_posts_page_title_sys_entries_of_author"><![CDATA[Posts of author]]></string>

+ 6 - 0
modules/boonex/posts/install/sql/enable.sql

@@ -120,6 +120,12 @@ SET @iBlockOrder = (SELECT `order` FROM `sys_pages_blocks` WHERE `object` = 'sys
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES 
 ('sys_home', 1, 'bx_posts', '_bx_posts_page_block_title_recent_entries', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_posts\";s:6:\"method\";s:13:\"browse_public\";}', 1, 0, IFNULL(@iBlockOrder, 0) + 1);
 
+-- PAGE: service blocks
+
+SET @iBlockOrder = (SELECT `order` FROM `sys_pages_blocks` WHERE `object` = '' AND `cell_id` = 0 ORDER BY `order` DESC LIMIT 1);
+INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES 
+('', 0, 'bx_posts', '_bx_posts_page_block_title_recent_entries_view_extended', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:8:"bx_posts";s:6:"method";s:13:"browse_public";s:6:"params";a:1:{i:0;s:8:"extended";}}', 0, 1, IFNULL(@iBlockOrder, 0) + 1),
+('', 0, 'bx_posts', '_bx_posts_page_block_title_popular_entries_view_extended', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:8:"bx_posts";s:6:"method";s:14:"browse_popular";s:6:"params";a:1:{i:0;s:8:"extended";}}', 0, 1, IFNULL(@iBlockOrder, 0) + 2);
 
 -- MENU: add to site menu
 

+ 13 - 4
template/scripts/BxBaseSearchResult.php

@@ -83,6 +83,8 @@ class BxBaseSearchResult extends BxDolSearchResult
             return '<div class="bx-page-block-container bx-search-results bx-def-padding-topbottom bx-clearfix" id="bx-page-block-' . $this->id . '">' . $sCode . '</div>';
         }
 
+        $this->addPageRssLink ();
+
         return array(        	
         	'content' => $sContent,
         	'menu' => $sMenu,
@@ -96,13 +98,20 @@ class BxBaseSearchResult extends BxDolSearchResult
     }
 
     function getDesignBoxMenu ()
+    {
+        return array();
+    }
+
+    protected function addPageRssLink ()
     {
         if (false === ($sLink = $this->getRssPageUrl ()))
-            return false;
+            return;
 
-        return array(
-            array('name' => 'rss', 'title' => _t('_sys_menu_title_rss'), 'link' => $sLink, 'icon' => 'rss')
-        );
+        bx_import('BxDolTemplate');
+        if (!($oTemplate = BxDolTemplate::getInstance()))
+            return;
+
+        $oTemplate->addPageRssLink($this->aCurrent['title'], $sLink);
     }
 
     function getRssPageUrl ()