script() public method

public script ( )
Example #1
0
 /**
  * load Anywhere script
  *
  * @param string $dataSource
  * @param string $apiKey
  * @param string $apiVersion
  */
 public function loadScript($dataSource = 'twitter', $apiKey = null, $apiVersion = 1)
 {
     if (empty($apiKey)) {
         /* @var $ds TwitterSource */
         $ds = ConnectionManager::getDataSource($dataSource);
         if (!empty($ds->config['api_key'])) {
             $apiKey = $ds->config['api_key'];
         }
     }
     $params = array('id' => $apiKey, 'v' => $apiVersion);
     return $this->Html->script(self::$anywhereUri . Router::queryString($params, array(), true));
 }
Example #2
0
 /**
  * Returns one or many `<script>` tags depending on the number of scripts given.
  *
  * If the filename is prefixed with "//", it will be returned early as its a special http(s) indepenent url.
  *
  * If the filename is prefixed with "/", the path will be relative to the base path of your
  * application.  Otherwise, the path will be relative to your JavaScript path, usually webroot/js.
  *
  * Can include one or many Javascript files.
  *
  * ### Options
  *
  * - `inline` - Whether script should be output inline or into scripts_for_layout.
  * - `once` - Whether or not the script should be checked for uniqueness. If true scripts will only be
  *   included once, use false to allow the same script to be included more than once per request.
  *
  * @param mixed $url String or array of javascript files to include
  * @param mixed $options Array of options, and html attributes see above. If boolean sets $options['inline'] = value
  * @return mixed String of `<script />` tags or null if $inline is false or if $once is true and the file has been
  *   included before.
  * @access public
  * @link http://book.cakephp.org/view/1589/script
  */
 function script($url, $options = array())
 {
     if (strpos((string) $url, '//') !== false) {
         return sprintf($this->tags['javascriptlink'], $url, null);
     }
     return parent::script($url, $options);
 }
 public function bootstrapScript($url = 'bootstrap.min.js', $options = array())
 {
     $pluginRoot = dirname(dirname(DIRNAME(__FILE__)));
     $pluginName = end(explode(DS, $pluginRoot));
     $url = '/' . Inflector::underscore($pluginName) . '/js/' . $url;
     return parent::script($url, $options);
 }
 /**
  * (non-PHPdoc)
  * @see GalleryHelper::get_markup()
  */
 public function get_markup()
 {
     if (empty($this->images)) {
         return '';
     }
     if (empty($this->unid)) {
         $this->calculate_unique();
     }
     $this->load_assets();
     $list = array();
     foreach ($this->images as $k => $image) {
         $list[] = $this->render_element($k);
     }
     $first_image = array_shift($list);
     /*$src = '/images/ajax-loader.gif';
     		if(file_exists(get_stylesheet_directory().$src))
     			$src = get_stylesheet_directory_uri().$src;
     		
     		if(file_exists(get_template_directory().$src))
     			$src = get_template_directory_uri().$src;
     		
     		$first_image = HtmlHelper::image($src, array('id'=>'loading-gif'));*/
     $script = HtmlHelper::script(json_encode($list), array('id' => 'script_' . $this->unid));
     $defaults = array('id' => $this->unid, 'class' => 'cycle-slideshow', 'data-cycle-loader' => 'true', 'data-cycle-progressive' => '#script_' . $this->unid);
     return HtmlHelper::div($first_image . $script, wp_parse_args($this->cycle_attrs, $defaults));
 }
Example #5
0
 public function test_void_elements()
 {
     $h = new HtmlHelper();
     $this->assertEquals('<area />', $h->area()->toString());
     $this->assertEquals('<br />', $h->BR()->toString());
     $this->assertEquals('<script></script>', $h->script()->toString());
 }
