Skip to content

Commit 1902cb2

Browse files
committed
feat(form): icon dropdown list included in the project
svg no longer in Font Awesome 6; an API is provided to get data we need, but it timeouts too often with 5 seconds
1 parent 85609c4 commit 1902cb2

File tree

6 files changed

+2
-128
lines changed

6 files changed

+2
-128
lines changed

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ vendor/
99
/.gtm/
1010
lib/
1111

12-
# Ignore content of data except for the index
13-
data/*
14-
!data/index.php
15-
1612
# Ignore content of data except for the index
1713
css_compiled/*
1814
!css_compiled/remove.txt

ajax/target_actor.php

Lines changed: 0 additions & 67 deletions
This file was deleted.

hook.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -610,19 +610,6 @@ function plugin_formcreator_dynamicReport($params) {
610610
return false;
611611
}
612612

613-
function plugin_formcreator_hook_update_plugin(CommonDBTM $item) {
614-
if ($item->fields['directory'] != 'formcreator') {
615-
return;
616-
}
617-
618-
if ($item->fields['state'] != Plugin::ACTIVATED) {
619-
return;
620-
}
621-
622-
// This is Formcreator, and its state switched to enabled
623-
PluginFormcreatorCommon::buildFontAwesomeData();
624-
}
625-
626613
/**
627614
* Hook for timeline_actions; display a new action for a CommonITILObject
628615
* @see CommonITILObject

inc/common.class.php

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ public static function prepareBooleanKeywords(string $keywords) : string {
157157
*
158158
* @return array
159159
*/
160-
public static function getFontAwesomePictoNames() : array {
160+
public static function getFontAwesomePictoNames(): array {
161161
static $list = null;
162162

163-
$list = $list ?? require_once(GLPI_PLUGIN_DOC_DIR . '/formcreator/' . self::getPictoFilename());
163+
$list = $list ?? require_once(Plugin::getPhpDir('formcreator') . '/data/' . self::getPictoFilename());
164164
return $list;
165165
}
166166

@@ -541,39 +541,6 @@ public static function cleanOldCaptchas($expiration = 600) {
541541
}
542542
}
543543

544-
public static function buildFontAwesomeData() {
545-
$fontAwesomeDir = GLPI_ROOT . '/public/lib/fortawesome/fontawesome-free/webfonts';
546-
$outFile = GLPI_PLUGIN_DOC_DIR . '/formcreator/font-awesome.php';
547-
@mkdir(dirname($outFile));
548-
if (!is_readable($fontAwesomeDir) || !is_writable(dirname($outFile))) {
549-
return false;
550-
}
551-
552-
$faSvgFiles = [
553-
'fa' => "$fontAwesomeDir/fa-regular-400.svg",
554-
'fab' => "$fontAwesomeDir/fa-brands-400.svg",
555-
'fas' => "$fontAwesomeDir/fa-solid-900.svg",
556-
];
557-
558-
$fanames = [];
559-
$searchRegex = '#glyph-name=\"([^\"]*)\"#i';
560-
foreach ($faSvgFiles as $key => $svgSource) {
561-
$svg = file_get_contents($svgSource);
562-
$matches = null;
563-
preg_match_all($searchRegex, $svg, $matches);
564-
foreach ($matches[1] as $name) {
565-
$fanames["$key fa-$name"] = $name;
566-
}
567-
$list = '<?php' . PHP_EOL . 'return ' . var_export($fanames, true) . ';';
568-
$size = file_put_contents($outFile, $list);
569-
if ($size != strlen($list)) {
570-
return false;
571-
}
572-
}
573-
574-
return true;
575-
}
576-
577544
/**
578545
* get path to CSS file
579546
*

setup.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ function plugin_formcreator_permanent_hook() {
283283
$PLUGIN_HOOKS['item_update']['formcreator'] = [
284284
Ticket::class => 'plugin_formcreator_hook_update_ticket',
285285
TicketValidation::class => 'plugin_formcreator_hook_update_ticketvalidation',
286-
Plugin::class => 'plugin_formcreator_hook_update_plugin',
287286
Profile::class => 'plugin_formcreator_hook_update_profile',
288287
];
289288
$PLUGIN_HOOKS['item_delete']['formcreator'] = [

tests/1-install/Config.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ public function testUpgradedPlugin() {
124124

125125
// Check the version saved in configuration
126126
$this->checkConfig();
127-
$this->checkFontAwesomeData();
128127
$this->testPluginName();
129128

130129
$fresh_tables = $DB->listTables("glpi_plugin_${pluginName}_%");
@@ -188,13 +187,6 @@ public function checkAutomaticAction() {
188187
$this->integer((int) $cronTask->fields['state'])->isEqualTo(0);
189188
}
190189

191-
public function checkFontAwesomeData() {
192-
$pluginName = TEST_PLUGIN_NAME;
193-
194-
$file = GLPI_ROOT . '/files/_plugins/' . $pluginName . '/font-awesome.php';
195-
$this->boolean(is_readable($file))->isTrue();
196-
}
197-
198190
/**
199191
* Undocumented function
200192
*

0 commit comments

Comments
 (0)