1
|
<?php
|
2
|
/**
|
3
|
* @file
|
4
|
* Singleton class to provide render hints.
|
5
|
*
|
6
|
* @copyright
|
7
|
* (C) 2007-2012 EDIT
|
8
|
* European Distributed Institute of Taxonomy
|
9
|
* http://www.e-taxonomy.eu
|
10
|
*
|
11
|
* The contents of this module are subject to the Mozilla
|
12
|
* Public License Version 1.1.
|
13
|
* @see http://www.mozilla.org/MPL/MPL-1.1.html
|
14
|
*/
|
15
|
|
16
|
/**
|
17
|
* A Singleton class wich holds and manages information on the render path in the
|
18
|
* page element hierarchy and also stored the current FootnoteListKey.
|
19
|
*
|
20
|
* RenderPath:
|
21
|
* The render path is manages as a stack.
|
22
|
* Usually you will push a new element to this stack at the begining of a theme
|
23
|
* method: RenderHints::pushToRenderStack('mypageElement');
|
24
|
* After the output is generated you again pop the current path element from the stack:
|
25
|
* RenderHints::popFromRenderStack()
|
26
|
* The current render path can be retrieved by @see getRenderPath().
|
27
|
*
|
28
|
* FootnoteListKey
|
29
|
*
|
30
|
*/
|
31
|
class RenderHints {
|
32
|
private static $renderStack = array();
|
33
|
private static $footnoteListKey = FALSE;
|
34
|
|
35
|
/**
|
36
|
* Private constructor.
|
37
|
*/
|
38
|
private function __construct() {}
|
39
|
|
40
|
/**
|
41
|
* @todo document this function.
|
42
|
*/
|
43
|
public static function getFootnoteListKey() {
|
44
|
return self::$footnoteListKey;
|
45
|
}
|
46
|
|
47
|
/**
|
48
|
* @todo document this function.
|
49
|
*/
|
50
|
public static function setFootnoteListKey($key) {
|
51
|
self::$footnoteListKey = $key;
|
52
|
}
|
53
|
|
54
|
/**
|
55
|
* @todo document this function.
|
56
|
*/
|
57
|
public static function clearFootnoteListKey() {
|
58
|
self::$footnoteListKey = FALSE;
|
59
|
}
|
60
|
|
61
|
/**
|
62
|
* @todo document this function.
|
63
|
*/
|
64
|
public static function pushToRenderStack($pathelement) {
|
65
|
array_push(self::$renderStack, $pathelement);
|
66
|
}
|
67
|
|
68
|
/**
|
69
|
* @todo document this function.
|
70
|
*/
|
71
|
public static function popFromRenderStack() {
|
72
|
return array_pop(self::$renderStack);
|
73
|
}
|
74
|
|
75
|
/**
|
76
|
* @todo document this function.
|
77
|
*/
|
78
|
public static function sizeof() {
|
79
|
return sizeof(self::$renderStack);
|
80
|
}
|
81
|
|
82
|
/**
|
83
|
* @todo document this function.
|
84
|
*/
|
85
|
public static function getRenderPath() {
|
86
|
return join('.', array_reverse(self::$renderStack));
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
* @todo document this function.
|
91
|
*/
|
92
|
public static function getHtmlElementID($cdmBase) {
|
93
|
return 'id="' . RenderHints::getRenderPath() . '(' . $cdmBase->class . ':' . $cdmBase->uuid . ')"';
|
94
|
}
|
95
|
|
96
|
/**
|
97
|
* Stop users from cloning.
|
98
|
*/
|
99
|
public function __clone() {
|
100
|
trigger_error('Cloning instances of the singleton class RenderHints is prohibited', E_USER_ERROR);
|
101
|
}
|
102
|
}
|