diff --git a/application/dashlet.class.inc.php b/application/dashlet.class.inc.php index 2e2945fa4..14876bfc9 100644 --- a/application/dashlet.class.inc.php +++ b/application/dashlet.class.inc.php @@ -16,6 +16,7 @@ // You should have received a copy of the GNU Affero General Public License // along with iTop. If not, see +use Combodo\iTop\Application\Helper\WebResourcesHelper; use Combodo\iTop\Application\UI\Base\Component\Dashlet\DashletContainer; use Combodo\iTop\Application\UI\Base\Component\Dashlet\DashletFactory; use Combodo\iTop\Application\UI\Base\Component\Html\Html; @@ -1702,10 +1703,7 @@ class DashletGroupByPie extends DashletGroupBy { return array_merge( parent::GetJSFilesRelPaths(), - [ - 'js/d3.js', - 'js/c3.js', - ] + WebResourcesHelper::GetJSFilesRelPathsForC3JS() ); } @@ -1716,9 +1714,7 @@ class DashletGroupByPie extends DashletGroupBy { return array_merge( parent::GetCSSFilesRelPaths(), - [ - 'css/c3.min.css', - ] + WebResourcesHelper::GetCSSFilesRelPathsForC3JS() ); } diff --git a/pages/csvimport.php b/pages/csvimport.php index 896dbe3eb..2f9e6d609 100644 --- a/pages/csvimport.php +++ b/pages/csvimport.php @@ -4,6 +4,7 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ +use Combodo\iTop\Application\Helper\WebResourcesHelper; use Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\CollapsibleSection\CollapsibleSectionUIBlockFactory; @@ -663,9 +664,7 @@ EOF $sUnchanged = json_encode(Dict::Format('UI:CSVImportUnchanged_items', $iUnchanged)); // Add graphs dependencies - $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/c3.min.css'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/d3.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/c3.js'); + WebResourcesHelper::EnableC3JSToWebPage($oPage); $oPage->add_script( <<< EOF diff --git a/pages/schema.php b/pages/schema.php index 25c41c2a2..67c757a67 100644 --- a/pages/schema.php +++ b/pages/schema.php @@ -4,6 +4,7 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ +use Combodo\iTop\Application\Helper\WebResourcesHelper; use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Input\Select\Select; @@ -538,9 +539,7 @@ function DisplayRelatedClassesGraph($oPage, $sClass) // 3) Processing data and building graph // // - Add graphs dependencies - $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/c3.min.css'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/d3.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/c3.js'); + WebResourcesHelper::EnableC3JSToWebPage($oPage); // - Add markup $oPage->add( <<add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().$sFile); + } + + foreach (static::GetJSFilesRelPathsForC3JS() as $sFile) { + $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().$sFile); + } + } + + /** + * @return string[] Relative URLs to the CSS files necessary for d3/c3.js + */ + public static function GetCSSFilesRelPathsForC3JS(): array + { + return [ + 'css/c3.min.css', + ]; + } + + /** + * @return string[] Relative URLs to the JS files necessary for d3/c3.js + */ + public static function GetJSFilesRelPathsForC3JS(): array + { + return [ + 'js/d3.js', + 'js/c3.js', + ]; + } + /** * Add necessary files (JS/CSS) to be able to use simple_graph in the page *