Exemplo n.º 1
0
/**
 * Returns <script> tags with the url toward all javascripts configured in view.yml or added to the response object.
 *
 * You can use this helper to decide the location of javascripts in pages.
 * By default, if you don't call this helper, symfony will automatically include javascripts before </head>.
 * Calling this helper disables this behavior.
 *
 * @return string <script> tags
 */
function get_combined_javascripts()
{
    if (!sfConfig::get('app_sfCombinePlugin_enabled', false)) {
        return get_javascripts();
    }
    $response = sfContext::getInstance()->getResponse();
    sfConfig::set('symfony.asset.javascripts_included', true);
    $configSfCombinePlugin['js'] = sfConfig::get('app_sfCombinePlugin_js', array());
    $html = '';
    $jsFiles = $include_tags = array();
    foreach (array('first', '', 'last') as $position) {
        foreach ($response->getJavascripts($position) as $files => $options) {
            if (!in_array($files, $configSfCombinePlugin['js']['online']) && !in_array($files, $configSfCombinePlugin['js']['offline'])) {
                if (!is_array($files)) {
                    $files = array($files);
                }
                $jsFiles = array_merge($jsFiles, $files);
            } else {
                $include_tags[] = javascript_include_tag(url_for($files));
            }
        }
    }
    $key = _get_key($jsFiles);
    $include_tags[] = str_replace('.js', '', javascript_include_tag(url_for('sfCombine/js?key=' . $key)));
    return implode("", $include_tags);
}
  /**
   * Executes this filter.
   *
   * @param sfFilterChain $filterChain A sfFilterChain instance
   */
  public function execute($filterChain)
  {
    // execute next filter
    $filterChain->execute();

    // execute this filter only once
    $response = $this->context->getResponse();

    // include javascripts and stylesheets
    $content = $response->getContent();
    if (false !== ($pos = strpos($content, '</head>')))
    {
      $this->context->getConfiguration()->loadHelpers(array('Tag', 'Asset'));
      $html = '';
      if (!sfConfig::get('symfony.asset.javascripts_included', false))
      {
        $html .= get_javascripts($response);
      }
      if (!sfConfig::get('symfony.asset.stylesheets_included', false))
      {
        $html .= get_stylesheets($response);
      }

      if ($html)
      {
        $response->setContent(substr($content, 0, $pos).$html.substr($content, $pos));
      }
    }

    sfConfig::set('symfony.asset.javascripts_included', false);
    sfConfig::set('symfony.asset.stylesheets_included', false);
  }
/**
 * 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;
}
/**
 * Retrieves the javascripts tags from the response or the tmp js tag 
 * @return string
 */
function javascript_assets()
{
    sfContext::getInstance()->getConfiguration()->loadHelpers('Asset');
    // Update response after it gets totally loaded
    if (sfConfig::get('app_sf_assets_manager_plugin_alter_response', false)) {
        return sfConfig::get('app_sf_assets_manager_plugin_alter_response_tempjstag');
    } else {
        return get_javascripts();
    }
}
/**
 * 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;
}
 /**
  * Executes this filter.
  *
  * @param sfFilterChain A sfFilterChain instance
  */
 public function execute($filterChain)
 {
     // execute next filter
     $filterChain->execute();
     // execute this filter only once
     $response = $this->getContext()->getResponse();
     // include javascripts and stylesheets
     $content = $response->getContent();
     if (false !== ($pos = strpos($content, '</head>'))) {
         sfLoader::loadHelpers(array('Tag', 'Asset'));
         $html = '';
         if (!$response->getParameter('javascripts_included', false, 'symfony/view/asset')) {
             $html .= get_javascripts($response);
         }
         if (!$response->getParameter('stylesheets_included', false, 'symfony/view/asset')) {
             $html .= get_stylesheets($response);
         }
         if ($html) {
             $response->setContent(substr($content, 0, $pos) . $html . substr($content, $pos));
         }
     }
     $response->setParameter('javascripts_included', false, 'symfony/view/asset');
     $response->setParameter('stylesheets_included', false, 'symfony/view/asset');
 }
Exemplo n.º 7
0
/**
 * Prints <script> tags for all javascripts configured in view.yml or added to the response object.
 *
 * @see get_javascripts()
 */
function include_javascripts()
{
    echo get_javascripts();
}
Exemplo n.º 8
0
function a_get_javascripts()
{
    if (sfConfig::get('app_a_minify', false)) {
        $response = sfContext::getInstance()->getResponse();
        return _a_get_assets_body('javascripts', $response->getJavascripts());
    } else {
        return get_javascripts();
    }
}
Exemplo n.º 9
0
$t->is(_dynamic_path('module/action', 'js'), 'module/action?sf_format=js', '_dynamic_path() converts an internal URI to a URL');
$t->is(_dynamic_path('module/action?key=value', 'js'), 'module/action?key=value&sf_format=js', '_dynamic_path() converts an internal URI to a URL');
$t->is(_dynamic_path('module/action', 'js', true), '/module/action?sf_format=js', '_dynamic_path() converts an internal URI to a URL');

