Merge pull request #409 from jgen/linting

Linting
This commit is contained in:
Shish
2014-04-20 00:29:53 +01:00
17 changed files with 93 additions and 75 deletions

View File

@ -805,7 +805,7 @@ class Artists extends Extension {
$urls = $_POST["urls"];
$userID = $user->id;
$artistID = "";
//$artistID = "";
//// WE CHECK IF THE ARTIST ALREADY EXISTS ON DATABASE; IF NOT WE CREATE
if(!$this->artist_exists($name))

View File

@ -106,7 +106,7 @@ class BlotterTheme extends Themelet {
// Reset variables:
$i_open = "";
$i_close = "";
$id = $entries[$i]['id'];
//$id = $entries[$i]['id'];
$messy_date = $entries[$i]['entry_date'];
$clean_date = date("y/m/d", strtotime($messy_date));
$entry_text = $entries[$i]['entry_text'];

View File

@ -1,4 +1,4 @@
<?
<?php
error_reporting(E_ALL);
include '../php/filestorage.class.php';
@ -39,6 +39,9 @@
$banned = $ys->banned($post['adminInfo']['ip']);
$html .= '<div ' . ($admin ? 'rel="' . $post['adminInfo']['ip'] . '" ' : '') . 'id="ys-post-' . $id . '" class="ys-post' . ($post['admin'] ? ' ys-admin-post' : '') . ($banned ? ' ys-banned-post' : '') . '">' . "\n";
$ts = '';
switch($prefs['timestamp']) {
case 12:
$ts = date('h:i', $post['timestamp']);

View File

@ -374,12 +374,13 @@ YShout.prototype = {
if (!$.browser.safari) return;
var same = [];
for (var i = 0; i < this.p.length; i++)
for (var i = 0; i < this.p.length; i++) {
if (this.p[i].adminInfo.ip == ip)
same.push(this.p[i]);
for (var i = 0; i < same.length; i++) {
$('#' + same[i].id).fadeTo(this.animSpeed, .8).fadeTo(this.animSpeed, 1);
}
for (var j = 0; j < same.length; j++) {
$('#' + same[j].id).fadeTo(this.animSpeed, 0.8).fadeTo(this.animSpeed, 1);
}
},

View File

@ -208,6 +208,7 @@ class DanbooruApi extends Extension {
// Fire off an event which should process the new file and add it to the db
$fileinfo = pathinfo($filename);
$metadata = array();
$metadata['filename'] = $fileinfo['basename'];
$metadata['extension'] = $fileinfo['extension'];
$metadata['tags'] = $posttags;

View File

@ -342,7 +342,7 @@ class Pools extends Extension {
/**
* Check if the given user has permission to edit/change the pool.
* TODO: Should the user variable be global?
* @retval bool
* @return bool
*/
private function have_permission($user, $pool) {
// If the pool is public and user is logged OR if the user is admin OR if the pool is owned by the user.
@ -415,12 +415,13 @@ class Pools extends Extension {
throw new PoolCreationException("A pool using this title already exists.");
}
$public = $_POST["public"] == "Y" ? "Y" : "N";
$public = $_POST["public"] === "Y" ? "Y" : "N";
$database->execute("
INSERT INTO pools (user_id, public, title, description, date)
VALUES (:uid, :public, :title, :desc, now())",
array("uid"=>$user->id, "public"=>$public, "title"=>$_POST["title"], "desc"=>$_POST["description"]));
$result = array();
$result['poolID'] = $database->get_last_insert_id('pools_id_seq');
log_info("pools", "Pool {$result["poolID"]} created by {$user->name}");
@ -429,9 +430,9 @@ class Pools extends Extension {
}
/**
* Retrieve information about pools given mulitiple pool IDs.
* Retrieve information about pools given multiple pool IDs.
* @param $poolID Array of integers
* @retval 2D Array
* @return 2D Array
*/
private function get_pool(/*int*/ $poolID) {
global $database;
@ -441,7 +442,7 @@ class Pools extends Extension {
/**
* Retrieve information about a pool given a pool ID.
* @param $poolID Integer
* @retval 2D array (with only 1 element in the one dimension)
* @return 2D array (with only 1 element in the one dimension)
*/
private function get_single_pool(/*int*/ $poolID) {
global $database;
@ -451,7 +452,7 @@ class Pools extends Extension {
/**
* Retrieve information about a pool given a pool title.
* @param $poolTitle Integer
* @retval 2D array (with only 1 element in the one dimension)
* @return 2D array (with only 1 element in the one dimension)
*/
private function get_single_pool_from_title(/*string*/ $poolTitle) {
global $database;
@ -461,7 +462,7 @@ class Pools extends Extension {
/**
* Get all of the pool IDs that an image is in, given an image ID.
* @param $imageID Integer
* @retval 2D array
* @return 2D array
*/
private function get_pool_id(/*int*/ $imageID) {
global $database;
@ -581,7 +582,7 @@ class Pools extends Extension {
* @see add_posts()
* @param $poolID integer
* @param $imageID integer
* @retval bool
* @return bool
*/
private function check_post(/*int*/ $poolID, /*int*/ $imageID) {
global $database;
@ -594,7 +595,7 @@ class Pools extends Extension {
*
* @param $pool Array for the given pool
* @param $imageID Integer
* @retval Integer which is the next Image ID or NULL if none.
* @return Integer which is the next Image ID or NULL if none.
*/
private function get_next_post(/*array*/ $pool, /*int*/ $imageID) {
global $database;
@ -684,7 +685,7 @@ class Pools extends Extension {
/**
* This function gets the current order of images from a given pool.
* @param $poolID integer
* @retval Array of image objects.
* @return Array of image objects.
*/
private function edit_posts(/*int*/ $poolID) {
global $database;
@ -750,6 +751,7 @@ class Pools extends Extension {
*/
private function add_history(/*int*/ $poolID, $action, $images, $count) {
global $user, $database;
$database->execute("
INSERT INTO pool_history (pool_id, user_id, action, images, count, date)
VALUES (:pid, :uid, :act, :img, :count, now())",
@ -804,6 +806,7 @@ class Pools extends Extension {
$images = explode(" ", $images);
$poolID = $entry['pool_id'];
$imageArray = "";
$newAction = -1;
if($entry['action'] == 0) {
// READ ENTRIES
@ -824,6 +827,10 @@ class Pools extends Extension {
$imageArray .= " ".$imageID;
$newAction = 0;
}
} else {
// FIXME: should this throw an exception instead?
log_error("pools", "Invalid history action.");
continue; // go on to the next one.
}
$count = $database->get_one("SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid", array("pid"=>$poolID));

View File

@ -62,7 +62,9 @@ class XMLSitemap extends Extension {
private function handle_full_sitemap()
{
global $database, $config;
// add index
$index = array();
$index[0] = $config->get_string("front_page");
$this->add_sitemap_queue($index, "weekly", "1");

View File

@ -99,7 +99,7 @@ class StatsDInterface extends Extension {
// Wrap this in a try/catch - failures in any of this should be silently ignored
try {
$parts = explode(":", STATSD_HOST);
$parts = explode(":", STATSD_HOST);
$host = $parts[0];
$port = $parts[1];
$fp = fsockopen("udp://$host", $port, $errno, $errstr);
@ -109,6 +109,7 @@ class StatsDInterface extends Extension {
}
fclose($fp);
} catch (Exception $e) {
// ignore any failures.
}
}
}

View File

@ -20,7 +20,7 @@ Array.prototype.editcloud_remove = function (ele) {
var hide_text = null;
function tageditcloud_toggle_extra(hide) {
if (hide_text == null) {
if (hide_text === null) {
hide_text = hide.innerHTML;
}

View File

@ -135,13 +135,13 @@ class Tag_History extends Extension {
// there is no history entry with that id so either the image was deleted
// while the user was viewing the history, someone is playing with form
// variables or we have messed up in code somewhere.
/* calling die() is probably not a good idea, we should throw an Exception */
/* FIXME: calling die() is probably not a good idea, we should throw an Exception */
die("Error: No tag history with specified id was found.");
}
// lets get the values out of the result
$stored_result_id = $result['id'];
$stored_image_id = $result['image_id'];
$stored_image_id = int_escape($result['image_id']);
$stored_tags = $result['tags'];
log_debug("tag_history", 'Reverting tags of Image #'.$stored_image_id.' to ['.$stored_tags.']');
@ -267,7 +267,7 @@ class Tag_History extends Extension {
log_info("tag_history", 'Attempting to revert edits where '.implode(" and ", $select_code)." (".implode(" / ", $select_args).")");
// Get all the images that the given IP has changed tags on (within the timeframe) that were last editied by the given IP
// Get all the images that the given IP has changed tags on (within the timeframe) that were last edited by the given IP
$result = $database->get_col('
SELECT t1.image_id
FROM tag_histories t1
@ -304,8 +304,8 @@ class Tag_History extends Extension {
}
// lets get the values out of the result
$stored_result_id = $result['id'];
$stored_image_id = $result['image_id'];
$stored_result_id = int_escape($result['id']);
$stored_image_id = int_escape($result['image_id']);
$stored_tags = $result['tags'];
log_debug("tag_history", 'Reverting tags of Image #'.$stored_image_id.' to ['.$stored_tags.']');
@ -350,8 +350,8 @@ class Tag_History extends Extension {
$entries++;
}
// add a history entry
$row = $database->execute("
// add a history entry
$database->execute("
INSERT INTO tag_histories(image_id, tags, user_id, user_ip, date_set)
VALUES (?, ?, ?, ?, now())",
array($image->id, $new_tags, $user->id, $_SERVER['REMOTE_ADDR']));

View File

@ -48,7 +48,7 @@ class TagList extends Extension {
else if($event->page_matches("api/internal/tag_list/complete")) {
if(!isset($_GET["s"])) return;
$limit = 0;
//$limit = 0;
$limitSQL = "";
$SQLarr = array("search"=>$_GET["s"]."%");
if(isset($_GET["limit"]) && $_GET["limit"] !== 0){
@ -321,7 +321,7 @@ class TagList extends Extension {
private function build_tag_list() {
global $database;
$tags_min = $this->get_tags_min();
//$tags_min = $this->get_tags_min();
$tag_data = $database->get_all("SELECT tag,count FROM tags ORDER BY count DESC, tag ASC LIMIT 9");
$html = "<table>";

View File

@ -2,9 +2,9 @@ $(function() {
if($('#updatecheck').length !== 0){
$.getJSON('https://api.github.com/repos/shish/shimmie2/commits', function(data){
var c = data[0];
$('#updatecheck').html('<a href="'+c['html_url']+'">'+c['sha']+'</a>' + " ("+c['commit']['message']+")");
$('#updatecheck').html('<a href="'+ c.html_url+'">'+ c.sha+'</a>' + " ("+ c.commit.message+")");
var params = $.param({sha: c['sha'], date: c['commit']['committer']['date']});
var params = $.param({sha: c.sha, date: c.commit.committer.date});
$('#updatelink').attr('href', function(i, val){ return val + "?" + params; });
$('#updatelink').text("Update");
}).fail(function(){

View File

@ -279,6 +279,7 @@ class Upload extends Extension {
}
$pathinfo = pathinfo($file['name']);
$metadata = array();
$metadata['filename'] = $pathinfo['basename'];
$metadata['extension'] = $pathinfo['extension'];
$metadata['tags'] = $tags;
@ -349,6 +350,7 @@ class Upload extends Extension {
}else{
global $user;
$pathinfo = pathinfo($url);
$metadata = array();
$metadata['filename'] = $filename;
$metadata['extension'] = getExtension($headers['Content-Type']) ?: $pathinfo['extension'];
$metadata['tags'] = $tags;