Example #1
0
 protected function _initLogs()
 {
     $logger = new Zend_Log();
     $fireBugWriter = new Zend_Log_Writer_Firebug();
     $logger->addWriter($fireBugWriter);
     Zend_Registry::set('logger', $logger);
 }
Example #2
0
 protected function _initLogger()
 {
     $logger = $this->bootstrapLog()->getResource('Log');
     /*if (! $this->hasPluginResource ( 'Log' )) {
     			return false;
     		}*/
     switch (strtolower(APPLICATION_ENV)) {
         case 'production':
             $writer = new Zend_Log_Writer_Firebug();
             $filter = new Zend_Log_Filter_Priority(5, '>=');
             $writer->addFilter($filter);
             // Uncomment and alter following line if you want to get more then message.
             //$writer->setPriorityStyle(Zend_Log::WARN, 'TRACE');
             $logger->addWriter($writer);
             break;
         case 'staging':
             //Not considered yet.
             break;
         case 'testing':
             //Not considered yet.
             break;
         case 'development':
             $writer = new Zend_Log_Writer_Firebug();
             $filter = new Zend_Log_Filter_Priority(2, '>=');
             $writer->addFilter($filter);
             // Uncomment and alter following line if you want to get more then message.
             //$writer->setPriorityStyle(Zend_Log::WARN, 'TRACE');
             $logger->addWriter($writer);
             break;
         default:
             throw new Zend_Exception('Unknown <b>Application Environment</b> to create log writer in bootstrap.', Zend_Log::WARN);
     }
     // Now set logger globally in application.
     Zend_Registry::set("logger", $logger);
 }
Example #3
0
 protected function _initConfig()
 {
     $aConfig = $this->getOptions();
     Zend_Registry::set('facebook_client_id', $aConfig['facebook']['client_id']);
     Zend_Registry::set('facebook_client_secret', $aConfig['facebook']['client_secret']);
     Zend_Registry::set('facebook_redirect_uri', $aConfig['facebook']['redirect_uri']);
 }
Example #4
0
 /**
  * Retrieve translate object
  *
  * @return Zend_Translate
  * @throws Zend_Application_Resource_Exception if registry key was used
  *          already but is no instance of Zend_Translate
  */
 public function getTranslate()
 {
     if (null === $this->_translate) {
         $options = $this->getOptions();
         if (!isset($options['data'])) {
             // require_once 'Zend/Application/Resource/Exception.php';
             throw new Zend_Application_Resource_Exception('No translation source data provided.');
         }
         $adapter = isset($options['adapter']) ? $options['adapter'] : Zend_Translate::AN_ARRAY;
         $locale = isset($options['locale']) ? $options['locale'] : null;
         $translateOptions = isset($options['options']) ? $options['options'] : array();
         $key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY;
         if (Zend_Registry::isRegistered($key)) {
             $translate = Zend_Registry::get($key);
             if (!$translate instanceof Zend_Translate) {
                 // require_once 'Zend/Application/Resource/Exception.php';
                 throw new Zend_Application_Resource_Exception($key . ' already registered in registry but is ' . 'no instance of Zend_Translate');
             }
             $translate->addTranslation($options['data'], $locale, $options);
             $this->_translate = $translate;
         } else {
             $this->_translate = new Zend_Translate($adapter, $options['data'], $locale, $translateOptions);
             Zend_Registry::set($key, $this->_translate);
         }
     }
     return $this->_translate;
 }
Example #5
0
    /**
     * Retrieve locale object
     *
     * @return Zend_Locale
     */
    public function getLocale()
    {
        if (null === $this->_locale) {
            $options = $this->getOptions();

            if (!isset($options['default'])) {
                $this->_locale = new Zend_Locale();
            } elseif(!isset($options['force']) ||
                     (bool) $options['force'] == false)
            {
                // Don't force any locale, just go for auto detection
                Zend_Locale::setDefault($options['default']);
                $this->_locale = new Zend_Locale();
            } else {
                $this->_locale = new Zend_Locale($options['default']);
            }

            $key = (isset($options['registry_key']) && !is_numeric($options['registry_key']))
                ? $options['registry_key']
                : self::DEFAULT_REGISTRY_KEY;
            Zend_Registry::set($key, $this->_locale);
        }

        return $this->_locale;
    }
