Exemple #1
0
 /**
  * Call an action
  * @param <type> $routerInfo
  */
 public static function callAction($routerInfo = array())
 {
     $routerInfo['disableLayout'] = isset($routerInfo['disableLayout']) ? $routerInfo['disableLayout'] : true;
     $routerInfo['breakOnRender'] = false;
     $routerInfo['caller'] = 1;
     // 0 - call from internet request, 1 - call local
     K_Capture::start();
     K_Application::get()->executeRequest($routerInfo, true);
     // execute router with autoRender attribute
     return K_Capture::end();
 }
Exemple #2
0
 /**
 * Run & capture html + cache
 * @param Array $routerInfo - array( 'controller'=>'...', 'action'=>'...', 'module'=>'...', 'disableLayout'=true, ['params'=>array()] )
 * @param Array $cacheArray - array( 'manager'=>$cacheManagerObject, 'id'=>'cacheID', ['tags'=>array()], ['lifetime'=>(int)60])
 * @param bool $fastDrawCacheData - false - disabled, true - enabled, put content to output buffer & NOT RETURN RESULT HTML (return true on OK), works only if you use cache
 * @example
 		$this->call->html( 
 			array(
 				'module'=>'admin',
 				'controller'=>'index',
 				'action'=>'index',
 				'params'=>array(
 					'id'=>22
 				)
 			),
 			array(
 				'manager' => K_Registry::get('cacheManager')->getCache('unlim'),
 				'id'=>'admin_index_index_22_cache_id',
 				'tags'=>array(
 					'cache-by-call',
 					'id-22',
 					'admin-index-index-22'
 				),
 				'lifetime'=>120
 			),
 			true // on false you can use result HTML, and draw its manually (ONLY IF YOU USE CACHE)
 		);
 */
 public function html($routerInfo = array(), $cacheArray = null, $fastDrawCacheData = false)
 {
     // load from cache
     if (isset($cacheArray) && !empty($cacheArray) && is_array($cacheArray)) {
         if ($cacheArray['manager']->test($cacheArray['id'])) {
             return $cacheArray['manager']->loadRender($cacheArray['id'], $fastDrawCacheData);
         }
     }
     $routerInfo['disableLayout'] = isset($routerInfo['disableLayout']) ? $routerInfo['disableLayout'] : true;
     $routerInfo['breakOnRender'] = false;
     $routerInfo['caller'] = 1;
     // 0 - call from internet request, 1 - call local
     K_Capture::start();
     K_Application::get()->executeRequest($routerInfo, true, false);
     // execute router with autoRender attribute
     $html = K_Capture::end();
     // save to cache
     if (isset($cacheArray) && !empty($cacheArray) && is_array($cacheArray)) {
         $cacheArray['manager']->saveRender($cacheArray['id'], $html, isset($cacheArray['tags']) && is_array($cacheArray['tags']) ? $cacheArray['tags'] : array(), isset($cacheArray['lifetime']) ? (int) $cacheArray['lifetime'] : 0);
     }
     return $html;
 }
Exemple #3
0
 public function _render()
 {
     if ($this->_options['disableRender']) {
         if ($this->_options['breakOnRender']) {
             die or exit;
         }
         return;
     }
     if ($this->_options['breakOnRender']) {
         $headers = K_Application::get()->getHeaders();
         if (is_array($headers) && count($headers)) {
             foreach ($headers as $header) {
                 header($header, true);
                 // @TODO may be error TRUE/FALSE on replace
             }
         }
     }
     if (!empty($this->_options['ajaxOutput'])) {
         echo $this->_options['ajaxOutput'];
         die or exit;
     }
     if (is_array($this->_options['helpers']) && count($this->_options['helpers'])) {
         $viewHelper = K_ViewHelper::get();
         foreach ($this->_options['helpers'] as $helper) {
             $viewHelper->loadHelper($this, $helper);
         }
     }
     if (!$this->_options['disableLayout']) {
         $this->_loadLayout();
     } else {
         $this->context();
     }
     if ($this->_options['breakOnRender']) {
         K_Debug::get()->printAll();
         die or exit;
         // ;)
     }
 }
 public function __construct()
 {
     K_Debug::get()->enable(false);
     $this->application = K_Application::get();
     K_Registry::write('bootstrap', $this);
 }