53 lines
1.6 KiB
PHP
53 lines
1.6 KiB
PHP
<?php
|
|
|
|
class IconsHelper extends \Prefab {
|
|
|
|
static public $status_icons = [
|
|
'New' => ['fas fa-plus-circle has-text-warning', "🆕"],
|
|
'In Progress' => ['fas fa-repeat has-text-link', "🔄"],
|
|
'On Hold' => ['fas fa-pause-circle has-text-danger',"⏸️"],
|
|
'Completed' => ['fas fa-check-circle has-text-success', "✅"]
|
|
];
|
|
|
|
static public $priority_icons = [
|
|
'Low' => ['fas fa-arrow-down',"🟢"],
|
|
'Medium' => ['fas fa-minus', "🟡"],
|
|
'High' => ['fas fa-arrow-up', "🔴"]
|
|
];
|
|
|
|
static public function icons($node){
|
|
|
|
$attr = $node['@attrib'];
|
|
|
|
$tpl = Template::instance();
|
|
$f3 = Base::instance();
|
|
|
|
$context = $f3->hive();
|
|
$inner = $tpl->token($node[0], $context);
|
|
|
|
return '<?php echo IconsHelper::do_the_switch("' . $attr['type'] . '", ' . $inner . '); ?>';
|
|
|
|
}
|
|
|
|
static function do_the_switch($type, $value){
|
|
|
|
$icon_class = '';
|
|
switch(strtolower($type)){
|
|
case 'status':
|
|
$icon_class = IconsHelper::$status_icons[$value] ?? ['fas fa-question-circle has-text-info', "🔲"];
|
|
break;
|
|
case 'priority':
|
|
$icon_class = IconsHelper::$priority_icons[$value] ?? ['fas fa-question-circle', "🔲"];
|
|
break;
|
|
default:
|
|
$icon_class = 'fas fa-question-circle';
|
|
}
|
|
|
|
return '<span class="is-size-5">'.$icon_class[1].'</span>';
|
|
return '<i class="'.$icon_class[0].' is-size-4"></i>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
\Template::instance()->extend('icons', 'IconsHelper::icons'); |