Example #6
0
 /**
  * Setup Akismet
  *
  * @param array $options
  * @return Zend_Service_Akismet
  */
 protected function _setupService($options)
 {
     if (!isset($options['apiKey'])) {
         $message = 'option "apiKey" not found for Service_Akismet';
         throw new Robo47_Application_Resource_Exception($message);
     }
     if (!isset($options['blog'])) {
         $message = 'option "blog" not found for Service_Akismet';
         throw new Robo47_Application_Resource_Exception($message);
     }
     $akismet = new Zend_Service_Akismet($options['apiKey'], $options['blog']);
     if (isset($options['charset'])) {
         $akismet->setCharset($options['charset']);
     }
     if (isset($options['userAgent'])) {
         $akismet->setUserAgent($options['userAgent']);
     }
     if (isset($options['port'])) {
         // casting needed because of is_int in Zend_Service_Akismet::setPort
         $akismet->setPort((int) $options['port']);
     }
     if (isset($options['registryKey'])) {
         Zend_Registry::set($options['registryKey'], $akismet);
     }
     return $akismet;
 }
Example #7
0
 public function _initDoctrineEntityManager()
 {
     $this->bootstrap(array('classLoaders'));
     $zendConfig = $this->getOptions();
     // parameters required for connecting to the database.
     // the required attributes are driver, host, user, password and dbname
     $connectionParameters = $zendConfig['doctrine']['connectionParameters'];
     // now initialize the configuration object
     $configuration = new DoctrineConfiguration();
     // the metadata cache is used to avoid parsing all mapping information every time
     // the framework is initialized.
     //$configuration->setMetadataCacheImpl($this->getResource('doctrineCache'));
     //// for performance reasons, it is also recommended to use a result cache
     //$configuration->setResultCacheImpl($this->getResource('doctrineCache'));
     // if you set this option to true, Doctrine 2 will generate proxy classes for your entities
     // on the fly. This has of course impact on the performance and should therefore be disabled
     // in the production environment
     $configuration->setAutoGenerateProxyClasses($zendConfig['doctrine']['autoGenerateProxyClasses']);
     // the directory, where your proxy classes live
     $configuration->setProxyDir($zendConfig['doctrine']['proxyPath']);
     // the proxy classes' namespace
     $configuration->setProxyNamespace($zendConfig['doctrine']['proxyNamespace']);
     // the next option tells doctrine which description language we want to use for the mapping
     // information
     $configuration->setMetadataDriverImpl($configuration->newDefaultAnnotationDriver($zendConfig['doctrine']['entityPath']));
     // next, we create an event manager
     $eventManager = new DoctrineEventManager();
     // now we have everything required to initialize the entity manager
     $entityManager = DoctrineEntityManager::create($connectionParameters, $configuration, $eventManager);
     Zend_Registry::set('em', $entityManager);
     return $entityManager;
 }
 public function setUp()
 {
     parent::setUp();
     // All tests are done with local paths to simplify them (no http layer).
     if ($this->_allowLocalPaths) {
         $settings = (object) array('local_folders' => (object) array('allow' => '1', 'check_realpath' => '0', 'base_path' => TEST_FILES_DIR));
         Zend_Registry::set('oai_pmh_static_repository', $settings);
     } else {
         $settings = (object) array('local_folders' => (object) array('allow' => '0', 'check_realpath' => '0', 'base_path' => '/var/path/to/the/folder'));
         Zend_Registry::set('oai_pmh_static_repository', $settings);
     }
     defined('TEST_FILES_WEB') or define('TEST_FILES_WEB', WEB_ROOT . DIRECTORY_SEPARATOR . basename(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'suite' . DIRECTORY_SEPARATOR . '_files');
     $pluginHelper = new Omeka_Test_Helper_Plugin();
     // ArchiveDocument is a required plugin.
     $path = PLUGIN_DIR . DIRECTORY_SEPARATOR . 'ArchiveDocument' . DIRECTORY_SEPARATOR . 'ArchiveDocumentPlugin.php';
     $this->assertTrue(is_file($path) && filesize($path), __('This plugin requires ArchiveDocument.'));
     $pluginHelper->setUp('ArchiveDocument');
     $pluginHelper->setUp(self::PLUGIN_NAME);
     // OcrElementSet is an optional plugin, but required for some tests.
     try {
         $pluginHelper->setUp('OcrElementSet');
     } catch (Omeka_Plugin_Loader_Exception $e) {
     }
     // Allow extensions "xml" and "json".
     $whiteList = get_option(Omeka_Validate_File_Extension::WHITELIST_OPTION) . ',xml,json';
     set_option(Omeka_Validate_File_Extension::WHITELIST_OPTION, $whiteList);
     // Allow media types for "xml" and "json".
     $whiteList = get_option(Omeka_Validate_File_MimeType::WHITELIST_OPTION) . ',application/xml,text/xml,application/json';
     set_option(Omeka_Validate_File_MimeType::WHITELIST_OPTION, $whiteList);
 }
Example #9
0
 protected function _initApiServer()
 {
     $server = new Cosmos_Api_Server(new Cosmos_Api_Request_Http());
     Zend_Registry::set('server', $server);
     var_dump($server->handle());
     die('done');
 }
Example #10
0
 /**
  * Retrieve service object instance
  *
  * @param Zend_Config $config
  * @return Zend_Translate
  */
 public function &getService($config)
 {
     if (!$this->service) {
         Zend_Translate::setCache(Zoo::getService('cache')->getCache('translate'));
         /*
          * @todo Re-enable this with configuration options instead of hardcoding
         $writer = new Zend_Log_Writer_Firebug();
         			$logger = new Zend_Log($writer);
         $this->service = new Zend_Translate('gettext',
                                             ZfApplication::$_base_path."/app/Zoo/Language",
                                             null,
                                             array(
                                                   'scan' => Zend_Translate::LOCALE_FILENAME,
                                                   'disableNotices' => true, 
                                             	  'log' => $logger,
                                             	  'logUntranslated' => true)
                                             );
         */
         if ($config->language->default) {
             $locale = new Zend_Locale($config->language->default);
             Zend_Registry::set("Zend_Locale", $locale);
         } else {
             $locale = new Zend_Locale("en");
         }
         $this->service = new Zend_Translate('gettext', ZfApplication::$_base_path . "/app/Zoo/Language", $locale, array('scan' => Zend_Translate::LOCALE_FILENAME, 'disableNotices' => true));
     }
     return $this->service;
 }
Example #11
0
 protected function _initUrl()
 {
     $port = !APPLICATION_SSL && $_SERVER['SERVER_PORT'] == STANDARD_PORT || APPLICATION_SSL && $_SERVER['SERVER_PORT'] == SSL_PORT ? '' : ':' . $_SERVER['SERVER_PORT'];
     $url = APPLICATION_PROTOCOL . '://' . $_SERVER['SERVER_NAME'] . $port . APPLICATION_BASE_URL;
     Zend_Registry::set('siteUrl', $url);
     Zend_Registry::set('baseUrl', APPLICATION_BASE_URL);
 }
 /**
  * Bootstrap logging
  */
 protected function _initSyslog()
 {
     // Zend_Log
     $writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . "/tmp/log/si.log");
     $logger = new Zend_Log($writer);
     Zend_Registry::set('logger', $logger);
 }
