Esempio n. 1
0
 /**
  * afterRender
  * 
  * @return void
  * @access public
  */
 function afterRender()
 {
     parent::afterRender();
     // コンテンツをフックする
     $this->_content = ob_get_contents();
 }
Esempio n. 2
0
 /**
  * use the callback of afterRender to inject all JS
  * this triggers AFTER the view, but BEFORE the layout
  * so if you need to customize $this->pathToJs, do so in the view
  * or you can pass in as settings
  * via Html->scriptBlock()
  */
 public function afterRender($viewFile = null)
 {
     $content = parent::afterRender($viewFile);
     if (!empty($this->js)) {
         $content .= $this->Html->css($this->pathToCss, null, array('inline' => false));
         //$content .= $this->Html->script( $this->pathToJs, array('inline' => false) );
         $this->Html->scriptBlock('jQuery(function() { ' . $this->js . '});', array('inline' => false));
     }
     return $content;
 }
Esempio n. 3
0
 /**
  * Callback
  *
  * @access public
  */
 public function afterRender()
 {
     if (!$this->enabled) {
         return;
     }
     parent::afterRender();
     $isDebug = (bool) Configure::read();
     if (empty($this->params['isAjax']) && empty($this->params['requested'])) {
         if (!empty($this->_uses)) {
             $uses = array();
             foreach ($this->_uses as $file) {
                 if (isset($this->fileMap[$file])) {
                     if (is_array($this->fileMap[$file])) {
                         $uses[] = $isDebug ? $this->fileMap[$file][1] : $this->fileMap[$file][0];
                     } else {
                         $uses[] = $this->fileMap[$file];
                     }
                 } else {
                     $uses[] = $file;
                 }
             }
             $this->Javascript->link($uses, false);
         }
         $this->Javascript->cacheEvents($this->cacheToFile, true);
         $this->Javascript->writeEvents(false);
     } else {
         echo $this->Javascript->writeEvents();
     }
     if (!empty($this->_scripts)) {
         $scripts = "\$(function(){\n\t";
         $scripts .= join(ife($isDebug, "\n\t", ' '), $this->_scripts);
         $scripts .= "\n});";
         $View = ClassRegistry::getObject('view');
         $View->set('bottom_for_layout', $this->Javascript->codeBlock($scripts));
     }
 }
Esempio n. 4
0
 /**
  * After Render
  *
  * @param string $viewFile
  */
 public function afterRender($viewFile)
 {
     parent::afterRender($viewFile);
     if (BcUtil::isAdminSystem()) {
         return;
     }
     if (empty($this->request->params['Site'])) {
         return;
     }
     if (isset($this->request->params['Site']['name']) && is_null($this->request->params['Site']['name'])) {
         return;
     }
     if (isset($this->request->params['Site']['device']) && $this->request->params['Site']['device'] != '') {
         return;
     }
     // 別URLの場合、alternateを出力(スマートフォンのみ対応)
     $pureUrl = $this->BcContents->getPureUrl($this->request->url, $this->request->params['Site']['id']);
     $agent = BcAgent::find('smartphone');
     $subSite = BcSite::findCurrentSub(false, $agent);
     if (!$subSite) {
         return;
     }
     $url = $subSite->makeUrl(new CakeRequest($pureUrl));
     $this->_View->set('meta', $this->BcHtml->meta('canonical', $this->BcHtml->url($url, true), ['rel' => 'canonical', 'media' => 'only screen and (max-width: 640px)', 'type' => null, 'title' => null, 'inline' => false]));
 }