nazar-pc /
CleverStyle-Framework
| 1 | <?php |
||||
| 2 | /** |
||||
| 3 | * @package CleverStyle Framework |
||||
| 4 | * @subpackage CleverStyle theme |
||||
| 5 | * @author Nazar Mokrynskyi <[email protected]> |
||||
| 6 | * @license 0BSD |
||||
| 7 | */ |
||||
| 8 | namespace cs\themes\CleverStyle; |
||||
| 9 | use |
||||
| 10 | cs\Config, |
||||
| 11 | cs\DB, |
||||
| 12 | cs\Event, |
||||
| 13 | cs\Language, |
||||
| 14 | cs\Page, |
||||
| 15 | cs\Request, |
||||
| 16 | cs\User, |
||||
| 17 | h; |
||||
| 18 | |||||
| 19 | /** |
||||
| 20 | * Returns array with `a` items |
||||
| 21 | * |
||||
| 22 | * @return string[] |
||||
| 23 | */ |
||||
| 24 | function get_main_menu () { |
||||
| 25 | $Config = Config::instance(); |
||||
| 26 | $L = Language::instance(); |
||||
| 27 | $User = User::instance(); |
||||
| 28 | $main_menu_items = []; |
||||
| 29 | /** |
||||
| 30 | * Administration item |
||||
| 31 | */ |
||||
| 32 | if ($User->admin()) { |
||||
| 33 | $main_menu_items[] = h::a( |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 34 | $L->system_admin_administration, |
||||
|
0 ignored issues
–
show
The property
system_admin_administration does not exist on cs\Language. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||||
| 35 | [ |
||||
| 36 | 'href' => 'admin' |
||||
| 37 | ] |
||||
| 38 | ); |
||||
| 39 | } |
||||
| 40 | /** |
||||
| 41 | * Home item |
||||
| 42 | */ |
||||
| 43 | $main_menu_items[] = h::a( |
||||
| 44 | $L->system_home, |
||||
|
0 ignored issues
–
show
The property
system_home does not exist on cs\Language. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||||
| 45 | [ |
||||
| 46 | 'href' => '/' |
||||
| 47 | ] |
||||
| 48 | ); |
||||
| 49 | /** |
||||
| 50 | * All other active modules if permissions allow to visit |
||||
| 51 | */ |
||||
| 52 | foreach (array_keys($Config->components['modules']) as $module) { |
||||
| 53 | if ( |
||||
| 54 | $module != Config::SYSTEM_MODULE && |
||||
| 55 | $module != $Config->core['default_module'] && |
||||
| 56 | $User->get_permission($module, 'index') && |
||||
| 57 | file_exists_with_extension(MODULES."/$module/index", ['php', 'html', 'json']) && |
||||
| 58 | !@file_get_json(MODULES."/$module/meta.json")['hide_in_menu'] && |
||||
| 59 | $Config->module($module)->enabled() |
||||
| 60 | ) { |
||||
| 61 | $main_menu_items[] = h::a( |
||||
| 62 | $L->$module, |
||||
| 63 | [ |
||||
| 64 | 'href' => path($L->$module) |
||||
| 65 | ] |
||||
| 66 | ); |
||||
| 67 | } |
||||
| 68 | } |
||||
| 69 | return $main_menu_items; |
||||
| 70 | } |
||||
| 71 | |||||
| 72 | /** |
||||
| 73 | * Getting footer information |
||||
| 74 | * |
||||
| 75 | * @return string |
||||
| 76 | */ |
||||
| 77 | function get_footer () { |
||||
| 78 | $db = class_exists('cs\\DB', false) ? DB::instance() : null; |
||||
| 79 | /** |
||||
| 80 | * Some useful details about page execution process, will be called directly before output |
||||
| 81 | */ |
||||
| 82 | Event::instance()->on( |
||||
| 83 | 'System/Page/render/after', |
||||
| 84 | function () { |
||||
| 85 | $Page = Page::instance(); |
||||
| 86 | $Page->Html = str_replace( |
||||
| 87 | [ |
||||
| 88 | '<!--generate time-->', |
||||
| 89 | '<!--memory usage-->', |
||||
| 90 | '<!--peak memory usage-->' |
||||
| 91 | ], |
||||
| 92 | [ |
||||
| 93 | round(microtime(true) - Request::instance()->started, 5), |
||||
| 94 | round(memory_get_usage() / 1024 / 1024, 5), |
||||
| 95 | round(memory_get_peak_usage() / 1024 / 1024, 5) |
||||
| 96 | ], |
||||
| 97 | $Page->Html |
||||
| 98 | ); |
||||
| 99 | } |
||||
| 100 | ); |
||||
| 101 | return h::div( |
||||
|
0 ignored issues
–
show
The method
div() does not exist on h. Since you implemented __callStatic, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 102 | sprintf( |
||||
| 103 | 'Page generated in %s s; %d queries to DB in %f s; memory consumption %s MiB (peak %s MiB)', |
||||
| 104 | '<!--generate time-->', |
||||
| 105 | $db ? $db->queries() : 0, |
||||
| 106 | $db ? round($db->time(), 5) : 0, |
||||
| 107 | '<!--memory usage-->', |
||||
| 108 | '<!--peak memory usage-->' |
||||
| 109 | ), |
||||
| 110 | '© Powered by <a target="_blank" href="https://cleverstyle.org/Framework" title="CleverStyle Framework">CleverStyle Framework</a>' |
||||
| 111 | ); |
||||
| 112 | } |
||||
| 113 | |||||
| 114 | function level ($in, $level) { |
||||
| 115 | return trim(h::level($in, $level))."\n"; |
||||
| 116 | } |
||||
| 117 |