// dynamic_javascript_include_tag()
$t->diag('dynamic_javascript_include_tag()');
$t->is(dynamic_javascript_include_tag('module/action'), '<script type="text/javascript" src="module/action?sf_format=js"></script>'."\n", 'dynamic_javascript_include_tag() returns a tag relative to the given action');
$t->is(dynamic_javascript_include_tag('module/action', true), '<script type="text/javascript" src="/module/action?sf_format=js"></script>'."\n", 'dynamic_javascript_include_tag() takes an absolute boolean as its second argument');
$t->is(dynamic_javascript_include_tag('module/action', true, array('class' => 'foo')), '<script type="text/javascript" src="/module/action?sf_format=js" class="foo"></script>'."\n", 'dynamic_javascript_include_tag() takes an array of HTML attributes as its third argument');

$context->response = new myResponse($context->getEventDispatcher());

// use_dynamic_javascript()
$t->diag('use_dynamic_javascript()');
use_dynamic_javascript('module/action');
$t->is(get_javascripts(),
  '<script type="text/javascript" src="module/action?sf_format=js"></script>'."\n",
  'use_dynamic_javascript() register a dynamic javascript in the response'
);

// use_dynamic_stylesheet()
$t->diag('use_dynamic_stylesheet()');
use_dynamic_stylesheet('module/action');
$t->is(get_stylesheets(),
  '<link rel="stylesheet" type="text/css" media="screen" href="module/action?sf_format=css" />'."\n",
  'use_dynamic_stylesheet() register a dynamic stylesheet in the response'
);

class MyForm extends sfForm
{
  public function getStylesheets()
Exemplo n.º 10
0
$t->is(get_stylesheets(), '<link rel="stylesheet" type="text/css" media="screen" href="/css/style.css" />' . "\n" . '<link rel="stylesheet" type="text/css" media="screen" href="/css/style2.css" />' . "\n", 'get_stylesheets() returns all the stylesheets previously added by use_stylesheet()');
// _dynamic_path()
$t->diag('_dynamic_path()');
$t->is(_dynamic_path('module/action', 'js'), 'module/action?sf_format=js', '_dynamic_path() converts an internal URI to a URL');
$t->is(_dynamic_path('module/action?key=value', 'js'), 'module/action?key=value&sf_format=js', '_dynamic_path() converts an internal URI to a URL');
$t->is(_dynamic_path('module/action', 'js', true), '/module/action?sf_format=js', '_dynamic_path() converts an internal URI to a URL');
// dynamic_javascript_include_tag()
$t->diag('dynamic_javascript_include_tag()');
$t->is(dynamic_javascript_include_tag('module/action'), '<script type="text/javascript" src="module/action?sf_format=js"></script>' . "\n", 'dynamic_javascript_include_tag() returns a tag relative to the given action');
$t->is(dynamic_javascript_include_tag('module/action', true), '<script type="text/javascript" src="/module/action?sf_format=js"></script>' . "\n", 'dynamic_javascript_include_tag() takes an absolute boolean as its second argument');
$t->is(dynamic_javascript_include_tag('module/action', true, array('class' => 'foo')), '<script type="text/javascript" src="/module/action?sf_format=js" class="foo"></script>' . "\n", 'dynamic_javascript_include_tag() takes an array of HTML attributes as its third argument');
$context->response = new myResponse($context->getEventDispatcher());
// use_dynamic_javascript()
$t->diag('use_dynamic_javascript()');
use_dynamic_javascript('module/action');
$t->is(get_javascripts(), '<script type="text/javascript" src="module/action?sf_format=js"></script>' . "\n", 'use_dynamic_javascript() register a dynamic javascript in the response');
// use_dynamic_stylesheet()
$t->diag('use_dynamic_stylesheet()');
use_dynamic_stylesheet('module/action');
$t->is(get_stylesheets(), '<link rel="stylesheet" type="text/css" media="screen" href="module/action?sf_format=css" />' . "\n", 'use_dynamic_stylesheet() register a dynamic stylesheet in the response');
class MyForm extends sfForm
{
    public function getStylesheets()
    {
        return array('/path/to/a/foo.css' => 'all', '/path/to/a/bar.css' => 'print');
    }
    public function getJavaScripts()
    {
        return array('/path/to/a/foo.js', '/path/to/a/bar.js');
    }
}
Exemplo n.º 11
0
Arquivo: layout.php Projeto: EQ4/smint
?>
	<?php 
use_javascript('../smintplayer/js/slider.js');
?>
	<?php 
use_javascript('../smintplayer/js/jquery.ui.touch-punch.min.js');
?>

<!-- css should be before js for performance reasons -->
    <?php 
echo get_stylesheets();
?>

<!-- other js : should be at the end of all use_javascript calls -->
    <?php 
echo get_javascripts();
?>
    
    
   
    <link rel="icon" type="image/png" href="<?php 
echo image_path("favicon.png");
?>
" />



	<?php 
require_once dirname(__FILE__) . '/ga-tracking.php';
?>