Pwirth has uploaded a new change for review. https://gerrit.wikimedia.org/r/184362
Change subject: Blog: Added bs:blog:time tag ...................................................................... Blog: Added bs:blog:time tag * Added parserhook on onBlogTime * Changed bs:blog tag query * Added messages Change-Id: I9bebcc78bdeeddab7a30969338693bd3280a21f9 --- M Blog/Blog.class.php M Blog/languages/Blog.i18n.php 2 files changed, 53 insertions(+), 15 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions refs/changes/62/184362/1 diff --git a/Blog/Blog.class.php b/Blog/Blog.class.php index fc89264..cb3a68f 100644 --- a/Blog/Blog.class.php +++ b/Blog/Blog.class.php @@ -231,6 +231,9 @@ $parser->setHook( 'more', array( &$this, 'onMore' ) ); $parser->setHook( 'bs:blog', array( &$this, 'onBlog' ) ); $parser->setHook( 'bs:blog:more', array( &$this, 'onMore' ) ); + // get timestamp for custom sorting + $parser->setHook( 'blog:time', array( &$this, 'onBlogTime' ) ); + $parser->setHook( 'bs:blog:time', array( &$this, 'onBlogTime' ) ); return true; } @@ -251,6 +254,14 @@ 'code' => '<bs:blog />', ); + $oResponse->result[] = array( + 'id' => 'bs:blog:time', + 'type' => 'tag', + 'name' => 'blogtime', + 'desc' => wfMessage( 'bs-blog-tag-blogtime-desc' )->plain(), + 'code' => '<bs:blog:time />', + ); + return true; } @@ -263,6 +274,22 @@ */ public function onMore( $input, $args, $parser ) { $parser->disableCache(); + return ''; + } + + public function onBlogTime( $input, $args, $parser ) { + $parser->disableCache(); + $sValue = array_pop( $args ).'00'; + + if( strlen( $sValue ) !== 14 ) { + $oErrorListView = new ViewTagErrorList( $this ); + $oErrorListView->addItem( new ViewTagError( + wfMessage('bs-blog-tag-blogtime-err')->plain() ) + ); + return $oErrorListView->execute(); + } + + $parser->getOutput()->setProperty( 'blogtime', $sValue ); return ''; } @@ -409,27 +436,33 @@ $aArticleIds = 0; } - // get blog entries - $aOptions = array(); - if ( !$argsSSortBy || $argsSSortBy == 'creation' ) { - $aOptions['ORDER BY'] = 'page_id DESC'; - } elseif ( $argsSSortBy == 'title' ) { - $aOptions['ORDER BY'] = 'page_title ASC'; - } - $aTables = array( 'page' ); - $sFiels = ''; + $aFiels = array( 'entry_page_id' => 'page_id' ); $aConditions = array(); + $aOptions = array(); + $aJoins = array(); $dbr = wfGetDB( DB_SLAVE ); + // get blog entries + if( $argsSSortBy == 'title' ) { + $aOptions['ORDER BY'] = 'page_title ASC'; + } else { + //Creation: Also fetch possible custom timestamps from page_props table + $aOptions['ORDER BY'] = 'entry_timestamp DESC'; + $aOptions['GROUP BY'] = 'page_id'; + $aFiels['entry_timestamp'] = "IFNULL( pp_value, rev_timestamp )"; //use pp_value if exists + $aTables[] = 'revision'; + $aTables[] = 'page_props'; + $aConditions[] = 'rev_page = page_id'; + $aJoins['page_props'] = array( 'LEFT JOIN', "pp_page = rev_page AND pp_propname = 'blogtime'" ); + } + if ( $argsSCategory ) { $aTables[] = 'categorylinks'; - $sFiels = 'cl_from AS entry_page_id'; $aConditions['cl_to'] = $argsSCategory; $aConditions[] = 'cl_from = page_id'; } else { - $sFiels = 'page_id AS entry_page_id'; if ( $argsModeNamespace === 'ns' ) { $aConditions['page_id'] = $aArticleIds; } @@ -438,10 +471,11 @@ $res = $dbr->select( $aTables, - $sFiels, + $aFiels, $aConditions, __METHOD__, - $aOptions + $aOptions, + $aJoins ); $iNumberOfEntries = $dbr->numRows( $res ); diff --git a/Blog/languages/Blog.i18n.php b/Blog/languages/Blog.i18n.php index ac4cffa..a5776d5 100644 --- a/Blog/languages/Blog.i18n.php +++ b/Blog/languages/Blog.i18n.php @@ -44,7 +44,9 @@ 'bs-blog-pref-ImageRenderMode' => 'Display pictures', 'bs-blog-pref-MaxEntryCharacters' => 'Number of displayed words', 'bs-blog-pref-ShowTagFormWhenNotLoggedIn' => 'Show insert form also for not registed users', - 'bs-blog-tag-blog-desc' => 'This tag provides you the opportunity to display blog entry on every page.' + 'bs-blog-tag-blog-desc' => 'This tag provides you the opportunity to display blog entry on every page.', + 'bs-blog-tag-blogtime-desc' => 'This tag provides you the opportunity to set a custom timestamp for blog entries.', + 'bs-blog-tag-blogtime-err' => 'The format has to be YYYYMMDDHHmm i.e. for 12. Jan. 2013 15:43 the timestamps looks like: 201301121543', ); $messages['de'] = array( @@ -76,7 +78,9 @@ 'bs-blog-pref-ImageRenderMode' => 'Bilder anzeigen', 'bs-blog-pref-MaxEntryCharacters' => 'Anzahl darzustellender Wörter ', 'bs-blog-pref-ShowTagFormWhenNotLoggedIn' => 'Erstellformular auch für nicht angemeldete Benutzer anzeigen', - 'bs-blog-tag-blog-desc' => 'Dieser Tag stellt die Funktionalität bereit, auf jeder Seite sich Blog Einträge anzeigen zulassen.' + 'bs-blog-tag-blog-desc' => 'Dieser Tag stellt die Funktionalität bereit, auf jeder Seite sich Blog Einträge anzeigen zulassen.', + 'bs-blog-tag-blogtime-desc' => 'Dieser Tag stellt die Funktionalität bereit, für Blogeinträge einen benutzerdefinierten Zeitstempel zu setzen.', + 'bs-blog-tag-blogtime-err' => 'Das Format ist YYYYMMDDHHmm d. h. für den 12. Jan. 2013 15:43 muss der Zeitstempel wie folgt angegeben sein: 201301121543', ); $messages['de-formal'] = array(); -- To view, visit https://gerrit.wikimedia.org/r/184362 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9bebcc78bdeeddab7a30969338693bd3280a21f9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions Gerrit-Branch: REL1_22 Gerrit-Owner: Pwirth <wi...@hallowelt.biz> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits