Such linting, such wow. Much clean.

This commit is contained in:
jgen 2014-04-28 02:56:58 -04:00
parent 8fd532e5a8
commit d4ac6ca451
9 changed files with 133 additions and 23 deletions

View file

@ -1,9 +1,12 @@
<?php
class QRImageTheme extends Themelet {
/**
* @param string $link
*/
public function links_block($link) {
global $page;
$page->add_block( new Block(
"QR Code","<img alt='QR Code' src='http://chart.apis.google.com/chart?chs=150x150&amp;cht=qr&amp;chl=$link' />","left",50));
"QR Code","<img alt='QR Code' src='http://chart.apis.google.com/chart?chs=150x150&amp;cht=qr&amp;chl={$link}' />","left",50));
}
}

View file

@ -15,7 +15,7 @@
class RegenThumb extends Extension {
public function onPageRequest(PageRequestEvent $event) {
global $config, $database, $page, $user;
global $page, $user;
if($event->page_matches("regen_thumb") && $user->can("delete_image") && isset($_POST['image_id'])) {
$image = Image::by_id(int_escape($_POST['image_id']));

View file

@ -1,8 +1,11 @@
<?php
class RegenThumbTheme extends Themelet {
/*
/**
* Show a form which offers to regenerate the thumb of an image with ID #$image_id
*
* @param int|string $image_id
* @return string
*/
public function get_buttons_html($image_id) {
return "
@ -13,8 +16,11 @@ class RegenThumbTheme extends Themelet {
";
}
/*
* Show a link to the new thumbnail
/**
* Show a link to the new thumbnail.
*
* @param Page $page
* @param Image $image
*/
public function display_results(Page $page, Image $image) {
$page->set_title("Thumbnail Regenerated");

View file

@ -21,7 +21,6 @@ class Relationships extends Extension {
}
public function onImageInfoSet(ImageInfoSetEvent $event) {
global $user;
if(isset($_POST['tag_edit__tags']) ? !preg_match('/parent[=|:]/', $_POST["tag_edit__tags"]) : TRUE) { //Ignore tag_edit__parent if tags contain parent metatag
if (isset($_POST["tag_edit__parent"]) ? ctype_digit($_POST["tag_edit__parent"]) : FALSE) {
$this->set_parent($event->image->id, (int) $_POST["tag_edit__parent"]);
@ -91,6 +90,10 @@ class Relationships extends Extension {
}
}
/**
* @param int $imageID
* @param int $parentID
*/
private function set_parent(/*int*/ $imageID, /*int*/ $parentID){
global $database;
@ -100,6 +103,10 @@ class Relationships extends Extension {
}
}
/**
* @param int $parentID
* @param int $childID
*/
private function set_child(/*int*/ $parentID, /*int*/ $childID){
global $database;
@ -109,6 +116,9 @@ class Relationships extends Extension {
}
}
/**
* @param int $imageID
*/
private function remove_parent(/*int*/ $imageID){
global $database;
$parentID = $database->get_one("SELECT parent_id FROM images WHERE id = :iid", array("iid"=>$imageID));

View file

@ -1,6 +1,9 @@
<?php
class RelationshipsTheme extends Themelet {
/**
* @param \Image $image
*/
public function relationship_info($image) {
global $page, $database;
@ -25,6 +28,7 @@ class RelationshipsTheme extends Themelet {
public function get_parent_editor_html(Image $image) {
global $user;
$h_parent_id = $image->parent_id;
$s_parent_id = $h_parent_id ?: "None.";

View file

@ -16,8 +16,12 @@
* This class is just a wrapper around SCoreException.
*/
class ImageRotateException extends SCoreException {
var $error;
/** @var string */
public $error;
/**
* @param string $error
*/
public function __construct($error) {
$this->error = $error;
}

View file

@ -1,12 +1,13 @@
<?php
class RotateImageTheme extends Themelet {
/*
* Display a link to rotate an image
/**
* Display a link to rotate an image.
*
* @param int $image_id
* @return string
*/
public function get_rotate_html(/*int*/ $image_id) {
global $user, $config;
$html = "
".make_form(make_link('rotate/'.$image_id), 'POST')."
<input type='hidden' name='image_id' value='$image_id'>
@ -17,7 +18,14 @@ class RotateImageTheme extends Themelet {
return $html;
}
/**
* Display the error.
*
* @param Page $page
* @param string $title
* @param string $message
*/
public function display_rotate_error(Page $page, /*string*/ $title, /*string*/ $message) {
$page->set_title("Rotate Image");
$page->set_heading("Rotate Image");

View file

@ -121,6 +121,10 @@ class TagList extends Extension {
}
// }}}
// misc {{{
/**
* @param string $tag
* @return string
*/
private function tag_link(/*string*/ $tag) {
$u_tag = url_escape($tag);
return make_link("post/list/$u_tag/1");
@ -129,7 +133,8 @@ class TagList extends Extension {
/**
* Get the minimum number of times a tag needs to be used
* in order to be considered in the tag list.
* @retval int
*
* @return int
*/
private function get_tags_min() {
if(isset($_GET['mincount'])) {
@ -141,6 +146,9 @@ class TagList extends Extension {
}
}
/**
* @return string
*/
private function get_starts_with() {
global $config;
if(isset($_GET['starts_with'])) {
@ -156,6 +164,9 @@ class TagList extends Extension {
}
}
/**
* @return string
*/
private function build_az() {
global $database;
@ -179,6 +190,10 @@ class TagList extends Extension {
}
// }}}
// maps {{{
/**
* @return string
*/
private function build_navigation() {
$h_index = "<a href='".make_link()."'>Index</a>";
$h_map = "<a href='".make_link("tags/map")."'>Map</a>";
@ -189,6 +204,9 @@ class TagList extends Extension {
return "$h_index<br>&nbsp;<br>$h_map<br>$h_alphabetic<br>$h_popularity<br>$h_cats<br>&nbsp;<br>$h_all";
}
/**
* @return string
*/
private function build_tag_map() {
global $config, $database;
@ -226,6 +244,9 @@ class TagList extends Extension {
return $html;
}
/**
* @return string
*/
private function build_tag_alphabetic() {
global $config, $database;
@ -279,6 +300,9 @@ class TagList extends Extension {
return $html;
}
/**
* @return string
*/
private function build_tag_popularity() {
global $database;
@ -318,6 +342,9 @@ class TagList extends Extension {
return $html;
}
/**
* @return string
*/
private function build_tag_list() {
global $database;
@ -344,9 +371,12 @@ class TagList extends Extension {
}
// }}}
// blocks {{{
/**
* @param Page $page
* @param Image $image
*/
private function add_related_block(Page $page, Image $image) {
global $database;
global $config;
global $database, $config;
$query = "
SELECT t3.tag AS tag, t3.count AS calc_count, it3.tag_id
@ -376,9 +406,12 @@ class TagList extends Extension {
}
}
/**
* @param Page $page
* @param Image $image
*/
private function add_split_tags_block(Page $page, Image $image) {
global $database;
global $config;
$query = "
SELECT tags.tag, tags.count as calc_count
@ -395,9 +428,12 @@ class TagList extends Extension {
}
}
/**
* @param Page $page
* @param Image $image
*/
private function add_tags_block(Page $page, Image $image) {
global $database;
global $config;
$query = "
SELECT tags.tag, tags.count as calc_count
@ -414,9 +450,11 @@ class TagList extends Extension {
}
}
/**
* @param Page $page
*/
private function add_popular_block(Page $page) {
global $database;
global $config;
global $database, $config;
$tags = $database->cache->get("popular_tags");
if(empty($tags)) {
@ -437,9 +475,12 @@ class TagList extends Extension {
}
}
/**
* @param Page $page
* @param string[] $search
*/
private function add_refine_block(Page $page, /*array(string)*/ $search) {
global $database;
global $config;
global $database, $config;
$wild_tags = Tag::explode($search);
$str_search = Tag::implode($search);

View file

@ -1,13 +1,23 @@
<?php
class TagListTheme extends Themelet {
var $heading = "";
var $list = "";
/** @var string */
public $heading = "";
/** @var string|string[] */
public $list = "";
public $navigation;
/**
* @param string $text
*/
public function set_heading($text) {
$this->heading = $text;
}
/**
* @param string|string[] $list
*/
public function set_tag_list($list) {
$this->list = $list;
}
@ -219,6 +229,11 @@ class TagListTheme extends Themelet {
return array($category, $display_html);
}
/**
* @param string $tag
* @param string[] $tags
* @return string
*/
protected function ars(/*string*/ $tag, /*array(string)*/ $tags) {
assert(is_array($tags));
@ -234,6 +249,11 @@ class TagListTheme extends Themelet {
return $html;
}
/**
* @param array $tags
* @param string $tag
* @return string
*/
protected function get_remove_link($tags, $tag) {
if(!in_array($tag, $tags) && !in_array("-$tag", $tags)) {
return "";
@ -245,6 +265,11 @@ class TagListTheme extends Themelet {
}
}
/**
* @param array $tags
* @param string $tag
* @return string
*/
protected function get_add_link($tags, $tag) {
if(in_array($tag, $tags)) {
return "";
@ -256,6 +281,11 @@ class TagListTheme extends Themelet {
}
}
/**
* @param array $tags
* @param string $tag
* @return string
*/
protected function get_subtract_link($tags, $tag) {
if(in_array("-$tag", $tags)) {
return "";
@ -267,6 +297,10 @@ class TagListTheme extends Themelet {
}
}
/**
* @param string $tag
* @return string
*/
protected function tag_link($tag) {
$u_tag = url_escape($tag);
return make_link("post/list/$u_tag/1");