hypweb.net
XOOPSマニア  最新情報のRSS(サイト全体)
[ 自宅サーバーWebRing |ID=54 前後5表示乱移動サイト一覧 ]

12年5月17日(Thu) 20時34分
TOP » UsersWiki » nao-pon » メモ » modPukiWiki

この改造で得られる機能は、のぶのぶさん にすべて取り込んで頂きました。
(2004-08-23にCVSで確認。)

modPukiWiki改造メモ anchor.png

Page Top

共通リンクディレクトリに対応してみた。 anchor.png

Page Top

PukiWikiConfig.php - class PukiWikiConfig anchor.png

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
	function initParams() {
		global $_PukiWikiParam;
		$_PukiWikiParam = array();
		
		//PukiWikiMod 共通リンクディレクトリ読み込み by nao-pon
		$wiki_common_dirs = "";
		if (MOD_PUKI_WIKI_VER == "1.3" && file_exists(MOD_PUKI_WIKI_CACHE_DIR."config.php"))
		{
			include(MOD_PUKI_WIKI_CACHE_DIR."config.php");
		}
		// 共通リンクディレクトリ展開
		$wiki_common_dirs = preg_split("/\s+/",trim($wiki_common_dirs));
		sort($wiki_common_dirs,SORT_STRING);
		$_PukiWikiParam['wiki_common_dirs'] = $wiki_common_dirs;
		
		// オートリンクデータ読み込みとチェック
		$need_cache_clear = 0;
		$_PukiWikiParam['autolink_dat'] = array();
		if (file_exists(MOD_PUKI_WIKI_CACHE_DIR.'autolink.dat'))
		{
			$_PukiWikiParam['autolink_dat'] = file(MOD_PUKI_WIKI_CACHE_DIR.'autolink.dat');
			if (!file_exists(MOD_PUKI_CACHE_DIR .'autolink.dat') || ($_PukiWikiParam['autolink_dat'] != file(MOD_PUKI_CACHE_DIR .'autolink.dat')))
			{
				// 比較オートリンクデータを保存
				list($pattern, $pattern_a, $forceignorelist) = $_PukiWikiParam['autolink_dat'];
				$fp = fopen(MOD_PUKI_CACHE_DIR . 'autolink.dat', 'wb') or
					die_message('Cannot write autolink file ' .
					MOD_PUKI_CACHE_DIR . '/autolink.dat' .
					'<br />Maybe permission is not writable');
				set_file_buffer($fp, 0);
				flock($fp, LOCK_EX);
				rewind($fp);
				fputs($fp, trim($pattern)   . "\n");
				fputs($fp, trim($pattern_a) . "\n");
				fputs($fp, trim($forceignorelist) . "\n");
				flock($fp, LOCK_UN);
				fclose($fp);
				
				// オートリンクデータが更新されているのでキャッシュをクリア
				$dh = dir(MOD_PUKI_CACHE_DIR);
				while (($file = $dh->read()) !== FALSE)
				{
					if (substr($file,-6) != '.cache')
					{
						continue;
					}
					$file = MOD_PUKI_CACHE_DIR.$file;
					unlink($file);
				}
				$dh->close();
			}
		}
	}
Page Top

PukiWikiLink.php - class PukiWikiLink_autolink anchor.png

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
	function set($arr,$page)
	{
		$WikiName = PukiWikiConfig::getParam('WikiName');
		
		list($name) = $this->splice($arr);
		
		// 共通リンクディレクトリ対応 by nao-pon
		$alias = $name;
		
		// 無視リストに含まれている、あるいは存在しないページを捨てる
		// 共通リンクディレクトリ対応 by nao-pon
		//if (in_array($name,$this->forceignorepages) or !PukiWikiFunc::is_page($name))
		if (in_array($name,$this->forceignorepages))
		{
			return FALSE;
		}
		
		// 共通リンクディレクトリを探す by nao-pon
		if (!PukiWikiFunc::is_page($name))
		{
 
			if (!$name = PukiWikiFunc::get_real_pagename($name))
				return FALSE;
		}
		
		// 共通リンクディレクトリ対応 by nao-pon
		//return parent::setParam($page,$name,'','pagename',$name);
		return parent::setParam($page,$name,'','pagename',$alias);
	}
Page Top

