Moved to JHtml loading the CSS and JS files found in the media folder of the component.

This commit is contained in:
2022-05-19 15:34:11 +02:00
parent c99cb17c5b
commit 6e4443b997
11 changed files with 98 additions and 135 deletions

View File

@ -8621,11 +8621,11 @@ class Get
*/
protected function getPowers($guids)
{
if (ArrayHelper::check($guids, true))
if (ArrayHelper::check($guids))
{
foreach ($guids as $guid)
foreach ($guids as $guid => $build)
{
$this->getPower($guid);
$this->getPower($guid, $build);
}
}
}
@ -8636,9 +8636,9 @@ class Get
* @return mixed
*
*/
public function getPower($guid)
public function getPower($guid, $build = 0)
{
if ($this->addPower && $this->setPower($guid))
if (($this->addPower || $build == 1) && $this->setPower($guid))
{
return $this->powers[$guid];
}
@ -8805,6 +8805,7 @@ class Get
}
// load use ids
$use = array();
$as = array();
// check if we have use selection
$power->use_selection = (isset($power->use_selection)
&& JsonHelper::check(
@ -8812,7 +8813,10 @@ class Get
)) ? json_decode($power->use_selection, true) : null;
if ($power->use_selection)
{
$use = array_values(array_map(function ($u) {
$use = array_values(array_map(function ($u) use(&$as) {
// track the AS options
$as[$u['use']] = (string) $u['as'];
// return the guid
return $u['use'];
}, $power->use_selection));
}
@ -8857,7 +8861,7 @@ class Get
if ($this->setPower($implement))
{
// get the name
$power->implement_names[] = $this->getPower($implement)->class_name;
$power->implement_names[] = $this->getPower($implement, 1)->class_name;
// add to use
$use[] = $implement;
}
@ -8884,7 +8888,7 @@ class Get
if ($this->setPower($power->extends))
{
// get the name
$power->extends_name = $this->getPower($power->extends)->class_name;
$power->extends_name = $this->getPower($power->extends, 1)->class_name;
// add to use
$use[] = $power->extends;
}
@ -8915,11 +8919,19 @@ class Get
{
if ($this->setPower($u))
{
$add_use = $this->getPower($u)->namespace;
$add_use = $this->getPower($u, 1)->namespace;
// check if it is already added manually, you know how some people are
if (strpos($power->head, $add_use) === false)
{
$power->head .= 'use ' . $add_use . ';' . PHP_EOL;
// check if it has an AS option
if (isset($as[$u]) && StringHelper::check($as[$u]) && $as[$u] !== 'default')
{
$power->head .= 'use ' . $add_use . ' as ' . $as[$u] . ';' . PHP_EOL;
}
else
{
$power->head .= 'use ' . $add_use . ';' . PHP_EOL;
}
}
}
}

View File

@ -6217,21 +6217,12 @@ class Interpretation extends Fields
$chart[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " load the google chart js.";
$chart[] = $this->_t(2)
. "\$this->document->addScript(JURI::root(true) .'/media/com_"
. $this->componentCodeName . "/js/google.jsapi.js', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
. "JHtml::_('script', 'com_"
. $this->componentCodeName . "/js/google.jsapi.js', ['version' => 'auto']);";
$chart[] = $this->_t(2)
. "\$this->document->addScript('https://canvg.googlecode.com/svn/trunk/rgbcolor.js', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
. "\$this->document->addScript('https://canvg.googlecode.com/svn/trunk/rgbcolor.js', ['version' => 'auto']);";
$chart[] = $this->_t(2)
. "\$this->document->addScript('https://canvg.googlecode.com/svn/trunk/canvg.js', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
. "\$this->document->addScript('https://canvg.googlecode.com/svn/trunk/canvg.js', ['version' => 'auto']);";
return implode(PHP_EOL, $chart);
}
@ -6635,12 +6626,9 @@ class Interpretation extends Fields
. "if ((!\$HeaderCheck->css_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)";
$setter .= PHP_EOL . $tabV . $this->_t(2) . "{";
$setter .= PHP_EOL . $tabV . $this->_t(3)
. "\$this->document->addStyleSheet(JURI::root(true) .'/media/com_"
. "JHtml::_('stylesheet', 'com_"
. $this->componentCodeName
. "/uikit-v2/css/uikit'.\$style.\$size.'.css', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');";
. "/uikit-v2/css/uikit'.\$style.\$size.'.css', ['version' => 'auto']);";
$setter .= PHP_EOL . $tabV . $this->_t(2) . "}";
$setter .= PHP_EOL . $tabV . $this->_t(2) . "//" . $this->setLine(
__LINE__
@ -6649,12 +6637,9 @@ class Interpretation extends Fields
. "if ((!\$HeaderCheck->js_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)";
$setter .= PHP_EOL . $tabV . $this->_t(2) . "{";
$setter .= PHP_EOL . $tabV . $this->_t(3)
. "\$this->document->addScript(JURI::root(true) .'/media/com_"
. "JHtml::_('script', 'com_"
. $this->componentCodeName
. "/uikit-v2/js/uikit'.\$size.'.js', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
. "/uikit-v2/js/uikit'.\$size.'.js', ['version' => 'auto']);";
$setter .= PHP_EOL . $tabV . $this->_t(2) . "}";
}
// load the components need
@ -6748,12 +6733,9 @@ class Interpretation extends Fields
__LINE__
) . " load the css.";
$setter .= PHP_EOL . $tabV . $this->_t(6)
. "\$this->document->addStyleSheet(JURI::root(true) .'/media/com_"
. "JHtml::_('stylesheet', 'com_"
. $this->componentCodeName
. "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');";
. "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css', ['version' => 'auto']);";
$setter .= PHP_EOL . $tabV . $this->_t(5) . "}";
$setter .= PHP_EOL . $tabV . $this->_t(5) . "//" . $this->setLine(
__LINE__
@ -6767,15 +6749,9 @@ class Interpretation extends Fields
__LINE__
) . " load the js.";
$setter .= PHP_EOL . $tabV . $this->_t(6)
. "\$this->document->addScript(JURI::root(true) .'/media/com_"
. "JHtml::_('script', 'com_"
. $this->componentCodeName
. "/uikit-v2/js/components/'.\$name.\$size.'.js', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true);";
. "/uikit-v2/js/components/'.\$name.\$size.'.js', ['version' => 'auto'], ['type' => 'text/javascript', 'async' => 'async']);";
$setter .= PHP_EOL . $tabV . $this->_t(5) . "}";
$setter .= PHP_EOL . $tabV . $this->_t(4) . "}";
$setter .= PHP_EOL . $tabV . $this->_t(3) . "}";
@ -6819,12 +6795,9 @@ class Interpretation extends Fields
__LINE__
) . " load the css.";
$setter .= PHP_EOL . $tabV . $this->_t(6)
. "\$this->document->addStyleSheet(JURI::root(true) .'/media/com_"
. "JHtml::_('stylesheet', 'com_"
. $this->componentCodeName
. "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');";
. "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css', ['version' => 'auto']);";
$setter .= PHP_EOL . $tabV . $this->_t(5) . "}";
$setter .= PHP_EOL . $tabV . $this->_t(5) . "//" . $this->setLine(
__LINE__
@ -6838,7 +6811,7 @@ class Interpretation extends Fields
__LINE__
) . " load the js.";
$setter .= PHP_EOL . $tabV . $this->_t(6)
. "\$this->document->addScript(JURI::root(true) .'/media/com_"
. "JHtml::_('script', JURI::root(true) .'/media/com_"
. $this->componentCodeName
. "/uikit-v2/js/components/'.\$name.\$size.'.js', ("
. $this->fileContentStatic[$this->hhh . 'Component'
@ -6873,12 +6846,9 @@ class Interpretation extends Fields
. "if ((!\$HeaderCheck->css_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)";
$setter .= PHP_EOL . $tabV . $this->_t(2) . "{";
$setter .= PHP_EOL . $tabV . $this->_t(3)
. "\$this->document->addStyleSheet(JURI::root(true) .'/media/com_"
. "JHtml::_('stylesheet', 'com_"
. $this->componentCodeName
. "/uikit-v3/css/uikit'.\$size.'.css', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');";
. "/uikit-v3/css/uikit'.\$size.'.css', ['version' => 'auto']);";
$setter .= PHP_EOL . $tabV . $this->_t(2) . "}";
$setter .= PHP_EOL . $tabV . $this->_t(2) . "//" . $this->setLine(
__LINE__
@ -6887,19 +6857,13 @@ class Interpretation extends Fields
. "if ((!\$HeaderCheck->js_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)";
$setter .= PHP_EOL . $tabV . $this->_t(2) . "{";
$setter .= PHP_EOL . $tabV . $this->_t(3)
. "\$this->document->addScript(JURI::root(true) .'/media/com_"
. "JHtml::_('script', 'com_"
. $this->componentCodeName
. "/uikit-v3/js/uikit'.\$size.'.js', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
. "/uikit-v3/js/uikit'.\$size.'.js', ['version' => 'auto']);";
$setter .= PHP_EOL . $tabV . $this->_t(3)
. "\$this->document->addScript(JURI::root(true) .'/media/com_"
. "JHtml::_('script', 'com_"
. $this->componentCodeName
. "/uikit-v3/js/uikit-icons'.\$size.'.js', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
. "/uikit-v3/js/uikit-icons'.\$size.'.js', ['version' => 'auto']);";
$setter .= PHP_EOL . $tabV . $this->_t(2) . "}";
if (2 == $this->uikit)
{
@ -14146,12 +14110,9 @@ class Interpretation extends Fields
__LINE__
) . " Add the CSS for Footable.";
$foo .= PHP_EOL . $this->_t(2)
. "\$this->document->addStyleSheet(JURI::root() .'media/com_"
. "JHtml::_('stylesheet', 'com_"
. $this->componentCodeName
. "/footable-v2/css/footable.core.min.css', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');";
. "/footable-v2/css/footable.core.min.css', ['version' => 'auto']);";
$foo .= PHP_EOL . PHP_EOL . $this->_t(2) . "//" . $this->setLine(
__LINE__
) . " Use the Metro Style";
@ -14159,12 +14120,9 @@ class Interpretation extends Fields
. "if (!isset(\$this->fooTableStyle) || 0 == \$this->fooTableStyle)";
$foo .= PHP_EOL . $this->_t(2) . "{";
$foo .= PHP_EOL . $this->_t(3)
. "\$this->document->addStyleSheet(JURI::root() .'media/com_"
. "JHtml::_('stylesheet', 'com_"
. $this->componentCodeName
. "/footable-v2/css/footable.metro.min.css', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');";
. "/footable-v2/css/footable.metro.min.css', ['version' => 'auto']);";
$foo .= PHP_EOL . $this->_t(2) . "}";
$foo .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__)
. " Use the Legacy Style.";
@ -14172,43 +14130,28 @@ class Interpretation extends Fields
. "elseif (isset(\$this->fooTableStyle) && 1 == \$this->fooTableStyle)";
$foo .= PHP_EOL . $this->_t(2) . "{";
$foo .= PHP_EOL . $this->_t(3)
. "\$this->document->addStyleSheet(JURI::root() .'media/com_"
. "JHtml::_('stylesheet', 'com_"
. $this->componentCodeName
. "/footable-v2/css/footable.standalone.min.css', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');";
. "/footable-v2/css/footable.standalone.min.css', ['version' => 'auto']);";
$foo .= PHP_EOL . $this->_t(2) . "}";
$foo .= PHP_EOL . PHP_EOL . $this->_t(2) . "//" . $this->setLine(
__LINE__
) . " Add the JavaScript for Footable";
$foo .= PHP_EOL . $this->_t(2)
. "\$this->document->addScript(JURI::root() .'media/com_"
. $this->componentCodeName . "/footable-v2/js/footable.js', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
. "JHtml::_('script', 'com_"
. $this->componentCodeName . "/footable-v2/js/footable.js', ['version' => 'auto']);";
$foo .= PHP_EOL . $this->_t(2)
. "\$this->document->addScript(JURI::root() .'media/com_"
. "JHtml::_('script', 'com_"
. $this->componentCodeName
. "/footable-v2/js/footable.sort.js', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
. "/footable-v2/js/footable.sort.js', ['version' => 'auto']);";
$foo .= PHP_EOL . $this->_t(2)
. "\$this->document->addScript(JURI::root() .'media/com_"
. "JHtml::_('script', 'com_"
. $this->componentCodeName
. "/footable-v2/js/footable.filter.js', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
. "/footable-v2/js/footable.filter.js', ['version' => 'auto']);";
$foo .= PHP_EOL . $this->_t(2)
. "\$this->document->addScript(JURI::root() .'media/com_"
. "JHtml::_('script', 'com_"
. $this->componentCodeName
. "/footable-v2/js/footable.paginate.js', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
. "/footable-v2/js/footable.paginate.js', ['version' => 'auto']);";
if ($init)
{
$foo .= PHP_EOL . PHP_EOL . $this->_t(2)
@ -14232,21 +14175,15 @@ class Interpretation extends Fields
$foo .= PHP_EOL . $this->_t(2)
. "\$this->document->addStyleSheet('https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css');";
$foo .= PHP_EOL . $this->_t(2)
. "\$this->document->addStyleSheet(JURI::root() .'media/com_"
. "JHtml::_('stylesheet', 'com_"
. $this->componentCodeName
. "/footable-v3/css/footable.standalone.min.css', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');";
. "/footable-v3/css/footable.standalone.min.css', ['version' => 'auto']);";
$foo .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__)
. " Add the JavaScript for Footable (adding all funtions)";
. " Add the JavaScript for Footable (adding all functions)";
$foo .= PHP_EOL . $this->_t(2)
. "\$this->document->addScript(JURI::root() .'media/com_"
. "JHtml::_('script', 'com_"
. $this->componentCodeName
. "/footable-v3/js/footable.min.js', ("
. $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh]
. "Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');";
. "/footable-v3/js/footable.min.js', ['version' => 'auto']);";
if ($init)
{
$foo .= PHP_EOL . PHP_EOL . $this->_t(2)