/**
  * Renders the registered scripts.
  * Prevents rendering at the end of the controller, and waits until $this->render is true.
  *
  * @param string $output the existing output that needs to be inserted with script tags
  */
 public function render(&$output)
 {
     if (!$this->render) {
         return;
     }
     parent::render($output);
 }
Esempio n. 2
0
 public function render(&$output)
 {
     parent::render($output);
     if ($this->_minifyGroupsUpdated) {
         file_put_contents(Yii::app()->getRuntimePath() . "/minifyGroups.var", serialize($this->_minifyGroups));
     }
 }
Esempio n. 3
0
 /**
  * Method override to call @see removeAllPageLoadedScriptFilesWhenRenderingInAjaxMode
  * (non-PHPdoc)
  * @see CClientScript::render()
  */
 public function render(&$output)
 {
     if ($this->isAjaxMode()) {
         $this->removeAllPageLoadedScriptFilesWhenRenderingInAjaxMode();
     }
     parent::render($output);
 }
 /**
  * @depends testRenderScripts
  *
  * @dataProvider providerRenderScriptsBatch
  *
  * @param array $scriptBatch
  * @param integer $expectedScriptTagCount
  *
  * @see https://github.com/yiisoft/yii/issues/2770
  */
 public function testRenderScriptsBatch(array $scriptBatch, $expectedScriptTagCount)
 {
     $this->_clientScript->reset();
     foreach ($scriptBatch as $scriptParams) {
         $this->_clientScript->registerScript($scriptParams['id'], $scriptParams['script'], $scriptParams['position'], $scriptParams['htmlOptions']);
     }
     $output = '<head></head>';
     $this->_clientScript->render($output);
     $this->assertEquals($expectedScriptTagCount, substr_count($output, '<script'));
 }
Esempio n. 5
0
 /**
  * add JSONP-supporting functionality
  * using: $.getJSON('url?callback=?', function(html) {alert(html);});
  * see(http://api.jquery.com/jQuery.getJSON/#jsonp)
  * all registered scripts (non file) will evaluate on client automatically
  *
  * @param string $output
  */
 public function render(&$output)
 {
     if (Yii::app()->request->getIsAjaxRequest() && isset($_GET['callback'])) {
         $scripts = '';
         foreach ($this->scripts as $pos) {
             foreach ($pos as $script) {
                 $scripts .= $script;
             }
         }
         $output = $scripts . "\n" . $_GET['callback'] . '("' . addslashes($output) . '")';
     } else {
         parent::render($output);
     }
 }
Esempio n. 6
0
 public function render(&$output)
 {
     parent::render($output);
     // conditional js/css for IE
     if ($this->hasScripts) {
         $output = preg_replace('#(<(?:link|script) .+?) media="((?:[lg]te? )?IE \\d+)"(.*?>(?:</script>)?)#', '<!--[if \\2]>\\1\\3<![endif]-->', $output);
     }
 }
Esempio n. 7
0
 public function render(&$output)
 {
     $this->registerScriptInit();
     parent::render($output);
 }
Esempio n. 8
0
 /**
  * Код метода CClientScript::render() дополнен подсчётом статистики
  * и выводом отладочной информации в лог.
  * 
  * @param  string $output
  */
 public function render(&$output)
 {
     $this->startCounters('total');
     if ($this->cacheMutexName && Yii::app()->hasComponent($this->cacheMutexName)) {
         $this->cacheMutex = Yii::app()->getComponent($this->cacheMutexName);
         $this->features[] = 'mutex file processing';
     } else {
         $this->cacheMutexName = false;
     }
     // Если выставлен флаг отложенной обработки, но
     // не указана ревизия файлов или недоступен планировщик
     // заданий Yiiq, снимаем флаг.
     if ($this->delayed && (!$this->getAssetVersion() || !Yii::app()->hasComponent('yiiq'))) {
         $this->delayed = false;
     }
     if ($this->features) {
         Yii::trace('Yiisset started with ' . implode(', ', $this->features)) . '.';
     } else {
         Yii::trace('Yiisset started.');
     }
     if ($this->delayed) {
         $this->renderDelayed($output);
     } else {
         parent::render($output);
     }
     $this->stopCounters('total');
     arsort($this->counters);
     $statistics = array();
     foreach ($this->counters as $type => $time) {
         $statistics[] = str_pad($type . ':', 16) . "\t\t" . number_format($time, 4) . 's';
     }
     Yii::trace("Yiisset completed.\nStatistics (slowest first):\n" . implode("\n", $statistics));
 }