@@ -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` |
@@ -39,20 +39,20 @@ discard block |
||
| 39 | 39 | public function perform() |
| 40 | 40 | { |
| 41 | 41 | $weighted_array = array(); |
| 42 | - foreach($this->result as $row) |
|
| 42 | + foreach ($this->result as $row) |
|
| 43 | 43 | { |
| 44 | 44 | $weight = $this->get_search_weight($row); |
| 45 | - if($weight > 0) |
|
| 45 | + if ($weight > 0) |
|
| 46 | 46 | $weighted_array[$row['id']] = $weight; |
| 47 | 47 | } |
| 48 | 48 | arsort($weighted_array); |
| 49 | 49 | |
| 50 | 50 | $final_array = array(); |
| 51 | - foreach($weighted_array as $id => $weight) |
|
| 51 | + foreach ($weighted_array as $id => $weight) |
|
| 52 | 52 | { |
| 53 | - foreach($this->result as $row) |
|
| 53 | + foreach ($this->result as $row) |
|
| 54 | 54 | { |
| 55 | - if($row['id'] == $id) |
|
| 55 | + if ($row['id'] == $id) |
|
| 56 | 56 | $final_array[] = $row; |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | private function get_search_weight($row) |
| 63 | 63 | { |
| 64 | 64 | $weight = 0; |
| 65 | - foreach($this->weight as $weight_array) |
|
| 65 | + foreach ($this->weight as $weight_array) |
|
| 66 | 66 | { |
| 67 | 67 | $text = $row[$weight_array['field']]; |
| 68 | 68 | $weight += $weight_array['weight'] * substr_count(strtolower($text), strtolower($this->query)); |
@@ -3,71 +3,71 @@ |
||
| 3 | 3 | final class Search |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - private $query; |
|
| 7 | - private $result; |
|
| 8 | - private $weight; |
|
| 6 | + private $query; |
|
| 7 | + private $result; |
|
| 8 | + private $weight; |
|
| 9 | 9 | |
| 10 | - function __construct() |
|
| 11 | - { |
|
| 12 | - return $this; |
|
| 13 | - } |
|
| 10 | + function __construct() |
|
| 11 | + { |
|
| 12 | + return $this; |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - public function setQuery($query) |
|
| 16 | - { |
|
| 17 | - $this->query = $query; |
|
| 18 | - return $this; |
|
| 19 | - } |
|
| 15 | + public function setQuery($query) |
|
| 16 | + { |
|
| 17 | + $this->query = $query; |
|
| 18 | + return $this; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function setResult($array) |
|
| 22 | - { |
|
| 23 | - $this->result = $array; |
|
| 24 | - return $this; |
|
| 25 | - } |
|
| 21 | + public function setResult($array) |
|
| 22 | + { |
|
| 23 | + $this->result = $array; |
|
| 24 | + return $this; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - public function setWeight($weight) |
|
| 28 | - { |
|
| 29 | - $this->weight = $weight; |
|
| 30 | - return $this; |
|
| 31 | - } |
|
| 27 | + public function setWeight($weight) |
|
| 28 | + { |
|
| 29 | + $this->weight = $weight; |
|
| 30 | + return $this; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public static function instance() |
|
| 34 | - { |
|
| 35 | - $reflection = new ReflectionClass('Search'); |
|
| 36 | - return $reflection->newInstance(); |
|
| 37 | - } |
|
| 33 | + public static function instance() |
|
| 34 | + { |
|
| 35 | + $reflection = new ReflectionClass('Search'); |
|
| 36 | + return $reflection->newInstance(); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public function perform() |
|
| 40 | - { |
|
| 41 | - $weighted_array = array(); |
|
| 42 | - foreach($this->result as $row) |
|
| 43 | - { |
|
| 44 | - $weight = $this->get_search_weight($row); |
|
| 45 | - if($weight > 0) |
|
| 46 | - $weighted_array[$row['id']] = $weight; |
|
| 47 | - } |
|
| 48 | - arsort($weighted_array); |
|
| 39 | + public function perform() |
|
| 40 | + { |
|
| 41 | + $weighted_array = array(); |
|
| 42 | + foreach($this->result as $row) |
|
| 43 | + { |
|
| 44 | + $weight = $this->get_search_weight($row); |
|
| 45 | + if($weight > 0) |
|
| 46 | + $weighted_array[$row['id']] = $weight; |
|
| 47 | + } |
|
| 48 | + arsort($weighted_array); |
|
| 49 | 49 | |
| 50 | - $final_array = array(); |
|
| 51 | - foreach($weighted_array as $id => $weight) |
|
| 52 | - { |
|
| 53 | - foreach($this->result as $row) |
|
| 54 | - { |
|
| 55 | - if($row['id'] == $id) |
|
| 56 | - $final_array[] = $row; |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - return $final_array; |
|
| 60 | - } |
|
| 50 | + $final_array = array(); |
|
| 51 | + foreach($weighted_array as $id => $weight) |
|
| 52 | + { |
|
| 53 | + foreach($this->result as $row) |
|
| 54 | + { |
|
| 55 | + if($row['id'] == $id) |
|
| 56 | + $final_array[] = $row; |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + return $final_array; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - private function get_search_weight($row) |
|
| 63 | - { |
|
| 64 | - $weight = 0; |
|
| 65 | - foreach($this->weight as $weight_array) |
|
| 66 | - { |
|
| 67 | - $text = $row[$weight_array['field']]; |
|
| 68 | - $weight += $weight_array['weight'] * substr_count(strtolower($text), strtolower($this->query)); |
|
| 69 | - } |
|
| 70 | - return $weight; |
|
| 71 | - } |
|
| 62 | + private function get_search_weight($row) |
|
| 63 | + { |
|
| 64 | + $weight = 0; |
|
| 65 | + foreach($this->weight as $weight_array) |
|
| 66 | + { |
|
| 67 | + $text = $row[$weight_array['field']]; |
|
| 68 | + $weight += $weight_array['weight'] * substr_count(strtolower($text), strtolower($this->query)); |
|
| 69 | + } |
|
| 70 | + return $weight; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | } |
@@ -1,49 +1,50 @@ discard block |
||
| 1 | 1 | <? |
| 2 | 2 | |
| 3 | -final class Search |
|
| 4 | -{ |
|
| 3 | +final class Search |
|
| 4 | +{
|
|
| 5 | 5 | |
| 6 | 6 | private $query; |
| 7 | 7 | private $result; |
| 8 | 8 | private $weight; |
| 9 | 9 | |
| 10 | - function __construct() |
|
| 11 | - { |
|
| 10 | + function __construct() |
|
| 11 | + {
|
|
| 12 | 12 | return $this; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - public function setQuery($query) |
|
| 16 | - { |
|
| 15 | + public function setQuery($query) |
|
| 16 | + {
|
|
| 17 | 17 | $this->query = $query; |
| 18 | 18 | return $this; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function setResult($array) |
|
| 22 | - { |
|
| 21 | + public function setResult($array) |
|
| 22 | + {
|
|
| 23 | 23 | $this->result = $array; |
| 24 | 24 | return $this; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function setWeight($weight) |
|
| 28 | - { |
|
| 27 | + public function setWeight($weight) |
|
| 28 | + {
|
|
| 29 | 29 | $this->weight = $weight; |
| 30 | 30 | return $this; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public static function instance() |
|
| 34 | - { |
|
| 33 | + public static function instance() |
|
| 34 | + {
|
|
| 35 | 35 | $reflection = new ReflectionClass('Search'); |
| 36 | 36 | return $reflection->newInstance(); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function perform() |
|
| 40 | - { |
|
| 39 | + public function perform() |
|
| 40 | + {
|
|
| 41 | 41 | $weighted_array = array(); |
| 42 | 42 | foreach($this->result as $row) |
| 43 | 43 | { |
| 44 | 44 | $weight = $this->get_search_weight($row); |
| 45 | - if($weight > 0) |
|
| 46 | - $weighted_array[$row['id']] = $weight; |
|
| 45 | + if($weight > 0) {
|
|
| 46 | + $weighted_array[$row['id']] = $weight; |
|
| 47 | + } |
|
| 47 | 48 | } |
| 48 | 49 | arsort($weighted_array); |
| 49 | 50 | |
@@ -52,15 +53,16 @@ discard block |
||
| 52 | 53 | { |
| 53 | 54 | foreach($this->result as $row) |
| 54 | 55 | { |
| 55 | - if($row['id'] == $id) |
|
| 56 | - $final_array[] = $row; |
|
| 56 | + if($row['id'] == $id) {
|
|
| 57 | + $final_array[] = $row; |
|
| 58 | + } |
|
| 57 | 59 | } |
| 58 | 60 | } |
| 59 | 61 | return $final_array; |
| 60 | 62 | } |
| 61 | 63 | |
| 62 | - private function get_search_weight($row) |
|
| 63 | - { |
|
| 64 | + private function get_search_weight($row) |
|
| 65 | + {
|
|
| 64 | 66 | $weight = 0; |
| 65 | 67 | foreach($this->weight as $weight_array) |
| 66 | 68 | { |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | ], |
| 27 | 27 | ]; |
| 28 | 28 | |
| 29 | - return array_map(function ($row) { |
|
| 29 | + return array_map(function($row) { |
|
| 30 | 30 | return (object) $row; |
| 31 | 31 | }, $paths); |
| 32 | 32 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | ], |
| 49 | 49 | ]; |
| 50 | 50 | |
| 51 | - return array_map(function ($row) { |
|
| 51 | + return array_map(function($row) { |
|
| 52 | 52 | return (object) $row; |
| 53 | 53 | }, $paths); |
| 54 | 54 | } |
@@ -2,11 +2,11 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('router', 'Router'); |
| 4 | 4 | |
| 5 | -class PortfolioRouter extends Router |
|
| 6 | -{ |
|
| 5 | +class PortfolioRouter extends Router |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | - protected function get_redirect_array() |
|
| 9 | - { |
|
| 8 | + protected function get_redirect_array() |
|
| 9 | + {
|
|
| 10 | 10 | $paths = [ |
| 11 | 11 | [ |
| 12 | 12 | 'pattern' => '@/index.(html|htm|php)$@', |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | }, $paths); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - protected function get_direct_array() |
|
| 35 | - { |
|
| 34 | + protected function get_direct_array() |
|
| 35 | + {
|
|
| 36 | 36 | $paths = [ |
| 37 | 37 | [ |
| 38 | 38 | 'match' => '/', |
@@ -18,10 +18,10 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | private static function get_router_name() |
| 20 | 20 | { |
| 21 | - if(Request::isAJAX()) |
|
| 21 | + if (Request::isAJAX()) |
|
| 22 | 22 | return 'AJAXRouter'; |
| 23 | 23 | |
| 24 | - switch(URLDecode::getSite()) |
|
| 24 | + switch (URLDecode::getSite()) |
|
| 25 | 25 | { |
| 26 | 26 | case 'ajax' : |
| 27 | 27 | return 'AjaxRouter'; |
@@ -65,42 +65,42 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | final protected function check_for_redirect($redirect_uri) |
| 67 | 67 | { |
| 68 | - foreach($this->get_redirect_array() as $check) |
|
| 68 | + foreach ($this->get_redirect_array() as $check) |
|
| 69 | 69 | { |
| 70 | 70 | $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $redirect_uri = $this->check_for_special_redirect($redirect_uri); |
| 74 | 74 | |
| 75 | - if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
| 75 | + if ($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
| 76 | 76 | $redirect_uri .= '/'; |
| 77 | 77 | |
| 78 | 78 | if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') { |
| 79 | 79 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
| 80 | - $redirect_uri = $protocol . '://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri; |
|
| 80 | + $redirect_uri = $protocol.'://'.(!Loader::isLive() ? 'dev' : 'www').'.waterfallsofthekeweenaw.com'.$redirect_uri; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if($redirect_uri == URLDecode::getURI()) |
|
| 83 | + if ($redirect_uri == URLDecode::getURI()) |
|
| 84 | 84 | return; |
| 85 | 85 | |
| 86 | 86 | $controller_check = $redirect_uri; |
| 87 | - if(substr($redirect_uri, 0, 4) == 'http') { |
|
| 87 | + if (substr($redirect_uri, 0, 4) == 'http') { |
|
| 88 | 88 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
| 89 | - $controller_check = preg_replace('@^' . $protocol . '://([a-z\.]+)@', '', $redirect_uri); |
|
| 89 | + $controller_check = preg_replace('@^'.$protocol.'://([a-z\.]+)@', '', $redirect_uri); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $controller = $this->get_controller($controller_check); |
| 93 | - if($controller == '/Error404Controller') |
|
| 93 | + if ($controller == '/Error404Controller') |
|
| 94 | 94 | { |
| 95 | 95 | Loader::loadNew('controller', '/Error404Controller') |
| 96 | 96 | ->activate(); |
| 97 | 97 | exit; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if(substr($redirect_uri, 0, 4) != 'http') |
|
| 100 | + if (substr($redirect_uri, 0, 4) != 'http') |
|
| 101 | 101 | { |
| 102 | 102 | $redirect_uri = substr($redirect_uri, 1); |
| 103 | - $redirect_uri = URLDecode::getBase() . $redirect_uri; |
|
| 103 | + $redirect_uri = URLDecode::getBase().$redirect_uri; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | Loader::loadNew('controller', '/Error301Controller', (array) $redirect_uri) |
@@ -114,12 +114,12 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | final private function get_controller($uri) |
| 116 | 116 | { |
| 117 | - foreach($this->get_direct_array() as $check) |
|
| 117 | + foreach ($this->get_direct_array() as $check) |
|
| 118 | 118 | { |
| 119 | - if($uri == $check->match) |
|
| 119 | + if ($uri == $check->match) |
|
| 120 | 120 | return "{$this->get_primary_folder()}/{$check->controller}"; |
| 121 | 121 | |
| 122 | - if(preg_match("@^{$check->match}$@", $uri)) |
|
| 122 | + if (preg_match("@^{$check->match}$@", $uri)) |
|
| 123 | 123 | return "{$this->get_primary_folder()}/{$check->controller}"; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | final private function get_primary_folder() |
| 130 | 130 | { |
| 131 | - if(Request::isAjax()) |
|
| 131 | + if (Request::isAjax()) |
|
| 132 | 132 | return 'ajax'; |
| 133 | 133 | |
| 134 | 134 | return URLDecode::getSite(); |
@@ -1,144 +1,144 @@ |
||
| 1 | 1 | <? |
| 2 | 2 | |
| 3 | 3 | Loader::load('utility', array( |
| 4 | - 'Request', |
|
| 5 | - 'URLDecode')); |
|
| 4 | + 'Request', |
|
| 5 | + 'URLDecode')); |
|
| 6 | 6 | |
| 7 | 7 | abstract class Router |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - public function __construct() {} |
|
| 10 | + public function __construct() {} |
|
| 11 | 11 | |
| 12 | - public static function instance() |
|
| 13 | - { |
|
| 14 | - $router_name = self::get_router_name(); |
|
| 15 | - $router = Loader::loadNew('router', $router_name); |
|
| 16 | - $router->route(); |
|
| 17 | - } |
|
| 12 | + public static function instance() |
|
| 13 | + { |
|
| 14 | + $router_name = self::get_router_name(); |
|
| 15 | + $router = Loader::loadNew('router', $router_name); |
|
| 16 | + $router->route(); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - private static function get_router_name() |
|
| 20 | - { |
|
| 21 | - if(Request::isAJAX()) |
|
| 22 | - return 'AJAXRouter'; |
|
| 19 | + private static function get_router_name() |
|
| 20 | + { |
|
| 21 | + if(Request::isAJAX()) |
|
| 22 | + return 'AJAXRouter'; |
|
| 23 | 23 | |
| 24 | - switch(URLDecode::getSite()) |
|
| 25 | - { |
|
| 26 | - case 'ajax' : |
|
| 27 | - return 'AjaxRouter'; |
|
| 28 | - break; |
|
| 29 | - case 'blog' : |
|
| 30 | - return 'BlogRouter'; |
|
| 31 | - break; |
|
| 32 | - case 'home' : |
|
| 33 | - return 'HomeRouter'; |
|
| 34 | - break; |
|
| 35 | - case 'lifestream' : |
|
| 36 | - return 'LifestreamRouter'; |
|
| 37 | - break; |
|
| 38 | - case 'portfolio' : |
|
| 39 | - return 'PortfolioRouter'; |
|
| 40 | - break; |
|
| 41 | - case 'site' : |
|
| 42 | - return 'SiteRouter'; |
|
| 43 | - break; |
|
| 44 | - case 'waterfalls' : |
|
| 45 | - return 'WaterfallRouter'; |
|
| 46 | - break; |
|
| 47 | - } |
|
| 24 | + switch(URLDecode::getSite()) |
|
| 25 | + { |
|
| 26 | + case 'ajax' : |
|
| 27 | + return 'AjaxRouter'; |
|
| 28 | + break; |
|
| 29 | + case 'blog' : |
|
| 30 | + return 'BlogRouter'; |
|
| 31 | + break; |
|
| 32 | + case 'home' : |
|
| 33 | + return 'HomeRouter'; |
|
| 34 | + break; |
|
| 35 | + case 'lifestream' : |
|
| 36 | + return 'LifestreamRouter'; |
|
| 37 | + break; |
|
| 38 | + case 'portfolio' : |
|
| 39 | + return 'PortfolioRouter'; |
|
| 40 | + break; |
|
| 41 | + case 'site' : |
|
| 42 | + return 'SiteRouter'; |
|
| 43 | + break; |
|
| 44 | + case 'waterfalls' : |
|
| 45 | + return 'WaterfallRouter'; |
|
| 46 | + break; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 50 | - } |
|
| 49 | + Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - protected function route() |
|
| 53 | - { |
|
| 54 | - $uri = URLDecode::getURI(); |
|
| 52 | + protected function route() |
|
| 53 | + { |
|
| 54 | + $uri = URLDecode::getURI(); |
|
| 55 | 55 | |
| 56 | - $this->check_for_redirect($uri); |
|
| 56 | + $this->check_for_redirect($uri); |
|
| 57 | 57 | |
| 58 | - $controller = $this->get_controller($uri); |
|
| 59 | - Loader::loadNew('controller', $controller) |
|
| 60 | - ->activate(); |
|
| 61 | - } |
|
| 58 | + $controller = $this->get_controller($uri); |
|
| 59 | + Loader::loadNew('controller', $controller) |
|
| 60 | + ->activate(); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - abstract protected function get_redirect_array(); |
|
| 64 | - abstract protected function get_direct_array(); |
|
| 63 | + abstract protected function get_redirect_array(); |
|
| 64 | + abstract protected function get_direct_array(); |
|
| 65 | 65 | |
| 66 | - final protected function check_for_redirect($redirect_uri) |
|
| 67 | - { |
|
| 68 | - foreach($this->get_redirect_array() as $check) |
|
| 69 | - { |
|
| 70 | - $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); |
|
| 71 | - } |
|
| 66 | + final protected function check_for_redirect($redirect_uri) |
|
| 67 | + { |
|
| 68 | + foreach($this->get_redirect_array() as $check) |
|
| 69 | + { |
|
| 70 | + $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - $redirect_uri = $this->check_for_special_redirect($redirect_uri); |
|
| 73 | + $redirect_uri = $this->check_for_special_redirect($redirect_uri); |
|
| 74 | 74 | |
| 75 | - if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
| 76 | - $redirect_uri .= '/'; |
|
| 75 | + if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
| 76 | + $redirect_uri .= '/'; |
|
| 77 | 77 | |
| 78 | 78 | if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') { |
| 79 | 79 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
| 80 | 80 | $redirect_uri = $protocol . '://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if($redirect_uri == URLDecode::getURI()) |
|
| 84 | - return; |
|
| 83 | + if($redirect_uri == URLDecode::getURI()) |
|
| 84 | + return; |
|
| 85 | 85 | |
| 86 | - $controller_check = $redirect_uri; |
|
| 87 | - if(substr($redirect_uri, 0, 4) == 'http') { |
|
| 88 | - $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
|
| 89 | - $controller_check = preg_replace('@^' . $protocol . '://([a-z\.]+)@', '', $redirect_uri); |
|
| 86 | + $controller_check = $redirect_uri; |
|
| 87 | + if(substr($redirect_uri, 0, 4) == 'http') { |
|
| 88 | + $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
|
| 89 | + $controller_check = preg_replace('@^' . $protocol . '://([a-z\.]+)@', '', $redirect_uri); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - $controller = $this->get_controller($controller_check); |
|
| 93 | - if($controller == '/Error404Controller') |
|
| 94 | - { |
|
| 95 | - Loader::loadNew('controller', '/Error404Controller') |
|
| 96 | - ->activate(); |
|
| 97 | - exit; |
|
| 98 | - } |
|
| 92 | + $controller = $this->get_controller($controller_check); |
|
| 93 | + if($controller == '/Error404Controller') |
|
| 94 | + { |
|
| 95 | + Loader::loadNew('controller', '/Error404Controller') |
|
| 96 | + ->activate(); |
|
| 97 | + exit; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - if(substr($redirect_uri, 0, 4) != 'http') |
|
| 101 | - { |
|
| 102 | - $redirect_uri = substr($redirect_uri, 1); |
|
| 103 | - $redirect_uri = URLDecode::getBase() . $redirect_uri; |
|
| 104 | - } |
|
| 100 | + if(substr($redirect_uri, 0, 4) != 'http') |
|
| 101 | + { |
|
| 102 | + $redirect_uri = substr($redirect_uri, 1); |
|
| 103 | + $redirect_uri = URLDecode::getBase() . $redirect_uri; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - Loader::loadNew('controller', '/Error301Controller', (array) $redirect_uri) |
|
| 107 | - ->activate(); |
|
| 108 | - } |
|
| 106 | + Loader::loadNew('controller', '/Error301Controller', (array) $redirect_uri) |
|
| 107 | + ->activate(); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - protected function check_for_special_redirect($uri) |
|
| 111 | - { |
|
| 112 | - return $uri; |
|
| 113 | - } |
|
| 110 | + protected function check_for_special_redirect($uri) |
|
| 111 | + { |
|
| 112 | + return $uri; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - final private function get_controller($uri) |
|
| 116 | - { |
|
| 117 | - foreach($this->get_direct_array() as $check) |
|
| 118 | - { |
|
| 119 | - if($uri == $check->match) |
|
| 120 | - return "{$this->get_primary_folder()}/{$check->controller}"; |
|
| 115 | + final private function get_controller($uri) |
|
| 116 | + { |
|
| 117 | + foreach($this->get_direct_array() as $check) |
|
| 118 | + { |
|
| 119 | + if($uri == $check->match) |
|
| 120 | + return "{$this->get_primary_folder()}/{$check->controller}"; |
|
| 121 | 121 | |
| 122 | - if(preg_match("@^{$check->match}$@", $uri)) |
|
| 123 | - return "{$this->get_primary_folder()}/{$check->controller}"; |
|
| 124 | - } |
|
| 122 | + if(preg_match("@^{$check->match}$@", $uri)) |
|
| 123 | + return "{$this->get_primary_folder()}/{$check->controller}"; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - return '/Error404Controller'; |
|
| 127 | - } |
|
| 126 | + return '/Error404Controller'; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - final private function get_primary_folder() |
|
| 130 | - { |
|
| 131 | - if(Request::isAjax()) |
|
| 132 | - return 'ajax'; |
|
| 129 | + final private function get_primary_folder() |
|
| 130 | + { |
|
| 131 | + if(Request::isAjax()) |
|
| 132 | + return 'ajax'; |
|
| 133 | 133 | |
| 134 | - return URLDecode::getSite(); |
|
| 135 | - } |
|
| 134 | + return URLDecode::getSite(); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - private function requires_trailing_slash() |
|
| 138 | - { |
|
| 139 | - return ( |
|
| 140 | - URLDecode::getExtension() != 'json' && |
|
| 137 | + private function requires_trailing_slash() |
|
| 138 | + { |
|
| 139 | + return ( |
|
| 140 | + URLDecode::getExtension() != 'json' && |
|
| 141 | 141 | strstr(URLDecode::getURI(), '#') === false); |
| 142 | - } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | } |
@@ -4,22 +4,25 @@ discard block |
||
| 4 | 4 | 'Request', |
| 5 | 5 | 'URLDecode')); |
| 6 | 6 | |
| 7 | -abstract class Router |
|
| 8 | -{ |
|
| 7 | +abstract class Router |
|
| 8 | +{
|
|
| 9 | 9 | |
| 10 | - public function __construct() {} |
|
| 10 | + public function __construct() |
|
| 11 | + {
|
|
| 12 | +} |
|
| 11 | 13 | |
| 12 | - public static function instance() |
|
| 13 | - { |
|
| 14 | + public static function instance() |
|
| 15 | + {
|
|
| 14 | 16 | $router_name = self::get_router_name(); |
| 15 | 17 | $router = Loader::loadNew('router', $router_name); |
| 16 | 18 | $router->route(); |
| 17 | 19 | } |
| 18 | 20 | |
| 19 | - private static function get_router_name() |
|
| 20 | - { |
|
| 21 | - if(Request::isAJAX()) |
|
| 22 | - return 'AJAXRouter'; |
|
| 21 | + private static function get_router_name() |
|
| 22 | + {
|
|
| 23 | + if(Request::isAJAX()) {
|
|
| 24 | + return 'AJAXRouter'; |
|
| 25 | + } |
|
| 23 | 26 | |
| 24 | 27 | switch(URLDecode::getSite()) |
| 25 | 28 | { |
@@ -49,8 +52,8 @@ discard block |
||
| 49 | 52 | Loader::loadNew('controller', '/Error404Controller')->activate(); |
| 50 | 53 | } |
| 51 | 54 | |
| 52 | - protected function route() |
|
| 53 | - { |
|
| 55 | + protected function route() |
|
| 56 | + {
|
|
| 54 | 57 | $uri = URLDecode::getURI(); |
| 55 | 58 | |
| 56 | 59 | $this->check_for_redirect($uri); |
@@ -63,8 +66,8 @@ discard block |
||
| 63 | 66 | abstract protected function get_redirect_array(); |
| 64 | 67 | abstract protected function get_direct_array(); |
| 65 | 68 | |
| 66 | - final protected function check_for_redirect($redirect_uri) |
|
| 67 | - { |
|
| 69 | + final protected function check_for_redirect($redirect_uri) |
|
| 70 | + {
|
|
| 68 | 71 | foreach($this->get_redirect_array() as $check) |
| 69 | 72 | { |
| 70 | 73 | $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); |
@@ -72,16 +75,18 @@ discard block |
||
| 72 | 75 | |
| 73 | 76 | $redirect_uri = $this->check_for_special_redirect($redirect_uri); |
| 74 | 77 | |
| 75 | - if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
| 76 | - $redirect_uri .= '/'; |
|
| 78 | + if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') {
|
|
| 79 | + $redirect_uri .= '/'; |
|
| 80 | + } |
|
| 77 | 81 | |
| 78 | 82 | if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') { |
| 79 | 83 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
| 80 | 84 | $redirect_uri = $protocol . '://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri; |
| 81 | 85 | } |
| 82 | 86 | |
| 83 | - if($redirect_uri == URLDecode::getURI()) |
|
| 84 | - return; |
|
| 87 | + if($redirect_uri == URLDecode::getURI()) {
|
|
| 88 | + return; |
|
| 89 | + } |
|
| 85 | 90 | |
| 86 | 91 | $controller_check = $redirect_uri; |
| 87 | 92 | if(substr($redirect_uri, 0, 4) == 'http') { |
@@ -107,35 +112,38 @@ discard block |
||
| 107 | 112 | ->activate(); |
| 108 | 113 | } |
| 109 | 114 | |
| 110 | - protected function check_for_special_redirect($uri) |
|
| 111 | - { |
|
| 115 | + protected function check_for_special_redirect($uri) |
|
| 116 | + {
|
|
| 112 | 117 | return $uri; |
| 113 | 118 | } |
| 114 | 119 | |
| 115 | - final private function get_controller($uri) |
|
| 116 | - { |
|
| 120 | + final private function get_controller($uri) |
|
| 121 | + {
|
|
| 117 | 122 | foreach($this->get_direct_array() as $check) |
| 118 | 123 | { |
| 119 | - if($uri == $check->match) |
|
| 120 | - return "{$this->get_primary_folder()}/{$check->controller}"; |
|
| 124 | + if($uri == $check->match) {
|
|
| 125 | + return "{$this->get_primary_folder()}/{$check->controller}";
|
|
| 126 | + } |
|
| 121 | 127 | |
| 122 | - if(preg_match("@^{$check->match}$@", $uri)) |
|
| 123 | - return "{$this->get_primary_folder()}/{$check->controller}"; |
|
| 128 | + if(preg_match("@^{$check->match}$@", $uri)) {
|
|
| 129 | + return "{$this->get_primary_folder()}/{$check->controller}";
|
|
| 130 | + } |
|
| 124 | 131 | } |
| 125 | 132 | |
| 126 | 133 | return '/Error404Controller'; |
| 127 | 134 | } |
| 128 | 135 | |
| 129 | - final private function get_primary_folder() |
|
| 130 | - { |
|
| 131 | - if(Request::isAjax()) |
|
| 132 | - return 'ajax'; |
|
| 136 | + final private function get_primary_folder() |
|
| 137 | + {
|
|
| 138 | + if(Request::isAjax()) {
|
|
| 139 | + return 'ajax'; |
|
| 140 | + } |
|
| 133 | 141 | |
| 134 | 142 | return URLDecode::getSite(); |
| 135 | 143 | } |
| 136 | 144 | |
| 137 | - private function requires_trailing_slash() |
|
| 138 | - { |
|
| 145 | + private function requires_trailing_slash() |
|
| 146 | + {
|
|
| 139 | 147 | return ( |
| 140 | 148 | URLDecode::getExtension() != 'json' && |
| 141 | 149 | strstr(URLDecode::getURI(), '#') === false); |