diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-06-12 22:44:51 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-06-12 22:44:51 -0700 |
commit | 26314d0ef85d4a1e73ca6c9bd728a4cfb8d46d6b (patch) | |
tree | 7e220587f1684b86ae2c18e46cd4425cc7ed1e7b | |
parent | 4166fbcd67d828d42b0b1d3d27730355ca8dbce0 (diff) |
Create gallery::date_time(), gallery::date() and gallery::time()
functions that format a unix timestamp into a date+time/date/time
string.
Partial fix for ticket #347.
-rw-r--r-- | modules/comment/views/admin_block_recent_comments.html.php | 2 | ||||
-rw-r--r-- | modules/comment/views/admin_comments.html.php | 4 | ||||
-rw-r--r-- | modules/comment/views/comment.html.php | 5 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery.php | 27 | ||||
-rw-r--r-- | modules/gallery/views/admin_block_log_entries.html.php | 2 | ||||
-rw-r--r-- | modules/gallery/views/admin_maintenance.html.php | 4 | ||||
-rw-r--r-- | modules/info/views/info_block.html.php | 2 | ||||
-rw-r--r-- | modules/user/views/admin_users.html.php | 2 |
8 files changed, 38 insertions, 10 deletions
diff --git a/modules/comment/views/admin_block_recent_comments.html.php b/modules/comment/views/admin_block_recent_comments.html.php index d5aab84c..8b9634c5 100644 --- a/modules/comment/views/admin_block_recent_comments.html.php +++ b/modules/comment/views/admin_block_recent_comments.html.php @@ -7,7 +7,7 @@ alt="<?= p::clean($comment->author_name()) ?>" width="32" height="32" /> - <?= date("Y-M-d H:i:s", $comment->created) ?> + <?= gallery::date_time($comment->created) ?> <?= t("<a href=#>%author_name</a> said <em>%comment_text</em>", array("author_name" => p::clean($comment->author_name()), "comment_text" => text::limit_words(p::clean($comment->text), 50))); ?> diff --git a/modules/comment/views/admin_comments.html.php b/modules/comment/views/admin_comments.html.php index 79bdb1f3..e749fde0 100644 --- a/modules/comment/views/admin_comments.html.php +++ b/modules/comment/views/admin_comments.html.php @@ -117,7 +117,7 @@ </td> <td> <div class="right"> - <? $item = $comment->item(); ?> + <? $item = $comment->item() ?> <div class="gItem gPhoto"> <a href="<?= $item->url() ?>"> <? if ($item->has_thumb()): ?> @@ -131,7 +131,7 @@ </a> </div> </div> - <p><?= date("Y-M-d", $comment->created); ?></p> + <p><?= gallery::date($comment->created) ?></p> <?= p::clean($comment->text) ?> </td> <td> diff --git a/modules/comment/views/comment.html.php b/modules/comment/views/comment.html.php index 0337173b..ce52951b 100644 --- a/modules/comment/views/comment.html.php +++ b/modules/comment/views/comment.html.php @@ -8,8 +8,9 @@ width="40" height="40" /> </a> - <?= t("on ") . date("Y-M-d H:i:s", $comment->created) ?> - <a href="#"><?= p::clean($comment->author_name()) ?></a> <?= t("said") ?> + <?= t("on %date_time, %author_name said", + array("date_time" => gallery::date_time($comment->created), + "author_name" => p::clean($comment->author_name()))) ?> </p> <div> <?= p::clean($comment->text) ?> diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 1686571c..e201fded 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -49,4 +49,31 @@ class gallery_Core { static function shutdown() { module::event("gallery_shutdown"); } + + /** + * Return a unix timestamp in a user specified format including date and time. + * @param $timestamp unix timestamp + * @return string + */ + static function date_time($timestamp) { + return date("Y-M-d H:i:s", $timestamp); + } + + /** + * Return a unix timestamp in a user specified format that's just the date. + * @param $timestamp unix timestamp + * @return string + */ + static function date($timestamp) { + return date("Y-M-d", $timestamp); + } + + /** + * Return a unix timestamp in a user specified format that's just the time. + * @param $timestamp unix timestamp + * @return string + */ + static function time($timestamp) { + return date("H:i:s", $timestamp); + } }
\ No newline at end of file diff --git a/modules/gallery/views/admin_block_log_entries.html.php b/modules/gallery/views/admin_block_log_entries.html.php index 38070fe1..44c1657f 100644 --- a/modules/gallery/views/admin_block_log_entries.html.php +++ b/modules/gallery/views/admin_block_log_entries.html.php @@ -3,7 +3,7 @@ <? foreach ($entries as $entry): ?> <li class="<?= log::severity_class($entry->severity) ?>" style="direction: ltr"> <a href="<?= url::site("user/$entry->user_id") ?>"><?= p::clean($entry->user->name) ?></a> - <?= date("Y-M-d H:i:s", $entry->timestamp) ?> + <?= gallery::date_time($entry->timestamp) ?> <?= $entry->message ?> <?= $entry->html ?> </li> diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index 66c4eea0..c47f77f8 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -69,7 +69,7 @@ <? foreach ($running_tasks as $task): ?> <tr class="<?= $task->state == "stalled" ? "gWarning" : "" ?>"> <td> - <?= date("M j, Y H:i:s", $task->updated) ?> + <?= gallery::date_time($task->updated) ?> </td> <td> <?= $task->name ?> @@ -139,7 +139,7 @@ <? foreach ($finished_tasks as $task): ?> <tr class="<?= $task->state == "success" ? "gSuccess" : "gError" ?>"> <td> - <?= date("M j, Y H:i:s", $task->updated) ?> + <?= gallery::date_time($task->updated) ?> </td> <td> <?= $task->name ?> diff --git a/modules/info/views/info_block.html.php b/modules/info/views/info_block.html.php index f8e5f35e..9f9ec5df 100644 --- a/modules/info/views/info_block.html.php +++ b/modules/info/views/info_block.html.php @@ -31,7 +31,7 @@ <? if ($item->captured): ?> <tr> <th><?= t("Captured:") ?></th> - <td><?= date("M j, Y H:i:s", $item->captured)?></td> + <td><?= gallery::date_time($item->captured) ?></td> </tr> <? endif ?> <? if ($item->owner): ?> diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index a99c9506..68486e6d 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -80,7 +80,7 @@ <?= p::clean($user->email) ?> </td> <td> - <?= ($user->last_login == 0) ? "" : date("j-M-y", $user->last_login) ?> + <?= ($user->last_login == 0) ? "" : gallery::date($user->last_login) ?> </td> <td class="gActions"> <a href="<?= url::site("admin/users/edit_user_form/$user->id") ?>" |