Example #6
0
 /**
  * create tweet button
  *
  * @see http://dev.twitter.com/pages/tweet_button
  * @param string  $label
  * @param array   $options
  * @param boolean $dataAttribute
  * @param boolean $scriptInline
  * @return string
  */
 public function tweetButton($label = null, $options = array(), $dataAttribute = false, $scriptInline = false)
 {
     $attributes = array();
     $defaults = array('class' => 'twitter-share-button', 'url' => '', 'via' => '', 'text' => '', 'related' => '', 'count' => 'horizontal', 'lang' => 'en', 'counturl' => '');
     if (empty($label)) {
         $label = 'Tweet';
     }
     $options = am($defaults, $options);
     $attributes['class'] = $options['class'];
     unset($options['class']);
     $options['count'] = strtolower($options['count']);
     if (!in_array($options['count'], array('none', 'horizontal', 'vertical'))) {
         $options['count'] = 'none';
     }
     $options = Set::filter($options);
     if ($dataAttribute) {
         foreach ($options as $key => $val) {
             $attributes['data-' . $key] = $val;
         }
         $options = array();
     }
     $out = $this->Html->link($label, 'http://twitter.com/share' . Router::queryString($options), $attributes);
     $out .= $this->Html->script('http://platform.twitter.com/widgets.js', array('inline' => $scriptInline));
     return $this->output($out);
 }
Example #7
0
 /**
  * load Anywhere script
  *
  * @param array $options
  * @return string
  */
 public function loadScript($options = array())
 {
     $dataSource = $apiKey = $apiVersion = null;
     $defaults = array('dataSource' => 'twitter', 'apiKey' => null, 'apiVersion' => 1, 'inline' => false);
     $options = am($defaults, $options);
     extract($options, EXTR_OVERWRITE);
     unset($options['dataSource']);
     unset($options['apiKey']);
     unset($options['apiVersion']);
     if (empty($apiKey)) {
         /* @var $ds TwitterSource */
         $ds = ConnectionManager::getDataSource($dataSource);
         if (!empty($ds->config['api_key'])) {
             $apiKey = $ds->config['api_key'];
         }
     }
     $params = array('id' => $apiKey, 'v' => $apiVersion);
     return $this->Html->script(self::$anywhereUri . Router::queryString($params, array(), true), $options);
 }
 /**
  * _addScripts method
  *
  * Adds properties
  *
  * @param mixed $view
  * @return boolean
  */
 public function _addScripts($view)
 {
     if ($this->request->params['plugin'] == 'lil_tasks' || $this->request->params['plugin'] == 'lil' && $this->request->params['action'] == 'admin_dashboard') {
         App::uses('HtmlHelper', 'View/Helper');
         $Html = new HtmlHelper($view);
         $Html->css('/lil_tasks/css/lil_tasks.css', null, array('inline' => false));
         $Html->script('/lil_tasks/js/lil_tasks.js');
     }
     return true;
 }
Example #9
0
 public function script($src = "", $attr = array(), $full = false)
 {
     $tags = "";
     if (is_array($src)) {
         foreach ($src as $tag) {
             $tags .= HtmlHelper::script($tag, $attr, $full) . PHP_EOL;
         }
         return $tags;
     }
     $attrs = array("src" => $this->internalUrl("/scripts", $src, $full), "type" => "text/javascript");
     $attr = array_merge($attrs, $attr);
     return $this->output($this->tag("script", null, $attr));
 }
Example #10
0
 public function script($url, $options = array())
 {
     $options += array('assetFilter' => true);
     if (!$options['assetFilter']) {
         $__backup = Configure::read('Asset.filter.js');
         Configure::write('Asset.filter.js', null);
     }
     unset($options['assetFilter']);
     $result = parent::script($url, $options);
     if (isset($__backup)) {
         Configure::write('Asset.filter.js', $__backup);
     }
     return $result;
 }
