private function __construct() { $this->sessionContext = SessionContext::instance(); $this->pageContext = PageContext::instance(); $this->requestContext = RequestContext::instance(); $this->eventContext = EventContext::instance(); }
public function sayHello($name = 'Johnson', $prefix = 'Pie', $boo = '4') { $em = Zool::app()->em; if ($this->count > 10) { $this->count = 1; } $this->list = $em->createQuery('select b from app\\model\\Bug b where b.id > 1')->setFirstResult(0)->setMaxResults(15)->getResult(); PageContext::instance()->set('list', $this->list); RequestContext::instance()->set('listcount', count($this->list)); SessionContext::instance()->set('count', $this->count++); PageContext::instance()->set('textboxvalue', 'Szöveg'); return 'Helloka ' . $name . ' ' . $prefix . ' ' . $boo; }
public function __construct($config = array()) { parent::__construct($config); set_error_handler(array($this, 'errorHandler')); set_exception_handler(array($this, 'exceptionHandler')); $asp = isset($_GET['asp']) ? $_GET['asp'] : 'xul'; $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $reRender = isset($_REQUEST['reRender']) ? $_REQUEST['reRender'] : null; $zoolForm = isset($_REQUEST['zoolForm']) ? $_REQUEST['zoolForm'] : null; Annotations::$config['cachePath'] = APP_PATH . '/runtime'; // Zool specific annotations Annotations::getManager()->registry['scope'] = 'Annotation\\Standard\\ScopeAnnotation'; Annotations::getManager()->registry['method'] = 'Annotation\\Standard\\MethodAnnotation'; // obtaining the entity manager $em = $this->entityManager; if ($asp == 'xul') { $this->viewProvider = new ZXulViewProvider(); } else { $this->viewProvider = new ZWebViewProvider(); } /** * Input value binding */ if ($zoolForm !== null && is_array($zoolForm)) { foreach ($zoolForm as $key => $value) { list($var, $scope) = explode(':', $key, 2); try { if ($scope == UNSPECIFIED_SCOPE) { $scope = EVENT_SCOPE; } Contexts::instance()->setToContext($scope, $var, $value); } catch (ZException $e) { throw new ZException($e->getMessage()); } } } if ($action !== null) { $methodExpression = PageContext::instance()->get($action); if ($methodExpression instanceof ZMethodExpression) { $methodExpression->run(); } // there is no outputing } EventContext::instance()->reset(); if ($reRender !== null) { $this->viewProvider->handleReRender(); } if ($action !== null || $reRender !== null) { die; } }
protected function getActionHandlerScript($propertyName, $callBack = '', $data = array(), $dataString = '') { $methodExpression = $this->{$propertyName}; if (!$methodExpression instanceof ZMethodExpression) { throw new ZElementException('Action property must be ZMethodExpression.'); } $methodId = $methodExpression->getId(); PageContext::instance()->set($methodId, $methodExpression); $crp = $methodExpression->getContextRootPath(); PageContext::instance()->addToRootPaths($crp[0], $crp[1]); // TODO urlManager $url = 'http://' . $_SERVER['SERVER_NAME'] . '/zool/index.php'; $data['action'] = $methodId; $resultHandler = ''; if (!empty($this->reRender)) { $viewId = str_replace(APP_PATH, '', $this->document->viewId); /* * multiple rerender */ if (strpos($this->reRender, ',') !== false) { $reRenders = array_map('trim', explode(',', $this->reRender)); foreach ($reRenders as $key => $reRender) { if (strpos($reRender, ':') === false) { $reRenders[$key] = $viewId . ':' . $reRender; } } $this->reRender = implode(',', $reRenders); } elseif (strpos($this->reRender, ':') === false) { $this->reRender = $viewId . ':' . $this->reRender; } $data['reRender'] = $this->reRender; } $resultHandler = 'Zool.handleResponse(data);'; $resultHandler .= $callBack; $requestData = str_replace('"', "'", json_encode($data)); if ($dataString != '') { $replacement = $dataString . ', '; $requestData = substr_replace($requestData, $replacement, 1, 0); } return <<<SCRIPT (function(self){Sys.ajax({url:'{$url}', data: {$requestData}, parse: 'json', success: function(data){{$resultHandler}}});})(this); SCRIPT; }