public function aboutAction() { if ($this->_request->isXmlHttpRequest()) { $layout = Zend_Layout::getMvcInstance(); $layout->disableLayout(); } }
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { $auth = Zend_Auth::getInstance(); $result = $auth->getStorage(); $identity = $auth->getIdentity(); $registry = Zend_Registry::getInstance(); $config = Zend_Registry::get('config'); $module = strtolower($this->_request->getModuleName()); $controller = strtolower($this->_request->getControllerName()); $action = strtolower($this->_request->getActionName()); if ($identity && $identity != "") { $layout = Zend_Layout::getMvcInstance(); $view = $layout->getView(); $view->login = $identity; $siteInfoNamespace = new Zend_Session_Namespace('siteInfoNamespace'); $id = $siteInfoNamespace->userId; $view->firstname = $siteInfoNamespace->Firstname; $username = $siteInfoNamespace->username; $password = $siteInfoNamespace->password; $db = new Zend_Db_Adapter_Pdo_Mysql(array('host' => $config->resources->db->params->host, 'username' => $username, 'password' => $password, 'dbname' => $config->resources->db->params->dbname)); Zend_Db_Table_Abstract::setDefaultAdapter($db); return; } else { $siteInfoNamespace = new Zend_Session_Namespace('siteInfoNamespace'); $siteInfoNamespace->requestURL = $this->_request->getParams(); $this->_request->setModuleName('default'); $this->_request->setControllerName('Auth'); $this->_request->setActionName('login'); } }
public function routeShutdown(Zend_Controller_Request_Abstract $request) { Zend_Layout::getMvcInstance()->setLayout($request->getModuleName()); Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/modules/" . $request->getModuleName() . "/layouts/scripts"); $eh = Zend_Controller_Front::getInstance()->getPlugin("Zend_Controller_Plugin_ErrorHandler"); $eh->setErrorHandlerModule($request->getModuleName()); }
function init() { $this->_redirector = $this->_helper->getHelper('Redirector'); $this->_layout = $this->_helper->getHelper('Layout'); $this->_flashMessenger = $this->_helper->getHelper('FlashMessenger'); //Get Controller,Action,Module Name $this->_moduleName = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $this->_controllerName = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $this->_actionName = Zend_Controller_Front::getInstance()->getRequest()->getActionName(); $this->_cleanUrl = $this->view->rootUrl() . '/' . $this->_moduleName . '/' . $this->_controllerName . '/' . $this->_actionName; //get user profile $this->setUserProfile(); //Set layout $layout = Zend_Layout::getMvcInstance(); $layout->setLayoutPath(APPLICATION_PATH . '/modules/admin/layouts'); $layout->setLayout('admin'); //set redirector helper $this->_redirector = $this->_helper->getHelper('Redirector'); //set flash messenger $this->_flash = $this->_helper->FlashMessenger; //set Edit state if ($this->_actionName == 'edit') { $this->view->state_edit = TRUE; } //set paginator session $this->_paginator_sess = new Zend_Session_Namespace('paginator'); $this->setPaginatorSession(); //set default language (untuk sementara) Zend_Registry::set('language', 'en'); }
public function preDispatch(Zend_Controller_Request_Abstract $request) { if (!isset($_SERVER['HTTP_USER_AGENT']) || isset($_SERVER['HTTP_USER_AGENT']) && false === strpos($_SERVER['HTTP_USER_AGENT'], 'sanmax-crawler-bot')) { return; } $config = array('accept_schemes' => 'basic', 'realm' => 'crawler', 'digest_domains' => '/', 'nonce_timeout' => 3600); $adapter = new Zend_Auth_Adapter_Http($config); $basicResolver = new Zend_Auth_Adapter_Http_Resolver_File(APPLICATION_PATH . '/var/bot-basic'); $adapter->setBasicResolver($basicResolver); $response = Zend_Controller_Front::getInstance()->getResponse(); $adapter->setRequest($request); $adapter->setResponse($response); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($adapter); if (!$result->isValid()) { $response->sendHeaders(); exit; } $user = new SxCms_User(); $gMapper = new SxCms_Group_DataMapper(); $groups = $gMapper->getAll(); foreach ($groups as $group) { $user->addGroup($group); } $storage = $auth->getStorage(); $storage->write($user); $front = Zend_Controller_Front::getInstance(); $front->setParam('isBot', true); $mvc = Zend_Layout::getMvcInstance(); $view = $mvc->getView(); $view->isBot = true; return; }
public function updateScreenshot($values) { if (!empty($values['project'])) { $this->project_id = $values['project']; } if (!empty($values['description'])) { $this->description = $values['description']; } if ($values['file'] instanceof Zend_Form_Element_File) { $file = $values['file']->receive(); if (!$file) { throw new Zend_Exception('There was an error with the file upload.'); } if (!empty($this->screenshot)) { $file = explode('/', $this->screenshot); $file = $file[count($file) - 1]; @unlink(realpath(UPLOAD_PATH . '/screenshots/') . DIRECTORY_SEPARATOR . $file); } if (!empty($values['screen'])) { $view = Zend_Layout::getMvcInstance()->getView(); $this->screenshot = $view->baseUrl('/upload/screenshots/' . $values['screen']); } } $this->save(); }
public function preDispatch(Zend_Controller_Request_Abstract $request) { $flash = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger'); $mvc = Zend_Layout::getMvcInstance(); $view = $mvc->getView(); $view->flashMessages = $flash->getMessages(); }
public function preDispatch(Zend_Controller_Request_Abstract $request) { $module = $request->getModuleName(); if ($module != 'default') { Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . "layouts" . DIRECTORY_SEPARATOR . "scripts"); } }
public function preDispatch(Zend_Controller_Request_Abstract $request) { Zend_Auth::getInstance()->setStorage(new Dfi_Auth_Storage_Cookie('user')); /** @var Zend_Controller_Request_Http $request */ $request = $this->getRequest(); $bypass = $this->isBypassRequest($request->getModuleName(), $request->getControllerName(), $request->getActionName()); if (!Zend_Auth::getInstance()->hasIdentity() && !$bypass) { if ($request->isXmlHttpRequest()) { $response = $this->getResponse(); $data = array('auth' => true); $output = json_encode($data); $response->setHeader('Content-Type', 'application/json', true); $this->getResponse()->setBody($output); $this->getResponse()->sendResponse(); exit; } else { if ($request->getControllerName() == 'index' && $request->getActionName() == 'index') { if (!Zend_Layout::getMvcInstance()) { $layoutPath = Dfi_App_Config::get('layout.layoutPath'); Zend_Layout::startMvc($layoutPath); } } $request->setControllerName('login'); $request->setActionName('index'); $request->setModuleName('default'); } } }
/** * Show categories list ( based on parent_id ). if no sub category found - will forward to products list * * @var integer $pcategory Parent category */ public function indexAction() { $categoriesModel = new Model_DbTable_Categories(); $select = $categoriesModel->select(); if (NULL != ($parent_id = $this->getRequest()->getParam("category"))) { $category = $categoriesModel->find($parent_id)->current(); $this->view->category = $category; $select->where("`parent_id` = ?", $parent_id); $this->view->headTitle()->prepend("Альфа-Гидро: Каталог продукции - " . $category['name']); } else { $select->where("`parent_id` = ?", 0); $this->view->headTitle()->prepend("Альфа-Гидро: Продукция"); } $select->order(new Zend_Db_Expr('`order`<=-100'))->order("order"); if (!Zend_Auth::getInstance()->hasIdentity()) { $select->where("`order` != -100 OR `order` IS NULL"); } $this->view->rowset = $categoriesModel->fetchAll($select); if ($this->getRequest()->isXmlHttpRequest()) { $this->view->curRowId = $this->getRequest()->getParam("currentCategory"); $this->_helper->viewRenderer->setRender('index-ajax'); Zend_Layout::getMvcInstance()->disableLayout(); return; } if (count($this->view->rowset) == 0) { $this->forward("index", "products"); return; } }
public function indexAction() { $this->_helper->viewRenderer->setNoRender(false); $this->_helper->layout()->enableLayout(); if ($this->getRequest()->isPost()) { if ($this->_getParam('num_cnpj') == '') { Zend_Layout::getMvcInstance()->assign('msg_error', 'Campo CNPJ é obrigatório !'); } else { if (strlen($this->_getParam('num_cnpj')) < 18) { Zend_Layout::getMvcInstance()->assign('msg_error', 'CNPJ está incorreto !'); } else { $num_cnpj = $this->_getParam('num_cnpj', ''); $this->view->assign('num_cnpj', $num_cnpj); // Incluir arquivo de cliente web service require_once 'Zend/Rest/Client.php'; // Criar classe da conexão com o web-service $clientRest = new Zend_Rest_Client('http://' . $_SERVER['HTTP_HOST'] . '/Consulta/sintegra'); // Fazer requisição do registro $result = $clientRest->ConsultarRegistro($num_cnpj, $this->generateAuthKey())->get(); $result = json_decode($result); if (count($result) <= 0) { Zend_Layout::getMvcInstance()->assign('msg_error', 'Não foi encontrado nenhum registro para o CNPJ ' . $num_cnpj); } else { $result = get_object_vars($result[0]); Zend_Layout::getMvcInstance()->assign('msg_success', 'Exibindo dados do CNPJ ' . $num_cnpj); $this->view->assign('result', $result); } } } } }
public function loginAction() { Zend_Layout::getMvcInstance()->setLayout('layout-login2'); $request = $this->getRequest(); $returnUrl = $request->getParam('returnUrl', null); $this->view->assign('returnUrl', $returnUrl); }
public function indexAction() { $this->_helper->viewRenderer->setNoRender(true); Zend_Layout::getMvcInstance()->disableLayout(); $conf = new Z_Config('robots.txt'); echo $conf->getValue(); }
/** * Set navigation object based on conference abbreviation * * @return void */ public function preDispatch(Zend_Controller_Request_Abstract $request) { $acl = new Core_Model_Acl_Core(); $auth = Zend_Auth::getInstance(); $view = Zend_Layout::getMvcInstance()->getView(); // get user role $role = $auth->hasIdentity() ? $auth->getIdentity() : 'guest'; // store ACL in global registry Zend_Registry::set('acl', $acl); $abbreviation = 'core'; try { $conference = Zend_Registry::get('conference'); if ($conference['navigation']) { $abbreviation = strtolower($conference['abbreviation']); } } catch (Exception $e) { throw new TA_Exception('conference key not found in registry'); } $pages = (require APPLICATION_PATH . '/configs/navigation/' . $abbreviation . '.php'); $this->_navigation = new Zend_Navigation($pages); // view helper $navViewHelper = $view->navigation($this->_navigation); // add ACL and default role to navigation $navViewHelper->setAcl($acl)->setRole($role); }
public function init() { $session = new Zend_Session_Namespace('homelet_global'); // Bit of a dirty hack to use a layout from the CMS module $layout = Zend_Layout::getMvcInstance(); $layout->setLayoutPath(APPLICATION_PATH . '/modules/cms/layouts/scripts'); $layout->setLayout('default'); // Extra form css for Letting Agents //$this->view->headLink()->appendStylesheet('/assets/cms/css/portfolio_form.css'); $this->view->headScript()->appendFile('/assets/cms/js/letting-agents/letting-agents_form.js'); $this->url = trim($this->getRequest()->getRequestUri(), '/'); $this->view->pageTitle = 'Letting Agents Application'; $menuData = array('selected' => 'letting-agents', 'url' => $this->url); // This could be quite yucky - I'm just trying to work out how to get the menu structure to work $mainMenu = $this->view->partial('partials/homelet-mainmenu.phtml', $menuData); $subMenu = $this->view->partial('partials/homelet-submenu.phtml', $menuData); $layout = Zend_Layout::getMvcInstance(); $layout->getView()->mainMenu = $mainMenu; $layout->getView()->subMenu = $subMenu; if (isset($menuData['selected'])) { $layout->getView()->styling = $menuData['selected']; } // Load the site link urls from the parameters and push them into the layout $params = Zend_Registry::get('params'); $layout->getView()->urls = $params->url->toArray(); // Some Session Stuff $pageSession = new Zend_Session_Namespace('letting_agents_application'); // Unique Id if (!isset($pageSession->agentUniqueId)) { $pageSession->agentUniqueId = uniqid(); } }
public function init() { $session = new Zend_Session_Namespace('referencing_global'); // Bit of a dirty hack to use a layout from the CMS module $layout = Zend_Layout::getMvcInstance(); $layout->setLayoutPath(APPLICATION_PATH . '/modules/cms/layouts/scripts'); $layout->setLayout('default'); // Top level styles and Javacript $this->view->headLink()->appendStylesheet('/assets/landlords-referencing/css/landlords-referencing.css'); $this->view->headScript()->appendFile('/assets/common/js/insurance-forms.js'); $this->view->headScript()->appendFile('/assets/landlords-referencing/js/referencing_form.js'); $this->view->pageTitle = 'Tenant Referencing'; $this->url = trim($this->getRequest()->getRequestUri(), '/'); //Menu selection $menuData = array('selected' => 'landlords', 'url' => $this->url); // Munting menu layout logics. $mainMenu = $this->view->partial('partials/homelet-mainmenu.phtml', $menuData); $subMenu = $this->view->partial('partials/homelet-submenu.phtml', $menuData); $layout = Zend_Layout::getMvcInstance(); $layout->getView()->mainMenu = $mainMenu; $layout->getView()->subMenu = $subMenu; if (isset($menuData['selected'])) { $layout->getView()->styling = $menuData['selected']; } // Load the site link urls from the parameters and push them into the layout $params = Zend_Registry::get('params'); $layout->getView()->urls = $params->url->toArray(); }
/** * Prepare data for autocompletion * * @param mixed $data * @param boolean $keepLayouts * @return string */ public function prepareAutoCompletion($data, $keepLayouts = false) { if (!$data instanceof Zend_Dojo_Data) { require_once 'Zend/Dojo/Data.php'; $items = array(); foreach ($data as $key => $value) { $items[] = array('label' => $value, 'name' => $value); } $data = new Zend_Dojo_Data('name', $items); } if (!$keepLayouts) { require_once 'Zend/Controller/Action/HelperBroker.php'; Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true); require_once 'Zend/Layout.php'; $layout = Zend_Layout::getMvcInstance(); if ($layout instanceof Zend_Layout) { $layout->disableLayout(); } } $response = Zend_Controller_Front::getInstance()->getResponse(); $response->setHeader('Content-Type', 'application/json'); return $data->toJson(); }
protected function _load() { if (empty($this->_options)) { throw new Exceptions_SeotoasterWidgetException('No options provided'); } if (is_numeric(reset($this->_options))) { $userId = array_shift($this->_options); $this->_user = Application_Model_Mappers_UserMapper::getInstance()->find($userId); if (is_null($this->_user)) { return ''; } } elseif ($this->_sessionHelper->getCurrentUser()->getRoleId() === Tools_Security_Acl::ROLE_GUEST) { return ''; } else { $this->_user = $this->_sessionHelper->getCurrentUser(); } $this->_user->loadAttributes(); if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_USERS) || $this->_user->getId() === $this->_sessionHelper->getCurrentUser()->getId()) { $this->_editableMode = true; Zend_Layout::getMvcInstance()->getView()->headScript()->appendFile($this->_websiteHelper->getUrl() . 'system/js/internal/user-attributes.js'); } $method = strtolower(array_shift($this->_options)); try { return $this->{'_render' . ucfirst($method)}(); } catch (Exception $e) { return '<b>Method ' . $method . ' doesn\'t exist</b>'; } }
function configureTheme($theme = APPLICATION_THEME, $layoutName = 'index', $layoutPath = '/themes/core/layouts') { global $baseUrl; $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); if ($layoutName == 'integration') { $viewRenderer->view->themeUrl = str_replace("index.php", "", BASE_URL) . '/public/' . $theme; $viewRenderer->view->themeImages = $viewRenderer->view->themeUrl . "/images"; } else { $viewRenderer->view->themeUrl = str_replace("index.php", "", BASE_URL) . "/themes/" . $theme; $viewRenderer->view->themesUrl = str_replace("index.php", "", BASE_URL) . "/themes/"; $viewRenderer->view->themeImages = $viewRenderer->view->themeUrl . "/images"; } $viewRenderer->view->theme = $theme; $viewRenderer->view->asset = new Joobsbox_Helpers_AssetHelper(); $viewRenderer->view->css = new Joobsbox_Helpers_CssHelper(); $viewRenderer->view->js = new Joobsbox_Helpers_JsHelper(); $viewRenderer->view->addScriptPath(APPLICATION_DIRECTORY . '/themes/core/views/scripts'); $viewRenderer->view->addScriptPath(APPLICATION_DIRECTORY . '/themes/' . $theme . '/views/scripts'); $viewRenderer->view->setEncoding("UTF-8"); $viewRenderer->view->addHelperPath(APPLICATION_DIRECTORY . '/Joobsbox/Helpers', "Joobsbox_Helpers"); $conf = Zend_Registry::get("conf"); Zend_Registry::set("theme", $theme); $viewRenderer->view->conf = $conf; if ($conf->general->standalone) { if ($layout = Zend_Layout::getMvcInstance()) { $layout->setLayoutPath(APPLICATION_DIRECTORY . $layoutPath); $layout->setLayout($layoutName); } else { Zend_Layout::startMvc(array('layoutPath' => APPLICATION_DIRECTORY . $layoutPath, 'layout' => $layoutName)); } } }
protected function setLayout($name) { $layout = Zend_Layout::getMvcInstance(); if ($layout instanceof Zend_Layout) { $layout->setLayout($name); } }
public function initContext($format = null) { parent::initContext($format); // Hack to prevent duplicate content-type headers $pos = false; $response = $this->getResponse(); $headers = $response->getHeaders(); $response->clearHeaders(); foreach ($headers as $header) { $name = $header['name']; $value = $header['value']; $replace = $header['replace']; if (strtolower($name) == 'content-type') { if ($pos === true) { continue; } $pos = true; } $response->setHeader($name, $value, $replace); } if (null === $this->_currentContext || !$this->getAutoSwitchLayout()) { return; } $layoutName = $this->getLayout($this->_currentContext); if ($layoutName) { $layout = Zend_Layout::getMvcInstance(); $layout->enableLayout()->setLayout($layoutName); } }
public function init() { if (Z_Auth::getInstance()->getUser()->getLogin() == 'guest') { $this->_redirect('/admin'); return; } $role = Z_Auth::getInstance()->getUser()->getRole(); $acl = Z_Acl::getInstance(); $allowed = true; try { $allowed = $acl->isAllowed($role, 'z_backups', 'list'); } catch (Exception $e) { $allowed = false; } if (!$allowed) { $this->_redirect('/admin'); return; } if ($this->_getParam('action') != 'download' && !$this->getRequest()->isXmlHttpRequest()) { $this->_redirect('/admin'); return; } $this->_helper->viewRenderer->setNoRender(true); Zend_Layout::getMvcInstance()->disableLayout(); @ini_set("memory_limit", "-1"); $this->session = new Zend_Session_Namespace("z_backup"); }
protected function renderMenu() { $container = new Zend_Navigation(VAR_menu); $this->view->assign('menu', $container); $this->view->assign('module', $this->_getParam('module')); Zend_Layout::getMvcInstance()->assign('navbar', $this->view->render('navbar.phtml')); }
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { $moduleName = $request->getModuleName(); Zend_Layout::startMvc(); $layout = Zend_Layout::getMvcInstance(); switch ($moduleName) { case 'admin': $layout->setLayoutPath(APPLICATION_PATH . '/layouts/scripts/' . $moduleName); $layout->setLayout('admin'); break; case 'login': $layout->setLayoutPath(APPLICATION_PATH . '/layouts/scripts/' . $moduleName); $layout->setLayout('login'); break; default: $layout->setLayoutPath(APPLICATION_PATH . '/layouts/scripts/default'); $layout->setLayout('layout'); break; } $frontController = Zend_Controller_Front::getInstance(); $frontController->setBaseUrl('http://local.kemsakura/'); $view = Zend_Layout::getMvcInstance()->getView(); $view->addHelperPath(APPLICATION_PATH . "/layouts/helpers"); $wew = new Zend_View(); $wew->baseUrl(); }
public function postDispatch(Zend_Controller_Request_Abstract $request) { $layout = Zend_Layout::getMvcInstance(); // the name "maintenanceMode" is also referred to in the Admin_MaintenanceController, // so if you change the filename, it needs to be changed there too $maintenanceModeFileName = 'maintenanceMode'; $register = new Ot_Config_Register(); $identity = Zend_Auth::getInstance()->getIdentity(); $role = empty($identity->role) ? $register->defaultRole->getValue() : $identity->role; if (isset($identity->masquerading) && $identity->masquerading == true && isset($identity->realAccount) && !is_null($identity->realAccount) && isset($identity->realAccount->role)) { $role = $identity->realAccount->role; } $acl = Zend_Registry::get('acl'); $view = $layout->getView(); $viewRenderer = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer'); if (is_file(APPLICATION_PATH . '/../overrides/' . $maintenanceModeFileName) && (!$request->isXmlHttpRequest() && !$viewRenderer->getNeverRender())) { if (!$acl->isAllowed($role, 'ot_maintenance', 'index')) { if (!($request->getModuleName() == 'ot' && $request->getControllerName() == 'login' && $request->getActionName() == 'index')) { $response = $this->getResponse(); $layout->disableLayout(); $response->setBody($view->maintenanceMode()->publicLayout()); } } else { $response = $this->getResponse(); // there's no point in setting text here if it's a redirect if ($response->isRedirect()) { $response->setBody(''); } else { $response->setBody($view->maintenanceMode()->header() . $response->getBody()); } } } }
public function routeShutdown(Zend_Controller_Request_Abstract $request) { $translate = Zend_Registry::get('Zend_Translate'); $locale = Zend_Registry::get('Zend_Locale'); $languages = Zend_Registry::get('languages'); $front = Zend_Controller_Front::getInstance(); $router = $front->getRouter(); $view = Zend_Layout::getMvcInstance()->getView(); //$view->route = ''; if ($language = strtolower($request->getParam('language'))) { if ($language != $locale->getLanguage($translate->getLocale()) && Zend_Locale::isLocale($language)) { try { $translate->addTranslation(APPLICATION_PATH . '/../data/locales/' . $language . '.php', $language); if ($translate->isAvailable($language)) { $locale->setLocale($languages[$language]); $router->setGlobalParam('language', $language); Zend_Registry::set('Zend_Translate', $translate); Zend_Registry::set('Zend_Locale', $locale); //$view->route .= '_language'; } } catch (Exception $e) { } } } $view->route = $router->getCurrentRouteName(); /* echo $router->getCurrentRouteName(); echo ' <h3>Request Parameters:</h3> <pre> ' . var_export($request->getParams(), true) . ' </pre> '; //die(); */ }
public function preDispatch(Zend_Controller_Request_Abstract $request) { if ($request->getParam('isAdmin')) { $layout = Zend_Layout::getMvcInstance(); $layout->setLayout('admin'); } }
public function GetRestaurantType(Application_Model_Restaurant $restaurant) { $view = Zend_Layout::getMvcInstance()->getView(); $restaurantOptionsRepository = new Application_Model_Restaurant_Option_Search_Repository(); $restaurantTypeCategory = (new Application_Model_Option_Category_Search_Repository())->getRestaurantType(); return $view->formatRestaurantOptions($restaurantOptionsRepository->getRestaurantOptions($restaurant, $restaurantTypeCategory)); }
/** * Encode data as JSON, disable layouts, and set response header * * If $keepLayouts is true, does not disable layouts. * If $encodeJson is false, does not JSON-encode $data * * @param mixed $data * @param bool $keepLayouts * NOTE: if boolean, establish $keepLayouts to true|false * if array, admit params for Zend_Json::encode as enableJsonExprFinder=>true|false * this array can contains a 'keepLayout'=>true|false and/or 'encodeData'=>true|false * that will not be passed to Zend_Json::encode method but will be used here * @param bool $encodeData * @return string|void */ public function json($data, $keepLayouts = false, $encodeData = true) { $options = array(); if (is_array($keepLayouts)) { $options = $keepLayouts; $keepLayouts = false; if (array_key_exists('keepLayouts', $options)) { $keepLayouts = $options['keepLayouts']; unset($options['keepLayouts']); } if (array_key_exists('encodeData', $options)) { $encodeData = $options['encodeData']; unset($options['encodeData']); } } if ($encodeData) { $data = Zend_Json::encode($data, null, $options); } if (!$keepLayouts) { require_once 'Zend/Layout.php'; $layout = Zend_Layout::getMvcInstance(); if ($layout instanceof Zend_Layout) { $layout->disableLayout(); } } $response = Zend_Controller_Front::getInstance()->getResponse(); $response->setHeader('Content-Type', 'application/json', true); return $data; }
public function addJavascript($js) { $script = (string) $js; $script = Zmz_Utils::clearScript($script); $view = Zend_Layout::getMvcInstance()->getView(); $view->headScript()->appendScript($script); }