PukiWiki
Revision | 35ec9f5866c6056875088363037570d3d01c2b25 (tree) |
---|---|
Time | 2016-02-13 01:51:35 |
Author | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack2/382 Add PukiWikiConfig class and remove 3 global variables
@@ -785,3 +785,39 @@ if (! function_exists('sha1')) { | ||
785 | 785 | } |
786 | 786 | } |
787 | 787 | |
788 | +class PukiWikiConfigSetter { | |
789 | + public $page_title; | |
790 | + public $modifier; | |
791 | + public $modifierlink; | |
792 | +} | |
793 | + | |
794 | +class PukiWikiConfig { | |
795 | + private $page_title; | |
796 | + private $modifier; | |
797 | + private $modifierlink; | |
798 | + function page_title() { return $this->page_title; } | |
799 | + function modifier() { return $this->modifier; } | |
800 | + function modifierlink() { return $this->modifierlink; } | |
801 | + function __construct(PukiWikiConfigSetter $setter) { | |
802 | + $this->page_title = $setter->page_title; | |
803 | + $this->modifier = $setter->modifier; | |
804 | + $this->modifierlink = $setter->modifierlink; | |
805 | + } | |
806 | +} | |
807 | + | |
808 | +/** | |
809 | + * Return config | |
810 | + * | |
811 | + * @return PukiWikiConfig | |
812 | + */ | |
813 | +function config(PukiWikiConfigSetter $setter = null) { | |
814 | + static $config = null; | |
815 | + if (isset($config)) { | |
816 | + return $config; | |
817 | + } | |
818 | + if ($setter) { | |
819 | + $config = new PukiWikiConfig($setter); | |
820 | + return; | |
821 | + } | |
822 | + throw new Exception('Config init errror'); | |
823 | +} |
@@ -18,11 +18,9 @@ function catbody($title, $page, $body) | ||
18 | 18 | global $_LANG, $_LINK, $_IMAGE; |
19 | 19 | global $auth_type, $auth_user; |
20 | 20 | |
21 | + $config = config(); | |
21 | 22 | global $pkwk_dtd; // XHTML 1.1, XHTML1.0, HTML 4.01 Transitional... |
22 | - global $page_title; // Title of this site | |
23 | 23 | global $do_backup; // Do backup or not |
24 | - global $modifier; // Site administrator's web page | |
25 | - global $modifierlink; // Site administrator's name | |
26 | 24 | |
27 | 25 | $enable_login = false; |
28 | 26 | $enable_logout = false; |
@@ -56,9 +56,6 @@ define('MUTIME', getmicrotime()); | ||
56 | 56 | function initialize_settings() { |
57 | 57 | require(INI_FILE); |
58 | 58 | $vars = array( |
59 | -'page_title', | |
60 | -'modifier', | |
61 | -'modifierlink', | |
62 | 59 | 'defaultpage', |
63 | 60 | 'whatsnew', |
64 | 61 | 'whatsdeleted', |
@@ -129,6 +126,10 @@ function initialize_settings() { | ||
129 | 126 | foreach($vars as $varname) { |
130 | 127 | $GLOBALS[$varname] = ${$varname}; |
131 | 128 | } |
129 | + $setter = new PukiWikiConfigSetter(); | |
130 | + $setter->page_title = $page_title; | |
131 | + $setter->modifier = $modifier; | |
132 | + config($setter); | |
132 | 133 | } |
133 | 134 | |
134 | 135 | define('INI_FILE', DATA_HOME . 'pukiwiki.ini.php'); |
@@ -262,7 +263,7 @@ foreach(array('DATA_DIR', 'DIFF_DIR', 'BACKUP_DIR', 'CACHE_DIR') as $dir){ | ||
262 | 263 | |
263 | 264 | // 設定ファイルの変数チェック |
264 | 265 | $temp = ''; |
265 | -foreach(array('rss_max', 'page_title', 'note_hr', 'related_link', 'show_passage', | |
266 | +foreach(array('rss_max', 'note_hr', 'related_link', 'show_passage', | |
266 | 267 | 'rule_related_str', 'load_template_func') as $var){ |
267 | 268 | if (! isset(${$var})) $temp .= '$' . $var . "\n"; |
268 | 269 | } |
@@ -76,7 +76,7 @@ if (isset($pkwk_dtd)) { | ||
76 | 76 | <?php if ($nofollow || ! $is_read) { ?> <meta name="robots" content="NOINDEX,NOFOLLOW" /><?php } ?> |
77 | 77 | <?php if (PKWK_ALLOW_JAVASCRIPT && isset($javascript)) { ?> <meta http-equiv="Content-Script-Type" content="text/javascript" /><?php } ?> |
78 | 78 | |
79 | - <title><?php echo $title ?> - <?php echo $page_title ?></title> | |
79 | + <title><?php echo $title ?> - <?php echo $config->page_title() ?></title> | |
80 | 80 | |
81 | 81 | <link rel="SHORTCUT ICON" href="<?php echo $image['favicon'] ?>" /> |
82 | 82 | <link rel="stylesheet" type="text/css" media="screen" href="<?php echo SKIN_DIR ?>pukiwiki.css.php?charset=<?php echo $css_charset ?>" charset="<?php echo $css_charset ?>" /> |
@@ -278,7 +278,7 @@ function _toolbar($key, $x = 20, $y = 20){ | ||
278 | 278 | <?php } ?> |
279 | 279 | |
280 | 280 | <div id="footer"> |
281 | - Site admin: <a href="<?php echo $modifierlink ?>"><?php echo $modifier ?></a><p /> | |
281 | + Site admin: <a href="<?php echo $config->modifierlink() ?>"><?php echo $config->modifier() ?></a><p /> | |
282 | 282 | <?php echo S_COPYRIGHT ?>. |
283 | 283 | Powered by PHP <?php echo PHP_VERSION ?>. HTML convert time: <?php echo elapsedtime() ?> sec. |
284 | 284 | </div> |