Robert Vogel has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/364146 )

Change subject: Fix for Blog RSS feed
......................................................................

Fix for Blog RSS feed

Im not sure what was the idea for blog RSS feed, and if this change should
even be

Customer complained about RSS feed in section Blog not showing any items
and NS_BLOG is not even listed in the list.

I have added Blog ns into select box.

When choosing any other NS (other than Blog) code retrieves subpages from
Blog page in that NS. That is ok for other NSs, but when selecting Blog ns
user is not expection to have to have another page named Blog inside
containing blog entries,  but they expect RSS feed to show all pages
inside Blog NS.

ERM: #6605

Needs cherry-picking to REL1_27 and (if possible) REL1_23

Change-Id: Idd7ee6c22052ced4facd81c836033efed22acc8d
---
M Blog/Blog.class.php
1 file changed, 33 insertions(+), 24 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions 
refs/changes/46/364146/1

diff --git a/Blog/Blog.class.php b/Blog/Blog.class.php
index 375144c..165fc96 100644
--- a/Blog/Blog.class.php
+++ b/Blog/Blog.class.php
@@ -701,52 +701,61 @@
 
                $oRequest = $this->getRequest();
                $sTitle = $oRequest->getVal( 'p', '' );
-               $iNSid = $oRequest->getInt( 'ns', 0 );
+               $iNS = $oRequest->getInt( 'ns', 0 );
                $aNamespaces = $wgContLang->getNamespaces();
 
-               if( $iNSid != 0 ) {
-                       $sPageName = $aNamespaces[$iNSid].':'.$sTitle;
+               if( $iNS != 0 ) {
+                       $sPageName = $aNamespaces[$iNS] . ':' . $sTitle;
                } else {
                        $sPageName = $sTitle;
                }
-
-               /*$dbr = wfGetDB( DB_SLAVE );
-               $res = $dbr->select(
-                       array( 'page', 'recentchanges' ),
-                       '*',
-                       array(
-                               'page_title'     => $sTitle,
-                               'page_namespace' => $iNSid,
-                               'rc_timestamp > '. $dbr->timestamp( time() - 
intval( 7 * 86400 ) )
-                       ),
-                       __METHOD__,
-                       array( 'ORDER BY' => 'rc_timestamp DESC' ),
-                       array(
-                               'page'=> array( 'LEFT JOIN', 'rc_cur_id = 
page_id' )
-                       )
-               );*/
 
                $oChannel = RSSCreator::createChannel(
                        RSSCreator::xmlEncode( $wgSitename . ' - ' . $sPageName 
),
                        'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'], 
wfMessage( 'bs-blog-rss-desc-blog' )->plain()
                );
 
-               $oTitle = Title::makeTitle( $iNSid , 'Blog' );
-               $aSubpages = $oTitle->getSubpages();
+               $aSubpages = $this->getBlogPages( $iNS );
 
                foreach( $aSubpages as $oSubpage ) {
-//                     $oPageCP = new BsPageContentProvider();
                        if( $oSubpage instanceof Title ) {}
                        $entry = RSSItemCreator::createItem(
                                $oSubpage->getText(),
                                $oSubpage->getFullURL(),
                                
BsPageContentProvider::getInstance()->getContentFromTitle( $oSubpage )
-//                             $oPageCP->getHTMLContentFor( $oSubpage )
                        );
                        $entry->setPubDate( wfTimestamp( TS_UNIX, 
$oSubpage->getTouched() ) );
                        $oChannel->addItem($entry);
                }
                return $oChannel->buildOutput();
+       }
+
+       protected function getBlogPages( $iNS ) {
+               $aSubpages = array();
+               if( $iNS == NS_BLOG ) {
+                       $dbr = wfGetDB( DB_SLAVE );
+                       $res = $dbr->select(
+                               array( 'page' ),
+                               array( 'page_title', 'page_namespace'),
+                               array(
+                                       'page_namespace' => $iNS
+                               ),
+                               __METHOD__
+                       );
+                       foreach( $res as $row ) {
+                               $oTmpTitle = Title::newFromRow( $row );
+                               $aSubpages[] = $oTmpTitle;
+                       }
+               } else {
+                       $oTitle = Title::newFromText( 'Blog', $iNS );
+                       if( $oTitle && $oTitle instanceof Title ) {
+                               $aSubpages = $oTitle->getSubpages();
+                               BSDebug::logVar($aSubpages);
+                       }
+
+               }
+
+               return $aSubpages;
        }
 
        // TODO: make RSSStandards methods more generic
@@ -760,7 +769,7 @@
                $select->setName( 'selFeedNsBlog' );
                $select->setLabel( wfMessage( 'bs-ns' )->plain() );
 
-               $aNamespacesTemp = 
BsNamespaceHelper::getNamespacesForSelectOptions( array( NS_SPECIAL, NS_MEDIA, 
NS_BLOG, NS_BLOG_TALK, NS_FILE ) );
+               $aNamespacesTemp = 
BsNamespaceHelper::getNamespacesForSelectOptions( array( NS_SPECIAL, NS_MEDIA, 
NS_FILE ) );
                $aNamespaces = array();
                foreach( $aNamespacesTemp as $index => $name ) {
                        if ( $index % 2 == 0 ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/364146
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idd7ee6c22052ced4facd81c836033efed22acc8d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: REL1_27
Gerrit-Owner: Robert Vogel <[email protected]>
Gerrit-Reviewer: ItSpiderman <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to