Browse files

Merge branch 'master' into talmdal_dev

Conflicts:
	modules/gallery/controllers/albums.php
	modules/gallery/controllers/movies.php
	modules/gallery/controllers/photos.php
  • Loading branch information...
2 parents 1cd6a61 + 32d25da commit 3060a6f662da66008d57a461bf1c9b5b4aa2b002 @talmdal talmdal committed Dec 26, 2009
Showing with 8,114 additions and 6,500 deletions.
  1. +67 −0 application/Bootstrap.php
  2. +7 −0 application/config/config.php
  3. +1 −1 index.php
  4. +2 −1 installer/database_config.php
  5. +2 −2 modules/akismet/helpers/akismet.php
  6. +1 −1 modules/akismet/tests/Akismet_Helper_Test.php
  7. +14 −12 modules/comment/controllers/admin_comments.php
  8. +1 −1 modules/comment/helpers/comment_block.php
  9. +22 −19 modules/comment/helpers/comment_event.php
  10. +3 −3 modules/comment/helpers/comment_rss.php
  11. +3 −3 modules/comment/helpers/comment_theme.php
  12. +1 −1 modules/comment/models/comment.php
  13. +1 −1 modules/comment/tests/Comment_Event_Test.php
  14. +4 −3 modules/comment/tests/Comment_Helper_Test.php
  15. +2 −2 modules/comment/tests/Comment_Model_Test.php
  16. +13 −12 modules/digibug/controllers/digibug.php
  17. +1 −1 modules/digibug/models/digibug_proxy.php
  18. +0 −4 modules/digibug/tests/Digibug_Controller_Test.php
  19. +14 −14 modules/exif/helpers/exif.php
  20. +4 −1 modules/exif/helpers/exif_event.php
  21. +10 −9 modules/exif/helpers/exif_task.php
  22. +3 −3 modules/exif/helpers/exif_theme.php
  23. +3 −2 modules/forge/libraries/Forge.php
  24. +7 −7 modules/forge/libraries/Form_Input.php
  25. +10 −13 modules/g2_import/helpers/g2_import.php
  26. +4 −1 modules/g2_import/helpers/g2_import_event.php
  27. +2 −2 modules/g2_import/helpers/g2_import_task.php
  28. +2 −1 modules/gallery/config/cache.php
  29. +29 −0 modules/gallery/config/log_file.php
  30. +1 −1 modules/gallery/controllers/admin.php
  31. +2 −1 modules/gallery/controllers/admin_advanced_settings.php
  32. +1 −1 modules/gallery/controllers/admin_dashboard.php
  33. +2 −2 modules/gallery/controllers/admin_identity.php
  34. +4 −3 modules/gallery/controllers/admin_languages.php
  35. +20 −16 modules/gallery/controllers/admin_maintenance.php
  36. +1 −1 modules/gallery/controllers/admin_modules.php
  37. +1 −1 modules/gallery/controllers/admin_sidebar.php
  38. +10 −7 modules/gallery/controllers/albums.php
  39. +2 −4 modules/gallery/controllers/combined.php
  40. +14 −14 modules/gallery/controllers/file_proxy.php
  41. +2 −2 modules/gallery/controllers/items.php
  42. +16 −19 modules/gallery/controllers/l10n_client.php
  43. +1 −1 modules/gallery/controllers/logout.php
  44. +3 −3 modules/gallery/controllers/move.php
  45. +1 −1 modules/gallery/controllers/movies.php
  46. +13 −12 modules/gallery/controllers/packager.php
  47. +1 −1 modules/gallery/controllers/permissions.php
  48. +1 −1 modules/gallery/controllers/photos.php
  49. +1 −1 modules/gallery/controllers/simple_uploader.php
  50. +5 −5 modules/gallery/helpers/MY_url.php
  51. +88 −65 modules/gallery/helpers/access.php
  52. +6 −6 modules/gallery/helpers/album.php
  53. +1 −1 modules/gallery/helpers/auth.php
  54. +7 −8 modules/gallery/helpers/gallery_block.php
  55. +27 −26 modules/gallery/helpers/gallery_event.php
  56. +1 −1 modules/gallery/helpers/gallery_graphics.php
  57. +6 −6 modules/gallery/helpers/gallery_rss.php
  58. +3 −3 modules/gallery/helpers/gallery_task.php
  59. +48 −28 modules/gallery/helpers/graphics.php
  60. +3 −3 modules/gallery/helpers/identity.php
  61. +7 −24 modules/gallery/helpers/item.php
  62. +9 −8 modules/gallery/helpers/l10n_client.php
  63. +6 −6 modules/gallery/helpers/l10n_scanner.php
  64. +3 −3 modules/gallery/helpers/locales.php
  65. +2 −2 modules/gallery/helpers/model_cache.php
  66. +59 −33 modules/gallery/helpers/module.php
  67. +6 −6 modules/gallery/helpers/movie.php
  68. +6 −6 modules/gallery/helpers/photo.php
  69. +4 −4 modules/gallery/helpers/site_status.php
  70. +4 −4 modules/gallery/helpers/task.php
  71. +4 −3 modules/gallery/helpers/theme.php
  72. +2 −2 modules/gallery/hooks/init_gallery.php
  73. +10 −12 modules/gallery/libraries/{I18n.php → Gallery_I18n.php}
  74. +3 −3 modules/gallery/libraries/Gallery_View.php
  75. +2 −2 modules/gallery/libraries/IdentityProvider.php
  76. +23 −34 modules/gallery/libraries/MY_Database.php
  77. +3 −4 modules/gallery/libraries/MY_Forge.php
  78. +31 −0 modules/gallery/libraries/MY_Kohana_Exception.php
  79. +0 −10 modules/gallery/libraries/MY_ORM.php
  80. +33 −3 modules/gallery/libraries/MY_View.php
  81. +92 −54 modules/gallery/libraries/ORM_MPTT.php
  82. +1 −1 modules/gallery/libraries/SafeString.php
  83. +2 −2 modules/gallery/libraries/Sendmail.php
  84. +69 −53 modules/gallery/libraries/drivers/Cache/Database.php
  85. +62 −54 modules/gallery/models/item.php
  86. +1 −1 modules/gallery/models/log.php
  87. +11 −11 modules/gallery/tests/Access_Helper_Test.php
  88. +34 −45 modules/gallery/tests/Cache_Test.php
  89. +95 −58 modules/gallery/tests/Database_Test.php
  90. +15 −12 modules/gallery/tests/DrawForm_Test.php
  91. +12 −4 modules/gallery/tests/File_Structure_Test.php
  92. +5 −5 modules/gallery/tests/{I18n_Test.php → Gallery_I18n_Test.php}
  93. +2 −2 modules/gallery/tests/Gallery_Installer_Test.php
  94. +2 −2 modules/gallery/tests/Item_Helper_Test.php
  95. +11 −4 modules/gallery/tests/Item_Model_Test.php
  96. +4 −4 modules/gallery/tests/ORM_MPTT_Test.php
  97. +1 −3 modules/gallery/tests/Sendmail_Test.php
  98. +2 −1 modules/gallery/tests/controller_auth_data.txt
  99. +6 −5 modules/gallery/tests/xss_data.txt
  100. +279 −0 modules/gallery/views/kohana/error.php
  101. +1 −1 modules/gallery/views/kohana_error_page.php
  102. +20 −19 modules/gallery_unit_test/controllers/gallery_unit_test.php
  103. +25 −0 modules/gallery_unit_test/helpers/MY_request.php
  104. +26 −0 modules/gallery_unit_test/helpers/diff.php
  105. +1 −1 modules/gallery_unit_test/views/kohana_unit_test_cli.php
  106. +6 −6 modules/image_block/helpers/image_block_block.php
  107. +27 −0 modules/kohana23_compat/config/pagination.php
  108. +46 −0 modules/kohana23_compat/libraries/MY_Database_Builder.php
  109. +252 −0 modules/kohana23_compat/libraries/Pagination.php
  110. +13 −13 modules/notification/helpers/notification.php
  111. +22 −20 modules/notification/helpers/notification_event.php
  112. +18 −9 modules/organize/controllers/organize.php
  113. +1 −1 modules/organize/js/organize.js
  114. +1 −1 modules/organize/views/organize_tree.html.php
  115. +3 −3 modules/rss/controllers/rss.php
  116. +2 −2 modules/search/controllers/search.php
  117. +9 −11 modules/search/helpers/search.php
  118. +1 −1 modules/search/helpers/search_event.php
  119. +6 −6 modules/search/helpers/search_task.php
  120. +2 −2 modules/server_add/controllers/admin_server_add.php
  121. +13 −14 modules/server_add/controllers/server_add.php
  122. +1 −1 modules/slideshow/helpers/slideshow_event.php
  123. +10 −10 modules/tag/controllers/admin_tags.php
  124. +5 −5 modules/tag/controllers/tags.php
  125. +17 −11 modules/tag/helpers/tag.php
  126. +1 −1 modules/tag/helpers/tag_event.php
  127. +2 −2 modules/tag/helpers/tag_rss.php
  128. +22 −10 modules/tag/models/tag.php
  129. +3 −3 modules/tag/tests/Tag_Test.php
  130. +69 −27 modules/unit_test/libraries/Unit_Test.php
  131. +11 −11 modules/user/controllers/admin_users.php
  132. +1 −1 modules/user/controllers/password.php
  133. +3 −3 modules/user/helpers/group.php
  134. +4 −4 modules/user/helpers/user.php
  135. +1 −1 modules/user/libraries/drivers/IdentityProvider/Gallery.php
  136. +6 −2 modules/user/models/group.php
  137. +6 −2 modules/user/models/user.php
  138. +4 −4 modules/user/tests/User_Groups_Test.php
  139. +2 −2 modules/user/views/admin_users_group.html.php
  140. +1 −1 system/KohanaLicense.html
  141. +4 −5 system/config/cache.php
  142. +0 −20 system/config/cache_memcache.php
  143. +0 −10 system/config/cache_sqlite.php
  144. +0 −12 system/config/cache_xcache.php
  145. +9 −3 system/config/cookie.php
  146. +3 −2 system/config/database.php
  147. +0 −22 system/config/email.php
  148. +2 −0 system/config/inflector.php
  149. +3 −2 system/config/locale.php
  150. +19 −0 system/config/log.php
  151. +1 −1 system/config/mimes.php
  152. +0 −25 system/config/pagination.php
  153. +4 −0 system/config/profiler.php
  154. +3 −2 system/config/session.php
  155. +75 −40 system/config/sql_types.php
  156. +1 −0 system/config/view.php
  157. +3 −3 system/controllers/template.php
  158. +6 −3 system/core/Benchmark.php
  159. +0 −58 system/core/Bootstrap.php
  160. +41 −40 system/core/Event.php
  161. +262 −936 system/core/Kohana.php
  162. +331 −0 system/core/Kohana_Config.php
  163. +621 −0 system/core/Kohana_Exception.php
  164. +0 −743 system/core/utf8.php
  165. +0 −68 system/core/utf8/from_unicode.php
  166. +0 −22 system/core/utf8/ltrim.php
  167. +0 −88 system/core/utf8/ord.php
  168. +0 −22 system/core/utf8/rtrim.php
  169. +0 −70 system/core/utf8/str_ireplace.php
  170. +0 −54 system/core/utf8/str_pad.php
  171. +0 −33 system/core/utf8/str_split.php
  172. +0 −19 system/core/utf8/strcasecmp.php
  173. +0 −30 system/core/utf8/strcspn.php
  174. +0 −28 system/core/utf8/stristr.php
  175. +0 −21 system/core/utf8/strlen.php
  176. +0 −30 system/core/utf8/strpos.php
  177. +0 −18 system/core/utf8/strrev.php
  178. +0 −30 system/core/utf8/strrpos.php
  179. +0 −30 system/core/utf8/strspn.php
  180. +0 −84 system/core/utf8/strtolower.php
  181. +0 −84 system/core/utf8/strtoupper.php
  182. +0 −75 system/core/utf8/substr.php
  183. +0 −22 system/core/utf8/substr_replace.php
  184. +0 −141 system/core/utf8/to_unicode.php
  185. +0 −77 system/core/utf8/transliterate_to_ascii.php
  186. +0 −17 system/core/utf8/trim.php
  187. +0 −18 system/core/utf8/ucfirst.php
  188. +0 −26 system/core/utf8/ucwords.php
  189. +33 −70 system/helpers/arr.php
  190. +77 −10 system/helpers/cookie.php
  191. +17 −25 system/helpers/date.php
  192. +49 −0 system/helpers/db.php
  193. +90 −58 system/helpers/download.php
  194. +0 −181 system/helpers/email.php
  195. +62 −53 system/helpers/expires.php
  196. +3 −3 system/helpers/feed.php
  197. +3 −3 system/helpers/file.php
  198. +33 −114 system/helpers/form.php
  199. +51 −3 system/helpers/format.php
  200. +13 −93 system/helpers/html.php
  201. +69 −8 system/helpers/inflector.php
  202. +3 −3 system/helpers/num.php
  203. +5 −5 system/helpers/remote.php
  204. +431 −51 system/helpers/request.php
  205. +6 −16 system/helpers/security.php
  206. +225 −37 system/helpers/text.php
  207. +6 −9 system/helpers/upload.php
  208. +18 −9 system/helpers/url.php
  209. +746 −0 system/helpers/utf8.php
  210. +46 −18 system/helpers/valid.php
  211. +0 −10 system/i18n/en_US/cache.php
  212. +0 −59 system/i18n/en_US/calendar.php
  213. +0 −34 system/i18n/en_US/core.php
  214. +0 −15 system/i18n/en_US/database.php
  215. +0 −8 system/i18n/en_US/encrypt.php
  216. +0 −16 system/i18n/en_US/errors.php
  217. +0 −7 system/i18n/en_US/event.php
  218. +0 −33 system/i18n/en_US/image.php
  219. +0 −3 system/i18n/en_US/orm.php
  220. +0 −15 system/i18n/en_US/profiler.php
  221. +0 −6 system/i18n/en_US/session.php
  222. +0 −6 system/i18n/en_US/upload.php
  223. +0 −41 system/i18n/en_US/validation.php
  224. +122 −80 system/libraries/Cache.php
  225. +12 −0 system/libraries/Cache_Exception.php
  226. +3 −44 system/libraries/Controller.php
  227. +432 −1,244 system/libraries/Database.php
  228. +1,011 −0 system/libraries/Database_Builder.php
  229. +83 −0 system/libraries/Database_Cache_Result.php
  230. +17 −0 system/libraries/Database_Exception.php
  231. +10 −11 system/libraries/Database_Expression.php
  232. +228 −0 system/libraries/Database_Mysql.php
  233. +176 −0 system/libraries/Database_Mysql_Result.php
  234. +92 −0 system/libraries/Database_Mysqli.php
  235. +177 −0 system/libraries/Database_Mysqli_Result.php
  236. +95 −0 system/libraries/Database_Query.php
  237. +170 −0 system/libraries/Database_Result.php
