From 1040302794716463eddc522d2749fc1108cde152 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 12 Sep 2009 17:29:22 -0700 Subject: [PATCH 1/2] Store the stack in a string instead of nested arrays to save space when serializing, which gives us a little more headroom to store big stacks in the context field. --- modules/rescue/helpers/rescue_task.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/rescue/helpers/rescue_task.php b/modules/rescue/helpers/rescue_task.php index c094cf5d..253c6592 100644 --- a/modules/rescue/helpers/rescue_task.php +++ b/modules/rescue/helpers/rescue_task.php @@ -36,25 +36,25 @@ class rescue_task_Core { $total = $task->get("total"); if (empty($total)) { $task->set("total", $total = Database::instance()->count_records("items")); - $task->set("stack", array(array(1, self::LEFT))); + $task->set("stack", "1:" . self::LEFT); $task->set("ptr", 1); $task->set("completed", 0); } $ptr = $task->get("ptr"); - $stack = $task->get("stack"); + $stack = explode(" ", $task->get("stack")); $completed = $task->get("completed"); // Implement a depth-first tree walk using a stack. Not the most efficient, but it's simple. while ($stack && microtime(true) - $start < 1.5) { - list($id, $state) = array_pop($stack); + list($id, $state) = explode(":", array_pop($stack)); switch ($state) { case self::LEFT: self::set_left($id, $ptr++); $item = ORM::factory("item", $id); - array_push($stack, array($id, self::RIGHT)); + array_push($stack, $id . ":" . self::RIGHT); foreach (self::children($id) as $child) { - array_push($stack, array($child->id, self::LEFT)); + array_push($stack, $child->id . ":" . self::LEFT); } break; @@ -65,7 +65,7 @@ class rescue_task_Core { } } - $task->set("stack", $stack); + $task->set("stack", implode(" ", $stack)); $task->set("ptr", $ptr); $task->set("completed", $completed); From 7574c96946d125482f816a11201ccf0692ca9ea8 Mon Sep 17 00:00:00 2001 From: rWatcher Date: Thu, 10 Sep 2009 02:50:04 +0800 Subject: [PATCH 2/2] Initial commit of rWInfo module. Signed-off-by: Bharat Mediratta --- modules/rwinfo/helpers/rwinfo_installer.php | 24 +++++++ modules/rwinfo/helpers/rwinfo_theme.php | 73 +++++++++++++++++++++ modules/rwinfo/module.info | 3 + modules/rwinfo/notes.txt | 5 ++ modules/rwinfo/views/rwinfo_block.html.php | 55 ++++++++++++++++ 5 files changed, 160 insertions(+) create mode 100644 modules/rwinfo/helpers/rwinfo_installer.php create mode 100644 modules/rwinfo/helpers/rwinfo_theme.php create mode 100644 modules/rwinfo/module.info create mode 100644 modules/rwinfo/notes.txt create mode 100644 modules/rwinfo/views/rwinfo_block.html.php diff --git a/modules/rwinfo/helpers/rwinfo_installer.php b/modules/rwinfo/helpers/rwinfo_installer.php new file mode 100644 index 00000000..fd0359ae --- /dev/null +++ b/modules/rwinfo/helpers/rwinfo_installer.php @@ -0,0 +1,24 @@ +item()) { + if ($theme->item->id == 1) { + return ; + } + + $block = new Block(); + $block->css_id = "gMetadata"; + $block->title = $theme->item()->is_album() ? t("Album Info") : t("Photo Info"); + $block->content = new View("rwinfo_block.html"); + return $block; + } + } + + static function thumb_info($theme, $item) { + $results = ""; + if ($item->view_count) { + $results .= "
  • "; + $results .= t("Views: %view_count", array("view_count" => $item->view_count)); + $results .= "
  • "; + } + + if (module::is_active("tag")) { + $tagsItem = ORM::factory("tag") + ->join("items_tags", "tags.id", "items_tags.tag_id") + ->where("items_tags.item_id", $item->id) + ->find_all(); + if (count($tagsItem) > 0) { + $results .= "
  • "; + $results .= t("Tags:") . " "; + for ($counter=0; $counter" . html::clean($tagsItem[$counter]->name) . ", "; + } else { + $results .= "" . html::clean($tagsItem[$counter]->name) . ""; + } + } + $results .= "
  • "; + } + } + + if ($item->owner) { + $results .= "
  • "; + if ($item->owner->url) { + $results .= t("By: %owner_name", array("owner_name" => "owner->url}\">{$item->owner->full_name}")); + } else { + $results .= t("By: %owner_name", array("owner_name" => "{$item->owner->full_name}")); + } + $results .= "
  • "; + } + return $results; + } +} \ No newline at end of file diff --git a/modules/rwinfo/module.info b/modules/rwinfo/module.info new file mode 100644 index 00000000..7bbf8e37 --- /dev/null +++ b/modules/rwinfo/module.info @@ -0,0 +1,3 @@ +name = "rWInfo" +description = "Display extra information about photos and albums" +version = 1 diff --git a/modules/rwinfo/notes.txt b/modules/rwinfo/notes.txt new file mode 100644 index 00000000..38a3ed67 --- /dev/null +++ b/modules/rwinfo/notes.txt @@ -0,0 +1,5 @@ +Drop Title and Description (they're displayed elsewhere in the default theme, no reason to show them twice on the same page) +Hide the info sidebar for the root album (without title and description there really isn't anything worth displaying here) +Display date created for albums only (and continue to display the capture date for everything else) +Display tags in the info sidebar (if the tags module is active). +Display tags when mousing over the thumbnails (if tags module is active). diff --git a/modules/rwinfo/views/rwinfo_block.html.php b/modules/rwinfo/views/rwinfo_block.html.php new file mode 100644 index 00000000..b657bb82 --- /dev/null +++ b/modules/rwinfo/views/rwinfo_block.html.php @@ -0,0 +1,55 @@ + +