commit
ae3ee1fe79
9 changed files with 45 additions and 30 deletions
|
@ -69,7 +69,7 @@ abstract class BaseConfig implements Config {
|
|||
$this->save($name);
|
||||
}
|
||||
public function set_array(/*string*/ $name, $value) {
|
||||
assert(is_array($value));
|
||||
assert(isset($value) && is_array($value));
|
||||
$this->values[$name] = implode(",", $value);
|
||||
$this->save($name);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ abstract class BaseConfig implements Config {
|
|||
}
|
||||
}
|
||||
public function set_default_array(/*string*/ $name, $value) {
|
||||
assert(is_array($value));
|
||||
assert(isset($value) && is_array($value));
|
||||
if(is_null($this->get($name))) {
|
||||
$this->values[$name] = implode(",", $value);
|
||||
}
|
||||
|
|
|
@ -148,9 +148,9 @@ class Image {
|
|||
public static function count_images($tags=array()) {
|
||||
assert(is_array($tags));
|
||||
global $database;
|
||||
$tag_count = count($tags);
|
||||
|
||||
if($tag_count == 0) {
|
||||
$tag_count = count($tags);
|
||||
|
||||
if($tag_count === 0) {
|
||||
$total = $database->cache->get("image-count");
|
||||
if(!$total) {
|
||||
$total = $database->get_one("SELECT COUNT(*) FROM images");
|
||||
|
@ -158,7 +158,7 @@ class Image {
|
|||
}
|
||||
return $total;
|
||||
}
|
||||
else if($tag_count == 1 && !preg_match("/[:=><\*\?]/", $tags[0])) {
|
||||
else if($tag_count === 1 && !preg_match("/[:=><\*\?]/", $tags[0])) {
|
||||
$term = Tag::resolve_alias($tags[0]);
|
||||
return $database->get_one(
|
||||
$database->scoreql_to_sql("SELECT count FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"),
|
||||
|
@ -207,7 +207,7 @@ class Image {
|
|||
$dir = "ASC";
|
||||
}
|
||||
|
||||
if(count($tags) == 0) {
|
||||
if(count($tags) === 0) {
|
||||
$row = $database->get_row('SELECT images.* FROM images WHERE images.id '.$gtlt.' '.$this->id.' ORDER BY images.id '.$dir.' LIMIT 1');
|
||||
}
|
||||
else {
|
||||
|
@ -584,14 +584,14 @@ class Image {
|
|||
$_flexihash = new Flexihash();
|
||||
foreach(explode(",", $opts) as $opt) {
|
||||
$parts = explode("=", $opt);
|
||||
$parts_count = count($parts);
|
||||
$parts_count = count($parts);
|
||||
$opt_val = "";
|
||||
$opt_weight = 0;
|
||||
if($parts_count == 2) {
|
||||
if($parts_count === 2) {
|
||||
$opt_val = $parts[0];
|
||||
$opt_weight = $parts[1];
|
||||
}
|
||||
elseif($parts_count == 1) {
|
||||
elseif($parts_count === 1) {
|
||||
$opt_val = $parts[0];
|
||||
$opt_weight = 1;
|
||||
}
|
||||
|
@ -694,9 +694,11 @@ class Image {
|
|||
}
|
||||
$img_search = new Querylet($sql, $terms);
|
||||
|
||||
// How many tag querylets are there?
|
||||
$count_tag_querylets = count($tag_querylets);
|
||||
|
||||
// no tags, do a simple search (+image metadata if we have any)
|
||||
if(count($tag_querylets) == 0) {
|
||||
if($count_tag_querylets === 0) {
|
||||
$query = new Querylet("SELECT images.* FROM images ");
|
||||
|
||||
if(!empty($img_search->sql)) {
|
||||
|
@ -706,7 +708,7 @@ class Image {
|
|||
}
|
||||
|
||||
// one positive tag (a common case), do an optimised search
|
||||
else if(count($tag_querylets) == 1 && $tag_querylets[0]->positive) {
|
||||
else if($count_tag_querylets === 1 && $tag_querylets[0]->positive) {
|
||||
$query = new Querylet($database->scoreql_to_sql("
|
||||
SELECT images.* FROM images
|
||||
JOIN image_tags ON images.id=image_tags.image_id
|
||||
|
@ -990,7 +992,7 @@ class Tag {
|
|||
}
|
||||
}
|
||||
|
||||
if(count($tag_array) == 0 && $tagme) {
|
||||
if(count($tag_array) === 0 && $tagme) {
|
||||
$tag_array = array("tagme");
|
||||
}
|
||||
|
||||
|
@ -1106,8 +1108,8 @@ function move_upload_to_archive(DataUploadEvent $event) {
|
|||
function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) {
|
||||
global $config;
|
||||
|
||||
if($orig_width == 0) $orig_width = 192;
|
||||
if($orig_height == 0) $orig_height = 192;
|
||||
if($orig_width === 0) $orig_width = 192;
|
||||
if($orig_height === 0) $orig_height = 192;
|
||||
|
||||
if($orig_width > $orig_height * 5) $orig_width = $orig_height * 5;
|
||||
if($orig_height > $orig_width * 5) $orig_height = $orig_width * 5;
|
||||
|
|
|
@ -797,7 +797,7 @@ function data_path($filename) {
|
|||
function transload($url, $mfile) {
|
||||
global $config;
|
||||
|
||||
if($config->get_string("transload_engine") == "curl" && function_exists("curl_init")) {
|
||||
if($config->get_string("transload_engine") === "curl" && function_exists("curl_init")) {
|
||||
$ch = curl_init($url);
|
||||
$fp = fopen($mfile, "w");
|
||||
|
||||
|
@ -814,7 +814,7 @@ function transload($url, $mfile) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if($config->get_string("transload_engine") == "wget") {
|
||||
if($config->get_string("transload_engine") === "wget") {
|
||||
$s_url = escapeshellarg($url);
|
||||
$s_mfile = escapeshellarg($mfile);
|
||||
system("wget --no-check-certificate $s_url --output-document=$s_mfile");
|
||||
|
@ -822,7 +822,7 @@ function transload($url, $mfile) {
|
|||
return file_exists($mfile);
|
||||
}
|
||||
|
||||
if($config->get_string("transload_engine") == "fopen") {
|
||||
if($config->get_string("transload_engine") === "fopen") {
|
||||
$fp = @fopen($url, "r");
|
||||
if(!$fp) {
|
||||
return false;
|
||||
|
|
|
@ -112,7 +112,7 @@ class Artists extends Extension {
|
|||
global $database;
|
||||
|
||||
$author = strtolower($event->author);
|
||||
if (strlen($author) == 0 || strpos($author, " "))
|
||||
if (strlen($author) === 0 || strpos($author, " "))
|
||||
return;
|
||||
|
||||
$paddedAuthor = str_replace(" ", "_", $author);
|
||||
|
@ -709,7 +709,7 @@ class Artists extends Extension {
|
|||
if (is_null($aliasID) || !is_numeric($aliasID))
|
||||
return;
|
||||
|
||||
if (is_null($alias) || strlen($alias) == 0)
|
||||
if (is_null($alias) || strlen($alias) === 0)
|
||||
return;
|
||||
|
||||
global $user;
|
||||
|
@ -767,7 +767,7 @@ class Artists extends Extension {
|
|||
if (is_null($memberID) || !is_numeric($memberID))
|
||||
return;
|
||||
|
||||
if (is_null($memberName) || strlen($memberName) == 0)
|
||||
if (is_null($memberName) || strlen($memberName) === 0)
|
||||
return;
|
||||
|
||||
global $user;
|
||||
|
@ -796,7 +796,7 @@ class Artists extends Extension {
|
|||
global $user;
|
||||
|
||||
$name = html_escape(strtolower($_POST["name"]));
|
||||
if (is_null($name) || (strlen($name) == 0) || strpos($name, " "))
|
||||
if (is_null($name) || (strlen($name) === 0) || strpos($name, " "))
|
||||
return -1;
|
||||
|
||||
$notes = html_escape(ucfirst($_POST["notes"]));
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
$ys = ys($log);
|
||||
$posts = $ys->posts();
|
||||
|
||||
if (sizeof($posts) == 0)
|
||||
if (sizeof($posts) === 0)
|
||||
$html .= '
|
||||
<div id="ys-post-1" class="ys-post ys-first ys-admin-post">
|
||||
<span class="ys-post-timestamp">13:37</span>
|
||||
|
|
|
@ -162,10 +162,13 @@ class Index extends Extension {
|
|||
$search_terms = $event->get_search_terms();
|
||||
$page_number = $event->get_page_number();
|
||||
$page_size = $event->get_page_size();
|
||||
|
||||
$count_search_terms = count($search_terms);
|
||||
|
||||
try {
|
||||
#log_debug("index", "Search for ".implode(" ", $search_terms), false, array("terms"=>$search_terms));
|
||||
$total_pages = Image::count_pages($search_terms);
|
||||
if(SPEED_HAX && count($search_terms) == 0 && ($page_number < 10)) { // extra caching for the first few post/list pages
|
||||
if(SPEED_HAX && $count_search_terms === 0 && ($page_number < 10)) { // extra caching for the first few post/list pages
|
||||
$images = $database->cache->get("post-list-$page_number");
|
||||
if(!$images) {
|
||||
$images = Image::find_images(($page_number-1)*$page_size, $page_size, $search_terms);
|
||||
|
@ -182,11 +185,13 @@ class Index extends Extension {
|
|||
$images = array();
|
||||
}
|
||||
|
||||
if(count($search_terms) == 0 && count($images) == 0 && $page_number == 1) {
|
||||
$count_images = count($images);
|
||||
|
||||
if($count_search_terms === 0 && $count_images === 0 && $page_number === 1) {
|
||||
$this->theme->display_intro($page);
|
||||
send_event(new PostListBuildingEvent($search_terms));
|
||||
}
|
||||
else if(count($search_terms) > 0 && count($images) == 1 && $page_number == 1) {
|
||||
else if($count_search_terms > 0 && $count_images === 1 && $page_number === 1) {
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link('post/view/'.$images[0]->id));
|
||||
}
|
||||
|
|
|
@ -256,7 +256,9 @@ EOD;
|
|||
$url=$matches[1][0];
|
||||
}
|
||||
|
||||
for($i=0;$i<count($pages_matched);$i++) {
|
||||
$count_pages_matched = count($pages_matched);
|
||||
|
||||
for($i=0; $i < $count_pages_matched; $i++) {
|
||||
if($url == $pages_matched[$i]) {
|
||||
$html = "<li class='current-page'><a href='$link'>$desc</a></li>";
|
||||
}
|
||||
|
|
|
@ -282,7 +282,9 @@ EOD;
|
|||
$url=$matches[1][0];
|
||||
}
|
||||
|
||||
for($i=0;$i<count($pages_matched);$i++) {
|
||||
$count_pages_matched = count($pages_matched);
|
||||
|
||||
for($i=0; $i < $count_pages_matched; $i++) {
|
||||
if($url == $pages_matched[$i]) {
|
||||
$html = "<li class='current-page'><a href='$link'>$desc</a></li>";
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ EOD;
|
|||
} else {
|
||||
$html .= "<div class='navtop navside tab shm-toggler' data-toggle-sel='#$i'>$h</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!is_null($b)) {
|
||||
if($salt =="main") {
|
||||
$html .= "<div class='blockbody'>$b</div>";
|
||||
|
@ -245,12 +245,16 @@ EOD;
|
|||
$url=$matches[1][0];
|
||||
}
|
||||
|
||||
for($i=0;$i<count($pages_matched);$i++) {
|
||||
$count_pages_matched = count($pages_matched);
|
||||
|
||||
for($i=0; $i < $count_pages_matched; $i++) {
|
||||
if($url == $pages_matched[$i]) {
|
||||
$html = "<a class='tab-selected' href='$link'>$desc</a>";
|
||||
}
|
||||
}
|
||||
|
||||
if(is_null($html)) {$html = "<a class='tab' href='$link'>$desc</a>";}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue