/**
     * 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);
        // 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;
        $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]",
  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' => get_id_from_name($id, null)), _convert_options($options)));
    }
function stylesheet_link_tag($sources, $options = array())
{
    if (!is_array($sources)) {
        $sources = array($sources);
    }
    $html = '';
    foreach ($sources as $source) {
        $options = array_merge(array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen'), $options);
        $options['href'] = stylesheet_path($source);
        $html .= tag('link', $options) . "\n";
    }
    return $html;
}
Ejemplo n.º 3
0
 public function printJavascript()
 {
     $this->addScriptContent("\n            \$('#ohrmTreeViewComponent_Tree').treeview({\n                collapsed: false,\n                control:'#ohrmTreeViewComponent_TreeController',\n                persist: 'location'\n            });\n\n            \$('#ohrmTreeViewComponent_Tree *').css('list-style', 'none'); // TODO: Move this to a stylesheet. Make sure to test in IE\n\n            \$('a[id^=\"treeLink_edit_\"]').click(function() {\n                loadNode(parseInt(\$(this).attr('id').replace('treeLink_edit_', '')));\n                _clearMessage();\n            });\n\n            \$('a[id^=\"treeLink_addChild_\"]').click(function() {\n                addChildToNode(parseInt(\$(this).attr('id').replace('treeLink_addChild_', '')));\n            });\n\n            \$('a[id^=\"treeLink_delete_\"]').click(function() {\n                deleteNode(parseInt(\$(this).attr('id').replace('treeLink_delete_', '')));\n            });\n\n            clearForm();\n");
     $this->addScriptFunction("\n            \$('form[id^=\"ohrmFormComponent_Form\"]').each(function() {\n                \$(this).parent().parent().show();\n            });\n            \$('.requirednotice').show();\n        ", 'showForm');
     $this->addScriptFunction("\n            \$('form[id^=\"ohrmFormComponent_Form\"]').each(function() {\n                \$(this).parent().parent().hide();\n            });\n            \$('.requirednotice').hide();\n        ", 'hideForm');
     $this->addScriptFunction("\n            \$('form[id^=\"ohrmFormComponent_Form\"] :input').filter(':not([type=\"button\"])').val('');\n            \$('.idValueLabel').html('');\n            \$('#lblParentNotice').remove();\n        ", 'clearForm');
     $html = '';
     $html .= content_tag('script', '', array('type' => 'text/javascript', 'src' => javascript_path('jquery.treeview.min.js')));
     if ($this->type == null) {
         $html .= tag('link', array('rel' => 'stylesheet', 'href' => stylesheet_path('jquery-treeview/jquery.treeview.css')));
     } else {
         $html .= tag('link', array('rel' => 'stylesheet', 'href' => stylesheet_path('jquery-treeview/jquery.treeview_1.css')));
     }
     $this->addScriptContent(array('$(document).ready(function() {', '});'), 'wrap');
     $this->addScriptContent($this->getScriptFunctionsString());
     $this->addScriptContent(array('//<![CDATA[', '//]]>'), 'wrap');
     $html .= content_tag('script', $this->scriptContent, array('type' => 'text/javascript'));
     echo $html;
     return true;
 }
Ejemplo n.º 4
0
/**
 * Returns a css <link> tag per source given as argument,
 * to be included in the <head> section of a HTML document.
 *
 * <b>Options:</b>
 * - rel - defaults to 'stylesheet'
 * - type - defaults to 'text/css'
 * - media - defaults to 'screen'
 *
 * <b>Examples:</b>
 * <code>
 *  echo stylesheet_tag('style');
 *    => <link href="/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />
 *  echo stylesheet_tag('style', array('media' => 'all'));
 *    => <link href="/stylesheets/style.css" media="all" rel="stylesheet" type="text/css" />
 *  echo stylesheet_tag('style', array('raw_name' => true));
 *    => <link href="style" media="all" rel="stylesheet" type="text/css" />
 *  echo stylesheet_tag('random.styles', '/css/stylish');
 *    => <link href="/stylesheets/random.styles" media="screen" rel="stylesheet" type="text/css" />
 *       <link href="/css/stylish.css" media="screen" rel="stylesheet" type="text/css" />
 * </code>
 *
 * @param string asset names
 * @param array  additional HTML compliant <link> tag parameters
 *
 * @return string XHTML compliant <link> tag(s)
 * @see    stylesheet_path
 */