PukiWikiFunc.php anchor.png

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
	// 共通リンクディレクトリの処理(該当フルネームを返す:ブラケットなし) by nao-pon
	function get_real_pagename($page)
	{
		static $real_pages = array();
		
		$page = PukiWikiFunc::strip_bracket($page);
		
		if (isset($real_pages[$page])) return $real_pages[$page];
		
		$real_pages[$page] = false;
		foreach(PukiWikiConfig::getParam('wiki_common_dirs') as $dir)
		{
			$check = $dir.$page;
			if (PukiWikiFunc::is_page($check))
			{
				$real_pages[$page] = $check;
				break;
			}
		}
		return $real_pages[$page];
	}
Page Top

レンダリングデータをキャッシュするようにしてみた。 anchor.png

Page Top

PukiWikiConfig.php - class PukiWikiConfig anchor.png

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
	function initParams() {
		global $_PukiWikiParam;
		$_PukiWikiParam = array();
		
		//PukiWikiMod 共通リンクディレクトリ読み込み by nao-pon
		$wiki_common_dirs = "";
		if (MOD_PUKI_WIKI_VER == "1.3" && file_exists(MOD_PUKI_WIKI_CACHE_DIR."config.php"))
		{
			include(MOD_PUKI_WIKI_CACHE_DIR."config.php");
		}
		// 共通リンクディレクトリ展開
		$wiki_common_dirs = preg_split("/\s+/",trim($wiki_common_dirs));
		sort($wiki_common_dirs,SORT_STRING);
		$_PukiWikiParam['wiki_common_dirs'] = $wiki_common_dirs;
		
		// オートリンクデータ読み込みとチェック
		$need_cache_clear = 0;
		$_PukiWikiParam['autolink_dat'] = array();
		if (file_exists(MOD_PUKI_WIKI_CACHE_DIR.'autolink.dat'))
		{
			$_PukiWikiParam['autolink_dat'] = file(MOD_PUKI_WIKI_CACHE_DIR.'autolink.dat');
			if (!file_exists(MOD_PUKI_CACHE_DIR .'autolink.dat') &#x7c;&#x7c; ($_PukiWikiParam['autolink_dat'] != file(MOD_PUKI_CACHE_DIR .'autolink.dat')))
			{
				// 比較オートリンクデータを保存
				list($pattern, $pattern_a, $forceignorelist) = $_PukiWikiParam['autolink_dat'];
				$fp = fopen(MOD_PUKI_CACHE_DIR . 'autolink.dat', 'wb') or
					die_message('Cannot write autolink file ' .
					MOD_PUKI_CACHE_DIR . '/autolink.dat' .
					'<br />Maybe permission is not writable');
				set_file_buffer($fp, 0);
				flock($fp, LOCK_EX);
				rewind($fp);
				fputs($fp, trim($pattern)   . "\n");
				fputs($fp, trim($pattern_a) . "\n");
				fputs($fp, trim($forceignorelist) . "\n");
				flock($fp, LOCK_UN);
				fclose($fp);
				
				// オートリンクデータが更新されているのでキャッシュをクリア
				$dh = dir(MOD_PUKI_CACHE_DIR);
				while (($file = $dh->read()) !== FALSE)
				{
					if (substr($file,-6) != '.cache')
					{
						continue;
					}
					$file = MOD_PUKI_CACHE_DIR.$file;
					unlink($file);
				}
				$dh->close();
			}
		}
	}
Page Top

PukiWikiRender.php anchor.png

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
	function transform($wikistr) {
		global $_PukiWikiFootExplain;
		
		if (PukiWikiConfig::getParam('use_cache'))
		{
			// キャッシュ確認 by nao-pon
			$cache_file = MOD_PUKI_CACHE_DIR.md5($wikistr).".cache";
			if (file_exists($cache_file)) return join('',file($cache_file));
		}
		
		if (!is_array($wikistr)) {
			$wikistr = explode("\n", $wikistr);
		}
		
		$this->_body->parse($wikistr);
		$retstr = $this->_body->toString();
		if (count($_PukiWikiFootExplain)) {
			ksort($_PukiWikiFootExplain,SORT_NUMERIC);
			$retstr .= count($_PukiWikiFootExplain) ? PukiWikiConfig::getParam('note_hr').join("\n",$_PukiWikiFootExplain) : '';
		}
		$_PukiWikiFootExplain=array();
		
		if (PukiWikiConfig::getParam('use_cache'))
		{
			//キャッシュ保存 by nao-pon
			$fp = fopen($cache_file, "wb");
			fwrite($fp, $retstr);
			fclose($fp);
		}
		
		return $retstr;
	}
Page Top

PukiWikiLink.php - class PukiWikiLink_autolink anchor.png

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
	function PukiWikiLink_autolink($start)
	{
		parent::PukiWikiLink($start);
		$autolink = PukiWikiConfig::getParam('autolink');
		$autolink_data = PukiWikiConfig::getParam('autolink_dat');
		// AutoLinkデータを予めチェックするようにした by nao-pon
		//if (!$autolink or !file_exists(MOD_PUKI_WIKI_CACHE_DIR.'autolink.dat'))
		if (!$autolink or !$autolink_data)
		{
			return;
		}
		// AutoLinkデータを予めチェックするようにした by nao-pon
		//@list($auto,$auto_a,$forceignorepages) = file(MOD_PUKI_WIKI_CACHE_DIR.'autolink.dat');
		@list($auto,$auto_a,$forceignorepages) = $autolink_data;
		$this->auto = $auto;
		$this->auto_a = $auto_a; 
		$this->forceignorepages = explode("\t",trim($forceignorepages));
	}
Page Top

WikiNameの自動リンクが有効の時、ページがない場合のページ作成リンク有り無しのオプションを追加してみた。 anchor.png

Page Top

PukiWikiLink.php anchor.png

※ 関数作成

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
	function make_pagelink($page, $alias='',$anchor='',$refer='')
	{
		$s_page = htmlspecialchars(PukiWikiFunc::strip_bracket($page));
		$s_alias = ($alias == '') ? $s_page : $alias;
		
		if ($page == '') {
			return "<a href=\"$anchor\">$s_alias</a>";
		}
		
		$r_page = rawurlencode($page);
		$r_refer = ($refer == '') ? '' : '&amp;refer='.rawurlencode($refer);
		
 
		if (PukiWikiFunc::is_page($page)) {
			$passage = "";
			$title = PukiWikiConfig::getParam('link_compact') ? '' : " title=\"$s_page$passage\"";
			return "<a href=\"".MOD_PUKI_WIKI_URL."?$r_page$anchor\"$title>$s_alias</a>";
		} else {
			// ページ作成リンクをつけないオプション追加 by nao-pon
			if (!PukiWikiConfig::getParam('makepage_link')) return $s_alias;
			$retval = "$s_alias<a href=\"".MOD_PUKI_WIKI_URL."?cmd=edit&amp;page=$r_page$r_refer\">".PukiWikiConfig::getParam('_symbol_noexists')."</a>";
			if (!PukiWikiConfig::getParam('link_compact')) {
				$retval = "<span class=\"".PukiWikiConfig::getParam('style_prefix')."noexists\">$retval</span>";
			}
			return $retval;
		}
	}

Post a new comment

Subject
guestname
Body
Go to richer form

Front page   Freeze Diff Backup Copy Rename ReloadPrint View   New Page Page list Search Recent changes   Help   RSS of recent changes (RSS 1.0) RSS of recent changes (RSS 2.0) RSS of recent changes (RSS Atom) Powered by xpWiki
Counter: 5110, today: 1, yesterday: 0
Princeps date: 2004-08-23 (Mon) 17:27:45
Last-modified: 2004-08-23 (Mon) 17:27:45 (JST) (2824d) by nao-pon
このページのTopへ
ログイン
ユーザ名:

パスワード:

オートログイン

Basic 認証 | SSLログイン

Register now! | Lost Password?



メインメニュー
付箋メニュー
Fusen(Tag) menu 
Tag Editor
Color: BG:
Name:  Connect line ID:
 
MenuBar (UsersWiki)
ブックマーク
Please log in to use it.
[Login]
サイト内 Wiki
☆ 検索 ☆



高度な検索(サイト内)
FireFox検索プラグイン
オンライン状況
合計 65 人がオンライン中 :-)
(UsersWiki : 5 人)

登録ユーザ: 0 & ゲスト: 65

もっと...
サイト情報
管理人

nao-pon
 

登録ユーザ数: 2172


Web Services by Yahoo! JAPAN
楽天ウェブサービスセンター
Amazon.co.jpアソシエイト
現在ページのQRコード
現在ページのQRコード
[携帯対応]
参照元情報
No trackback