本文整理汇总了PHP中javascript_include_tag函数的典型用法代码示例。如果您正苦于以下问题:PHP javascript_include_tag函数的具体用法?PHP javascript_include_tag怎么用?PHP javascript_include_tag使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了javascript_include_tag函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_javascript_include_tag
function test_javascript_include_tag()
{
$this->assertEqual('<script src="mocked_stylesheet_directory/assets/javascripts/source.js" type="text/javascript"></script>', javascript_include_tag("source"));
$this->assertEqual('<script src="mocked_stylesheet_directory/assets/javascripts/source.js" type="text/javascript"></script>' . "\n" . '<script src="http://welaika.com/another_source.js" type="text/javascript"></script>', javascript_include_tag("source", "http://welaika.com/another_source.js"));
$this->assertEqual('<script src="mocked_stylesheet_directory/assets/javascripts/source.js" type="text/javascript" charset="utf-8"></script>', javascript_include_tag("source", array("charset" => "utf-8")));
$this->assertEqual('<script src="mocked_stylesheet_directory/assets/javascripts/source.js" type="text/javascript" charset="utf-8"></script>' . "\n" . '<script src="https://welaika.com/another_source.js" type="text/javascript" charset="utf-8"></script>', javascript_include_tag("source", "https://welaika.com/another_source.js", array("charset" => "utf-8")));
}
示例2: 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);
}
示例3: cdn_javascript_tag
/**
* Generates a HTML Script include Tag, refering to our amazon bucket
*
* @author Christian Weyand
* @param string $pFilename
* @param array() $pOptions
* @return unknown_type
*/
function cdn_javascript_tag($pFilename, $pOptions = array())
{
if (sfConfig::get("sf_environment") != "dev") {
$pFilename = concatNameWithRevision($pFilename, 'css');
}
return javascript_include_tag($pFilename, $pOptions);
}
示例4: 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;
}
示例5: renderMenu
function renderMenu()
{
echo javascript_include_tag('sfShowHideMenu/ClickShowHideMenu.js');
echo stylesheet_tag('sfShowHideMenu/ClickShowHideMenu.css');
echo $this->buildMenuData();
$menu_js = "var clickMenu1 = new ClickShowHideMenu('click-menu1');\n clickMenu1.init();\n";
echo javascript_tag($menu_js);
}
示例6: renderHtml
function renderHtml()
{
echo stylesheet_tag('sfToolbar/dhtmlXToolbar.css');
echo javascript_include_tag('sfToolbar/dhtmlXProtobar.js');
echo javascript_include_tag('sfToolbar/dhtmlXToolbar.js');
echo javascript_include_tag('sfToolbar/dhtmlXCommon.js');
echo $this->renderTable();
echo javascript_tag($this->buildData());
}
示例7: testJsIncludeTag
public function testJsIncludeTag()
{
$this->assertDomEqual(javascript_include_defaults(), '<script src="/js/prototype.js" type="text/javascript"></script>
<script src="/js/controls.js" type="text/javascript"></script>
<script src="/js/dragdrop.js" type="text/javascript"></script>
<script src="/js/effects.js" type="text/javascript"></script>');
$this->assertDomEqual(javascript_include_tag('sortable'), '<script src="/js/sortable.js" type="text/javascript"></script>');
$this->assertDomEqual(javascript_include_tag(array('sortable', 'test.js')), '<script src="/js/sortable.js" type="text/javascript"></script>
<script src="/js/test.js" type="text/javascript"></script>');
}
示例8: op_smt_get_javascripts
/**
* Returns <script> tags for all javascripts for smartphone pages 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, openpne will automatically include javascripts before </head>.
* calling this helper disables this behavior.
*
* @return string <script> tags
*
* @see get_javascripts()
*/
function op_smt_get_javascripts()
{
$response = sfContext::getInstance()->getResponse();
sfConfig::set('symfony.asset.javascripts_included', true);
$html = '';
foreach ($response->getSmtJavascripts() as $file => $options) {
$html .= javascript_include_tag($file, $options);
}
return $html;
}
示例9: javascript_include_tag
function javascript_include_tag($script_names)
{
if (is_array($script_names)) {
$tags = '';
foreach ($script_names as $script) {
$tags .= javascript_include_tag($script) . "\n";
}
return $tags;
}
$url = is_external_url($script_names) ? $script_names : url_for("/javascripts/{$script_names}?v=" . TIPI::getVersion());
return '<script src="' . $url . '" type="text/javascript"></script>';
}
示例10: renderMenu
function renderMenu()
{
echo stylesheet_tag('sfTreeMenu/DynamicTree.css');
echo javascript_include_tag('sfTreeMenu/ie5.js');
echo javascript_include_tag('sfTreeMenu/DynamicTree.js');
echo $this->renderMenuData();
$append_js = <<<EOD
\t\t
var tree = new DynamicTree("tree");
tree.init();
\t\t
EOD;
echo javascript_tag($append_js);
}
示例11: printAssetPaths
function printAssetPaths($assets, $plugin = '')
{
if (count($assets) > 0) {
foreach ($assets as $key => $asset) {
$assetType = substr($asset, strrpos($asset, '.') + 1);
if ($plugin == '') {
echo javascript_include_tag($asset);
} elseif ($assetType == 'js') {
echo javascript_include_tag(plugin_web_path($plugin, 'js/' . $asset));
} elseif ($assetType == 'css') {
echo stylesheet_tag(plugin_web_path($plugin, 'css/' . $asset));
} else {
echo $assetType;
}
}
}
}
示例12: 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;
}
示例13: render
/**
* Renders the widget.
*
* @param string $name The element name
* @param string $value The value displayed in this widget
* @param array $attributes An array of HTML attributes to be merged with the default HTML attributes
* @param array $errors An array of errors for the field
*
* @return string An HTML tag string
* @see sfWidgetForm
*/
public function render($name, $value = null, $attributes = array(), $errors = array())
{
if (!$this->getAttribute('size')) {
$this->setAttribute('size', $this->getOption('with_time') ? 15 : 9);
}
$this->default_picker_options['timeFormat'] = $this->getOption('time_format');
$this->default_picker_options['dateFormat'] = $this->getOption('date_format');
$this->default_picker_options['showSecond'] = strstr($this->getOption('time_format'), 'ss') !== false;
if ($timestamp = strtotime($value)) {
$value = strtr($this->getOption('date_format'), array('yy' => date('Y', $timestamp), 'mm' => date('m', $timestamp), 'dd' => date('d', $timestamp), 'y' => date('y', $timestamp), 'm' => date('n', $timestamp), 'd' => date('j', $timestamp)));
if ($this->getOption('with_time')) {
$value .= ' ' . strtr($this->getOption('time_format'), array('hh' => date('H', $timestamp), 'mm' => date('i', $timestamp), 'ss' => date('s', $timestamp), 'h' => date('G', $timestamp), 'm' => intval(date('i', $timestamp)), 's' => intval(date('s', $timestamp))));
}
}
// Generate the datePicker javascript code
$jq_picker_options = array_merge($this->default_picker_options, $this->getOption('jq_picker_options'));
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
$jq_picker_options = json_encode($jq_picker_options, JSON_FORCE_OBJECT);
} else {
$jq_picker_options = json_encode($jq_picker_options);
}
$jq_picker_options = str_replace('\\/', '/', $jq_picker_options);
// Fix for: http://bugs.php.net/bug.php?id=49366
$pickerClass = $this->getOption('with_time') ? 'datetimepicker' : 'datepicker';
$id = $this->generateId($name);
$attributes['class'] = 'sfDateTimePicker' . (isset($attributes['class']) ? ' ' . $attributes['class'] : '');
$html = parent::render($name, $value, $attributes, $errors);
foreach ($this->getStylesheets() as $file => $options) {
$html .= stylesheet_tag($file, $options);
}
foreach ($this->getJavaScripts() as $file) {
$html .= javascript_include_tag($file);
}
$html .= <<<EOHTML
<script type="text/javascript">
jQueryPicker(function(){
jQueryPicker("#{$id}").{$pickerClass}({$jq_picker_options});
// jQueryPicker(".ui-datepicker").draggable();
});
</script>
EOHTML;
return $html;
}
示例14: _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;
}
示例15: sw_get_javascripts
function sw_get_javascripts()
{
$params = sfConfig::get('app_swToolbox_swCombine', array('version' => false));
$version = $params['version'];
$response = sfContext::getInstance()->getResponse();
$included_files = $response->getCombinedAssets();
sfConfig::set('symfony.asset.javascripts_included', true);
$html = '';
foreach ($response->getJavascripts() as $file => $options) {
// avoid loading combined files
if (in_array($file, $included_files)) {
continue;
}
$file = $version ? $file . '?v=' . $version : $file;
$html .= javascript_include_tag($file, $options);
}
return $html;
}