/**
 * 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;
}
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
0
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
0
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;
}
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
0
 /**
  * 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="&lt;p&gt;default&lt;/p&gt;">
         $content = str_replace('type="hidden"', 'type="text"', $content);
     }
     return $content;
 }
예제 #7
0
 /**
  * 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;
 }
/**
 * 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
0
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
0
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
0
파일: aHelper.php 프로젝트: hashir/UoA
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;
}
예제 #12
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');
예제 #13
0
파일: layout.php 프로젝트: ArnaudD/RdvZ
      <?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
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');
예제 #15
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 sfCombinePlusCombiner
  */
 protected function _getAssetPath($file)
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers('Asset');
     return javascript_path($file);
 }
예제 #17
0
/**
 *
 * @author fabriceb
 * @since May 27, 2009 fabriceb
 */
function include_facebook_connect_script_src()
{
    if (sfFacebook::isJsLoaded()) {
        return;
    }
    ?>
  <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/<?php 
    echo sfFacebook::getLocale();
    ?>
" type="text/javascript"></script>
  <script src="<?php 
    echo javascript_path('/sfFacebookConnectPlugin/js/sfFacebookConnect');
    ?>
" type="text/javascript"></script>
  <?php 
    sfFacebook::setJsLoaded();
}
예제 #18
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;
 }
예제 #19
0
    /**
     * 
     * @param  string $name        The element name
     * @param  string $value       The value displayed in this widget
     * @param  array  $options     The options set on the aWidgetFormRichTextarea object (id, tool, width, height)
     * @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 aEditor
     */
    public function render($name, $value, $options, $attributes, $errors)
    {
        $attributes = array_merge($attributes, $options);
        $attributes = array_merge($attributes, array('name' => $name));
        // TBB: a sitewide additional config settings file is used, if it
        // exists and a different one has not been explicitly specified
        if (!isset($attributes['config'])) {
            if (file_exists(sfConfig::get('sf_web_dir') . '/js/fckextraconfig.js')) {
                $attributes['config'] = '/js/fckextraconfig.js';
            }
        }
        // Merged in from Symfony 1.3's FCK rich text editor implementation,
        // since that is no longer available in 1.4
        $options = $attributes;
        // sf_web_dir already contains the relative root, don't append it twice
        $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 widget (see rich_text_fck_js_dir settings). ' . sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $php_file);
        }
        // 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);
        // What if the name isn't an acceptable id?
        $fckeditor = new FCKeditor($options['name']);
        $fckeditor->BasePath = sfContext::getInstance()->getRequest()->getRelativeUrlRoot() . '/' . sfConfig::get('sf_rich_text_fck_js_dir') . '/';
        $fckeditor->Value = $value;
        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'])) {
            // We need the asset helper to load things via javascript_path
            sfContext::getInstance()->getConfiguration()->loadHelpers(array('Asset'));
            $fckeditor->Config['CustomConfigurationsPath'] = javascript_path($options['config']);
        }
        $content = $fckeditor->CreateHtml();
        // Skip the braindead 'type='text'' hack that breaks Safari
        // in 1.0 compat mode, since we're in a 1.2+ widget here for sure
        // We must register an a.onSubmit handler to be sure of updating the
        // hidden field when a richtext slot or other AJAX context is updated
        $content .= <<<EOM
<script type="text/javascript" charset="utf-8">
\$(function() {
  \$('#{$name}').addClass('a-needs-update');
  \$('#{$name}').bind('a.update', function() {
    var value = FCKeditorAPI.GetInstance('{$name}').GetXHTML();
    \$('#{$name}').val(value);
  });
});
</script>
EOM;
        return $content;
    }
/**
 *
 * @author fabriceb
 * @since May 27, 2009 fabriceb
 */
