xref: /plugin/strata/types/title.php (revision 18f9272a602e4ce337cb918e4a294e94553ca15b)
1*18f9272aSFKaag<?php
2*18f9272aSFKaag/**
3*18f9272aSFKaag * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
4*18f9272aSFKaag * @author     Brend Wanders <b.wanders@utwente.nl>
5*18f9272aSFKaag */
6*18f9272aSFKaag// must be run within Dokuwiki
7*18f9272aSFKaagif(!defined('DOKU_INC')) die('Meh.');
8*18f9272aSFKaag
9*18f9272aSFKaag/**
10*18f9272aSFKaag * The reference link type.
11*18f9272aSFKaag */
12*18f9272aSFKaagclass plugin_strata_type_title extends plugin_strata_type_page {
13*18f9272aSFKaag    function __construct() {
14*18f9272aSFKaag        $this->util =& plugin_load('helper', 'strata_util');
15*18f9272aSFKaag        parent::__construct();
16*18f9272aSFKaag    }
17*18f9272aSFKaag
18*18f9272aSFKaag    function render($mode, &$R, &$T, $value, $hint='') {
19*18f9272aSFKaag        $heading = "missing";
20*18f9272aSFKaag
21*18f9272aSFKaag        $titles = $T->fetchTriples($value, $this->util->getTitleKey());
22*18f9272aSFKaag        if($titles) {
23*18f9272aSFKaag            $heading = $titles[0]['object'];
24*18f9272aSFKaag         }
25*18f9272aSFKaag
26*18f9272aSFKaag        // render internal link
27*18f9272aSFKaag        // (':' is prepended to make sure we use an absolute pagename,
28*18f9272aSFKaag        // internallink resolves page names, but the name is already resolved.)
29*18f9272aSFKaag        $R->internallink($hint.':'.$value, $heading);
30*18f9272aSFKaag    }
31*18f9272aSFKaag
32*18f9272aSFKaag    function getInfo() {
33*18f9272aSFKaag        return array(
34*18f9272aSFKaag            'desc'=>'References another piece of data or wiki page, and creates a link named after the title of the page. The optional hint is used as namespace for the link. If the hint ends with a #, all values will be treated as fragments.',
35*18f9272aSFKaag            'hint'=>'namespace'
36*18f9272aSFKaag        );
37*18f9272aSFKaag    }
38*18f9272aSFKaag}
39