Example #13
0
 public static function run()
 {
     #echo get_include_path();
     #exit();
     try {
         // ่จญๅฎšใƒ•ใ‚กใ‚คใƒซ่ชญใฟ่พผใฟ
         $config = new Zend_Config_Ini(INSTALL_DIR . 'application/configs/config.ini', 'production');
         // Zend_Loader ใฎ่จญๅฎš๏ผˆใƒ•ใ‚กใ‚คใƒซ่‡ชๅ‹•่ชญใฟ่พผใฟ๏ผ‰
         require_once 'Zend/Loader/Autoloader.php';
         $loader = Zend_Loader_Autoloader::getInstance();
         $loader->setFallbackAutoloader(true);
         Zend_Registry::set($config->registry->config, $config);
         $view = new Tokyofr_View_Smarty($config->smarty->template_dir, $config->smarty->toArray());
         $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
         $viewRenderer->setView($view)->setViewBasePathSpec($view->getEngine()->template_dir[0]);
         $viewRenderer->setViewScriptPathSpec(':controller/:action.:suffix');
         $viewRenderer->setViewScriptPathNoControllerSpec(':action.:suffix');
         $viewRenderer->setViewSuffix('phtml');
         Tokyofr_Controller_Front::run($config->path->controller);
     } catch (Zend_Exception $e) {
         //var_dump($e->getMessage());
         exit("error.");
     } catch (Exception $e) {
         //var_dump($e->getMessage());
         exit('error02');
     }
 }
