diff options
Diffstat (limited to 'modules/tag/helpers')
| -rw-r--r-- | modules/tag/helpers/tag_event.php | 7 | ||||
| -rw-r--r-- | modules/tag/helpers/tag_installer.php | 12 | ||||
| -rw-r--r-- | modules/tag/helpers/tag_rss.php | 2 | ||||
| -rw-r--r-- | modules/tag/helpers/tags_rest.php | 19 |
4 files changed, 33 insertions, 7 deletions
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"), |
