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

TOP » xpwiki » xpWiki開発日記 » 2006-11-03

2006 11月 3 (金)
 

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




トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード印刷に適した表示   ページ新規作成 全ページ一覧 単語検索 最新ページの一覧   ヘルプ   最新ページのRSS 1.0 最新ページのRSS 2.0 最新ページのRSS Atom Powered by xpWiki
Counter: 181, today: 1, yesterday: 1
初版日時: 2006-11-03 (金) 01:01:16
最終更新: 2006-11-15 (水) 16:50:25 (JST) (6362d) by nao-pon
このページのTopへ
メインメニュー
ログイン

ユーザー名:


パスワード:





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

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

もっと...
サイト情報