function stylesheet_tag($source, $options = array())
{
    if (!is_array($options)) {
        $options = array();
    }
    $options += array('absolute' => false);
    if (empty($options['raw_name'])) {
        $source = stylesheet_path($source, $options['absolute']);
    }
    $tag = tag('link', array_diff_key($options + array('href' => $source, 'media' => 'screen', 'rel' => 'stylesheet', 'type' => 'text/css'), array('absolute' => 'abosolute', 'condition' => 'condition', 'raw_name' => 'raw_name')));
    if (isset($options['condition'])) {
        $tag = comment_as_conditional($options['condition'], $tag);
    }
    return $tag . "\n";
}
Ejemplo n.º 5
0
function stylesheet_link_tag( $sources )
{
	$options = ( is_array( $sources[ count( $sources ) - 1 ] ) ? array_pop( $sources ) : array() );
	$n_sources = array();
	foreach( $sources as $source )
	{
		$source = stylesheet_path( $source );
		array_push( $n_sources, tag( 'link', array_merge( array( 'rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen', 'href' => $source ), $options ) ) );
	}
	return join( "\n", $n_sources )."\n";
}
Ejemplo n.º 6
0
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
                        // pulling our CSS files via http rather than the filesystem
                        // dirname would resolve symbolic links, we don't want that
                        $fdir = preg_replace('/\\/[^\\/]*$/', '', $path);
                        $options['currentDir'] = $fdir;
                        $options['docRoot'] = sfConfig::get('sf_web_dir');
                    }
                    if (sfConfig::get('app_a_minify', false)) {
                        $fileContent = Minify_CSS::minify($fileContent, $options);
                    }
                } else {
                    // Trailing carriage return makes behavior more consistent with
                    // JavaScript's behavior when loading separate files. For instance,
                    // a missing trailing semicolon should be tolerated to the same
                    // degree it would be with separate files. The minifier is not
                    // a lint tool and should not surprise you with breakage
                    $fileContent = JSMin::minify($fileContent) . "\n";
                }
                $content .= $fileContent;
            }
            if ($gzip) {
                _gz_file_put_contents($dir . '/' . $groupFilename . '.tmp', $content);
            } else {
                file_put_contents($dir . '/' . $groupFilename . '.tmp', $content);
            }
            @rename($dir . '/' . $groupFilename . '.tmp', $dir . '/' . $groupFilename);
        }
        $options = json_decode($optionsJson, true);
        // Use stylesheet_path and javascript_path so we can respect relative_root_dir
        if ($type === 'stylesheets') {
            $options['href'] = stylesheet_path(sfConfig::get('app_a_assetCacheUrl', '/uploads/asset-cache') . '/' . $groupFilename);
            $html .= tag('link', $options);
        } else {
            $options['src'] = javascript_path(sfConfig::get('app_a_assetCacheUrl', '/uploads/asset-cache') . '/' . $groupFilename);
            $html .= content_tag('script', '', $options);
        }
    }
    return $html;
}
Ejemplo n.º 7
0
$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');
Ejemplo n.º 8
0
Archivo: html.php Proyecto: brego/prank
function stylesheet($file, $options = null)
{
    $file = stylesheet_path($file);
    $options = html_parse_params($options);
    return '<link href="' . $file . '" rel="stylesheet" type="text/css"' . $options . ' />';
}
Ejemplo n.º 9
0
<?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');
  protected function _configureStylist() {
		$cssArray = sfContext::getInstance()->getResponse()->getStylesheets();
		$cssArray = $this->getOption('css_files')? array_merge($cssArray, $this->getOption('css_files')): $cssArray;
		foreach ($cssArray as $file => $options) {
				$this->_additionalConfig .= 'xinha_config.stylistLoadStylesheet("'.stylesheet_path($file).'");'."\n";
		}
  }
