@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | interface DisplayController extends BaseController |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /* |
|
| 8 | + /* |
|
| 9 | 9 | The viewport is an associative array of values to be exported as variables in the view |
| 10 | 10 | the assoc keys will be the variable names |
| 11 | 11 | |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | returns null |
| 43 | 43 | */ |
| 44 | 44 | |
| 45 | - public function viewport($key=null, $value=null, $coercion=false); |
|
| 45 | + public function viewport($key=null, $value=null, $coercion=false); |
|
| 46 | 46 | |
| 47 | - public function display($custom_template = null, $standalone=false); |
|
| 47 | + public function display($custom_template = null, $standalone=false); |
|
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | { |
| 8 | 8 | protected static function prepare_pagination($records_total) |
| 9 | 9 | { |
| 10 | - global $settings; |
|
| 11 | - global $smarty; |
|
| 10 | + global $settings; |
|
| 11 | + global $smarty; |
|
| 12 | 12 | |
| 13 | 13 | $pages_max_on_each_side = 3; |
| 14 | 14 | $pages_max_displayed = $pages_max_on_each_side*2+1; |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | if($pages_last > $pages_total) // $pages_max_displayed greater than the total of pages |
| 36 | 36 | $pages_last = $pages_total; |
| 37 | 37 | |
| 38 | - $this->viewport("pages_total", $pages_total); |
|
| 39 | - $this->viewport("pages_first", $pages_first); |
|
| 38 | + $this->viewport("pages_total", $pages_total); |
|
| 39 | + $this->viewport("pages_first", $pages_first); |
|
| 40 | 40 | $this->viewport("pages_previous", $pages_current <= 1 ? $pages_total : $pages_current - 1); |
| 41 | - $this->viewport("pages_current", $pages_current); |
|
| 42 | - $this->viewport("pages_next", $pages_current >= $pages_total ? 1 : $pages_current + 1); |
|
| 43 | - $this->viewport("pages_last", $pages_last); |
|
| 41 | + $this->viewport("pages_current", $pages_current); |
|
| 42 | + $this->viewport("pages_next", $pages_current >= $pages_total ? 1 : $pages_current + 1); |
|
| 43 | + $this->viewport("pages_last", $pages_last); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | } |
@@ -107,18 +107,18 @@ discard block |
||
| 107 | 107 | $custom_template = null; |
| 108 | 108 | |
| 109 | 109 | if(method_exists($this, 'prepare')) |
| 110 | - $this->prepare(); |
|
| 110 | + $this->prepare(); |
|
| 111 | 111 | |
| 112 | - if(method_exists($this, $method = $this->router()->target_method())) |
|
| 112 | + if(method_exists($this, $method = $this->router()->target_method())) |
|
| 113 | 113 | { |
| 114 | 114 | $custom_template = $this->$method(); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | if(method_exists($this, 'conclude')) |
| 118 | - $this->conclude(); |
|
| 118 | + $this->conclude(); |
|
| 119 | 119 | |
| 120 | 120 | if(method_exists($this, 'display')) |
| 121 | - $template = $this->display($custom_template); |
|
| 121 | + $template = $this->display($custom_template); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | public function conclude(){} |
@@ -143,16 +143,16 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | $template = $this->find_template($smarty, $custom_template); // throws Exception if nothing found |
| 145 | 145 | |
| 146 | - $this->viewport('controller', $this); |
|
| 146 | + $this->viewport('controller', $this); |
|
| 147 | 147 | |
| 148 | 148 | $this->viewport('user_messages', $this->logger()->get_user_report()); |
| 149 | 149 | |
| 150 | 150 | |
| 151 | - $this->viewport('file_root', $this->router()->file_root()); |
|
| 152 | - $this->viewport('view_path', $this->router()->file_root() . $this->box('settings.smarty.template_path').'app/'); |
|
| 153 | - $this->viewport('web_root', $this->router()->web_root()); |
|
| 154 | - $this->viewport('view_url', $this->router()->web_root() . $this->box('settings.smarty.template_path')); |
|
| 155 | - $this->viewport('images_url', $this->router()->web_root() . $this->box('settings.smarty.template_path') . 'images/'); |
|
| 151 | + $this->viewport('file_root', $this->router()->file_root()); |
|
| 152 | + $this->viewport('view_path', $this->router()->file_root() . $this->box('settings.smarty.template_path').'app/'); |
|
| 153 | + $this->viewport('web_root', $this->router()->web_root()); |
|
| 154 | + $this->viewport('view_url', $this->router()->web_root() . $this->box('settings.smarty.template_path')); |
|
| 155 | + $this->viewport('images_url', $this->router()->web_root() . $this->box('settings.smarty.template_path') . 'images/'); |
|
| 156 | 156 | |
| 157 | 157 | foreach($this->viewport() as $template_var_name => $value) |
| 158 | 158 | $smarty->assign($template_var_name, $value); |
@@ -227,12 +227,12 @@ discard block |
||
| 227 | 227 | * |
| 228 | 228 | */ |
| 229 | 229 | public function route_back($route_name=null, $route_params=[]) : string |
| 230 | - { |
|
| 230 | + { |
|
| 231 | 231 | if(is_null($route_name)) |
| 232 | - return $this->route_back ?? $this->router()->prehop(RouterInterface::ROUTE_HOME_NAME); |
|
| 232 | + return $this->route_back ?? $this->router()->prehop(RouterInterface::ROUTE_HOME_NAME); |
|
| 233 | 233 | |
| 234 | 234 | return $this->route_back = $this->route_factory($route_name, $route_params); |
| 235 | - } |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | 237 | public function route_factory($route_name=null, $route_params=[]) : string |
| 238 | 238 | { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | foreach(['prepare', "before_$method", $method, "after_$method"] as $step => $chainling) |
| 31 | 31 | { |
| 32 | 32 | $this->search_and_execute_trait_methods($chainling); |
| 33 | - if(method_exists($this, $chainling) && empty($this->errors())) |
|
| 33 | + if(method_exists($this, $chainling) && empty($this->errors())) |
|
| 34 | 34 | { |
| 35 | 35 | $res = $this->$chainling(); |
| 36 | 36 | |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | if(method_exists($this, 'conclude')) // conclude always executed, even with has_halting_messages |
| 51 | - $this->conclude(); |
|
| 51 | + $this->conclude(); |
|
| 52 | 52 | |
| 53 | 53 | if(method_exists($this, 'display')) |
| 54 | - $template = $this->display($custom_template); |
|
| 54 | + $template = $this->display($custom_template); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function prepare() |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | $picture_directory = $this->build_path_to_directory(); |
| 17 | 17 | $thumbnail_directory = $picture_directory; |
| 18 | 18 | |
| 19 | - if(!file_exists($picture_directory) && mkdir($picture_directory) === false) |
|
| 20 | - return []; |
|
| 19 | + if(!file_exists($picture_directory) && mkdir($picture_directory) === false) |
|
| 20 | + return []; |
|
| 21 | 21 | |
| 22 | 22 | $filenames = self::preg_scandir($picture_directory, '/^[0-9]+_[0-9]+\.[a-zA-Z]+/');// ID_SEQUENCENUMBER.ext |
| 23 | 23 | |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | $filepath = $this->build_filename() . '.' . self::file_ext($_FILES[$this->get_type()]['name']); |
| 76 | 76 | $filepath = $this->locate_file($filepath); |
| 77 | 77 | |
| 78 | - if(file_exists($filepath)) |
|
| 78 | + if(file_exists($filepath)) |
|
| 79 | 79 | throw new \Exception($this->get_type()." new path '$filepath' already exists"); |
| 80 | 80 | |
| 81 | - if(copy($_FILES[$this->get_type()]['tmp_name'], $filepath) === false) |
|
| 82 | - throw new \Exception(" cant copy ".$_FILES[$this->get_type()]['name']." to ($filepath)"); |
|
| 81 | + if(copy($_FILES[$this->get_type()]['tmp_name'], $filepath) === false) |
|
| 82 | + throw new \Exception(" cant copy ".$_FILES[$this->get_type()]['name']." to ($filepath)"); |
|
| 83 | 83 | |
| 84 | 84 | $this->make_thumbnail($filepath); |
| 85 | 85 | } |
@@ -95,64 +95,64 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function make_thumbnail($filepath) |
| 98 | - { |
|
| 98 | + { |
|
| 99 | 99 | global $settings; |
| 100 | 100 | |
| 101 | - $cover_iri = null; |
|
| 102 | - |
|
| 103 | - $mime_type = mime_content_type($filepath); |
|
| 104 | - switch($mime_type) |
|
| 105 | - { |
|
| 106 | - case 'image/jpeg': |
|
| 107 | - case 'image/pjpeg': |
|
| 108 | - $cover_iri = imagecreatefromjpeg($filepath); |
|
| 109 | - break; |
|
| 101 | + $cover_iri = null; |
|
| 110 | 102 | |
| 111 | - case 'image/png': |
|
| 112 | - $cover_iri = imagecreatefrompng($filepath); |
|
| 113 | - break; |
|
| 114 | - |
|
| 115 | - case 'image/gif': |
|
| 116 | - $cover_iri = imagecreatefromgif($filepath); |
|
| 117 | - break; |
|
| 118 | - } |
|
| 103 | + $mime_type = mime_content_type($filepath); |
|
| 104 | + switch($mime_type) |
|
| 105 | + { |
|
| 106 | + case 'image/jpeg': |
|
| 107 | + case 'image/pjpeg': |
|
| 108 | + $cover_iri = imagecreatefromjpeg($filepath); |
|
| 109 | + break; |
|
| 110 | + |
|
| 111 | + case 'image/png': |
|
| 112 | + $cover_iri = imagecreatefrompng($filepath); |
|
| 113 | + break; |
|
| 114 | + |
|
| 115 | + case 'image/gif': |
|
| 116 | + $cover_iri = imagecreatefromgif($filepath); |
|
| 117 | + break; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - if(!is_null($cover_iri)) |
|
| 121 | - { |
|
| 122 | - $width = imagesx( $cover_iri ); |
|
| 123 | - $height = imagesy( $cover_iri ); |
|
| 120 | + if(!is_null($cover_iri)) |
|
| 121 | + { |
|
| 122 | + $width = imagesx( $cover_iri ); |
|
| 123 | + $height = imagesy( $cover_iri ); |
|
| 124 | 124 | |
| 125 | - // calculate thumbnail size |
|
| 125 | + // calculate thumbnail size |
|
| 126 | 126 | |
| 127 | - $new_width = $settings[get_class($this->pmi)::model_type()][$this->get_type()]['thumbnail']['width']; |
|
| 128 | - $new_height = floor( $height * ( $new_width / $width ) ); |
|
| 127 | + $new_width = $settings[get_class($this->pmi)::model_type()][$this->get_type()]['thumbnail']['width']; |
|
| 128 | + $new_height = floor( $height * ( $new_width / $width ) ); |
|
| 129 | 129 | |
| 130 | - // create a new temporary image |
|
| 131 | - $thumb_iri = imagecreatetruecolor($new_width, $new_height); |
|
| 130 | + // create a new temporary image |
|
| 131 | + $thumb_iri = imagecreatetruecolor($new_width, $new_height); |
|
| 132 | 132 | |
| 133 | - // copy and resize old image into new image |
|
| 134 | - imagecopyresized( $thumb_iri, $cover_iri, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); |
|
| 133 | + // copy and resize old image into new image |
|
| 134 | + imagecopyresized( $thumb_iri, $cover_iri, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); |
|
| 135 | 135 | |
| 136 | - // save thumbnail into a file |
|
| 136 | + // save thumbnail into a file |
|
| 137 | 137 | imagejpeg($thumb_iri, $this->locate_thumbnail(pathinfo($filepath, PATHINFO_BASENAME))); |
| 138 | - } |
|
| 139 | - } |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | 141 | public function remove_all() |
| 142 | 142 | { |
| 143 | 143 | $filenames = $this->filenames(); |
| 144 | 144 | |
| 145 | 145 | foreach($filenames as $filename) |
| 146 | - $this->remove($filename); |
|
| 146 | + $this->remove($filename); |
|
| 147 | 147 | |
| 148 | 148 | $directory = $this->build_path_to_directory(); |
| 149 | - if(file_exists($directory) === true) |
|
| 149 | + if(file_exists($directory) === true) |
|
| 150 | 150 | { |
| 151 | 151 | if(is_dir($directory) === false) |
| 152 | 152 | throw new \Exception($this->get_type()."' directory '$directory' is not a directory"); |
| 153 | 153 | |
| 154 | - if(rmdir($directory) === false) |
|
| 155 | - throw new \Exception("rmdir($directory) failed like a bitch"); |
|
| 154 | + if(rmdir($directory) === false) |
|
| 155 | + throw new \Exception("rmdir($directory) failed like a bitch"); |
|
| 156 | 156 | } |
| 157 | 157 | else trigger_error($this->get_type()." $directory doesn't exist", E_USER_WARNING); |
| 158 | 158 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | foreach($pathes as $what => $path) |
| 170 | 170 | { |
| 171 | 171 | $error = null; |
| 172 | - if(!file_exists($path)) |
|
| 172 | + if(!file_exists($path)) |
|
| 173 | 173 | $error = 'file does not exist'; |
| 174 | 174 | elseif(unlink($path)===false) |
| 175 | 175 | $error = 'unlink() failed'; |
@@ -223,16 +223,16 @@ discard block |
||
| 223 | 223 | global $settings; |
| 224 | 224 | $pi_manager = new PictureManager($item, $picture_type); |
| 225 | 225 | |
| 226 | - $pictures = $pi_manager->filenames(); |
|
| 226 | + $pictures = $pi_manager->filenames(); |
|
| 227 | 227 | |
| 228 | 228 | $item_model_type = get_class($item)::model_type(); |
| 229 | 229 | if(count($pictures)===0) |
| 230 | 230 | return $settings[$item_model_type][$picture_type]['generic_picture']; |
| 231 | 231 | |
| 232 | - if($settings[$item_model_type][$picture_type]['cycle_on_load']) |
|
| 233 | - $filename = $pictures[array_rand($pictures, 1)]; |
|
| 234 | - else |
|
| 235 | - $filename = array_shift($pictures); |
|
| 232 | + if($settings[$item_model_type][$picture_type]['cycle_on_load']) |
|
| 233 | + $filename = $pictures[array_rand($pictures, 1)]; |
|
| 234 | + else |
|
| 235 | + $filename = array_shift($pictures); |
|
| 236 | 236 | |
| 237 | 237 | return $thumbnail===true ? $pi_manager->locate_thumbnail($filename) : $pi_manager->locate_file($filename); |
| 238 | 238 | } |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | return $this->iso_name().' ('.$this->Part3.')'; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function traceable() : bool |
|
| 35 | - { |
|
| 36 | - return false; |
|
| 37 | - } |
|
| 34 | + public function traceable() : bool |
|
| 35 | + { |
|
| 36 | + return false; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | public function iso_name() |
| 40 | 40 | { |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | public static function search_language($term, $authority=null) |
| 103 | 103 | { |
| 104 | 104 | $rows = self::query_retrieve(['term' => $term, 'requires_authority' => $authority])->ret_ass(); |
| 105 | - $ret = []; |
|
| 106 | - foreach($rows as $row) |
|
| 107 | - $ret[$row[self::ISO_3]] = $row[self::ISO_NAME]; |
|
| 105 | + $ret = []; |
|
| 106 | + foreach($rows as $row) |
|
| 107 | + $ret[$row[self::ISO_3]] = $row[self::ISO_NAME]; |
|
| 108 | 108 | |
| 109 | 109 | return $ret; |
| 110 | 110 | } |
@@ -10,10 +10,10 @@ |
||
| 10 | 10 | const TABLE_NAME = 'kadro_traduki'; |
| 11 | 11 | const TABLE_ALIAS = 'traduko'; |
| 12 | 12 | |
| 13 | - public function traceable() : bool |
|
| 14 | - { |
|
| 15 | - return false; |
|
| 16 | - } |
|
| 13 | + public function traceable() : bool |
|
| 14 | + { |
|
| 15 | + return false; |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | 18 | public function immortal() : bool |
| 19 | 19 | { |
@@ -23,22 +23,22 @@ |
||
| 23 | 23 | |
| 24 | 24 | public static function today($format=Dato::FORMAT) |
| 25 | 25 | { |
| 26 | - return Dato::today($format); |
|
| 27 | - } |
|
| 26 | + return Dato::today($format); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | public static function date($date=null, $format=Dato::FORMAT) : string |
| 30 | - { |
|
| 31 | - return Dato::format($date); |
|
| 32 | - } |
|
| 30 | + { |
|
| 31 | + return Dato::format($date); |
|
| 32 | + } |
|
| 33 | 33 | // |
| 34 | 34 | // //------------------------------------------------------------ MySQL DateTime helpers |
| 35 | 35 | // public static function year($date=null) : string |
| 36 | - // { |
|
| 37 | - // return Dato::format($date, Dato::FORMAT_YEAR); |
|
| 38 | - // } |
|
| 36 | + // { |
|
| 37 | + // return Dato::format($date, Dato::FORMAT_YEAR); |
|
| 38 | + // } |
|
| 39 | 39 | // |
| 40 | - // public static function datetime($date=null) : string |
|
| 41 | - // { |
|
| 42 | - // return DatoTempo::format($date); |
|
| 43 | - // } |
|
| 40 | + // public static function datetime($date=null) : string |
|
| 41 | + // { |
|
| 42 | + // return DatoTempo::format($date); |
|
| 43 | + // } |
|
| 44 | 44 | } |
@@ -265,7 +265,7 @@ |
||
| 265 | 265 | * const NOTICE = 'notice'; // Normal but significant events. |
| 266 | 266 | * const INFO = 'info'; // Interesting events. User logs in, SQL logs. |
| 267 | 267 | * const DEBUG = 'debug'; // Detailed debug information. |
| 268 | - */ |
|
| 268 | + */ |
|
| 269 | 269 | private static function map_error_level_to_log_level($level) : string |
| 270 | 270 | { |
| 271 | 271 | // http://php.net/manual/en/errorfunc.constants.php |