Skip to content

Commit

Permalink
plg_system_microdata
Browse files Browse the repository at this point in the history
  • Loading branch information
P.Alex committed Jan 2, 2015
1 parent 1c53ec8 commit add4639
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
9 changes: 9 additions & 0 deletions administrator/language/en-GB/en-GB.plg_system_microdata.ini
@@ -0,0 +1,9 @@
; Joomla! Project
; Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM

PLG_SYSTEM_MICRODATA="System - Microdata"
PLG_SYSTEM_MICRODATA_FIELD_SUFFIX_DESCRIPTION="The suffix to search for when parsing the data-* HTML5 attribute"
PLG_SYSTEM_MICRODATA_FIELD_SUFFIX_LABEL="The data-* suffix"
PLG_SYSTEM_MICRODATA_XML_DESCRIPTION="System Plugin for parsing the HTML markup and convert the 'data-sd' HTML5 attributes in Microdata semantics."
@@ -0,0 +1,7 @@
; Joomla! Project
; Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM

PLG_SYSTEM_MICRODATA="System - Microdata"
PLG_SYSTEM_MICRODATA_XML_DESCRIPTION="System Plugin for parsing the HTML markup and convert the 'data-sd' HTML5 attributes in Microdata semantics."
1 change: 1 addition & 0 deletions plugins/system/microdata/index.html
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
59 changes: 59 additions & 0 deletions plugins/system/microdata/microdata.php
@@ -0,0 +1,59 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage System.Microdata
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

defined('JPATH_BASE') or die;

/**
* System Plugin for parsing the HTML markup and convert
* the data-sd HTML5 attributes in Microdata semantics.
*
* @package Joomla.Plugin
* @subpackage System.Microdata
* @since 3.2
*/
class PlgSystemMicrodata extends JPlugin
{
/**
* Parse the HTML markup and convert the data-sd HTML5 attributes in Microdata 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;
}

// Retrieve the params
$suffix = explode(',', $this->params->get('suffix', 'sd'));

// Get the body HTML
$output = $app->getBody();

// Make an instance of the parser
$parser = new JMicrodataParser($suffix);

// Set the body HTML
$app->setBody($parser->parse($output));
}
}
32 changes: 32 additions & 0 deletions plugins/system/microdata/microdata.xml
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension version="3.3" type="plugin" group="system">
<name>plg_system_microdata</name>
<author>Joomla! Project</author>
<creationDate>August 2014</creationDate>
<copyright>Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_SYSTEM_MICRODATA_XML_DESCRIPTION</description>
<files>
<filename plugin="microdata">microdata.php</filename>
<filename>index.html</filename>
<folder>lib</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/en-GB.plg_system_microdata.ini</language>
<language tag="en-GB">language/en-GB/en-GB.plg_system_microdata.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="suffix" type="text"
default="sd"
label="PLG_SYSTEM_MICRODATA_FIELD_SUFFIX_LABEL"
description="PLG_SYSTEM_MICRODATA_FIELD_SUFFIX_DESCRIPTION"
/>
</fieldset>
</fields>
</config>
</extension>

0 comments on commit add4639

Please sign in to comment.