1: <?php
2: 3: 4: 5: 6: 7: 8:
9: $plugin_is_filter = 5 | THEME_PLUGIN | ADMIN_PLUGIN;
10: $plugin_description = gettext("Adds example macros.");
11: $plugin_author = "Stephen Billard (sbillard)";
12:
13: zp_register_filter('content_macro', 'exampleMacros::macro');
14:
15: class exampleMacros {
16:
17: static function macro($macros) {
18: $my_macros = array(
19: 'CODEBLOCK' => array('class' => 'procedure',
20: 'params' => array('int'),
21: 'value' => 'printCodeblock',
22: 'owner' => 'exampleMacros',
23: 'desc' => gettext('Places codeblock number <code>%1</code> in the content where the macro exists.')),
24: 'PAGE' => array('class' => 'function',
25: 'params' => array(),
26: 'value' => 'getCurrentPage',
27: 'owner' => 'exampleMacros',
28: 'desc' => gettext('Prints the current page number.')),
29: 'ZENPHOTO_VERSION' => array('class' => 'constant',
30: 'params' => array(),
31: 'value' => ZENPHOTO_VERSION,
32: 'owner' => 'exampleMacros',
33: 'desc' => gettext('Prints the version of the Zenphoto installation.')),
34: 'CURRENT_SCRIPT' => array('class' => 'expression',
35: 'params' => array(),
36: 'value' => '"current script: ".stripSuffix($GLOBALS["_zp_gallery_page"]);',
37: 'owner' => 'exampleMacros',
38: 'desc' => gettext('An example of how to reference global variables. In this case to dump the current gallery page variable.')),
39: 'PARAM_DUMP' => array('class' => 'procedure',
40: 'params' => array('array'),
41: 'value' => 'exampleMacros::arrayTest',
42: 'owner' => 'exampleMacros',
43: '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>.')),
44: 'PAGELINK' => array('class' => 'function',
45: 'params' => array('string', 'string'),
46: 'value' => 'printCustomPageURL',
47: 'owner' => 'exampleMacros',
48: '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>).'))
49: );
50: return array_merge($macros, $my_macros);
51: }
52:
53: static function arrayTest($params) {
54: ?>
55: <div>
56: <?php
57: echo gettext('The PARAM_DUMP macro was passed the following:');
58: ?>
59: <ul>
60: <?php
61: foreach ($params as $key => $value) {
62: echo '<li>' . $key . ' => ' . $value . '</li>';
63: }
64: ?>
65: </ul>
66: </div>
67: <?php
68: }
69:
70: }
71: ?>
72: