summaryrefslogtreecommitdiff
path: root/modules/gallery/models
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/models')
-rw-r--r--modules/gallery/models/cache.php20
-rw-r--r--modules/gallery/models/item.php15
-rw-r--r--modules/gallery/models/task.php40
3 files changed, 67 insertions, 8 deletions
diff --git a/modules/gallery/models/cache.php b/modules/gallery/models/cache.php
new file mode 100644
index 00000000..99e19a6e
--- /dev/null
+++ b/modules/gallery/models/cache.php
@@ -0,0 +1,20 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Cache_Model extends ORM {}
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 7dbbbcb1..85b0c9a7 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -491,14 +491,13 @@ class Item_Model extends ORM_MPTT {
* @return string
*/
public function movie_img($extra_attrs) {
- $attrs = array_merge($extra_attrs,
- array("id" => "player",
- "style" => "display:block;width:400px;height:300px")
- );
- return html::anchor($this->file_url(true), "", $attrs) .
- "<script>flowplayer('player', '" .
- url::abs_file("lib/flowplayer-3.0.5.swf") .
- "'); </script>";
+ $v = new View("movieplayer.html");
+ $v->attrs = array_merge($extra_attrs,
+ array("style" => "display:block;width:{$this->width}px;height:{$this->height}px"));
+ if (empty($v->attrs["id"])) {
+ $v->attrs["id"] = "gMovieId-{$this->id}";
+ }
+ return $v;
}
/**
diff --git a/modules/gallery/models/task.php b/modules/gallery/models/task.php
index 9e3ae5c6..b7e255a2 100644
--- a/modules/gallery/models/task.php
+++ b/modules/gallery/models/task.php
@@ -40,7 +40,47 @@ class Task_Model extends ORM {
return parent::save();
}
+ public function delete() {
+ Cache::instance()->delete($this->_cache_key());
+ return parent::delete();
+ }
+
public function owner() {
return user::lookup($this->owner_id);
}
+
+ /**
+ * Log a message to the task log.
+ * @params $msg mixed a string or array of strings
+ */
+ public function log($msg) {
+ $key = $this->_cache_key();
+ $log = Cache::instance()->get($key);
+
+ if (is_array($msg)) {
+ $msg = implode("\n", $msg);
+ }
+
+ // Save for 30 days.
+ $log .= !empty($log) ? "\n" : "";
+ Cache::instance()->set($key, "$log{$msg}",
+ array("task", "log", "import"), 2592000);
+ }
+
+ /**
+ * Retrieve the cached log information for this task.
+ * @returns the log data or null if there is no log data
+ */
+ public function get_log() {
+ $log_data = Cache::instance()->get($this->_cache_key());
+ return $log_data !== null ? $log_data : false;
+ }
+
+ /**
+ * Build the task cache key
+ * @returns the key to use in access the cache
+ */
+ private function _cache_key() {
+ return md5("$this->id; $this->name; $this->callback");
+ }
} \ No newline at end of file