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

TOP » xpwiki » calendar xpWiki開発日記/2006.11
Archives
2006
1 2 3 4 5 6 7 8 9 10 11 12
2007
1 2 3 4 5 6 7 8 9 10 11 12
2008
1 2 3 4 5 6 7 8 9 10 11 12
2009
1 2 3 4 5 6 7 8 9 10 11 12
2010
1 2 3 4 5 6 7 8 9 10 11 12
2011
1 2 3 4 5 6 7 8 9 10 11 12
2012
1 2 3 4 5 6 7 8 9 10 11 12
2013
1 2 3 4 5 6 7 8 9 10 11 12
2014
1 2 3 4 5 6 7 8 9 10 11 12
2017
1 2 3 4 5 6 7 8 9 10 11 12
<< 2006.11 >>
[xpWiki開発日記]
      1 2 4
5 6 9 10 11
12 14 15 16 17 18
20 21 22 23 25
26 27 30    
 

Ver 0.5.6-10 anchor.png Edit

Page Top

ページ保存時のイベントフック anchor.png Edit

ページ保存直前と直後に、独自の処理を挟み込めるようにしました。

  • trust側/events/onPageWriteBefore
  • trust側/events/onPageWriteAfter

ディレクトリにPHPファイルを置くことで、そのファイル内容の処理が実行されます。

基本的には、こんな感じ。

 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
<?php
/*
Custom event files are included in this directory.
You can use next variables here.
 
$this        : XpWiki Function object
$page        : page name
$postdata    : text data of page
$notimestamp : no change time stamp flag (TRUE or FALSE)
$mode        : Action mode (insert, update or delete)
 
**/
 
// Here is a sample code.
 
// This block always execute.
 
// Get plugin instance
$_plugin = & $this->get_plugin_instance('PLUGIN_NAME');
 
// exec plugin function with arguments.
$aryargs = array('hoge', 'hege');
$result  = call_user_func_array(array(& $_plugin, 'PLUGIN_FUNCTION_NAME'), $aryargs);
 
if ( $mode === 'insert' ) {
    // Only page create time.
 
} else if ( $mode === 'update' ) {
    // Only page update time.
 
} else if ( $mode === 'delete' ) {
    // Only page delete time.
 
}
 
unset ($_plugin);
?>

この機能を利用したプラグインが tag.inc.php です。 tag プラグインでは、ページ編集してtagプラグインの記述が削除された時とページ削除時に Tag の更新処理を行います。 その内容は、次の通りです。

filetag.inc.php
 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
//
// Created on 2006/10/31 by nao-pon http://hypweb.net/
// $Id: tag.inc.php,v 1.3 2006/11/02 15:59:29 nao-pon Exp $
//
if (file_exists($this->cont['CACHE_DIR'] . $this->encode($page) . '_page.tag')) {
    // ページのtagデータファイルがある場合
    
    // temp
    $_temparr = array();
    
    // tagプラグイン記述の存在チェック
    $_temparr['found'] = FALSE;
    $_temparr['ic'] = new XpWikiInlineConverter($this->xpwiki, array('plugin'));
    $_temparr['data'] = explode("\n",$postdata);
    while (! empty($_temparr['data'])) {
        
        $_temparr['line'] =  array_shift($_temparr['data']);
        
        // The first character
        $_temparr['head'] = $_temparr['line']{0};
        
        if (
            // Escape comments
            substr($_temparr['line'], 0, 2) === '//' ||
            // Horizontal Rule
            substr($_temparr['line'], 0, 4) === '----' ||
            // Pre
            $_temparr['head'] === ' ' || $_temparr['head'] === "\t"
        ) {    continue; }
 
        // Multiline-enabled block plugin
        if (!$this->cont['PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK'] && preg_match('/^#[^{]+(\{\{+)\s*$/', $_temparr['line'], $matches)) {
            $_temparr['len'] = strlen($matches[1]);
            while (! empty ($_temparr['data'])) {
                $_temparr['$next_line'] = preg_replace("/[\r\n]*$/", '', array_shift($_temparr['data']));
                if (preg_match('/\}{'.$_temparr['len'].'}/', $_temparr['$next_line'])) { break; }
            }
        }
        
        // ちょっと重いけどしっかりチェック版
        $_temparr['arr'] = $_temparr['ic']->get_objects($_temparr['line'], $page);
        while( ! empty($_temparr['arr']) ) {
            $_temparr['obj'] = array_shift($_temparr['arr']);
            if ( $_temparr['obj']->name === 'tag' ) {
                $_temparr['found'] = TRUE;
                break 2;
            }
        }
        
        /*
        // ちょっと手抜きの軽量版
        if (preg_match("/&tag\([\^)]*\)(\{.*?\})?;/",$_temparr['line'])) {
            $_temparr['found'] = TRUE;
            break;
        }
        */
        
    }
    
    if ($mode === 'delete' || ($mode === 'update' && $_temparr['found'] === FALSE)) {
        // ページ削除または&tag();を削除した場合
        $_temparr['plugin'] =& $this->get_plugin_instance('tag');
        if ($_temparr['plugin'] !== FALSE) {
            $aryargs = array($page, array());
            call_user_func_array(array($this->root->plugin_tag, 'renew_tagcache'), $aryargs);
        }
    } else if ($mode === 'update' && $notimestamp) {
        // ページ編集でページタイムスタンプを保持する場合
        $this->pkwk_touch_file($this->cont['CACHE_DIR'] . $this->encode($page) . '_page.tag',1);
    }
    unset($_temparr);
}
?>
Page Top

