Permalink
Browse files

Merge pull request #464 from shadlaws/fix_20130906_kohana3

Fix 20130906 kohana3
  • Loading branch information...
2 parents ca8e4b5 + 24ef67f commit 01ae40cb6b44529513898a9f40c258997ad1fe14 @shadlaws shadlaws committed Sep 6, 2013
View
@@ -385,7 +385,7 @@ CREATE TABLE {vars} (
`value` text,
PRIMARY KEY (`id`),
UNIQUE KEY `module_name` (`module_name`,`name`)
-) AUTO_INCREMENT=51 DEFAULT CHARSET=utf8;
+) AUTO_INCREMENT=52 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind');
INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind');
@@ -432,6 +432,7 @@ INSERT INTO {vars} VALUES (NULL,'info','show_owner','1');
INSERT INTO {vars} VALUES (NULL,'info','show_name','1');
INSERT INTO {vars} VALUES (NULL,'info','show_captured','1');
INSERT INTO {vars} VALUES (NULL,'info','show_dimensions','1');
+INSERT INTO {vars} VALUES (NULL,'search','item_types','all');
INSERT INTO {vars} VALUES (NULL,'search','wildcard_mode','append_stem');
INSERT INTO {vars} VALUES (NULL,'search','short_search_fix','0');
INSERT INTO {vars} VALUES (NULL,'search','short_search_prefix','1Z');
@@ -62,12 +62,18 @@ public function action_index() {
Module::event("theme_edit_form", $form);
if ($form->load()->validate()) {
- Module::set_var("gallery", "page_size", $form->theme->page_size->val());
- Module::set_var("gallery", "favicon_url", $form->theme->favicon_url->val());
- Module::set_var("gallery", "apple_touch_icon_url", $form->theme->apple_touch_icon_url->val());
- Module::set_var("gallery", "header_text", $form->theme->header_text->val());
- Module::set_var("gallery", "footer_text", $form->theme->footer_text->val());
- Module::set_var("gallery", "show_credits", $form->theme->show_credits->val());
+ Module::set_var("gallery", "page_size", $form->theme->page_size->val());
+ Module::set_var("gallery", "show_credits", $form->theme->show_credits->val());
+
+ // Sanitize values that get placed directly in HTML output by theme.
+ Module::set_var("gallery", "favicon_url",
+ Purifier::clean_html($form->theme->favicon_url->val()));
+ Module::set_var("gallery", "apple_touch_icon_url",
+ Purifier::clean_html($form->theme->apple_touch_icon_url->val()));
+ Module::set_var("gallery", "header_text",
+ Purifier::clean_html($form->theme->header_text->val()));
+ Module::set_var("gallery", "footer_text",
+ Purifier::clean_html($form->theme->footer_text->val()));
foreach (array("thumb", "resize") as $type) {
$size = $form->theme->{"{$type}_size"}->val();
@@ -109,6 +109,10 @@ static function available() {
$module_name = basename(dirname($file));
$modules->$module_name =
new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
+ foreach ($modules->$module_name as &$value) {
+ $value = Purifier::clean_html($value);
+ }
+
$m =& $modules->$module_name;
$m->installed = Module::is_installed($module_name);
$m->active = Module::is_active($module_name);
@@ -26,9 +26,17 @@ public function action_index() {
->add("submit", "input|submit", t("Save"));
$form->settings
->set("label", t("Settings"))
+ ->add("item_types", "select", Module::get_var("search", "item_types", "all"))
->add("wildcard_mode", "select", Module::get_var("search", "wildcard_mode", "append_stem"))
->add("short_search_fix", "checkbox", Module::get_var("search", "short_search_fix", false))
->add("short_search_prefix", "input", Module::get_var("search", "short_search_prefix", "1Z"));
+ $form->settings->item_types
+ ->set("label", t("Item types shown in search results"))
+ ->set("opts", array(
+ "all" => t("all (default)"),
+ "no_albums" => t("no albums; photos and movies only"),
+ "photos_only" => t("photos only; no albums or movies")
+ ));
$form->settings->wildcard_mode
->set("label", t("Wildcard mode"))
->set("opts", array(
@@ -52,6 +60,7 @@ public function action_index() {
Search::mark_dirty();
}
+ Module::set_var("search", "item_types", $form->settings->item_types->val());
Module::set_var("search", "wildcard_mode", $form->settings->wildcard_mode->val());
Module::set_var("search", "short_search_fix", $form->settings->short_search_fix->val());
Module::set_var("search", "short_search_prefix", $form->settings->short_search_prefix->val());
@@ -32,6 +32,7 @@ static function install() {
ENGINE=MyISAM
DEFAULT CHARSET=utf8;");
+ Module::set_var("search", "item_types", "all");
Module::set_var("search", "wildcard_mode", "append_stem");
Module::set_var("search", "short_search_fix", false);
Module::set_var("search", "short_search_prefix", "1Z");
@@ -48,6 +49,7 @@ static function activate() {
static function upgrade($version) {
if ($version == 1) {
// In v2, we added some additional module variables for wildcards and short search fixes.
+ Module::set_var("search", "item_types", "all");
Module::set_var("search", "wildcard_mode", "append_stem");
Module::set_var("search", "short_search_fix", false);
Module::set_var("search", "short_search_prefix", "1Z");
@@ -62,6 +62,19 @@ static function get_search_query($q, $album, $where=array()) {
$q_boolean = Database::instance()->escape(implode("", (array)$q_boolean));
$q_natural = Database::instance()->escape(implode("", (array)$q_natural));
+ switch ($item_types = Module::get_var("search", "item_types", "all")) {
+ case "no_albums":
+ $where[] = array("type", "<>", "album");
+ break;
+ case "photos_only":
+ $where[] = array("type", "=", "photo");
+ break;
+ case "all":
+ break;
+ default:
+ throw new Gallery_Exception("Invalid search item_types setting: $item_types");
+ }
+
// Build the query.
return $album->descendants
->with("search_record")
@@ -124,7 +124,6 @@ public static function set($name, $value, $expiration = NULL)
*
* @param string $name cookie name
* @return boolean
- * @uses Cookie::set
*/
public static function delete($name)
{
@@ -16,8 +16,8 @@
class Kohana_Core {
// Release version and codename
- const VERSION = '3.3.0';
- const CODENAME = 'badius';
+ const VERSION = '3.3.1';
+ const CODENAME = 'peregrinus';
// Common environment type constants for consistency and convenience
const PRODUCTION = 10;
@@ -49,7 +49,7 @@ function koggle(elem)
}
</script>
<div id="kohana_error">
- <h1><span class="type"><?php echo $class ?> [ <?php echo $code ?> ]:</span> <span class="message"><?php echo HTML::chars($message) ?></span></h1>
+ <h1><span class="type"><?php echo $class ?> [ <?php echo $code ?> ]:</span> <span class="message"><?php echo htmlspecialchars( (string) $message, ENT_QUOTES, Kohana::$charset, TRUE); ?></span></h1>
<div id="<?php echo $error_id ?>" class="content">
<p><span class="file"><?php echo Debug::path($file) ?> [ <?php echo $line ?> ]</span></p>
<?php echo Debug::source($file, $line) ?>
@@ -118,7 +118,7 @@ function koggle(elem)
<table cellspacing="0">
<?php foreach ($GLOBALS[$var] as $key => $value): ?>
<tr>
- <td><code><?php echo HTML::chars($key) ?></code></td>
+ <td><code><?php echo htmlspecialchars( (string) $key, ENT_QUOTES, Kohana::$charset, TRUE); ?></code></td>
<td><pre><?php echo Debug::dump($value) ?></pre></td>
</tr>
<?php endforeach ?>

0 comments on commit 01ae40c

Please sign in to comment.