Skip to content

Commit

Permalink
v 0.5.8
Browse files Browse the repository at this point in the history
Add not-using-database function
  • Loading branch information
Prev committed Dec 29, 2013
1 parent 50edfa1 commit 5e94600
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
8 changes: 7 additions & 1 deletion config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* Define PMC version
*/
define('PMC_VERSION', '0.5.5');
define('PMC_VERSION', '0.5.8');


/**
Expand Down Expand Up @@ -87,7 +87,13 @@
*/
//define('DEBUG_MODE', true);

/**
* Define using database.
* In common case, should not fix it.
*/
define('USE_DATABASE', true);


/**
* Define log file's path
*/
Expand Down
11 changes: 11 additions & 0 deletions lib/classes/Context.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ public function init($db_info) {
private function initMenu($getVars) {
$this->parentMenus = array();

if (!USE_DATABASE) {
$indexModuleExists = is_dir(ROOT_DIR . '/modules/index');
$this->moduleID = isset($getVars['module']) ? basename($getVars['module']) : ($indexModuleExists ? 'index' : NULL);
$this->moduleAction = isset($getVars['action']) ? basename($getVars['action']) : NULL;
return;
}

if (isset($getVars['module'])) {
// 모듈이 정의됬을때
$this->moduleID = basename($getVars['module']);
Expand Down Expand Up @@ -307,6 +314,10 @@ private function initMenu($getVars) {
* 메뉴 데이터를 반환
*/
static public function getMenu($level) {
if (!USE_DATABASE){
return array();
}

if ($level == 1) {
// 최상위 메뉴 로드
$arr = DBHandler::for_table('menu')
Expand Down
8 changes: 8 additions & 0 deletions lib/classes/DBHandler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ class DBHandler extends ORM {
// 주로 table prefix 문제를 해결하기 위해 override함
// @override
static public function for_table($table_name, $connection_name = self::DEFAULT_CONNECTION, $appendPrefix=true) {
if (!USE_DATABASE) {
Context::printWarning(array(
'en' => 'If you want to use database, Use should fix const "USE_DATABASE" to "true"',
'ko' => '데이터베이스를 사용하려면 상수 "USE_DATABASE"를 "true"로 바꿔야 합니다.'
));
return;
}

if ($appendPrefix) $table_name = self::$prefix . $table_name;
self::_setup_db($connection_name);

Expand Down
9 changes: 9 additions & 0 deletions modules/board/BoardModule.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@

class BoardModule extends Module {

public function init() {
if (!USE_DATABASE) {
Context::printErrorPage(array(
'en' => 'If you want to use database, Use should fix const "USE_DATABASE" to "true"',
'ko' => '데이터베이스를 사용하려면 상수 "USE_DATABASE"를 "true"로 바꿔야 합니다.'
));
}
}

}

0 comments on commit 5e94600

Please sign in to comment.