summaryrefslogtreecommitdiff
path: root/modules/tag
diff options
context:
space:
mode:
Diffstat (limited to 'modules/tag')
-rw-r--r--modules/tag/controllers/tags.php2
-rw-r--r--modules/tag/helpers/tag_event.php7
-rw-r--r--modules/tag/helpers/tag_installer.php12
-rw-r--r--modules/tag/helpers/tag_rss.php2
-rw-r--r--modules/tag/helpers/tags_rest.php19
-rw-r--r--modules/tag/module.info2
-rw-r--r--modules/tag/tests/Tags_Rest_Helper_Test.php2
7 files changed, 36 insertions, 10 deletions
diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php
index f9a56ccf..f3d456d3 100644
--- a/modules/tag/controllers/tags.php
+++ b/modules/tag/controllers/tags.php
@@ -41,7 +41,7 @@ class Tags_Controller extends Controller {
$template->set_global("children", $tag->items($page_size, $offset));
$template->set_global("children_count", $children_count);
$template->content = new View("dynamic.html");
- $template->content->title = $tag->name;
+ $template->content->title = t("Tag: %tag_name", array("tag_name" => $tag->name));
print $template;
}
diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php
index a790b930..7fe9fba3 100644
--- a/modules/tag/helpers/tag_event.php
+++ b/modules/tag/helpers/tag_event.php
@@ -36,7 +36,8 @@ class tag_event_Core {
$tag = str_replace("\0", "", $tag);
foreach (explode(",", $tag) as $word) {
$word = trim($word);
- if (function_exists("mb_detect_encoding") && mb_detect_encoding($word) != "UTF-8") {
+ if (function_exists("mb_detect_encoding") &&
+ mb_detect_encoding($word, "ISO-8859-1, UTF-8") != "UTF-8") {
$word = utf8_encode($word);
}
$tags[$word] = 1;
@@ -67,8 +68,8 @@ class tag_event_Core {
static function item_edit_form($item, $form) {
$url = url::site("tags/autocomplete");
$form->script("")
- ->text("$('form input[id=tags]').ready(function() {
- $('form input[id=tags]').autocomplete(
+ ->text("$('form input[name=tags]').ready(function() {
+ $('form input[name=tags]').autocomplete(
'$url', {max: 30, multiple: true, multipleSeparator: ',', cacheLength: 1});
});");
diff --git a/modules/tag/helpers/tag_installer.php b/modules/tag/helpers/tag_installer.php
index 6ccaf835..df6f0c65 100644
--- a/modules/tag/helpers/tag_installer.php
+++ b/modules/tag/helpers/tag_installer.php
@@ -22,7 +22,7 @@ class tag_installer {
$db = Database::instance();
$db->query("CREATE TABLE IF NOT EXISTS {tags} (
`id` int(9) NOT NULL auto_increment,
- `name` varchar(64) NOT NULL,
+ `name` varchar(128) NOT NULL,
`count` int(10) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY(`name`))
@@ -36,7 +36,15 @@ class tag_installer {
KEY(`tag_id`, `id`),
KEY(`item_id`, `id`))
DEFAULT CHARSET=utf8;");
- module::set_version("tag", 1);
+ module::set_version("tag", 2);
+ }
+
+ static function upgrade($version) {
+ $db = Database::instance();
+ if ($version == 1) {
+ $db->query("ALTER TABLE {tags} MODIFY COLUMN `name` VARCHAR(128)");
+ module::set_version("tag", $version = 2);
+ }
}
static function uninstall() {
diff --git a/modules/tag/helpers/tag_rss.php b/modules/tag/helpers/tag_rss.php
index 7d52814b..ea3865be 100644
--- a/modules/tag/helpers/tag_rss.php
+++ b/modules/tag/helpers/tag_rss.php
@@ -36,7 +36,7 @@ class tag_rss_Core {
}
$feed = new stdClass();
- $feed->children = $tag->items($limit, $offset, "photo");
+ $feed->items = $tag->items($limit, $offset, "photo");
$feed->max_pages = ceil($tag->count / $limit);
$feed->title = $tag->name;
$feed->description = t("Photos related to %tag_name", array("tag_name" => $tag->name));
diff --git a/modules/tag/helpers/tags_rest.php b/modules/tag/helpers/tags_rest.php
index 434e774a..4f40e7f4 100644
--- a/modules/tag/helpers/tags_rest.php
+++ b/modules/tag/helpers/tags_rest.php
@@ -18,9 +18,26 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class tags_rest_Core {
+ /**
+ * Possible request parameters:
+ * start=#
+ * start at the Nth comment (zero based)
+ *
+ * num=#
+ * return up to N comments (max 100)
+ */
static function get($request) {
$tags = array();
- foreach (ORM::factory("tag")->find_all() as $tag) {
+
+ $num = 10;
+ $start = 0;
+ if (isset($request->params)) {
+ $p = $request->params;
+ $num = isset($p->num) ? min((int)$p->num, 100) : 10;
+ $start = isset($p->start) ? (int)$p->start : 0;
+ }
+
+ foreach (ORM::factory("tag")->find_all($num, $start) as $tag) {
$tags[] = rest::url("tag", $tag);
}
return array("url" => rest::url("tags"),
diff --git a/modules/tag/module.info b/modules/tag/module.info
index e505dd81..8851d119 100644
--- a/modules/tag/module.info
+++ b/modules/tag/module.info
@@ -1,3 +1,3 @@
name = "Tags"
description = "Allows users to tag photos and albums"
-version = 1
+version = 2
diff --git a/modules/tag/tests/Tags_Rest_Helper_Test.php b/modules/tag/tests/Tags_Rest_Helper_Test.php
index 99332c7c..1b909e50 100644
--- a/modules/tag/tests/Tags_Rest_Helper_Test.php
+++ b/modules/tag/tests/Tags_Rest_Helper_Test.php
@@ -45,7 +45,7 @@ class Tags_Rest_Helper_Test extends Gallery_Unit_Test_Case {
}
public function post_test() {
- identity::set_active_user(identity::guest());
+ identity::set_active_user(identity::admin_user());
$request = new stdClass();
$request->params = new stdClass();