[MediaWiki-commits] [Gerrit] Last modified timestamps with hover swap to full ts - change (mediawiki...Flow)

2013-08-26 Thread EBernhardson (WMF) (Code Review)
EBernhardson (WMF) has submitted this change and it was merged.

Change subject: Last modified timestamps with hover swap to full ts
..


Last modified timestamps with hover swap to full ts

Change-Id: I74cb43a9bf04aa17bde57fa3cd8831f30c302668
---
M Flow.i18n.php
M includes/Block/Topic.php
M includes/Model/UUID.php
M includes/Model/Workflow.php
M includes/Templating.php
M modules/discussion/ui.js
M templates/post.html.php
M templates/topic.html.php
8 files changed, 91 insertions(+), 17 deletions(-)

Approvals:
  EBernhardson (WMF): Verified; Looks good to me, approved



diff --git a/Flow.i18n.php b/Flow.i18n.php
index 3e256db..b88058f 100644
--- a/Flow.i18n.php
+++ b/Flow.i18n.php
@@ -70,6 +70,10 @@
 
'flow-paging-rev' => 'More recent topics',
'flow-paging-fwd' => 'Older topics',
+   'flow-last-modified' => 'Last modified about $1',
+   'flow-days-ago' => '$1 {{PLURAL:$1|day|days}} ago',
+   'flow-monthss-ago' => '$1 {{PLURAL:$1|months|monthss}} ago',
+   'flow-years-ago' => '$1 {{PLURAL:$1|year|years}} ago',
 );
 
 /** Message documentation (Message documentation)
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index 82edc2f..baee11f 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -187,6 +187,8 @@
}
 
public function commit() {
+   $this->workflow->updateLastModified();
+
switch( $this->action ) {
case 'reply':
case 'delete-post':
@@ -197,6 +199,7 @@
throw new \MWException( 'Attempt to save null 
revision' );
}
$this->storage->put( $this->newRevision );
+   $this->storage->put( $this->workflow );
$self = $this;
$newRevision = $this->newRevision;
$rootPost = $this->loadRootPost();
@@ -220,12 +223,11 @@
);
 
return $output;
-   break;
+
case 'delete-topic':
$this->storage->put( $this->workflow );
 
return 'success';
-   break;
 
default:
throw new \MWException( "Unknown commit action: 
{$this->action}" );
diff --git a/includes/Model/UUID.php b/includes/Model/UUID.php
index fa60fa7..8a2d5b0 100644
--- a/includes/Model/UUID.php
+++ b/includes/Model/UUID.php
@@ -57,13 +57,25 @@
return wfBaseConvert( $this->getHex(), 16, 10 );
}
 
-   public function getTimestamp() {
+   public function getTimestampObj() {
// First 6 bytes === 48 bits
-   $timePortion = substr( $this->getHex(), 0, 12 );
+   $hex = $this->getHex();
+   $timePortion = substr( $hex, 0, 12 );
$bits_48 = wfBaseConvert( $timePortion, 16, 2, 48 );
$bits_46 = substr( $bits_48, 0, 46 );
$msTimestamp = wfBaseConvert( $bits_46, 2, 10 );
-   return wfTimestamp( TS_MW, intval( $msTimestamp / 1000 ) );
+
+   try {
+   return new \MWTimestamp( intval( $msTimestamp / 1000 ) 
);
+   } catch ( \TimestampException $e ) {
+   wfDebugLog( __CLASS__, __FUNCTION__ . ": bogus time 
value: UUID=$hex; VALUE=$msTimestamp" );
+   return false;
+   }
+   }
+
+   public function getTimestamp() {
+   $ts = $this->getTimestampObj();
+   return $ts ? $ts->getTimestamp( TS_MW ) : false;
}
 
public static function convertUUIDs( $array ) {
diff --git a/includes/Model/Workflow.php b/includes/Model/Workflow.php
index 3f79665..e6e9a9c 100644
--- a/includes/Model/Workflow.php
+++ b/includes/Model/Workflow.php
@@ -20,6 +20,7 @@
// is the active state.
protected $lockState;
protected $definitionId;
+   protected $lastModified;
 
static public function fromStorageRow( array $row, $obj = null ) {
if ( $obj === null ) {
@@ -37,6 +38,7 @@
$obj->userText = $row['workflow_user_text'];
$obj->lockState = $row['workflow_lock_state'];
$obj->definitionId = UUID::create( 
$row['workflow_definition_id'] );
+   $obj->lastModified = $row['workflow_last_update_timestamp'];
return $obj;
}
 
@@ -51,6 +53,7 @@
'workflow_user_text' => $obj->userText,
'workflow_lock_state' => $obj->lockState,
'workflow_definition_id' => 
$obj->definitionId->getBinary(),
+   'workflow_last_update_timestamp' => $obj->lastModified,
);
}
 
@@ -77,6 +80,7 @@
$obj->userText = $user->getName();
$ob

[MediaWiki-commits] [Gerrit] Last modified timestamps with hover swap to full ts - change (mediawiki...Flow)

2013-08-26 Thread EBernhardson (WMF) (Code Review)
EBernhardson (WMF) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/81018


Change subject: Last modified timestamps with hover swap to full ts
..

Last modified timestamps with hover swap to full ts

Change-Id: I74cb43a9bf04aa17bde57fa3cd8831f30c302668
---
M Flow.i18n.php
M includes/Block/Topic.php
M includes/Model/UUID.php
M includes/Model/Workflow.php
M includes/Templating.php
M modules/discussion/discussion.js
M templates/post.html.php
M templates/topic.html.php
8 files changed, 92 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/18/81018/1

diff --git a/Flow.i18n.php b/Flow.i18n.php
index 4cd3713..4feed6d 100644
--- a/Flow.i18n.php
+++ b/Flow.i18n.php
@@ -67,6 +67,11 @@
 
'flow-comment-restored' => 'Restored comment',
'flow-comment-deleted' => 'Deleted comment',
+
+   'flow-last-modified' => 'Last modified about $1',
+   'flow-days-ago' => '$1 {{PLURAL:$1|day|days}} ago',
+   'flow-monthss-ago' => '$1 {{PLURAL:$1|months|monthss}} ago',
+   'flow-years-ago' => '$1 {{PLURAL:$1|year|years}} ago',
 );
 
 /** Message documentation (Message documentation)
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index e5c9d1b..b752aa0 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -187,6 +187,8 @@
}
 
public function commit() {
+   $this->workflow->updateLastModified();
+
switch( $this->action ) {
case 'reply':
case 'delete-post':
@@ -197,6 +199,7 @@
throw new \MWException( 'Attempt to save null 
revision' );
}
$this->storage->put( $this->newRevision );
+   $this->storage->put( $this->workflow );
$self = $this;
$newRevision = $this->newRevision;
$rootPost = $this->loadRootPost();
@@ -220,12 +223,11 @@
);
 
return $output;
-   break;
+
case 'delete-topic':
$this->storage->put( $this->workflow );
 
return 'success';
-   break;
 
default:
throw new \MWException( "Unknown commit action: 
{$this->action}" );
diff --git a/includes/Model/UUID.php b/includes/Model/UUID.php
index fa60fa7..8a2d5b0 100644
--- a/includes/Model/UUID.php
+++ b/includes/Model/UUID.php
@@ -57,13 +57,25 @@
return wfBaseConvert( $this->getHex(), 16, 10 );
}
 
-   public function getTimestamp() {
+   public function getTimestampObj() {
// First 6 bytes === 48 bits
-   $timePortion = substr( $this->getHex(), 0, 12 );
+   $hex = $this->getHex();
+   $timePortion = substr( $hex, 0, 12 );
$bits_48 = wfBaseConvert( $timePortion, 16, 2, 48 );
$bits_46 = substr( $bits_48, 0, 46 );
$msTimestamp = wfBaseConvert( $bits_46, 2, 10 );
-   return wfTimestamp( TS_MW, intval( $msTimestamp / 1000 ) );
+
+   try {
+   return new \MWTimestamp( intval( $msTimestamp / 1000 ) 
);
+   } catch ( \TimestampException $e ) {
+   wfDebugLog( __CLASS__, __FUNCTION__ . ": bogus time 
value: UUID=$hex; VALUE=$msTimestamp" );
+   return false;
+   }
+   }
+
+   public function getTimestamp() {
+   $ts = $this->getTimestampObj();
+   return $ts ? $ts->getTimestamp( TS_MW ) : false;
}
 
public static function convertUUIDs( $array ) {
diff --git a/includes/Model/Workflow.php b/includes/Model/Workflow.php
index 3f79665..e6e9a9c 100644
--- a/includes/Model/Workflow.php
+++ b/includes/Model/Workflow.php
@@ -20,6 +20,7 @@
// is the active state.
protected $lockState;
protected $definitionId;
+   protected $lastModified;
 
static public function fromStorageRow( array $row, $obj = null ) {
if ( $obj === null ) {
@@ -37,6 +38,7 @@
$obj->userText = $row['workflow_user_text'];
$obj->lockState = $row['workflow_lock_state'];
$obj->definitionId = UUID::create( 
$row['workflow_definition_id'] );
+   $obj->lastModified = $row['workflow_last_update_timestamp'];
return $obj;
}
 
@@ -51,6 +53,7 @@
'workflow_user_text' => $obj->userText,
'workflow_lock_state' => $obj->lockState,
'workflow_definition_id' => 
$obj->definitionId->getBinary(),
+   'workflow_last_update_timestamp' => $obj->lastModified,
);
}
 
@@ -77,6