Skip to content

Commit

Permalink
psr2 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
lcherone committed Oct 18, 2017
1 parent 599bb99 commit 7316245
Show file tree
Hide file tree
Showing 29 changed files with 210 additions and 175 deletions.
1 change: 1 addition & 0 deletions .php_cs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"7.0.18-0ubuntu0.17.04.1","version":"2.7.0","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":{"ensure_fully_multiline":true},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true},"hashes":{"app\/\/template\/default\/template.php":3136700671,"app\/\/template\/default\/ajax.php":3136700671,"app\/\/template\/starter\/template.php":1727269453,"app\/\/template\/developer\/template.php":3702324045,"app\/\/module\/example\/view\/index.php":1697046663,"app\/\/module\/example\/controller.php":3751192754,"app\/\/module\/cms\/action\/admin.php":1736409272,"app\/\/module\/cms\/view\/template.php":2566799738,"app\/\/module\/cms\/view\/admin.php":1106211042,"app\/\/module\/cms\/view\/ajax.php":3021121263,"app\/\/module\/cms\/view\/admin\/objects\/index.php":4243547960,"app\/\/module\/cms\/view\/admin\/objects\/new.php":844624377,"app\/\/module\/cms\/view\/admin\/objects\/edit.php":41990189,"app\/\/module\/cms\/view\/admin\/page\/index.php":1668763883,"app\/\/module\/cms\/view\/admin\/page\/new.php":1076256290,"app\/\/module\/cms\/view\/admin\/page\/edit.php":1731907981,"app\/\/module\/cms\/view\/admin\/menu\/new.php":1341166534,"app\/\/module\/cms\/view\/admin\/menu\/edit.php":2629330881,"app\/\/module\/cms\/view\/admin\/menu\/index.php":1754974259,"app\/\/module\/cms\/view\/admin\/sign-in.php":1455515385,"app\/\/module\/cms\/view\/admin\/index.php":978715433,"app\/\/module\/cms\/view\/admin\/search\/index.php":634988040,"app\/\/module\/cms\/view\/admin\/template\/edit.php":1336875959,"app\/\/module\/cms\/view\/admin\/template\/new.php":872728314,"app\/\/module\/cms\/view\/admin\/template\/index.php":2840055386,"app\/\/module\/cms\/view\/admin\/settings\/index.php":1460865501,"app\/\/module\/cms\/view\/admin\/snippet\/edit.php":775334433,"app\/\/module\/cms\/view\/admin\/snippet\/index.php":688053924,"app\/\/module\/cms\/view\/admin\/snippet\/new.php":1142691519,"app\/\/module\/cms\/view\/admin\/module\/new.php":1075750828,"app\/\/module\/cms\/view\/admin\/module\/view.php":1335707945,"app\/\/module\/cms\/view\/admin\/module\/index.php":3252323382,"app\/\/module\/cms\/view\/admin\/module\/edit.php":3429423843,"app\/\/module\/cms\/view\/admin\/task\/view.php":2949652318,"app\/\/module\/cms\/view\/admin\/task\/index.php":3483692186,"app\/\/module\/cms\/view\/admin\/task\/new.php":1825492831,"app\/\/module\/cms\/view\/admin\/task\/edit.php":846251049,"app\/\/module\/cms\/controller.php":621778871,"app\/\/framework\/traits\/csrf.php":955386642,"app\/\/framework\/helper.php":2264487613,"app\/\/framework\/model.php":629551421,"app\/\/framework\/controller.php":1545133040,"app\/\/controller\/module.php":2987741726,"app\/\/controller\/error.php":795712275,"app\/\/controller\/asset.php":2867769708,"tasks\/\/tasks\/SetFilePermissions.php":3501878165,"tasks\/\/tasks\/RotateLogs.php":1875066464,"tasks\/\/tasks\/Daemon.php":599472155,"tasks\/\/lib\/Runner.php":3345243835,"tasks\/\/lib\/PID.php":3692464962,"tasks\/\/lib\/Db.php":977441352,"tasks\/\/lib\/traits\/RedBean.php":3867071544,"tasks\/\/lib\/traits\/Log.php":1118032917,"tasks\/\/run.php":2908446932}}
5 changes: 2 additions & 3 deletions app/controller/asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct()
$this->f3->set('f3', $this->f3);