Ejemplo n.º 11
0
$t->is(javascript_include_tag('xmlhr', array('absolute' => true)), '<script type="text/javascript" src="http://localhost/js/xmlhr.js"></script>' . "\n", 'javascript_include_tag() can take an absolute option to output an absolute file name');
$t->is(javascript_include_tag('xmlhr', array('raw_name' => true)), '<script type="text/javascript" src="xmlhr"></script>' . "\n", 'javascript_include_tag() can take a raw_name option to bypass file name decoration');
$t->is(javascript_include_tag('xmlhr', array('defer' => 'defer')), '<script type="text/javascript" src="/js/xmlhr.js" defer="defer"></script>' . "\n", 'javascript_include_tag() can take additional html options like defer');
$t->is(javascript_include_tag('xmlhr', array('condition' => 'IE 6')), '<!--[if IE 6]><script type="text/javascript" src="/js/xmlhr.js"></script><![endif]-->' . "\n", 'javascript_include_tag() can take a condition option');
// javascript_path()
$t->diag('javascript_path()');
$t->is(javascript_path('xmlhr'), '/js/xmlhr.js', 'javascript_path() decorates a relative filename with js dir name and extension');
$t->is(javascript_path('/xmlhr'), '/xmlhr.js', 'javascript_path() does not decorate absolute file names with js dir name');
$t->is(javascript_path('xmlhr.foo'), '/js/xmlhr.foo', 'javascript_path() does not decorate file names with extension with .js');
$t->is(javascript_path('xmlhr.foo', true), 'http://localhost/js/xmlhr.foo', 'javascript_path() accepts a second parameter to output an absolute resource path');
// stylesheet_path()
$t->diag('stylesheet_path()');
$t->is(stylesheet_path('style'), '/css/style.css', 'stylesheet_path() decorates a relative filename with css dir name and extension');
$t->is(stylesheet_path('/style'), '/style.css', 'stylesheet_path() does not decorate absolute file names with css dir name');
$t->is(stylesheet_path('style.foo'), '/css/style.foo', 'stylesheet_path() does not decorate file names with extension with .css');
$t->is(stylesheet_path('style.foo', true), 'http://localhost/css/style.foo', 'stylesheet_path() accepts a second parameter to output an absolute resource path');
// image_path()
$t->diag('image_path()');
$t->is(image_path('img'), '/images/img.png', 'image_path() decorates a relative filename with images dir name and png extension');
$t->is(image_path('/img'), '/img.png', 'image_path() does not decorate absolute file names with images dir name');
$t->is(image_path('img.jpg'), '/images/img.jpg', 'image_path() does not decorate file names with extension with .png');
$t->is(image_path('img.jpg', true), 'http://localhost/images/img.jpg', 'image_path() accepts a second parameter to output an absolute resource path');
// use_javascript() get_javascripts()
$t->diag('use_javascript() get_javascripts()');
use_javascript('xmlhr');
$t->is(get_javascripts(), '<script type="text/javascript" src="/js/xmlhr.js"></script>' . "\n", 'get_javascripts() returns a javascript previously added by use_javascript()');
use_javascript('xmlhr', '', array('raw_name' => true));
$t->is(get_javascripts(), '<script type="text/javascript" src="xmlhr"></script>' . "\n", 'use_javascript() accepts an array of options as a third parameter');
use_javascript('xmlhr', '', array('absolute' => true));
$t->is(get_javascripts(), '<script type="text/javascript" src="http://localhost/js/xmlhr.js"></script>' . "\n", 'use_javascript() accepts an array of options as a third parameter');
use_javascript('xmlhr');
Ejemplo n.º 12
0
<script type="text/javascript" src="<?php 
echo javascript_path(sfSympalConfig::getAssetPath('/sfSympalEditorPlugin/js/links.js'));
?>
"></script>
<link rel="stylesheet" type="text/css" media="screen" href="<?php 
echo stylesheet_path(sfSympalConfig::getAssetPath('/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');
?>
</h2>
    <ul>
      <?php 
Ejemplo n.º 13
0
	<meta http-equiv="X-UA-Compatible" content="IE=7" />
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" href="<?php 
echo stylesheet_path('../sfSqlDesignerPlugin/css/style');
?>
" media="all" />
	<!--[if IE 6]><link rel="stylesheet" type="text/css" href="<?php 
echo stylesheet_path('../sfSqlDesignerPlugin/css/ie6');
?>
" /><![endif]-->
	<!--[if IE 7]><link rel="stylesheet" type="text/css" href="<?php 
echo stylesheet_path('../sfSqlDesignerPlugin/css/ie7');
?>
" /><![endif]-->
	<link rel="stylesheet" href="<?php 
echo stylesheet_path('../sfSqlDesignerPlugin/css/print');
?>
" type="text/css" media="print" />
	<script type="text/javascript" src="<?php 
echo javascript_path('../sfSqlDesignerPlugin/js/oz');
?>
"></script>
	<script type="text/javascript" src="<?php 
echo javascript_path('../sfSqlDesignerPlugin/js/config');
?>
"></script>
	<script type="text/javascript" src="<?php 
echo javascript_path('../sfSqlDesignerPlugin/js/wwwsqldesigner');
?>
"></script>
	<script type="text/javascript" src="<?php 
/**
 * @see get_combined_javascripts
 */
function get_combined_stylesheets($groups = null, $groupType = sfCombinePlusManager::GROUP_INCLUDE, $onlyUnusedGroups = true, $markGroupsUsed = true)
{
    if (!sfConfig::get('app_sfCombinePlusPlugin_enabled', false)) {
        return get_stylesheets();
    }
    $manager = sfCombinePlusManager::getCssManager();
    sfConfig::set('symfony.asset.stylesheets_included', true);
    $response = sfContext::getInstance()->getResponse();
    $config = sfConfig::get('app_sfCombinePlusPlugin_css', array());
    $doNotCombine = isset($config['combine_skip']) ? $config['combine_skip'] : array();
    $manager->setSkips(array_merge($manager->getSkips(), $doNotCombine));
    $groupedFiles = $manager->getAssetsByGroup($response->getStylesheets(), $config['combine'], $groups, $groupType, $onlyUnusedGroups, $markGroupsUsed);
    $html = '';
    foreach ($groupedFiles as $fileDetails) {
        if (!$fileDetails['combinable']) {
            $html .= stylesheet_tag(stylesheet_path($fileDetails['files']), $fileDetails['options']);
        } else {
            $route = isset($config['route']) ? $config['route'] : 'sfCombinePlus';
            $html .= stylesheet_tag(url_for('@' . $route . '?module=sfCombinePlus&action=js&' . sfCombinePlusUrl::getUrlString($fileDetails['files'])), $fileDetails['options']);
        }
    }
    return $html;
}
 protected function getAssetPath($file)
 {
     sfProjectConfiguration::getActive()->loadHelpers('Asset');
     return stylesheet_path($file);
 }
Ejemplo n.º 16
0
function minify_get_stylesheets($position_array = array('first', '', 'last'), $debug = false, $my_already_seen = array())
{
    $response = sfContext::getInstance()->getResponse();
    $response->setParameter('stylesheets_included', true, 'symfony/view/asset');
    $app_static_url = sfConfig::get('app_static_url');
    $already_seen = $my_already_seen;
    $minify_files = array();
    foreach ($position_array as $position) {
        foreach ($response->getStylesheets($position) as $files => $options) {
            if (!is_array($files)) {
                $files = array($files);
            }
            $options = array_merge(array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'all'), $options);
            foreach ($files as $file) {
                if (isset($already_seen[$file])) {
                    continue;
                }
                $already_seen[$file] = 1;
                $absolute = false;
                if (isset($options['absolute'])) {
                    unset($options['absolute']);
                    $absolute = true;
                }
                if (!isset($options['raw_name'])) {
                    $file = stylesheet_path($file, $absolute);
                } else {
                    unset($options['raw_name']);
                }
                $type = serialize($options);
                if (isset($minify_files[$type])) {
                    array_push($minify_files[$type], $file);
                } else {
                    $minify_files[$type] = array($file);
                }
            }
        }
    }
    $html = '';
    foreach ($minify_files as $options => $files) {
        $options = unserialize($options);
        $options['href'] = minify_get_combined_files_url($files, $debug);
        $html .= tag('link', $options) . "\n";
    }
    return $html;
}
 /**
  * @deprecated
  */
 private function _drawTestTree()
 {
     $listItems = '';
     for ($i = 1; $i <= 5; $i++) {
         $subListItems = array();
         for ($j = 1; $j <= rand(0, 8); $j++) {
             $subListItems[] = content_tag('li', "\n\t" . content_tag('a', "Sub List Item {$i}-{$j}", array('href' => "?#{$i}-{$j}"))) . "\n";
         }
         $subListItems = count($subListItems) > 0 ? content_tag('ul', "\n" . implode('', $subListItems)) : '';
         $listItems[] = content_tag('li', "\n\t" . content_tag('a', "Item {$i}", array('href' => "?#{$i}")) . "{$subListItems}");
     }
     $listItems = "\n" . implode('', $listItems);
     $html = '';
     $html .= content_tag('script', '', array('type' => 'text/javascript', 'src' => javascript_path('jquery.treeview.min.js')));
     $html .= tag('link', array('rel' => 'stylesheet', 'href' => stylesheet_path('jquery-treeview/jquery.treeview.css')));
     $html .= content_tag('a', 'Collapse All', array('href' => '?#'));
     $html .= ' | ';
     $html .= content_tag('a', 'Expand All', array('href' => '?#'));
     $html = content_tag('div', $html, array('id' => 'ohrmTreeViewComponent_TreeController', 'class' => 'treecontrol'));
     $html .= content_tag('div', $this->getPropertyObject()->getRootLabel(), array('id' => 'ohrmTreeViewComponent_TreeHeader'));
     $html .= content_tag('ul', $listItems, array('id' => 'ohrmTreeViewComponent_Tree'));
     return $html;
 }
