Skip to content

Commit

Permalink
Merge pull request #413 from jgen/linting
Browse files Browse the repository at this point in the history
Lots o' Linting
  • Loading branch information
shish committed Apr 26, 2014
2 parents ef3daaf + 95ba85e commit e9d8ae7
Show file tree
Hide file tree
Showing 280 changed files with 1,530 additions and 1,063 deletions.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ imports:
- php

filter:
excluded_paths: [lib/*,ext/chatbox/js/jquery.js]
excluded_paths: [lib/*,ext/tagger/script.js]
61 changes: 51 additions & 10 deletions core/basethemelet.class.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
<?php

/**
* Class BaseThemelet
*
* A collection of common functions for theme parts
*/
class BaseThemelet {

/**
* Generic error message display
*
* @param int $code
* @param string $title
* @param string $message
*/
public function display_error(/*int*/ $code, /*string*/ $title, /*string*/ $message) {
global $page;
Expand All @@ -24,7 +32,6 @@ public function display_error(/*int*/ $code, /*string*/ $title, /*string*/ $mess
$page->add_block(new Block("Error", $message));
}


/**
* A specific, common error message
*/
Expand All @@ -36,6 +43,9 @@ public function display_permission_denied() {
/**
* Generic thumbnail code; returns HTML rather than adding
* a block since thumbs tend to go inside blocks...
*
* @param Image $image
* @return string
*/
public function build_thumb_html(Image $image) {
global $config;
Expand All @@ -56,38 +66,69 @@ public function build_thumb_html(Image $image) {

$custom_classes = "";
if(class_exists("Relationships")){
if($image->parent_id !== NULL){ $custom_classes .= "shm-thumb-has_parent "; }
if($image->has_children == TRUE){ $custom_classes .= "shm-thumb-has_child "; }
if(property_exists('Image', 'parent_id') && $image->parent_id !== NULL){ $custom_classes .= "shm-thumb-has_parent "; }
if(property_exists('Image', 'has_children') && $image->has_children == TRUE){ $custom_classes .= "shm-thumb-has_child "; }
}

return "<a href='$h_view_link' class='thumb shm-thumb shm-thumb-link {$custom_classes}' data-tags='$h_tags' data-post-id='$i_id'>".
"<img id='thumb_$i_id' title='$h_tip' alt='$h_tip' height='{$tsize[1]}' width='{$tsize[0]}' src='$h_thumb_link'>".
"</a>\n";
"<img id='thumb_$i_id' title='$h_tip' alt='$h_tip' height='{$tsize[1]}' width='{$tsize[0]}' src='$h_thumb_link'>".
"</a>\n";
}


/**
* Add a generic paginator
* Add a generic paginator.
*
* @param Page $page
* @param string $base
* @param string $query
* @param int $page_number
* @param int $total_pages
*/
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages) {
if($total_pages == 0) $total_pages = 1;
$body = $this->build_paginator($page_number, $total_pages, $base, $query);
$page->add_block(new Block(null, $body, "main", 90, "paginator"));
}

/**
* Generate a single HTML link.
*
* @param string $base_url
* @param string $query
* @param int|string $page
* @param string $name
* @return string
*/
private function gen_page_link($base_url, $query, $page, $name) {
$link = make_link($base_url.'/'.$page, $query);
return '<a href="'.$link.'">'.$name.'</a>';
}


/**
* @param string $base_url
* @param string $query
* @param int|string $page
* @param int|string $current_page
* @param string $name
* @return string
*/
private function gen_page_link_block($base_url, $query, $page, $current_page, $name) {
$paginator = "";
if($page == $current_page) $paginator .= "<b>";
$paginator .= $this->gen_page_link($base_url, $query, $page, $name);
if($page == $current_page) $paginator .= "</b>";
return $paginator;
}


/**
* Build the paginator.
*
* @param int $current_page
* @param int $total_pages
* @param string $base_url
* @param string $query
* @return string
*/
private function build_paginator($current_page, $total_pages, $base_url, $query) {
$next = $current_page + 1;
$prev = $current_page - 1;
Expand Down Expand Up @@ -115,4 +156,4 @@ private function build_paginator($current_page, $total_pages, $base_url, $query)
.'<br>&lt;&lt; '.$pages_html.' &gt;&gt;';
}
}
?>

37 changes: 26 additions & 11 deletions core/block.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,48 @@ class Block {
/**
* The block's title
*
* @retval string
* @var string
*/
var $header;
public $header;

/**
* The content
*
* @retval string
* @var string
*/
var $body;
public $body;

/**
* Where the block should be placed. The default theme supports
* "main" and "left", other themes can add their own areas
*
* @retval string
* @var string
*/
var $section;
public $section;

/**
* How far down the section the block should appear, higher
* numbers appear lower. The scale is 0-100 by convention,
* though any number or string will work.
*
* @retval int
* @var int
*/
var $position;
public $position;

/**
*
* @var int
*/
var $id;
public $id;

/**
* Construct a block.
*
* @param string $header
* @param string $body
* @param string $section
* @param int $position
* @param null|int $id
*/
public function __construct($header, $body, /*string*/ $section="main", /*int*/ $position=50, $id=null) {
$this->header = $header;
$this->body = $body;
Expand All @@ -47,6 +56,12 @@ public function __construct($header, $body, /*string*/ $section="main", /*int*/
$this->id = str_replace(' ', '_', is_null($id) ? (is_null($header) ? md5($body) : $header) . $section : $id);
}

/**
* Get the HTML for this block.
*
* @param bool $hidable
* @return string
*/
public function get_html($hidable=false) {
$h = $this->header;
$b = $this->body;
Expand All @@ -71,4 +86,4 @@ public function __construct() {
parent::__construct("Navigation", "<a href='".make_link()."'>Index</a>", "left", 0);
}
}
?>

2 changes: 1 addition & 1 deletion core/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,4 @@ public function __construct($config=array()) {
parent::__construct($config);
}
}
?>

10 changes: 5 additions & 5 deletions core/database.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct($qlet, $positive) {
// }}}
// {{{ db engines
class DBEngine {
var $name = null;
public $name = null;

public function init($db) {}

Expand All @@ -58,7 +58,7 @@ public function create_table_sql($name, $data) {
}
}
class MySQL extends DBEngine {
var $name = "mysql";
public $name = "mysql";

public function init($db) {
$db->exec("SET NAMES utf8;");
Expand All @@ -84,7 +84,7 @@ public function create_table_sql($name, $data) {
}
}
class PostgreSQL extends DBEngine {
var $name = "pgsql";
public $name = "pgsql";

public function init($db) {
$db->exec("SET application_name TO 'shimmie [{$_SERVER['REMOTE_ADDR']}]';");
Expand Down Expand Up @@ -123,7 +123,7 @@ function _concat($a, $b) { return $a . $b; }
function _lower($a) { return strtolower($a); }

class SQLite extends DBEngine {
var $name = "sqlite";
public $name = "sqlite";

public function init($db) {
ini_set('sqlite.assoc_case', 0);
Expand Down Expand Up @@ -553,4 +553,4 @@ public function scoreql_to_sql($sql) {return $sql;}
public function create_table($name, $def) {}
public function connect_engine() {}
}
?>

24 changes: 12 additions & 12 deletions core/email.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ class Email {
/**
* A generic email.
*/
var $to;
var $subject;
var $header;
var $style;
var $header_img;
var $sitename;
var $sitedomain;
var $siteemail;
var $date;
var $body;
var $footer;
public $to;
public $subject;
public $header;
public $style;
public $header_img;
public $sitename;
public $sitedomain;
public $siteemail;
public $date;
public $body;
public $footer;

public function __construct($to, $subject, $header, $body) {
global $config;
Expand Down Expand Up @@ -116,4 +116,4 @@ public function send() {
return $sent;
}
}
?>

Loading

0 comments on commit e9d8ae7

Please sign in to comment.