// helper - get active template path from session
$this->f3->set('getAssetPath', function($params = [], $type = 'css') {
$this->f3->set('getAssetPath', function ($params = [], $type = 'css') {
//dir
$dir = (!empty($params['dir']) ? basename($params['dir']) : null);

Expand Down Expand Up @@ -146,5 +146,4 @@ public function favicon(\Base $f3, $params)

exit(\Web::instance()->send($path, null, 1024, false));
}

}
}
7 changes: 3 additions & 4 deletions app/controller/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Error extends \Prefab
protected $view;

/**
*
*
*/
public function __construct()
{
Expand All @@ -23,7 +23,7 @@ public function __construct()
$this->settings = new \Framework\Model('settings');
}

/**
/**
* Needs doing
*/
public function display(\Base $f3, $params)
Expand Down Expand Up @@ -86,5 +86,4 @@ public function afterRoute(\Base $f3, $params)
{
echo \View::instance()->render($f3->get('template'));
}

}
}
8 changes: 3 additions & 5 deletions app/controller/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public function __construct()
}

/**
*
*/
*
*/
public function init(\Base $f3, $params)
{
//
Expand All @@ -23,7 +23,6 @@ public function init(\Base $f3, $params)

//
if (file_exists(getcwd().'/app/module/'.$params['module'].'/controller.php')) {

$namespace = '\\Module\\'.ucfirst($params['module']).'\\Controller';

$controller = new $namespace();
Expand Down Expand Up @@ -53,5 +52,4 @@ public function init(\Base $f3, $params)
}
}
}

}
}
5 changes: 2 additions & 3 deletions app/framework/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Controller extends \Prefab
use \Framework\Traits\CSRF;

/**
*
*
*/
public function __construct()
{
Expand Down Expand Up @@ -44,5 +44,4 @@ public function afterRoute(\Base $f3, $params)
echo \View::instance()->render($f3->get('template'));
}
}

}
}
65 changes: 39 additions & 26 deletions app/framework/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ public function __construct()
*/
public function format_bytes($bytes = 0)
{
if ($bytes < 1024) return $bytes.' B';
elseif ($bytes < 1048576) return round($bytes / 1024, 2).' KiB';
elseif ($bytes < 1073741824) return round($bytes / 1048576, 2).' MiB';
elseif ($bytes < 1099511627776) return round($bytes / 1073741824, 2).' GiB';
else return round($bytes / 1099511627776, 2).' TiB';
if ($bytes < 1024) {
return $bytes.' B';
} elseif ($bytes < 1048576) {
return round($bytes / 1024, 2).' KiB';
} elseif ($bytes < 1073741824) {
return round($bytes / 1048576, 2).' MiB';
} elseif ($bytes < 1099511627776) {
return round($bytes / 1073741824, 2).' GiB';
} else {
return round($bytes / 1099511627776, 2).' TiB';
}
}

