Trimming trailing blank space.

This commit is contained in:
jgen 2014-02-22 15:42:09 -05:00
parent 3d1217a1be
commit 7eb2bd9112
5 changed files with 37 additions and 37 deletions

View File

@ -284,7 +284,7 @@ class Database {
* (ie: True if beginTransaction() already called) * (ie: True if beginTransaction() already called)
*/ */
public $transaction = false; public $transaction = false;
/** /**
* For now, only connect to the cache, as we will pretty much certainly * For now, only connect to the cache, as we will pretty much certainly
* need it. There are some pages where all the data is in cache, so the * need it. There are some pages where all the data is in cache, so the
@ -359,7 +359,7 @@ class Database {
$this->transaction = true; $this->transaction = true;
} }
} }
public function commit() { public function commit() {
if(!is_null($this->db)) { if(!is_null($this->db)) {
if ($this->transaction === true) { if ($this->transaction === true) {
@ -417,7 +417,7 @@ class Database {
} }
} }
$stmt->execute(); $stmt->execute();
} }
else { else {
$stmt->execute($args); $stmt->execute($args);
} }
@ -494,13 +494,13 @@ class Database {
if(is_null($this->engine)) $this->connect_engine(); if(is_null($this->engine)) $this->connect_engine();
$this->execute($this->engine->create_table_sql($name, $data)); $this->execute($this->engine->create_table_sql($name, $data));
} }
/** /**
* Returns the number of tables present in the current database. * Returns the number of tables present in the current database.
*/ */
public function count_tables() { public function count_tables() {
if(is_null($this->db) || is_null($this->engine)) $this->connect_db(); if(is_null($this->db) || is_null($this->engine)) $this->connect_db();
if($this->engine->name === "mysql") { if($this->engine->name === "mysql") {
return count( return count(
$this->get_all("SHOW TABLES") $this->get_all("SHOW TABLES")

View File

@ -146,7 +146,7 @@ class CommandEvent extends Event {
$opts = array(); $opts = array();
$log_level = SCORE_LOG_WARNING; $log_level = SCORE_LOG_WARNING;
$arg_count = count($args); $arg_count = count($args);
for($i=1; $i<$arg_count; $i++) { for($i=1; $i<$arg_count; $i++) {
switch($args[$i]) { switch($args[$i]) {
case '-u': case '-u':

View File

@ -1,18 +1,18 @@
<?php <?php
/** /**
* \page eande Events and Extensions * \page eande Events and Extensions
* *
* An event is a little blob of data saying "something happened", possibly * An event is a little blob of data saying "something happened", possibly
* "something happened, here's the specific data". Events are sent with the * "something happened, here's the specific data". Events are sent with the
* send_event() function. Since events can store data, they can be used to * send_event() function. Since events can store data, they can be used to
* return data to the extension which sent them, for example: * return data to the extension which sent them, for example:
* *
* \code * \code
* $tfe = new TextFormattingEvent($original_text); * $tfe = new TextFormattingEvent($original_text);
* send_event($tfe); * send_event($tfe);
* $formatted_text = $tfe->formatted; * $formatted_text = $tfe->formatted;
* \endcode * \endcode
* *
* An extension is something which is capable of reacting to events. * An extension is something which is capable of reacting to events.
* *
* *
@ -25,7 +25,7 @@
* $this->username = $username; * $this->username = $username;
* } * }
* } * }
* *
* public class Hello extends Extension { * public class Hello extends Extension {
* public function onPageRequest(PageRequestEvent $event) { // Every time a page request is sent * public function onPageRequest(PageRequestEvent $event) { // Every time a page request is sent
* global $user; // Look at the global "currently logged in user" object * global $user; // Look at the global "currently logged in user" object
@ -149,13 +149,13 @@ abstract class DataHandlerExtension extends Extension {
/* Check if we are replacing an image */ /* Check if we are replacing an image */
if(array_key_exists('replace', $event->metadata) && isset($event->metadata['replace'])) { if(array_key_exists('replace', $event->metadata) && isset($event->metadata['replace'])) {
/* hax: This seems like such a dirty way to do this.. */ /* hax: This seems like such a dirty way to do this.. */
/* Validate things */ /* Validate things */
$image_id = int_escape($event->metadata['replace']); $image_id = int_escape($event->metadata['replace']);
/* Check to make sure the image exists. */ /* Check to make sure the image exists. */
$existing = Image::by_id($image_id); $existing = Image::by_id($image_id);
if(is_null($existing)) { if(is_null($existing)) {
throw new UploadException("Image to replace does not exist!"); throw new UploadException("Image to replace does not exist!");
} }
@ -166,7 +166,7 @@ abstract class DataHandlerExtension extends Extension {
// even more hax.. // even more hax..
$event->metadata['tags'] = $existing->get_tag_list(); $event->metadata['tags'] = $existing->get_tag_list();
$image = $this->create_image_from_data(warehouse_path("images", $event->metadata['hash']), $event->metadata); $image = $this->create_image_from_data(warehouse_path("images", $event->metadata['hash']), $event->metadata);
if(is_null($image)) { if(is_null($image)) {
throw new UploadException("Data handler failed to create image object from data"); throw new UploadException("Data handler failed to create image object from data");
} }
@ -183,13 +183,13 @@ abstract class DataHandlerExtension extends Extension {
$iae = new ImageAdditionEvent($image); $iae = new ImageAdditionEvent($image);
send_event($iae); send_event($iae);
$event->image_id = $iae->image->id; $event->image_id = $iae->image->id;
// Rating Stuff. // Rating Stuff.
if(!empty($event->metadata['rating'])){ if(!empty($event->metadata['rating'])){
$rating = $event->metadata['rating']; $rating = $event->metadata['rating'];
send_event(new RatingSetEvent($image, $rating)); send_event(new RatingSetEvent($image, $rating));
} }
// Locked Stuff. // Locked Stuff.
if(!empty($event->metadata['locked'])){ if(!empty($event->metadata['locked'])){
$locked = $event->metadata['locked']; $locked = $event->metadata['locked'];

View File

@ -6,13 +6,13 @@
/** /**
* \page search Shimmie2: Searching * \page search Shimmie2: Searching
* *
* The current search system is built of several search item -> image ID list * The current search system is built of several search item -> image ID list
* translators, eg: * translators, eg:
* *
* \li the item "fred" will search the image_tags table to find image IDs with the fred tag * \li the item "fred" will search the image_tags table to find image IDs with the fred tag
* \li the item "size=640x480" will search the images table to find image IDs of 640x480 images * \li the item "size=640x480" will search the images table to find image IDs of 640x480 images
* *
* So the search "fred size=640x480" will calculate two lists and take the * So the search "fred size=640x480" will calculate two lists and take the
* intersection. (There are some optimisations in there making it more * intersection. (There are some optimisations in there making it more
* complicated behind the scenes, but as long as you can turn a single word * complicated behind the scenes, but as long as you can turn a single word
@ -144,7 +144,7 @@ class Image {
/* /*
* Image-related utility functions * Image-related utility functions
*/ */
/** /**
* Count the number of image results for a given search * Count the number of image results for a given search
*/ */
@ -152,7 +152,7 @@ class Image {
assert(is_array($tags)); assert(is_array($tags));
global $database; global $database;
$tag_count = count($tags); $tag_count = count($tags);
if($tag_count === 0) { if($tag_count === 0) {
$total = $database->cache->get("image-count"); $total = $database->cache->get("image-count");
if(!$total) { if(!$total) {
@ -312,9 +312,9 @@ class Image {
*/ */
public function get_thumb_link() { public function get_thumb_link() {
global $config; global $config;
$image_tlink = $config->get_string('image_tlink'); // store a copy for speed. $image_tlink = $config->get_string('image_tlink'); // store a copy for speed.
if( !empty($image_tlink) ) { /* empty is faster than strlen */ if( !empty($image_tlink) ) { /* empty is faster than strlen */
if(!startsWith($image_tlink, "http://") && !startsWith($image_tlink, "/")) { if(!startsWith($image_tlink, "http://") && !startsWith($image_tlink, "/")) {
$image_tlink = make_link($image_tlink); $image_tlink = make_link($image_tlink);
@ -339,7 +339,7 @@ class Image {
global $config; global $config;
$tt = $this->parse_link_template($config->get_string('image_tip'), "no_escape"); $tt = $this->parse_link_template($config->get_string('image_tip'), "no_escape");
// Removes the size tag if the file is an mp3 // Removes the size tag if the file is an mp3
if($this->ext === 'mp3'){ if($this->ext === 'mp3'){
$iitip = $tt; $iitip = $tt;
$mp3tip = array("0x0"); $mp3tip = array("0x0");
@ -546,7 +546,7 @@ class Image {
@unlink($this->get_image_filename()); @unlink($this->get_image_filename());
@unlink($this->get_thumb_filename()); @unlink($this->get_thumb_filename());
} }
/** /**
* Someone please explain this * Someone please explain this
* *
@ -830,7 +830,7 @@ class Image {
$terms = Tag::resolve_aliases($terms); $terms = Tag::resolve_aliases($terms);
reset($terms); // rewind to first element in array. reset($terms); // rewind to first element in array.
// turn each term into a specific type of querylet // turn each term into a specific type of querylet
foreach($terms as $term) { foreach($terms as $term) {
$negative = false; $negative = false;
@ -866,7 +866,7 @@ class Image {
//$terms["tag$tag_n"] = $tq->tag; //$terms["tag$tag_n"] = $tq->tag;
$terms['tag'.$tag_n] = $tq->tag; $terms['tag'.$tag_n] = $tq->tag;
$tag_n++; $tag_n++;
if($sign === "+") $positive_tag_count++; if($sign === "+") $positive_tag_count++;
else $negative_tag_count++; else $negative_tag_count++;
} }
@ -920,7 +920,7 @@ class Image {
else { else {
$s_tag_array = array_map("sql_escape", $tag_search->variables); $s_tag_array = array_map("sql_escape", $tag_search->variables);
$s_tag_list = join(', ', $s_tag_array); $s_tag_list = join(', ', $s_tag_array);
$tag_id_array = array(); $tag_id_array = array();
$tags_ok = true; $tags_ok = true;
foreach($tag_search->variables as $tag) { foreach($tag_search->variables as $tag) {
@ -991,7 +991,7 @@ class Tag {
*/ */
public static function explode($tags, $tagme=true) { public static function explode($tags, $tagme=true) {
assert(is_string($tags) || is_array($tags)); assert(is_string($tags) || is_array($tags));
if(is_string($tags)) { if(is_string($tags)) {
$tags = explode(' ', trim($tags)); $tags = explode(' ', trim($tags));
} }

View File

@ -83,7 +83,7 @@ function bool_escape($input) {
/* /*
Sometimes, I don't like PHP -- this, is one of those times... Sometimes, I don't like PHP -- this, is one of those times...
"a boolean FALSE is not considered a valid boolean value by this function." "a boolean FALSE is not considered a valid boolean value by this function."
Yay for Got'chas! Yay for Got'chas!
http://php.net/manual/en/filter.filters.validate.php http://php.net/manual/en/filter.filters.validate.php
*/ */
if (is_bool($input)) { if (is_bool($input)) {
@ -555,7 +555,7 @@ function getMimeType($file, $ext="", $list=false) {
$type = trim(mime_content_type($file)); $type = trim(mime_content_type($file));
if ($type !== false && strlen($type) > 0) return $type; if ($type !== false && strlen($type) > 0) return $type;
return 'application/octet-stream'; return 'application/octet-stream';
} }
@ -654,20 +654,20 @@ function get_memory_limit() {
// thumbnail generation requires lots of memory // thumbnail generation requires lots of memory
$default_limit = 8*1024*1024; // 8 MB of memory is PHP's default. $default_limit = 8*1024*1024; // 8 MB of memory is PHP's default.
$shimmie_limit = parse_shorthand_int($config->get_int("thumb_mem_limit")); $shimmie_limit = parse_shorthand_int($config->get_int("thumb_mem_limit"));
if($shimmie_limit < 3*1024*1024) { if($shimmie_limit < 3*1024*1024) {
// we aren't going to fit, override // we aren't going to fit, override
$shimmie_limit = $default_limit; $shimmie_limit = $default_limit;
} }
/* /*
Get PHP's configured memory limit. Get PHP's configured memory limit.
Note that this is set to -1 for NO memory limit. Note that this is set to -1 for NO memory limit.
http://ca2.php.net/manual/en/ini.core.php#ini.memory-limit http://ca2.php.net/manual/en/ini.core.php#ini.memory-limit
*/ */
$memory = parse_shorthand_int(ini_get("memory_limit")); $memory = parse_shorthand_int(ini_get("memory_limit"));
if($memory == -1) { if($memory == -1) {
// No memory limit. // No memory limit.
// Return the larger of the set limits. // Return the larger of the set limits.
@ -1214,7 +1214,7 @@ function get_debug_info() {
$i_files = count(get_included_files()); $i_files = count(get_included_files());
$hits = $database->cache->get_hits(); $hits = $database->cache->get_hits();
$miss = $database->cache->get_misses(); $miss = $database->cache->get_misses();
$debug = "<br>Took $time seconds and {$i_mem}MB of RAM"; $debug = "<br>Took $time seconds and {$i_mem}MB of RAM";
$debug .= "; Used $i_files files and $_execs queries"; $debug .= "; Used $i_files files and $_execs queries";
$debug .= "; Sent $_event_count events"; $debug .= "; Sent $_event_count events";
@ -1435,7 +1435,7 @@ function _start_coverage() {
function _end_coverage() { function _end_coverage() {
if(function_exists("xdebug_get_code_coverage")) { if(function_exists("xdebug_get_code_coverage")) {
// Absolute path is necessary because working directory // Absolute path is necessary because working directory
// inside register_shutdown_function is unpredictable. // inside register_shutdown_function is unpredictable.
$absolute_path = dirname(dirname(__FILE__)) . "/data/coverage"; $absolute_path = dirname(dirname(__FILE__)) . "/data/coverage";
if(!file_exists($absolute_path)) mkdir($absolute_path); if(!file_exists($absolute_path)) mkdir($absolute_path);