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) |
||
77 | |||
78 | /** |
||
79 | * Main function to format & output metadata as an HTML string. |
||
80 | * |
||
81 | * Use the `updateMetadata($config, $owner, $metadata)` update hook when extending `DataExtension`s. |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | public function Metadata() |
||
103 | |||
104 | |||
105 | /* Template Methods |
||
106 | ------------------------------------------------------------------------------*/ |
||
107 | |||
108 | /** |
||
109 | * Updates metadata fields. |
||
110 | * |
||
111 | * @param SiteConfig $config |
||
112 | * @param SiteTree $owner |
||
113 | * @param $metadata |
||
114 | * |
||
115 | * @return void |
||
116 | */ |
||
117 | public function updateMetadata(SiteConfig $config, SiteTree $owner, &$metadata) |
||
151 | |||
152 | |||
153 | /* Helper Methods |
||
154 | ------------------------------------------------------------------------------*/ |
||
155 | |||
156 | /** |
||
157 | * Returns a given string as a HTML comment. |
||
158 | * |
||
159 | * @var string $comment |
||
160 | * |
||
161 | * @return string |
||
162 | */ |
||
163 | public function MarkupComment($comment) |
||
167 | |||
168 | /** |
||
169 | * Returns markup for a HTML meta element. |
||
170 | * |
||
171 | * @var string $name |
||
172 | * @var string $content |
||
173 | * @var bool $encode |
||
174 | * |
||
175 | * @return string |
||
176 | */ |
||
177 | public function MarkupMeta($name, $content, $encode = false) |
||
181 | |||
182 | /** |
||
183 | * Returns markup for a HTML link element. |
||
184 | * |
||
185 | * @param string $rel |
||
186 | * @param string $href |
||
187 | * @param string $type |
||
188 | * @param string $sizes |
||
189 | * |
||
190 | * @return string |
||
191 | */ |
||
192 | public function MarkupLink($rel, $href, $type = '', $sizes = '') |
||
209 | |||
210 | |||
211 | /* Meta Methods |
||
212 | ------------------------------------------------------------------------------*/ |
||
213 | |||
214 | /** |
||
215 | * Generates HTML title based on configuration settings. |
||
216 | * |
||
217 | * @return string|null |
||
218 | */ |
||
219 | public function GenerateTitle() |
||
223 | |||
224 | /** |
||
225 | * Returns description from the page `MetaDescription`, or the first paragraph of the `Content` attribute. |
||
226 | * |
||
227 | * @return string|null |
||
228 | */ |
||
229 | public function GenerateDescription() |
||
237 | |||
238 | /** |
||
239 | * Generates description from the first paragraph of the `Content` attribute. |
||
240 | * |
||
241 | * @return string|null |
||
242 | */ |
||
243 | public function GenerateDescriptionFromContent() |
||
262 | |||
263 | /** |
||
264 | * Returns a plain or HTML-encoded string according to the current charset & encoding settings. |
||
265 | * |
||
266 | * @param string $content |
||
267 | * @param bool $encode |
||
268 | * |
||
269 | * @return string |
||
270 | */ |
||
271 | public function encodeContent($content, $encode = true) { |
||
278 | |||
279 | } |
||
280 |
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.