summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/photo.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-09-07 21:01:51 -0700
committerBharat Mediratta <bharat@menalto.com>2009-09-07 21:01:51 -0700
commitf28353f4e1c573a33dc1c3375585ab040f8be2fc (patch)
treeaa99bcedc2c7e5725733ca452323a7eb57fc9e8c /modules/gallery/helpers/photo.php
parentdccfce4c00024fa170a060b1c4b1d2bb227964ae (diff)
Add the 'Internet Address' field to all items, along with proper
validation for the fields.
Diffstat (limited to 'modules/gallery/helpers/photo.php')
-rw-r--r--modules/gallery/helpers/photo.php16
1 files changed, 13 insertions, 3 deletions
diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php
index 12515330..a56c7e3c 100644
--- a/modules/gallery/helpers/photo.php
+++ b/modules/gallery/helpers/photo.php
@@ -144,7 +144,11 @@ class photo_Core {
$group->input("title")->label(t("Title"));
$group->textarea("description")->label(t("Description"));
$group->input("name")->label(t("Filename"));
- $group->input("slug")->label(t("Internet Address"))->value($photo->slug);
+ $group->input("slug")->label(t("Internet Address"))->value($photo->slug)
+ ->callback("item::validate_url_safe")
+ ->error_messages(
+ "not_url_safe",
+ t("The internet address should contain only letters, numbers, hyphens and underscores"));
$group->upload("file")->label(t("File"))->rules("required|allow[jpg,png,gif,flv,mp4]");
$group->hidden("type")->value("photo");
$group->submit("")->value(t("Upload"));
@@ -159,12 +163,18 @@ class photo_Core {
$group->input("title")->label(t("Title"))->value($photo->title);
$group->textarea("description")->label(t("Description"))->value($photo->description);
$group->input("filename")->label(t("Filename"))->value($photo->name)
- ->error_messages("conflict", t("There is already a file with this name"))
+ ->error_messages("name_conflict", t("There is already a photo or album with this name"))
->callback("item::validate_no_slashes")
->error_messages("no_slashes", t("The photo name can't contain a \"/\""))
->callback("item::validate_no_trailing_period")
->error_messages("no_trailing_period", t("The photo name can't end in \".\""));
- $group->input("slug")->label(t("Internet Address"))->value($photo->slug);
+ $group->input("slug")->label(t("Internet Address"))->value($photo->slug)
+ ->callback("item::validate_url_safe")
+ ->error_messages(
+ "slug_conflict", t("There is already a photo or album with this internet address"))
+ ->error_messages(
+ "not_url_safe",
+ t("The internet address should contain only letters, numbers, hyphens and underscores"));
module::event("item_edit_form", $photo, $form);