From 072cad31141f1435af55920c0632102a46ba98df Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Sat, 17 Dec 2016 17:35:47 +0100 Subject: [PATCH] Fixes and improvements --- bin/phpl-generate | 4 ++++ lib/bootstrap.php | 4 ---- lib/config.php | 5 +++++ modules/tux.php | 4 ++-- modules/username.php | 5 +++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/bin/phpl-generate b/bin/phpl-generate index a4c1627..a52c00d 100755 --- a/bin/phpl-generate +++ b/bin/phpl-generate @@ -36,6 +36,10 @@ if (!file_exists(PHPL_STATE)) { passthru("phpl-reload --all -q"); } +function seticon($name, $icon) { + PHPL::$ICONS[$name] = $icon; +} + if (cmdl_get($opts,'q')) { ob_start(); require_once PHPL_STATE; diff --git a/lib/bootstrap.php b/lib/bootstrap.php index 592cabd..a572542 100644 --- a/lib/bootstrap.php +++ b/lib/bootstrap.php @@ -66,7 +66,3 @@ function icon($name) { return array_key_exists($name,PHPL::$THEMEICONS)?PHPL::$THEMEICONS[$name]: (array_key_exists($name,PHPL::$ICONS)?PHPL::$ICONS[$name]:null); } - -function seticon($name, $icon) { - PHPL::$ICONS[$name] = $icon; -} \ No newline at end of file diff --git a/lib/config.php b/lib/config.php index 2797e28..8c42833 100644 --- a/lib/config.php +++ b/lib/config.php @@ -198,6 +198,7 @@ function module($name, $info, array $tags=[]) { 'info' => $info, 'tags' => $tags, 'opts' => [], + 'icons' => [], 'src' => $_SOURCE ]; } @@ -211,6 +212,10 @@ function option($name, $key, $type, $description, $default=null) { 'def' => $default, ]; } + function seticon($name, $text) { + global $_MODULES, $_CURRENT; + $_MODULES[$_CURRENT]->icons[$name] = $text; + } $modules = glob(PHPL_MODULES."/*.php"); foreach ($modules as $module) { $_CURRENT = null; diff --git a/modules/tux.php b/modules/tux.php index 5d04956..1624631 100644 --- a/modules/tux.php +++ b/modules/tux.php @@ -7,8 +7,8 @@ function _tux(array $opts) { $attr = []; if ($opts[TUX_CLASS]) $attr['class'] = $opts[TUX_CLASS]; - return panel(icon("tux"), $attr, 'text'); + return panel(icon("tux.icon"), $attr, 'text'); } module("tux", "Show a tux"); option("class", TUX_CLASS, "string", "The class to use", "tux"); -seticon("tux", "🐧"); +seticon("tux.icon", "🐧"); diff --git a/modules/username.php b/modules/username.php index a222f7c..3078633 100644 --- a/modules/username.php +++ b/modules/username.php @@ -7,7 +7,8 @@ function _username(array $opts) { 'class' => $opts[USERNAME_CLASS] ]; $user = trim(exec("whoami")); - return panel($user, $attr, 'username'); + return panel(icon("username.icon").$user, $attr, 'username'); } module("username", "Username"); -option("class", USERNAME_CLASS, "string", "The class to use", "user"); \ No newline at end of file +option("class", USERNAME_CLASS, "string", "The class to use", "user"); +seticon("username.icon", ""); \ No newline at end of file