/** * Translates passed index * * @param string $sTextIdent translation index * * @return string */ public function getText($sTextIdent) { if ($this->_aLangData === null) { $this->_aLangData = array(); $sLangFilePath = getInstallPath() . EditionPathProvider::SETUP_DIRECTORY . '/' . ucfirst($this->getLanguage()) . '/lang.php'; if (file_exists($sLangFilePath) && is_readable($sLangFilePath)) { $aLang = array(); include $sLangFilePath; $this->_aLangData = array_merge($aLang, $this->getAdditionalMessages()); } } return isset($this->_aLangData[$sTextIdent]) ? $this->_aLangData[$sTextIdent] : null; }
/** * Returns image file path * * @return string */ public function getImageDir() { return getInstallPath() . 'out/admin/img'; }
/** * Class constructor, loads config key */ public function __construct() { if (defined('OXID_PHP_UNIT')) { include getShopBasePath() . "Core/oxconfk.php"; } else { include getInstallPath() . "Core/oxconfk.php"; } }
/** * Performs application removal process * * @return null */ public function remove() { // cleanup and remove tmp folder $oUtils = $this->getInstance("oxSetupUtils"); $sCompileDir = getInstallPath() . "tmp/"; $oUtils->removeDir($sCompileDir, true); // seems like APS removes rest of files/db itself return; /* // -- // collecting data // db host $sDbPort = $oUtils->getEnvVar("DB_main_PORT"); $aParams['dbHost'] = $oUtils->getEnvVar( "DB_main_HOST" ) . ( $sDbPort ? ":".$sDbPort : "" ); // db user $aParams['dbUser'] = $oUtils->getEnvVar( "DB_main_LOGIN" ); // db pass $aParams['dbPwd'] = $oUtils->getEnvVar( "DB_main_PASSWORD" ); // db name $aParams['dbName'] = $oUtils->getEnvVar( "DB_main_NAME" ); // -- // removing // db connection instance $oDb = $this->getInstance( "oxSetupDb" ); // initializing connection $oDb->openDatabase( $aParams ); // setupping db $oDb->queryFile( "remove.sql" ); */ }
// 初始化ibos,执行各个已安装模块有extention.php的安装文件,更新缓存 define('ENGINE', 'LOCAL'); $yii = PATH_ROOT . '/library/yii.php'; $ibosApplication = PATH_ROOT . '/system/core/components/ICApplication.php'; require_once $yii; require_once $ibosApplication; $commonConfig = (require CONFIG_PATH . 'common.php'); Yii::createApplication('ICApplication', $commonConfig); CacheUtil::rm('module'); $allModules = getModuleDirs(); $customModules = array_diff($allModules, $sysModules); $modules = !empty($customModules) ? array_merge($sysModules, $customModules) : $sysModules; defined('IN_MODULE_ACTION') or define('IN_MODULE_ACTION', true); foreach ($modules as $module) { if (getIsInstall($module)) { $installPath = getInstallPath($module); $config = (require $installPath . 'config.php'); if (isset($config['authorization'])) { ModuleUtil::updateAuthorization($config['authorization'], $module, $config['param']['category']); } $extentionScript = $installPath . 'extention.php'; // 执行模块扩展脚本(如果有) if (file_exists($extentionScript)) { include_once $extentionScript; } } } // 安装演示数据 if (isset($_SESSION['extData']) && $_SESSION['extData'] == md5('extData')) { $sqlData = file_get_contents(PATH_ROOT . './install/data/installExtra.sql'); $search = array('{time}', '{time1}', '{time2}', '{date}', '{date+1}');
/** * If demo data installation is OFF, tries to delete demo pictures also * checks if setup deletion is ON and deletes setup files if possible, * return deletion status * * @return bool */ public function isDeletedSetup() { //finalizing installation $blDeleted = true; /** @var Session $oSession */ $oSession = $this->getInstance("Session"); /** @var Utilities $oUtils */ $oUtils = $this->getInstance("Utilities"); $sPath = getInstallPath(); $aDemoConfig = $oSession->getSessionParam("aDB"); if (!isset($aDemoConfig['dbiDemoData']) || $aDemoConfig['dbiDemoData'] != '1') { // "/generated" cleanup $oUtils->removeDir($sPath . "out/pictures/generated", true); // "/master" cleanup, leaving nopic $oUtils->removeDir($sPath . "out/pictures/master", true, 1, array("nopic.jpg")); } $aSetupConfig = $oSession->getSessionParam("aSetupConfig"); if (isset($aSetupConfig['blDelSetupDir']) && $aSetupConfig['blDelSetupDir']) { // removing setup files $blDeleted = $oUtils->removeDir($sPath . EditionPathProvider::SETUP_DIRECTORY, true); } return $blDeleted; }
/** * Testing view::getImageDir() * * @return null */ public function testGetImageDir() { $oSetupView = new View(); $this->assertEquals(getInstallPath() . 'out/admin/img', $oSetupView->getImageDir()); }
/** * 执行模块安装 * @param string $moduleName 模块名 * @return boolean 安装成功与否 */ function install($moduleName) { global $coreModules, $sysDependModule; defined('IN_MODULE_ACTION') or define('IN_MODULE_ACTION', true); $installPath = getInstallPath($moduleName); // 安装模块模型(如果有) $modelSqlFile = $installPath . 'model.sql'; if (file_exists($modelSqlFile)) { $modelSql = file_get_contents($modelSqlFile); executeSql($modelSql); } // 处理模块配置,写入数据 $config = (require $installPath . 'config.php'); $icon = MODULE_PATH . $moduleName . '/static/image/icon.png'; if (is_file($icon)) { $config['param']['icon'] = 1; } else { $config['param']['icon'] = 0; } if (!isset($config['param']['category'])) { $config['param']['category'] = ''; } if (isset($config['param']['indexShow']) && isset($config['param']['indexShow']['link'])) { $config['param']['url'] = $config['param']['indexShow']['link']; } else { $config['param']['url'] = ''; } $configs = json_encode($config); $record = array('module' => $moduleName, 'name' => $config['param']['name'], 'url' => $config['param']['url'], 'category' => $config['param']['category'], 'version' => $config['param']['version'], 'description' => $config['param']['description'], 'icon' => $config['param']['icon'], 'config' => $configs, 'installdate' => time()); if (in_array($moduleName, $coreModules)) { $record['iscore'] = 1; } elseif (in_array($moduleName, $sysDependModule)) { $record['iscore'] = 2; } else { $record['iscore'] = 0; } $insertStatus = Yii::app()->db->createCommand()->insert('{{module}}', $record); return $insertStatus; }
/** * Checks if config file is alleady filled with data * * @return bool */ public function alreadySetUp() { $blSetUp = false; $sConfig = join("", file(getInstallPath() . "config.inc.php")); if (strpos($sConfig, "<dbHost>") === false) { $blSetUp = true; } return $blSetUp; }
/** * Testing view::isDeletedSetup() * * @return null */ public function testIsDeletedSetup() { $sPath = getInstallPath(); $oInst1 = $this->getMock("Session", array("getSessionParam"), array(), '', null); $oInst1->expects($this->at(0))->method("getSessionParam")->will($this->returnValue(array("dbiDemoData" => 0))); $oInst1->expects($this->at(1))->method("getSessionParam")->will($this->returnValue(array("blDelSetupDir" => true))); $oInst2 = $this->getMock("Utilities", array("removeDir")); $oInst2->expects($this->at(0))->method("removeDir")->with($this->equalTo($sPath . "out/pictures/generated"), $this->equalTo(true))->will($this->returnValue(true)); $oInst2->expects($this->at(1))->method("removeDir")->with($this->equalTo($sPath . "out/pictures/master"), $this->equalTo(true), $this->equalTo(1), $this->equalTo(array("nopic.jpg")))->will($this->returnValue(true)); $oInst2->expects($this->at(2))->method("removeDir")->with($this->equalTo($sPath . "Setup"), $this->equalTo(true))->will($this->returnValue(true)); $oSetupView = $this->getMock("\\OxidEsales\\Eshop\\Setup\\View", array("getInstance")); $oSetupView->expects($this->at(0))->method("getInstance")->with($this->equalTo("Session"))->will($this->returnValue($oInst1)); $oSetupView->expects($this->at(1))->method("getInstance")->with($this->equalTo("Utilities"))->will($this->returnValue($oInst2)); $this->assertTrue($oSetupView->isDeletedSetup()); }