Ejemplo n.º 18
0
function stylesheet_link_tag($file, $media = 'screen')
{
    return "<link href=\"" . stylesheet_path($file) . "\" media=\"{$media}\" rel=\"Stylesheet\" type=\"text/css\" />\n";
}
Ejemplo n.º 19
0
<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();
?>
" />
 /**
  * @see sfCombineCombiner
  */
 public function getAssetPath($file)
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers('Asset');
     return stylesheet_path($file);
 }
/**
 * This one is a copy from get_stylesheets from symfony except that it also looks for custom css
 */
function get_all_stylesheets($debug = false)
{
    $response = sfContext::getInstance()->getResponse();
    $response->setParameter('stylesheets_included', true, 'symfony/view/asset');
    $static_base_url = sfConfig::get('app_static_url');
    $already_seen = array();
    $html = '';
    foreach (array('first', '', 'last', 'print', 'custom_first', 'custom', 'custom_last') as $position) {
        foreach ($response->getStylesheets($position) as $files => $options) {
            if (!is_array($files)) {
                $files = array($files);
            }
            foreach ($files as $file) {
                $file = stylesheet_path($file);
                if (isset($already_seen[$file])) {
                    continue;
                }
                $already_seen[$file] = 1;
                $ts = sfTimestamp::getTimestamp($file);
                $prefix = $debug ? '/no' : '';
                $prefix = empty($ts) ? $prefix : '/' . $ts . $prefix;
                $html .= stylesheet_tag($static_base_url . $prefix . $file, $options);
            }
        }
    }
    return $html;
}
 /**
  * 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);
     // 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)));
 }
Ejemplo n.º 23
0
/**
 * Returns <link> tags for all stylesheets configured in view.yml or added to the response object.
 *
 * You can use this helper to decide the location of stylesheets in pages.
 * By default, if you don't call this helper, symfony will automatically include stylesheets before </head>.
 * Calling this helper disables this behavior.
 *
 * @return string <link> tags
 */
