2008-11-10 17:32:04 +00:00
|
|
|
<?php defined("SYSPATH") or die("No direct script access.");
|
|
|
|
|
/**
|
|
|
|
|
* Gallery - a web based photo album viewer and editor
|
2009-05-13 20:04:58 +00:00
|
|
|
* Copyright (C) 2000-2009 Bharat Mediratta
|
2008-11-10 17:32:04 +00:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This is the API for handling comments.
|
|
|
|
|
*
|
|
|
|
|
* Note: by design, this class does not do any permission checking.
|
|
|
|
|
*/
|
2008-11-22 06:06:02 +00:00
|
|
|
class comment_Core {
|
2008-12-25 05:12:46 +00:00
|
|
|
static function get_add_form($item) {
|
2009-11-25 08:05:21 -08:00
|
|
|
$form = new Forge("comments/create/{$item->id}", "", "post", array("id" => "g-comment-form"));
|
2009-01-08 17:13:06 +00:00
|
|
|
$group = $form->group("add_comment")->label(t("Add comment"));
|
2009-10-04 00:27:22 -06:00
|
|
|
$group->input("name") ->label(t("Name")) ->id("g-author");
|
|
|
|
|
$group->input("email") ->label(t("Email (hidden)")) ->id("g-email");
|
|
|
|
|
$group->input("url") ->label(t("Website (hidden)"))->id("g-url");
|
|
|
|
|
$group->textarea("text")->label(t("Comment")) ->id("g-text");
|
2008-12-25 05:12:46 +00:00
|
|
|
$group->hidden("item_id")->value($item->id);
|
2009-11-09 11:52:43 -08:00
|
|
|
module::event("comment_add_form", $form);
|
2009-10-25 23:32:49 -06:00
|
|
|
$group->submit("")->value(t("Add"))->class("ui-state-default ui-corner-all");
|
2009-01-10 00:34:23 +00:00
|
|
|
|
2009-10-22 13:09:20 -07:00
|
|
|
$active = identity::active_user();
|
2009-01-10 00:34:23 +00:00
|
|
|
if (!$active->guest) {
|
|
|
|
|
$group->inputs["name"]->value($active->full_name)->disabled("disabled");
|
|
|
|
|
$group->email->value($active->email)->disabled("disabled");
|
|
|
|
|
$group->url->value($active->url)->disabled("disabled");
|
2009-01-16 04:06:03 +00:00
|
|
|
} else {
|
|
|
|
|
$group->inputs["name"]->error_messages("missing", t("You must provide a name"));
|
2009-01-10 00:34:23 +00:00
|
|
|
}
|
2009-01-16 04:06:03 +00:00
|
|
|
$group->text->error_messages("missing", t("You must provide a comment"));
|
2009-01-10 00:34:23 +00:00
|
|
|
|
2008-11-16 07:14:12 +00:00
|
|
|
return $form;
|
|
|
|
|
}
|
2008-11-11 22:46:25 +00:00
|
|
|
}
|
|
|
|
|
|