Skip to content

Commit

Permalink
Merge pull request #12 from symphonists/integration
Browse files Browse the repository at this point in the history
Version 1.3.2 - Merge Integration
  • Loading branch information
nitriques committed Nov 6, 2014
2 parents 40ad6df + 6f2fe2b commit 0c3342e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 51 deletions.
11 changes: 4 additions & 7 deletions README.markdown
Expand Up @@ -2,13 +2,6 @@

This is an extension for [Symphony 2](http://getsymphony.com/): A cludge to enforce a basic HTML5 doctype regardless of your XSLT output.

- Version: 1.3.1
- Date: 11 February 2013
- Requirements: Symphony 2
- Author: Nick Dunn
- Constributors: Stephen Bau, Michael Eichelsdoerfer
- GitHub Repository: <https://github.com/domain7/html5_doctype>


## Usage

Expand Down Expand Up @@ -66,6 +59,10 @@ Information about [installing and updating extensions](http://getsymphony.com/le

## Change Log

**Version 1.3.2**

- Compatibility update for Symphony 2.4: Add 'data-interactive' attribute to tag field in preferences

**Version 1.3.1**

- Add Russian language translation
Expand Down
88 changes: 44 additions & 44 deletions extension.driver.php
Expand Up @@ -5,26 +5,26 @@ class extension_html5_doctype extends Extension{
private $_trigger;
private static $_name = 'HTML5 Doctype';

public function getSubscribedDelegates(){
return array(
array(
'page' => '/frontend/',
'delegate' => 'FrontendOutputPostGenerate',
'callback' => 'parse_html'
),

array(
'page' => '/frontend/',
public function getSubscribedDelegates(){
return array(
array(
'page' => '/frontend/',
'delegate' => 'FrontendOutputPostGenerate',
'callback' => 'parse_html'
),

array(
'page' => '/frontend/',
'delegate' => 'FrontendPageResolved',
'callback' => 'setRenderTrigger'
),
),

array(
'page' => '/system/preferences/',
array(
'page' => '/system/preferences/',
'delegate' => 'AddCustomPreferenceFieldsets',
'callback' => 'appendPreferences'
),
);
),
);
}

/**
Expand All @@ -42,13 +42,13 @@ public function appendPreferences($context, $errors = null) {
Symphony::Configuration()->get('exclude_pagetypes', 'html5_doctype')
));

$tags = new XMLElement('ul', null, array('class' => 'tags'));
$tags = new XMLElement('ul', null, array('class' => 'tags', 'data-interactive' => 'data-interactive'));

$types = PageManager::fetchAvailablePageTypes();
$types = PageManager::fetchAvailablePageTypes();

foreach($types as $type) {
$tags->appendChild(new XMLElement('li', $type));
}
foreach($types as $type) {
$tags->appendChild(new XMLElement('li', $type));
}

$div->appendChild($label);
$div->appendChild($tags);
Expand Down Expand Up @@ -84,27 +84,27 @@ public function setRenderTrigger($context)

public function parse_html($context) {
if (!$this->_trigger) return;
// Parse only if $context['output'] exists and it's an HTML document
if(substr($context['output'], 0, 14) == '<!DOCTYPE html') {
$html = $context['output'];

// Split the HTML output into two variables:
// $html_doctype contains the first fifteen lines of the HTML document
// $html_doc contains the rest of the HTML document
$html_array = explode("\n", $html, 15);
$html_doc = array_pop($html_array);
$html_doctype = implode("\n", $html_array);

// Parse the doctype to convert XHTML syntax to HTML5
$html_doctype = preg_replace("/<!DOCTYPE [^>]+>/", "<!DOCTYPE html>", $html_doctype);
$html_doctype = preg_replace('/ xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"| xml:lang="[^\"]*\"/', '', $html_doctype);
$html_doctype = preg_replace('/<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=(.*[a-z0-9-])\"( \/)?>/i', '<meta charset="\1"\2>', $html_doctype);

// Concatenate the fragments into a complete HTML5 document
$html = $html_doctype . "\n" . $html_doc;

$context['output'] = $html;
}
}

}
// Parse only if $context['output'] exists and it's an HTML document
if(substr($context['output'], 0, 14) == '<!DOCTYPE html') {
$html = $context['output'];

// Split the HTML output into two variables:
// $html_doctype contains the first fifteen lines of the HTML document
// $html_doc contains the rest of the HTML document
$html_array = explode("\n", $html, 15);
$html_doc = array_pop($html_array);
$html_doctype = implode("\n", $html_array);

// Parse the doctype to convert XHTML syntax to HTML5
$html_doctype = preg_replace("/<!DOCTYPE [^>]+>/", "<!DOCTYPE html>", $html_doctype);
$html_doctype = preg_replace('/ xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"| xml:lang="[^\"]*\"/', '', $html_doctype);
$html_doctype = preg_replace('/<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=(.*[a-z0-9-])\"( \/)?>/i', '<meta charset="\1"\2>', $html_doctype);

// Concatenate the fragments into a complete HTML5 document
$html = $html_doctype . "\n" . $html_doc;

$context['output'] = $html;
}
}

}
6 changes: 6 additions & 0 deletions extension.meta.xml
Expand Up @@ -8,12 +8,18 @@
<type>Other</type>
</types>
<authors>
<author>
<name github="symphonists" symphony="community">Symphony Community</name>
</author>
<author>
<name github="bauhouse" symphony="bauhouse">Stephen Bau</name>
<website>http://stephenbau.com/</website>
</author>
</authors>
<releases>
<release version="1.3.2" date="2014-11-05" min="2.3">
- Compatibility update for Symphony 2.4: Add 'data-interactive' attribute to tag field in preferences
</release>
<release version="1.3.1" date="2013-02-11" min="2.3">
- Add Russian language translation
</release>
Expand Down

0 comments on commit 0c3342e

Please sign in to comment.