68 lines
2.1 KiB
PHP
68 lines
2.1 KiB
PHP
<?php
|
|
|
|
class IconsHelper extends \Prefab {
|
|
|
|
static public $status_icons = [
|
|
'New' => ['fas fa-circle-dot has-text-success', "🆕"],
|
|
'In Progress' => ['fas fa-circle-play has-text-link', "🔄"],
|
|
'On Hold' => ['fas fa-pause-circle has-text-warning',"⏸️"],
|
|
'Completed' => ['fas fa-check-circle has-text-danger', "✅"]
|
|
];
|
|
|
|
static public $priority_icons = [
|
|
'Low' => ['fas fa-circle-down',"🟢"],
|
|
'Medium' => ['fas fa-circle-dot', "🟡"],
|
|
'High' => ['fas fa-circle-up', "🔴"]
|
|
];
|
|
|
|
static public $priority_colors = [
|
|
'Low' => 'success',
|
|
'Medium' => 'warning',
|
|
'High' => 'danger',
|
|
'' => 'info'
|
|
];
|
|
|
|
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', "🔲"];
|
|
$icon_color = IconsHelper::$priority_colors[$value] ?? 'info';
|
|
break;
|
|
default:
|
|
$icon_class = 'fas fa-question-circle';
|
|
}
|
|
|
|
if($type == 'priority'){
|
|
// return '<p class="button"><span class="icon is-small">'
|
|
return '<span class="icon is-medium">
|
|
<i class="'.$icon_class[0].' fa-lg has-text-'.$icon_color.'"></i>
|
|
</span>';
|
|
} else {
|
|
return '<span class="icon is-medium"><i class="'.$icon_class[0].' fa-lg"></i></span>';
|
|
}
|
|
return '<span class="is-size-5">'.$icon_class[1].'</span>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
\Template::instance()->extend('icons', 'IconsHelper::icons'); |