function get_stylesheets()
{
    $response = sfContext::getInstance()->getResponse();
    $response->setParameter('stylesheets_included', true, 'symfony/view/asset');
    $already_seen = array();
    $html = '';
    foreach (array('first', '', 'last') as $position) {
        foreach ($response->getStylesheets($position) as $files => $options) {
            if (!is_array($files)) {
                $files = array($files);
            }
            foreach ($files as $file) {
                $file = stylesheet_path($file);
                if (isset($already_seen[$file])) {
                    continue;
                }
                $already_seen[$file] = 1;
                $html .= stylesheet_tag($file, $options);
            }
        }
    }
    return $html;
}
Ejemplo n.º 24
0
    <?php 
include_http_metas();
?>
    <?php 
include_metas();
?>
    <?php 
include_title();
?>
    <link rel="shortcut icon" href="/favicon.ico" />
    <?php 
include_stylesheets();
?>
    <!--[if lt IE 8]>
      <link rel="stylesheet" href="<?php 
echo stylesheet_path($sf_theme->getConfig('ie_stylesheet'));
?>
" type="text/css" media="screen, projection">
    <![endif]-->
    <?php 
include_javascripts();
?>
  </head>

  <body>

<div id="wrapper">

<div id="header">

    <h1 id="site-title">
