File: Registrylink.php

package info (click to toggle)
php-horde-wicked 2.0.1-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,528 kB
  • ctags: 1,236
  • sloc: php: 5,386; xml: 1,027; makefile: 10; sh: 3
file content (44 lines) | stat: -rw-r--r-- 1,387 bytes parent folder | download | duplicates (30)
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
<?php
/**
 * This parser parses Horde Registry links, which allow calling Horde
 * API "*"/show methods from within the page. Basic syntax is
 * [[link link title | link-app/link-method argname1=value1 argname2=value2 ...]].
 *
 * @package Wicked
 */
class Text_Wiki_Parse_Registrylink extends Text_Wiki_Parse
{
    /**
     * The regular expression used to find registry links.
     *
     * @access public
     *
     * @var string
     */
    public $regex = "/\[\[link (.*)\]\]/sU";

    /**
     * Generates a token entry for the matched text. Token options are:
     *
     * 'app'  => The application to link to.
     * 'args' => The parameters passed to the app/show method.
     *
     * @access public
     *
     * @param array &$matches  The array of matches from parse().
     *
     * @return  A delimited token number to be used as a placeholder in
     *          the source text.
     */
    public function process(&$matches)
    {
        @list($title, $call) = explode('|', $matches[1], 2);
        $opts = explode(' ', trim($call));
        $method = trim(array_shift($opts));
        parse_str(implode('&', $opts), $args);

        return $this->wiki->addToken($this->rule, array('title' => trim($title),
                                                        'method' => $method,
                                                        'args' => $args));
    }
}