XOOPS のグローバル検索に対応 anchor.png Edit

XOOPS のグローバル検索に対応するとともに、XOOPS検索モジュールにも対応しました。

Page Top

Ver 0.5.11 anchor.png Edit

pukiwiki.ini.php に設定項目を追加しました。

ページキャッシュ関連の設定項目です。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
/////////////////////////////////////////////////
// ページキャッシュの設定 (ゲストアクセス時のみ)
// ページキャッシュを最長何分間するか?
$root->pagecache_min = 0;
 
// ページ更新時常にページキャッシュを破棄するページ
$root->always_clear_cache_pages = array (
    //$root->defaultpage,
    $root->menubar,
);
 
// 上位層のページもキャッシュをクリアする
$root->clear_cache_parent = TRUE; // (TRUE or FASLE)
Page Top

コメント anchor.png Edit



 

Ver 0.5.11-14 anchor.png Edit

Page Top

ini設定追加 anchor.png Edit

  • pukiwiki.ini.php
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    
    /////////////////////////////////////////////////
    // ページキャッシュの設定 (ゲストアクセス時のみ)
    // ページキャッシュを最長何分間するか?
    $root->pagecache_min = 0;
     
    // ページ更新時常にページキャッシュを破棄するページ
    $root->always_clear_cache_pages = array (
        //$root->defaultpage,
        $root->menubar,
    );
     
    // 上位層のページもキャッシュをクリアする
    $root->clear_cache_parent = TRUE; // (TRUE or FASLE)
Page Top

XOOPS管理画面でページを表示 anchor.png Edit

XOOPSの管理画面にWikiページを表示する仕組みを追加しました。

ページ内容に

#xoopsadmin

と記述するか、もしくはアクションプラグイン動作時に管理画面内に表示するようにするには、plugin_*_init() 関数内で

1
2
3
4
// 管理画面モード指定
if ($this->root->module['platform'] == "xoops") {
    $this->root->runmode = "xoops_admin";
}

と記述してください。

Page Top

プラグインオブジェクトに msg メンバーを追加 anchor.png Edit

プラグイン独自の言語ファイル読み込みの仕組みを追加しました。

lang/plugin/プラグイン名.言語コード.php に $msg 配列を書いて、plugin_*_init() 関数内に、

1
2
// 言語ファイルの読み込み
$this->load_language();

と命令文を書くとプラグインオブジェクト->msg に格納されます。

html側にあれば、trust側を上書きします。

例えば、dump プラグインの言語ファイルは、次のようになっています。

filedump.ja.php
 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
