1 | <?php |
||
13 | class Autotoc extends DataExtension |
||
14 | { |
||
15 | /** |
||
16 | * @config |
||
17 | * Callable to be used for augmenting a DOMElement: specify as a |
||
18 | * string in the format "class::method". `Tocifier::prependAnchor` |
||
19 | * and `Tocifier::setId` are two valid callbacks. |
||
20 | */ |
||
21 | private static $augment_callback; |
||
|
|||
22 | |||
23 | protected static $tocifiers; |
||
24 | |||
25 | |||
26 | /** |
||
27 | * Initialize the Autotoc extension. |
||
28 | * |
||
29 | * Creates an internal SplObjectStorage where caching the table of |
||
30 | * contents. |
||
31 | */ |
||
32 | 5 | public function __construct() |
|
39 | |||
40 | 2 | private static function convertNode($node) |
|
53 | |||
54 | 2 | private static function convertChildren($children) |
|
64 | |||
65 | /** |
||
66 | * Get the field name to be used as content. |
||
67 | * @return string |
||
68 | */ |
||
69 | 5 | private function contentField() |
|
74 | |||
75 | /** |
||
76 | * Provide content_field customization on a class basis. |
||
77 | * |
||
78 | * Override the default setOwner() method so, when valorized, I can |
||
79 | * enhance the (possibly custom) content field with anchors. I did |
||
80 | * not find a better way to override a field other than directly |
||
81 | * substituting it with setField(). |
||
82 | * |
||
83 | * @param Object $owner |
||
84 | */ |
||
85 | 5 | public function setOwner($owner) |
|
98 | |||
99 | /** |
||
100 | * Return the internal Tocifier instance bound to $owner. |
||
101 | * |
||
102 | * If not present, try to create and execute a new one. On failure |
||
103 | * (e.g. because of malformed content) no further attempts will be |
||
104 | * made. |
||
105 | * |
||
106 | * @param \SilverStripe\ORM\DataObject $owner |
||
107 | * @return Tocifier|false|null |
||
108 | */ |
||
109 | 3 | private static function getTocifier($owner) |
|
133 | |||
134 | /** |
||
135 | * Clear the internal Autotoc cache. |
||
136 | * |
||
137 | * The TOC is usually cached the first time you call (directly or |
||
138 | * indirectly) getAutotoc() or getContentField(). This method allows |
||
139 | * to clear the internal cache to force a recomputation. |
||
140 | */ |
||
141 | 2 | public function clearAutotoc() |
|
145 | |||
146 | /** |
||
147 | * Get the automatically generated table of contents. |
||
148 | * @return ArrayData|null |
||
149 | */ |
||
150 | 2 | public function getAutotoc() |
|
166 | |||
167 | /** |
||
168 | * Get the non-augmented content field. |
||
169 | * @return string |
||
170 | */ |
||
171 | 4 | public function getOriginalContentField() |
|
188 | |||
189 | /** |
||
190 | * Get the augmented content field. |
||
191 | * @return string |
||
192 | */ |
||
193 | 3 | public function getContentField() |
|
202 | |||
203 | /** |
||
204 | * I don't remember what the hell is this... |
||
205 | * @return string |
||
206 | */ |
||
207 | 1 | public function getBodyAutotoc() |
|
211 | } |
||
212 |
This check marks private properties in classes that are never used. Those properties can be removed.