Example #14
0
 public function init()
 {
     if (null === $this->_locale) {
         $sessionLocale = new Zend_Session_Namespace('locale');
         //Zend_Session::destroy();
         //var_dump($session->localename);
         //Zend_Debug::dump($_SESSION);exit;
         //Zend_Debug::dump(Zend_Session::getOptions());exit;
         if (isset($sessionLocale->localename)) {
             $this->_locale = new Zend_Locale($sessionLocale->localename);
         } else {
             $options = $this->getOptions();
             if (!isset($options['default'])) {
                 $this->_locale = new Zend_Locale();
             } elseif (!isset($options['force']) || (bool) $options['force'] == false) {
                 // Don't force any locale, just go for auto detection
                 Zend_Locale::setDefault($options['default']);
                 $this->_locale = new Zend_Locale();
             } else {
                 //ๅผบๅˆถๅŒบๅŸŸไธบ...
                 $this->_locale = new Zend_Locale($options['default']);
             }
             $sessionLocale->localename = $this->_locale->getLanguage() . '_' . $this->_locale->getRegion();
         }
         $key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY;
         Zend_Registry::set($key, $this->_locale);
         Zend_Registry::set('sessionLocale', $sessionLocale);
     }
     return $this->_locale;
 }
Example #15
0
 /**
  * @param \HumusMvc\MvcEvent $e
  * @return void
  */
 public function __invoke(MvcEvent $e)
 {
     $serviceManager = $e->getApplication()->getServiceManager();
     $config = $serviceManager->get('Config');
     if (!isset($config['locale'])) {
         // no locale config found, return
         return;
     }
     // set cache in locale to speed up application
     if ($serviceManager->has('CacheManager')) {
         $cacheManager = $serviceManager->get('CacheManager');
         Locale::setCache($cacheManager->getCache('default'));
     }
     $options = $config['locale'];
     if (!isset($options['default'])) {
         $locale = new Locale();
     } elseif (!isset($options['force']) || (bool) $options['force'] == false) {
         // Don't force any locale, just go for auto detection
         Locale::setDefault($options['default']);
         $locale = new Locale();
     } else {
         $locale = new Locale($options['default']);
     }
     $key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY;
     Registry::set($key, $locale);
 }
Example #16
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     $params = $request->getParams();
     $auth = Zend_Auth::getInstance();
     Zend_Registry::set('Zend_Auth', $auth);
     if ($auth->hasIdentity()) {
         $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
         $identity = $auth->getIdentity();
         $userDb = new Users_Model_DbTable_User();
         $user = array('id' => $identity->id, 'username' => $identity->username, 'name' => $identity->name, 'email' => $identity->email, 'clientid' => $identity->clientid);
         $authNamespace = new Zend_Session_Namespace('Zend_Auth');
         $authNamespace->user = $user['username'];
         if ($_SESSION['__ZF']['Zend_Auth']['ENT'] - time() < 3600) {
             $authNamespace->setExpirationSeconds(3600);
         }
         Zend_Registry::set('User', $user);
         $view->user = $user;
         $clientDb = new Application_Model_DbTable_Client();
         $client = $clientDb->getClient($user['clientid']);
         Zend_Registry::set('Client', $client);
     } elseif ($params['module'] != 'users' && $params['action'] != 'login') {
         $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
         if (isset($params['id']) && $params['id']) {
             $redirector->gotoSimple('login', 'user', 'users', array('url' => $params['module'] . '|' . $params['controller'] . '|' . $params['action'] . '|' . $params['id']));
         } else {
             $redirector->gotoSimple('login', 'user', 'users', array('url' => $params['module'] . '|' . $params['controller'] . '|' . $params['action']));
         }
     }
 }
