summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/gallery/helpers/movie.php1
-rw-r--r--modules/gallery/helpers/photo.php1
-rw-r--r--modules/gallery/models/item.php3
-rw-r--r--modules/search/helpers/search.php15
4 files changed, 9 insertions, 11 deletions
diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php
index 2190fc94..98419387 100644
--- a/modules/gallery/helpers/movie.php
+++ b/modules/gallery/helpers/movie.php
@@ -135,6 +135,7 @@ class movie_Core {
$group->input("title")->label(t("Title"))->value($movie->title);
$group->textarea("description")->label(t("Description"))->value($movie->description);
$group->input("filename")->label(t("Filename"))->value($movie->name)
+ ->rules("required")
->error_messages(
"name_conflict", t("There is already a movie, photo or album with this name"))
->callback("item::validate_no_slashes")
diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php
index 692f7111..99f28753 100644
--- a/modules/gallery/helpers/photo.php
+++ b/modules/gallery/helpers/photo.php
@@ -163,6 +163,7 @@ 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)
+ ->rules("required")
->error_messages(
"name_conflict", t("There is already a movie, photo or album with this name"))
->callback("item::validate_no_slashes")
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 5d356841..6f0e3525 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -24,7 +24,8 @@ class Item_Model extends ORM_MPTT {
var $rules = array(
"name" => "required|length[0,255]",
"title" => "required|length[0,255]",
- "description" => "length[0,65535]"
+ "description" => "length[0,65535]",
+ "slug" => "required|length[0,255]"
);
/**
diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php
index 20d26b61..069b5b77 100644
--- a/modules/search/helpers/search.php
+++ b/modules/search/helpers/search.php
@@ -31,21 +31,16 @@ class search_Core {
$access_sql = "";
}
- // Count the total number of rows. We can't do this with our regular query because of the
- // limit statement. It's possible that if we get rid of the limit (but keep the offset) on
- // the 2nd query and combine the two, it might be faster than making 2 separate queries.
- $count_query = "SELECT COUNT(*) AS c " .
- "FROM {items} JOIN {search_records} ON ({items}.`id` = {search_records}.`item_id`) " .
- "WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE) " .
- $access_sql;
- $count = $db->query($count_query)->current()->c;
-
- $query = "SELECT {items}.*, MATCH({search_records}.`data`) AGAINST ('$q') AS `score` " .
+ $query =
+ "SELECT SQL_CALC_FOUND_ROWS {items}.*, " .
+ " MATCH({search_records}.`data`) AGAINST ('$q') AS `score` " .
"FROM {items} JOIN {search_records} ON ({items}.`id` = {search_records}.`item_id`) " .
"WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE) " .
$access_sql .
"ORDER BY `score` DESC " .
"LIMIT $limit OFFSET $offset";
+ $data = $db->query($query);
+ $count = $db->query("SELECT FOUND_ROWS() as c")->current()->c;
return array($count, new ORM_Iterator(ORM::factory("item"), $db->query($query)));
}