• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

PukiWiki


Commit MetaInfo

Revisão8efdb777b1ea9d3c6913075f4ecf015f8416bf8c (tree)
Hora2016-02-13 01:42:42
Autorumorigu <umorigu@gmai...>
Commiterumorigu

Mensagem de Log

BugTrack2/382 Add PukiWikiConfig class and remove 3 global variables

Mudança Sumário

Diff

--- a/lib/func.php
+++ b/lib/func.php
@@ -785,3 +785,39 @@ if (! function_exists('sha1')) {
785785 }
786786 }
787787
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+}
--- a/lib/html.php
+++ b/lib/html.php
@@ -18,10 +18,9 @@ function catbody($title, $page, $body)
1818 global $_LANG, $_LINK, $_IMAGE;
1919 global $auth_type, $auth_user;
2020
21+ $config = config();
2122 global $pkwk_dtd; // XHTML 1.1, XHTML1.0, HTML 4.01 Transitional...
22- global $page_title; // Title of this site
2323 global $do_backup; // Do backup or not
24- global $modifier; // Site administrator's web page
2524 global $modifierlink; // Site administrator's name
2625
2726 $enable_login = false;
--- a/lib/init.php
+++ b/lib/init.php
@@ -56,9 +56,6 @@ define('MUTIME', getmicrotime());
5656 function initialize_settings() {
5757 require(INI_FILE);
5858 $vars = array(
59-'page_title',
60-'modifier',
61-'modifierlink',
6259 'defaultpage',
6360 'whatsnew',
6461 'whatsdeleted',
@@ -129,6 +126,10 @@ function initialize_settings() {
129126 foreach($vars as $varname) {
130127 $GLOBALS[$varname] = ${$varname};
131128 }
129+ $setter = new PukiWikiConfigSetter();
130+ $setter->page_title = $page_title;
131+ $setter->modifier = $modifier;
132+ config($setter);
132133 }
133134
134135 define('INI_FILE', DATA_HOME . 'pukiwiki.ini.php');
@@ -262,7 +263,7 @@ foreach(array('DATA_DIR', 'DIFF_DIR', 'BACKUP_DIR', 'CACHE_DIR') as $dir){
262263
263264 // 設定ファイルの変数チェック
264265 $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',
266267 'rule_related_str', 'load_template_func') as $var){
267268 if (! isset(${$var})) $temp .= '$' . $var . "\n";
268269 }
--- a/skin/pukiwiki.skin.php
+++ b/skin/pukiwiki.skin.php
@@ -76,7 +76,7 @@ if (isset($pkwk_dtd)) {
7676 <?php if ($nofollow || ! $is_read) { ?> <meta name="robots" content="NOINDEX,NOFOLLOW" /><?php } ?>
7777 <?php if (PKWK_ALLOW_JAVASCRIPT && isset($javascript)) { ?> <meta http-equiv="Content-Script-Type" content="text/javascript" /><?php } ?>
7878
79- <title><?php echo $title ?> - <?php echo $page_title ?></title>
79+ <title><?php echo $title ?> - <?php echo $config->page_title() ?></title>
8080
8181 <link rel="SHORTCUT ICON" href="<?php echo $image['favicon'] ?>" />
8282 <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){
278278 <?php } ?>
279279
280280 <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 />
282282 <?php echo S_COPYRIGHT ?>.
283283 Powered by PHP <?php echo PHP_VERSION ?>. HTML convert time: <?php echo elapsedtime() ?> sec.
284284 </div>