Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style cleanup #259

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 43 additions & 32 deletions inc/html.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,45 @@ static function displayProgressBar($width, $percent, $options = [])
}
}

/* Returns a list of CSS files to include for plugins
*
* @return array
*/
static function getPluginsCss() {
global $PLUGIN_HOOKS;
$css = [];
if (isset($PLUGIN_HOOKS['add_css']) && count($PLUGIN_HOOKS['add_css'])) {
foreach ($PLUGIN_HOOKS["add_css"] as $plugin => $files) {
if (!Plugin::isPluginActive($plugin)) {
continue;
}

$plugin_root_dir = Plugin::getPhpDir($plugin, true);
$plugin_web_dir = Plugin::getWebDir($plugin, false);
$version = Plugin::getInfo($plugin, 'version');

if (!is_array($files)) {
$files = [$files];
}

foreach ($files as $file) {
$filename = "$plugin_root_dir/$file";

if (!file_exists($filename)) {
continue;
}

if ('scss' === substr(strrchr($filename, '.'), 1)) {
$css[] = Html::scss("$plugin_web_dir/$file", ['version' => $version]);
} else {
$css[] = Html::css("$plugin_web_dir/$file", ['version' => $version]);
}
}
}
}
return $css;
}


/**
* Include common HTML headers
Expand Down Expand Up @@ -1453,6 +1492,7 @@ static function includeHeader($title = '', $sector = 'none', $item = 'none', $op

// CSS link
echo Html::scss('css/styles');
echo Html::scss('css/colors');
echo Html::scss('css/itsm2');
if (isset($_SESSION['glpihighcontrast_css']) && $_SESSION['glpihighcontrast_css']) {
echo Html::scss('css/highcontrast');
Expand All @@ -1462,40 +1502,11 @@ static function includeHeader($title = '', $sector = 'none', $item = 'none', $op
echo "<link rel='shortcut icon' type='images/x-icon' href='" .
$CFG_GLPI["root_doc"] . "/pics/favicon.ico' >\n";

// Add specific css for plugins
if (isset($PLUGIN_HOOKS['add_css']) && count($PLUGIN_HOOKS['add_css'])) {

foreach ($PLUGIN_HOOKS["add_css"] as $plugin => $files) {
if (!Plugin::isPluginActive($plugin)) {
continue;
}

$plugin_root_dir = Plugin::getPhpDir($plugin, true);
$plugin_web_dir = Plugin::getWebDir($plugin, false);
$version = Plugin::getInfo($plugin, 'version');

if (!is_array($files)) {
$files = [$files];
}

foreach ($files as $file) {
$filename = "$plugin_root_dir/$file";

if (!file_exists($filename)) {
continue;
}

if ('scss' === substr(strrchr($filename, '.'), 1)) {
echo Html::scss("$plugin_web_dir/$file", ['version' => $version]);
} else {
echo Html::css("$plugin_web_dir/$file", ['version' => $version]);
}
}
}
$pluginCss = self::getPluginsCss();
foreach ($pluginCss as $css) {
echo $css;
}

echo Html::scss('css/palettes/' . $theme);

// Custom CSS for active entity
if ($DB instanceof DBmysql && $DB->connected) {
$entity = new Entity();
Expand Down
5 changes: 4 additions & 1 deletion inc/itsmnguploadhandler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class ItsmngUploadHandler {
static function getUploadPath($type, $filename, $withDir = true) {
$extension = strtoupper(pathinfo($filename, PATHINFO_EXTENSION));
switch ($type) {
case self::UPLOAD:
$upload_path = '_uploads';
break;
case self::TMP:
$upload_path = '_tmp';
break;
Expand All @@ -62,7 +65,7 @@ static function getUploadPath($type, $filename, $withDir = true) {
$upload_path = '_dumps';
break;
default:
$upload_path = '_uploads';
$upload_path = $type;
break;
}
if (!file_exists(GLPI_DOC_DIR . $upload_path . '/' . $extension)) {
Expand Down
10 changes: 4 additions & 6 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@
CronTask::callCronForce();
}


try {
renderTwigTemplate('index.twig', ["root_doc" => $CFG_GLPI['root_doc'], 'header_data' => $header_data] + $twig_vars);
} catch (\Exception $e) {
echo $e->getMessage();
}
renderTwigTemplate('index.twig', [
"root_doc" => $CFG_GLPI['root_doc'],
'header_data' => $header_data
] + $twig_vars);
Loading