1 | <?php |
||
12 | class SEO_Metadata_SiteTree_DataExtension extends DataExtension |
||
|
|||
13 | { |
||
14 | |||
15 | |||
16 | /* Overload Model |
||
17 | ------------------------------------------------------------------------------*/ |
||
18 | |||
19 | private static $db = array( |
||
20 | 'MetaTitle' => 'Varchar(128)', |
||
21 | 'MetaDescription' => 'Text', // redundant, but included for backwards-compatibility |
||
22 | 'ExtraMeta' => 'HTMLText', // redundant, but included for backwards-compatibility |
||
23 | ); |
||
24 | |||
25 | |||
26 | /* Overload Methods |
||
27 | ------------------------------------------------------------------------------*/ |
||
28 | |||
29 | // CMS Fields |
||
30 | public function updateCMSFields(FieldList $fields) |
||
82 | |||
83 | /** |
||
84 | * Main function to format & output metadata as an HTML string. |
||
85 | * |
||
86 | * Use the `updateMetadata($config, $owner, $metadata)` update hook when extending `DataExtension`s. |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | public function Metadata() |
||
146 | |||
147 | |||
148 | /* Helper Methods |
||
149 | ------------------------------------------------------------------------------*/ |
||
150 | |||
151 | /** |
||
152 | * Returns a given string as a HTML comment. |
||
153 | * |
||
154 | * @var string $comment |
||
155 | * |
||
156 | * @return string |
||
157 | */ |
||
158 | public function MarkupComment($comment) |
||
159 | { |
||
160 | |||
161 | // return |
||
162 | return '<!-- ' . $comment . ' -->' . PHP_EOL; |
||
163 | |||
164 | } |
||
165 | |||
166 | /** |
||
167 | * Returns markup for a HTML meta element. |
||
168 | * |
||
169 | * @var string $name |
||
170 | * @var string $content |
||
171 | * @var bool $encode |
||
172 | * |
||
173 | * @return string |
||
174 | */ |
||
175 | public function MarkupMeta($name, $content, $encode = false) |
||
176 | { |
||
177 | |||
178 | // return |
||
179 | return '<meta name="' . $name . '" content="' . $this->encodeContent($content, $encode) . '" />' . PHP_EOL; |
||
180 | |||
181 | } |
||
182 | |||
183 | /** |
||
184 | * Returns markup for a HTML link element. |
||
185 | * |
||
186 | * @param string $rel |
||
187 | * @param string $href |
||
188 | * @param string $type |
||
189 | * @param string $sizes |
||
190 | * |
||
191 | * @return string |
||
192 | */ |
||
193 | public function MarkupLink($rel, $href, $type = '', $sizes = '') |
||
210 | |||
211 | |||
212 | /* Meta Methods |
||
213 | ------------------------------------------------------------------------------*/ |
||
214 | |||
215 | /** |
||
216 | * Generates HTML title based on configuration settings. |
||
217 | * |
||
218 | * @return bool|string |
||
219 | */ |
||
220 | public function GenerateTitle() |
||
227 | |||
228 | /** |
||
229 | * Returns description from the page `MetaDescription`, or the first paragraph of the `Content` attribute. |
||
230 | * |
||
231 | * @return bool|string |
||
232 | */ |
||
233 | public function GenerateDescription() |
||
243 | |||
244 | /** |
||
245 | * Generates description from the first paragraph of the `Content` attribute. |
||
246 | * |
||
247 | * @return bool|string |
||
248 | */ |
||
249 | public function GenerateDescriptionFromContent() |
||
273 | |||
274 | /** |
||
275 | * Returns a plain or HTML-encoded string according to the current charset & encoding settings. |
||
276 | * |
||
277 | * @param string $content |
||
278 | * @param bool $encode |
||
279 | * |
||
280 | * @return string |
||
281 | */ |
||
282 | public function encodeContent($content, $encode = true) { |
||
289 | |||
290 | } |
||
291 |
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.