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 = .'/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 ;
}
}
?>
|