Changeset 7022

Show
Ignore:
Timestamp:
11/20/08 17:52:00 (7 weeks ago)
Author:
inureyes
Message:

refs #777

  • 로더의 플로우 패치를 통하여 '일단 돌아가게' 만듬.
  • TODO :
    • Setting 컴포넌트의 재작성, Config 의 컨텐츠를 Setting 을 통해서 접근가능하도록 함
    • 캐시 구조 재작성
    • dispatcher 에서 DB 커넥션 후에 전역변수 설정 로드가 일어나야 하므로 DB 접속 초기화 시점을 당김
    • 세션 매니지먼트 구조를 dispatcher 로 이전
Location:
trunk
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/dispatcher.php

    r7021 r7022  
    2323include(ROOT.'/library/loader.php'); 
    2424$config = Config::getInstance(); 
    25  
    2625/** Parse and normalize URI. */ 
    2726/* TODO: Unify the environment and do work-arounds. (For IIS, Apache - mod_php or fastcgi, lighttpd, and etc.) */ 
     
    7473 
    7574/* TODO: Database Initialization (if necessary) 
     75 
     76 
    7677/* TODO: Parse virtual blog information (if necessary)*/ 
    77 $gCacheStorage = new globalCacheStorage; 
    7878$context->URIParser(); 
     79$gCacheStorage = new GlobalCacheStorage; 
    7980$context->globalVariableParser(); 
    8081 
  • trunk/library/auth.php

    r7020 r7022  
    6363function getUserId() { 
    6464    return Acl::getIdentity('textcube'); 
    65 } 
    66  
    67  
    68 function getBlogId() { 
    69     global $blogid; 
    70     return Context::$blogid; 
    71 //  return $blogid; 
    7265} 
    7366 
  • trunk/library/cache/PageCache.php

    r6989 r7022  
    253253// blogSettings, ServiceSettings, activePlugins, etc.. 
    254254// Textcube will use it as global object. 
    255 class globalCacheStorage extends pageCache { 
     255class GlobalCacheStorage extends pageCache { 
    256256    function __construct($blogid = null) { 
     257        $context = Context::getInstance(); 
    257258        $this->_isChanged = false; 
    258259        $this->_gCacheStorage = array(); 
    259         if(is_null($blogid)) $this->_gBlogId = getBlogId(); 
     260        if(is_null($blogid)) $this->_gBlogId = $context->blogid; 
    260261        else $this->_gBlogId = $blogid; 
    261262    } 
  • trunk/library/context.php

    r7021 r7022  
    178178                Respond::NotFoundPage(); 
    179179        } 
    180  
    181  
    182         $blog = Setting::getBlogSettingsGlobal($this->blogid); 
    183         $skinSetting = getSkinSetting($blogid); 
    184180         
    185181        if(isset($context->accessInfo['interfacePath'])) { 
     
    224220     
    225221    private function __GValParser() { 
    226         global $serviceURL, $pathURL, $defaultURL, $baseURL, $pathURL, $blog, $hostURL, $folderURL, $suri; 
     222        global $serviceURL, $pathURL, $defaultURL, $baseURL, $pathURL, $hostURL, $folderURL; 
     223        global $suri, $blog, $blogid, $skinSetting; 
    227224        $config = Config::getInstance(); 
    228         $suri = $self->suri; 
     225         
     226        $suri = $this->suri; 
     227        $blog = Setting::getBlogSettingsGlobal($this->blogid); 
     228        $skinSetting = Setting::getSkinSetting($this->blogid); 
     229        $blogid = $this->blogid; 
     230         
    229231        if (!isset($serviceURL)) 
    230             $serviceURL = 'http://' . $config->service['domain'] . (isset($config->service['port']) ? ':' . $config->service['port'] : '') . $service['path']; 
     232            $serviceURL = 'http://' . $config->service['domain'] . (isset($config->service['port']) ? ':' . $config->service['port'] : '') . $config->service['path']; 
    231233        switch ($config->service['type']) { 
    232234            case 'domain': 
     
    274276        } 
    275277        $hostURL = 'http://' . $_SERVER['HTTP_HOST'] . (isset($config->service['port']) ? ':' . $config->service['port'] : ''); 
    276         $blogURL = $pathURL.getFancyURLpostfix(); 
     278        $blogURL = $pathURL.$this->__getFancyURLpostfix(); 
    277279        $folderURL = rtrim($blogURL . $suri['directive'], '/'); 
    278280        if (defined('__TEXTCUBE_MOBILE__')) { 
     
    295297        return POD::queryCell("SELECT blogid FROM {$database['prefix']}BlogSettings WHERE name = 'secondaryDomain' AND (value = '$domain' OR  value = '" . (substr($domain, 0, 4) == 'www.' ? substr($domain, 4) : 'www.' . $domain) ."')");     
    296298    } 
     299    private function __getFancyURLpostfix() {    
     300        $config = Config::getInstance(); 
     301        switch($config->service['fancyURL']) { 
     302            case 0: return '/index.php?'; 
     303            case 1: return '/?'; 
     304            case 2:default: return ''; 
     305        } 
     306    } 
    297307     
    298308    function __destruct() { 
     
    300310    } 
    301311} 
     312 
     313/** Support functions */ 
     314 
     315function getBlogId() { 
     316    global $blogid; 
     317    return $blogid;  
     318} 
     319 
    302320?> 
  • trunk/library/data/Setting.php

    r7021 r7022  
    4141            return $query->getCell('value'); 
    4242        } 
    43         $settings = Setting::getBlogSettingsGlobal(($blogid == null ? getBlogId() : $blogid));  
     43        $settings = setting::getBlogSettingsGlobal(($blogid == null ? getBlogId() : $blogid));  
    4444        if ($settings === false) return $default; 
    4545        if( isset($settings[$name]) ) { 
     
    106106                if(!in_array($name,$blogSettingFields)) { 
    107107                    $result[$name] = $value; 
    108                     Setting::setBlogSettingDefault($name,$value,$blogid); 
     108                    setting::setBlogSettingDefault($name,$value,$blogid); 
    109109                } 
    110110            } 
     
    127127        if (!array_key_exists($blogid, $__gCacheBlogSettings)) { 
    128128            // force loading 
    129             Setting::getBlogSettingsGlobal($blogid); 
     129            setting::getBlogSettingsGlobal($blogid); 
    130130        } 
    131131        if ($__gCacheBlogSettings[$blogid] === false) { 
     
    169169        if (!array_key_exists($blogid, $__gCacheBlogSettings)) { 
    170170            // force loading 
    171             Setting::getBlogSettingsGlobal($blogid); 
     171            setting::getBlogSettingsGlobal($blogid); 
    172172        } 
    173173        if ($__gCacheBlogSettings[$blogid] === false) { 
     
    191191    // For plugin-specific use. 
    192192    function getBlogSetting($name, $default = null) { 
    193         $settings = Setting::getBlogSettingsGlobal(getBlogId()); // from blog.service.php 
     193        $settings = setting::getBlogSettingsGlobal(getBlogId()); // from blog.service.php 
    194194        if ($settings === false) return $default; 
    195195        $name = 'plugin_' . $name; 
     
    203203        global $database, $blogid; 
    204204        $name = 'plugin_' . $name; 
    205         return Setting::setBlogSettingGlobal($name, $value); 
     205        return setting::setBlogSettingGlobal($name, $value); 
    206206    } 
    207207     
     
    209209        global $database, $blogid; 
    210210        $name = 'plugin_' . $name; 
    211         return Setting::removeBlogSettingGlobal($name); 
     211        return setting::removeBlogSettingGlobal($name); 
    212212    } 
    213213 
     
    216216        global $database, $userSetting; 
    217217        $name = 'plugin_' . $name; 
    218         return Setting::getUserSettingGlobal($name, $default); 
     218        return setting::getUserSettingGlobal($name, $default); 
    219219    } 
    220220 
     
    243243        global $database; 
    244244        $name = 'plugin_' . $name; 
    245         return Setting::setUserSettingGlobal($name, $value); 
     245        return setting::setUserSettingGlobal($name, $value); 
    246246    } 
    247247     
     
    257257        global $database; 
    258258        $name = 'plugin_' . $name; 
    259         return Setting::removeUserSettingGlobal($name); 
     259        return setting::removeUserSettingGlobal($name); 
    260260    } 
    261261 
     
    285285        $name = 'plugin_' . $name; 
    286286        return POD::execute("DELETE FROM {$database['prefix']}ServiceSettings WHERE name = '".POD::escapeString($name)."'"); 
     287    } 
     288 
     289    function getSkinSetting($blogid, $forceReload = false) { 
     290        global $database, $service, $skinSetting; 
     291        global $__gCacheSkinSetting; 
     292        global $gCacheStorage; 
     293        if ( 
     294            ($forceReload == false)  
     295            && (isset($__gCacheSkinSetting))  
     296            && (array_key_exists($blogid, $__gCacheSkinSetting)) 
     297            )  
     298        { 
     299            return $__gCacheSkinSetting[$blogid]; 
     300        } 
     301        if($blogid == getBlogId() && $forceReload == false) { 
     302            $retval = $gCacheStorage->getContent('SkinSetting'); 
     303            if(!empty($retval)) { 
     304                $__gCacheSkinSetting[$blogid] = $retval; 
     305                return $retval; 
     306            } 
     307        } 
     308        if ($retval = POD::queryRow("SELECT * FROM {$database['prefix']}SkinSettings WHERE blogid = $blogid",MYSQL_ASSOC)) { 
     309            if ($retval != FALSE) { 
     310                if (!Validator::directory($retval['skin']) && ($retval['skin'] !="customize/$blogid")) { 
     311                    $retval['skin'] = $service['skin']; 
     312                } 
     313                $__gCacheSkinSetting[$blogid] = $retval; 
     314                if($blogid == getBlogId())  $gCacheStorage->setContent('SkinSetting',$retval); 
     315                return $retval; 
     316            } 
     317        } 
     318         
     319        $retval = array( 'blogid' => $blogid , 'skin' => $service['skin'],  
     320            'entriesOnRecent' => 5, 'commentsOnRecent' => 5, 'commentsOnGuestbook' => 5, 
     321            'tagsOnTagbox' => 30, 'tagboxAlign' => 3, 'trackbacksOnRecent' => 5,  
     322            'expandComment' => 1, 'expandTrackback' => 1,  
     323            'recentNoticeLength' => 25, 'recentEntryLength' => 30,  
     324            'recentCommentLength' => 30, 'recentTrackbackLength' => 30,  
     325            'linkLength' => 30, 'showListOnCategory' => 1, 'showListOnArchive' => 1,  
     326            'tree' => 'base',  
     327            'colorOnTree' => '000000', 'bgColorOnTree' => '',  
     328            'activeColorOnTree' => 'FFFFFF', 'activeBgColorOnTree' => '00ADEF',  
     329            'labelLengthOnTree' => 27, 'showValueOnTree' => 1 ); 
     330         
     331        $__gCacheSkinSetting[$blogid] = $retval; 
     332        if($blogid == getBlogId())  $gCacheStorage->setContent('SkinSetting',$retval); 
     333        return $retval;  
    287334    } 
    288335     
  • trunk/library/loader.php

    r7020 r7022  
    88    private static $classInfo = array( 
    99        'auth'        => array('Auth','OpenID',array('Privilege'=>'Auth','Acl'=>'Auth')), 
    10         'cache'       => array('PageCache','ICache',array('globalCacheStorage','PageCache'), 
     10        'cache'       => array('PageCache','ICache',array('GlobalCacheStorage'=>'PageCache')), 
    1111        'data'        => array('BlogSetting','BlogStatistics','DailyStatistics', 
    1212            'DataMaintenance','Filter','Image','POD','RSS', 
     
    5555    } 
    5656    public static function autoload($name) { 
    57         global $service; 
    5857        $name = ucfirst($name); 
    5958        $config = Config::getInstance(); 
     
    6261            require_once(ROOT . "/library/data/".$config->backend_name."/Adapter.php"); 
    6362            require_once(ROOT . "/library/data/Database.php"); 
    64         } else if(self::$relation[$name] == 'session' && isset($service['memcached']) && $service['memcached'] == true) { 
     63        } else if(self::$relation[$name] == 'session' && isset($config->service['memcached']) && $config->service['memcached'] == true) { 
    6564            require_once(ROOT . "/library/session/Session_Memcached.php"); 
    6665        } else if(empty(self::$relation[$name])) { 
  • trunk/library/model/blog.service.php

    r7020 r7022  
    1212 
    1313function getSkinSetting($blogid, $forceReload = false) { 
    14     global $database, $service, $skinSetting; 
    15     global $__gCacheSkinSetting; 
    16     global $gCacheStorage; 
    17     if ( 
    18         ($forceReload == false)  
    19         && (isset($__gCacheSkinSetting))  
    20         && (array_key_exists($blogid, $__gCacheSkinSetting)) 
    21         )  
    22     { 
    23         return $__gCacheSkinSetting[$blogid]; 
    24     } 
    25     if($blogid == getBlogId() && $forceReload == false) { 
    26         $retval = $gCacheStorage->getContent('SkinSetting'); 
    27         if(!empty($retval)) { 
    28             $__gCacheSkinSetting[$blogid] = $retval; 
    29             return $retval; 
    30         } 
    31     } 
    32     if ($retval = POD::queryRow("SELECT * FROM {$database['prefix']}SkinSettings WHERE blogid = $blogid",MYSQL_ASSOC)) { 
    33         if ($retval != FALSE) { 
    34             if (!Validator::directory($retval['skin']) && ($retval['skin'] !="customize/$blogid")) { 
    35                 $retval['skin'] = $service['skin']; 
    36             } 
    37             $__gCacheSkinSetting[$blogid] = $retval; 
    38             if($blogid == getBlogId())  $gCacheStorage->setContent('SkinSetting',$retval); 
    39             return $retval; 
    40         } 
    41     } 
    42      
    43     $retval = array( 'blogid' => $blogid , 'skin' => $service['skin'],  
    44         'entriesOnRecent' => 5, 'commentsOnRecent' => 5, 'commentsOnGuestbook' => 5, 
    45         'tagsOnTagbox' => 30, 'tagboxAlign' => 3, 'trackbacksOnRecent' => 5,  
    46         'expandComment' => 1, 'expandTrackback' => 1,  
    47         'recentNoticeLength' => 25, 'recentEntryLength' => 30,  
    48         'recentCommentLength' => 30, 'recentTrackbackLength' => 30,  
    49         'linkLength' => 30, 'showListOnCategory' => 1, 'showListOnArchive' => 1,  
    50         'tree' => 'base',  
    51         'colorOnTree' => '000000', 'bgColorOnTree' => '',  
    52         'activeColorOnTree' => 'FFFFFF', 'activeBgColorOnTree' => '00ADEF',  
    53         'labelLengthOnTree' => 27, 'showValueOnTree' => 1 ); 
    54      
    55     $__gCacheSkinSetting[$blogid] = $retval; 
    56     if($blogid == getBlogId())  $gCacheStorage->setContent('SkinSetting',$retval); 
    57     return $retval;  
     14    return Setting::getSkinSetting($blogid, $forceReload); 
    5815} 
    5916 
     
    9249        case 'single':default: 
    9350            return "http://$domain$path".getFancyURLpostfix(); 
    94     } 
    95 } 
    96  
    97 function getFancyURLpostfix() { 
    98     global $service; 
    99     switch($service['fancyURL']) { 
    100         case 0: return '/index.php?'; 
    101         case 1: return '/?'; 
    102         case 2:default: return ''; 
    10351    } 
    10452} 
  • trunk/library/settings.php

    r7020 r7022  
    1212 
    1313    protected function __construct() { 
    14         self::__basicConfigLoader(); 
     14        $this->__basicConfigLoader(); 
    1515    } 
    1616