├── Config ├── Backend.php └── Notification.php ├── Controllers └── BaseController.php ├── Helpers ├── array_helper.php ├── calc_helper.php ├── date_helper.php ├── error_helper.php └── string_helper.php ├── LICENSE ├── Libraries └── Notification.php ├── README.md ├── Views ├── home │ └── index.php ├── layouts │ ├── application.php │ ├── backend.php │ └── nolayout.php └── login │ └── index.php └── composer.json /Config/Backend.php: -------------------------------------------------------------------------------- 1 | '#343a40', 9 | 'sidebarLink' => '#c2c7d0', 10 | 'sidebarHover' => 'rgba(255,255,255,.1)', 11 | 'sidebarHoverLink' => '#FFFFFF', 12 | 'primaryColor' => '#007bff', 13 | 'contentWrapper' => '#f4f6f9', 14 | ]; 15 | public $siteName = 'CI - Toolkit'; 16 | public $logoutControllerMethod = '#'; 17 | public $loginName = 'Login'; 18 | public $brandLink = '#'; 19 | public $brand = 'CI - Tookit'; 20 | public $logo = ''; 21 | public $background = ''; 22 | public $copyrightLeft = 'All rights reserved'; 23 | public $copyrightRight = null; 24 | public $breadcrumb = false; 25 | 26 | public $assetsPath = 'backend'; 27 | public $css = [ 28 | '/plugins/fontawesome-free/css/all.min.css', 29 | 'https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.cs', 30 | '/dist/css/adminlte.min.css', 31 | 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700', 32 | ]; 33 | public $js = [ 34 | '/plugins/jquery/jquery.min.js', 35 | '/plugins/bootstrap/js/bootstrap.bundle.min.js', 36 | '/dist/js/adminlte.min.js', 37 | ]; 38 | 39 | public $navigation = [ 40 | [ 41 | 'name' => 'Dashboard', 42 | 'link' => '#', 43 | 'icon' => 'fas fa-circle nav-icon', 44 | ], 45 | ]; 46 | } 47 | -------------------------------------------------------------------------------- /Config/Notification.php: -------------------------------------------------------------------------------- 1 | 'html', 9 | 'protocol' => 'smtp', 10 | 'smtp_host' => '', 11 | 'smtp_user' => '', 12 | 'smtp_pass' => '', 13 | 'smtp_port' => '587', 14 | 'smtp_timeout' => '15', 15 | ]; 16 | public $from = [ 17 | 'email' => 'noreply@site.com', 18 | 'name' => 'noreply', 19 | ]; 20 | public $bcc = ''; 21 | } 22 | -------------------------------------------------------------------------------- /Controllers/BaseController.php: -------------------------------------------------------------------------------- 1 | session = \Config\Services::session(); 56 | // Required if you're using flashdata 57 | $this->session = \Config\Services::session(); 58 | 59 | //-------------------------------------------------------------------- 60 | // Check for flashdata 61 | //-------------------------------------------------------------------- 62 | $this->data['confirm'] = $this->session->getFlashdata('confirm'); 63 | $this->data['errors'] = $this->session->getFlashdata('errors'); 64 | 65 | // Arguments to be used in the callback remap 66 | $segments = $request->uri->getSegments(); 67 | $this->arguments = array_slice($segments, (($this->directory === null) ? 2 : 3)); 68 | 69 | $this->data['adminConf'] = new \Toolkit\Config\Backend(); 70 | } 71 | 72 | /** 73 | * -------------------------------------------------------------------- 74 | * REMAP AUTOLOAD VIEWS 75 | * -------------------------------------------------------------------- 76 | */ 77 | 78 | /** 79 | * Remap the CI request, running the method 80 | * and loading the view automagically 81 | * @param string $method The method we're trying to load 82 | */ 83 | public function _remap($method = null) 84 | { 85 | $router = service('router'); 86 | 87 | $controller_full_name = explode('\\', $router->controllerName()); 88 | $view_folder = strtolower(end($controller_full_name)); 89 | 90 | if (method_exists($this, $method)) { 91 | $redirect = call_user_func_array(array($this, $method), $this->arguments); 92 | } else { 93 | throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound(); 94 | } 95 | 96 | if (isset($redirect) && is_object($redirect) && get_class($redirect) === 'CodeIgniter\HTTP\RedirectResponse') { 97 | return $redirect; 98 | } elseif (isset($redirect) && is_object($redirect) && get_class($redirect) === 'CodeIgniter\HTTP\Response') { 99 | return $redirect; 100 | } else if (is_array($redirect) && isset($redirect['url'])) { 101 | $confirm = (isset($redirect['confirm'])) ? $redirect['confirm'] : null; 102 | if (!empty($confirm)) { 103 | return redirect()->to($redirect['url'])->with('confirm', $redirect['confirm']); 104 | } 105 | $errors = (isset($redirect['errors'])) ? $redirect['errors'] : null; 106 | if (!empty($errors)) { 107 | return redirect()->to($redirect['url'])->with('errors', $redirect['errors']); 108 | } 109 | return redirect()->to($redirect['url']); 110 | } 111 | 112 | if ($this->view !== false) { 113 | $this->data['layout'] = (empty($this->layout)) ? 'layouts/nolayout' : $this->layout; 114 | $this->data['yield'] = (!empty($this->view)) ? $this->view : strtolower($this->directory . $view_folder . '/' . $router->methodName()); 115 | echo view($this->data['yield'], $this->data); 116 | } else { 117 | return $redirect; 118 | } 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /Helpers/array_helper.php: -------------------------------------------------------------------------------- 1 | $value) { 17 | if (is_array($value)) { 18 | $result = array_merge($result, array_flatten($value)); 19 | } else { 20 | $result[$key] = $value; 21 | } 22 | } 23 | return $result; 24 | } 25 | } 26 | 27 | /* 28 | * Return array average 29 | */ 30 | if (!function_exists('avg_array')) { 31 | function avg_array($array) 32 | { 33 | if (!is_array($array)) { 34 | return false; 35 | } 36 | if (empty($array)) { 37 | return 0.0; 38 | } 39 | return round((array_sum($array) / count($array)), 1); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Helpers/calc_helper.php: -------------------------------------------------------------------------------- 1 | = $min_score) { 37 | return 0; 38 | } else { 39 | return (($min_score - $score) * 100) / ($min_score - $max_score); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Helpers/date_helper.php: -------------------------------------------------------------------------------- 1 | format($format) == $date; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Helpers/error_helper.php: -------------------------------------------------------------------------------- 1 | 'a', 37 | '/[ÁÀÂÃÄ]/u' => 'A', 38 | '/[ÍÌÎÏ]/u' => 'I', 39 | '/[íìîï]/u' => 'i', 40 | '/[éèêë]/u' => 'e', 41 | '/[ÉÈÊË]/u' => 'E', 42 | '/[óòôõºö]/u' => 'o', 43 | '/[ÓÒÔÕÖ]/u' => 'O', 44 | '/[úùûü]/u' => 'u', 45 | '/[ÚÙÛÜ]/u' => 'U', 46 | '/ç/' => 'c', 47 | '/Ç/' => 'C', 48 | '/ñ/' => 'n', 49 | '/Ñ/' => 'N', 50 | '/–/' => '-', 51 | '/[’‘‹›‚]/u' => ' ', 52 | '/[“”«»„]/u' => ' ', 53 | '/ /' => ' ', 54 | ); 55 | return preg_replace(array_keys($utf8), array_values($utf8), $original_utf8); 56 | } 57 | 58 | } 59 | 60 | if (!function_exists('decimal_number')) { 61 | /** 62 | * Set any number to a set of decimal number eg. 1 = 1.0 63 | * @param int $number The number to be formated 64 | * @param integer $decimal How many decimals 65 | * @return double 66 | */ 67 | function decimal_number($number = null, $decimal = 1) 68 | { 69 | if (is_null($number)) { 70 | return 0; 71 | } 72 | return number_format($number, $decimal, '.', ' '); 73 | } 74 | } 75 | 76 | if (!function_exists('round_up')) { 77 | /** 78 | * Round up a number 79 | */ 80 | function round_up($number, $precision = 3) 81 | { 82 | $fig = (int) str_pad('1', $precision, '0'); 83 | return (ceil($number * $fig) / $fig); 84 | } 85 | } 86 | 87 | if (!function_exists('round_down')) { 88 | /** 89 | * Round down a number 90 | */ 91 | function round_down($number, $precision = 3) 92 | { 93 | $fig = (int) str_pad('1', $precision, '0'); 94 | return (floor($number * $fig) / $fig); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Marco Monteiro 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Libraries/Notification.php: -------------------------------------------------------------------------------- 1 | config = config('Notification'); 13 | } 14 | 15 | /** 16 | * SEND NOTIFICATION 17 | */ 18 | public function send($data = []) 19 | { 20 | $email = \Config\Services::email(); 21 | 22 | $config = $this->config; 23 | 24 | $email->initialize($config->settings); 25 | if (isset($data['from'])) { 26 | $email->setFrom($data['from'], $data['from_name']); 27 | } else { 28 | $email->setFrom($config->from['email'], $config->from['name']); 29 | } 30 | if (isset($data['to'])) { 31 | $data['to'] = $this->validEmail($data['to']); 32 | $email->setTo($data['to']); 33 | } else { 34 | return false; 35 | } 36 | 37 | if (isset($data['cc'])) { 38 | $data['cc'] = $this->validEmail($data['cc']); 39 | $email->setCC($data['cc']); 40 | } 41 | 42 | $bcc = $config->bcc; 43 | 44 | if (isset($data['bcc'])) { 45 | $data['bcc'] = $this->validEmail($data['bcc']); 46 | $bcc .= ',' . $data['bcc']; 47 | } 48 | $email->setBCC($bcc); 49 | 50 | if (!isset($data['subject'])) { 51 | return false; 52 | } else { 53 | $email->setSubject($data['subject']); 54 | } 55 | 56 | if (!isset($data['message'])) { 57 | return false; 58 | } else { 59 | $email->setMessage($data['message']); 60 | } 61 | 62 | if (isset($data['attach'])) { 63 | $email->attach($data['attach']); 64 | } 65 | 66 | if ($email->send()) { 67 | return true; 68 | } else { 69 | echo $email->printDebugger(['headers']); 70 | die(); 71 | } 72 | } 73 | 74 | /* valid emails before send */ 75 | public function validEmail($emails = []) 76 | { 77 | $emails_valid = []; 78 | if (!is_array($emails)) { 79 | $emails = explode(', ', $emails); 80 | } 81 | foreach ($emails as $key => $email) { 82 | if (!!filter_var($email, FILTER_VALIDATE_EMAIL)) { 83 | $emails_valid[$key] = $email; 84 | } 85 | } 86 | return $emails_valid = implode(', ', $emails_valid); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # codeigniter 4 Toolkit 2 | 3 | A set of libraries and helpers for codeigniter 4 4 | 5 | ## Composer Install 6 | 7 | This way you should run the following command in your terminal. 8 | 9 | composer require mpmont/ci-toolkit dev-master 10 | 11 | Or add the following to your composer.json file. 12 | 13 | { 14 | "require": { 15 | "mpmont/ci-toolkit": "dev-master" 16 | } 17 | } 18 | 19 | ## Dependencies 20 | 21 | - elephpant/breadcrumb [Breacrumb Library](https://github.com/sergiodanilojr/breadcrumb) 22 | - almasaeed2010/adminlte [Admin LTE template](https://github.com/ColorlibHQ/AdminLTE) 23 | 24 | ## Suggested dependencies 25 | 26 | ### IonAuth 27 | 28 | As an authentication system I suggest using Ion Auth. To add that to your project just run the following commands on your project. 29 | 30 | $ composer config minimum-stability dev 31 | $ composer config repositories.ionAuth vcs git@github.com:benedmunds/CodeIgniter-Ion-Auth.git 32 | $ composer require benedmunds/CodeIgniter-Ion-Auth:4.x-dev 33 | 34 | Documentation for Ion Auth can be found [Here](https://github.com/benedmunds/CodeIgniter-Ion-Auth/blob/4/USERGUIDE.md). 35 | 36 | ### pwrsrg/codeigniter4-cart-module 37 | 38 | In case you're building a store and need a cart module just add this to your composer.json and you're good to go. 39 | 40 | $ composer require pwrsrg/codeigniter4-cart-module 41 | 42 | Documentation can be found [Here](https://github.com/pwrsrg/codeigniter4-cart-module). 43 | 44 | ## Base Controller 45 | 46 | codeigniter-base-controller is an extended `BaseController` class to use in your CodeIgniter applications. Any controllers that inherit from `BaseController` get intelligent view autoloading and layout support. It's strongly driven by the ideals of convention over configuration, favouring simplicity and consistency over configuration and complexity. 47 | 48 | #### Usage 49 | 50 | If you install the package via composer then controllers should use a different namespace. In that case your controllers that extend to base Controller should extend to \Toolkit\Controllers\BaseController, like so: 51 | 52 | data` will be passed through to the view and the layout. By default, the class will look for the view in _app/views/controller/action.php_. 69 | 70 | In order to prevent the view being automatically rendered, set `$this->view` to `false`. 71 | 72 | $this->view = false; 73 | 74 | Or, to load a different view than the automatically guessed view: 75 | 76 | $this->view = 'some_path/some_view.php'; 77 | 78 | Views will be loaded into a layout. The class will look for an _app/views/layouts/backend.php_ layout file or _app/views/layouts/application.php_ depending if it's the baseController or the adminController. 79 | 80 | In case you want to override this in your controller just set your layout to whatever you want. 81 | 82 | $this->layout = 'layouts/yourlayout.php' 83 | 84 | In order to specify where in your layout you'd like to output the view, the rendered view will be stored in a `$yield` variable: 85 | 86 |

Header

87 | 88 |
89 | renderSection('yield') ?> 90 |
91 | 92 |

Footer

93 | 94 | If you wish to disable the layout entirely and only display the view - a technique especially useful for AJAX requests - you can set `$this->layout` to `FALSE`. 95 | 96 | $this->layout = FALSE; 97 | 98 | Like with `$this->view`, `$this->layout` can also be used to specify an unconventional layout file: 99 | 100 | $this->layout = 'layouts/mobile.php'; 101 | 102 | Any variables set in `$this->data` will be passed through to both the view and the layout files. 103 | 104 | #### View structure 105 | 106 | Your views should be created to support the built in functionality of layouts that comes with codeigniter 4 107 | 108 | extend($layout); ?> 109 | 110 | section('yield') ?> 111 |

Hello World from the home/index view!

112 | endSection() ?> 113 | 114 | As for your layouts, those should have a render section called yield. 115 | 116 | 117 | 118 | 119 | My Layout 120 | 121 | 122 | This is my layout content 123 | renderSection('yield') ?> 124 | 125 | 126 | 127 | To actually be able to rendere a view directly without the layout we need an empty layout doing the render. For that there's a nolayout.php file included in your Views/layouts folder that only does the view render. 128 | 129 | renderSection('yield') ?> 130 | 131 | The complete folder structure is now included in the project. 132 | 133 | 134 | ### Loading Helpers in your controllers 135 | 136 | If you want to load helpers in your controllers in a global scope and not inside a function all your have to do is declare the helpers property as array with all your helpers, like so: 137 | 138 | 139 | 140 | layout = false; 186 | $this->view = '\Toolkit\Views\login/index'; 187 | } 188 | 189 | This will use the provied login view that looks something like this: 190 | 191 | ![Login](https://i.imgur.com/wf6i0bB.png) 192 | 193 | This view has the form helper has a dependency so you must set that in your controllers. 194 | 195 | protected $helpers = ['form']; 196 | 197 | ## Using the provided Admin template 198 | 199 | There's a simple admin template provied you can use for your backend applications. To use this in your controllers or your base controller that extends to the provied base controller you can just set a new layout pointing to that specific view. 200 | 201 | To do this in your controller just set the property layouts with this: 202 | 203 | protected $layout = '\Toolkit\Views\layouts/backend'; 204 | 205 | The default look of your admin template looks like this: 206 | 207 | ![Backend](https://i.imgur.com/C9PUEYP.png) 208 | 209 | You can configure the looks of your admin template by creating a config class that extends to toolkit\Backend like so: 210 | 211 | 212 | '#343a40', // Change the sidebar color 222 | 'sidebarLink' => '#c2c7d0', // Change the sidebar link color 223 | ]; 224 | public $siteName = 'CI - Toolkit'; // Change sitename 225 | public $logoutControllerMethod = '#'; // Change logout link 226 | public $brandLink = '#'; // Set a brand link relative to the app like /home/index 227 | public $brand = 'CI - Tookit'; // Set the brand name 228 | public $copyrightLeft = 'All rights reserved'; // Your copyright info Left 229 | public $copyrightRight = null; // Your copyright info right 230 | public $breadcrumb = false; // Want to use breadcrumbs 231 | 232 | public $assetsPath = 'backend'; // Set your base folder in your assets structrure, should be the same folder you set on your composer file 233 | 234 | // A list of all the assets you're using in your backend application, just add more here to add your custom css and js 235 | public $css = [ 236 | '/plugins/fontawesome-free/css/all.min.css', 237 | 'https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.cs', 238 | '/dist/css/adminlte.min.css', 239 | 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700', 240 | ]; 241 | public $js = [ 242 | '/plugins/jquery/jquery.min.js', 243 | '/plugins/bootstrap/js/bootstrap.bundle.min.js', 244 | '/dist/js/adminlte.min.js', 245 | ]; 246 | 247 | // Your navigation up to 2 levels deap 248 | public $navigation = [ 249 | [ 250 | 'name' => 'Link 1', 251 | 'link' => '#', 252 | 'icon' => 'fas fa-circle nav-icon', 253 | ], 254 | ]; 255 | } 256 | 257 | If you decide to use the breadcrumbs that will use another dependency elephpant/breadcrumb. Look up to their documentation to use the breadcrumbs. 258 | 259 | In case you need a menu structure with two levels you should set that up like so: 260 | 261 | public $navigation = [ 262 | [ 263 | 'name' => 'Link 1', 264 | 'link' => '#', 265 | 'icon' => 'fas fa-circle nav-icon', 266 | 'childs' => [ 267 | [ 268 | 'name' => 'Link 1.1', 269 | 'link' => '#', 270 | 'icon' => 'fas fa-circle nav-icon', 271 | ], 272 | [ 273 | 'name' => 'Link 1.2', 274 | 'link' => '#', 275 | 'icon' => 'fas fa-circle nav-icon', 276 | ], 277 | [ 278 | 'name' => 'Link 1.3', 279 | 'link' => '#', 280 | 'icon' => 'fas fa-circle nav-icon', 281 | ], 282 | ], 283 | ], 284 | ]; 285 | 286 | 287 | # Notification Library 288 | 289 | Sending emails is a core feature of almost all your applications, so instead of having to repeat code to send emails over and over again I create a small library to help you there. 290 | 291 | To setup your config you just need to copy the provided codif in /config/Notification.php to your app/Config/Notification.php and don't forget to change your namespace. 292 | 293 | class Notification extends BaseConfig 294 | { 295 | public $settings = [ 296 | 'mailtype' => 'html', 297 | 'protocol' => 'smtp', 298 | 'smtp_host' => '', 299 | 'smtp_user' => '', 300 | 'smtp_pass' => '', 301 | 'smtp_port' => '587', 302 | 'smtp_timeout' => '15', 303 | ]; 304 | public $from = [ 305 | 'email' => 'noreply@site.com', 306 | 'name' => 'noreply', 307 | ]; 308 | public $bcc = ''; 309 | } 310 | 311 | Then to use the library is as easy as: 312 | 313 | $notification = new \Toolkit\Libraries\Notification(); 314 | $data = [ 315 | 'to' => 'destionation@email.com', 316 | 'subject' => 'Your subject', 317 | 'message' => 'Your message, this can be a view too', 318 | ]; 319 | $notification->send($data); 320 | 321 | # Provided Helpers in the Toolkit 322 | 323 | The toolkit brings a set of helpers that you can use in your application, this will probably be one of the more growing parts of this project. 324 | 325 | ## Array Helper 326 | 327 | Loading the Array Helper 328 | 329 | helper('\Toolkit\array'); 330 | 331 | ### Array Flatten 332 | 333 | Convert a multi-dimensional array into a single-dimensional array. 334 | 335 | $newArray = array_flatten($array); 336 | 337 | ### Average Array 338 | 339 | Returns the average value in an array of numbers. 340 | 341 | $avgArray = avg_array($array); 342 | 343 | ## Calc Helper 344 | 345 | Loading the Calc Helper 346 | 347 | helper('\Toolkit\calc'); 348 | 349 | ### Convert To Percent 350 | 351 | Get a percentage value based on another value. Example: 1 is how much percentage of 34? 352 | 353 | $slice = 1; 354 | $cake = 34; 355 | 356 | echo convertToPercent($slice, $cake); 357 | // Output 3 358 | 359 | However there's a third param that you can set that gives the round value like so: 360 | 361 | $slice = 1; 362 | $cake = 34; 363 | echo convertToPercent(1, 34, 2); 364 | // output 2.94 365 | 366 | ### Calc Inverted 367 | 368 | Let's say you need to calc the percentage in a inverted value. So your max score is 0, min score is 200. The closer the value is to zero the higher the percentage. If the value is higher than 200 then 0 is your score. 369 | 370 | $maxScore = 0; 371 | $minScore = 200; 372 | $score 100; 373 | echo calcInverted($maxScore, $minScore, $score); 374 | // outputs 100 375 | 376 | ## Date Helper 377 | 378 | Loading the Date Helper 379 | 380 | helper('\Toolkit\date'); 381 | 382 | ### Transform date into a new format 383 | 384 | $date = '20-10-2020'; 385 | $format = 'Y-m-d H:i:s'; 386 | echo validateDate($date, $format) 387 | // Outputs 20-10-2020 00:00:00 388 | 389 | ## Error Helper 390 | 391 | Loading the Error Helper 392 | 393 | helper('\Toolkit\error'); 394 | 395 | ### Show a 404 error 396 | 397 | show_404(); 398 | 399 | ## String Helper 400 | 401 | Loading the String Helper 402 | 403 | helper('\Toolkit\string'); 404 | 405 | ### Get random string 406 | 407 | echo getRandomString(10); 408 | // Outputs a random string with lenght of 10 409 | 410 | ### Translate a string from latin character to the correspondent non latin characters 411 | 412 | So basically all characters like: Áãà will be translated to just "a". This is specially usefull if your doing something with urls and want to remove those from the url. 413 | 414 | $string = 'Cão'; 415 | echo transliterateString($string); 416 | // outputs "Cao" 417 | 418 | ### Decimal Number 419 | 420 | This will translate any int into a decimal. So 3 can be 3.00 or even 3.000 421 | 422 | echo decimal_number(3, 2); 423 | // Outputs 3.00 424 | 425 | ### Round up and Round down a value 426 | 427 | echo round_up(4.5, 3); 428 | // Output 5.000 429 | echo round_down(4.5, 3); 430 | // Output 4.000 431 | 432 | -------------------------------------------------------------------------------- /Views/home/index.php: -------------------------------------------------------------------------------- 1 | extend($layout); ?> 2 | 3 | section('yield') ?> 4 |

Hello World from the home/index view!

5 | endSection() ?> -------------------------------------------------------------------------------- /Views/layouts/application.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | My Layout 5 | 6 | 7 | This is my layout content 8 | renderSection('yield') ?> 9 | 10 | -------------------------------------------------------------------------------- /Views/layouts/backend.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <?php echo $adminConf->siteName ?? '' ?> | Admin 7 | 8 | 9 | css as $key => $file): ?> 10 | 11 | 12 | 13 | 14 | 15 | 16 | 31 | 32 | 33 | 34 |
35 | 36 | 50 | 51 | 52 | 53 | 108 | 109 | 110 |
111 | 112 |
113 |
114 |
115 |
116 |

117 |
118 |
119 |
120 |
121 |
122 |
123 | 124 | 125 |
126 | 127 | 130 | 131 | 132 | 137 | 138 | breadcrumb) && $adminConf->breadcrumb): ?> 139 | render(); ?> 140 | 141 | renderSection('yield') ?> 142 |
143 | 144 |
145 | 146 | 147 | 153 |
154 | js as $key => $file): ?> 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /Views/layouts/nolayout.php: -------------------------------------------------------------------------------- 1 | renderSection('yield') ?> 2 | -------------------------------------------------------------------------------- /Views/login/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <?php echo $adminConf->siteName ?> | Log in 7 | 8 | 9 | 10 | 11 | 12 | 13 | 21 | 22 | background)): ?> style="background-image: url(background; ?>);"> 24 |
25 | 34 |
35 | 62 |
63 |
64 | 65 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mpmont/ci-toolkit", 3 | "description": "View autoloading, notification library and helpers", 4 | "type": "library", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Marco Monteiro", 9 | "email": "marco@marcomonteiro.net" 10 | } 11 | ], 12 | "replace": { 13 | "marcogmonteiro/ci-admin-controller": "1.1.7" 14 | }, 15 | "autoload": { 16 | "psr-4": { 17 | "Toolkit\\": "/" 18 | } 19 | }, 20 | "require": { 21 | "elephpant/breadcrumb": "^1.1", 22 | "almasaeed2010/adminlte": "~3.0" 23 | }, 24 | "suggest": { 25 | "PHP 7.2": "Required to use Codeigniter 4 Framework", 26 | "benedmunds/codeigniter-ion-auth": "So you can use the authentication features provided", 27 | "pwrsrg/codeigniter4-cart-module": "In case you're building a store, add this to your project to get cart functionality" 28 | } 29 | } 30 | --------------------------------------------------------------------------------