Changeset 7022
- Timestamp:
- 11/20/08 17:52:00 (7 weeks ago)
- Location:
- trunk
- Files:
-
- 8 modified
-
dispatcher.php (modified) (2 diffs)
-
library/auth.php (modified) (1 diff)
-
library/cache/PageCache.php (modified) (1 diff)
-
library/context.php (modified) (5 diffs)
-
library/data/Setting.php (modified) (11 diffs)
-
library/loader.php (modified) (3 diffs)
-
library/model/blog.service.php (modified) (2 diffs)
-
library/settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dispatcher.php
r7021 r7022 23 23 include(ROOT.'/library/loader.php'); 24 24 $config = Config::getInstance(); 25 26 25 /** Parse and normalize URI. */ 27 26 /* TODO: Unify the environment and do work-arounds. (For IIS, Apache - mod_php or fastcgi, lighttpd, and etc.) */ … … 74 73 75 74 /* TODO: Database Initialization (if necessary) 75 76 76 77 /* TODO: Parse virtual blog information (if necessary)*/ 77 $gCacheStorage = new globalCacheStorage;78 78 $context->URIParser(); 79 $gCacheStorage = new GlobalCacheStorage; 79 80 $context->globalVariableParser(); 80 81 -
trunk/library/auth.php
r7020 r7022 63 63 function getUserId() { 64 64 return Acl::getIdentity('textcube'); 65 }66 67 68 function getBlogId() {69 global $blogid;70 return Context::$blogid;71 // return $blogid;72 65 } 73 66 -
trunk/library/cache/PageCache.php
r6989 r7022 253 253 // blogSettings, ServiceSettings, activePlugins, etc.. 254 254 // Textcube will use it as global object. 255 class globalCacheStorage extends pageCache {255 class GlobalCacheStorage extends pageCache { 256 256 function __construct($blogid = null) { 257 $context = Context::getInstance(); 257 258 $this->_isChanged = false; 258 259 $this->_gCacheStorage = array(); 259 if(is_null($blogid)) $this->_gBlogId = getBlogId();260 if(is_null($blogid)) $this->_gBlogId = $context->blogid; 260 261 else $this->_gBlogId = $blogid; 261 262 } -
trunk/library/context.php
r7021 r7022 178 178 Respond::NotFoundPage(); 179 179 } 180 181 182 $blog = Setting::getBlogSettingsGlobal($this->blogid);183 $skinSetting = getSkinSetting($blogid);184 180 185 181 if(isset($context->accessInfo['interfacePath'])) { … … 224 220 225 221 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; 227 224 $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 229 231 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']; 231 233 switch ($config->service['type']) { 232 234 case 'domain': … … 274 276 } 275 277 $hostURL = 'http://' . $_SERVER['HTTP_HOST'] . (isset($config->service['port']) ? ':' . $config->service['port'] : ''); 276 $blogURL = $pathURL. getFancyURLpostfix();278 $blogURL = $pathURL.$this->__getFancyURLpostfix(); 277 279 $folderURL = rtrim($blogURL . $suri['directive'], '/'); 278 280 if (defined('__TEXTCUBE_MOBILE__')) { … … 295 297 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) ."')"); 296 298 } 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 } 297 307 298 308 function __destruct() { … … 300 310 } 301 311 } 312 313 /** Support functions */ 314 315 function getBlogId() { 316 global $blogid; 317 return $blogid; 318 } 319 302 320 ?> -
trunk/library/data/Setting.php
r7021 r7022 41 41 return $query->getCell('value'); 42 42 } 43 $settings = Setting::getBlogSettingsGlobal(($blogid == null ? getBlogId() : $blogid));43 $settings = setting::getBlogSettingsGlobal(($blogid == null ? getBlogId() : $blogid)); 44 44 if ($settings === false) return $default; 45 45 if( isset($settings[$name]) ) { … … 106 106 if(!in_array($name,$blogSettingFields)) { 107 107 $result[$name] = $value; 108 Setting::setBlogSettingDefault($name,$value,$blogid);108 setting::setBlogSettingDefault($name,$value,$blogid); 109 109 } 110 110 } … … 127 127 if (!array_key_exists($blogid, $__gCacheBlogSettings)) { 128 128 // force loading 129 Setting::getBlogSettingsGlobal($blogid);129 setting::getBlogSettingsGlobal($blogid); 130 130 } 131 131 if ($__gCacheBlogSettings[$blogid] === false) { … … 169 169 if (!array_key_exists($blogid, $__gCacheBlogSettings)) { 170 170 // force loading 171 Setting::getBlogSettingsGlobal($blogid);171 setting::getBlogSettingsGlobal($blogid); 172 172 } 173 173 if ($__gCacheBlogSettings[$blogid] === false) { … … 191 191 // For plugin-specific use. 192 192 function getBlogSetting($name, $default = null) { 193 $settings = Setting::getBlogSettingsGlobal(getBlogId()); // from blog.service.php193 $settings = setting::getBlogSettingsGlobal(getBlogId()); // from blog.service.php 194 194 if ($settings === false) return $default; 195 195 $name = 'plugin_' . $name; … … 203 203 global $database, $blogid; 204 204 $name = 'plugin_' . $name; 205 return Setting::setBlogSettingGlobal($name, $value);205 return setting::setBlogSettingGlobal($name, $value); 206 206 } 207 207 … … 209 209 global $database, $blogid; 210 210 $name = 'plugin_' . $name; 211 return Setting::removeBlogSettingGlobal($name);211 return setting::removeBlogSettingGlobal($name); 212 212 } 213 213 … … 216 216 global $database, $userSetting; 217 217 $name = 'plugin_' . $name; 218 return Setting::getUserSettingGlobal($name, $default);218 return setting::getUserSettingGlobal($name, $default); 219 219 } 220 220 … … 243 243 global $database; 244 244 $name = 'plugin_' . $name; 245 return Setting::setUserSettingGlobal($name, $value);245 return setting::setUserSettingGlobal($name, $value); 246 246 } 247 247 … … 257 257 global $database; 258 258 $name = 'plugin_' . $name; 259 return Setting::removeUserSettingGlobal($name);259 return setting::removeUserSettingGlobal($name); 260 260 } 261 261 … … 285 285 $name = 'plugin_' . $name; 286 286 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; 287 334 } 288 335 -
trunk/library/loader.php
r7020 r7022 8 8 private static $classInfo = array( 9 9 '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')), 11 11 'data' => array('BlogSetting','BlogStatistics','DailyStatistics', 12 12 'DataMaintenance','Filter','Image','POD','RSS', … … 55 55 } 56 56 public static function autoload($name) { 57 global $service;58 57 $name = ucfirst($name); 59 58 $config = Config::getInstance(); … … 62 61 require_once(ROOT . "/library/data/".$config->backend_name."/Adapter.php"); 63 62 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) { 65 64 require_once(ROOT . "/library/session/Session_Memcached.php"); 66 65 } else if(empty(self::$relation[$name])) { -
trunk/library/model/blog.service.php
r7020 r7022 12 12 13 13 function 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); 58 15 } 59 16 … … 92 49 case 'single':default: 93 50 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 '';103 51 } 104 52 } -
trunk/library/settings.php
r7020 r7022 12 12 13 13 protected function __construct() { 14 self::__basicConfigLoader();14 $this->__basicConfigLoader(); 15 15 } 16 16
