Esempio n. 1
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     if (!in_array(Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName(), array('admin', 'admin_language'))) {
         return;
     }
     $resource = new User_Model_Acl_Resource();
     $resource->getAdminPrivileges();
     if ($resource->admin_privileges) {
         //$actionStack = Zend_Controller_Action_HelperBroker::getStaticHelper('ActionStack');
         $actionStack = new Zend_Controller_Plugin_ActionStack();
         foreach ($resource->admin_privileges as $module => $actions) {
             $class = ucfirst($module) . '_AdminController';
             if (!class_exists($class)) {
                 Zend_Loader::loadFile(APPLICATION_PATH . '/modules/' . $module . '/controllers/AdminController.php');
             }
             $reflection = new Zend_Reflection_Class($class);
             $method = null;
             try {
                 if ($method = $reflection->getMethod('menuAction')) {
                     $actionStack->pushStack(new Zend_Controller_Request_Simple('menu', 'admin', $module, array('admin_actions' => array_flip($actions))));
                 }
             } catch (Exception $e) {
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * Loads a Form from the Form Path
  * 
  * @param string $sModel
  * @return mixed
  */
 public static function factory($sForm)
 {
     $sFormFile = $sForm . '.php';
     $sFormClass = 'Form_' . $sForm;
     Zend_Loader::loadFile($sFormFile, self::$_formPath);
     return new $sFormClass();
 }
Esempio n. 3
0
 /**
  * Singleton pattern implementation makes "new" unavailable
  *
  * @return void
  */
 protected function __construct()
 {
     Zend_Loader::loadFile("Predis.php", EXTERNAL_LIBRARY_PATH . "/predis/lib");
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $redisConfig = $config['cache']['backend']['redis'];
     $redis = new Predis\Client($redisConfig['servers']['global']);
     return $redis;
 }
Esempio n. 4
0
 protected function _initBook()
 {
     $view = Zend_Registry::get('Zend_View');
     $view->headScript()->appendFile($view->layout()->staticBaseUrl . 'application/modules/Book/externals/scripts/core.js');
     $view->headTranslate('click to rate');
     $view->headTranslate('you already rated');
     $view->headTranslate('please log in to rate');
     $view->headTranslate(array('%s rating', '%s ratings'));
     $view->headTranslate('Thanks for rating');
     Zend_Loader::loadFile('Bootstrap.php', $this->getModulePath() . '/libs/HTMLPurifier/', true);
 }
 public function subPostsAction()
 {
     $request = $this->getRequest();
     $uri_arr = explode('=', $request->getRequestUri());
     $_GET['JSQUERYID'] = array_pop($uri_arr);
     Zend_Loader::loadFile('JsDataLoader.php', 'Rp');
     $id = $request->getParam('id');
     $treePosts = new Rp_Db_View_TreePosts();
     $result['pid'] = $id;
     $result['posts'] = $treePosts->findChildPosts($id, true)->toArray();
     $GLOBALS['_RESULT'] = $result;
     exit;
 }
Esempio n. 6
0
 function __construct()
 {
     $front = Zend_Controller_Front::getInstance();
     $event_handlers = array();
     $filters = array();
     $dir = new DirectoryIterator(APPLICATION_DIRECTORY . "/plugins");
     $plugins = array();
     foreach ($dir as $file) {
         $className = $file->getFilename();
         if ($file->isDir() && $className[0] != '.' && $className[0] != '_') {
             if (file_exists("plugins/{$className}/{$className}.php") && file_exists("plugins/{$className}/config.xml")) {
                 Zend_Loader::loadFile("plugins/{$className}/{$className}.php");
                 $class = new ReflectionClass($className);
                 if ($class->getParentClass() && ($class->getParentClass()->getName() == "Joobsbox_Plugin_Base" || $class->getParentClass()->getName() == "Joobsbox_Plugin_AdminBase")) {
                     foreach ($class->getMethods() as $method) {
                         $methodName = $method->getName();
                         if (strpos($methodName, "event_") !== FALSE) {
                             $eventName = substr($methodName, strpos($methodName, "_") + 1);
                             $event_handlers[$eventName][] = $className;
                         } elseif (strpos($methodName, "filter_") !== FALSE) {
                             $filterName = substr($methodName, strpos($methodName, "_") + 1);
                             $filters[$filterName][] = $className;
                         }
                     }
                     $plugins[$className] = new $className();
                     if ($class->getParentClass()->getName() == "Joobsbox_Plugin_AdminBase") {
                         $plugins[$className]->isAdmin = true;
                     }
                     $plugins[$className]->conf = new Zend_Config_Xml("plugins/{$className}/config.xml");
                     $plugins[$className]->path = "plugins/{$className}";
                     if (method_exists($plugins[$className], 'setPluginName')) {
                         $plugins[$className]->setPluginName($className);
                     }
                     if (method_exists($plugins[$className], 'initPlugin')) {
                         $plugins[$className]->initPlugin();
                     }
                     if (method_exists($plugins[$className], 'init')) {
                         $plugins[$className]->init();
                     }
                     if (method_exists($plugins[$className], 'startup')) {
                         $plugins[$className]->startup();
                     }
                 }
             }
         }
     }
     Zend_Registry::set("event_handler_plugins", $event_handlers);
     Zend_Registry::set("filter_plugins", $filters);
     Zend_Registry::set("plugins", $plugins);
 }
Esempio n. 7
0
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $module = $request->getModuleName();
     if (!isset($this->_modules[$module])) {
         throw new Exception("Module does not exist!");
     }
     $bootstrapPath = $this->_modules[$module];
     //$bootstrapFile = dirname($bootstrapPath) . '/Bootstrap.php';
     $class = ucfirst($module) . '_Bootstrap';
     if (Zend_Loader::loadFile('Bootstrap.php', dirname($bootstrapPath)) && class_exists($class)) {
         $bootstrap = new $class(new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/modules/' . $module . '/configs/module.ini'));
         $bootstrap->bootstrap();
     }
 }
Esempio n. 8
0
 /**
  * PreDispatch actions
  *
  * Initialize module bootstraps
  * 
  * @param Zend_Controller_Request_Abstract $request 
  * @return void
  */
 public function initModules()
 {
     $modules = $this->front->getControllerDirectory();
     foreach ($modules as $module => $dir) {
         if ('default' == $module) {
             continue;
         }
         $bootstrapFile = dirname($dir) . '/Bootstrap.php';
         $class = ucfirst($module) . '_Bootstrap';
         if (Zend_Loader::loadFile('Bootstrap.php', dirname($dir)) && class_exists($class)) {
             $bootstrap = new $class();
             $bootstrap->setAppBootstrap($this);
             $bootstrap->bootstrap();
         }
     }
     return $this;
 }
Esempio n. 9
0
 public function codeHighlight($source, $lang)
 {
     Zend_Loader::loadFile("geshi.php", array(config::getFilename("geshi/"), "/usr/share/php-geshi"), true);
     if ($lang == "cpp") {
         $lang = "C++";
     }
     if ($lang == "gcj") {
         $lang = "Java";
     }
     if (!class_exists("GeSHi")) {
         return "<!-- GeSHi disabled --> <pre>" . htmlspecialchars($source) . "</pre>";
     }
     $geshi = new GeSHi($source, $lang);
     $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
     $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
     $geshi->set_overall_class("geshi");
     $code = $geshi->parse_code();
     return $code;
 }
Esempio n. 10
0
 /**
  * Load a model class and return an object instance
  * 
  * @param string $model 
  * @param string $module Use explicitly named module
  * @return object
  */
 public function getModel($model, $module = null)
 {
     $model = preg_replace_callback('/(\\b|_)([a-z])/i', create_function('$m', 'return $m[1].strtoupper($m[2]);'), $model);
     $module = $module === null ? $this->_getModuleName() : $module;
     $className = 'Model_' . $model;
     if ('default' != $module) {
         $className = ucfirst($module) . '_' . $className;
     }
     if (class_exists($className, false)) {
         return new $className();
     }
     $modulePath = $this->_getModulePath($module);
     $modelFileName = str_replace('_', '/', $model);
     $modelFileName = $modulePath . '/models/' . $modelFileName . '.php';
     if (!Zend_Loader::isReadable($modelFileName)) {
         throw new Exception(sprintf('Invalid model (%s) specified; model class file (%s) not found', $model, $modelFileName));
     }
     Zend_Loader::loadFile($modelFileName);
     return new $className();
 }
Esempio n. 11
0
 public function __construct()
 {
     $this->lockFile = BASE_DIR . '/data/cache/__run_lock';
     $this->jobData = array();
     try {
         if (!Zend_Loader::isReadable(self::$DATA_FILE, BASE_DIR . '/data/cache')) {
             throw new Zend_Exception("Scheduled task cache not found");
         }
         Zend_Loader::loadFile(self::$DATA_FILE, BASE_DIR . '/data/cache', null, true);
         global $__SCHEDULE_CACHE;
         if (isset($__SCHEDULE_CACHE)) {
             $this->jobData = $__SCHEDULE_CACHE;
         } else {
             $this->jobData = array();
         }
     } catch (Zend_Exception $e) {
         // So create the cache dammit!
     }
     $this->lastRun = ifset($this->jobData, 'last_run', 0);
 }
Esempio n. 12
0
 public function load()
 {
     $files = $this->_getFiles();
     $manifestRegistry = Zend_Tool_Rpc_Manifest_Registry::getInstance();
     $providerRegistry = Zend_Tool_Rpc_Provider_Registry::getInstance();
     $classesLoadedBefore = get_declared_classes();
     foreach ($files as $file) {
         Zend_Loader::loadFile($file);
     }
     $classesLoadedAfter = get_declared_classes();
     $loadedClasses = array_diff($classesLoadedAfter, $classesLoadedBefore);
     foreach ($loadedClasses as $loadedClass) {
         $reflectionClass = new ReflectionClass($loadedClass);
         if ($reflectionClass->implementsInterface('Zend_Tool_Rpc_Manifest_Interface') && !$reflectionClass->isAbstract()) {
             $manifestRegistry->addManifest($reflectionClass->newInstance());
         }
         if ($reflectionClass->implementsInterface('Zend_Tool_Rpc_Provider_Interface') && !$reflectionClass->isAbstract()) {
             $providerRegistry->addProvider($reflectionClass->newInstance());
         }
     }
 }
Esempio n. 13
0
 /**
  * Загружаем Bootstrap модулей
  */
 protected function _initModules()
 {
     $this->bootstrap('Frontcontroller');
     $this->bootstrap('Session');
     $filesModules = glob(MODULES_PATH . DS . '*' . DS . 'Bootstrap.php');
     $filesHeap = glob(HEAP_PATH . DS . '*' . DS . 'Bootstrap.php');
     $bootstraps = array_merge($filesModules, $filesHeap);
     $modules = array();
     foreach ($bootstraps as $path) {
         Zend_Loader::loadFile($path, null, 1);
         $temp = explode(DS, $path);
         $prefix = $temp[sizeof($temp) - 3] == 'Modules' ? 'Modules_' : '';
         $bootstrapClass = $prefix . $temp[sizeof($temp) - 2] . '_Bootstrap';
         if (class_exists($bootstrapClass, false)) {
             $moduleBootstrap = new $bootstrapClass();
             $moduleBootstrap->bootstrap();
             $modules[$prefix . $temp[sizeof($temp) - 2]] = dirname($path);
         }
     }
     Zend_Registry::set('modules', $modules);
 }
Esempio n. 14
0
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     //    	$module = $request->getModuleName();
     //
     //	    if (!isset($this->_modules[$module])) {
     //	        throw new Exception("Module does not exist!");
     //	    }
     //
     //	    $bootstrapPath = $this->_modules[$module];
     //
     //	    $bootstrapFile = dirname($bootstrapPath) . '/Bootstrap.php';
     //	       $class         = ucfirst($module) . '_Bootstrap';
     //	       $application   = new Zend_Application(
     //	        APPLICATION_ENV,
     //	        APPLICATION_PATH . '/modules/' . $module . '/configs/module.ini'
     //	    );
     //
     //       if (Zend_Loader::loadFile('Bootstrap.php', dirname($bootstrapPath)) & class_exists($class)) {
     //	           $bootstrap = new $class($application);
     //	           $bootstrap->bootstrap();
     //	       }
     $front = Zend_Controller_Front::getInstance();
     // Get current module name
     $module = $request->getModuleName();
     // Array module
     $modules = $front->getParam('cmsModules');
     $modulePath = $front->getParam("pathToModules");
     if (isset($modules[$module])) {
         $currentModulePath = $modulePath . '/' . $modules[$module];
         $bootstrapFile = $currentModulePath . '/Bootstrap.php';
         $class = ucfirst($modules[$module]) . '_Bootstrap';
         $application = new Zend_Application(APPLICATION_ENV, $currentModulePath . '/configs/module.ini');
         if (Zend_Loader::loadFile('Bootstrap.php', $currentModulePath) && class_exists($class)) {
             $bootstrap = new $class($application);
             $bootstrap->bootstrap();
         }
     }
 }
Esempio n. 15
0
 /**
  * Ensure that a given type is actually included
  *
  * @param string $class
  */
 public function includeType($class)
 {
     if (empty($class)) {
         throw new Exception("Cannot include null type");
     }
     $class = str_replace('.', '_', $class);
     $dir = 'model';
     $file = $class . '.php';
     $source = $dir . DIRECTORY_SEPARATOR . $file;
     $found = false;
     if (!Zend_Loader::isReadable($source)) {
         $extensions = array_merge(array('november'), za()->getExtensions());
         foreach ($extensions as $extDir) {
             $source = $extDir . DIRECTORY_SEPARATOR . 'model' . DIRECTORY_SEPARATOR . $file;
             if (Zend_Loader::isReadable($source)) {
                 $found = true;
                 break;
             }
         }
     } else {
         $found = true;
     }
     if (!$found && endswith($class, 'Version')) {
         // try including the non-version instance instead
         return $this->includeType(substr($class, 0, strrpos($class, 'Version')));
     }
     try {
         if (!class_exists($class, false)) {
             Zend_Loader::loadFile(basename($source), APP_DIR . DIRECTORY_SEPARATOR . dirname($source), true);
         }
     } catch (Zend_Exception $ze) {
         // ignore it, we'll just assume it was loaded elsewhere
     }
     if (!class_exists($class)) {
         throw new Exception("Class {$class} not found in the model directory");
     }
 }
Esempio n. 16
0
 public static function getControllersJavaScript()
 {
     $frontController = Zend_Controller_Front::getInstance();
     $directories = $frontController->getControllerDirectory();
     $moduleDirectories = $directories[RM_Environment::getConnector()->getModule()];
     $jsResult = "";
     foreach ($moduleDirectories as $directoryName) {
         $moduleDirectory = $directoryName . DIRECTORY_SEPARATOR . 'RM' . DIRECTORY_SEPARATOR . ucfirst(RM_Environment::getConnector()->getModule());
         $files = RM_Filesystem::getFilesRecursively($moduleDirectory);
         foreach ($files as $file) {
             Zend_Loader::loadFile($file, null, true);
             $className = self::_getClassName($moduleDirectory, $file);
             $jsMethodNames = self::_getJsMethodList($className);
             if (count($jsMethodNames) == 0) {
                 continue;
             }
             $controller = new $className($frontController->getRequest(), $frontController->getResponse());
             foreach ($jsMethodNames as $jsMethodName) {
                 $jsResult .= $controller->{$jsMethodName}();
             }
         }
     }
     return $jsResult;
 }
Esempio n. 17
0
 /**
  * Load a controller class
  *
  * Attempts to load the controller class file from
  * {@link getControllerDirectory()}.  If the controller belongs to a
  * module, looks for the module prefix to the controller class.
  *
  * @param string $className
  * @return string Class name loaded
  * @throws Zend_Controller_Dispatcher_Exception if class not loaded
  */
 public function loadClass($className)
 {
     $finalClass = $className;
     if ($this->_defaultModule != $this->_curModule || $this->getParam('prefixDefaultModule')) {
         $finalClass = $this->formatClassName($this->_curModule, $className);
     }
     if (class_exists($finalClass, false)) {
         return $finalClass;
     }
     $dispatchDir = $this->getDispatchDirectory();
     $loadFile = $dispatchDir . DIRECTORY_SEPARATOR . $this->classToFilename($className);
     $dir = dirname($loadFile);
     $file = basename($loadFile);
     try {
         Zend_Loader::loadFile($file, $dir, true);
     } catch (Zend_Exception $e) {
         require_once 'Zend/Controller/Dispatcher/Exception.php';
         throw new Zend_Controller_Dispatcher_Exception('Cannot load controller class "' . $className . '" from file "' . $file . '" in directory "' . $dir . '"');
     }
     if (!class_exists($finalClass, false)) {
         require_once 'Zend/Controller/Dispatcher/Exception.php';
         throw new Zend_Controller_Dispatcher_Exception('Invalid controller class ("' . $finalClass . '")');
     }
     return $finalClass;
 }
Esempio n. 18
0
 public static function loadFile($filename, $dirs, $once = false)
 {
     $dirs = array_merge($dirs, array(dirname(__FILE__)));
     parent::loadFile($filename, $dirs, $once);
 }
Esempio n. 19
0
 /**
  * Loads a Controller file given a module and controller name
  *
  * @param Zend_Controller_Request_Abstract $action
  * @return boolean
  */
 protected function loadControllerFile($moduleName, $controllerName)
 {
     $dirs = $this->getFrontController()->getControllerDirectory();
     Zend_Loader::loadFile($this->classToFilename($this->formatControllerName($controllerName)), $dirs[$moduleName], true);
 }
Esempio n. 20
0
 /**
  * Load the model
  * 
  * @throws Exception
  * @param string $modelName
  * @param string $module
  * @param string $modelPrefix
  */
 public function loadModel($modelName, $module = null, $modelPrefix = null)
 {
     $modelName = ucfirst($modelName);
     $fileName = $modelName . '.php';
     if (!$module) {
         $module = $this->_request->getModuleName();
     }
     if (!$modelPrefix) {
         $modelPrefix = $this->_modelPrefix;
     }
     if ($modelPrefix) {
         $modelName = ucfirst($modelPrefix) . '_' . $modelName;
     }
     $modelName = str_ireplace('_', '/', $modelName);
     if (class_exists($modelName, false)) {
         return true;
     }
     $controllerDirectory = $this->_dispatcher->getControllerDirectory($module);
     $moduleDirectory = dirname($controllerDirectory);
     $modelDirectory = $moduleDirectory . '/' . $this->_modelDirectory;
     Zend_Loader::loadFile($fileName, $modelDirectory, true);
     if (!class_exists($modelName, false)) {
         throw new Zym_Loader_Exception('Failed to load class "' . $modelName . '"');
     }
     return true;
 }
Esempio n. 21
0
    /**
     * Tests that loadFile() finds a file in the include_path when $dirs is non-null
     * This was not working vis-a-vis ZF-1174
     */
    public function testLoaderFileIncludePathNonEmptyDirs()
    {
        $saveIncludePath = get_include_path();
        set_include_path(implode(array($saveIncludePath, implode(array(dirname(__FILE__), '_files', '_testDir1'), DIRECTORY_SEPARATOR)), PATH_SEPARATOR));

        $result = Zend_Loader::loadFile('Class4.php', implode(PATH_SEPARATOR, array('foo', 'bar')));
        $this->assertEquals(1, $result);

        set_include_path($saveIncludePath);
    }
Esempio n. 22
0
File: Sitemap.php Progetto: cwcw/cms
 /**
  *
  */
 protected function _getControllers($controllerPath)
 {
     $controllers = array();
     try {
         $dir = new DirectoryIterator($controllerPath);
     } catch (Exception $e) {
         throw new Streamwide_Exception("Directory {$controllerPath} not readable");
     }
     $module = basename(dirname($controllerPath));
     //default, admin ...
     $module = $module == 'default' ? "" : ucfirst($module) . "_";
     foreach ($dir as $file) {
         if ($file->isDot() || $file->isDir()) {
             continue;
         }
         $controllerFile = $file->getFilename();
         $match = array();
         if (!preg_match('/([A-Za-z0-9]+)Controller.php$/', $controllerFile, $match)) {
             continue;
         }
         Zend_Loader::loadFile($controllerFile, $controllerPath, true);
         $controller = $match[1];
         $controllers[$controller] = $module . $controller . "Controller";
     }
     return $controllers;
 }
Esempio n. 23
0
 /**
  * This function require module define files : application/module 
  *
  * @return void
  */
 protected function _initModuleDefines()
 {
     $options = $this->getApplication()->getOptions();
     $plugins = $options['digitalus_plugins'];
     //Create a router and request object
     // 		$router = new Zend_Controller_Router_Rewrite();
     $router = $this->_front->getRouter();
     $request = new Zend_Controller_Request_Http();
     $router->route($request);
     // Get current module name
     $module = $request->getModuleName();
     $index = $module;
     if ($module != 'admin' && $module != 'client' && $module != 'public') {
         $index = 'admin';
     }
     $plugins = $options['digitalus_plugins'][$index];
     //		$this->_front->registerPlugin(new Digitalus_Controller_Plugin_Initializer());
     //		$this->_front->registerPlugin(new Digitalus_Controller_Plugin_Auth());
     foreach ($plugins as $key => $class) {
         $this->_front->registerPlugin(new $class());
     }
     // Array module
     $modules = $this->_front->getParam('cmsModules');
     //        $filepath = $this->_front->getParam("pathToModules");
     $modulePath = $this->_front->getParam("pathToModules");
     //        if (isset($modules[$module])) {
     //            $modulePluginPath = $filepath . '/' . $modules[$module] . '/' . $modules[$module] . '.php' ;
     //            require_once($modulePluginPath);
     //            $pluginName = ucfirst($modules[$module]) . '_Plugin';
     //            $this->_front->registerPlugin(new $pluginName);
     //        }
     // Theo cam tinh , cach nay cham hon cach cu 1 chut (nhung khong dang ke) 1.25s voi 1.3s trung binh
     if (isset($modules[$module])) {
         $currentModulePath = $modulePath . '/' . $modules[$module];
         $bootstrapFile = $currentModulePath . '/Bootstrap.php';
         $class = ucfirst($modules[$module]) . '_Bootstrap';
         $moduleInit = $currentModulePath . '/configs/module.ini';
         if (!file_exists($moduleInit)) {
             $moduleInit = null;
         }
         $application = new Zend_Application(APPLICATION_ENV, $moduleInit);
         if (Zend_Loader::loadFile('Bootstrap.php', $currentModulePath) && class_exists($class)) {
             $bootstrap = new $class($application);
             $bootstrap->bootstrap();
         }
     }
 }
Esempio n. 24
0
 /**
  * Load a controller class
  * 
  * Overridden to take into account the extension directory
  * location, so will search in that for a controller 
  * definition if none is found in the controllers directory.
  *
  * @param string $className 
  * @return string Class name loaded
  * @throws Zend_Controller_Dispatcher_Exception if class not loaded
  */
 public function loadClass($className)
 {
     Zend_Loader::loadFile($this->classToFilename($className), $this->controllerPath, true);
     if ('default' != $this->_curModule) {
         $className = $this->formatModuleName($this->_curModule) . '_' . $className;
     }
     if (!class_exists($className)) {
         require_once 'Zend/Controller/Dispatcher/Exception.php';
         throw new Zend_Controller_Dispatcher_Exception('Invalid controller class ("' . $className . '")');
     }
     return $className;
 }
Esempio n. 25
0
 /**
  * Load a controller class
  * 
  * Attempts to load the controller class file from 
  * {@link getControllerDirectory()}.  If the controller belongs to a 
  * module, looks for the module prefix to the controller class.
  *
  * @param string $className 
  * @return string Class name loaded
  * @throws Zend_Controller_Dispatcher_Exception if class not loaded
  */
 public function loadClass($className)
 {
     $dispatchDir = $this->getDispatchDirectory();
     $loadFile = $dispatchDir . DIRECTORY_SEPARATOR . $this->classToFilename($className);
     $dir = dirname($loadFile);
     $file = basename($loadFile);
     Zend_Loader::loadFile($file, $dir, true);
     if ('default' != $this->_curModule) {
         $className = $this->formatModuleName($this->_curModule) . '_' . $className;
     }
     if (!class_exists($className)) {
         require_once 'Zend/Controller/Dispatcher/Exception.php';
         throw new Zend_Controller_Dispatcher_Exception('Invalid controller class ("' . $className . '")');
     }
     return $className;
 }
Esempio n. 26
0
 /**
  *
  * @param Zend_Controller_Request_Abstract $request
  */
 public function setRequest(Zend_Controller_Request_Abstract $request)
 {
     $this->_request = $request;
     $moduleName = $request->getModuleName();
     $dispatcher = Zend_Controller_Front::getInstance()->getDispatcher();
     // Add the core module's view path first so ZF doesn't try to later and mess things up
     Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->initView();
     $moduleDirectory = Zend_Controller_Front::getInstance()->getModuleDirectory($moduleName);
     $scriptPath = "{$moduleDirectory}/views";
     if (is_dir($scriptPath)) {
         Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->addBasePath($scriptPath);
     }
     $moduleLayoutDirectory = "{$moduleDirectory}/views/layouts";
     if (is_dir($moduleLayoutDirectory)) {
         Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->addScriptPath($moduleLayoutDirectory);
     } else {
         $defualtModule = Zend_Controller_Front::getInstance()->getDefaultModule();
         $defaultModuleDirectory = Zend_Controller_Front::getInstance()->getModuleDirectory($defualtModule);
         Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->addBasePath($defaultModuleDirectory . '/views');
         Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->addScriptPath($defaultModuleDirectory . '/views/layouts');
     }
     foreach ($this->_addons as $addonName => $addon) {
         $addonDir = $addon['directory'];
         // Add extended module stuff...
         if (isset($addon['config']['modules']['extended']['ext_' . $moduleName])) {
             $extended = $addon['config']['modules']['extended']['ext_' . $moduleName];
             $extendedDir = $addonDir . "/modules/ext_{$moduleName}";
             // View stuff
             if (isset($extended['views']) && $extended['views']) {
                 // Add the view path
                 $viewPath = $extendedDir . '/views';
                 Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->addBasePath($viewPath);
                 // Add the layouts path
                 if (isset($extended['views']['layouts']) && $extended['views']['layouts'] == true) {
                     $layoutPath = $viewPath . '/layouts';
                     Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->addScriptPath($layoutPath);
                 }
                 // Run the placeholders
                 if (isset($extended['views']['placeholders']) && $extended['views']['placeholders'] == true) {
                     $this->_runPlaceholders($viewPath . '/scripts');
                 }
             }
             // Extended controllers
             if (!isset($controllerLoaded) && isset($extended['controllers']) && $extended['controllers'] == true && !$dispatcher->isDispatchable($request)) {
                 $controllerPath = $extendedDir . '/controllers';
                 $file = $dispatcher->getControllerClass($request) . '.php';
                 if (Zend_Loader::isReadable($controllerPath . '/' . $file)) {
                     Zend_Loader::loadFile($file, $controllerPath, true);
                     $controllerLoaded = true;
                 }
             }
         }
     }
 }
Esempio n. 27
0
 /**
  * Loads a PHP file.  This is a wrapper for PHP's include() function.
  *
  * $filename must be the complete filename, including any
  * extension such as ".php".  Note that a security check is performed that
  * does not permit extended characters in the filename.  This method is
  * intended for loading Zend Framework files.
  *
  * If $dirs is a string or an array, it will search the directories
  * in the order supplied, and attempt to load the first matching file.
  *
  * If the file was not found in the $dirs, or if no $dirs were specified,
  * it will attempt to load it from PHP's include_path.
  *
  * If $once is TRUE, it will use include_once() instead of include().
  *
  * @param  string        $filename
  * @param  string|array  $dirs - OPTIONAL either a path or array of paths to search
  * @param  boolean       $once
  * @throws Zend_Exception
  * @return mixed
  *
  * @deprecated Since 0.9.0 -- Use Zend_Loader::loadFile() instead.
  */
 public static function loadFile($filename, $dirs = null, $once = false)
 {
     trigger_error(__CLASS__ . "::" . __FUNCTION__ . " deprecated since 0.9.0, use Zend_Loader::loadFile() instead");
     require_once 'Zend/Loader.php';
     Zend_Loader::loadFile($filename, $dirs, $once);
 }
Esempio n. 28
0
 /**
  * Load a plugin via the name provided
  *
  * @param  string $name
  * @return string Class name of loaded class
  * @throws Zend_Loader_Exception if class not found
  */
 public function load($name)
 {
     $name = $this->_formatName($name);
     if ($this->_useStaticRegistry) {
         $registry = self::$_staticPrefixToPaths[$this->_useStaticRegistry];
     } else {
         $registry = $this->_prefixToPaths;
     }
     if ($this->isLoaded($name)) {
         return $this->getClassName($name);
     }
     $found = false;
     $classFile = str_replace('_', DIRECTORY_SEPARATOR, $name) . '.php';
     $registry = array_reverse($registry, true);
     $incPathsMaster = explode(PATH_SEPARATOR, get_include_path());
     foreach ($registry as $prefix => $paths) {
         $incPaths = $incPathsMaster;
         $className = $prefix . $name;
         if (class_exists($className, false)) {
             $found = true;
             break;
         }
         $paths = array_reverse($paths, true);
         foreach ($paths as $key => $path) {
             if (preg_match('/^[a-z0-9_](?!(:\\/))(?!:' . preg_quote('\\') . ')/i', $path)) {
                 foreach ($incPaths as $index => $incPath) {
                     $incPaths[$index] .= DIRECTORY_SEPARATOR . $path;
                 }
                 unset($paths[$key]);
             }
         }
         $paths = array_merge($paths, $incPaths);
         if (Zend_Loader::loadFile($classFile, $paths, true)) {
             if (class_exists($className, false)) {
                 $found = true;
                 break;
             }
         }
     }
     if ($found) {
         if ($this->_useStaticRegistry) {
             self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name] = $className;
         } else {
             $this->_loadedPlugins[$name] = $className;
         }
         return $className;
     }
     require_once 'Zend/Loader/PluginLoader/Exception.php';
     $message = 'Plugin by name ' . $name . ' was not found in the registry; paths searched: ' . var_export($registry, 1) . "\n" . 'Original include_path: ' . get_include_path();
     throw new Zend_Loader_PluginLoader_Exception($message);
 }
Esempio n. 29
0
 /**
  * Export Action
  */
 public function exportAction()
 {
     // Chave Primária
     $primaries = $this->_getPrimaries(function ($value) {
         return (int) $value;
     });
     // Recuperação de Elemento
     $table = $this->_getDbTable();
     $element = $table->find($primaries)->current();
     // Verificação
     if ($element === null) {
         throw new Zend_Db_Exception('Invalid Element');
     }
     // Dependências
     Zend_Loader::loadFile('antlr.php', null, true);
     Zend_Loader::loadClass('SubWikiParser');
     Zend_Loader::loadClass('SubWikiLexer');
     // Inicialização
     $ass = new ANTLRStringStream($element->conteudo);
     $lex = new SubWikiLexer($ass);
     $cts = new CommonTokenStream($lex);
     // Tradutor
     $parser = $this->_getParser();
     $parser->setTokenStream($cts);
     // Usuário Atual
     $usuario = $element->findParentRow('Usuario');
     $autor = $usuario->findParentRow('Autor');
     $instituicao = $autor->findParentRow('Instituicao');
     // Preenchimento de Imagens Disponíveis
     $figuras = $usuario->findDependentRowset('Figura');
     foreach ($figuras as $figura) {
         $identifier = $figura->identificador;
         $filename = $figura->arquivo;
         $caption = $figura->legenda;
         $parser->addImageInfo($identifier, $filename, $caption);
     }
     $this->_images = $figuras;
     // Preenchimento de Citações Disponíveis
     $referencias = $usuario->findDependentRowset('Referencia');
     foreach ($referencias as $referencia) {
         $identifier = $referencia->identificador;
         $parser->addCiteInfo($identifier);
     }
     $this->_citations = $referencias;
     // Processamento
     $parser->wikipage();
     $this->view->document = trim($parser->render());
     // Pacotes
     $this->view->packages = $this->_getPackages();
     // Informações Pessoais e Artigo
     $this->view->title = $element->titulo;
     $this->view->author = $autor->nome;
     $this->view->email = $autor->email;
     $this->view->address = $instituicao->endereco;
     // Citações Inclusas?
     $citations = $parser->getCitations();
     $this->view->citations = !empty($citations);
     // Construção da Saída
     $pathname = $this->_buildOutput();
     // Tipo de Saída Esperada
     $extension = $this->_getParam('type', 'pdf');
     if (!in_array($extension, array('pdf', 'zip'))) {
         $extension = 'pdf';
     }
     // Código Completo Compactado?
     if ($extension == 'zip') {
         $filter = new Zend_Filter_Compress(array('adapter' => 'Zip', 'options' => array('archive' => $pathname . '/document.zip')));
         $filter->filter($pathname);
     }
     // Capturar o Conteúdo
     $content = file_get_contents($pathname . '/document.' . $extension);
     // @todo Remover Diretório Temporário
     // Preparação para Ignorar Renderização de Saída
     $renderer = $this->_helper->getHelper('ViewRenderer');
     $renderer->setNoRender(true);
     $this->view->layout()->disableLayout();
     // Modificação de Cabeçalho
     $this->getResponse()->setHeader('Content-Type', 'application/' . $extension)->setHeader('Content-Disposition', "attachment;filename=document.{$extension}")->append('content', $content);
 }
Esempio n. 30
0
 /**
  * @return void
  * @see    http://framework.zend.com/issues/browse/ZF-2463
  */
 public function testLoaderLoadfileMethodExposesErrorsFromIncludedFile()
 {
     try {
         Zend_Loader::loadFile('Zend/Loader/RunErrorProducer.php');
         $this->fail('Expected Zend_Exception not thrown');
     } catch (Zend_Exception $e) {
         $this->assertEquals(3, count($e->includeErrors));
         $this->assertEquals(E_WARNING, $e->includeErrors[0]->errno);
         $this->assertEquals(E_WARNING, $e->includeErrors[1]->errno);
         $this->assertEquals(E_NOTICE, $e->includeErrors[2]->errno);
     }
 }