Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup and updates for newer versions of Symphony #3

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
4 changes: 1 addition & 3 deletions README
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Redirect to Subpage
Version 1.0
Written by Huib Keemink

When enabled, this action redirects the user to the first subpage associated with the page.
When enabled, this action redirects the user to the first subpage associated with the page.
84 changes: 41 additions & 43 deletions events/event.redirect.php
Original file line number Diff line number Diff line change
@@ -1,49 +1,47 @@
<?php

if(!defined('__IN_SYMPHONY__')) die('<h2>Error</h2><p>You cannot directly access this file</p>');
if (!defined('__IN_SYMPHONY__')) die('<h2>Error</h2><p>You cannot directly access this file</p>');

require_once(TOOLKIT . '/class.event.php');
require_once(TOOLKIT . '/class.event.php');

Class eventRedirect extends Event{

public static function about(){

$description = new XMLElement('p', 'This event redirects the users to the first subpage attached to the page');

return array(
'name' => 'Subpage Redirect',
'author' => array('name' => 'Huib Keemink',
'website' => 'http://www.creativedutchmen.com',
'email' => '[email protected]'),
'version' => '1.0',
'release-date' => '2008-11-10',
'trigger-condition' => '');
}

public function load(){
return $this->__trigger();
}
class eventRedirect extends Event
{
public static function about()
{
return array(
'name' => 'Subpage Redirect',
'author' => array(
'name' => 'Huib Keemink',
'website' => 'http://www.creativedutchmen.com',
'email' => '[email protected]'
),
'version' => '1.1',
'release-date' => '2013-09-01',
'trigger-condition' => ''
);
}

public static function documentation(){
return 'Redirects the user to the first subpage associated with the page';
}

protected function __trigger(){
if($this->_env['param']['parent-path'] == '/'){
$path = $this->_env['param']['current-page'];
}
else{
$path = substr($this->_env['param']['parent-path'].'/'.$this->_env['param']['current-page'],1);
}
$row = $this->_Parent->Database->fetchRow(0, "SELECT * from tbl_pages where path = '".$path."' ORDER BY sortorder ASC");
if(empty($row)){
return false;
}
else{
header ('Location: '.$this->_env['param']['root'].'/'.$path.'/'.$row['handle'] . '/');
die();
}
}
}
public static function documentation()
{
return 'Redirects the user to the first subpage associated with the page. Provided by the Subpage Redirect extension.';
}

?>
public function load()
{
return $this->__trigger();
}

protected function __trigger()
{
$page_id = $this->_env['param']['current-page-id'];
$child_pages = PageManager::fetchChildPages($page_id);
$child_page_id = $child_pages[0]['id'];
if (empty($child_page_id)) {
return false;
} else {
$child_page_path = PageManager::resolvePagePath($child_page_id);
header ('Location: '.$this->_env['param']['root'].'/'.$child_page_path.'/');
die();
}
}
}
26 changes: 3 additions & 23 deletions extension.driver.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
<?php

require_once(TOOLKIT . '/class.entrymanager.php');


Class extension_redirect_subpage extends Extension{

protected $section_data;
protected $_page;
protected $static_section_name;

static $alreadyRan = false;

public function about(){
return array('name' => 'Redirect to Subpage',
'version' => '1.0',
'release-date' => '2009-10-05',
'author' => array('name' => 'Huib Keemink',
'website' => 'http://www.creativedutchmen.com',
'email' => '[email protected]')
);
}
}

?>
class extension_redirect_subpage extends Extension
{
}
23 changes: 23 additions & 0 deletions extension.meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension id="redirect_subpage" status="released" xmlns="http://symphony-cms.com/schemas/extension/1.0">
<name>Subpage Redirect</name>
<description>Provides an event which redirects the users to the first subpage attached to the page.</description>
<repo type="github">https://github.com/creativedutchmen/redirect_subpage</repo>
<url type="discuss">http://www.getsymphony.com/discuss/thread/31936/</url>
<types>
<type>Events</type>
<type>Redirection</type>
</types>
<authors>
<author>
<name github="creativedutchmen" symphony="creativedutchmen">Huib Keemink</name>
</author>
</authors>
<releases>
<release version="1.2.0" date="2016-03-06" min="2.3.x" max="2.x.x">
* Marked as compatible with Symphony 2.x.x
</release>
<release version="1.1" date="2013-10-04" min="2.3" />
<release version="1.0" date="2008-11-10" min="2.0.6" max="2.2.x"/>
</releases>
</extension>