/** * Get the modules CSS and combine these */ public function getModuleCSS() { $cacheDir = RM_Environment::getConnector()->getRootPath() . DIRECTORY_SEPARATOR . 'RM' . DIRECTORY_SEPARATOR . 'userdata' . DIRECTORY_SEPARATOR . 'temp' . DIRECTORY_SEPARATOR . 'css'; if (is_dir($cacheDir) == false) { $rmConfig = new RM_Config(); $chmodOctal = intval($rmConfig->getValue('rm_config_chmod_value'), 8); mkdir($cacheDir, $chmodOctal); } $cachedCSS = file_exists($cacheDir . DIRECTORY_SEPARATOR . "modules.css"); if (!$cachedCSS) { $newfileContents = ""; $moduleDAO = new RM_Modules(); $modules = $moduleDAO->fetchAllEnabled(); $config = new RM_Module_Config(); foreach ($modules as $module) { $files = RM_Module_Manager::getCssFiles($module->name); foreach ($files as $file) { // read in the css and change the relative paths then add to a cached css file that we will load $fileContents = file_get_contents(RM_Environment::getConnector()->getRootURL() . "RM/userdata/modules/" . $module->name . "/" . RM_Module_Config::CSS . '/' . $file); $search = "/url\\(([^\\)]*)\\)/"; $replace = "url(../../../userdata/modules/" . $module->name . "/images/\$1)"; $newfileContents .= preg_replace($search, $replace, $fileContents); } } $this->_saveCachedCSS($newfileContents, $cacheDir . DIRECTORY_SEPARATOR . "modules.css"); } // return the cached CSS url so it can be included return RM_Environment::getConnector()->getRootURL() . "RM/userdata/temp/css/modules.css"; }
/** * Will initialize the full observers structure */ private function _init() { $model = new RM_Modules(); $modules = $model->fetchAllEnabled(); $manager = new RM_Module_Manager(); foreach ($modules as $module) { $moduleObject = $manager->getModule($module->name); //We will get the last enabled module in the system //that implements one of our internal interfaces if ($moduleObject instanceof RM_Notifications_Observer) { $this->_observers[] = $moduleObject; } } }
/** * Private constructor that invokes only from 'getInstance' method */ private function __construct() { $this->_initializeLocale(); $model = new RM_Modules(); $allModules = $model->fetchAll(); $modules = $model->fetchAllEnabled(); foreach ($modules as $module) { $moduleObject = RM_Module_Manager::getModule($module->name); //We will get the last enabled module in the system //that implements one of our internal interfaces if ($moduleObject instanceof RM_Payments_Interface) { $this->_paymentSystem = $moduleObject; } if ($moduleObject instanceof RM_Extras_Interface) { $this->_extrasSystems[] = $moduleObject; } if ($moduleObject instanceof RM_Others_Interface) { $this->_othersSystems[] = $moduleObject; } if ($moduleObject instanceof RM_SEF_Manager_Interface) { $this->_sefManager = $moduleObject; } } $pluginModel = new RM_Plugins(); $allPlugins = $pluginModel->fetchAll(); $plugins = $pluginModel->fetchAllEnabled(); $this->_taxSystem = new RM_Taxes_Default(); foreach ($plugins as $plugin) { $pluginObject = RM_Plugin_Manager::getPlugin($plugin->name); if ($pluginObject instanceof RM_Taxes_Interface) { $this->_taxSystem = $pluginObject; } if ($pluginObject instanceof RM_Discounts_Plugin_Interface) { $this->_discounts[] = $pluginObject; } //We will assign only one deposit system (the last one enabled) if ($pluginObject instanceof RM_Deposit_Plugin_Interface) { $this->_depositSystem = $pluginObject; } } $this->_initializeTranslate($allModules, $allPlugins); }
public function dispatch() { $rootPath = $this->_rootPath; $modulesDAO = new RM_Modules(); $modules = $modulesDAO->fetchAll(); $pluginsDAO = new RM_Plugins(); $plugins = $pluginsDAO->fetchAll(); $frontController = Zend_Controller_Front::getInstance(); $frontController->setDispatcher($this->getDispatcher()); $frontController->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(array('module' => $this->getModule(), 'controller' => 'Error', 'action' => 'error'))); $frontController->setDefaultModule($this->_module); $frontController->throwExceptions(false); $controllerPathes = array('admin' => array(), 'user' => array()); $coreControllers = implode(DIRECTORY_SEPARATOR, array($rootPath, 'RM', 'system', 'application', 'controllers')) . DIRECTORY_SEPARATOR; $controllerPathes['admin'][] = $coreControllers; $controllerPathes['user'][] = $coreControllers; foreach ($modules as $module) { $controllerPathes['admin'][] = $controllerPathes['user'][] = RM_Module_Manager::getModuleFolderpath($module->name, $this->_rootPath) . DIRECTORY_SEPARATOR . RM_Module_Config::CONTROLLERS; } foreach ($plugins as $plugin) { $controllerPathes['admin'][] = $controllerPathes['user'][] = RM_Plugin_Manager::getPluginFolderpath($plugin->name, $this->_rootPath) . DIRECTORY_SEPARATOR . RM_Plugin_Config::CONTROLLERS; } $frontController->setControllerDirectory($controllerPathes); $scriptPathes = array(); foreach ($modules as $module) { $scriptPathes[] = implode(DIRECTORY_SEPARATOR, array($rootPath, 'RM', 'userdata', 'modules', $module->name, RM_Module_Config::VIEWS, 'admin', 'scripts')) . DIRECTORY_SEPARATOR; $scriptPathes[] = implode(DIRECTORY_SEPARATOR, array($rootPath, 'RM', 'userdata', 'modules', $module->name, RM_Module_Config::VIEWS, 'user', 'scripts')) . DIRECTORY_SEPARATOR; } foreach ($plugins as $plugin) { $scriptPathes[] = implode(DIRECTORY_SEPARATOR, array($rootPath, 'RM', 'userdata', 'plugins', $plugin->name, RM_Plugin_Config::VIEWS, 'admin', 'scripts')) . DIRECTORY_SEPARATOR; $scriptPathes[] = implode(DIRECTORY_SEPARATOR, array($rootPath, 'RM', 'userdata', 'plugins', $plugin->name, RM_Plugin_Config::VIEWS, 'user', 'scripts')) . DIRECTORY_SEPARATOR; } $scriptPathes[] = implode(DIRECTORY_SEPARATOR, array($rootPath, 'RM', 'userdata', 'views', 'admin', 'scripts')) . DIRECTORY_SEPARATOR; $scriptPathes[] = implode(DIRECTORY_SEPARATOR, array($rootPath, 'RM', 'userdata', 'views', 'user', 'scripts')) . DIRECTORY_SEPARATOR; $view = new RM_View(); $view->addScriptPath($scriptPathes); $viewRenderer = new RM_Controller_Action_Helper_ViewRenderer($view); Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); $router = RM_Environment::getInstance()->getRouter(); $frontController->setRouter($router); Zend_Layout::startMvc(array('layout' => $this->_module, 'layoutPath' => implode(DIRECTORY_SEPARATOR, array($rootPath, 'RM', 'userdata', 'layouts')))); $model = new RM_Modules(); $modules = $model->fetchAllEnabled(); $manager = new RM_Module_Manager(); foreach ($modules as $module) { $moduleObject = $manager->getModule($module->name); if ($moduleObject instanceof RM_System_Setup) { $moduleObject->preDispatch(); } } $frontController->dispatch($this->getRequestHTTP()); }