Sorry, we could not display the entire diff because too many files (310) changed.
View
67 application/Bootstrap.php
@@ -0,0 +1,67 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * 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.
+ */
+
+// Kohana benchmarks are prefixed to prevent collisions
+define('SYSTEM_BENCHMARK', 'system_benchmark');
+
+// Load benchmarking support
+require SYSPATH.'core/Benchmark'.EXT;
+
+// Start total_execution
+Benchmark::start(SYSTEM_BENCHMARK.'_total_execution');
+
+// Start kohana_loading
+Benchmark::start(SYSTEM_BENCHMARK.'_kohana_loading');
+
+// Load core files
+require SYSPATH.'core/Event'.EXT;
+final class Event extends Event_Core {}
+
+require SYSPATH.'core/Kohana'.EXT;
+final class Kohana extends Kohana_Core {}
+
+require SYSPATH.'core/Kohana_Exception'.EXT;
+require MODPATH.'gallery/libraries/MY_Kohana_Exception'.EXT;
+
+require SYSPATH.'core/Kohana_Config'.EXT;
+require SYSPATH.'libraries/drivers/Config'.EXT;
+require SYSPATH.'libraries/drivers/Config/Array'.EXT;
+final class Kohana_Config extends Kohana_Config_Core {}
+
+// Prepare the environment
+Kohana::setup();
+
+// End kohana_loading
+Benchmark::stop(SYSTEM_BENCHMARK.'_kohana_loading');
+
+// Start system_initialization
+Benchmark::start(SYSTEM_BENCHMARK.'_system_initialization');
+
+// Prepare the system
+Event::run('system.ready');
+
+// Determine routing
+Event::run('system.routing');
+
+// End system_initialization
+Benchmark::stop(SYSTEM_BENCHMARK.'_system_initialization');
+
+// Make the magic happen!
+Event::run('system.execute');
View
7 application/config/config.php
@@ -130,12 +130,19 @@
$config["extension_prefix"] = "MY_";
/**
+ * An optional list of Config Drivers to use, they "fallback" to the one below them if they
+ * dont work so the first driver is tried then so on until it hits the built in "array" driver and fails
+ */
+$config['config_drivers'] = array();
+
+/**
* Additional resource paths, or "modules". Each path can either be absolute
* or relative to the docroot. Modules can include any resource that can exist
* in your application directory, configuration files, controllers, views, etc.
*/
$config["modules"] = array(
MODPATH . "forge",
+ MODPATH . "kohana23_compat",
MODPATH . "gallery", // gallery must be *last* in the order
);
View
2 index.php
@@ -87,4 +87,4 @@
}
// Initialize.
-require SYSPATH . "core/Bootstrap" . EXT;
+require APPPATH . "Bootstrap" . EXT;
View
3 installer/database_config.php
@@ -35,7 +35,8 @@
'host' => '<?php print $host ?>',
'port' => <?php if (!empty($port)): ?>'<?php print $port ?>' <?php else: ?>false<?php endif ?>,
'socket' => false,
- 'database' => '<?php print $dbname ?>'
+ 'database' => '<?php print $dbname ?>',
+ 'params' => null,
),
'character_set' => 'utf8',
'table_prefix' => '<?php print $prefix ?>',
View
4 modules/akismet/helpers/akismet.php
@@ -166,7 +166,7 @@ private static function _http_post($http_request, $host=null) {
}
$response = "";
- Kohana::log("debug", "Send request\n" . print_r($http_request, 1));
+ Kohana_Log::add("debug", "Send request\n" . print_r($http_request, 1));
if (false !== ($fs = @fsockopen($host, 80, $errno, $errstr, 5))) {
fwrite($fs, $http_request);
while ( !feof($fs) ) {
@@ -181,7 +181,7 @@ private static function _http_post($http_request, $host=null) {
} else {
throw new Exception("@todo CONNECTION TO SPAM SERVICE FAILED");
}
- Kohana::log("debug", "Received response\n" . print_r($response, 1));
+ Kohana_Log::add("debug", "Received response\n" . print_r($response, 1));
return $response;
}
View
2 modules/akismet/tests/Akismet_Helper_Test.php
@@ -22,7 +22,7 @@ class Akismet_Helper_Test extends Unit_Test_Case {
public function setup() {
Input::instance()->ip_address = "1.1.1.1";
- Kohana::$user_agent = "Akismet_Helper_Test";
+ request::set_user_agent("Akismet_Helper_Test");
$root = ORM::factory("item", 1);
$this->_comment = comment::create(
View
26 modules/comment/controllers/admin_comments.php
@@ -22,10 +22,11 @@ class Admin_Comments_Controller extends Admin_Controller {
public function index() {
// Get rid of old deleted/spam comments once in a while
- Database::instance()->query(
- "DELETE FROM {comments} " .
- "WHERE state IN ('deleted', 'spam') " .
- "AND unix_timestamp(now()) - updated > 86400 * 7");
+ db::build()
+ ->delete("comments")
+ ->where("state", "IN", array("deleted", "spam"))
+ ->where("updated", "<", "UNIX_TIMESTAMP() - 86400 * 7")
+ ->execute();
// Redirect to the appropriate queue
url::redirect("admin/comments/queue/unpublished");
@@ -48,8 +49,8 @@ public function queue($state) {
$view->content->menu = $this->_menu($view->content->counts);
$view->content->state = $state;
$view->content->comments = ORM::factory("comment")
- ->orderby("created", "DESC")
- ->where("state", $state)
+ ->order_by("created", "DESC")
+ ->where("state", "=", $state)
->limit(self::$items_per_page, ($page - 1) * self::$items_per_page)
->find_all();
$view->content->pager = new Pagination();
@@ -95,11 +96,12 @@ private function _counts() {
$counts->published = 0;
$counts->spam = 0;
$counts->deleted = 0;
- foreach (Database::instance()
- ->select("state", "count(*) as c")
+ foreach (db::build()
+ ->select("state")
+ ->select(array("c" => 'COUNT("*")'))
->from("comments")
- ->groupby("state")
- ->get() as $row) {
+ ->group_by("state")
+ ->execute() as $row) {
$counts->{$row->state} = $row->c;
}
return $counts;
@@ -110,7 +112,7 @@ public function set_state($id, $state) {
$comment = ORM::factory("comment", $id);
$orig = clone $comment;
- if ($comment->loaded) {
+ if ($comment->loaded()) {
$comment->state = $state;
$comment->save();
}
@@ -120,7 +122,7 @@ public function delete_all_spam() {
access::verify_csrf();
ORM::factory("comment")
- ->where("state", "spam")
+ ->where("state", "=", "spam")
->delete_all();
url::redirect("admin/comments/queue/spam");
}
View
2 modules/comment/helpers/comment_block.php
@@ -30,7 +30,7 @@ static function get($block_id) {
$block->title = t("Recent comments");
$block->content = new View("admin_block_recent_comments.html");
$block->content->comments =
- ORM::factory("comment")->orderby("created", "DESC")->limit(5)->find_all();
+ ORM::factory("comment")->order_by("created", "DESC")->limit(5)->find_all();
break;
}
View
41 modules/comment/helpers/comment_event.php
@@ -19,29 +19,33 @@
*/
class comment_event_Core {
static function item_deleted($item) {
- Database::instance()->delete("comments", array("item_id" => $item->id));
+ db::build()
+ ->delete("comments")
+ ->where("item_id", "=", $item->id)
+ ->execute();
}
static function user_deleted($user) {
$guest = identity::guest();
- Database::instance()->from("comments")
- ->set(array("author_id" => $guest->id,
- "guest_email" => null,
- "guest_name" => "guest",
- "guest_url" => null))
- ->where(array("author_id" => $user->id))
- ->update();
+ db::build()
+ ->update("comments")
+ ->set("author_id", $guest->id)
+ ->set("guest_email", null)
+ ->set("guest_name", "guest")
+ ->set("guest_url", null)
+ ->where("author_id", "=", $user->id)
+ ->execute();
}
static function identity_provider_changed($old_provider, $new_provider) {
$guest = identity::guest();
- Database::instance()->from("comments")
- ->set(array("author_id" => $guest->id,
- "guest_email" => null,
- "guest_name" => "guest",
- "guest_url" => null))
- ->where("1 = 1")
- ->update();
+ db::build()
+ ->update("comments")
+ ->set("author_id", $guest->id)
+ ->set("guest_email", null)
+ ->set("guest_name", "guest")
+ ->set("guest_url", null)
+ ->execute();
}
static function admin_menu($menu, $theme) {
@@ -62,12 +66,11 @@ static function photo_menu($menu, $theme) {
}
static function item_index_data($item, $data) {
- foreach (Database::instance()
+ foreach (db::build()
->select("text")
->from("comments")
- ->where("item_id", $item->id)
- ->get()
- ->as_array() as $row) {
+ ->where("item_id", "=", $item->id)
+ ->execute() as $row) {
$data[] = $row->text;
}
}
View
6 modules/comment/helpers/comment_rss.php
@@ -35,11 +35,11 @@ static function feed($feed_id, $offset, $limit, $id) {
$comments = ORM::factory("comment")
->viewable()
- ->where("state", "published")
- ->orderby("created", "DESC");
+ ->where("state", "=", "published")
+ ->order_by("created", "DESC");
if ($feed_id == "item") {
- $comments->where("item_id", $id);
+ $comments->where("item_id", "=", $id);
}
$feed->view = "comment.mrss";
View
6 modules/comment/helpers/comment_theme.php
@@ -37,9 +37,9 @@ static function photo_bottom($theme) {
$view = new View("comments.html");
$view->comments = ORM::factory("comment")
- ->where("item_id", $theme->item()->id)
- ->where("state", "published")
- ->orderby("created", "ASC")
+ ->where("item_id", "=", $theme->item()->id)
+ ->where("state", "=", "published")
+ ->order_by("created", "ASC")
->find_all();
$block->content = $view;
View
2 modules/comment/models/comment.php
@@ -59,7 +59,7 @@ function author_url() {
public function save() {
if (!empty($this->changed)) {
$this->updated = time();
- if (!$this->loaded && empty($this->created)) {
+ if (!$this->loaded() && empty($this->created)) {
$this->created = $this->updated;
$created = true;
}
View
2 modules/comment/tests/Comment_Event_Test.php
@@ -27,6 +27,6 @@ public function deleting_an_item_deletes_its_comments_too_test() {
$album->delete();
$deleted_comment = ORM::factory("comment", $comment->id);
- $this->assert_false($deleted_comment->loaded);
+ $this->assert_false($deleted_comment->loaded());
}
}
View
7 modules/comment/tests/Comment_Helper_Test.php
@@ -23,7 +23,7 @@ class Comment_Helper_Test extends Unit_Test_Case {
public function setup() {
$this->_ip_address = Input::instance()->ip_address;
- $this->_user_agent = Kohana::$user_agent;
+ $this->_user_agent = request::user_agent();
$this->_save = $_SERVER;
$_SERVER["HTTP_ACCEPT"] = "HTTP_ACCEPT";
@@ -33,16 +33,17 @@ public function setup() {
$_SERVER["HTTP_CONNECTION"] = "HTTP_CONNECTION";
$_SERVER["HTTP_HOST"] = "HTTP_HOST";
$_SERVER["HTTP_REFERER"] = "HTTP_REFERER";
- $_SERVER["HTTP_USER_AGENT"] = "HTTP_USER_AGENT";
$_SERVER["QUERY_STRING"] = "QUERY_STRING";
$_SERVER["REMOTE_ADDR"] = "REMOTE_ADDR";
$_SERVER["REMOTE_HOST"] = "REMOTE_HOST";
$_SERVER["REMOTE_PORT"] = "REMOTE_PORT";
+
+ request::set_user_agent("HTTP_USER_AGENT");
}
public function teardown() {
Input::instance()->ip_address = $this->_ip_address;
- Kohana::$user_agent = $this->_user_agent;
+ request::set_user_agent($this->_user_agent);
$_SERVER = $this->_save;
}
View
4 modules/comment/tests/Comment_Model_Test.php
@@ -29,12 +29,12 @@ public function cant_view_comments_for_unviewable_items_test() {
access::allow(identity::everybody(), "view", $album);
$this->assert_equal(
1,
- ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
+ ORM::factory("comment")->viewable()->where("comments.id", "=", $comment->id)->count_all());
// We can't see the comment when permissions are denied on the album
access::deny(identity::everybody(), "view", $album);
$this->assert_equal(
0,
- ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
+ ORM::factory("comment")->viewable()->where("comments.id", "=", $comment->id)->count_all());
}
}
View
25 modules/digibug/controllers/digibug.php
@@ -55,13 +55,13 @@ public function print_photo($id) {
print $v;
}
- public function print_proxy($type, $id) {
+ public function print_proxy($type, $uuid) {
// If its a request for the full size then make sure we are coming from an
// authorized address
if ($type == "full") {
- $remote_addr = ip2long($this->input->server("REMOTE_ADDR"));
+ $remote_addr = ip2long(Input::instance()->server("REMOTE_ADDR"));
if ($remote_addr === false) {
- Kohana::show_404();
+ throw new Kohana_404_Exception();
}
$config = Kohana::config("digibug");
@@ -76,18 +76,18 @@ public function print_proxy($type, $id) {
}
}
if (!$authorized) {
- Kohana::show_404();
+ throw new Kohana_404_Exception();
}
}
- $proxy = ORM::factory("digibug_proxy", array("uuid" => $id));
- if (!$proxy->loaded || !$proxy->item->loaded) {
- Kohana::show_404();
+ $proxy = ORM::factory("digibug_proxy")->where("uuid", "=", $uuid)->find();
+ if (!$proxy->loaded() || !$proxy->item->loaded()) {
+ throw new Kohana_404_Exception();
}
$file = $type == "full" ? $proxy->item->file_path() : $proxy->item->thumb_path();
if (!file_exists($file)) {
- kohana::show_404();
+ throw new Kohana_404_Exception();
}
// We don't need to save the session for this request
@@ -115,9 +115,10 @@ public function close_window() {
}
private function _clean_expired() {
- Database::instance()->query(
- "DELETE FROM {digibug_proxies} " .
- "WHERE request_date <= (CURDATE() - INTERVAL 10 DAY) " .
- "LIMIT 20");
+ db::build()
+ ->delete("digibug_proxies")
+ ->where("request_date", "<=", new Database_Expression("(CURDATE() - INTERVAL 10 DAY)"))
+ ->limit(20)
+ ->execute();
}
}
View
2 modules/digibug/models/digibug_proxy.php
@@ -18,5 +18,5 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Digibug_Proxy_Model extends ORM {
- protected $has_one = array("item");
+ protected $belongs_to = array("item");
}
View
4 modules/digibug/tests/Digibug_Controller_Test.php
@@ -24,10 +24,6 @@ class Digibug_Controller_Test extends Unit_Test_Case {
public function teardown() {
$_SERVER = $this->_server;
-
- if ($this->_proxy) {
- $this->_proxy->delete();
- }
}
public function setup() {
View
28 modules/exif/helpers/exif.php
@@ -39,7 +39,7 @@ static function extract($item) {
if (function_exists("mb_detect_encoding") && mb_detect_encoding($value) != "UTF-8") {
$value = utf8_encode($value);
}
- $keys[$field] = utf8::clean($value);
+ $keys[$field] = Input::clean($value);
if ($field == "DateTime") {
$time = strtotime($value);
@@ -62,7 +62,7 @@ static function extract($item) {
if (function_exists("mb_detect_encoding") && mb_detect_encoding($value) != "UTF-8") {
$value = utf8_encode($value);
}
- $keys[$keyword] = utf8::clean($value);
+ $keys[$keyword] = Input::clean($value);
if ($keyword == "Caption" && !$item->description) {
$item->description = $value;
@@ -73,8 +73,8 @@ static function extract($item) {
}
$item->save();
- $record = ORM::factory("exif_record")->where("item_id", $item->id)->find();
- if (!$record->loaded) {
+ $record = ORM::factory("exif_record")->where("item_id", "=", $item->id)->find();
+ if (!$record->loaded()) {
$record->item_id = $item->id;
}
$record->data = serialize($keys);
@@ -86,9 +86,9 @@ static function extract($item) {
static function get($item) {
$exif = array();
$record = ORM::factory("exif_record")
- ->where("item_id", $item->id)
+ ->where("item_id", "=", $item->id)
->find();
- if (!$record->loaded) {
+ if (!$record->loaded()) {
return array();
}
@@ -139,19 +139,19 @@ private static function _keys() {
}
static function stats() {
- $missing_exif = Database::instance()
+ $missing_exif = db::build()
->select("items.id")
->from("items")
->join("exif_records", "items.id", "exif_records.item_id", "left")
- ->where("type", "photo")
- ->open_paren()
- ->where("exif_records.item_id", null)
- ->orwhere("exif_records.dirty", 1)
- ->close_paren()
- ->get()
+ ->where("type", "=", "photo")
+ ->and_open()
+ ->where("exif_records.item_id", "IS", null)
+ ->or_where("exif_records.dirty", "=", 1)
+ ->close()
+ ->execute()
->count();
- $total_items = ORM::factory("item")->where("type", "photo")->count_all();
+ $total_items = ORM::factory("item")->where("type", "=", "photo")->count_all();
if (!$total_items) {
return array(0, 0, 0);
}
View
5 modules/exif/helpers/exif_event.php
@@ -25,6 +25,9 @@ static function item_created($item) {
}
static function item_deleted($item) {
- Database::instance()->delete("exif_records", array("item_id" => $item->id));
+ db::build()
+ ->delete("exif_records")
+ ->where("item_id", "=", $item->id)
+ ->execute();
}
}
View
19 modules/exif/helpers/exif_task.php
@@ -20,10 +20,11 @@
class exif_task_Core {
static function available_tasks() {
// Delete extra exif_records
- Database::instance()->query(
- "DELETE FROM {exif_records} " .
- "WHERE {exif_records}.`item_id` NOT IN " .
- "(SELECT `id` FROM {items} WHERE {items}.`type` = 'photo')");
+ db::build()
+ ->delete("exif_records")
+ ->where("item_id", "NOT IN",
+ db::build()->select("id")->from("items")->where("type", "=", "photo"))
+ ->execute();
list ($remaining, $total, $percent) = exif::stats();
return array(Task_Definition::factory()
@@ -44,11 +45,11 @@ static function update_index($task) {
$start = microtime(true);
foreach (ORM::factory("item")
->join("exif_records", "items.id", "exif_records.item_id", "left")
- ->where("type", "photo")
- ->open_paren()
- ->where("exif_records.item_id", null)
- ->orwhere("exif_records.dirty", 1)
- ->close_paren()
+ ->where("type", "=", "photo")
+ ->and_open()
+ ->where("exif_records.item_id", "IS", null)
+ ->or_where("exif_records.dirty", "=", 1)
+ ->close()
->find_all() as $item) {
// The query above can take a long time, so start the timer after its done
// to give ourselves a little time to actually process rows.
View
6 modules/exif/helpers/exif_theme.php
@@ -21,11 +21,11 @@ class exif_theme_Core {
static function sidebar_bottom($theme) {
$item = $theme->item();
if ($item && $item->is_photo()) {
- $record = Database::instance()
+ $record = db::build()
->select("key_count")
->from("exif_records")
- ->where("item_id", $item->id)
- ->get()
+ ->where("item_id", "=", $item->id)
+ ->execute()
->current();
if ($record && $record->key_count) {
$view = new View("exif_sidebar.html");
View
5 modules/forge/libraries/Forge.php
@@ -277,7 +277,8 @@ public function render($template = 'forge_template', $custom = FALSE)
{
foreach ($this->hidden as $input)
{
- $hidden[$input->name] = $input->value;
+ $hidden['name'] = $input->name;
+ $hidden['value'] = $input->value;
}
}
@@ -299,7 +300,7 @@ public function render($template = 'forge_template', $custom = FALSE)
// Set the form open and close
$form->open = form::$form_type(arr::remove('action', $this->attr), $this->attr, $hidden);
- $form->close = form::close();
+ $form->close = "</form>";
// Set the inputs
$form->inputs = $this->inputs;
View
14 modules/forge/libraries/Form_Input.php
@@ -317,7 +317,7 @@ public function error_messages($func = NULL, $message = NULL)
$args = is_array($args) ? $args : array();
// Add the label or name to the beginning of the args
- array_unshift($args, $this->label ? utf8::strtolower($this->label) : $this->name);
+ array_unshift($args, $this->label ? mb_strtolower($this->label) : $this->name);
if (isset($this->error_messages[$func]))
{
@@ -333,7 +333,7 @@ public function error_messages($func = NULL, $message = NULL)
case 'valid_email':
case 'valid_ip':
// Fetch an i18n error message
- $error = Kohana::lang('validation.'.$func, $args);
+ $error = 'validation.'.$func;
break;
case substr($func, 0, 6) === 'valid_':
// Strip 'valid_' from func name
@@ -343,11 +343,11 @@ public function error_messages($func = NULL, $message = NULL)
case 'digit':
case 'numeric':
// i18n strings have to be inserted into valid_type
- $args[] = Kohana::lang('validation.'.$func);
- $error = Kohana::lang('validation.valid_type', $args);
+ $args[] = 'validation.'.$func;
+ $error = 'validation.valid_type';
break;
default:
- $error = Kohana::lang('validation.'.$func, $args);
+ $error = 'validation.'.$func;
}
}
}
@@ -490,7 +490,7 @@ public function validate()
if ($this->value != $input->value)
{
// Field does not match
- $this->errors['matches'] = array($input->label ? utf8::strtolower($input->label) : $input->name);
+ $this->errors['matches'] = array($input->label ? mb_strtolower($input->label) : $input->name);
break;
}
}
@@ -529,7 +529,7 @@ protected function rule_required()
protected function rule_length($min, $max = NULL)
{
// Get the length, return if zero
- if (($length = utf8::strlen($this->value)) === 0)
+ if (($length = mb_strlen($this->value)) === 0)
return;
if ($max == NULL)
View
23 modules/g2_import/helpers/g2_import.php
@@ -458,7 +458,7 @@ static function import_item(&$queue) {
switch ($g2_type) {
case "GalleryPhotoItem":
if (!in_array($g2_item->getMimeType(), array("image/jpeg", "image/gif", "image/png"))) {
- Kohana::log("alert", "$g2_path is an unsupported image type; using a placeholder gif");
+ Kohana_Log::add("alert", "$g2_path is an unsupported image type; using a placeholder gif");
$message[] = t("'%path' is an unsupported image type, using a placeholder",
array("path" => $g2_path));
$g2_path = MODPATH . "g2_import/data/broken-image.gif";
@@ -473,7 +473,7 @@ static function import_item(&$queue) {
self::_decode_html_special_chars(self::extract_description($g2_item)),
self::map($g2_item->getOwnerId()));
} catch (Exception $e) {
- Kohana::log(
+ Kohana_Log::add(
"alert", "Corrupt image $g2_path\n" . $e->__toString());
$message[] = t("Corrupt image '%path'", array("path" => $g2_path));
$message[] = $e->__toString();
@@ -493,13 +493,13 @@ static function import_item(&$queue) {
self::_decode_html_special_chars(self::extract_description($g2_item)),
self::map($g2_item->getOwnerId()));
} catch (Exception $e) {
- Kohana::log("alert", "Corrupt movie $g2_path\n" . $e->__toString());
+ Kohana_Log::add("alert", "Corrupt movie $g2_path\n" . $e->__toString());
$message[] = t("Corrupt movie '%path'", array("path" => $g2_path));
$message[] = $e->__toString();
$corrupt = 1;
}
} else {
- Kohana::log("alert", "$g2_path is an unsupported movie type");
+ Kohana_Log::add("alert", "$g2_path is an unsupported movie type");
$message[] = t("'%path' is an unsupported movie type", array("path" => $g2_path));
$corrupt = 1;
}
@@ -611,11 +611,9 @@ static function import_tags_for_item(&$queue) {
array("id" => $g2_item_id, "exception" => $e->__toString()));
}
- $tags = "";
// Multiword tags have the space changed to dots.s
foreach ($tag_names as $tag_name) {
- $tags .= (strlen($tags) ? ", " : "") .
- tag::add($g3_item, $tag_name);
+ tag::add($g3_item, $tag_name);
}
// Tag operations are idempotent so we don't need to map them. Which is good because we don't
@@ -634,11 +632,10 @@ static function import_keywords_as_tags($keywords, $item) {
$delim = " ";
}
- $tags = "";
foreach (preg_split("/$delim/", $keywords) as $keyword) {
$keyword = trim($keyword);
if ($keyword) {
- $tags .= (strlen($tags) ? ", " : "") . tag::add($item, $keyword);
+ tag::add($item, $keyword);
}
}
}
@@ -867,8 +864,8 @@ static function get_tag_item_ids($min_id) {
*/
static function map($g2_id) {
if (!array_key_exists($g2_id, self::$map)) {
- $g2_map = ORM::factory("g2_map")->where("g2_id", $g2_id)->find();
- self::$map[$g2_id] = $g2_map->loaded ? $g2_map->g3_id : null;
+ $g2_map = ORM::factory("g2_map")->where("g2_id", "=", $g2_id)->find();
+ self::$map[$g2_id] = $g2_map->loaded() ? $g2_map->g3_id : null;
}
return self::$map[$g2_id];
@@ -887,7 +884,7 @@ static function set_map($g2_id, $g3_id) {
static function log($msg) {
message::warning($msg);
- Kohana::log("alert", $msg);
+ Kohana_Log::add("alert", $msg);
}
}
@@ -906,7 +903,7 @@ function g2() {
$args = func_get_arg(0);
$ret = array_shift($args);
if ($ret) {
- Kohana::log("error", "Gallery 2 call failed with: " . $ret->getAsText());
+ Kohana_Log::add("error", "Gallery 2 call failed with: " . $ret->getAsText());
throw new Exception("@todo G2_FUNCTION_FAILED");
}
if (count($args) == 1) {
View
5 modules/g2_import/helpers/g2_import_event.php
@@ -19,7 +19,10 @@
*/
class g2_import_event_Core {
static function item_deleted($item) {
- Database::instance()->delete("g2_maps", array("g3_id" => $item->id));
+ db::build()
+ ->delete("g2_maps")
+ ->where("g3_id", "=", $item->id)
+ ->execute();
}
static function item_created($item) {
View
4 modules/g2_import/helpers/g2_import_task.php
@@ -65,8 +65,8 @@ static function import($task) {
$task->set("done", $done);
$root_g2_id = g2(GalleryCoreApi::getDefaultAlbumId());
- $root = ORM::factory("g2_map")->where("g2_id", $root_g2_id)->find();
- if (!$root->loaded) {
+ $root = ORM::factory("g2_map")->where("g2_id", "=", $root_g2_id)->find();
+ if (!$root->loaded()) {
$root->g2_id = $root_g2_id;
$root->g3_id = 1;
$root->save();
View
3 modules/gallery/config/cache.php
@@ -45,5 +45,6 @@
"driver" => "database",
"params" => null,
"lifetime" => 84600,
- "requests" => 1000
+ "requests" => 1000,
+ "prefix" => null,
);
View
29 modules/gallery/config/log_file.php
@@ -0,0 +1,29 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * 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.
+ */
+
+/**
+ * Message logging directory.
+ */
+$config['log_directory'] = VARPATH.'logs';
+
+/**
+ * Permissions of the log file
+ */
+$config['posix_permissions'] = 0644;
View
2 modules/gallery/controllers/admin.php
@@ -44,7 +44,7 @@ public function __call($controller_name, $args) {
}
if (!method_exists($controller_name, $method)) {
- return kohana::show_404();
+ throw new Kohana_404_Exception();
}
call_user_func_array(array(new $controller_name, $method), $args);
View
3 modules/gallery/controllers/admin_advanced_settings.php
@@ -22,7 +22,8 @@ public function index() {
$view = new Admin_View("admin.html");
$view->content = new View("admin_advanced_settings.html");
$view->content->vars = ORM::factory("var")
- ->orderby("module_name", "name")
+ ->order_by("module_name")
+ ->order_by("name")
->find_all();
print $view;
}
View
2 modules/gallery/controllers/admin_dashboard.php
@@ -86,7 +86,7 @@ public function reorder() {
foreach (array("dashboard_sidebar", "dashboard_center") as $location) {
$new_blocks = array();
- foreach ($this->input->get($location, array()) as $id) {
+ foreach (Input::instance()->get($location, array()) as $id) {
$new_blocks[$id] = $active_set[$id];
}
block_manager::set_active($location, $new_blocks);
View
4 modules/gallery/controllers/admin_identity.php
@@ -30,7 +30,7 @@ public function confirm() {
access::verify_csrf();
$v = new View("admin_identity_confirm.html");
- $v->new_provider = $this->input->post("provider");
+ $v->new_provider = Input::instance()->post("provider");
print $v;
}
@@ -40,7 +40,7 @@ public function change() {
$active_provider = module::get_var("gallery", "identity_provider", "user");
$providers = identity::providers();
- $new_provider = $this->input->post("provider");
+ $new_provider = Input::instance()->post("provider");
if ($new_provider != $active_provider) {
View
7 modules/gallery/controllers/admin_languages.php
@@ -36,10 +36,11 @@ public function index($share_translations_form=null) {
public function save() {
access::verify_csrf();
- locales::update_installed($this->input->post("installed_locales"));
+ $input = Input::instance();
+ locales::update_installed($input->post("installed_locales"));
$installed_locales = array_keys(locales::installed());
- $new_default_locale = $this->input->post("default_locale");
+ $new_default_locale = $input->post("default_locale");
if (!in_array($new_default_locale, $installed_locales)) {
if (!empty($installed_locales)) {
$new_default_locale = $installed_locales[0];
@@ -61,7 +62,7 @@ public function share() {
return $this->index($form);
}
- if ($this->input->post("share")) {
+ if (Input::instance()->post("share")) {
l10n_client::submit_translations();
message::success(t("Translations submitted"));
} else {
View
36 modules/gallery/controllers/admin_maintenance.php
@@ -22,11 +22,13 @@ class Admin_Maintenance_Controller extends Admin_Controller {
* Show a list of all available, running and finished tasks.
*/
public function index() {
- $query = Database::instance()->query(
- "UPDATE {tasks} SET `state` = 'stalled' " .
- "WHERE done = 0 " .
- "AND state <> 'stalled' " .
- "AND unix_timestamp(now()) - updated > 15");
+ $query = db::build()
+ ->update("tasks")
+ ->set("state", "stalled")
+ ->where("done", "=", 0)
+ ->where("state", "<>", "stalled")
+ ->where(new Database_Expression("UNIX_TIMESTAMP(NOW()) - `updated` > 15"))
+ ->execute();
$stalled_count = $query->count();
if ($stalled_count) {
log::warning("tasks",
@@ -41,9 +43,9 @@ public function index() {
$view->content = new View("admin_maintenance.html");
$view->content->task_definitions = task::get_definitions();
$view->content->running_tasks = ORM::factory("task")
- ->where("done", 0)->orderby("updated", "DESC")->find_all();
+ ->where("done", "=", 0)->order_by("updated", "DESC")->find_all();
$view->content->finished_tasks = ORM::factory("task")
- ->where("done", 1)->orderby("updated", "DESC")->find_all();
+ ->where("done", "=", 1)->order_by("updated", "DESC")->find_all();
print $view;
}
@@ -75,7 +77,7 @@ public function resume($task_id) {
access::verify_csrf();
$task = ORM::factory("task", $task_id);
- if (!$task->loaded) {
+ if (!$task->loaded()) {
throw new Exception("@todo MISSING_TASK");
}
$view = new View("admin_maintenance_task.html");
@@ -97,7 +99,7 @@ public function show_log($task_id) {
access::verify_csrf();
$task = ORM::factory("task", $task_id);
- if (!$task->loaded) {
+ if (!$task->loaded()) {
throw new Exception("@todo MISSING_TASK");
}
$view = new View("admin_maintenance_show_log.html");
@@ -114,7 +116,7 @@ public function save_log($task_id) {
access::verify_csrf();
$task = ORM::factory("task", $task_id);
- if (!$task->loaded) {
+ if (!$task->loaded()) {
throw new Exception("@todo MISSING_TASK");
}
@@ -138,10 +140,12 @@ public function cancel($task_id) {
public function cancel_running_tasks() {
access::verify_csrf();
- Database::instance()->update(
- "tasks",
- array("done" => 1, "state" => "cancelled"),
- array("done" => 0));
+ db::build()
+ ->update("tasks")
+ ->set("done", 1)
+ ->set("state", "cancelled")
+ ->where("done", "=", 0)
+ ->execute();
message::success(t("All running tasks cancelled"));
url::redirect("admin/maintenance");
}
@@ -164,7 +168,7 @@ public function remove_finished_tasks() {
// Do it the long way so we can call delete and remove the cache.
$finished = ORM::factory("task")
- ->where(array("done" => 1))
+ ->where("done", "=", 1)
->find_all();
foreach ($finished as $task) {
task::remove($task->id);
@@ -184,7 +188,7 @@ public function run($task_id) {
try {
$task = task::run($task_id);
} catch (Exception $e) {
- Kohana::log(
+ Kohana_Log::add(
"error",
sprintf(
"%s in %s at line %s:\n%s", $e->getMessage(), $e->getFile(),
View
2 modules/gallery/controllers/admin_modules.php
@@ -37,7 +37,7 @@ public function save() {
continue;
}
- $desired = $this->input->post($module_name) == 1;
+ $desired = Input::instance()->post($module_name) == 1;
if ($info->active && !$desired && module::is_active($module_name)) {
$changes->deactivate[] = $module_name;
$deactivated_names[] = t($info->name);
View
2 modules/gallery/controllers/admin_sidebar.php
@@ -34,7 +34,7 @@ public function update() {
$available_blocks = block_manager::get_available_site_blocks();
$active_blocks = array();
- foreach ($this->input->get("block", array()) as $block_id) {
+ foreach (Input::instance()->get("block", array()) as $block_id) {
$active_blocks[md5($block_id)] = explode(":", (string) $block_id);
}
block_manager::set_active("site_sidebar", $active_blocks);
View
17 modules/gallery/controllers/albums.php
@@ -42,7 +42,8 @@ public function show($album) {
}
}
- $show = $this->input->get("show");
+ $input = Input::instance();
+ $show = $input->get("show");
if ($show) {
$child = ORM::factory("item", $show);
@@ -57,7 +58,7 @@ public function show($album) {
}
}
- $page = $this->input->get("page", "1");
+ $page = $input->get("page", "1");
$children_count = $album->viewable()->children_count();
$offset = ($page - 1) * $page_size;
$max_pages = max(ceil($children_count / $page_size), 1);
@@ -71,6 +72,7 @@ public function show($album) {
$template = new Theme_View("page.html", "collection", "album");
$template->set_global("page", $page);
+ $template->set_global("page_title", null);
$template->set_global("max_pages", $max_pages);
$template->set_global("page_size", $page_size);
$template->set_global("item", $album);
@@ -81,7 +83,7 @@ public function show($album) {
// We can't use math in ORM or the query builder, so do this by hand. It's important
// that we do this with math, otherwise concurrent accesses will damage accuracy.
- Database::instance()->query(
+ db::query(
"UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $album->id");
print $template;
@@ -93,15 +95,16 @@ public function create($parent_id) {
access::required("view", $album);
access::required("add", $album);
+ $input = Input::instance();
$form = album::get_add_form($album);
if ($form->validate()) {
$new_album = album::create(
$album,
- $this->input->post("name"),
- $this->input->post("title", $this->input->post("name")),
- $this->input->post("description"),
+ $input->post("name"),
+ $input->post("title", $input->post("name")),
+ $input->post("description"),
identity::active_user()->id,
- $this->input->post("slug"));
+ $input->post("slug"));
log::success("content", "Created an album",
html::anchor("albums/$new_album->id", "view album"));
View
6 modules/gallery/controllers/combined.php
@@ -22,15 +22,13 @@ class Combined_Controller extends Controller {
* Return the combined Javascript bundle associated with the given key.
*/
public function javascript($key) {
- $key = substr($key, 0, strlen($key) - 3); // strip off the trailing .js
return $this->_emit("javascript", $key);
}
/**
* Return the combined CSS bundle associated with the given key.
*/
public function css($key) {
- $key = substr($key, 0, strlen($key) - 4); // strip off the trailing .css
return $this->_emit("css", $key);
}
@@ -56,7 +54,7 @@ private function _emit($type, $key) {
}
if (empty($key)) {
- Kohana::show_404();
+ throw new Kohana_404_Exception();
}
$cache = Cache::instance();
@@ -71,7 +69,7 @@ private function _emit($type, $key) {
$content = $cache->get($key);
}
if (empty($content)) {
- Kohana::show_404();
+ throw new Kohana_404_Exception();
}
// $type is either 'javascript' or 'css'
View
28 modules/gallery/controllers/file_proxy.php
@@ -29,7 +29,7 @@
class File_Proxy_Controller extends Controller {
public function __call($function, $args) {
// request_uri: http://example.com/gallery3/var/trunk/albums/foo/bar.jpg
- $request_uri = $this->input->server("REQUEST_URI");
+ $request_uri = Input::instance()->server("REQUEST_URI");
$request_uri = preg_replace("/\?.*/", "", $request_uri);
// var_uri: http://example.com/gallery3/var/
@@ -38,27 +38,27 @@ public function __call($function, $args) {
// Make sure that the request is for a file inside var
$offset = strpos($request_uri, $var_uri);
if ($offset === false) {
- kohana::show_404();
+ throw new Kohana_404_Exception();
}
$file_uri = substr($request_uri, strlen($var_uri));
// Make sure that we don't leave the var dir
if (strpos($file_uri, "..") !== false) {
- kohana::show_404();
+ throw new Kohana_404_Exception();
}
list ($type, $path) = explode("/", $file_uri, 2);
if ($type != "resizes" && $type != "albums" && $type != "thumbs") {
- kohana::show_404();
+ throw new Kohana_404_Exception();
}
// If the last element is .album.jpg, pop that off since it's not a real item
$path = preg_replace("|/.album.jpg$|", "", $path);
// We now have the relative path to the item. Search for it in the path cache
- $item = ORM::factory("item")->where("relative_path_cache", $path)->find();
- if (!$item->loaded) {
+ $item = ORM::factory("item")->where("relative_path_cache", "=", $path)->find();
+ if (!$item->loaded()) {
// We didn't turn it up. It's possible that the relative_path_cache is out of date here.
// There was fallback code, but bharat deleted it in 8f1bca74. If it turns out to be
// necessary, it's easily resurrected.
@@ -69,16 +69,16 @@ public function __call($function, $args) {
if (preg_match('/.jpg$/', $path)) {
foreach (array("flv", "mp4") as $ext) {
$movie_path = preg_replace('/.jpg$/', ".$ext", $path);
- $item = ORM::factory("item")->where("relative_path_cache", $movie_path)->find();
- if ($item->loaded) {
+ $item = ORM::factory("item")->where("relative_path_cache", "=", $movie_path)->find();
+ if ($item->loaded()) {
break;
}
}
}
}
- if (!$item->loaded) {
- kohana::show_404();
+ if (!$item->loaded()) {
+ throw new Kohana_404_Exception();
}
if ($type == "albums") {
@@ -91,21 +91,21 @@ public function __call($function, $args) {
// Make sure we have access to the item
if (!access::can("view", $item)) {
- kohana::show_404();
+ throw new Kohana_404_Exception();
}
// Make sure we have view_full access to the original
if ($type == "albums" && !access::can("view_full", $item)) {
- kohana::show_404();
+ throw new Kohana_404_Exception();
}
// Don't try to load a directory
if ($type == "albums" && $item->is_album()) {
- kohana::show_404();
+ throw new Kohana_404_Exception();
}
if (!file_exists($file)) {
- kohana::show_404();
+ throw new Kohana_404_Exception();
}
// We don't need to save the session for this request
View
4 modules/gallery/controllers/items.php
@@ -20,8 +20,8 @@
class Items_Controller extends Controller {
public function __call($function, $args) {
$item = ORM::factory("item", (int)$function);
- if (!$item->loaded) {
- return Kohana::show_404();
+ if (!$item->loaded()) {
+ throw new Kohana_404_Exception();
}
// Redirect to the more specific resource type, since it will render
View
35 modules/gallery/controllers/l10n_client.php
@@ -24,7 +24,7 @@ public function save() {