Merge branch 'master' of github.com:shish/shimmie2

This commit is contained in:
Shish 2012-06-05 13:09:31 +01:00
commit e89c14c72c
19 changed files with 67 additions and 53 deletions

View File

@ -11,7 +11,16 @@ class BaseThemelet {
$page->add_http_header("HTTP/1.0 $code $title");
$page->set_title($title);
$page->set_heading($title);
$page->add_block(new NavBlock());
$has_nav = false;
foreach($page->blocks as $block) {
if($block->header == "Navigation") {
$has_nav = true;
break;
}
}
if(!$has_nav) {
$page->add_block(new NavBlock());
}
$page->add_block(new Block("Error", $message));
}

View File

@ -386,10 +386,24 @@ function mtimefile($file) {
return "$data_href/$file?$mtime";
}
/*
* like glob, with support for matching very long patterns with braces
*/
function zglob($pattern) {
$r = glob($pattern);
if($r) return $r;
else return array();
$results = array();
if(preg_match('/(.*)\{(.*)\}(.*)/', $pattern, $matches)) {
$braced = explode(",", $matches[2]);
foreach($braced as $b) {
$sub_pattern = $matches[1].$b.$matches[3];
$results = array_merge($results, zglob($sub_pattern));
}
return $results;
}
else {
$r = glob($pattern);
if($r) return $r;
else return array();
}
}
@ -1088,8 +1102,8 @@ function _get_themelet_files($_theme) {
$base_themelets[] = 'themes/'.$_theme.'/layout.class.php';
$base_themelets[] = 'themes/'.$_theme.'/themelet.class.php';
$ext_themelets = glob("ext/{".ENABLED_EXTS."}/theme.php", GLOB_BRACE);
$custom_themelets = glob('themes/'.$_theme.'/{'.ENABLED_EXTS.'}.theme.php', GLOB_BRACE);
$ext_themelets = zglob("ext/{".ENABLED_EXTS."}/theme.php");
$custom_themelets = zglob('themes/'.$_theme.'/{'.ENABLED_EXTS.'}.theme.php');
return array_merge($base_themelets, $ext_themelets, $custom_themelets);
}

View File