Ejemplo n.º 25
0
/**
 * Returns a css <link> tag per source given as argument,
 * to be included in the <head> section of a HTML document.
 *
 * <b>Options:</b>
 * - rel - defaults to 'stylesheet'
 * - type - defaults to 'text/css'
 * - media - defaults to 'screen'
 *
 * <b>Examples:</b>
 * <code>
 *  echo stylesheet_tag('style');
 *    => <link href="/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />
 *  echo stylesheet_tag('style', array('media' => 'all'));
 *    => <link href="/stylesheets/style.css" media="all" rel="stylesheet" type="text/css" />
 *  echo stylesheet_tag('style', array('raw_name' => true));
 *    => <link href="style" media="all" rel="stylesheet" type="text/css" />
 *  echo stylesheet_tag('random.styles', '/css/stylish');
 *    => <link href="/stylesheets/random.styles" media="screen" rel="stylesheet" type="text/css" />
 *       <link href="/css/stylish.css" media="screen" rel="stylesheet" type="text/css" />
 * </code>
 *
 * @param string asset names
 * @param array  additional HTML compliant <link> tag parameters
 *
 * @return string XHTML compliant <link> tag(s)
 * @see    stylesheet_path
 */
function stylesheet_tag()
{
    $sources = func_get_args();
    $sourceOptions = func_num_args() > 1 && is_array($sources[func_num_args() - 1]) ? array_pop($sources) : array();
    $html = '';
    foreach ($sources as $source) {
        $absolute = false;
        if (isset($sourceOptions['absolute'])) {
            unset($sourceOptions['absolute']);
            $absolute = true;
        }
        $condition = null;
        if (isset($sourceOptions['condition'])) {
            $condition = $sourceOptions['condition'];
            unset($sourceOptions['condition']);
        }
        if (!isset($sourceOptions['raw_name'])) {
            $source = stylesheet_path($source, $absolute);
        } else {
            unset($sourceOptions['raw_name']);
        }
        $options = array_merge(array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen', 'href' => $source), $sourceOptions);
        $tag = tag('link', $options);
        if (!is_null($condition)) {
            $tag = comment_as_conditional($condition, $tag);
        }
        $html .= $tag . "\n";
    }
    return $html;
}
Ejemplo n.º 26
0
 /**
  * Adds the <style> tag for the given $stylesheet.
  *
  * @param string $stylesheet
  * @return string
  */
 protected function getStyleTagFor($stylesheet)
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers(array("Asset"));
     return sprintf("<style>%s</style>", file_get_contents(stylesheet_path($stylesheet, true)));
 }