summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/tag/controllers/tag.php76
-rw-r--r--modules/tag/helpers/tag.php5
-rw-r--r--modules/tag/helpers/tag_block.php10
-rw-r--r--modules/tag/js/tag.js24
-rw-r--r--modules/tag/views/tag_block.html.php15
-rw-r--r--themes/default/css/screen.css9
6 files changed, 134 insertions, 5 deletions
diff --git a/modules/tag/controllers/tag.php b/modules/tag/controllers/tag.php
new file mode 100644
index 00000000..e6bdbfe4
--- /dev/null
+++ b/modules/tag/controllers/tag.php
@@ -0,0 +1,76 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2008 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 Tag_Controller extends REST_Controller {
+ protected $resource_type = "tag";
+
+ /**
+ * @see Rest_Controller::_index()
+ */
+ public function _index() {
+ $filter = valid::digit($_GET["filter"]) ? $_GET["filter"] : null;
+ $filter = ($filter <= 0) ? 1 :
+ ($filter >= tag::$NUMBER_OF_BUCKETS ? tag::$NUMBER_OF_BUCKETS - 1 : $filter);
+ print tag_block::sidebar_blocks(null, $filter);
+ }
+
+ /**
+ * @see Rest_Controller::_form_add($parameters)
+ */
+ public function _form_add($parameters) {
+ throw new Exception("@todo Comment_Controller::_form NOT IMPLEMENTED");
+ }
+
+ /**
+ * @see Rest_Controller::_form_edit($resource)
+ */
+ public function _form_edit($tag) {
+ throw new Exception("@todo Comment_Controller::_form NOT IMPLEMENTED");
+ }
+
+ public function _show($tag) {
+ throw new Exception("@todo Tag_Controller::_show NOT IMPLEMENTED");
+ }
+
+ public function _create($tag) {
+ // @todo Productionize this code
+ // 1) Add security checks
+ throw new Exception("@todo Tag_Controller::_create NOT IMPLEMENTED");
+ }
+
+ public function _delete($tag) {
+ // @todo Production this code
+ // 1) Add security checks
+ throw new Exception("@todo Tag_Controller::_delete NOT IMPLEMENTED");
+ }
+
+ public function _update($tag) {
+ // @todo Productionize this
+ // 1) Figure out how to do the right validation here. Validate the form input and apply it to
+ // the model as appropriate.
+ // 2) Figure out how to dispatch according to the needs of the client. Ajax requests from
+ // jeditable will want the changed field back, and possibly the whole item in json.
+ //
+ // For now let's establish a simple protocol where the client passes in a __return parameter
+ // that specifies which field it wants back from the item. Later on we can expand that to
+ // include a data format, etc.
+
+ throw new Exception("@todo Tag_Controller::_update NOT IMPLEMENTED");
+ }
+}
diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php
index 6dfbcf38..70448527 100644
--- a/modules/tag/helpers/tag.php
+++ b/modules/tag/helpers/tag.php
@@ -57,7 +57,8 @@ class tag_Core {
*
* @param int $filter Minimum frequency to be included in the tag cloud
* @return array List of tags each entry has the following format:
- * array("name" => "tag_name", "count" => "frequency", "class" => "bucket")
+ * array("id" => "tag_id", "name" => "tag_name", "count" => "frequency",
+ * "class" => "bucket")
*/
public static function load_buckets($filter=1) {
$tag_list = array();
@@ -84,7 +85,7 @@ class tag_Core {
}
// Set the tag to the current class
- $tag_list[$key] = array("name" => $tag->name, "count" => $tag->count,
+ $tag_list[$key] = array("id" => $tag->id, "name" => $tag->name, "count" => $tag->count,
"class" => "$bucket_count");
$bucket_items++;
$tags_set++;
diff --git a/modules/tag/helpers/tag_block.php b/modules/tag/helpers/tag_block.php
index 629008b6..23a9e276 100644
--- a/modules/tag/helpers/tag_block.php
+++ b/modules/tag/helpers/tag_block.php
@@ -19,12 +19,18 @@
*/
class tag_block_Core {
- public static function sidebar_blocks($theme) {
+ public static function head($theme) {
+ $url = url::file("modules/tag/js/tag.js");
+ return "<script src=\"$url\" type=\"text/javascript\"></script>";
+ }
+
+ public static function sidebar_blocks($theme, $filter=1) {
$block = new Block();
$block->id = "gTag";
$block->title = _("Tags");
$block->content = new View("tag_block.html");
- $block->content->tag_list = tag::load_buckets();
+ $block->content->tag_list = tag::load_buckets($filter);
+ $block->content->filter = $filter;
return $block;
}
} \ No newline at end of file
diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js
new file mode 100644
index 00000000..6157b81b
--- /dev/null
+++ b/modules/tag/js/tag.js
@@ -0,0 +1,24 @@
+$("document").ready(function() {
+ $("#gTagLess").click(function(event){
+ event.preventDefault();
+ get_tag_block($("#gTagLess").attr("href"));
+ });
+ $("#gTagMore").click(function(event){
+ event.preventDefault();
+ get_tag_block($("#gTagMore").attr("href"));
+ });
+});
+
+function get_tag_block(url) {
+ $.get(url, function(data) {
+ $('#gTag').html(data);
+ $("#gTagLess").click(function(event){
+ event.preventDefault();
+ get_tag_block($("#gTagLess").attr("href"));
+ });
+ $("#gTagMore").click(function(event){
+ event.preventDefault();
+ get_tag_block($("#gTagMore").attr("href"));
+ });
+ });
+}
diff --git a/modules/tag/views/tag_block.html.php b/modules/tag/views/tag_block.html.php
index 68ae48d5..9334a5ce 100644
--- a/modules/tag/views/tag_block.html.php
+++ b/modules/tag/views/tag_block.html.php
@@ -1,9 +1,22 @@
<? defined("SYSPATH") or die("No direct script access."); ?>
+<div class="gTagFilter">
+ <? if ($filter < (tag::$NUMBER_OF_BUCKETS - 1)): ?>
+ <? $lessFilter = $filter + 1; ?>
+ <a id="gTagLess" href="<?= url::site("tag/?filter=$lessFilter") ?>">See Less</a>
+ <? endif; ?>
+ <? if ($filter > 1): ?>
+ <? $moreFilter = $filter - 1;?>
+ <a id="gTagMore" href="<?= url::site("tag/?filter=$moreFilter") ?>">See More</a>
+ <? endif; ?>
+
+ <div id="gTagReloadProgress" class="">Resizing Tag Cloud...</div>
+ <hr />
+</div>
<ul>
<? foreach ($tag_list as $tag): ?>
<li class="size<?=$tag["class"] ?>">
<span><?= $tag["count"] ?> photos are tagged with </span>
- <a href="#"><?=$tag["name"] ?></a>
+ <a href="<?=url::site("/tag/{$tag["id"]}?filter=$filter") ?>"><?=$tag["name"] ?></a>
</li>
<? endforeach; ?>
</ul>
diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css
index 52ad3fd9..5fffad62 100644
--- a/themes/default/css/screen.css
+++ b/themes/default/css/screen.css
@@ -408,6 +408,15 @@ table.gMetadata td.toggle {
margin-top: 10px;
}
+#gTag .gTagFilter {
+ margin-left: .5em;
+}
+
+#gTag #gTagReloadProgress {
+ display: none;
+ text-align: left;
+ color: #0e2b52;
+}
/* Tags ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
#gTag ul {