Example #17
0
 /**
  * Setup Cache
  *
  * @param array $config
  */
 public function _setupCache($config)
 {
     if (!isset($config['frontendName'])) {
         $message = 'Cache config doesn\'t contain frontendName';
         throw new Robo47_Application_Resource_Exception($message);
     }
     if (!isset($config['backendName'])) {
         $message = 'Cache config doesn\'t contain backendName';
         throw new Robo47_Application_Resource_Exception($message);
     }
     if (!isset($config['frontendOptions'])) {
         $config['frontendOptions'] = array();
     }
     if (!isset($config['backendOptions'])) {
         $config['backendOptions'] = array();
     }
     if (!isset($config['customFrontendNaming'])) {
         $config['customFrontendNaming'] = false;
     }
     if (!isset($config['customBackendNaming'])) {
         $config['customBackendNaming'] = false;
     }
     if (!isset($config['autoload'])) {
         $config['autoload'] = false;
     }
     $cache = Zend_Cache::factory($config['frontendName'], $config['backendName'], $config['frontendOptions'], $config['backendOptions'], $config['customFrontendNaming'], $config['customBackendNaming'], $config['autoload']);
     if (isset($config['registryKey'])) {
         Zend_Registry::set($config['registryKey'], $cache);
     }
     return $cache;
 }
 /**
  * Create a new GettextZendTranslator and configure it with passed params
  * @param string|Zend_Locale $given_locale
  * @param string $filename
  * @param boolean $default_instance If none instance yet, this instance will be used whatever this param value is
  */
 public function __construct($given_locale = null, $filename = null, $default_instance = true)
 {
     if ($filename != null) {
         $this->filename = $filename;
     }
     self::$absolutePath = Config::getInstance()->getString('appRootDir') . self::DIR_LOCALES;
     $this->debugMode = Config::getInstance()->getBoolean('i18n/gettextZendTranslator/debug', false);
     $path = self::$absolutePath . self::DEFAULT_LOCALE . '/' . $this->filename;
     parent::__construct(self::GETTEXT, $path, self::DEFAULT_LOCALE);
     // Adding other existing locales
     $locales = $this->getAvailableLocales();
     foreach ($locales as $locale) {
         if ($locale != self::DEFAULT_LOCALE) {
             parent::addTranslation(self::$absolutePath . $locale . '/' . $this->filename, $locale);
         }
     }
     if ($given_locale == null) {
         if (($given_locale = Zend_Registry::get('Zend_Locale')) == null) {
             $given_locale = self::DEFAULT_LOCALE;
         }
     }
     $this->setLocale($given_locale);
     Zend_Registry::set('Zend_Translator', $this);
     if ($default_instance || self::$instance == null) {
         self::$instance = $this;
     }
 }
 /**
  * Display Solr results.
  */
 public function indexAction()
 {
     // Get pagination settings.
     $limit = get_option('per_page_public');
     $page = $this->_request->page ? $this->_request->page : 1;
     $start = ($page - 1) * $limit;
     // determine whether to display private items or not
     // items will only be displayed if:
     // solr_search_display_private_items has been enabled in the Solr Search admin panel
     // user is logged in
     // user_role has sufficient permissions
     $user = current_user();
     if (get_option('solr_search_display_private_items') && $user && is_allowed('Items', 'showNotPublic')) {
         // limit to public items
         $limitToPublicItems = false;
     } else {
         $limitToPublicItems = true;
     }
     // Execute the query.
     $results = $this->_search($start, $limit, $limitToPublicItems);
     // Set the pagination.
     Zend_Registry::set('pagination', array('page' => $page, 'total_results' => $results->response->numFound, 'per_page' => $limit));
     // Push results to the view.
     $this->view->results = $results;
 }
