jenkins-bot has submitted this change and it was merged.

Change subject: Merged: Blog: Added bs:blog:time tag
......................................................................


Merged: Blog: Added bs:blog:time tag

* Added parserhook on onBlogTime
* Changed bs:blog tag query
* Added messages
* Marked ...og:time timestamp /> as deptecated. Now: ...og:time
* time=timestamp />
* Entries with future timestamp will not be listed
* I9bebcc78bdeeddab7a30969338693bd3280a21f9

Change-Id: I15d59f35d8b47607fffb04f90eee89ccf978f3bc
---
M Blog/Blog.class.php
M Blog/i18n/de.json
M Blog/i18n/en.json
M Blog/i18n/qqq.json
4 files changed, 99 insertions(+), 16 deletions(-)

Approvals:
  Robert Vogel: Checked; Looks good to me, but someone else must approve
  Tweichart: Looks good to me, approved
  Raimond Spekking: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/Blog/Blog.class.php b/Blog/Blog.class.php
index 2784a74..a67a301 100644
--- a/Blog/Blog.class.php
+++ b/Blog/Blog.class.php
@@ -262,6 +262,9 @@
                $parser->setHook( 'more', array( &$this, 'onMore' ) );
                $parser->setHook( 'bs:blog', array( &$this, 'onBlog' ) );
                $parser->setHook( 'bs:blog:more', array( &$this, 'onMore' ) );
+               // timestamp for custom sorting
+               $parser->setHook( 'blog:time', array( &$this, 'onBlogTime' ) );
+               $parser->setHook( 'bs:blog:time', array( &$this, 'onBlogTime' ) 
);
                return true;
        }
 
@@ -282,6 +285,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;
        }
 
@@ -294,6 +305,45 @@
         */
        public function onMore( $input, $args, $parser ) {
                $parser->disableCache();
+               return '';
+       }
+
+       /**
+        * Called by parser function for bs:blog:time tag
+        * @param String $input Inner HTML of bs:blog:time tag. Not used.
+        * @param Array $args List of tag attributes.
+        * @param Parser $parser MediaWiki parser object
+        * @return String - empty | error
+        */
+       public function onBlogTime( $input, $args, $parser ) {
+               $oDate = null;
+               if( !isset($args['time']) ) {
+                       //Deprecated: <bs:blog:time timestamp />
+                       //Use: <bs:blog:time time=timestamp />
+                       $aKeys = array_keys($args);
+                       foreach( $aKeys as $sKey ) {
+                               if( !is_numeric($sKey) || strlen( $sKey ) !== 
12 ) {
+                                       continue;
+                               }
+                               if( !$oDate = 
DateTime::createFromFormat('YmdHi', $sKey) ) {
+                                       continue;
+                               } else {
+                                       wfDeprecated(__METHOD__, '2.22.2');
+                                       break;
+                               }
+                       }
+               } else {
+                       $oDate = DateTime::createFromFormat( 'YmdHi', 
$args['time'] );
+               }
+               if( empty($oDate) ) {
+                       $oErrorListView = new ViewTagErrorList( $this );
+                       $oErrorListView->addItem( new ViewTagError(
+                               wfMessage('bs-blog-tag-blogtime-err')->plain() )
+                       );
+                       return $oErrorListView->execute();
+               }
+
+               $parser->getOutput()->setProperty( 'blogtime', 
$oDate->format('YmdHis') );
                return '';
        }
 
@@ -452,27 +502,53 @@
                        $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 = '';
+               $aFields = 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';
+
+                       global $wgDBtype;
+                       switch( $wgDBtype ) {
+                               case 'oracle':
+                                       $aFields['entry_timestamp'] = "NVL( 
pp_value, rev_timestamp )";
+                                       $aConditions[] = "NVL( pp_value, 
rev_timestamp ) < ".wfTimestampNow();
+                                       break;
+                               case 'mssql':
+                                       $aFields['entry_timestamp'] = "ISNULL( 
pp_value, rev_timestamp )";
+                                       $aConditions[] = "ISNULL( pp_value, 
rev_timestamp ) < ".wfTimestampNow();
+                                       break;
+                               case 'postgres':
+                                       $aFields['entry_timestamp'] = "NULLIF( 
pp_value, rev_timestamp )";
+                                       $aConditions[] = "NULLIF( pp_value, 
rev_timestamp ) < ".wfTimestampNow();
+                                       break;
+                               default: //MySQL, SQLite
+                                       //use pp_value if exists
+                                       $aFields['entry_timestamp'] = "IFNULL( 
pp_value, rev_timestamp )";
+                                       //also do not list future entries
+                                       $aConditions[] = "IFNULL( pp_value, 
rev_timestamp ) < ".wfTimestampNow();
+                       }
+                       $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;
                        }
