本文整理汇总了PHP中javascript_cdata_section函数的典型用法代码示例。如果您正苦于以下问题:PHP javascript_cdata_section函数的具体用法?PHP javascript_cdata_section怎么用?PHP javascript_cdata_section使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了javascript_cdata_section函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: javascript_tag
/**
* Returns a JavaScript tag with the '$content' inside. If no content is passed, it works as the slot() method and will output everythin between
* javascript_tag() and end_javascript_tag(),
* Example:
* <?php echo javascript_tag("alert('All is good')") ?>
* => <script type="text/javascript">alert('All is good')</script>
* <?php javascript_tag() ?>alert('All is good')<?php end_javascript_tag() ?>
*/
function javascript_tag($content = null)
{
if (!is_null($content)) {
return content_tag('script', javascript_cdata_section($content), array('type' => 'text/javascript'));
} else {
ob_start();
}
}
示例2: javascript_tag
/**
* Returns a JavaScript tag with the '$content' inside. If no content is passed, it works as the slot() method and will output everythin between
* javascript_tag() and end_javascript_tag(),
* Example:
* <?php echo javascript_tag("alert('All is good')") ?>
* => <script type="text/javascript">alert('All is good')</script>
* <?php javascript_tag() ?>alert('All is good')<?php end_javascript_tag() ?>
*/
function javascript_tag($content = null)
{
if (null !== $content) {
require_once dirname(__FILE__) . '/TagHelper.php';
return content_tag('script', javascript_cdata_section($content), array('type' => 'text/javascript'));
} else {
ob_start();
}
}
示例3: javascript_tag
/**
* Returns a JavaScript tag with the +content+ inside. Example:
* javascript_tag "alert('All is good')" # => <script type="text/javascript">alert('All is good')</script>
*/
function javascript_tag( $content )
{
return content_tag( 'script', javascript_cdata_section( $content ), array( 'type' => 'text/javascript' ) );
}
示例4: 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', get_id_from_name($this->name, null));
// use tinymce's gzipped js?
$tinymce_file = _get_option($options, 'tinymce_gzip') ? '/tiny_mce_gzip.php' : '/tiny_mce.js';
// tinymce installed?
$js_path = sfConfig::get('sf_rich_text_js_dir') ? '/' . sfConfig::get('sf_rich_text_js_dir') . $tinymce_file : '/sf/tinymce/js' . $tinymce_file;
if (!is_readable(sfConfig::get('sf_web_dir') . $js_path)) {
throw new sfConfigurationException('You must install TinyMCE to use this helper (see rich_text_js_dir settings).');
}
sfContext::getInstance()->getResponse()->addJavascript($js_path);
use_helper('Javascript');
$tinymce_options = '';
$style_selector = '';
// custom CSS file?
if ($css_file = _get_option($options, 'css')) {
$css_path = stylesheet_path($css_file);
sfContext::getInstance()->getResponse()->addStylesheet($css_path);
$css = file_get_contents(sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $css_path);
$styles = array();
preg_match_all('#^/\\*\\s*user:\\s*(.+?)\\s*\\*/\\s*\\015?\\012\\s*\\.([^\\s]+)#Smi', $css, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$styles[] = $match[1] . '=' . $match[2];
}
$tinymce_options .= ' content_css: "' . $css_path . '",' . "\n";
$tinymce_options .= ' theme_advanced_styles: "' . implode(';', $styles) . '"' . "\n";
$style_selector = 'styleselect,separator,';
}
$culture = sfContext::getInstance()->getUser()->getCulture();
$tinymce_js = '
tinyMCE.init({
mode: "exact",
language: "' . strtolower(substr($culture, 0, 2)) . '",
elements: "' . $id . '",
plugins: "table,advimage,advlink,flash",
theme: "advanced",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_path_location: "bottom",
theme_advanced_buttons1: "' . $style_selector . 'justifyleft,justifycenter,justifyright,justifyfull,separator,bold,italic,strikethrough,separator,sub,sup,separator,charmap",
theme_advanced_buttons2: "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,image,flash,separator,cleanup,removeformat,separator,code",
theme_advanced_buttons3: "tablecontrols",
extended_valid_elements: "img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style]",
relative_urls: false,
debug: false
' . ($tinymce_options ? ',' . $tinymce_options : '') . '
' . (isset($options['tinymce_options']) ? ',' . $options['tinymce_options'] : '') . '
});';
if (isset($options['tinymce_options'])) {
unset($options['tinymce_options']);
}
return content_tag('script', javascript_cdata_section($tinymce_js), array('type' => 'text/javascript')) . content_tag('textarea', $this->content, array_merge(array('name' => $this->name, 'id' => $id), _convert_options($options)));
}
示例5: jq_javascript_cdata_section
function jq_javascript_cdata_section($content)
{
return javascript_cdata_section($content);
}
示例6: toHTML
//.........这里部分代码省略.........
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);
// use tinymce's gzipped js?
$tinymce_file = _get_option($options, 'tinymce_gzip') ? '/tiny_mce_gzip.php' : '/tiny_mce.js';
// tinymce installed?
$js_path = sfConfig::get('sf_rich_text_js_dir') ? '/' . sfConfig::get('sf_rich_text_js_dir') . $tinymce_file : '/sf/tinymce/js' . $tinymce_file;
if (!is_readable(sfConfig::get('sf_web_dir') . $js_path)) {
throw new sfConfigurationException('You must install TinyMCE to use this helper (see rich_text_js_dir settings).');
}
sfContext::getInstance()->getResponse()->addJavascript($js_path);
use_helper('Javascript');
$tinymce_options = '';
$style_selector = '';
// custom CSS file?
if ($css_file = _get_option($options, 'css')) {
$css_path = stylesheet_path($css_file);
sfContext::getInstance()->getResponse()->addStylesheet($css_path);
$css = file_get_contents(sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $css_path);
$styles = array();
preg_match_all('#^/\\*\\s*user:\\s*(.+?)\\s*\\*/\\s*\\015?\\012\\s*\\.([^\\s]+)#Smi', $css, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$styles[] = $match[1] . '=' . $match[2];
}
$tinymce_options .= ' content_css: "' . $css_path . '",' . "\n";
$tinymce_options .= ' theme_advanced_styles: "' . implode(';', $styles) . '"' . "\n";
$style_selector = 'styleselect,separator,';
}
$config = sfConfig::get('sf_config_dir_name');
$path = sfConfigCache::getInstance()->checkConfig($config . DIRECTORY_SEPARATOR . 'tiny_mce.yml');
$config = sfYaml::load($path);
$culture = isset($config['culture']) ? $config['culture'] : sfContext::getInstance()->getUser()->getCulture();
$mode = $config['options']['mode'];
$plugins = implode(',', $config['options']['plugins']);
$theme = $config['options']['theme'];
$tbLocation = $config['options']['theme_settings']['theme_' . $theme . '_toolbar_location'];
$tbAlign = $config['options']['theme_settings']['theme_' . $theme . '_toolbar_align'];
$pathLocation = $config['options']['theme_settings']['theme_' . $theme . '_path_location'];
$buttons = array();
reset($config['options']['theme_settings']['buttons']);
while (($key = key($config['options']['theme_settings']['buttons'])) !== null) {
$current = current($config['options']['theme_settings']['buttons']);
$buttons[] = $key . ': "' . implode(',', $current) . '"';
next($config['options']['theme_settings']['buttons']);
}
$buttons = implode(",\n", $buttons);
$extendedValidElements = array();
reset($config['options']['theme_settings']['extended_valid_elements']);
while (($key = key($config['options']['theme_settings']['extended_valid_elements'])) !== null) {
$current = current($config['options']['theme_settings']['extended_valid_elements']);
$extendedValidElements[] = $key . '[' . implode('|', $current) . ']';
next($config['options']['theme_settings']['extended_valid_elements']);
}
$extendedValidElements = '"' . implode(",\n", $extendedValidElements) . '"';
$relativeUrls = $config['options']['relative_urls'] ? 'true' : 'false';
$debug = $config['options']['debug'] ? 'true' : 'false';
$tinymce_js = 'tinyMCE.init({';
// Mode
$tinymce_js .= "mode: '{$mode}'";
// Language
$tinymce_js .= ', language: "' . strtolower(substr($culture, 0, 2)) . '"';
// Elements
$tinymce_js .= ', elements: "' . $id . '"';
// Plugins
if ($plugins) {
$tinymce_js .= ', plugins: "' . $plugins . '"';
}
// Theme
$tinymce_js .= ", theme: '{$theme}'";
// Toolbar
$tinymce_js .= ', theme_' . $theme . '_toolbar_location: "' . $tbLocation . '"';
$tinymce_js .= ', theme_' . $theme . '_toolbar_align: "' . $tbAlign . '"';
$tinymce_js .= ', theme_' . $theme . '_path_location: "' . $pathLocation . '"';
// Buttons
if ($buttons) {
$tinymce_js .= ', ' . $buttons;
}
// Extended Valid Elements
$tinymce_js .= ', extended_valid_elements: ' . $extendedValidElements;
// Relative Urls
$tinymce_js .= ', relative_urls: ' . $relativeUrls;
// Debug
$tinymce_js .= ', debug: ' . $debug;
// Custom Options
$tinymce_js .= $tinymce_options ? ',' . $tinymce_options : '';
$tinymce_js .= isset($options['tinymce_options']) ? ',' . $options['tinymce_options'] : '';
if (isset($config['options']['misc'])) {
foreach ($config['options']['misc'] as $name => $value) {
$tinymce_js .= ", {$name}: \"{$value}\"";
}
}
if (isset($options['tinymce_options'])) {
unset($options['tinymce_options']);
}
$tinymce_js .= '});';
return content_tag('script', javascript_cdata_section($tinymce_js), array('type' => 'text/javascript')) . content_tag('textarea', $this->content, array_merge(array('name' => $this->name, 'id' => get_id_from_name($id, null)), _convert_options($options)));
}