diff options
author | Vincent Peugnet <33429034+vincent-peugnet@users.noreply.github.com> | 2020-03-25 19:55:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-25 19:55:25 +0100 |
commit | a17b7fc6aa87341c51e68baf3f217f709eb817d7 (patch) | |
tree | ba6958ba93e76d2464ad9ae068b9bd56400d5294 /app/fn/fn.php | |
parent | fa92ec6b40676677595047b71b3c2fafb1bf89ea (diff) | |
parent | d17713051ca2fef29de8025fe876d417838cea7f (diff) | |
download | wcms-a17b7fc6aa87341c51e68baf3f217f709eb817d7.tar.gz wcms-a17b7fc6aa87341c51e68baf3f217f709eb817d7.zip |
Merge pull request #72 from n-peugnet/implement-cytoscape.js
Implement cytoscape.js
Diffstat (limited to 'app/fn/fn.php')
-rw-r--r-- | app/fn/fn.php | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/app/fn/fn.php b/app/fn/fn.php index 6dfeb2c..60e4722 100644 --- a/app/fn/fn.php +++ b/app/fn/fn.php @@ -2,6 +2,8 @@ use Wcms\Medialist; +use function Clue\StreamFilter\fun; + function readablesize($bytes) { $format = ' %d %s'; @@ -292,7 +294,29 @@ function recurse_copy($src,$dst) { } } closedir($dir); -} +} + +/** + * Generate a list of <options> html drop down list + * + * @param array $options as `value => title` + * @param string|int $selected value of actualy selected option + * + * @return string HTML list of options + */ +function options(array $options, $selected = null) : string +{ + $html = ''; + foreach ($options as $value => $title) { + if($value == $selected) { + $attribute = 'selected'; + } else { + $attribute = ''; + } + $html .= '<option value="' . $value . '" ' . $attribute . '>' . $title . '</option>' . PHP_EOL; + } + return $html; +} |