diff --git a/README.md b/README.md
index b0e408b..a631a7d 100755
--- a/README.md
+++ b/README.md
@@ -1,15 +1,15 @@
# Custom Page Headers Symphony Extension
-- Version: 1.2
+- Version: 1.2.1
- Author: Henry Singleton
-- Build Date: 06 06 2012
-- Requirements: Symphony 2.2.x - Symphony 2.3.x
+- Build Date: 29 10 2014
+- Requirements: Symphony 2.2.x - Symphony 2.5.x
## Overview
This Symphony CMS extension allows you to define headers by page output. This lets you build headers using data from datasources or other page information. Anything that's accessible from a standard page really!
-Great for generating redirect urls for 301/302 redirects if you need information from existing Symphony entries, or want to store redirect stats via an event etc.
+Great for generating redirect urls for 301/302 redirects if you need information from existing Symphony entries, or want to store redirect stats via an event etc.
## Installation
@@ -32,17 +32,17 @@ Create a new page, give it a page type of 'headers' and save the following as th
-
+
-
+
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
-
+
Here is an exmpale of custom 404 page, implemented in a different way. Note that you'll need to ensure there are two empty lines
@@ -50,28 +50,28 @@ between your headers and any page content you want to output (as per the HTTP sp
-
+
-
+
HTTP/1.0 404 Not Found
-
+
-
+
Page not found
-
+
Try our homepage
-
+
-
+
## Changelog
+- **1.2.1** Updated extension.meta.xml to extend compatibility to Symphony 2.5.x.
- **1.2** Fixes bug where page output would be blank if a Symphony page error was generated.
- **1.1** Updated extension.meta.xml to include namespace for Symphony 2.3 compatibility. (Thanks to andrewminton)
- **1.0** Initial release for internal project.
-
diff --git a/extension.driver.php b/extension.driver.php
index 9c70bd0..32e02ec 100644
--- a/extension.driver.php
+++ b/extension.driver.php
@@ -1,93 +1,93 @@
'Page Headers',
- 'version' => '1.2',
- 'release-date' => '2012-06-06',
- 'author' => array(
- 'name' => 'Henry Singleton',
- 'website' => 'http://henrysingleton.com'
- ),
- 'description' => 'Allows headers to be output as part of page content, overwriting existing headers.'
- );
- }
-
- public function uninstall() {
- return true;
- }
-
- public function install() {
- return true;
- }
-
- public function getSubscribedDelegates() {
- return array(
- array(
- 'page' => '/frontend/',
- 'delegate' => 'FrontendPageResolved',
- 'callback' => 'checkHeadersPageType'
- ),
- array(
- 'page' => '/frontend/',
- 'delegate' => 'FrontendOutputPostGenerate',
- 'callback' => 'processPageContent'
- )
- );
- }
-
- public function checkheadersPageType($page) {
- //Check that the page type has been sent to 'headers' so we only process a page when we need to.
- if (is_array($page) &&
- is_array($page['page_data']) &&
- array_key_exists('type', $page['page_data']) &&
- array_search('headers',$page['page_data']['type']) !== false
- ) {
- $this->headersTrigger = true;
- }
- }
-
- public function processPageContent($page) {
- //If this page has 'headers' set as a page type, process the content.
- if ($this->headersTrigger === true) {
- $content = $page['output'];
-
- if (
-
- //If the content is false that means there is likely a symphony error being shown. If so, don't do anything.
- $content !== false &&
-
- //Just check that the page content doesn't start with an angle bracket, as that would mean XML/HTML was probably being output and not the sweet juicy headers we crave.
- strpos($content, '<') !== 0 &&
-
- //Check we haven't already sent the headers, to avoid nasty PHP error.
- !headers_sent()
-
- ) {
- //split response by two consecutive newlines (as per http sepc)
- $parts = explode("\n\n", $content);
-
- //grab the block before the first two newlines, and then split by newlines for each header
- $headers = explode("\n",array_shift($parts));
-
- if (is_array($headers)) {
-
- //Send each found header
- foreach ($headers as $header) {
- header(trim($header));
- }
-
- //Turn parts back into string, with headers absent due to array_unshift above
- $page['output'] = trim(implode("\n", $parts));
-
- //If only headers were used in the page output, kill the script now, as we have nothing else to send, and a Symphony error will be generated if the output is empty.
- if (strlen($page['output']) === 0) die();
- }
- }
- }
- }
- }
\ No newline at end of file
+
+ class extension_page_headers extends Extension {
+
+ private $headersTrigger;
+
+ public function about() {
+ return array(
+ 'name' => 'Page Headers',
+ 'version' => '1.2',
+ 'release-date' => '2012-06-06',
+ 'author' => array(
+ 'name' => 'Henry Singleton',
+ 'website' => 'http://henrysingleton.com'
+ ),
+ 'description' => 'Allows headers to be output as part of page content, overwriting existing headers.'
+ );
+ }
+
+ public function uninstall() {
+ return true;
+ }
+
+ public function install() {
+ return true;
+ }
+
+ public function getSubscribedDelegates() {
+ return array(
+ array(
+ 'page' => '/frontend/',
+ 'delegate' => 'FrontendPageResolved',
+ 'callback' => 'checkHeadersPageType'
+ ),
+ array(
+ 'page' => '/frontend/',
+ 'delegate' => 'FrontendOutputPostGenerate',
+ 'callback' => 'processPageContent'
+ )
+ );
+ }
+
+ public function checkheadersPageType($page) {
+ //Check that the page type has been sent to 'headers' so we only process a page when we need to.
+ if (is_array($page) &&
+ is_array($page['page_data']) &&
+ array_key_exists('type', $page['page_data']) &&
+ array_search('headers',$page['page_data']['type']) !== false
+ ) {
+ $this->headersTrigger = true;
+ }
+ }
+
+ public function processPageContent($page) {
+ //If this page has 'headers' set as a page type, process the content.
+ if ($this->headersTrigger === true) {
+ $content = $page['output'];
+
+ if (
+
+ //If the content is false that means there is likely a symphony error being shown. If so, don't do anything.
+ $content !== false &&
+
+ //Just check that the page content doesn't start with an angle bracket, as that would mean XML/HTML was probably being output and not the sweet juicy headers we crave.
+ strpos($content, '<') !== 0 &&
+
+ //Check we haven't already sent the headers, to avoid nasty PHP error.
+ !headers_sent()
+
+ ) {
+ //split response by two consecutive newlines (as per http sepc)
+ $parts = explode("\n\n", $content);
+
+ //grab the block before the first two newlines, and then split by newlines for each header
+ $headers = explode("\n",array_shift($parts));
+
+ if (is_array($headers)) {
+
+ //Send each found header
+ foreach ($headers as $header) {
+ header(trim($header));
+ }
+
+ //Turn parts back into string, with headers absent due to array_unshift above
+ $page['output'] = trim(implode("\n", $parts));
+
+ //If only headers were used in the page output, kill the script now, as we have nothing else to send, and a Symphony error will be generated if the output is empty.
+ if (strlen($page['output']) === 0) die();
+ }
+ }
+ }
+ }
+ }
diff --git a/extension.meta.xml b/extension.meta.xml
index 00fd287..958591d 100644
--- a/extension.meta.xml
+++ b/extension.meta.xml
@@ -1,20 +1,22 @@
\ No newline at end of file
+ Page Headers
+ Customise HTTP headers by standard page output.
+ https://github.com/henrysingleton/page_headers
+ http://www.getsymphony.com/discuss/thread/86515/
+
+ Other
+
+
+
+ Henry Singleton
+ http://henrysingleton.com/
+
+
+
+
+
+
+
+
+