function include_facebook_connect_script_src()
{
    if (sfFacebook::isJsLoaded()) {
        return;
    }
    ?>
  <div id="fb-root"></div>
  <script src="http://connect.facebook.net/<?php 
    echo sfFacebook::getLocale();
    ?>
/all.js"></script>
  <script src="<?php 
    echo javascript_path('/sfFacebookConnectPlugin/js/sfFacebookConnect');
    ?>
" type="text/javascript"></script>
  <?php 
    sfFacebook::setJsLoaded();
}
예제 #21
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 
 public static function getPlugins()
 {
     return array('opSyntaxHighlight' => javascript_path('/opRichTextareaSyntaxHighlightPlugin/js/tiny_mce/editor_plugin'));
 }
/**
 * 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_javascripts()
{
    $response = sfContext::getInstance()->getResponse();
    $response->setParameter('javascripts_included', true, 'symfony/view/asset');
    $already_seen = array();
    $html = '';
    foreach (array('first', '', 'last') as $position) {
        foreach ($response->getJavascripts($position) as $files) {
            if (!is_array($files)) {
                $files = array($files);
            }
            foreach ($files as $file) {
                $file = javascript_path($file);
                if (isset($already_seen[$file])) {
                    continue;
                }
                $already_seen[$file] = 1;
                $html .= javascript_include_tag($file);
            }
        }
    }
    return $html;
}
예제 #24
0
$t->is(stylesheet_tag('style', array('raw_name' => true)), '<link rel="stylesheet" type="text/css" media="screen" href="style" />' . "\n", 'stylesheet_tag() can take a raw_name option to bypass file name decoration');
$t->is(stylesheet_tag('style', array('condition' => 'IE 6')), '<!--[if IE 6]><link rel="stylesheet" type="text/css" media="screen" href="/css/style.css" /><![endif]-->' . "\n", 'stylesheet_tag() can take a condition option');
// javascript_include_tag()
$t->diag('javascript_include_tag()');
$t->is(javascript_include_tag('xmlhr'), '<script type="text/javascript" src="/js/xmlhr.js"></script>' . "\n", 'javascript_include_tag() takes a javascript name as its first argument');
$t->is(javascript_include_tag('common.javascript', '/elsewhere/cools'), '<script type="text/javascript" src="/js/common.javascript"></script>' . "\n" . '<script type="text/javascript" src="/elsewhere/cools.js"></script>' . "\n", 'javascript_include_tag() can takes n javascript file names as its arguments');
$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');
 /**
  * @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;
 }
 /**
  * @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
  *
  * This is mostly borrowed from the Symfony 1.3 sf Rich Text Editor FCK class,
  * (don't want to say it out loud and make project:validate worry),
  * which is gone in Symfony 1.4 and not autoloadable in Symfony 1.3.
  * Note that we are now officially FCK-specific. That was pretty much
  * true already (notice our fckextraconfig.js trick below). 
  *
  * NOTE: THE ID IS IGNORED, FCK always sets the name and id attributes
  * of the hidden input field or fallback textarea to the same value. 
  * This is a misfeature of FCK, not something we can fix here without
  * breaking the association between the hidden field and the rich text
  * editor. ALWAYS USE setNameFormat() in your form class to give your
  * form fields names that will distinguish them from any other forms
  * in the same page, otherwise your rich text fields will behave in
  * unexpected ways.
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $attributes = array_merge($attributes, $this->getOptions());
     $attributes = array_merge($attributes, array('name' => $name));
     // This is good form, but doesn't really work with FCK, which
     // does not support a name that is distinct from the id
     $attributes = $this->fixFormId($attributes);
     // TBB: a sitewide additional config settings file is used, if it
     // exists and a different one has not been explicitly specified
     if (isset($attributes['editor']) && strtolower($attributes['editor']) === 'fck') {
         if (!isset($attributes['config'])) {
             if (file_exists(sfConfig::get('sf_web_dir') . '/js/fckextraconfig.js')) {
                 $attributes['config'] = '/js/fckextraconfig.js';
             }
         }
     }
     // Merged in from Symfony 1.3's FCK rich text editor implementation,
     // since that is no longer available in 1.4
     $options = $attributes;
     $id = $options['id'];
     $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 widget (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);
     // What if the name isn't an acceptable id?
     $fckeditor = new FCKeditor($options['name']);
     $fckeditor->BasePath = sfContext::getInstance()->getRequest()->getRelativeUrlRoot() . '/' . sfConfig::get('sf_rich_text_fck_js_dir') . '/';
     $fckeditor->Value = $value;
     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'])) {
         // We need the asset helper to load things via javascript_path
         sfContext::getInstance()->getConfiguration()->loadHelpers(array('Asset'));
         $fckeditor->Config['CustomConfigurationsPath'] = javascript_path($options['config']);
     }
     $content = $fckeditor->CreateHtml();
     // Skip the braindead 'type='text'' hack that breaks Safari
     // in 1.0 compat mode, since we're in a 1.2+ widget here for sure
     return $content;
 }
예제 #27
0
/**
 * Returns a <script> include tag per source given as argument.
 *
 * <b>Examples:</b>
 * <code>
 *  echo javascript_include_tag('xmlhr');
 *    => <script language="JavaScript" type="text/javascript" src="/js/xmlhr.js"></script>
 *  echo javascript_include_tag('common.javascript', '/elsewhere/cools');
 *    => <script language="JavaScript" type="text/javascript" src="/js/common.javascript"></script>
 *       <script language="JavaScript" type="text/javascript" src="/elsewhere/cools.js"></script>
 * </code>
 *
 * @param string asset names
 * @param array additional HTML compliant <link> tag parameters
 *
 * @return string XHTML compliant <script> tag(s)
 * @see    javascript_path
 */