Example #20
0
 public function searchAction()
 {
     Zend_Registry::set('theaction', 'content');
     $this->toTpl('theInclude', 'list');
     Zend_Registry::set('module', 'Search Results');
     //error_reporting(E_ALL);
     $data = $this->_request->getParams();
     if (trim($data['q'])) {
         $dirs = $this->dirs;
         $word = strtolower($data['q']);
         $index = new Zend_Search_Lucene(APPL_PATH . $dirs['structure']['indexes'] . DIR_SEP . "objects");
         $exp = explode(" ", $word);
         $query = new Zend_Search_Lucene_Search_Query_Phrase($exp);
         $query->setSlop(2);
         //get all available indexed
         Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
         Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
         Zend_Search_Lucene::setResultSetLimit(10);
         $result = $index->find($query);
         foreach ($result as $hit) {
             $obj = $this->getAllBySlug($hit->slug);
             $type = $this->getContentType($obj['type_id']);
             $content = $this->getContent($type['title'], $obj['id']);
             $resu[] = $content;
         }
         $resu = $this->doQoolHook('front_pre_assign_search_results', $resu);
         $this->toTpl('content', $resu);
     } else {
         $params = array("message" => $this->t("Please fill in a search term"), "msgtype" => 'error');
         $this->addMessage($params);
         $this->_helper->redirector('index', 'index', 'default');
     }
 }
 public function indexAction()
 {
     if ($this->getRequest()->getParam('garbage')) {
         $this->redirect('');
     }
     $translator = Zend_Registry::get('Zend_Translate');
     if (!$this->getRequest()->isPost()) {
         if (Zend_Session::sessionExists()) {
             $namespace = $this->_session->getNamespace();
             if (isset($_SESSION[$namespace])) {
                 unset($_SESSION[$namespace]);
             }
             $translator->setLocale('en');
             Zend_Registry::set('Zend_Translate', $translator);
             Zend_Session::regenerateId();
         }
     } else {
         $lang = $this->getRequest()->getParam('lang');
         if ($lang && Zend_Locale::isLocale($lang)) {
             $this->_session->locale->setLocale($lang);
             if ($translator->getLocale() !== $lang) {
                 $translator->setLocale($lang);
                 Zend_Registry::set('Zend_Translate', $translator);
             }
             $this->_session->nextStep = 1;
         }
         if ($this->_session->nextStep !== null) {
             return $this->forward('step' . $this->_session->nextStep);
         }
     }
     $this->forward('step1');
 }
Example #22
0
 /**
  * _initLocale
  *
  * @return Zend_Locale
  */
 protected function _initLocale()
 {
     $locale = new Zend_Locale('pl_PL');
     Zend_Registry::set('Zend_Locale', $locale);
     date_default_timezone_set('Europe/Warsaw');
     return $locale;
 }
 public function init()
 {
     parent::init();
     $helper = new vkNgine_View_Helper_PublicUrl();
     $this->view->registerHelper($helper, 'publicUrl');
     $helper = new vkNgine_View_Helper_Seo();
     $this->view->registerHelper($helper, 'seo');
     $helper = new vkNgine_View_Helper_AssetUrl();
     $this->view->registerHelper($helper, 'assetUrl');
     $helper = new vkNgine_View_Helper_Dateformat();
     $this->view->registerHelper($helper, 'dateFormat');
     $searchForm = new Public_Model_Form_Search();
     $this->view->searchForm = $searchForm;
     $view = Zend_Registry::get('view');
     $appTitle = Zend_Registry::get('t')->_('GYM Tracker');
     $view->headTitle($appTitle, Zend_View_Helper_Placeholder_Container_Abstract::SET);
     if (!vkNgine_Auth::isAuthenticated()) {
         header("location:/auth/login");
         exit;
     }
     $modelExercises = new Model_Exercises();
     $this->view->exercises = $modelExercises;
     $user = vkNgine_Public_Auth::revalidate();
     $this->view->params = $this->getAllParams();
     Zend_Registry::set('user', $user);
     $this->view->assign('user', $user);
     $this->user = Zend_Registry::get('user');
     $this->view->t = Zend_Registry::get('t');
     $this->t = Zend_Registry::get('t');
 }
