1 | <?php |
||
14 | class SEO_Metadata_SiteTree_DataExtension extends DataExtension |
||
|
|||
15 | { |
||
16 | |||
17 | /* Overload Model |
||
18 | ------------------------------------------------------------------------------*/ |
||
19 | |||
20 | /** |
||
21 | * Database attributes. |
||
22 | * |
||
23 | * @var array $db |
||
24 | */ |
||
25 | private static $db = array( |
||
26 | 'MetaTitle' => 'Varchar(128)', |
||
27 | 'MetaDescription' => 'Text', // redundant, but included for backwards-compatibility |
||
28 | 'ExtraMeta' => 'HTMLText', // redundant, but included for backwards-compatibility |
||
29 | ); |
||
30 | |||
31 | |||
32 | /* Overload Methods |
||
33 | ------------------------------------------------------------------------------*/ |
||
34 | |||
35 | // @todo @inheritdoc ?? or does it happen automagically as promised? |
||
36 | public function updateCMSFields(FieldList $fields) |
||
49 | |||
50 | /** |
||
51 | * Gets SEO fields. |
||
52 | * |
||
53 | * @return array |
||
54 | */ |
||
55 | public function getSEOFields() |
||
83 | |||
84 | /** |
||
85 | * Gets the full output. |
||
86 | * |
||
87 | * @return array |
||
88 | */ |
||
89 | public function getFullOutput() |
||
96 | |||
97 | /** |
||
98 | * Main function to format & output metadata as an HTML string. |
||
99 | * |
||
100 | * Use the `updateMetadata($config, $owner, $metadata)` update hook when extending `DataExtension`s. |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | public function Metadata() |
||
121 | |||
122 | |||
123 | /* Template Methods |
||
124 | ------------------------------------------------------------------------------*/ |
||
125 | |||
126 | /** |
||
127 | * Updates metadata fields. |
||
128 | * |
||
129 | * @param SiteConfig $config |
||
130 | * @param SiteTree $owner |
||
131 | * @param string $metadata |
||
132 | * |
||
133 | * @return void |
||
134 | */ |
||
135 | public function updateMetadata(SiteConfig $config, SiteTree $owner, &$metadata) |
||
166 | |||
167 | |||
168 | /* Markup Methods |
||
169 | ------------------------------------------------------------------------------*/ |
||
170 | |||
171 | /** |
||
172 | * Returns a given string as a HTML comment. |
||
173 | * |
||
174 | * @var string $comment |
||
175 | * |
||
176 | * @return string |
||
177 | */ |
||
178 | public function MarkupComment($comment) |
||
182 | |||
183 | /** |
||
184 | * Returns markup for a HTML meta element. Can be flagged for encoding. |
||
185 | * |
||
186 | * @param string $name |
||
187 | * @param string $content |
||
188 | * @param string|null $encode |
||
189 | * |
||
190 | * @return string |
||
191 | */ |
||
192 | public function MarkupMeta($name, $content, $encode = null) |
||
200 | |||
201 | /** |
||
202 | * Returns markup for a HTML link element. |
||
203 | * |
||
204 | * @param string $rel |
||
205 | * @param string $href |
||
206 | * @param string $type |
||
207 | * @param string $sizes |
||
208 | * |
||
209 | * @return string |
||
210 | */ |
||
211 | public function MarkupLink($rel, $href, $type = '', $sizes = '') |
||
228 | |||
229 | |||
230 | /* Generation Methods |
||
231 | ------------------------------------------------------------------------------*/ |
||
232 | |||
233 | /** |
||
234 | * Generates HTML title based on configuration settings. |
||
235 | * |
||
236 | * @return string|null |
||
237 | */ |
||
238 | public function GenerateTitle() |
||
246 | |||
247 | /** |
||
248 | * Generates description from the page `MetaDescription`, or the first paragraph of the `Content` attribute. |
||
249 | * |
||
250 | * @return string|null |
||
251 | */ |
||
252 | public function GenerateDescription() |
||
260 | |||
261 | /** |
||
262 | * Generates description from the first paragraph of the `Content` attribute. |
||
263 | * |
||
264 | * @return string|null |
||
265 | */ |
||
266 | public function GenerateDescriptionFromContent() |
||
285 | |||
286 | /** |
||
287 | * Generates extra metadata. |
||
288 | * |
||
289 | * @return string |
||
290 | */ |
||
291 | public function GenerateExtraMeta() |
||
299 | |||
300 | |||
301 | /* Utility Methods |
||
302 | --------------------------------------------------------------------------*/ |
||
303 | |||
304 | /** |
||
305 | * Returns a plain or HTML-encoded string according to the current charset & encoding settings. |
||
306 | * |
||
307 | * @param string $content |
||
308 | * @param string $charset |
||
309 | * |
||
310 | * @return string |
||
311 | */ |
||
312 | public function encodeContent($content, $charset) |
||
316 | |||
317 | } |
||
318 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.