Example #11
0
 public function scriptsForLayout($type = null)
 {
     $scripts = '';
     $files = $this->Baklava->getCombined();
     foreach ($files as $t => $file) {
         if ($type && $type != $t) {
             continue;
         }
         switch ($t) {
             case 'css':
                 $scripts .= parent::css($file, null, array('inline' => true));
                 break;
             case 'js':
                 $scripts .= parent::script($file, array('inline' => true, 'defer' => true));
                 break;
             case 'style':
                 $scripts .= parent::tag('style', $file, array('type' => 'text/css'));
                 break;
         }
     }
     return $scripts;
 }
 /**
  * Get a <script> tag with a JSON variable in it.
  * @example GMapDataRetriever.example.json
  * @return string
  */
 function get_script_content()
 {
     return HtmlHelper::script('var map_info = ' . json_encode($this->map_data));
 }
 /**
  * Callback for wp_footer, prints the window.tests variable
  * Useful to read the information on a external node.js environment (ex zombiejs)
  */
 public function on_print_footer_script()
 {
     echo HtmlHelper::script('window.tests = ' . json_encode($this->tests) . ';');
 }
Example #14
0
 /**
  * Include Zuluru-specific JS files from the configured location.
  * This replicates a bare minimum of the main HtmlHelper's js function,
  * to avoid prefixing absolute paths. Everything else is passed to the
  * parent for processing.
  */
 function script($path, $options = array())
 {
     $base = Configure::read('urls.zuluru_js');
     if (is_array($path)) {
         $scripts = array();
         foreach ($path as $i) {
             $scripts[] = $this->script($i, $options);
         }
         return implode("\n", $scripts);
     }
     if (strpos($path, '://') !== false) {
         $url = $path;
     } else {
         if ($path[0] !== '/') {
             $url = $base . $path;
         }
     }
     return parent::script($url, $options);
 }
    /**
     * Retrieves some usefull meta tags for the <head>
     * @return some usefull meta tags for the <head>
     */
    public function get_head()
    {
        $meta_tags = $this->render_meta_tags();
        $title = esc_html($this->title);
        $desc = $this->render_meta_tag('description');
        $ga_tracking = '';
        $favicon = $this->locate_favicon();
        /*file_exists(get_stylesheet_directory().'/images/favicon.ico')
        		? get_stylesheet_directory_uri()
        		: get_template_directory_uri();*/
        if (!empty($this->ua)) {
            $ga_tracking = HtmlHelper::script(<<<EOF
     var _gaq = _gaq || [];
     _gaq.push(['_setAccount', '{$this->ua}'],
     ['_setDomainName', 'none'],
     ['_setAllowLinker', true ],
     ['_trackPageview'],
     ['_trackPageLoadTime'],
     ['second._setAccount', 'UA-4717938-7'],
     ['second._setDomainName', 'none'],
     ['second._trackPageview'],
     ['second._trackPageLoadTime']
      );
     (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
EOF
);
        }
        $custom_scripts = '';
        if (count($this->custom_scripts)) {
            foreach ($this->custom_scripts as $name => $script) {
                $custom_scripts = HtmlHelper::script($script, array('id' => $name));
            }
        }
        echo <<<EOF
\t\t<title>{$title}</title>
\t\t{$desc}
\t    <meta charset="{$this->charset}">
\t    {$meta_tags}
\t    <link rel="shortcut icon" href="{$favicon}">
\t    {$ga_tracking}
\t    {$custom_scripts}
EOF;
    }
    /**
     * Prints some javascript to simulate the iframe
     * loaded event while serving the cache
     */
    public function javascript_fix()
    {
        add_action('wp_footer', array(&$this, 'on_footer_scripts'));
        //return HtmlHelper::script('', array('src'=>'http://hotelsitecontents.fastbooking.com/js/fb.js'));
        $toret = <<<EOF

    var FB                  = FB || {};
    FB.Loader               = {};
    FB.Loader.eventType     = {
        BEFORE_LOADING: 0,
        AFTER_LOADING: 1
    };
    FB.Loader.Events        = [];
    FB.Loader.attachEvent   = function (e, t) {
        this.Events.push(t);
    };

EOF;
        return HtmlHelper::script($toret);
    }
Example #17
0
 /**
  * Load JS for the current page
  *
  * @param array $arrayJs Names of JS for the current page
  * @return string 		 A script tag for the head element
  */
 public function js($arrayJs = array())
 {
     $out = parent::script($this->pathJquery);
     $out .= parent::script($this->pathJS);
     // Others JS
     foreach ($arrayJs as $js) {
         $out .= parent::script($js);
     }
     return $out;
 }