This repository was archived by the owner on Feb 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructureddata.php
More file actions
64 lines (54 loc) · 1.6 KB
/
structureddata.php
File metadata and controls
64 lines (54 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* @package Joomla.Plugin
* @subpackage System.StructuredData
*
* @copyright Copyright (C) 2014 Alex Prut (Alexandru Pruteanu)
* @license Licensed under the MIT License; see LICENSE
*/
defined('JPATH_BASE') or die;
/**
* System Plugin for parsing the HTML markup and convert
* the data-* HTML5 attributes in Microdata or RDFa Lite 1.1 semantics.
*
* @package Joomla.Plugin
* @subpackage System.StructuredData
* @since 3.2
*/
class PlgSystemStructuredData extends JPlugin
{
/**
* Parse the HTML markup and convert the data-* HTML5 attributes in Microdata or RDFa Lite 1.1 semantics,
* after that all the HTML was generated by the application logic.
*
* @return boolean True on success
*
* @since 3.2
*/
public function onAfterRender()
{
$app = JFactory::getApplication();
// Prevent admin execution, and non HTML documents.
if ($app->isAdmin()
|| $app->getDocument()->getType() !== 'html')
{
return true;
}
// Prevent site execution when editing
if ($app->isSite() && $app->input->get('layout') == 'edit')
{
return true;
}
// Tell the auto-loader to look for classes starting with "Lib" in a specific folder.
JLoader::discover('Lib', JPATH_PLUGINS . '/system/structureddata/lib');
// Retrieve the params
$suffix = explode(',', $this->params->get('suffix', 'sd'));
$semantic = $this->params->get('semantic', 'microdata');
// Get the body HTML
$output = $app->getBody();
// Make an instance of the parser
$parser = new LibParserPlugin($semantic, $suffix);
// Set the body HTML
$app->setBody($parser->parse($output));
}
}