Skip to content

Commit

Permalink
v 0.2.6
Browse files Browse the repository at this point in the history
User 클래스 멤버변수 작성법 변경 -> 언더바 사용 X
각종 버그 픽스
  • Loading branch information
Prev committed Jul 31, 2013
1 parent c3d233e commit eaaebd9
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 40 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ engine-pmc 설치 및 개발 방법은 **[이 문서](https://github.com/Prev/en

#Change Log

####v 0.2.6
+ User 클래스 멤버변수 작성법 변경 -> 언더바 사용 X
+ 각종 버그 픽스

####v 0.2.5
+ 템플릿 문법 추가
Expand Down
9 changes: 6 additions & 3 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* Define PMC version
*/
define('PMC_VERSION', '0.2.5');
define('PMC_VERSION', '0.2.6');


/**
Expand Down Expand Up @@ -144,8 +144,11 @@
ini_set('display_errors', (DEBUG_MODE ? 1 : 0));


// lib.rsa.php
// lib.lessc.php is required when is needed
// lib.rsa.php, lib.lessc.php is required when is needed

if (file_exists(ROOT_DIR . '/lib/functions/custom.function.php'))
require ROOT_DIR . '/lib/functions/custom.function.php';

require ROOT_DIR . '/config/database.php';
require ROOT_DIR . '/config/secure-keys.php';
require ROOT_DIR . '/lib/others/lib.idiorm.php';
Expand Down
1 change: 1 addition & 0 deletions layouts/error/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
border:1px solid #CCC;
border-radius:7px;
box-shadow: 0 3px 7px #CCC;
background-color: white;

font-size:12px;
font-family:나눔고딕,NanumGothic,돋움,Dotum,Arial,Helvetica,sans-serif;
Expand Down
14 changes: 12 additions & 2 deletions lib/classes/CacheHandler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ static public function execTemplate($filePath, $module=NULL) {

if (!is_dir(ROOT_DIR . self::$siteCacheDir . '/layout/'))
mkdir(ROOT_DIR . self::$siteCacheDir . '/layout/');

if (!is_dir(ROOT_DIR . self::$siteCacheDir . '/template/'))
mkdir(ROOT_DIR . self::$siteCacheDir . '/template/');

if (!is_file(ROOT_DIR . $filePath)) {
Context::printWarning(array(
Expand Down Expand Up @@ -94,8 +97,15 @@ static public function execTemplate($filePath, $module=NULL) {
require self::getTemplateCacheDir($filePath);
}
static private function getTemplateCacheDir($originFilePath) {
return ROOT_DIR . self::$siteCacheDir . '/layout/' . urlencode($originFilePath) . '.compiled.php';
//return ROOT_DIR . self::$siteCacheDir . '/layout/' . md5($originFilePath) . '.compiled.php';
$originFilePath = getFilePathClear($originFilePath);

if (strpos($originFilePath, '/layouts') === 0) {
$originFilePath = substr($originFilePath, strlen('/layouts/'));
return ROOT_DIR . self::$siteCacheDir . '/layout/' . urlencode($originFilePath) . '.compiled.php';
}else {
$originFilePath = substr($originFilePath, strpos($originFilePath, '/modules/') + strlen('/modules/'));
return ROOT_DIR . self::$siteCacheDir . '/template/' . urlencode($originFilePath) . '.compiled.php';
}
}
static private function makeTemplateCache($filePath, $content) {
$cacheFileName = self::getTemplateCacheDir($filePath);
Expand Down
18 changes: 10 additions & 8 deletions lib/classes/Context.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function init($db_info) {
));
return;
}

CacheHandler::init();
ModuleHandler::init();
DBHandler::init($db_info);
Expand Down Expand Up @@ -165,6 +165,14 @@ private function initMenu($getVars) {
}else
$moduleID = $data->module;
}
if ($data && $data->extra_vars) {
$extraVars = json_decode($data->extra_vars);
if ($extraVars && $extraVars->linkToSubMenu == true) {
$subMenu = self::getMenu(2);
if ($subMenu && count($subMenu) > 0)
redirect(getUrl() . (USE_SHORT_URL ? '/' : '/?menu=') . $subMenu[0]->title);
}
}
if ($data && $data->module && $data->action && !$moduleAction)
$moduleAction = $data->action;
}
Expand Down Expand Up @@ -479,6 +487,7 @@ public function checkSSO() {
unset($_SESSION['pmc_sso_data']);
return false;
}

$ssoData = json_decode($urlData);
if (!$ssoData || $ssoData->result === 'fail') {
Context::printErrorPage(array(
Expand All @@ -489,12 +498,6 @@ public function checkSSO() {
return false;
}
$userData = $ssoData->userData;
if (isset($userData->groups)) {
for ($i=0; $i<count($userData->groups); $i++) {
$group = $userData->groups[$i];
$group->name_locale = fetchLocale($group->name_locales);
}
}
$_SESSION['pmc_sso_data'] = $ssoData;

User::initCurrent();
Expand Down Expand Up @@ -561,4 +564,3 @@ public function getModuleContent($moduleID=NULL, $moduleAction=NULL, $queryParam
}
}
}

9 changes: 3 additions & 6 deletions lib/classes/TemplateHandler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private function _compileTemplate($html, $module=NULL, $relativePath='/') {
$html = preg_replace('`<link(.*?)>(.*?)</link>`', '<a href="$2"$1>$2</a>', $html);

// <title>title</title> proc
$html = preg_replace_callback('`<title>(.*?)</title>`', array($this, 'setTitle'), $html);
$html = preg_replace_callback('`<title>(.*?)</title>`', create_function('$matches', 'Context::getInstance()->setTitle($matches[1]);'), $html);


$html = join('$_SERVER', explode('$__attr->_SERVER', $html));
Expand Down Expand Up @@ -216,13 +216,10 @@ private function parseSwitches($matches) {
$code = $matches[2];
$code = preg_replace('/<case value="(.*?)">([\s\S]*?)<\/case>/', 'case \'$1\' : ?>$2<?php break; ?>', $code, 1);
$code = preg_replace('/<case value="(.*?)">([\s\S]*?)<\/case>/', '<?php case \'$1\' : ?>$2<?php break; ?>', $code);
$code = preg_replace('/<default>([\s\S]*?)<\/default>/', '<?php default : ?>$1<?php break; ?>', $code);

return '<?php switch ('.$c.') :' . $code . '<?php endswitch; ?>';
}


private function setTitle($matches) {
Context::getInstance()->setTitle($matches[1]);
return '<?php switch ('.$c.') :' . $code . '<?php endswitch; ?>';
}


Expand Down
28 changes: 14 additions & 14 deletions lib/classes/User.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class User {
static private $userSingleTon;

public $id;
public $input_id;
public $nick_name;
public $user_name;
public $email_address;
public $phone_number;
public $permission;
public $last_logined_ip;
public $extra_vars;
public $inputId;
public $userId;
public $nickName;
public $userName;
public $emailAddress;
public $phoneNumber;
public $lastLoginedIp;
public $extraVars;
public $groups;

static public function getCurrent() {
Expand All @@ -44,15 +44,15 @@ static public function initCurrent() {
}

public function __construct($data) {
if (isset($data->input_id) &&
isset($data->nick_name) &&
isset($data->user_name) &&
isset($data->email_address) &&
isset($data->phone_number)
){
if (isset($data->id) && isset($data->inputId)){
foreach ($data as $key => $value) {
$this->{$key} = $value;
}
if (isset($this->groups)) {
for ($i=0; $i<count($this->groups); $i++)
$this->groups[$i]->nameLocale = fetchLocale($this->groups[$i]->nameLocales);
}

}
else {
Context::printWarning('User class is not initialize with User record data');
Expand Down
2 changes: 1 addition & 1 deletion modules/login/LoginController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private function login($id, $pw, $autoLogin) {

$this->insertLoginlog($id, true, $autoLogin);
setcookie('pmc_sess_key', $sessionKey, ($autoLogin ? $expireTime : 0), getServerInfo()->uri, SESSION_DOMAIN);

redirect($next);

}
Expand Down
18 changes: 12 additions & 6 deletions sso-server/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@
foreach ($userData as $key => $value) {
if ($key === 'password' || $key === 'password_salt') continue;
if ($key == 'input_id')
$obj->userData->user_id = $value;
$obj->userData->userId = $value;

$key = preg_replace_callback('/(.)_([a-z])/', create_function('$m', 'return $m[1].strtoupper($m[2]);'), $key);
$obj->userData->{$key} = $value;
}

Expand All @@ -70,11 +71,16 @@

$obj->userData->groups = array();
for ($i=0; $i < count($groupDatas); $i++) {
$tmp = $groupDatas[$i];
$tmp->name_locales = json_decode($tmp->name_locales);
unset($tmp->id);
unset($tmp->user_id);

$tmp = new StdClass();
foreach ($groupDatas[$i] as $key => $value) {
if ($key === 'id' || $key === 'user_id') continue;
if ($key === 'name_locales') {
$tmp->nameLocales = json_decode($value);
continue;
}
$key = preg_replace_callback('/(.)_([a-z])/', create_function('$m', 'return $m[1].strtoupper($m[2]);'), $key);
$tmp->{$key} = $value;
}
array_push($obj->userData->groups, $tmp);
}

Expand Down

0 comments on commit eaaebd9

Please sign in to comment.