HTML
1 year ago
views
5 months ago
Apply.php
6 months ago
Cron.php
1 year ago
CronJob.php
7 months ago
CronJobs.php
2 months ago
Crypt.php
1 month ago
DownloadStats.php
5 months ago
Email.php
4 days ago
EmailCron.php
1 year ago
FileSystem.php
1 year ago
Installer.php
6 hours ago
Messages.php
1 year ago
Query.php
4 months ago
Session.php
6 hours ago
Settings.php
4 years ago
SimpleMath.php
4 years ago
TempStorage.php
6 hours ago
Template.php
5 months ago
UI.php
6 months ago
Updater.php
4 years ago
UserAgent.php
2 years ago
__.php
1 month ago
__MailUI.php
3 years ago
UI.php
91 lines
| 1 | <?php |
| 2 | /** |
| 3 | * User: shahnuralam |
| 4 | * Date: 17/11/18 |
| 5 | * Time: 1:06 AM |
| 6 | */ |
| 7 | |
| 8 | namespace WPDM\__; |
| 9 | |
| 10 | |
| 11 | use WPDM\__\Template; |
| 12 | |
| 13 | class UI |
| 14 | { |
| 15 | static $elements = []; |
| 16 | |
| 17 | static function el($element) { |
| 18 | self::$elements['name'] = $element; |
| 19 | } |
| 20 | static function div($content, $class = '', $attrs = []) |
| 21 | { |
| 22 | $class = $class ? " class='{$class}'" : ''; |
| 23 | $_attrs = ""; |
| 24 | foreach ($attrs as $name => $val){ |
| 25 | $_attrs .= " {$name}='$val'"; |
| 26 | } |
| 27 | return "<div{$class} $_attrs>{$content}</div>"; |
| 28 | } |
| 29 | |
| 30 | static function html($tag, $attrs = [], $content = '') |
| 31 | { |
| 32 | $_attrs = ""; |
| 33 | foreach ($attrs as $name => $val){ |
| 34 | $_attrs .= " {$name}='$val'"; |
| 35 | } |
| 36 | return "<$tag $_attrs>{$content}</$tag>"; |
| 37 | } |
| 38 | |
| 39 | static function a($link, $label = '', $attrs = []) |
| 40 | { |
| 41 | $label = $label ? $label : $link; |
| 42 | $_attrs = ""; |
| 43 | foreach ($attrs as $name => $val){ |
| 44 | $_attrs .= esc_attr($name) . '="'.esc_attr($val).'"'; |
| 45 | } |
| 46 | return '<a href="'.esc_attr($link).'"'.$_attrs.'>'.$label.'</a>'; |
| 47 | } |
| 48 | |
| 49 | static function button($label, $attrs = []){ |
| 50 | $button = "<button"; |
| 51 | foreach ($attrs as $name => $val){ |
| 52 | $button .= " {$name}='$val'"; |
| 53 | } |
| 54 | $button .= ">{$label}</button>"; |
| 55 | return $button; |
| 56 | } |
| 57 | |
| 58 | static function card($heading = '', $content = [], $footer = '', $attrs = []){ |
| 59 | $template = new Template(); |
| 60 | return $template->assign('heading', $heading) |
| 61 | ->assign('attrs', $attrs) |
| 62 | ->assign('content', $content) |
| 63 | ->assign('footer', $footer) |
| 64 | ->fetch("views/ui-blocks/card.php", __DIR__); |
| 65 | } |
| 66 | |
| 67 | static function table($thead, $data, $css){ |
| 68 | $template = new Template(); |
| 69 | return $template->assign('thead', $thead) |
| 70 | ->assign('data', $data) |
| 71 | ->assign('css', $css) |
| 72 | ->fetch("views/ui-blocks/table.php", __DIR__); |
| 73 | } |
| 74 | |
| 75 | static function img($src, $alt = '', $attrs = []) |
| 76 | { |
| 77 | $_attrs = ""; |
| 78 | foreach ($attrs as $name => $val){ |
| 79 | $_attrs .= " {$name}='$val'"; |
| 80 | } |
| 81 | return "<img src='{$src}' alt='{$alt}' {$_attrs} />"; |
| 82 | } |
| 83 | |
| 84 | static function minifyHTML($html) |
| 85 | { |
| 86 | $html = str_replace(["\r", "\n"], "", $html); |
| 87 | return $html; |
| 88 | } |
| 89 | |
| 90 | } |
| 91 |