本文整理汇总了PHP中get_javascripts函数的典型用法代码示例。如果您正苦于以下问题:PHP get_javascripts函数的具体用法?PHP get_javascripts怎么用?PHP get_javascripts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_javascripts函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_combined_javascripts
/**
* Returns <script> tags with the url toward 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();
}
$response = sfContext::getInstance()->getResponse();
sfConfig::set('symfony.asset.javascripts_included', true);
$configSfCombinePlugin['js'] = sfConfig::get('app_sfCombinePlugin_js', array());
$html = '';
$jsFiles = $include_tags = array();
foreach (array('first', '', 'last') as $position) {
foreach ($response->getJavascripts($position) as $files => $options) {
if (!in_array($files, $configSfCombinePlugin['js']['online']) && !in_array($files, $configSfCombinePlugin['js']['offline'])) {
if (!is_array($files)) {
$files = array($files);
}
$jsFiles = array_merge($jsFiles, $files);
} else {
$include_tags[] = javascript_include_tag(url_for($files));
}
}
}
$key = _get_key($jsFiles);
$include_tags[] = str_replace('.js', '', javascript_include_tag(url_for('sfCombine/js?key=' . $key)));
return implode("", $include_tags);
}
示例2: execute
/**
* Executes this filter.
*
* @param sfFilterChain $filterChain A sfFilterChain instance
*/
public function execute($filterChain)
{
// execute next filter
$filterChain->execute();
// execute this filter only once
$response = $this->context->getResponse();
// include javascripts and stylesheets
$content = $response->getContent();
if (false !== ($pos = strpos($content, '</head>')))
{
$this->context->getConfiguration()->loadHelpers(array('Tag', 'Asset'));
$html = '';
if (!sfConfig::get('symfony.asset.javascripts_included', false))
{
$html .= get_javascripts($response);
}
if (!sfConfig::get('symfony.asset.stylesheets_included', false))
{
$html .= get_stylesheets($response);
}
if ($html)
{
$response->setContent(substr($content, 0, $pos).$html.substr($content, $pos));
}
}
sfConfig::set('symfony.asset.javascripts_included', false);
sfConfig::set('symfony.asset.stylesheets_included', false);
}
示例3: 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;
}
示例4: javascript_assets
/**
* Retrieves the javascripts tags from the response or the tmp js tag
* @return string
*/
function javascript_assets()
{
sfContext::getInstance()->getConfiguration()->loadHelpers('Asset');
// Update response after it gets totally loaded
if (sfConfig::get('app_sf_assets_manager_plugin_alter_response', false)) {
return sfConfig::get('app_sf_assets_manager_plugin_alter_response_tempjstag');
} else {
return get_javascripts();
}
}
示例5: 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;
}
示例6: execute
/**
* Executes this filter.
*
* @param sfFilterChain A sfFilterChain instance
*/
public function execute($filterChain)
{
// execute next filter
$filterChain->execute();
// execute this filter only once
$response = $this->getContext()->getResponse();
// include javascripts and stylesheets
$content = $response->getContent();
if (false !== ($pos = strpos($content, '</head>'))) {
sfLoader::loadHelpers(array('Tag', 'Asset'));
$html = '';
if (!$response->getParameter('javascripts_included', false, 'symfony/view/asset')) {
$html .= get_javascripts($response);
}
if (!$response->getParameter('stylesheets_included', false, 'symfony/view/asset')) {
$html .= get_stylesheets($response);
}
if ($html) {
$response->setContent(substr($content, 0, $pos) . $html . substr($content, $pos));
}
}
$response->setParameter('javascripts_included', false, 'symfony/view/asset');
$response->setParameter('stylesheets_included', false, 'symfony/view/asset');
}
示例7: include_javascripts
/**
* Prints <script> tags for all javascripts configured in view.yml or added to the response object.
*
* @see get_javascripts()
*/
function include_javascripts()
{
echo get_javascripts();
}
示例8: a_get_javascripts
function a_get_javascripts()
{
if (sfConfig::get('app_a_minify', false)) {
$response = sfContext::getInstance()->getResponse();
return _a_get_assets_body('javascripts', $response->getJavascripts());
} else {
return get_javascripts();
}
}
示例9: array
$t->is(_dynamic_path('module/action', 'js'), 'module/action?sf_format=js', '_dynamic_path() converts an internal URI to a URL');
$t->is(_dynamic_path('module/action?key=value', 'js'), 'module/action?key=value&sf_format=js', '_dynamic_path() converts an internal URI to a URL');
$t->is(_dynamic_path('module/action', 'js', true), '/module/action?sf_format=js', '_dynamic_path() converts an internal URI to a URL');
// dynamic_javascript_include_tag()
$t->diag('dynamic_javascript_include_tag()');
$t->is(dynamic_javascript_include_tag('module/action'), '<script type="text/javascript" src="module/action?sf_format=js"></script>'."\n", 'dynamic_javascript_include_tag() returns a tag relative to the given action');
$t->is(dynamic_javascript_include_tag('module/action', true), '<script type="text/javascript" src="/module/action?sf_format=js"></script>'."\n", 'dynamic_javascript_include_tag() takes an absolute boolean as its second argument');
$t->is(dynamic_javascript_include_tag('module/action', true, array('class' => 'foo')), '<script type="text/javascript" src="/module/action?sf_format=js" class="foo"></script>'."\n", 'dynamic_javascript_include_tag() takes an array of HTML attributes as its third argument');
$context->response = new myResponse($context->getEventDispatcher());
// use_dynamic_javascript()
$t->diag('use_dynamic_javascript()');
use_dynamic_javascript('module/action');
$t->is(get_javascripts(),
'<script type="text/javascript" src="module/action?sf_format=js"></script>'."\n",
'use_dynamic_javascript() register a dynamic javascript in the response'
);
// use_dynamic_stylesheet()
$t->diag('use_dynamic_stylesheet()');
use_dynamic_stylesheet('module/action');
$t->is(get_stylesheets(),
'<link rel="stylesheet" type="text/css" media="screen" href="module/action?sf_format=css" />'."\n",
'use_dynamic_stylesheet() register a dynamic stylesheet in the response'
);
class MyForm extends sfForm
{
public function getStylesheets()
示例10: use_stylesheet
$t->is(get_stylesheets(), '<link rel="stylesheet" type="text/css" media="screen" href="/css/style.css" />' . "\n" . '<link rel="stylesheet" type="text/css" media="screen" href="/css/style2.css" />' . "\n", 'get_stylesheets() returns all the stylesheets previously added by use_stylesheet()');
// _dynamic_path()
$t->diag('_dynamic_path()');
$t->is(_dynamic_path('module/action', 'js'), 'module/action?sf_format=js', '_dynamic_path() converts an internal URI to a URL');
$t->is(_dynamic_path('module/action?key=value', 'js'), 'module/action?key=value&sf_format=js', '_dynamic_path() converts an internal URI to a URL');
$t->is(_dynamic_path('module/action', 'js', true), '/module/action?sf_format=js', '_dynamic_path() converts an internal URI to a URL');
// dynamic_javascript_include_tag()
$t->diag('dynamic_javascript_include_tag()');
$t->is(dynamic_javascript_include_tag('module/action'), '<script type="text/javascript" src="module/action?sf_format=js"></script>' . "\n", 'dynamic_javascript_include_tag() returns a tag relative to the given action');
$t->is(dynamic_javascript_include_tag('module/action', true), '<script type="text/javascript" src="/module/action?sf_format=js"></script>' . "\n", 'dynamic_javascript_include_tag() takes an absolute boolean as its second argument');
$t->is(dynamic_javascript_include_tag('module/action', true, array('class' => 'foo')), '<script type="text/javascript" src="/module/action?sf_format=js" class="foo"></script>' . "\n", 'dynamic_javascript_include_tag() takes an array of HTML attributes as its third argument');
$context->response = new myResponse($context->getEventDispatcher());
// use_dynamic_javascript()
$t->diag('use_dynamic_javascript()');
use_dynamic_javascript('module/action');
$t->is(get_javascripts(), '<script type="text/javascript" src="module/action?sf_format=js"></script>' . "\n", 'use_dynamic_javascript() register a dynamic javascript in the response');
// use_dynamic_stylesheet()
$t->diag('use_dynamic_stylesheet()');
use_dynamic_stylesheet('module/action');
$t->is(get_stylesheets(), '<link rel="stylesheet" type="text/css" media="screen" href="module/action?sf_format=css" />' . "\n", 'use_dynamic_stylesheet() register a dynamic stylesheet in the response');
class MyForm extends sfForm
{
public function getStylesheets()
{
return array('/path/to/a/foo.css' => 'all', '/path/to/a/bar.css' => 'print');
}
public function getJavaScripts()
{
return array('/path/to/a/foo.js', '/path/to/a/bar.js');
}
}
示例11: use_javascript
?>
<?php
use_javascript('../smintplayer/js/slider.js');
?>
<?php
use_javascript('../smintplayer/js/jquery.ui.touch-punch.min.js');
?>
<!-- css should be before js for performance reasons -->
<?php
echo get_stylesheets();
?>
<!-- other js : should be at the end of all use_javascript calls -->
<?php
echo get_javascripts();
?>
<link rel="icon" type="image/png" href="<?php
echo image_path("favicon.png");
?>
" />
<?php
require_once dirname(__FILE__) . '/ga-tracking.php';
?>