@@ -4,5 +4,5 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface LogRepositoryInterface |
| 6 | 6 | { |
| 7 | - public function getActiveLogs($limit = null, $offset= 0); |
|
| 7 | + public function getActiveLogs($limit = null, $offset = 0); |
|
| 8 | 8 | } |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Jacobemerick\Web\Domain\Waterfall\Log; |
| 4 | 4 | |
| 5 | -interface LogRepositoryInterface |
|
| 6 | -{ |
|
| 5 | +interface LogRepositoryInterface |
|
| 6 | +{
|
|
| 7 | 7 | public function getActiveLogs($limit = null, $offset= 0); |
| 8 | 8 | } |
@@ -4,5 +4,5 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface WaterfallRepositoryInterface |
| 6 | 6 | { |
| 7 | - public function getWaterfalls($limit = null, $offset= 0); |
|
| 7 | + public function getWaterfalls($limit = null, $offset = 0); |
|
| 8 | 8 | } |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Jacobemerick\Web\Domain\Waterfall\Waterfall; |
| 4 | 4 | |
| 5 | -interface WaterfallRepositoryInterface |
|
| 6 | -{ |
|
| 5 | +interface WaterfallRepositoryInterface |
|
| 6 | +{
|
|
| 7 | 7 | public function getWaterfalls($limit = null, $offset= 0); |
| 8 | 8 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | protected $connections; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
| 14 | + * @param ConnectionLocator $connections |
|
| 15 | 15 | */ |
| 16 | 16 | public function __construct(ConnectionLocator $connections) |
| 17 | 17 | { |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Aura\Sql\ConnectionLocator; |
| 6 | 6 | |
| 7 | -class MysqlCompanionRepository implements CompanionRepositoryInterface |
|
| 8 | -{ |
|
| 7 | +class MysqlCompanionRepository implements CompanionRepositoryInterface |
|
| 8 | +{
|
|
| 9 | 9 | |
| 10 | 10 | /** @var Aura\Sql\ConnectionLocator */ |
| 11 | 11 | protected $connections; |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @param Aura\Sql\ConnectionLocator $connections |
| 15 | 15 | */ |
| 16 | - public function __construct(ConnectionLocator $connections) |
|
| 17 | - { |
|
| 16 | + public function __construct(ConnectionLocator $connections) |
|
| 17 | + {
|
|
| 18 | 18 | $this->connections = $connections; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function getCompanionList() |
|
| 22 | - { |
|
| 21 | + public function getCompanionList() |
|
| 22 | + {
|
|
| 23 | 23 | $query = " |
| 24 | 24 | SELECT `companion`.`name`, `companion`.`alias`, COUNT(1) AS `count` |
| 25 | 25 | FROM `jpemeric_waterfall`.`companion` |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | protected $connections; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
| 14 | + * @param ConnectionLocator $connections |
|
| 15 | 15 | */ |
| 16 | 16 | public function __construct(ConnectionLocator $connections) |
| 17 | 17 | { |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Aura\Sql\ConnectionLocator; |
| 6 | 6 | |
| 7 | -class MysqlCountyRepository implements CountyRepositoryInterface |
|
| 8 | -{ |
|
| 7 | +class MysqlCountyRepository implements CountyRepositoryInterface |
|
| 8 | +{
|
|
| 9 | 9 | |
| 10 | 10 | /** @var Aura\Sql\ConnectionLocator */ |
| 11 | 11 | protected $connections; |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @param Aura\Sql\ConnectionLocator $connections |
| 15 | 15 | */ |
| 16 | - public function __construct(ConnectionLocator $connections) |
|
| 17 | - { |
|
| 16 | + public function __construct(ConnectionLocator $connections) |
|
| 17 | + {
|
|
| 18 | 18 | $this->connections = $connections; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function getCountyList() |
|
| 22 | - { |
|
| 21 | + public function getCountyList() |
|
| 22 | + {
|
|
| 23 | 23 | $query = " |
| 24 | 24 | SELECT `county`.`name`, `county`.`alias`, COUNT(1) AS `count` |
| 25 | 25 | FROM `jpemeric_waterfall`.`county` |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | protected $connections; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
| 14 | + * @param ConnectionLocator $connections |
|
| 15 | 15 | */ |
| 16 | 16 | public function __construct(ConnectionLocator $connections) |
| 17 | 17 | { |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Aura\Sql\ConnectionLocator; |
| 6 | 6 | |
| 7 | -class MysqlLogRepository implements LogRepositoryInterface |
|
| 8 | -{ |
|
| 7 | +class MysqlLogRepository implements LogRepositoryInterface |
|
| 8 | +{
|
|
| 9 | 9 | |
| 10 | 10 | /** @var Aura\Sql\ConnectionLocator */ |
| 11 | 11 | protected $connections; |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @param Aura\Sql\ConnectionLocator $connections |
| 15 | 15 | */ |
| 16 | - public function __construct(ConnectionLocator $connections) |
|
| 17 | - { |
|
| 16 | + public function __construct(ConnectionLocator $connections) |
|
| 17 | + {
|
|
| 18 | 18 | $this->connections = $connections; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function getActiveLogs($limit = null, $offset = 0) |
|
| 22 | - { |
|
| 21 | + public function getActiveLogs($limit = null, $offset = 0) |
|
| 22 | + {
|
|
| 23 | 23 | $query = " |
| 24 | 24 | SELECT `id`, `title`, `alias`, `date`, `publish_date`, `introduction` |
| 25 | 25 | FROM `jpemeric_waterfall`.`log` |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | protected $connections; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
| 14 | + * @param ConnectionLocator $connections |
|
| 15 | 15 | */ |
| 16 | 16 | public function __construct(ConnectionLocator $connections) |
| 17 | 17 | { |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Aura\Sql\ConnectionLocator; |
| 6 | 6 | |
| 7 | -class MysqlPeriodRepository implements PeriodRepositoryInterface |
|
| 8 | -{ |
|
| 7 | +class MysqlPeriodRepository implements PeriodRepositoryInterface |
|
| 8 | +{
|
|
| 9 | 9 | |
| 10 | 10 | /** @var Aura\Sql\ConnectionLocator */ |
| 11 | 11 | protected $connections; |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @param Aura\Sql\ConnectionLocator $connections |
| 15 | 15 | */ |
| 16 | - public function __construct(ConnectionLocator $connections) |
|
| 17 | - { |
|
| 16 | + public function __construct(ConnectionLocator $connections) |
|
| 17 | + {
|
|
| 18 | 18 | $this->connections = $connections; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function getPeriodList() |
|
| 22 | - { |
|
| 21 | + public function getPeriodList() |
|
| 22 | + {
|
|
| 23 | 23 | $query = " |
| 24 | 24 | SELECT `period`.`name`, `period`.`alias`, COUNT(1) AS `count` |
| 25 | 25 | FROM `jpemeric_waterfall`.`period` |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | protected $connections; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
| 14 | + * @param ConnectionLocator $connections |
|
| 15 | 15 | */ |
| 16 | 16 | public function __construct(ConnectionLocator $connections) |
| 17 | 17 | { |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Aura\Sql\ConnectionLocator; |
| 6 | 6 | |
| 7 | -class MysqlWatercourseRepository implements WatercourseRepositoryInterface |
|
| 8 | -{ |
|
| 7 | +class MysqlWatercourseRepository implements WatercourseRepositoryInterface |
|
| 8 | +{
|
|
| 9 | 9 | |
| 10 | 10 | /** @var Aura\Sql\ConnectionLocator */ |
| 11 | 11 | protected $connections; |
@@ -13,14 +13,14 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @param Aura\Sql\ConnectionLocator $connections |
| 15 | 15 | */ |
| 16 | - public function __construct(ConnectionLocator $connections) |
|
| 17 | - { |
|
| 16 | + public function __construct(ConnectionLocator $connections) |
|
| 17 | + {
|
|
| 18 | 18 | $this->connections = $connections; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | // todo wot are you even serious |
| 22 | - public function getWatercourseList() |
|
| 23 | - { |
|
| 22 | + public function getWatercourseList() |
|
| 23 | + {
|
|
| 24 | 24 | $query = " |
| 25 | 25 | SELECT `sum_table`.`name`, `sum_table`.`alias`, SUM(`count`) AS `count` |
| 26 | 26 | FROM (( |
@@ -59,6 +59,9 @@ discard block |
||
| 59 | 59 | $this->add_posts($youtube_result, 'youtube'); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | + /** |
|
| 63 | + * @param string $type |
|
| 64 | + */ |
|
| 62 | 65 | private function remove_existing($result, $type) |
| 63 | 66 | {
|
| 64 | 67 | foreach($result as $key => $row) |
@@ -70,6 +73,9 @@ discard block |
||
| 70 | 73 | return $result; |
| 71 | 74 | } |
| 72 | 75 | |
| 76 | + /** |
|
| 77 | + * @param string $type |
|
| 78 | + */ |
|
| 73 | 79 | private function add_posts($result, $type) |
| 74 | 80 | {
|
| 75 | 81 | foreach($result as $row) |
@@ -17,14 +17,14 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public static function instance() |
| 19 | 19 | { |
| 20 | - if(!isset(self::$instance)) |
|
| 20 | + if (!isset(self::$instance)) |
|
| 21 | 21 | self::$instance = new Loader(); |
| 22 | 22 | return self::$instance; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | private function get_root() |
| 26 | 26 | { |
| 27 | - if(!isset($this->root)) |
|
| 27 | + if (!isset($this->root)) |
|
| 28 | 28 | { |
| 29 | 29 | $current_directory = dirname(__FILE__); |
| 30 | 30 | $current_directory = substr($current_directory, 0, -7); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | private static function get_extension($type) |
| 54 | 54 | { |
| 55 | - switch($type) |
|
| 55 | + switch ($type) |
|
| 56 | 56 | { |
| 57 | 57 | case 'collector' : |
| 58 | 58 | case 'controller' : |
@@ -104,15 +104,15 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | public static function load($type, $files, $data = array()) |
| 106 | 106 | { |
| 107 | - foreach((array) $files as $file) |
|
| 107 | + foreach ((array) $files as $file) |
|
| 108 | 108 | { |
| 109 | 109 | $file_path = self::instance()->get_path($type, $file); |
| 110 | - if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
| 110 | + if (in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
| 111 | 111 | continue; |
| 112 | 112 | |
| 113 | 113 | self::instance()->add_included_file($file_path); |
| 114 | 114 | |
| 115 | - switch($type) |
|
| 115 | + switch ($type) |
|
| 116 | 116 | { |
| 117 | 117 | case 'images' : |
| 118 | 118 | case 'scripts' : |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | $reflectionObject = self::create_reflection_class($file); |
| 144 | 144 | |
| 145 | - if( |
|
| 145 | + if ( |
|
| 146 | 146 | $reflectionObject->hasMethod('instance') && |
| 147 | 147 | $reflectionObject->getMethod('instance')->isStatic()) |
| 148 | 148 | { |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $reflectionObject = self::create_reflection_class($file); |
| 159 | 159 | |
| 160 | - if($reflectionObject->hasMethod('__construct')) |
|
| 160 | + if ($reflectionObject->hasMethod('__construct')) |
|
| 161 | 161 | return $reflectionObject->newInstanceArgs($data); |
| 162 | 162 | else |
| 163 | 163 | return $reflectionObject->newInstance(); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | if ($site == 'waterfalls' && self::instance()->is_live) { |
| 181 | 181 | return "{$protocol}://www.waterfallsofthekeweenaw.com/"; |
| 182 | 182 | } else { |
| 183 | - return $protocol . '://' . (self::instance()->is_live ? '' : 'dev.') . $site . '.jacobemerick.com/'; |
|
| 183 | + return $protocol.'://'.(self::instance()->is_live ? '' : 'dev.').$site.'.jacobemerick.com/'; |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | return '/'; |
@@ -3,175 +3,175 @@ |
||
| 3 | 3 | final class Loader |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - private $root; |
|
| 7 | - private $is_live; |
|
| 8 | - private $included_files = array(); |
|
| 9 | - |
|
| 10 | - private static $instance; |
|
| 11 | - |
|
| 12 | - private function __construct() |
|
| 13 | - { |
|
| 14 | - $this->is_live = (isset($_SERVER['HTTP_HOST']) && substr($_SERVER['HTTP_HOST'], 0, 4) !== 'dev.'); |
|
| 15 | - return $this; |
|
| 16 | - } |
|
| 17 | - |
|
| 18 | - public static function instance() |
|
| 19 | - { |
|
| 20 | - if(!isset(self::$instance)) |
|
| 21 | - self::$instance = new Loader(); |
|
| 22 | - return self::$instance; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - private function get_root() |
|
| 26 | - { |
|
| 27 | - if(!isset($this->root)) |
|
| 28 | - { |
|
| 29 | - $current_directory = dirname(__FILE__); |
|
| 30 | - $current_directory = substr($current_directory, 0, -7); |
|
| 31 | - $this->root = $current_directory; |
|
| 32 | - } |
|
| 6 | + private $root; |
|
| 7 | + private $is_live; |
|
| 8 | + private $included_files = array(); |
|
| 9 | + |
|
| 10 | + private static $instance; |
|
| 11 | + |
|
| 12 | + private function __construct() |
|
| 13 | + { |
|
| 14 | + $this->is_live = (isset($_SERVER['HTTP_HOST']) && substr($_SERVER['HTTP_HOST'], 0, 4) !== 'dev.'); |
|
| 15 | + return $this; |
|
| 16 | + } |
|
| 17 | + |
|
| 18 | + public static function instance() |
|
| 19 | + { |
|
| 20 | + if(!isset(self::$instance)) |
|
| 21 | + self::$instance = new Loader(); |
|
| 22 | + return self::$instance; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + private function get_root() |
|
| 26 | + { |
|
| 27 | + if(!isset($this->root)) |
|
| 28 | + { |
|
| 29 | + $current_directory = dirname(__FILE__); |
|
| 30 | + $current_directory = substr($current_directory, 0, -7); |
|
| 31 | + $this->root = $current_directory; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - return $this->root; |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - private function get_delimiter() |
|
| 38 | - { |
|
| 39 | - return (true || $this->is_live) ? '/' : '\\'; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - private function check_delimiters($path) |
|
| 43 | - { |
|
| 44 | - return (true || $this->is_live) ? $path : str_replace('/', '\\', $path); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - private static function get_class_name($path) |
|
| 48 | - { |
|
| 49 | - $path_array = explode('/', $path); |
|
| 50 | - return array_pop($path_array); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - private static function get_extension($type) |
|
| 54 | - { |
|
| 55 | - switch($type) |
|
| 56 | - { |
|
| 57 | - case 'collector' : |
|
| 58 | - case 'controller' : |
|
| 59 | - case 'model' : |
|
| 60 | - case 'module' : |
|
| 61 | - case 'router' : |
|
| 62 | - case 'utility' : |
|
| 63 | - $extension = '.class.inc.php'; |
|
| 64 | - break; |
|
| 65 | - case 'view' : |
|
| 66 | - $extension = '.tpl.php'; |
|
| 67 | - break; |
|
| 68 | - } |
|
| 69 | - return $extension; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - public static function getImagePath($type, $file) |
|
| 73 | - { |
|
| 74 | - $path = self::instance()->get_root(); |
|
| 75 | - $path .= 'public'; |
|
| 76 | - $path .= self::instance()->get_delimiter(); |
|
| 77 | - $path .= $type; |
|
| 78 | - $path .= self::instance()->get_delimiter(); |
|
| 79 | - $path .= self::instance()->check_delimiters($file); |
|
| 34 | + return $this->root; |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + private function get_delimiter() |
|
| 38 | + { |
|
| 39 | + return (true || $this->is_live) ? '/' : '\\'; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + private function check_delimiters($path) |
|
| 43 | + { |
|
| 44 | + return (true || $this->is_live) ? $path : str_replace('/', '\\', $path); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + private static function get_class_name($path) |
|
| 48 | + { |
|
| 49 | + $path_array = explode('/', $path); |
|
| 50 | + return array_pop($path_array); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + private static function get_extension($type) |
|
| 54 | + { |
|
| 55 | + switch($type) |
|
| 56 | + { |
|
| 57 | + case 'collector' : |
|
| 58 | + case 'controller' : |
|
| 59 | + case 'model' : |
|
| 60 | + case 'module' : |
|
| 61 | + case 'router' : |
|
| 62 | + case 'utility' : |
|
| 63 | + $extension = '.class.inc.php'; |
|
| 64 | + break; |
|
| 65 | + case 'view' : |
|
| 66 | + $extension = '.tpl.php'; |
|
| 67 | + break; |
|
| 68 | + } |
|
| 69 | + return $extension; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + public static function getImagePath($type, $file) |
|
| 73 | + { |
|
| 74 | + $path = self::instance()->get_root(); |
|
| 75 | + $path .= 'public'; |
|
| 76 | + $path .= self::instance()->get_delimiter(); |
|
| 77 | + $path .= $type; |
|
| 78 | + $path .= self::instance()->get_delimiter(); |
|
| 79 | + $path .= self::instance()->check_delimiters($file); |
|
| 80 | 80 | |
| 81 | - return $path; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - private static function get_path($type, $file) |
|
| 85 | - { |
|
| 86 | - $path = self::instance()->get_root(); |
|
| 87 | - $path .= $type; |
|
| 88 | - $path .= self::instance()->get_delimiter(); |
|
| 89 | - $path .= self::instance()->check_delimiters($file); |
|
| 90 | - $path .= self::get_extension($type); |
|
| 81 | + return $path; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + private static function get_path($type, $file) |
|
| 85 | + { |
|
| 86 | + $path = self::instance()->get_root(); |
|
| 87 | + $path .= $type; |
|
| 88 | + $path .= self::instance()->get_delimiter(); |
|
| 89 | + $path .= self::instance()->check_delimiters($file); |
|
| 90 | + $path .= self::get_extension($type); |
|
| 91 | 91 | |
| 92 | - return $path; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - private function get_included_files() |
|
| 96 | - { |
|
| 97 | - return $this->included_files; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - private function add_included_file($path) |
|
| 101 | - { |
|
| 102 | - $this->included_files[] = $path; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - public static function load($type, $files, $data = array()) |
|
| 106 | - { |
|
| 107 | - foreach((array) $files as $file) |
|
| 108 | - { |
|
| 109 | - $file_path = self::instance()->get_path($type, $file); |
|
| 110 | - if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
| 111 | - continue; |
|
| 92 | + return $path; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + private function get_included_files() |
|
| 96 | + { |
|
| 97 | + return $this->included_files; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + private function add_included_file($path) |
|
| 101 | + { |
|
| 102 | + $this->included_files[] = $path; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + public static function load($type, $files, $data = array()) |
|
| 106 | + { |
|
| 107 | + foreach((array) $files as $file) |
|
| 108 | + { |
|
| 109 | + $file_path = self::instance()->get_path($type, $file); |
|
| 110 | + if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
| 111 | + continue; |
|
| 112 | 112 | |
| 113 | - self::instance()->add_included_file($file_path); |
|
| 113 | + self::instance()->add_included_file($file_path); |
|
| 114 | 114 | |
| 115 | - switch($type) |
|
| 116 | - { |
|
| 117 | - case 'images' : |
|
| 118 | - case 'scripts' : |
|
| 119 | - case 'styles' : |
|
| 120 | - echo file_get_contents($file_path); |
|
| 121 | - break; |
|
| 122 | - case 'view' : |
|
| 123 | - extract($data); |
|
| 124 | - include($file_path); |
|
| 125 | - break; |
|
| 126 | - default : |
|
| 127 | - include_once($file_path); |
|
| 128 | - break; |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - private static function create_reflection_class($file) |
|
| 134 | - { |
|
| 135 | - $class_name = self::instance()->get_class_name($file); |
|
| 136 | - return new ReflectionClass($class_name); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - public static function loadInstance($type, $file) |
|
| 140 | - { |
|
| 141 | - self::load($type, $file); |
|
| 115 | + switch($type) |
|
| 116 | + { |
|
| 117 | + case 'images' : |
|
| 118 | + case 'scripts' : |
|
| 119 | + case 'styles' : |
|
| 120 | + echo file_get_contents($file_path); |
|
| 121 | + break; |
|
| 122 | + case 'view' : |
|
| 123 | + extract($data); |
|
| 124 | + include($file_path); |
|
| 125 | + break; |
|
| 126 | + default : |
|
| 127 | + include_once($file_path); |
|
| 128 | + break; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + private static function create_reflection_class($file) |
|
| 134 | + { |
|
| 135 | + $class_name = self::instance()->get_class_name($file); |
|
| 136 | + return new ReflectionClass($class_name); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + public static function loadInstance($type, $file) |
|
| 140 | + { |
|
| 141 | + self::load($type, $file); |
|
| 142 | 142 | |
| 143 | - $reflectionObject = self::create_reflection_class($file); |
|
| 143 | + $reflectionObject = self::create_reflection_class($file); |
|
| 144 | 144 | |
| 145 | - if( |
|
| 146 | - $reflectionObject->hasMethod('instance') && |
|
| 147 | - $reflectionObject->getMethod('instance')->isStatic()) |
|
| 148 | - { |
|
| 149 | - return $reflectionObject->getMethod('instance')->invoke(null); |
|
| 150 | - } |
|
| 151 | - trigger_error("Requested class cannot be instance'd: {$type}, {$file}"); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - public static function loadNew($type, $file, $data = array()) |
|
| 155 | - { |
|
| 156 | - self::load($type, $file); |
|
| 145 | + if( |
|
| 146 | + $reflectionObject->hasMethod('instance') && |
|
| 147 | + $reflectionObject->getMethod('instance')->isStatic()) |
|
| 148 | + { |
|
| 149 | + return $reflectionObject->getMethod('instance')->invoke(null); |
|
| 150 | + } |
|
| 151 | + trigger_error("Requested class cannot be instance'd: {$type}, {$file}"); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + public static function loadNew($type, $file, $data = array()) |
|
| 155 | + { |
|
| 156 | + self::load($type, $file); |
|
| 157 | 157 | |
| 158 | - $reflectionObject = self::create_reflection_class($file); |
|
| 158 | + $reflectionObject = self::create_reflection_class($file); |
|
| 159 | 159 | |
| 160 | - if($reflectionObject->hasMethod('__construct')) |
|
| 161 | - return $reflectionObject->newInstanceArgs($data); |
|
| 162 | - else |
|
| 163 | - return $reflectionObject->newInstance(); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - public static function getRoot() |
|
| 167 | - { |
|
| 168 | - return self::instance()->get_root(); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - public static function isLive() |
|
| 172 | - { |
|
| 173 | - return self::instance()->is_live; |
|
| 174 | - } |
|
| 160 | + if($reflectionObject->hasMethod('__construct')) |
|
| 161 | + return $reflectionObject->newInstanceArgs($data); |
|
| 162 | + else |
|
| 163 | + return $reflectionObject->newInstance(); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + public static function getRoot() |
|
| 167 | + { |
|
| 168 | + return self::instance()->get_root(); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + public static function isLive() |
|
| 172 | + { |
|
| 173 | + return self::instance()->is_live; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | 176 | public static function getRootURL($site = '') |
| 177 | 177 | { |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -final class Loader |
|
| 4 | -{ |
|
| 3 | +final class Loader |
|
| 4 | +{
|
|
| 5 | 5 | |
| 6 | 6 | private $root; |
| 7 | 7 | private $is_live; |
@@ -9,21 +9,22 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | private static $instance; |
| 11 | 11 | |
| 12 | - private function __construct() |
|
| 13 | - { |
|
| 12 | + private function __construct() |
|
| 13 | + {
|
|
| 14 | 14 | $this->is_live = (isset($_SERVER['HTTP_HOST']) && substr($_SERVER['HTTP_HOST'], 0, 4) !== 'dev.'); |
| 15 | 15 | return $this; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public static function instance() |
|
| 19 | - { |
|
| 20 | - if(!isset(self::$instance)) |
|
| 21 | - self::$instance = new Loader(); |
|
| 18 | + public static function instance() |
|
| 19 | + {
|
|
| 20 | + if(!isset(self::$instance)) {
|
|
| 21 | + self::$instance = new Loader(); |
|
| 22 | + } |
|
| 22 | 23 | return self::$instance; |
| 23 | 24 | } |
| 24 | 25 | |
| 25 | - private function get_root() |
|
| 26 | - { |
|
| 26 | + private function get_root() |
|
| 27 | + {
|
|
| 27 | 28 | if(!isset($this->root)) |
| 28 | 29 | { |
| 29 | 30 | $current_directory = dirname(__FILE__); |
@@ -34,24 +35,24 @@ discard block |
||
| 34 | 35 | return $this->root; |
| 35 | 36 | } |
| 36 | 37 | |
| 37 | - private function get_delimiter() |
|
| 38 | - { |
|
| 38 | + private function get_delimiter() |
|
| 39 | + {
|
|
| 39 | 40 | return (true || $this->is_live) ? '/' : '\\'; |
| 40 | 41 | } |
| 41 | 42 | |
| 42 | - private function check_delimiters($path) |
|
| 43 | - { |
|
| 43 | + private function check_delimiters($path) |
|
| 44 | + {
|
|
| 44 | 45 | return (true || $this->is_live) ? $path : str_replace('/', '\\', $path); |
| 45 | 46 | } |
| 46 | 47 | |
| 47 | - private static function get_class_name($path) |
|
| 48 | - { |
|
| 48 | + private static function get_class_name($path) |
|
| 49 | + {
|
|
| 49 | 50 | $path_array = explode('/', $path); |
| 50 | 51 | return array_pop($path_array); |
| 51 | 52 | } |
| 52 | 53 | |
| 53 | - private static function get_extension($type) |
|
| 54 | - { |
|
| 54 | + private static function get_extension($type) |
|
| 55 | + {
|
|
| 55 | 56 | switch($type) |
| 56 | 57 | { |
| 57 | 58 | case 'collector' : |
@@ -69,8 +70,8 @@ discard block |
||
| 69 | 70 | return $extension; |
| 70 | 71 | } |
| 71 | 72 | |
| 72 | - public static function getImagePath($type, $file) |
|
| 73 | - { |
|
| 73 | + public static function getImagePath($type, $file) |
|
| 74 | + {
|
|
| 74 | 75 | $path = self::instance()->get_root(); |
| 75 | 76 | $path .= 'public'; |
| 76 | 77 | $path .= self::instance()->get_delimiter(); |
@@ -81,8 +82,8 @@ discard block |
||
| 81 | 82 | return $path; |
| 82 | 83 | } |
| 83 | 84 | |
| 84 | - private static function get_path($type, $file) |
|
| 85 | - { |
|
| 85 | + private static function get_path($type, $file) |
|
| 86 | + {
|
|
| 86 | 87 | $path = self::instance()->get_root(); |
| 87 | 88 | $path .= $type; |
| 88 | 89 | $path .= self::instance()->get_delimiter(); |
@@ -92,23 +93,24 @@ discard block |
||
| 92 | 93 | return $path; |
| 93 | 94 | } |
| 94 | 95 | |
| 95 | - private function get_included_files() |
|
| 96 | - { |
|
| 96 | + private function get_included_files() |
|
| 97 | + {
|
|
| 97 | 98 | return $this->included_files; |
| 98 | 99 | } |
| 99 | 100 | |
| 100 | - private function add_included_file($path) |
|
| 101 | - { |
|
| 101 | + private function add_included_file($path) |
|
| 102 | + {
|
|
| 102 | 103 | $this->included_files[] = $path; |
| 103 | 104 | } |
| 104 | 105 | |
| 105 | - public static function load($type, $files, $data = array()) |
|
| 106 | - { |
|
| 106 | + public static function load($type, $files, $data = array()) |
|
| 107 | + {
|
|
| 107 | 108 | foreach((array) $files as $file) |
| 108 | 109 | { |
| 109 | 110 | $file_path = self::instance()->get_path($type, $file); |
| 110 | - if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
| 111 | - continue; |
|
| 111 | + if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') {
|
|
| 112 | + continue; |
|
| 113 | + } |
|
| 112 | 114 | |
| 113 | 115 | self::instance()->add_included_file($file_path); |
| 114 | 116 | |
@@ -130,14 +132,14 @@ discard block |
||
| 130 | 132 | } |
| 131 | 133 | } |
| 132 | 134 | |
| 133 | - private static function create_reflection_class($file) |
|
| 134 | - { |
|
| 135 | + private static function create_reflection_class($file) |
|
| 136 | + {
|
|
| 135 | 137 | $class_name = self::instance()->get_class_name($file); |
| 136 | 138 | return new ReflectionClass($class_name); |
| 137 | 139 | } |
| 138 | 140 | |
| 139 | - public static function loadInstance($type, $file) |
|
| 140 | - { |
|
| 141 | + public static function loadInstance($type, $file) |
|
| 142 | + {
|
|
| 141 | 143 | self::load($type, $file); |
| 142 | 144 | |
| 143 | 145 | $reflectionObject = self::create_reflection_class($file); |
@@ -151,30 +153,31 @@ discard block |
||
| 151 | 153 | trigger_error("Requested class cannot be instance'd: {$type}, {$file}"); |
| 152 | 154 | } |
| 153 | 155 | |
| 154 | - public static function loadNew($type, $file, $data = array()) |
|
| 155 | - { |
|
| 156 | + public static function loadNew($type, $file, $data = array()) |
|
| 157 | + {
|
|
| 156 | 158 | self::load($type, $file); |
| 157 | 159 | |
| 158 | 160 | $reflectionObject = self::create_reflection_class($file); |
| 159 | 161 | |
| 160 | - if($reflectionObject->hasMethod('__construct')) |
|
| 161 | - return $reflectionObject->newInstanceArgs($data); |
|
| 162 | - else |
|
| 163 | - return $reflectionObject->newInstance(); |
|
| 162 | + if($reflectionObject->hasMethod('__construct')) {
|
|
| 163 | + return $reflectionObject->newInstanceArgs($data); |
|
| 164 | + } else {
|
|
| 165 | + return $reflectionObject->newInstance(); |
|
| 166 | + } |
|
| 164 | 167 | } |
| 165 | 168 | |
| 166 | - public static function getRoot() |
|
| 167 | - { |
|
| 169 | + public static function getRoot() |
|
| 170 | + {
|
|
| 168 | 171 | return self::instance()->get_root(); |
| 169 | 172 | } |
| 170 | 173 | |
| 171 | - public static function isLive() |
|
| 172 | - { |
|
| 174 | + public static function isLive() |
|
| 175 | + {
|
|
| 173 | 176 | return self::instance()->is_live; |
| 174 | 177 | } |
| 175 | 178 | |
| 176 | - public static function getRootURL($site = '') |
|
| 177 | - { |
|
| 179 | + public static function getRootURL($site = '') |
|
| 180 | + {
|
|
| 178 | 181 | if (strlen($site) > 0) { |
| 179 | 182 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
| 180 | 183 | if ($site == 'waterfalls' && self::instance()->is_live) { |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | protected $connections; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
| 14 | + * @param ConnectionLocator $connections |
|
| 15 | 15 | */ |
| 16 | 16 | public function __construct(ConnectionLocator $connections) |
| 17 | 17 | { |
@@ -41,6 +41,9 @@ discard block |
||
| 41 | 41 | ->fetchOne($query, $bindings); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | + /** |
|
| 45 | + * @param integer $limit |
|
| 46 | + */ |
|
| 44 | 47 | public function getActivePosts($limit = null, $offset = 0) |
| 45 | 48 | { |
| 46 | 49 | $query = " |
@@ -79,6 +82,9 @@ discard block |
||
| 79 | 82 | ->fetchValue($query, $bindings); |
| 80 | 83 | } |
| 81 | 84 | |
| 85 | + /** |
|
| 86 | + * @param integer $limit |
|
| 87 | + */ |
|
| 82 | 88 | public function getActivePostsByTag($tag, $limit = null, $offset = 0) |
| 83 | 89 | { |
| 84 | 90 | $query = " |
@@ -122,6 +128,9 @@ discard block |
||
| 122 | 128 | ->fetchValue($query, $bindings); |
| 123 | 129 | } |
| 124 | 130 | |
| 131 | + /** |
|
| 132 | + * @param integer $limit |
|
| 133 | + */ |
|
| 125 | 134 | public function getActivePostsByCategory($category, $limit = null, $offset = 0) |
| 126 | 135 | { |
| 127 | 136 | $query = " |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Aura\Sql\ConnectionLocator; |
| 6 | 6 | |
| 7 | -class MysqlPostRepository implements PostRepositoryInterface |
|
| 8 | -{ |
|
| 7 | +class MysqlPostRepository implements PostRepositoryInterface |
|
| 8 | +{
|
|
| 9 | 9 | |
| 10 | 10 | /** @var Aura\Sql\ConnectionLocator */ |
| 11 | 11 | protected $connections; |
@@ -13,8 +13,8 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @param Aura\Sql\ConnectionLocator $connections |
| 15 | 15 | */ |
| 16 | - public function __construct(ConnectionLocator $connections) |
|
| 17 | - { |
|
| 16 | + public function __construct(ConnectionLocator $connections) |
|
| 17 | + {
|
|
| 18 | 18 | $this->connections = $connections; |
| 19 | 19 | } |
| 20 | 20 | |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array|false |
| 25 | 25 | */ |
| 26 | - public function findPostByPath($path) |
|
| 27 | - { |
|
| 26 | + public function findPostByPath($path) |
|
| 27 | + {
|
|
| 28 | 28 | $query = " |
| 29 | 29 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
| 30 | 30 | FROM `jpemeric_blog`.`post` |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | ->fetchOne($query, $bindings); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function getActivePosts($limit = null, $offset = 0) |
|
| 45 | - { |
|
| 44 | + public function getActivePosts($limit = null, $offset = 0) |
|
| 45 | + {
|
|
| 46 | 46 | $query = " |
| 47 | 47 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
| 48 | 48 | FROM `jpemeric_blog`.`post` |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | ->fetchAll($query, $bindings); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function getActivePostsCount() |
|
| 67 | - { |
|
| 66 | + public function getActivePostsCount() |
|
| 67 | + {
|
|
| 68 | 68 | $query = " |
| 69 | 69 | SELECT COUNT(1) AS `count` |
| 70 | 70 | FROM `jpemeric_blog`.`post` |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | ->fetchValue($query, $bindings); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - public function getActivePostsByTag($tag, $limit = null, $offset = 0) |
|
| 83 | - { |
|
| 82 | + public function getActivePostsByTag($tag, $limit = null, $offset = 0) |
|
| 83 | + {
|
|
| 84 | 84 | $query = " |
| 85 | 85 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
| 86 | 86 | FROM `jpemeric_blog`.`post` |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | ->fetchAll($query, $bindings); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - public function getActivePostsCountByTag($tag) |
|
| 108 | - { |
|
| 107 | + public function getActivePostsCountByTag($tag) |
|
| 108 | + {
|
|
| 109 | 109 | $query = " |
| 110 | 110 | SELECT COUNT(1) AS `count` |
| 111 | 111 | FROM `jpemeric_blog`.`post` |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | ->fetchValue($query, $bindings); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function getActivePostsByCategory($category, $limit = null, $offset = 0) |
|
| 127 | - { |
|
| 126 | + public function getActivePostsByCategory($category, $limit = null, $offset = 0) |
|
| 127 | + {
|
|
| 128 | 128 | $query = " |
| 129 | 129 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
| 130 | 130 | FROM `jpemeric_blog`.`post` |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | ->fetchAll($query, $bindings); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - public function getActivePostsCountByCategory($category) |
|
| 150 | - { |
|
| 149 | + public function getActivePostsCountByCategory($category) |
|
| 150 | + {
|
|
| 151 | 151 | $query = " |
| 152 | 152 | SELECT COUNT(1) AS `count` |
| 153 | 153 | FROM `jpemeric_blog`.`post` |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | ->fetchValue($query, $bindings); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - public function getActivePostsByRelatedTags($post, $limit = 4) |
|
| 167 | - { |
|
| 166 | + public function getActivePostsByRelatedTags($post, $limit = 4) |
|
| 167 | + {
|
|
| 168 | 168 | $query = " |
| 169 | 169 | SELECT `id`, `title`, `path`, `date`, `body`, `category`, COUNT(1) AS `count` |
| 170 | 170 | FROM `jpemeric_blog`.`post` |