@@ -481,10 +557,11 @@
 
                $res = $dbr->select(
                        $aTables,
-                       $sFiels,
+                       $aFields,
                        $aConditions,
                        __METHOD__,
-                       $aOptions
+                       $aOptions,
+                       $aJoins
                );
 
                $iNumberOfEntries = $dbr->numRows( $res );
diff --git a/Blog/i18n/de.json b/Blog/i18n/de.json
index 3ec420c..04af3e9 100644
--- a/Blog/i18n/de.json
+++ b/Blog/i18n/de.json
@@ -27,5 +27,7 @@
        "bs-blog-pref-imagerendermode": "Bilder anzeigen als:",
        "bs-blog-pref-imagefloatdirection": "Textumfluss: Bildposition",
        "bs-blog-pref-maxentrycharacters": "Anzahl darzustellender Wörter:",
-       "bs-blog-tag-blog-desc": "Zeigt Blog-Einträge auf jeder beliebigen 
Seite an."
+       "bs-blog-tag-blog-desc": "Zeigt Blog-Einträge auf jeder beliebigen 
Seite an.",
+       "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"
 }
diff --git a/Blog/i18n/en.json b/Blog/i18n/en.json
index b5a51cc..77d90d0 100644
--- a/Blog/i18n/en.json
+++ b/Blog/i18n/en.json
@@ -27,5 +27,7 @@
        "bs-blog-pref-imagerendermode": "Display pictures as:",
        "bs-blog-pref-imagefloatdirection": "Text flow: Image position",
        "bs-blog-pref-maxentrycharacters": "Number of words per entry:",
-       "bs-blog-tag-blog-desc": "Display blog entries on every page."
+       "bs-blog-tag-blog-desc": "Display blog entries 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"
 }
diff --git a/Blog/i18n/qqq.json b/Blog/i18n/qqq.json
index e3b228a..de10370 100644
--- a/Blog/i18n/qqq.json
+++ b/Blog/i18n/qqq.json
@@ -30,5 +30,7 @@
        "bs-blog-pref-imagerendermode": "Option in 
[{{canonicalurl:Special:WikiAdmin|mode=Preferences}} 
Special:WikiAdmin?mode=Preferences].\n\nUsed as label for the select box having 
the following items (hard-coded):\n* thumb\n* full\n* none",
        "bs-blog-pref-imagefloatdirection": "Option in 
[{{canonicalurl:Special:WikiAdmin|mode=Preferences}} 
Special:WikiAdmin?mode=Preferences].\n\nUsed as label for the select box having 
the following items (hard-coded):\n* left\n* right\n* none",
        "bs-blog-pref-maxentrycharacters": "Option in 
[{{canonicalurl:Special:WikiAdmin|mode=Preferences}} 
Special:WikiAdmin?mode=Preferences], label for number of words per entry:",
-       "bs-blog-tag-blog-desc": "Used in InsertMagic extension, tag 
description for display blog entries on every page.\n{{Related|Bs-tag-desc}}"
+       "bs-blog-tag-blog-desc": "Used in InsertMagic extension, tag 
description for display blog entries on every page.\n{{Related|Bs-tag-desc}}",
+       "bs-blog-tag-blogtime-desc": "Used in InsertMagic extension, tag 
description for set blog timestamp on every page.\n{{Related|Bs-tag-desc}}",
+       "bs-blog-tag-blogtime-err": "Error message on bs:blog:time tag when 
there is a wrong timestamp format.\nShould be YYYYMMDDHHmm (YmdHi)."
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I15d59f35d8b47607fffb04f90eee89ccf978f3bc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Pwirth <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: Pigpen <[email protected]>
Gerrit-Reviewer: Raimond Spekking <[email protected]>
Gerrit-Reviewer: Robert Vogel <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Tweichart <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to