summaryrefslogtreecommitdiff
path: root/modules/tag/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-11-27 05:00:50 +0000
committerBharat Mediratta <bharat@menalto.com>2008-11-27 05:00:50 +0000
commit5447b8321080afd09387d837a4acfa9c90ddfa16 (patch)
tree1fbaf7cc855066aa8d337282a648d809c921f5dc /modules/tag/helpers
parent8e33f5d7b90335236e14b283ccb6d6ee5db4762d (diff)
Clean up REST pattern in tags:
1) Generate the form in Tags_Controller::_form_add() 2) Process the form submit in Tags_Controller::_create() 3) Create the tag properly This required me to limit our scope to adding one tag at a time, which I think is fine if we're doing Ajax style tag addition.
Diffstat (limited to 'modules/tag/helpers')
-rw-r--r--modules/tag/helpers/tag.php18
-rw-r--r--modules/tag/helpers/tag_block.php9
2 files changed, 12 insertions, 15 deletions
diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php
index 09109cd5..a1939df7 100644
--- a/modules/tag/helpers/tag.php
+++ b/modules/tag/helpers/tag.php
@@ -23,8 +23,9 @@ class tag_Core {
*
* @todo Write test.
*
- * @param ORM $item an item
- * @param string $tag_name a tag name
+ * @param Item_Model $item an item
+ * @param string $tag_name a tag name
+ * @return Tag_Model
* @throws Exception("@todo {$tag_name} WAS_NOT_ADDED_TO {$item->id}")
*/
public static function add($item, $tag_name) {
@@ -46,6 +47,7 @@ class tag_Core {
$tag->count++;
$tag->save();
}
+ return $tag;
}
/**
@@ -59,16 +61,4 @@ class tag_Core {
->limit($count)
->find_all();
}
-
- public static function get_add_form($item_id) {
- $form = new Forge(url::site("form/add/tags/$item_id"), "", "post", array("id" => "gAddTag"));
- $form->input("tags")
- ->label(_("(Enter tags separated by commas)"))
- ->id("gNewTags")
- ->class("text")
- ->value("add new tags...")
- ->rules("required");
- $form->submit(_("Add"));
- return $form;
- }
}
diff --git a/modules/tag/helpers/tag_block.php b/modules/tag/helpers/tag_block.php
index 5cf6aa75..c735ee04 100644
--- a/modules/tag/helpers/tag_block.php
+++ b/modules/tag/helpers/tag_block.php
@@ -17,7 +17,6 @@
* 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_block_Core {
public static function head($theme) {
$url = url::file("modules/tag/js/tag.js");
@@ -39,7 +38,15 @@ class tag_block_Core {
if ($block->content->page_type != "tag") {
$block->content->item = $theme->item();
}
+ } else {
+ $block->content->tags = array();
+ }
+
+ if ($theme->page_type() != "tag") {
+ $controller = new Tags_Controller();
+ $block->content->form = $controller->form_add($theme->item());
}
+
return $block;
}