summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-20 20:04:57 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-20 20:04:57 +0000
commit50b0613243d7a841306d3674fc258c9e6952f350 (patch)
tree3ffd4ae530ff6f6335bf07d06ce8b7a5a3a7ff57
parent406830cbf8e99919d0d1845e0440c2063cceb301 (diff)
Add view counts and show them properly.
-rw-r--r--core/controllers/photos.php4
-rw-r--r--core/helpers/core_installer.php1
-rw-r--r--modules/info/helpers/info_block.php8
3 files changed, 10 insertions, 3 deletions
diff --git a/core/controllers/photos.php b/core/controllers/photos.php
index 5159d66f..181004a4 100644
--- a/core/controllers/photos.php
+++ b/core/controllers/photos.php
@@ -37,8 +37,10 @@ class Photos_Controller extends Items_Controller {
$template->set_global('parents', $item->parents());
$template->content = new View("photo.html");
-
print $template;
+
+ $item->view_count++;
+ $item->save();
}
/**
diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php
index 9dffeb8d..4ab54da9 100644
--- a/core/helpers/core_installer.php
+++ b/core/helpers/core_installer.php
@@ -60,6 +60,7 @@ class core_installer {
`thumb_width` int(9) default NULL,
`title` char(255) default NULL,
`type` char(32) NOT NULL,
+ `view_count` int(9) default 0,
`width` int(9) default NULL,
PRIMARY KEY (`id`),
KEY `parent_id` (`parent_id`),
diff --git a/modules/info/helpers/info_block.php b/modules/info/helpers/info_block.php
index 5687d770..422e62da 100644
--- a/modules/info/helpers/info_block.php
+++ b/modules/info/helpers/info_block.php
@@ -17,7 +17,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-
class info_block_Core {
public static function sidebar_blocks($theme) {
if ($theme->item()) {
@@ -30,7 +29,12 @@ class info_block_Core {
}
public static function thumb_info($theme, $item) {
- $results = "<li>Views: 321</li>";
+ $results = "";
+ if ($item->view_count) {
+ $results .= "<li>";
+ $results .= sprintf(_("Views: %d"), $item->view_count);
+ $results .= "</li>";
+ }
if ($item->owner) {
$results .= "<li>";
$results .= sprintf(_("By: %s"), "<a href=\"#\">{$item->owner->name}</a>");