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

08年8月21日(Thu) 0時46分
TOP » xpWiki::Dev » xpWiki開発日記 » 2006-11-03

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)

Post a new comment

Subject
guestname   :
Body
Go to richer form

Comments list


Front page   Edit Freeze Diff Backup Upload Copy Rename Reload   New List of pages Search Recent changes   Help   RSS of recent changes (RSS 1.0) RSS of recent changes (RSS 2.0) RSS of recent changes (RSS Atom)
Counter: 1566, today: 1, yesterday: 1
Last-modified: 2006-11-15 (Wed) 16:50:25 (JST) (644d) by nao-pon
このページのTopへ
ログイン
ユーザ名:

パスワード:

オートログイン

Basic 認証

Register now! | Lost Password?

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



高度な検索(サイト内)
FireFox検索プラグイン
オンライン状況
合計 91 人がオンライン中 :-)
(xpWiki::Dev : 1 人)

登録ユーザ: 1 & ゲスト: 90

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

nao-pon
 

登録ユーザ数: 1394


現在ページのQRコード 
現在ページのQRコード
[携帯対応]
参照元情報