Example #24
0
 /**
  * @param Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $this->setSessionLifeTime();
     if (!in_array($request->getModuleName(), $this->modules)) {
         return;
     }
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $user = Zend_Registry::get('container')->getService('user')->getCurrentUser();
         if (!$user->isAdmin()) {
             // can't go into admin
             $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
             $redirector->direct('index', 'index', 'default');
         }
         // set user for application
         $GLOBALS['g_user'] = $user;
         Zend_Registry::set('user', $user);
         // set view user
         $view = Zend_Registry::get('view');
         $view->currentUser = $user;
         // set view navigation acl
         $acl = Zend_Registry::get('acl')->getAcl($user);
         /* @var $acl Zend_Acl */
         $view->navigation()->setAcl($acl);
         $view->navigation()->setRole($user);
         return;
     }
 }
 /**
  * IS: Parameter id terdeklarasi
  * FS: Mengirimkan ke viewer: pageTitle
  * Desc: Fungsi untuk generate breadcrumb
  */
 protected function _generateBreadcrumb()
 {
     // id_menu_news = 'News'
     $listTitle = $this->view->translate('Figure');
     if ($this->_hasParam('id')) {
         // Param
         $id = $this->_getParam('id');
         // Model
         $db = new Model_DbTable_Figure();
         // Data
         $figure = $db->findWithDescription($id, $this->_languageId);
         $title = $figure['name'];
     }
     $texthomelink = $this->view->translate('id_menu_home');
     $links = null;
     switch ($this->_request->getActionName()) {
         case 'detail':
             $links = array($texthomelink => $this->view->baseUrl('/'), $listTitle => $this->view->baseUrl('figure'), $title => '');
             $this->view->pageTitle = $title;
             break;
         case 'index':
         default:
             $links = array($texthomelink => $this->view->baseUrl('/'), $listTitle => '');
             $this->view->pageTitle = $listTitle;
     }
     Zend_Registry::set('breadcrumb', $links);
 }
 public function testRequestUnpublishedDoc()
 {
     $r = Opus_UserRole::fetchByName('guest');
     $modules = $r->listAccessModules();
     $addOaiModuleAccess = !in_array('oai', $modules);
     if ($addOaiModuleAccess) {
         $r->appendAccessModule('oai');
         $r->store();
     }
     // enable security
     $config = Zend_Registry::get('Zend_Config');
     $security = $config->security;
     $config->security = '1';
     Zend_Registry::set('Zend_Config', $config);
     $doc = $this->createTestDocument();
     $doc->setServerState('unpublished');
     $doc->store();
     $this->dispatch('/oai/container/index/docId/' . $doc->getId());
     if ($addOaiModuleAccess) {
         $r->removeAccessModule('oai');
         $r->store();
     }
     // restore security settings
     $config->security = $security;
     Zend_Registry::set('Zend_Config', $config);
     $this->assertResponseCode(500);
     $this->assertContains('access to requested document is forbidden', $this->getResponse()->getBody());
 }
 public function listAction()
 {
     $elementSetName = $this->_getParam('elset');
     $elementName = $this->_getParam('elname');
     $curPage = $this->_getParam('page');
     $elementTextTable = $this->getDb()->getTable('ElementText');
     $el = $this->getDb()->getTable('Element')->findByElementSetNameAndElementName($this->_unslugify($elementSetName), $this->_unslugify($elementName));
     //$elTexts = $this->getDb()->getTable('ElementText')->findByElement($el->id);
     $select = $elementTextTable->getSelect()->where('element_id = ?', $el->id)->order('text')->group('text');
     $elTexts = $elementTextTable->fetchObjects($select);
     //$sortedTexts = $elTexts->getSelect()->findByElement($el->id)->order('text');
     $totalCategories = count($elTexts);
     release_object($el);
     // set-up pagination routine
     $paginationUrl = $this->getRequest()->getBaseUrl() . '/categories/list/' . $elementSetName . '/' . $elementName . "/";
     /*
     $pageAdapter = new Zend_Paginator_Adapter_DbSelect($elementTextTable->getSelect()->where('element_id = ?', $el->id)->order('text')->group('text'));
     */
     $paginator = Zend_Paginator::factory($select);
     $paginator->setItemCountPerPage(20);
     //$totalCategories = count($paginator);
     $paginator->setCurrentPageNumber($curPage);
     $this->view->paginator = $paginator;
     //Serve up the pagination
     // add other pagination items
     $pagination = array('page' => $curPage, 'per_page' => 20, 'total_results' => $totalCategories, 'link' => $paginationUrl);
     Zend_Registry::set('pagination', $pagination);
     //$this->view->assign(array('texts'=>$elTexts, 'elset'=>$elementSetName, 'elname'=>$elementName, 'total_results'=>$totalCategories));
     $this->view->assign(array('elset' => $elementSetName, 'elname' => $elementName, 'total_results' => $totalCategories));
 }