/**
Expand All @@ -35,13 +41,20 @@ public function short_number($n = 0)
$n = (0+str_replace(",", "", $n));

// is this a number?
if (!is_numeric($n)) return false;
if (!is_numeric($n)) {
return false;
}

// now filter it;
if ($n > 1000000000000) return round(($n/1000000000000), 2).'t';
elseif ($n > 1000000000) return round(($n/1000000000), 2).'b';
elseif ($n > 1000000) return round(($n/1000000), 2).'m';
elseif ($n > 1000) return round(($n/1000), 2).'k';
if ($n > 1000000000000) {
return round(($n/1000000000000), 2).'t';
} elseif ($n > 1000000000) {
return round(($n/1000000000), 2).'b';
} elseif ($n > 1000000) {
return round(($n/1000000), 2).'m';
} elseif ($n > 1000) {
return round(($n/1000), 2).'k';
}

return number_format($n);
}
Expand Down Expand Up @@ -124,7 +137,7 @@ public function slugify($text)
$text = strtolower($text);
// remove unwanted characters
$text = preg_replace('~[^-\w]+~', '', $text);
if (empty($text)){
if (empty($text)) {
return 'n-a';
}
return $text;
Expand Down Expand Up @@ -262,7 +275,7 @@ public function http_response_code_text($domain)
//set status color to warning if not 200
if ($status == 200) {
$labelColor = 'success';
} elseif($status == 404) {
} elseif ($status == 404) {
$labelColor = 'warning';
} else {
$labelColor = 'danger';
Expand All @@ -277,7 +290,8 @@ public function http_response_code_text($domain)
/**
*
*/
public function response_code_text($code) {
public function response_code_text($code)
{
switch ($code) {
case 100: $text = 'Continue'; break;
case 101: $text = 'Switching Protocols'; break;
Expand Down Expand Up @@ -406,7 +420,7 @@ public function get_ip_info($ip = null)
// if we dont have a status query the API
if (empty($ipinfo['status'])) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://ip-api.com/json/'.$ip);
curl_setopt($ch, CURLOPT_URL, 'http://ip-api.com/json/'.$ip);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);

Expand Down Expand Up @@ -447,8 +461,8 @@ public function get_ip_info($ip = null)
* $ids = $this->app->helper->hashid()->decode($ids);
*/
public function hashid(
$salt = 'SHA256ed.f0r.4a5h.sa1tlng',
$length = 6,
$salt = 'SHA256ed.f0r.4a5h.sa1tlng',
$length = 6,
$alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
) {
return new \Hashids\Hashids(
Expand All @@ -466,15 +480,15 @@ public function hashid(
* @param int $last_page
* @return string
*/
function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adjacents = 3, $key = 'pg')
public function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adjacents = 3, $key = 'pg')
{
$ret = null;
$prev = ($p-1);
$next = ($p+1);
$last_page = ($totalposts-1);

// sorting
$sorting =
$sorting =
(!empty($_GET['c']) ? '&c='.$_GET['c'] : '').
(!empty($_GET['o']) ? '&o='.($_GET['o'] == 'asc' ? 'asc' : 'desc') : '');

Expand All @@ -488,8 +502,8 @@ function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adj
$ret.= '<li class="disabled"><a href="javascript:void(0)">&laquo; Previous</a></li> ';
}

if ($totalposts < 7 + ($adjacents * 2)){
for ($counter = 1; $counter <= $totalposts; $counter++){
if ($totalposts < 7 + ($adjacents * 2)) {
for ($counter = 1; $counter <= $totalposts; $counter++) {
if ($counter == $p) {
$ret.= '<li class="active"><a href="javascript:void(0)">'.$counter.'</a></li> ';
} else {
Expand All @@ -498,7 +512,7 @@ function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adj
}
} elseif ($totalposts > 5 + ($adjacents * 2)) {
if ($p < 1 + ($adjacents * 2)) {
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++){
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) {
if ($counter == $p) {
$ret.= '<li class="active"><a href="javascript:void(0)">'.$counter.'</a></li> ';
} else {
Expand All @@ -510,11 +524,11 @@ function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adj
$ret.= ' <li><a href="?'.$key.'='.$totalposts.''.$sorting.'" class="'.$link_class.'" data-keep-state="true">'.$totalposts.'</a></li> ';
}
//in middle; hide some front and some back
elseif($totalposts - ($adjacents * 2) > $p && $p > ($adjacents * 2)){
elseif ($totalposts - ($adjacents * 2) > $p && $p > ($adjacents * 2)) {
$ret.= ' <li><a href="?'.$key.'=1'.$sorting.'" class="'.$link_class.'" data-keep-state="true">1</a></li> ';
$ret.= ' <li><a href="?'.$key.'=2'.$sorting.'" class="'.$link_class.'" data-keep-state="true">2</a></li> ';
$ret.= ' <li class="disabled"><a href="javascript:void(0)">...</a></li> ';
for ($counter = $p - $adjacents; $counter <= $p + $adjacents; $counter++){
for ($counter = $p - $adjacents; $counter <= $p + $adjacents; $counter++) {
if ($counter == $p) {
$ret.= ' <li class="active"><a href="javascript:void(0)">'.$counter.'</a></li> ';
} else {
Expand All @@ -528,7 +542,7 @@ function pagination($totalposts, $p, $last_page, $link_class = 'ajax-link', $adj
$ret.= ' <li><a href="?'.$key.'=1'.$sorting.'" class="'.$link_class.'" data-keep-state="true">1</a></li> ';
$ret.= ' <li><a href="?'.$key.'=2'.$sorting.'" class="'.$link_class.'" data-keep-state="true">2</a></li> ';
$ret.= ' <li class="active"><a href="javascript:void(0)">...</a></li> ';
for ($counter = $totalposts - (2 + ($adjacents * 2)); $counter <= $totalposts; $counter++){
for ($counter = $totalposts - (2 + ($adjacents * 2)); $counter <= $totalposts; $counter++) {
if ($counter == $p) {
$ret.= ' <li class="active"><a href="javascript:void(0)">'.$counter.'</a></li> ';
} else {
Expand Down Expand Up @@ -605,7 +619,6 @@ public function vincentyGreatCircleDistance($latitudeFrom, $longitudeFrom, $lati
$angle = atan2(sqrt($a), $b);
return $angle * $earthRadius;
}

}

}
}
35 changes: 23 additions & 12 deletions app/framework/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Model
protected $table;

/**
*
*
*/
public function __construct($table = null)
{
Expand Down Expand Up @@ -41,7 +41,9 @@ public function __construct($table = null)
*/
public function create($data = [])
{
if ($this->table === null) return null;
if ($this->table === null) {
return null;
}

$row = R::dispense($this->table);
$row->import($data);
Expand All @@ -55,7 +57,9 @@ public function create($data = [])
*/
public function find($where = null, $params = null)
{
if ($this->table === null) return null;
if ($this->table === null) {
return null;
}

if ($where !== null && $params !== null) {
return R::find($this->table, $where, $params);
Expand All @@ -71,7 +75,9 @@ public function find($where = null, $params = null)
*/
public function findAll($where = null, $params = null)
{
if ($this->table === null) return null;
if ($this->table === null) {
return null;
}

if ($where !== null && $params !== null) {
return R::findAll($this->table, $where, $params);
Expand All @@ -87,7 +93,9 @@ public function findAll($where = null, $params = null)
*/
public function findOne($where = null, $params = null)
{
if ($this->table === null) return null;
if ($this->table === null) {
return null;
}

if ($where !== null && $params !== null) {
return R::findOne($this->table, $where, $params);
Expand All @@ -96,7 +104,7 @@ public function findOne($where = null, $params = null)
} else {
return R::findOne($this->table);
}
}
}

/**
* Get all
Expand All @@ -110,7 +118,7 @@ public function getAll($where = null, $params = null)
} else {
return [];
}
}
}

/**
* Get row
Expand All @@ -124,7 +132,7 @@ public function getRow($where = null, $params = null)
} else {
return [];
}
}
}

/**
* Get col
Expand Down Expand Up @@ -167,7 +175,9 @@ public function findOrCreate($params = [])
*/
public function count($where = null, $params = null)
{
if ($this->table === null) return null;
if ($this->table === null) {
return null;
}

if ($where !== null && $params !== null) {
return R::count($this->table, $where, $params);
Expand All @@ -183,7 +193,9 @@ public function count($where = null, $params = null)
*/
public function load($id)
{
if ($this->table === null) return null;
if ($this->table === null) {
return null;
}

return R::load($this->table, $id);
}
Expand Down Expand Up @@ -227,6 +239,5 @@ public function trash(\RedBeanPHP\OODBBean $row)
{
return R::trash($row);
}

}
}
}
Loading

0 comments on commit 7316245

Please sign in to comment.