ページへ戻る

+ Links

 印刷 

Ver 3.50 (外部(d3pipesなど)から利用できる関数群を追加) :: XOOPS マニア

xpwiki:xpWiki開発日記/2007-12-20


Tag: XOOPS ブロック d3pipes RSS
2007 12月 20 (木)
 

Ver 3.50 (外部(d3pipesなど)から利用できる関数群を追加) anchor.png Edit

XOOPSのブロックや他のモジュールから簡単に呼び出せる関数群を追加しました。

とはいっても、今回は実質 "xpwiki_saf_getRecentPages_base()" のみですが・・・。

また、ついでに RSS 関連で調整を行いました。

とりあえず、d3pipes の「サイト内新着情報パイプ作成ウイザード」などで使用できる、内部情報取得用ジョイントを作って見ました。

次の fileD3pipesBlockXpwikipages.class.php を XOOPS_TRUST_PATH/modules/d3pipes/joints/block ディレクトリに放り込むと、サイト内新着情報パイプ作成ウイザードで xpWiki が設定できるようになります。


※ xpWiki Ver 3.51 以降では、D3pipesBlockXpwikipages.class.php は単なるラッパーにできますので、もっと簡潔になりました。
-> Ver 3.51 (d3pipes 用プラグイン追加)

fileD3pipesBlockXpwikipages.class.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
75
76
77
78
79
80
<?php
 
require_once dirname(dirname(__FILE__)).'/D3pipesBlockAbstract.class.php' ;
 
class D3pipesBlockXpwikipages extends D3pipesBlockAbstract {
 
    var $target_dirname = '' ;
    var $trustdirname = 'xpwiki' ;
 
    function init()
    {
        // parse and check option for this class
        $params = array_map( 'trim' , explode( '|' , $this->option ) ) ;
        if( empty( $params[0] ) ) {
            $this->errors[] = _MD_D3PIPES_ERR_INVALIDDIRNAMEINBLOCK."\n($this->pipe_id)" ;
            return false ;
        }
        $this->target_dirname = preg_replace( '/[^0-9a-zA-Z_-]/' , '' , $params[0] ) ;
 
        // configurations (file, name, block_options)
        $this->func_file = XOOPS_TRUST_PATH.'/modules/'.$this->trustdirname.'/include/stand_alone_functions.php' ;
        $this->func_name = 'xpwiki_saf_getRecentPages_base' ;
        
        $as_guest = (@ $params[3] === 'No')? false : true;
        $this->block_options = array(
            0 => $this->target_dirname , // mydirname
            1 => strval(@ $params[1]) ,  // base page
            2 => empty( $params[2] ) ? 10 : intval( $params[2] ) , // max_entries
            'as_guest' => $as_guest ,    // Get as guest always
        ) ;
 
        return true ;
    }
 
    function reassign( $data )
    {
        $entries = array() ;
        foreach( $data['entries'] as $entry ) {
            $entry['fingerprint'] = $entry['link'] ;
            $entries[] = $entry ;
        }
 
        return $entries ;
    }
 
    function renderOptions( $index , $current_value = null )
    {
        $index = intval( $index ) ;
        $options = explode( '|' , $current_value ) ;
 
        // options[0]  (dirname)
        $dirnames = $this->getValidDirnames() ;
        $ret_0 = '<select name="joint_options['.$index.'][0]">' ;
        foreach( $dirnames as $dirname ) {
            $ret_0 .= '<option value="'.$dirname.'" '.($dirname==@$options[0]?'selected="selected"':'').'>'.$dirname.'</option>' ;
        }
        $ret_0 .= '</select>' ;
 
        // options[1]  (base page)
        $options[1] = preg_replace( '/[^0-9a-zA-Z_-]/' , '' , @$options[1] ) ;
        $ret_1 = 'Base page'.'<input type="text" name="joint_options['.$index.'][1]" value="'.$options[1].'" size="15" />' ;
 
        // options[2]  (max_entries)
        $options[2] = empty( $options[2] ) ? 10 : intval( $options[2] ) ;
        $ret_2 = _MD_D3PIPES_N4J_MAXENTRIES.'<input type="text" name="joint_options['.$index.'][2]" value="'.$options[2].'" size="2" style="text-align:right;" />' ;
 
        // options[3]  (Get as guest?)
        $options[3] = ( @$options[3] === 'No' ) ? 'No' : 'Yes' ;
        $ret_3 = 'Get as guest always?'.'<select name="joint_options['.$index.'][3]">' ;
        foreach( array('Yes', 'No') as $name ) {
            $ret_3 .= '<option value="'.$name.'" '.($name === $options[3]?'selected="selected"':'').'>'.$name.'</option>' ;
        }
        $ret_3 .= '</select>' . '(Never cache it when you select "No".)';
        
        return '<input type="hidden" name="joint_option['.$index.']" id="joint_option_'.$index.'" value="" />'.$ret_0.' '.$ret_1.' '.$ret_2.'<br />'.$ret_3 ;
    }
 
}
 
?>
Page Top

CVS 更新内容 anchor.png Edit

  • 2007-12-20 18:38 nao-pon
    • * xoops_version.php (1.262):
      • Version 3.50
  • 2007-12-20 17:09 nao-pon
    • * include/stand_alone_functions.php (1.1):
      • Stand alone functions, this is called from the outside.
  • 2007-12-20 16:25 nao-pon
    • * class/: func/xpwiki_func.php (1.128), xpwiki.php (1.62), extension/whatsnew.php (1.13):
      • Function rename 'get_page_count' to 'get_page_views'.
  • 2007-12-20 16:23 nao-pon
    • * plugin/rss.inc.php (1.22):
      • Changed to use from $userinfo to $pginfo.
  • 2007-12-20 14:54 nao-pon
    • * plugin/rss.inc.php (1.21):
      • The entity reference value in discription is not removed.
Page Top

一行コメント anchor.png Edit




Last-modified: 2007-12-21 (金) 18:00:49 (JST) (6914d) by nao-pon