@ -54,7 +54,7 @@ class ET extends Extension {
$info['thumb_quality'] = $config->get_int('thumb_quality');
$info['thumb_width'] = $config->get_int('thumb_width');
$info['thumb_height'] = $config->get_int('thumb_height');
$info['thumb_mem'] = $config->get_int("thumb_max_memory");
$info['thumb_mem'] = $config->get_int("thumb_mem_limit");
$info['stat_images'] = $database->get_one("SELECT COUNT(*) FROM images");
$info['stat_comments'] = $database->get_one("SELECT COUNT(*) FROM comments");

View File

@ -141,10 +141,10 @@ class ExtManager extends Extension {
private function get_extensions(/*bool*/ $all) {
$extensions = array();
if($all) {
$exts = glob("ext/*/main.php", GLOB_BRACE);
$exts = zglob("ext/*/main.php");
}
else {
$exts = glob("ext/{".ENABLED_EXTS."}/main.php", GLOB_BRACE);
$exts = zglob("ext/{".ENABLED_EXTS."}/main.php");
}
foreach($exts as $main) {
$extensions[] = new ExtensionInfo($main);

View File

@ -97,7 +97,7 @@ class IcoFileHandler extends Extension {
$w = $config->get_int("thumb_width");
$h = $config->get_int("thumb_height");
$q = $config->get_int("thumb_quality");
$mem = $config->get_int("thumb_max_memory") / 1024 / 1024; // IM takes memory in MB
$mem = $config->get_int("thumb_mem_limit") / 1024 / 1024; // IM takes memory in MB
if($config->get_bool("ico_convert")) {
// "-limit memory $mem" broken?

View File

@ -90,7 +90,6 @@ class PixelFileHandler extends DataHandlerExtension {
$w = $config->get_int("thumb_width");
$h = $config->get_int("thumb_height");
$q = $config->get_int("thumb_quality");
$mem = $config->get_int("thumb_max_memory") / 1024 / 1024; // IM takes memory in MB
// Windows is a special case
if(in_array("OS", $_SERVER) && $_SERVER["OS"] == 'Windows_NT') {

View File

@ -70,8 +70,8 @@ class Home extends Extension {
}
else {
$main_links = '[url=site://post/list]Posts[/url] [url=site://comment/list]Comments[/url] [url=site://tags]Tags[/url]';
if(file_exists("ext/pools")) {$main_links .= ' [url=site://pools]Pools[/url]';}
if(file_exists("ext/wiki")) {$main_links .= ' [url=site://wiki]Wiki[/url]';}
if(class_exists("Pools")) {$main_links .= ' [url=site://pools]Pools[/url]';}
if(class_exists("Wiki")) {$main_links .= ' [url=site://wiki]Wiki[/url]';}
$main_links .= ' [url=site://ext_doc]>>[/url]';
}
$main_links = format_text($main_links);

View File

@ -267,7 +267,9 @@ class ImageIO extends Extension {
$sb->add_int_option("thumb_quality");
$sb->add_label(" % quality ");
$sb->add_shorthand_int_option("thumb_mem_limit", "<br>Max memory use: ");
if($config->get_string("thumb_engine") == "gd") {
$sb->add_shorthand_int_option("thumb_mem_limit", "<br>Max memory use: ");
}
$event->panel->add_block($sb);
}
@ -293,7 +295,7 @@ class ImageIO extends Extension {
if($handler == "merge" || isset($_GET['update'])) {
$merged = array_merge($image->get_tag_array(), $existing->get_tag_array());
send_event(new TagSetEvent($existing, $merged));
if(isset($_GET['rating']) && isset($_GET['update']) && file_exists("ext/rating")){
if(isset($_GET['rating']) && isset($_GET['update']) && class_exists("Ratings")){
send_event(new RatingSetEvent($existing, $user, $_GET['rating']));
}
if(isset($_GET['source']) && isset($_GET['update'])){

View File

@ -21,16 +21,6 @@ class LinkImage extends Extension {
$config->set_default_string("ext_link-img_text-link_format", '$title - $id ($ext $size $filesize)');
}
private function hostify(/*string*/ $str) {
$str = str_replace(" ", "%20", $str);
if(strpos($str, "ttp://") > 0) {
return $str;
}
else {
return "http://" . $_SERVER["HTTP_HOST"] . $str;
}
}
private function data(Image $image) {
global $config;
@ -38,9 +28,9 @@ class LinkImage extends Extension {
$text_link = trim($text_link) == "" ? null : $text_link; // null blank setting so the url gets filled in on the text links.
return array(
'thumb_src' => $this->hostify($image->get_thumb_link()),
'image_src' => $this->hostify($image->get_image_link()),
'post_link' => $this->hostify($_SERVER["REQUEST_URI"]),
'thumb_src' => make_http($image->get_thumb_link()),
'image_src' => make_http($image->get_image_link()),
'post_link' => make_http($_SERVER["REQUEST_URI"]),
'text_link' => $text_link);
}
}

View File

@ -38,13 +38,11 @@ class MassTagger extends Extension {
$ids = explode( ':', $_POST['ids'] );
$ids = array_filter ( $ids , 'is_numeric' );
$ids = array_map( "Image::by_id", $ids );
$images = array_map( "Image::by_id", $ids );
$func = function( $image ) use ( $tag ) {
$tag .= " " . $image->get_tag_list();
$image->set_tags( $tag );
};
array_walk( $ids, $func );
foreach($images as $image) {
$image->set_tags($tag . " " . $image->get_tag_list());
}
$page->set_mode("redirect");
$page->set_redirect(make_link("post/list"));

View File

@ -200,7 +200,7 @@ class TestFinder extends TestSuite {
$dir = "{".ENABLED_EXTS."}";
if(file_exists("ext/$hint/test.php")) $dir = $hint;
$this->TestSuite('All tests');
foreach(glob("ext/$dir/test.php", GLOB_BRACE) as $file) {
foreach(zglob("ext/$dir/test.php") as $file) {
$this->addFile($file);
}
}

View File

@ -438,7 +438,7 @@ class TagList extends Extension {
}
}
if(count($related_tags) > 0) {
if(!empty($related_tags)) {
$this->theme->display_refine_block($page, $related_tags, $wild_tags);
}
}

View File

@ -215,7 +215,9 @@ class Upload extends Extension {
private function tags_for_upload_slot($id) {
if(isset($_POST["tags$id"])) {
$tags = array_merge(Tag::explode($_POST['tags']), Tag::explode($_POST["tags$id"]));
# merge then explode, not explode then merge - else
# one of the merges may create a surplus "tagme"
$tags = Tag::explode($_POST['tags'] . " " . $_POST["tags$id"]);
}
else {
$tags = Tag::explode($_POST['tags']);
@ -327,7 +329,7 @@ class Upload extends Extension {
}
// Checks if url contains rating, also checks if the rating extension is enabled.
if($config->get_string("transload_engine", "none") != "none" && file_exists("ext/rating") && !empty($_GET['rating'])) {
if($config->get_string("transload_engine", "none") != "none" && class_exists("Ratings") && !empty($_GET['rating'])) {
// Rating event will validate that this is s/q/e/u
$rating = strtolower($_GET['rating']);
$rating = $rating[0];

View File

@ -215,10 +215,10 @@ class UploadTheme extends Themelet {
// Bookmarklet checks if shimmie supports ext. If not, won't upload to site/shows alert saying not supported.
$supported_ext = "jpg jpeg gif png";
if(file_exists("ext/handle_flash")){$supported_ext .= " swf";}
if(file_exists("ext/handle_ico")){$supported_ext .= " ico ani cur";}
if(file_exists("ext/handle_mp3")){$supported_ext .= " mp3";}
if(file_exists("ext/handle_svg")){$supported_ext .= " svg";}
if(class_exists("FlashFileHandler")){$supported_ext .= " swf";}
if(class_exists("ICOFileHandler")){$supported_ext .= " ico ani cur";}
if(class_exists("MP3FileHandler")){$supported_ext .= " mp3";}
if(class_exists("SVGFileHandler")){$supported_ext .= " svg";}
$title = "Booru to " . $config->get_string('title');
// CA=0: Ask to use current or new tags | CA=1: Always use current tags | CA=2: Always use new tags
$html .= '<p><a href="javascript:

View File

@ -67,7 +67,7 @@ _start_cache();
try {
// load base files
ctx_log_start("Opening files");
$files = array_merge(glob("core/*.php"), glob("ext/{".ENABLED_EXTS."}/main.php", GLOB_BRACE));
$files = array_merge(zglob("core/*.php"), zglob("ext/{".ENABLED_EXTS."}/main.php"));
foreach($files as $filename) {
require_once $filename;
}

View File

@ -140,11 +140,11 @@ class Layout {
# be nice to be correct
case "post":
case "upload":
if(file_exists("ext/numeric_score")){ $custom_sublinks .= "<li><b>Popular by </b><a href='".make_link('popular_by_day')."'>Day</a>/<a href='".make_link('popular_by_month')."'>Month</a>/<a href='".make_link('popular_by_year')."'>Year</a></li>";}
if(class_exists("NumericScore")){ $custom_sublinks .= "<li><b>Popular by </b><a href='".make_link('popular_by_day')."'>Day</a>/<a href='".make_link('popular_by_month')."'>Month</a>/<a href='".make_link('popular_by_year')."'>Year</a></li>";}
$custom_sublinks .= "<li><a href='".make_link('post/list')."'>All</a></li>";
if(file_exists("ext/favorites")){ $custom_sublinks .= "<li><a href='".make_link("post/list/favorited_by=$username/1")."'>My Favorites</a></li>";}
if(file_exists("ext/rss_images")){ $custom_sublinks .= "<li><a href='".make_link('rss/images')."'>Feed</a></li>";}
if(file_exists("ext/random_image")){ $custom_sublinks .= "<li><a href='".make_link("random_image/view")."'>Random Image</a></li>";}
if(class_exists("Favorites")){ $custom_sublinks .= "<li><a href='".make_link("post/list/favorited_by=$username/1")."'>My Favorites</a></li>";}
if(class_exists("RSS_Images")){ $custom_sublinks .= "<li><a href='".make_link('rss/images')."'>Feed</a></li>";}
if(class_exists("RandomImage")){ $custom_sublinks .= "<li><a href='".make_link("random_image/view")."'>Random Image</a></li>";}
if($hw){ $custom_sublinks .= "<li><a href='".make_link("wiki/posts")."'>Help</a></li>";
}else{ $custom_sublinks .= "<li><a href='".make_link("ext_doc/index")."'>Help</a></li>";}
break;

View File

@ -38,7 +38,7 @@ class CustomViewImageTheme extends ViewImageTheme {
$html .= "<br>Source: <a href='$h_source'>link</a>";
}
if(file_exists("ext/rating")) {
if(class_exists("Ratings")) {
if($image->rating == null || $image->rating == "u"){
$image->rating = "u";
}

View File

@ -94,11 +94,11 @@ class Layout {
# the subnav links aren't shown, but it would
# be nice to be correct
case "post":
if(file_exists("ext/numeric_score")){ $cs .= "<b>Popular by </b><a href='".make_link('popular_by_day')."'>Day</a><b>/</b><a href='".make_link('popular_by_month')."'>Month</a><b>/</b><a href='".make_link('popular_by_year')."'>Year</a> ";}
if(class_exists("NumericScore")){ $cs .= "<b>Popular by </b><a href='".make_link('popular_by_day')."'>Day</a><b>/</b><a href='".make_link('popular_by_month')."'>Month</a><b>/</b><a href='".make_link('popular_by_year')."'>Year</a> ";}
$cs .= "<a class='tab' href='".make_link('post/list')."'>All</a>";
if(file_exists("ext/favorites")){ $cs .= "<a class='tab' href='".make_link("post/list/favorited_by=$username/1")."'>My Favorites</a>";}
if(file_exists("ext/rss_images")){ $cs .= "<a class='tab' href='".make_link('rss/images')."'>Feed</a>";}
if(file_exists("ext/random_image")){ $cs .= "<a class='tab' href='".make_link("random_image/view")."'>Random Image</a>";}
if(class_exists("Favorites")){ $cs .= "<a class='tab' href='".make_link("post/list/favorited_by=$username/1")."'>My Favorites</a>";}
if(class_exists("RSS_Images")){ $cs .= "<a class='tab' href='".make_link('rss/images')."'>Feed</a>";}
if(class_exists("Random_Image")){ $cs .= "<a class='tab' href='".make_link("random_image/view")."'>Random Image</a>";}
if($hw){ $cs .= "<a class='tab' href='".make_link("wiki/posts")."'>Help</a>";
}else{ $cs .= "<a class='tab' href='".make_link("ext_doc/index")."'>Help</a>";}
break;

View File

@ -44,7 +44,7 @@ class CustomViewImageTheme extends ViewImageTheme {
$html .= "<br>Source: <a href='$h_source'>link</a>";
}
if(file_exists("ext/rating")) {
if(class_exists("Ratings")) {
if($image->rating == null || $image->rating == "u"){
$image->rating = "u";
}