Merge pull request #340 from jgen/master

Some small tweaks/changes
This commit is contained in:
Shish 2013-10-04 01:17:05 -07:00
commit dd58c35f8a
4 changed files with 14 additions and 9 deletions

View File

@ -37,7 +37,7 @@ class PageRequestEvent extends Event {
$path = ltrim($path, "/");
// if path is not specified, use the default front page
if(strlen($path) === 0) {
if(empty($path)) { /* empty is faster than strlen */
$path = $config->get_string('front_page');
}
@ -145,7 +145,9 @@ class CommandEvent extends Event {
$opts = array();
$log_level = SCORE_LOG_WARNING;
for($i=1; $i<count($args); $i++) {
$arg_count = count($args);
for($i=1; $i<$arg_count; $i++) {
switch($args[$i]) {
case '-u':
$user = User::by_name($args[++$i]);

View File

@ -148,7 +148,9 @@ class Image {
public static function count_images($tags=array()) {
assert(is_array($tags));
global $database;
if(count($tags) == 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");
@ -156,7 +158,7 @@ class Image {
}
return $total;
}
else if(count($tags) == 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)"),
@ -561,6 +563,7 @@ class Image {
$tmpl = str_replace('$filesize', to_shorthand_int($this->filesize), $tmpl);
$tmpl = str_replace('$filename', $_escape($base_fname), $tmpl);
$tmpl = str_replace('$title', $_escape($config->get_string("title")), $tmpl);
$tmpl = str_replace('$date', $_escape(autodate($this->posted, false)), $tmpl);
// nothing seems to use this, sending the event out to 50 exts is a lot of overhead
if(!SPEED_HAX) {
@ -581,13 +584,14 @@ class Image {
$_flexihash = new Flexihash();
foreach(explode(",", $opts) as $opt) {
$parts = explode("=", $opt);
$parts_count = count($parts);
$opt_val = "";
$opt_weight = 0;
if(count($parts) == 2) {
if($parts_count == 2) {
$opt_val = $parts[0];
$opt_weight = $parts[1];
}
elseif(count($parts) == 1) {
elseif($parts_count == 1) {
$opt_val = $parts[0];
$opt_weight = 1;
}
@ -655,7 +659,7 @@ class Image {
$positive = false;
$term = substr($term, 1);
}
if(strlen($term) == 0) {
if(strlen($term) === 0) {
continue;
}

View File

@ -83,7 +83,7 @@ class Wiki extends Extension {
public function onPageRequest(PageRequestEvent $event) {
global $config, $page, $user;
if($event->page_matches("wiki")) {
if(is_null($event->get_arg(0)) || strlen(trim($event->get_arg(0))) == 0) {
if(is_null($event->get_arg(0)) || strlen(trim($event->get_arg(0))) === 0) {
$title = "Index";
}
else {

View File

@ -233,7 +233,6 @@ class Layout {
<head>
<title>{$page->title}</title>
$header_html
<script src='$data_href/themes/$theme_name/script.js' type='text/javascript'></script>
</head>
<body>