| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | use System\Application; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | use System\File; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 6 |  |  | if (!function_exists('pre')) { | 
            
                                                                        
                            
            
                                    
            
            
                | 7 |  |  |   function pre($var) | 
            
                                                                        
                            
            
                                    
            
            
                | 8 |  |  |   { | 
            
                                                                        
                            
            
                                    
            
            
                | 9 |  |  |     echo '<pre>'; | 
            
                                                                        
                            
            
                                    
            
            
                | 10 |  |  |     print_r($var); | 
            
                                                                        
                            
            
                                    
            
            
                | 11 |  |  |     echo '</pre>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | if (!function_exists('array_get')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |   function array_get($array, $key, $default = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     return ($array[$key] || $array[$key] == '0') ? $array[$key] : $default; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | if (!function_exists('app')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |   function app() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     return Application::getInstance(new File(__DIR__)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | if (!function_exists('_e')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |   function _e($value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     $value = trim($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     $value = preg_replace('# {2,}#', ' ', $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     $value = htmlspecialchars($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     return $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | if (!function_exists('getLastParameter')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |   function getLastParameter($index) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     $array = explode('/', $index); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     return end($array); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | if (!function_exists('userId')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |   function userId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     return getLastParameter(app()->request->baseUrl()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | if (!function_exists('url')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |   function url($path) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     return app()->url->link($path); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | if (!function_exists('assets')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |   function assets($path = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     return app()->url->link('public' . DS . $path); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | if (!function_exists('remove_space')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |   function remove_space($str) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     return str_replace(' ', '-', $str); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | if (!function_exists('remove_dash')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |   function remove_dash($str) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     return str_replace('-', ' ', $str); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | if (!function_exists('text_char_limit')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |   function text_char_limit($text, $limit) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     if (strlen($text) > $limit) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |       return substr($text, 0, $limit) . '...'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | if (!function_exists('array_equal')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |   function array_equal($a, $b) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     return ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |       is_array($a) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |       && is_array($b) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |       && count($a) == count($b) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |       && array_diff($a, $b) === array_diff($b, $a) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |   } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 101 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 102 |  |  |  |