本文整理汇总了PHP中Media::getJSPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Media::getJSPath方法的具体用法?PHP Media::getJSPath怎么用?PHP Media::getJSPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Media
的用法示例。
在下文中一共展示了Media::getJSPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getJqueryPluginPath
/**
* return jquery plugin path.
*
* @param mixed $name
* @return string|boolean
*/
public static function getJqueryPluginPath($name, $folder = null)
{
$plugin_path = array('js' => array(), 'css' => array());
if ($folder === null) {
$folder = _PS_JS_DIR_ . 'jquery/plugins/';
}
//set default folder
$file = 'jquery.' . $name . '.js';
$url_data = parse_url($folder);
$file_uri = _PS_ROOT_DIR_ . Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']);
$file_uri_host_mode = _PS_CORE_DIR_ . Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']);
if (@file_exists($file_uri . $file) || defined('_PS_HOST_MODE_') && @file_exists($file_uri_host_mode . $file)) {
$plugin_path['js'] = Media::getJSPath($folder . $file);
} elseif (@file_exists($file_uri . $name . '/' . $file) || defined('_PS_HOST_MODE_') && @file_exists($file_uri_host_mode . $name . '/' . $file)) {
$plugin_path['js'] = Media::getJSPath($folder . $name . '/' . $file);
} else {
return false;
}
$plugin_path['css'] = Media::getJqueryPluginCSSPath($name, $folder);
return $plugin_path;
}
示例2: removeJS
public function removeJS($js_uri)
{
if (is_array($js_uri)) {
foreach ($js_uri as $js_file) {
$js_path = Media::getJSPath($js_file);
if ($js_path && in_array($js_path, $this->js_files)) {
unset($this->js_files[array_search($js_path, $this->js_files)]);
}
}
} else {
$js_path = Media::getJSPath($js_uri);
if ($js_path) {
unset($this->js_files[array_search($js_path, $this->js_files)]);
}
}
}
示例3: addJS
/**
* Add a new javascript file in page header.
*
* @param mixed $js_uri
* @return void
*/
public function addJS($js_uri)
{
if (is_array($js_uri)) {
foreach ($js_uri as $js_file) {
$js_path = Media::getJSPath($js_file);
if ($js_path && !in_array($js_path, $this->js_files)) {
$this->js_files[] = $js_path;
}
}
} else {
$js_path = Media::getJSPath($js_uri);
if ($js_path) {
$this->js_files[] = $js_path;
}
}
}