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
|
<?php /* * Declares example macros * * @package plugins * @subpackage development
*/ $plugin_is_filter = 5 | THEME_PLUGIN | ADMIN_PLUGIN; $plugin_description = gettext("Adds example macros."); $plugin_author = "Stephen Billard (sbillard)";
zp_register_filter('content_macro', 'exampleMacros::macro');
class exampleMacros {
static function macro($macros) { $my_macros = array( 'CODEBLOCK' => array('class' => 'procedure', 'params' => array('int'), 'value' => 'printCodeblock', 'owner' => 'exampleMacros', 'desc' => gettext('Places codeblock number <code>%1</code> in the content where the macro exists.')), 'PAGE' => array('class' => 'function', 'params' => array(), 'value' => 'getCurrentPage', 'owner' => 'exampleMacros', 'desc' => gettext('Prints the current page number.')), 'ZENPHOTO_VERSION' => array('class' => 'constant', 'params' => array(), 'value' => ZENPHOTO_VERSION, 'owner' => 'exampleMacros', 'desc' => gettext('Prints the version of the Zenphoto installation.')), 'CURRENT_SCRIPT' => array('class' => 'expression', 'params' => array(), 'value' => '"current script: ".stripSuffix($GLOBALS["_zp_gallery_page"]);', 'owner' => 'exampleMacros', 'desc' => gettext('An example of how to reference global variables. In this case to dump the current gallery page variable.')), 'PARAM_DUMP' => array('class' => 'procedure', 'params' => array('array'), 'value' => 'exampleMacros::arrayTest', 'owner' => 'exampleMacros', 'desc' => gettext('Dump the contents of the array parameter list. The array is in the form <em>variable_1</em>=<code>value</code> <em>variable_2</em>=<code>value</code> <em>etc.</em>.')), 'PAGELINK' => array('class' => 'function', 'params' => array('string', 'string'), 'value' => 'printCustomPageURL', 'owner' => 'exampleMacros', 'desc' => gettext('Provides text for a link to a "custom" script page indicated by a linktext (<code>%1</code>) and a custom page (<code>%2</code>).')) ); return array_merge($macros, $my_macros); }
static function arrayTest($params) { ?> <div> <?php echo gettext('The PARAM_DUMP macro was passed the following:'); ?> <ul> <?php foreach ($params as $key => $value) { echo '<li>' . $key . ' => ' . $value . '</li>'; } ?> </ul> </div> <?php }
} ?>
|