<?php
//
// Created on 2006/11/06 by nao-pon http://hypweb.net/
// $Id: dump.ja.php,v 1.1 2006/11/07 00:05:50 nao-pon Exp $
//
$msg = array(
'upload_ok'        => 'アップロードが完了しました',
'upload_ng'        => 'アップロードに失敗しました',
'maketmp_ng'       => 'テンポラリファイルの生成に失敗しました。',
'file_notfound'    => 'ファイルがみつかりませんでした。',
'tarfile_notfound' => '展開できるファイルがありませんでした。',
'filelist'         => '展開したファイル一覧',
'data_download'    => 'データのダウンロード',
'file'             => 'ファイル:',
'tar_type'         => 'アーカイブの形式',
'tar.gz'           => '~.tar.gz 形式',
'tar'              => '~.tar 形式',
'backup_dir'       => 'バックアップディレクトリ',
'option'           => 'オプション',
'decode_pagename'  => 'エンコードされているページ名をディレクトリ階層つきのファイルにデコード
  (※リストアに使うことはできなくなります。また、一部の文字は \'_\' に置換されます',
'admin_pass'       => '管理者パスワード',
'password_ng'      => 'パスワードが違います。',
'data_restore'     => 'データのリストア (*.tar, *.tar.gz)',
'data_overwrite'   => '[警告] 同じ名前のデータファイルは上書きされますので、十分ご注意ください。',
'max_filesize'     => 'アップロード可能な最大ファイルサイズは、$maxsize KByte までです。'
);
?>
filedump.en.php
 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
<?php
//
// Created on 2006/11/06 by nao-pon http://hypweb.net/
// $Id: dump.en.php,v 1.1 2006/11/07 00:05:50 nao-pon Exp $
//
$msg = array(
'upload_ok'        => 'Upload was completed.',
'upload_ng'        => 'Failed in upload.',
'maketmp_ng'       => 'Failed in generation of temporaty file.',
'file_notfound'    => 'A file was not found.',
'tarfile_notfound' => 'There was not the file which could untar.',
'filelist'         => 'Untared file list',
'data_download'    => 'A download of data.',
'file'             => 'File:',
'tar_type'         => 'Archive type',
'tar.gz'           => '*.tar.gz',
'tar'              => '*.tar',
'backup_dir'       => 'Backup directorys',
'option'           => 'Option',
'decode_pagename'  => 'Do decode page name with directory path.
 (You can not use restore, and Some character are replaced to \'_\'.)',
'admin_pass'       => 'Admin pass',
'password_ng'      => 'Password is different.',
'data_restore'     => 'Restore data (*.tar, *.tar.gz)',
'data_overwrite'   => '[Warning] It is overwritten, please warn a data file of the same name enough.',
'max_filesize'     => 'Maximum file size is $maxsize KByte.'
);
?>
Page Top

プラグインの整備 anchor.png Edit

xpWiki 用にプラグインを整備しました。

  • versionlist
  • dump
  • rename
  • links
Page Top

onInstall, onUpdate 時の整備 anchor.png Edit

html側に必要な、wiki/*.txt, cache/*.dat をCVSに入れ忘れていました。(爆)

いい機会だったので、モジュールインストール・アップデート時にチェックして、足らないファイルがあった場合、trust側からhtml側にコピーするようにしました。

Page Top

コメント anchor.png Edit


Page Top

/ anchor.png Edit


 

ページ情報のDB化に取り掛かります anchor.png Edit

いよいよ、ページ情報のデータベース化に取り掛かります。

とりあえず、考えたテーブル構造は次の通りです。

filemysql.sql
Everything is expanded.Everything is shortened.
 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
 
-
|
|
|
|
|
|
|
!
 
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
 
-
|
|
|
!
 
-
|
|
|
|
!
 
-
|
|
|
|
|
|
|
|
|
|
!
CREATE TABLE `attach` (
  `id` int(11) NOT NULL auto_increment,
  `pgid` int(11) NOT NULL default '0',
  `name` varchar(255) binary NOT NULL default '',
  `type` varchar(255) NOT NULL default '',
  `mtime` int(11) NOT NULL default '0',
  `size` int(11) NOT NULL default '0',
  `mode` varchar(20) NOT NULL default '',
  `count` int(11) NOT NULL default '0',
  `age` tinyint(4) NOT NULL default '0',
  `pass` varchar(16) binary NOT NULL default '',
  `freeze` tinyint(1) NOT NULL default '0',
  `copyright` tinyint(1) NOT NULL default '0',
  `owner` int(11) NOT NULL default '0',
  UNIQUE KEY `id` (`id`),
  KEY `pgid` (`pgid`),
  KEY `owner` (`owner`)
) TYPE=MyISAM;
 
CREATE TABLE `count` (
  `pgid` int(11) NOT NULL default '0',
  `count` int(11) NOT NULL default '0',
  `today` varchar(10) NOT NULL default '',
  `today_count` int(11) NOT NULL default '0',
  `yesterday_count` int(11) NOT NULL default '0',
  `ip` varchar(15) NOT NULL default '',
  PRIMARY KEY  (`pgid`)
) TYPE=MyISAM;
 
CREATE TABLE `pginfo` (
  `pgid` int(11) NOT NULL auto_increment,
  `name` varchar(255) binary NOT NULL default '',
  `title` varchar(255) NOT NULL default '',
  `buildtime` int(11) NOT NULL default '0',
  `editedtime` int(11) NOT NULL default '0',
  `uid` mediumint(8) NOT NULL default '0',
  `ucd` varchar(12) NOT NULL default '',
  `username` varchar(255) NOT NULL default '',
  `freeze` tinyint(1) NOT NULL default '0',
  `aids` text NOT NULL,
  `gids` varchar(255) NOT NULL default '',
  `vaids` text NOT NULL,
  `vgids` varchar(255) NOT NULL default '',
  `lastediter_uid` mediumint(8) NOT NULL default '0',
  `lastediter_ucd` varchar(12) NOT NULL default '',
  `lastediter_name` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`pgid`),
  UNIQUE KEY `name` (`name`),
  KEY `uid` (`uid`)
) TYPE=MyISAM;
 
CREATE TABLE `plain` (
  `pgid` int(11) NOT NULL default '0',
  `plain` text NOT NULL,
  PRIMARY KEY  (`pgid`)
) TYPE=MyISAM;
 
CREATE TABLE `rel` (
  `pgid` int(11) NOT NULL default '0',
  `relid` int(11) NOT NULL default '0',
  KEY `pgid` (`pgid`),
  KEY `relid` (`relid`)
) TYPE=MyISAM;
 
CREATE TABLE `tb` (
  `tbid` varchar(32) NOT NULL default '',
  `pgid` int(11) NOT NULL default '0',
  `last_time` int(11) NOT NULL default '0',
  `url` text NOT NULL,
  `title` varchar(255) NOT NULL default '',
  `excerpt` text NOT NULL,
  `blog_name` varchar(255) NOT NULL default '',
  `ip` varchar(15) NOT NULL default '',
  KEY `tbid` (`tbid`),
  KEY `pgid` (`pgid`)
) TYPE=MyISAM;
Page Top

コメント anchor.png Edit



 

Ver 0.6.0 html側更新 & 権限設定 anchor.png Edit

Page Top

html側更新 anchor.png Edit

  • xoops_uname.php
    • 権限設定にてユーザーIDのサジェストに使用するスクリプト(ローダー)です。
Page Top

権限設定 anchor.png Edit

#refx(pginfo.png,around,right) DB対応に先がけて、ページ毎の権限設定を実装しました。PukiWikiMod では、ページ編集画面に権限設定フォームを付けていましたが、xpWiki では、別画面にしました。

管理者およびページ作成ユーザーにはメニューに「権限」が表示されるので、それをクリックすることで権限編集画面に移動します。

ユーザー名の選択には、リストボックスではユーザーが増えたときに実用的ではないので、JavaScript を使った「サジェスト」方式にしました。

また、下位ページへの権限継承を「強制」「規定値」「なし」から選べるようにしました。「強制」は、下位ページで変更させない継承。「規定値」は下位ページに継承するが変更可能、「なし」は継承なし、そのページのみの設定となります。

Page Top

pukiwiki.ini.php 設定値追加 anchor.png Edit

権限設定のサイト規定値を pukiwiki.ini.php に追加しました。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
/////////////////////////////////////////////////
// ページ情報のサイト規定値
// inherit = 0:継承指定なし, 1:規定値継承指定, 2:強制継承指定
//           3:規定値継承した値, 4:強制継承した値
$root->pginfo = array(
    'uid'       => 0,     // UserID
    'ucd'       => '',    // UserCode(by cookie)
    'uname'     => '',    // UserName(by cookie)
    'einherit'  => 3,     // Edit Inherit
    'eaids'     => 'all', // Editable users
    'egids'     => 'all', // Editable groups
    'vinherit'  => 3,     // View Inherit
    'vaids'     => 'all', // Viewable users
    'vgids'     => 'all', // Viewable groups
    'lastuid'   => 0,     // Last editer's uid
    'lastucd'   => '',    // Last editer's ucd(by cookie)
    'lastuname' => '',    // Last editer's name(by cookie)
);
Page Top

コメント anchor.png Edit



 
Tag: DB化

Ver 0.6.4 (ページ情報のDB化) anchor.png Edit

ページ情報のDB化の基本部分がおおよそ完了しました。

これにより、ページ数増加によるパフォーマンスダウンがファイルベースよりは抑えられると思います。 また、ページを一覧する場面では、閲覧権限のないページは省かれて表示されます。

データーベーステーブルの環境を整えるためモジュールアップデートを行い、管理画面の「管理ツール一覧」より「データベースシンクロ」を必ず実行してください。 :)

あと、残っている作業としては、プラグインおよび検索のDB化対応です。

Page Top

コメント anchor.png Edit

  • あ!添付ファイルの部分を忘れてました。attach.inc.php を第一優先で行います。 :p -- nao-pon 2006-11-20 (日) 08:52:06


 

Ver 0.7.0 anchor.png Edit

Page Top

html側 anchor.png Edit

  • 更新分
  • 追加分
    • include/hyp_common/get_execpath.cgi
    • include/hyp_common/image_magick.cgi
Page Top

trust側 anchor.png Edit

Page Top
trust/class/hyp_common anchor.png Edit

サムネイルの作成などに HypCommonFunc を使うので、trust/class に hyp_common ディレクトリ以下を置いてください。

  • ディレクトリ構造
    xoops_trust
           ├ class
           │   └ hyp_common
           └ modules
                └ xpwiki
Page Top
attach, ref プラグイン整備 anchor.png Edit

DB化に伴ない、attach と ref プラグインの整備しました。

  • attach は PukiWikiMod の attach プラグインを元にしました。
  • ref プラグインは、作り直しました。PukiWiki 1.4 付属の ref, PukiWikiMod 付属の ref と互換性があります。

ref プラグインには、attachref プラグインの動作も一部取り入れています。#ref() とか &ref(); とすると、こんな ⇒ 添付[添付] 添付リンクが表示されます。そこをクリックしてファイル添付するとその場所に添付ファイルが表示されます。(このリンクは表示サンプルなので添付しないでね。)

引数を指定したい場合は &ref(,100x100,zoom); こんな風に引数の先頭にカンマをひとつ置いてください。

Page Top

添付テスト用 anchor.png Edit


Page Top

コメント anchor.png Edit



 

Ver 0.7.1 - 3 (主にDB化対応) anchor.png Edit

DB化対応を順次進めています。

  • とりあえず完了分
    • 指定ページ以下を抽出する動作をDB版へ移行。(プラグインも含む)
    • XOOPS グローバル検索を DB版へ移行。(Extension 機構を利用)
Page Top

その他 anchor.png Edit

  • 細かい部分での表示調整、バグ取りなど。
Page Top

コメント anchor.png Edit



 

Ver 0.7.4 (ページ名読みをDBに格納) anchor.png Edit

ページ名の読みを、pginfo DB に格納するようにしました。

DBフィールドを追加したのでモジュールアップデートを実行してください。

オリジナルの PukiWiki は、1つのWikiページにすべてのページの読みを保存するようになっているのですが、これだと、ページ数が増えた時のパフォーマンス低下が避けられないことと、メンテナンス性に問題があるので、DBに格納するようにしました。

さらに、ページ名読み ⇒ ページ頭文字読み に変更しました。

例えば「メモ/色々/下書き」というページ名の場合「メ/イ/シ」となります。

一覧で日本語ページの読みを反映したい場合は、pukiwiki.ini.php での以下の設定項目を適切に設定してください。ただし「$root->pagereading_config_page」は、意味を持ちません。

 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
/////////////////////////////////////////////////
// Page-reading feature settings
// (Automatically creating pronounce datas, for Kanji-included page names,
//  to show sorted page-list correctly)
 
// Enable page-reading feature by calling ChaSen or KAKASHI command
// (1:Enable, 0:Disable)
$root->pagereading_enable = 0;
 
// Specify converter as ChaSen('chasen') or KAKASI('kakasi') or None('none')
$root->pagereading_kanji2kana_converter = 'none';
 
// Specify Kanji encoding to pass data between PukiWiki and the converter
$root->pagereading_kanji2kana_encoding = 'EUC'; // Default for Unix
//$root->pagereading_kanji2kana_encoding = 'SJIS'; // Default for Windows
 
// Absolute path of the converter (ChaSen)
$root->pagereading_chasen_path = '/usr/local/bin/chasen';
//$root->pagereading_chasen_path = 'c:\progra~1\chasen21\chasen.exe';
 
// Absolute path of the converter (KAKASI)
$root->pagereading_kakasi_path = '/usr/local/bin/kakasi';
//$root->pagereading_kakasi_path = 'c:\kakasi\bin\kakasi.exe';
 
// Page name contains pronounce data (written by the converter)
$root->pagereading_config_page = ':config​/PageReading';
 
// Page name of default pronouncing dictionary, used when converter = 'none'
$root->pagereading_config_dict = ':config​/PageReading​/dict';
Page Top

コメント anchor.png Edit




トップ 印刷に適した表示   ページ新規作成 全ページ一覧 単語検索 最新ページの一覧   ヘルプ   最新ページのRSS 1.0 最新ページのRSS 2.0 最新ページのRSS Atom Powered by xpWiki
このページのTopへ
メインメニュー
ログイン

ユーザー名:


パスワード:





パスワード紛失  |新規登録
オンライン状況
526 人のユーザが現在オンラインです。 (8 人のユーザが xpwiki を参照しています。)

登録ユーザ: 0
ゲスト: 526

もっと...
サイト情報