Example #28
0
 public function archiveAction()
 {
     //content types awareness ;)
     $mytypes = $this->can_handle;
     $data = $this->_request->getParams();
     $settings = $this->addonSettings;
     $this->toTpl('module_title', $this->t("Archive for ") . $data['year-:month-:date']);
     $this->prefix = "Blog_";
     $this->setupCache('blog');
     $this->toTpl('current_href', $this->http_location . '/blog/archive/' . $data['year-:month-:date']);
     $this->totpl('theInclude', 'list');
     Zend_Registry::set('controller', 'blog');
     $from = $data['page'] * $settings['posts_per_page'];
     //if(!$content = $this->loadCache('blog_archive_'.str_replace("-","",$data['year-:month-:date']))){
     $content = array();
     //lets get the content for this date
     foreach ($mytypes as $k => $v) {
         //accept only blog posts ;)
         if (preg_match('#blog#', strtolower($v['title']))) {
             $content = $this->getContentByDate($v['title'], $data['year-:month-:date'], $settings['posts_per_page'], 0, true);
         }
     }
     //$this->cacheData($content,'blog_archive_'.str_replace("-","",$data['year-:month-:date']));
     //}
     $this->toTpl('content', $content);
 }
Example #29
0
 /**
  * Creates the PSR-6 cache pool based on the application.ini config
  * and sets it in the Zend_Registry
  *
  * @throws Zend_Exception
  */
 public function init()
 {
     /** @var Zend_Config $config */
     $config = Zend_Registry::get('config');
     if (!$config instanceof Zend_Config) {
         throw new Exception(Factory::EXCEPTION_CONFIG_AND_CONFIG_FILE_NOT_SET);
     }
     try {
         $config = $config->resources->CachePool;
     } catch (Exception $e) {
         throw new Exception(Factory::EXCEPTION_CONFIG_AND_CONFIG_FILE_NOT_SET);
     }
     $adapterIndex = Config::INDEX_ADAPTER;
     $defaultAdapterIndex = Config::INDEX_DEFAULT_ADAPTER;
     /** @var array $config */
     $config = $config->toArray();
     if (empty($config[$adapterIndex]) || !is_array($config[$adapterIndex])) {
         throw new Exception(Factory::EXCEPTION_BAD_CONFIG);
     }
     $defaultAdapter = !empty($config[$defaultAdapterIndex]) ? $config[$defaultAdapterIndex] : null;
     $cachePoolFactory = new Factory();
     $adaptersConfig = $config[$adapterIndex];
     foreach ($adaptersConfig as $adapterName => $config) {
         $cachePoolConfig = array(Config::INDEX_CACHE => array($adapterIndex => array($adapterName => $config)));
         $cachePoolFactory->setConfig($cachePoolConfig);
         $cachePool = $cachePoolFactory->makeTaggable($adapterName);
         Zend_Registry::set($adapterName, $cachePool);
         if ($adapterName === $defaultAdapter) {
             Zend_Registry::set($defaultAdapterIndex, $cachePool);
         }
     }
 }
Example #30
0
 /**
  * Add the layout around the content (varies according to the ini file)
  */
 public function setLayout()
 {
     Zend_Layout::startMvc(array('layoutPath' => '../layouts'));
     $layout = Zend_Layout::getMvcInstance();
     $this->registry->set('layouttype', 'desktop');
     $layout->setLayout($this->config->general->layout);
 }