本文整理汇总了PHP中javascript_path函数的典型用法代码示例。如果您正苦于以下问题:PHP javascript_path函数的具体用法?PHP javascript_path怎么用?PHP javascript_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了javascript_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_combined_javascripts
/**
* Returns <script> tags for all javascripts configured in view.yml or added to the response object.
*
* You can use this helper to decide the location of javascripts in pages.
* By default, if you don't call this helper, symfony will automatically include javascripts before </head>.
* Calling this helper disables this behavior.
*
* @return string <script> tags
*/
function get_combined_javascripts()
{
if (!sfConfig::get('app_sfCombinePlugin_enabled', false)) {
return get_javascripts();
}
sfConfig::set('symfony.asset.javascripts_included', true);
$html = '';
$jsFiles = array();
$regularJsFiles = array();
$response = sfContext::getInstance()->getResponse();
$config = sfConfig::get('app_sfCombinePlugin_js', array());
$doNotCombine = isset($config['combine_skip']) ? $config['combine_skip'] : array();
foreach ($response->getJavascripts() as $files => $options) {
if (!is_array($files)) {
$files = array($files);
}
// check for js files that should not be combined
foreach ($files as $key => $value) {
if (skip_asset($value, $doNotCombine)) {
array_push($regularJsFiles, $value);
unset($files[$key]);
}
}
$jsFiles = array_merge($jsFiles, $files);
}
if (!empty($jsFiles)) {
$html .= str_replace(array('.js', '.pjs'), '', javascript_include_tag(url_for('sfCombine/js?key=' . _get_key($jsFiles))));
}
foreach ($regularJsFiles as $file) {
$file = javascript_path($file);
$html .= javascript_include_tag($file);
}
return $html;
}
示例2: javascript_include_tag
function javascript_include_tag($sources)
{
if (!is_array($sources)) {
$sources = array($sources);
}
$html = '';
foreach ($sources as $source) {
$html .= '<script src="' . javascript_path($source) . '" type="text/javascript"></script>' . "\n";
}
return $html;
}
示例3: javascript_include_tag
function javascript_include_tag()
{
$args = func_get_args();
$out = '';
if (empty($args)) {
if (file_exists(DOC_ROOT . '/' . javascript_path('application'))) {
$out .= "<script src=\"" . javascript_path('application') . "\" type=\"text/javascript\" /></script>\n";
}
$out .= "<script src=\"" . javascript_path('prototype') . "\" type=\"text/javascript\" /></script>\n";
} else {
foreach ($args as $k => $v) {
$out .= "<script src=\"" . javascript_path($v) . "\" type=\"text/javascript\" /></script>\n";
}
}
return $out;
}
示例4: minify_get_javascripts
function minify_get_javascripts($position_array = array('first', '', 'last'), $debug = false, $my_already_seen = array())
{
$response = sfContext::getInstance()->getResponse();
$app_static_url = sfConfig::get('app_static_url');
$already_seen = $my_already_seen;
$minify_files = array();
$external_files = array();
foreach ($position_array as $position) {
foreach ($response->getJavascripts($position) as $files) {
if (!is_array($files)) {
$files = array($files);
}
$options = array_merge(array('type' => 'text/javascript'));
foreach ($files as $file) {
// be sure to normalize files with .js at the end
$file .= substr($file, -3) === '.js' ? '' : '.js';
if (isset($already_seen[$file])) {
continue;
}
$already_seen[$file] = 1;
// check if the javascript is on this server // TODO better handle + what if user wants to precisely place the call??
if (preg_match('/http(s)?:\\/\\//', $file)) {
$external_files[] = $file;
break;
}
$file = javascript_path($file);
$type = serialize($options);
if (isset($minify_files[$type])) {
array_push($minify_files[$type], $file);
} else {
$minify_files[$type] = array($file);
}
}
}
}
$html = '';
foreach ($external_files as $file) {
$html .= javascript_include_tag($file);
}
foreach ($minify_files as $options => $files) {
$options = unserialize($options);
$options['src'] = minify_get_combined_files_url($files, $debug);
$html .= content_tag('script', '', $options) . "\n";
}
return $html;
}
示例5: _include_javascripts
function _include_javascripts($position_array = array('first', '', 'last'), $debug = false, $my_already_seen = array())
{
$response = sfContext::getInstance()->getResponse();
$static_base_url = sfConfig::get('app_static_url');
$already_seen = $my_already_seen;
$internal_files = array();
$external_files = array();
foreach ($position_array as $position) {
foreach ($response->getJavascripts($position) as $files) {
if (!is_array($files)) {
$files = array($files);
}
foreach ($files as $file) {
// be sure to normalize files with .js at the end
$file .= substr($file, -3) === '.js' ? '' : '.js';
if (isset($already_seen[$file])) {
continue;
}
$already_seen[$file] = 1;
// check if the javascript is on this server // TODO better handle + what if user wants to precisely place the call??
if (preg_match('/http(s)?:\\/\\//', $file)) {
$external_files[] = $file;
break;
}
$file = javascript_path($file);
$internal_files[] = $file;
}
}
}
$html = '';
foreach ($external_files as $file) {
$html .= javascript_include_tag($file);
}
foreach ($internal_files as $file) {
$prefix = $debug ? '/no' : '';
$ts = sfTimestamp::getTimestamp($file);
if (!empty($ts)) {
$file = '/' . $ts . $prefix . $file;
} else {
$file = $prefix . $file;
}
$html .= javascript_include_tag($static_base_url . $file);
}
return $html;
}
示例6: toHTML
/**
* Returns the rich text editor as HTML.
*
* @return string Rich text editor HTML representation
*/
public function toHTML()
{
$options = $this->options;
// we need to know the id for things the rich text editor
// in advance of building the tag
$id = _get_option($options, 'id', $this->name);
$php_file = sfConfig::get('sf_rich_text_fck_js_dir') . DIRECTORY_SEPARATOR . 'fckeditor.php';
if (!is_readable(sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $php_file)) {
throw new sfConfigurationException('You must install FCKEditor to use this helper (see rich_text_fck_js_dir settings).');
}
// FCKEditor.php class is written with backward compatibility of PHP4.
// This reportings are to turn off errors with public properties and already declared constructor
$error_reporting = error_reporting(E_ALL);
require_once sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $php_file;
// turn error reporting back to your settings
error_reporting($error_reporting);
$fckeditor = new FCKeditor($this->name);
$fckeditor->BasePath = sfContext::getInstance()->getRequest()->getRelativeUrlRoot() . '/' . sfConfig::get('sf_rich_text_fck_js_dir') . '/';
$fckeditor->Value = $this->content;
if (isset($options['width'])) {
$fckeditor->Width = $options['width'];
} elseif (isset($options['cols'])) {
$fckeditor->Width = (string) ((int) $options['cols'] * 10) . 'px';
}
if (isset($options['height'])) {
$fckeditor->Height = $options['height'];
} elseif (isset($options['rows'])) {
$fckeditor->Height = (string) ((int) $options['rows'] * 10) . 'px';
}
if (isset($options['tool'])) {
$fckeditor->ToolbarSet = $options['tool'];
}
if (isset($options['config'])) {
$fckeditor->Config['CustomConfigurationsPath'] = javascript_path($options['config']);
}
$content = $fckeditor->CreateHtml();
if (sfConfig::get('sf_compat_10')) {
// fix for http://trac.symfony-project.com/ticket/732
// fields need to be of type text to be picked up by fillin. they are hidden by inline css anyway:
// <input type="hidden" id="name" name="name" style="display:none" value="<p>default</p>">
$content = str_replace('type="hidden"', 'type="text"', $content);
}
return $content;
}
示例7: toHTML
/**
* Returns the rich text editor as HTML.
*
* @return string Rich text editor HTML representation
*/
public function toHTML()
{
$options = $this->options;
// we need to know the id for things the rich text editor
// in advance of building the tag
$id = _get_option($options, 'id', $this->name);
$php_file = sfConfig::get('sf_rich_text_fck_js_dir') . DIRECTORY_SEPARATOR . 'fckeditor.php';
if (!is_readable(sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $php_file)) {
throw new sfConfigurationException('You must install FCKEditor to use this helper (see rich_text_fck_js_dir settings).');
}
// FCKEditor.php class is written with backward compatibility of PHP4.
// This reportings are to turn off errors with public properties and already declared constructor
$error_reporting = ini_get('error_reporting');
error_reporting(E_ALL);
require_once sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $php_file;
// turn error reporting back to your settings
error_reporting($error_reporting);
$fckeditor = new FCKeditor($this->name);
$fckeditor->BasePath = sfContext::getInstance()->getRequest()->getRelativeUrlRoot() . '/' . sfConfig::get('sf_rich_text_fck_js_dir') . '/';
$fckeditor->Value = $this->content;
if (isset($options['width'])) {
$fckeditor->Width = $options['width'];
} elseif (isset($options['cols'])) {
$fckeditor->Width = (string) ((int) $options['cols'] * 10) . 'px';
}
if (isset($options['height'])) {
$fckeditor->Height = $options['height'];
} elseif (isset($options['rows'])) {
$fckeditor->Height = (string) ((int) $options['rows'] * 10) . 'px';
}
if (isset($options['tool'])) {
$fckeditor->ToolbarSet = $options['tool'];
}
if (isset($options['config'])) {
$fckeditor->Config['CustomConfigurationsPath'] = javascript_path($options['config']);
}
$content = $fckeditor->CreateHtml();
return $content;
}
示例8: get_combined_javascripts
/**
* Get the combined Javascripts in script links. Can get all groups or a
* selection. Calling this method will stop symfony automatically inserting
* scripts
*
*
* @param mixed $groupsUse (Optional) A string or array of groups to
* include or exclude. Null for this to be
* ignored. Default null.
* @param int $groupsUseType (Optional) The type of grouping either
* sfCombinePlusManager::GROUP_INCLUDE or
* sfCombinePlusManager::GROUP_EXCLUDE.
* These dictate whether the group(s) in
* the previous argument should be marked
* as used or every group marked as used.
* Default sfCombinePlusManager::GROUP_INCLUDE
* @param bool $onlyUnusedGroups (Optional) Only use unused groups. Default
* true.
* @param bool $markGroupsUsed (Optional) Mark the groups that are used
* as used. Default true.
* @return string
*/
function get_combined_javascripts($groups = null, $groupType = sfCombinePlusManager::GROUP_INCLUDE, $onlyUnusedGroups = true, $markGroupsUsed = true)
{
if (!sfConfig::get('app_sfCombinePlusPlugin_enabled', false)) {
return get_javascripts();
}
$manager = sfCombinePlusManager::getJsManager();
sfConfig::set('symfony.asset.javascripts_included', true);
$response = sfContext::getInstance()->getResponse();
$config = sfConfig::get('app_sfCombinePlusPlugin_js', array());
$doNotCombine = isset($config['combine_skip']) ? $config['combine_skip'] : array();
$manager->setSkips(array_merge($manager->getSkips(), $doNotCombine));
$groupedFiles = $manager->getAssetsByGroup($response->getJavascripts(), $config['combine'], $groups, $groupType, $onlyUnusedGroups, $markGroupsUsed);
$html = '';
foreach ($groupedFiles as $fileDetails) {
if (!$fileDetails['combinable']) {
$html .= javascript_include_tag(javascript_path($fileDetails['files']), $fileDetails['options']);
} else {
$route = isset($config['route']) ? $config['route'] : 'sfCombinePlus';
$html .= javascript_include_tag(url_for('@' . $route . '?module=sfCombinePlus&action=js&' . sfCombinePlusUrl::getUrlString($fileDetails['files'])), $fileDetails['options']);
}
}
return $html;
}
示例9: javascript_include_tag
function javascript_include_tag( $sources )
{
global $javascript_default_sources;
$options = ( is_array( $sources[ count( $sources ) - 1 ] ) ? array_pop( $sources ) : array() );
if ( in_array( 'defaults', $sources ) )
{
$sources = array_merge( array_merge( array_slice( $sources, 0, array_search( 'defaults', $sources ) ), $javascript_default_sources ), array_slice( $sources, ( array_search( 'defaults', $sources ) + 1 ), count( $sources ) ) );
unset( $sources['defaults'] );
if ( defined( 'SAKE_ROOT' ) && file_exists( SAKE_ROOT.'/public/javascripts/application.js' ) )
array_push( $sources, 'application' );
}
$n_sources = array();
foreach( $sources as $source )
{
$source = javascript_path( $source );
array_push( $n_sources, content_tag( 'script', '', array_merge( array( 'type' => 'text/javascript', 'src' => $source ), $options ) ) );
}
return join( "\n", $n_sources )."\n";
}
示例10: checklists_tag
function checklists_tag($name, $options_array = null, $options = array())
{
$options = _convert_options($options);
if (isset($options['multiple']) && $options['multiple'] && substr($name, -2) !== '[]') {
$name .= '[]';
}
$options['class'] = "checklist cl1";
if (isset($options['style'])) {
$options['class'] = "checklist " . $options['style'];
}
$css_path = 'sfChecklistsPlugin/css/checklists.css';
if (!is_readable(sfConfig::get('sf_web_dir') . $css_path)) {
//throw new sfConfigurationException("Cannot find the specified css file: ".sfConfig::get('sf_web_dir').'/'.$css_path);
}
sfContext::getInstance()->getResponse()->addStylesheet($css_path);
$js_path = javascript_path('sfChecklistsPlugin/checklists.js');
if (!is_readable(sfConfig::get('sf_web_dir') . $js_path)) {
//throw new sfConfigurationException('You must install checklists.js to use this helper.');
}
sfContext::getInstance()->getResponse()->addJavascript($js_path);
$option_tags = options_for_checklists($options_array, null, array('name' => $name));
return content_tag('ul', $option_tags, array_merge(array('name' => $name, 'id' => $name), $options));
}
示例11: _a_get_assets_body
function _a_get_assets_body($type, $assets)
{
$gzip = sfConfig::get('app_a_minify_gzip', false);
sfConfig::set('symfony.asset.' . $type . '_included', true);
$html = '';
// We need our own copy of the trivial case here because we rewrote the asset list
// for stylesheets after LESS compilation, and there is no way to
// reset the list in the response object
if (!sfConfig::get('app_a_minify', false)) {
// This branch is seen only for CSS, because javascript calls the original Symfony
// functionality when minify is off
foreach ($assets as $file => $options) {
$html .= stylesheet_tag($file, $options);
}
return $html;
}
$sets = array();
foreach ($assets as $file => $options) {
if (preg_match('/^http(s)?:/', $file) || isset($options['data-minify']) && $options['data-minify'] === 0) {
// Nonlocal URL or minify was explicitly shut off.
// Don't get cute with it, otherwise things
// like Addthis and ckeditor don't work
if ($type === 'stylesheets') {
$html .= stylesheet_tag($file, $options);
} else {
$html .= javascript_include_tag($file, $options);
}
continue;
}
/*
*
* Guts borrowed from stylesheet_tag and javascript_tag. We still do a tag if it's
* a conditional stylesheet
*
*/
$absolute = false;
if (isset($options['absolute']) && $options['absolute']) {
unset($options['absolute']);
$absolute = true;
}
$condition = null;
if (isset($options['condition'])) {
$condition = $options['condition'];
unset($options['condition']);
}
if (!isset($options['raw_name'])) {
if ($type === 'stylesheets') {
$file = stylesheet_path($file, $absolute);
} else {
$file = javascript_path($file, $absolute);
}
} else {
unset($options['raw_name']);
}
if (is_null($options)) {
$options = array();
}
if ($type === 'stylesheets') {
$options = array_merge(array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen', 'href' => $file), $options);
} else {
$options = array_merge(array('type' => 'text/javascript', 'src' => $file), $options);
}
if (null !== $condition) {
$tag = tag('link', $options);
$tag = comment_as_conditional($condition, $tag);
$html .= $tag . "\n";
} else {
unset($options['href'], $options['src']);
$optionGroupKey = json_encode($options);
$set[$optionGroupKey][] = $file;
}
// echo($file);
// $html .= "<style>\n";
// $html .= file_get_contents(sfConfig::get('sf_web_dir') . '/' . $file);
// $html .= "</style>\n";
}
// CSS files with the same options grouped together to be loaded together
foreach ($set as $optionsJson => $files) {
$groupFilename = aAssets::getGroupFilename($files);
$groupFilename .= $type === 'stylesheets' ? '.css' : '.js';
if ($gzip) {
$groupFilename .= 'gz';
}
$dir = aFiles::getUploadFolder(array('asset-cache'));
if (!file_exists($dir . '/' . $groupFilename)) {
$content = '';
foreach ($files as $file) {
$path = null;
if (sfConfig::get('app_a_stylesheet_cache_http', false)) {
$url = sfContext::getRequest()->getUriPrefix() . $file;
$fileContent = file_get_contents($url);
} else {
$path = sfConfig::get('sf_web_dir') . $file;
$fileContent = file_get_contents($path);
}
if ($type === 'stylesheets') {
$options = array();
if (!is_null($path)) {
// Rewrite relative URLs in CSS files.
// This trick is available only when we don't insist on
//.........这里部分代码省略.........
示例12: sympal_use_jquery
<?php
sympal_use_jquery();
?>
<script type="text/javascript" src="<?php
echo javascript_path('/sfSympalEditorPlugin/js/links.js');
?>
"></script>
<link rel="stylesheet" type="text/css" media="screen" href="<?php
echo stylesheet_path('/sfSympalEditorPlugin/css/links.css');
?>
" />
<div id="sympal_links_container">
<h1><?php
echo __('Link Browser');
?>
</h1>
<p>
<?php
echo __('Browse your content below and insert links into the currently focused editor by ' . 'just clicking the page you want to link to.');
?>
<?php
echo __('You can control where the link is inserted by positioning the cursor in the editor.');
?>
</p>
<div id="content_types">
<h2><?php
echo __('Content Types');
示例13: include_title
<?php
if (!include_slot('title')) {
?>
RdvZ 2.0
<?php
} else {
?>
<?php
include_title();
?>
<?php
}
?>
</title>
<script type="text/javascript" src="<?php
echo javascript_path('jquery-1.4.2.min.js');
?>
"></script>
<?php
include_http_metas();
?>
<?php
include_metas();
?>
<?php
include_stylesheets();
?>
</head>
<body>
<?php
echo link_to('<img src="' . image_path('/images/rdvz_logo3_final.png') . '" id="logo" />', 'homepage');
示例14: MyForm
$response = sfContext::getInstance()->getResponse();
$form = new MyForm();
$response->resetAssets();
use_stylesheets_for_form($form);
$t->is_deeply($response->getStylesheets(), array('/path/to/a/foo.css' => array('media' => 'all'), '/path/to/a/bar.css' => array('media' => 'print')), 'use_stylesheets_for_form() adds stylesheets to the response');
$response->resetAssets();
use_javascripts_for_form($form);
$t->is_deeply($response->getJavaScripts(), array('/path/to/a/foo.js' => array(), '/path/to/a/bar.js' => array()), 'use_javascripts_for_form() adds javascripts to the response');
// custom web paths
$t->diag('Custom asset path handling');
sfConfig::set('sf_web_js_dir_name', 'static/js');
$t->is(javascript_path('xmlhr'), '/static/js/xmlhr.js', 'javascript_path() decorates a relative filename with js dir name and extension with custom js dir');
$t->is(javascript_include_tag('xmlhr'),
'<script type="text/javascript" src="/static/js/xmlhr.js"></script>'."\n",
'javascript_include_tag() takes a javascript name as its first argument');
sfConfig::set('sf_web_css_dir_name', 'static/css');
$t->is(stylesheet_path('style'), '/static/css/style.css', 'stylesheet_path() decorates a relative filename with css dir name and extension with custom css dir');
$t->is(stylesheet_tag('style'),
'<link rel="stylesheet" type="text/css" media="screen" href="/static/css/style.css" />'."\n",
'stylesheet_tag() takes a stylesheet name as its first argument');
sfConfig::set('sf_web_images_dir_name', 'static/img');
$t->is(image_path('img'), '/static/img/img.png', 'image_path() decorates a relative filename with images dir name and png extension with custom images dir');
$t->is(image_tag('test'), '<img src="/static/img/test.png" />', 'image_tag() takes an image name as its first argument');
示例15: stylesheet_path
<link rel="stylesheet" type="text/css" media="screen" href="<?php
echo stylesheet_path('/sfSympalAssetsPlugin/css/select.css');
?>
" />
<script type="text/javascript" src="<?php
echo javascript_path('/sfSympalAssetsPlugin/js/select.js');
?>
"></script>
<?php
use_helper('jQuery');
?>
<div id="sympal_assets_container" class="sympal_form">
<h1><?php
echo __('Asset Browser');
?>
</h1>
<p>
<?php
echo __('Browse your assets below and insert them into the currently focused editor by
just clicking the asset you want to insert. You can control where the asset is
inserted by positioning the cursor in the editor. You may also upload new assets
and create directories below.');
?>
</p>
<input type="hidden" id="current_url" value="<?php
echo $sf_request->getUri();
?>
" />