function javascript_include_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 = javascript_path($source, $absolute);
        } else {
            unset($sourceOptions['raw_name']);
        }
        $options = array_merge(array('type' => 'text/javascript', 'src' => $source), $sourceOptions);
        $tag = content_tag('script', '', $options);
        if (!is_null($condition)) {
            $tag = comment_as_conditional($condition, $tag);
        }
        $html .= $tag . "\n";
    }
    return $html;
}
 protected function getAssetPath($file)
 {
     sfProjectConfiguration::getActive()->loadHelpers('Asset');
     return javascript_path($file);
 }
예제 #29
0
  
		<script type="text/javascript" src="http://www.google.com/jsapi"></script>
		<script type="text/javascript" charset="utf-8">
			google.load('jquery','1.4');
			google.load('jqueryui', '1.8');
		</script>

		<?php 
use_stylesheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/cupertino/jquery-ui.css');
?>
		<script type="text/javascript" src="<?php 
echo javascript_path('jquery/fancybox/jquery.fancybox-1.3.1.pack.js');
?>
"></script>
		<link rel="stylesheet" href="<?php 
echo javascript_path('jquery/fancybox/jquery.fancybox-1.3.1.css');
?>
" type="text/css" media="screen" title="no title" charset="utf-8">
    <?php 
include_stylesheets();
?>
    <?php 
include_javascripts();
?>
</head>
  <body>
    <div id="header">
			<div class="container_16 clearfix">
				<div class="grid_5">
					<a href="<?php 
echo url_for('@homepage');
예제 #30
0
?>
" class="gadgets-gadget" name="remote_iframe_<?php 
echo $memberApplication->getId();
?>
" id="remote_iframe_<?php 
echo $memberApplication->getId();
?>
"></iframe>
</div>
</div></div>
<?php 
javascript_tag();
?>
(function (){
gadgets.rpc.setRelayUrl("remote_iframe_<?php 
echo $memberApplication->getId();
?>
", "<?php 
echo javascript_path('/opOpenSocialPlugin/js/rpc_relay.html', true);
?>
");
gadgets.rpc.setAuthToken("remote_iframe_<?php 
echo $memberApplication->getId();
?>
", "<?php 
echo $rpcToken;
?>
");
})();
<?php 
end_javascript_tag();