From 3fb259c82cedae9b266ba455db5e049a1c300c34 Mon Sep 17 00:00:00 2001 From: chrischerrett Date: Mon, 19 Nov 2012 13:40:34 +0000 Subject: [PATCH 1/8] - Modified build.transport.php to support two new events, OnDocFormRender and OnDocFormSave - Modified plugin.redirector.php to capture alias prior to save (OnDocFormRender). If the alias has changed and the system settings permit then add a new redirect record (OnDocFormSave) - Created new system setting: redirector.on_alias_update (Yes/No) - Updated readme.txt --- ...ild.config.sample.php => build.config.php} | 6 +- ...erties.sample.php => build.properties.php} | 8 +- _build/build.schema.php | 1 - _build/build.transport.php | 57 +++++++-- _build/data/transport.plugins.php | 36 ++++-- _build/data/transport.settings.php | 23 ++++ core/components/redirector/docs/readme.txt | 2 + .../elements/plugins/plugin.redirector.php | 109 ++++++++++++------ .../model/redirector/metadata.mysql.php | 8 ++ .../model/redirector/metadata.sqlsrv.php | 8 ++ .../redirector/mysql/modredirect.map.inc.php | 2 + .../redirector/sqlsrv/modredirect.map.inc.php | 2 + .../model/schema/redirector.sqlsrv.schema.xml | 2 +- 13 files changed, 197 insertions(+), 67 deletions(-) rename _build/{build.config.sample.php => build.config.php} (78%) rename _build/{build.properties.sample.php => build.properties.php} (89%) create mode 100644 _build/data/transport.settings.php create mode 100644 core/components/redirector/model/redirector/metadata.mysql.php create mode 100644 core/components/redirector/model/redirector/metadata.sqlsrv.php diff --git a/_build/build.config.sample.php b/_build/build.config.php similarity index 78% rename from _build/build.config.sample.php rename to _build/build.config.php index da5f036..459d682 100644 --- a/_build/build.config.sample.php +++ b/_build/build.config.php @@ -5,7 +5,7 @@ * @package redirector * @subpackage build */ -define('MODX_BASE_PATH', dirname(dirname(dirname(dirname(__FILE__)))) . '/modx/'); +define('MODX_BASE_PATH', 'C:/xampp/htdocs/sites/Adido/modx/'); define('MODX_CORE_PATH', MODX_BASE_PATH . 'core/'); define('MODX_MANAGER_PATH', MODX_BASE_PATH . 'manager/'); define('MODX_CONNECTORS_PATH', MODX_BASE_PATH . 'connectors/'); @@ -15,4 +15,6 @@ define('MODX_CORE_URL', MODX_BASE_URL . 'core/'); define('MODX_MANAGER_URL', MODX_BASE_URL . 'manager/'); define('MODX_CONNECTORS_URL', MODX_BASE_URL . 'connectors/'); -define('MODX_ASSETS_URL', MODX_BASE_URL . 'assets/'); \ No newline at end of file +define('MODX_ASSETS_URL', MODX_BASE_URL . 'assets/'); + +define('MODX_CONFIG_KEY', 'config'); \ No newline at end of file diff --git a/_build/build.properties.sample.php b/_build/build.properties.php similarity index 89% rename from _build/build.properties.sample.php rename to _build/build.properties.php index 1cd0da9..0d48455 100644 --- a/_build/build.properties.sample.php +++ b/_build/build.properties.php @@ -4,10 +4,10 @@ /* driver-specific connection properties */ /* mysql */ -$properties['mysql_string_dsn_test']= 'mysql:host=localhost;dbname=modx_modx;charset=utf8'; +$properties['mysql_string_dsn_test']= 'mysql:host=localhost;dbname=modx;charset=utf8'; $properties['mysql_string_dsn_nodb']= 'mysql:host=localhost;charset=utf8'; -$properties['mysql_string_dsn_error']= 'mysql:host= nonesuchhost;dbname=nonesuchdb'; -$properties['mysql_string_username']= ''; +$properties['mysql_string_dsn_error']= 'mysql:host=nonesuchhost;dbname=nonesuchdb'; +$properties['mysql_string_username']= 'root'; $properties['mysql_string_password']= ''; $properties['mysql_array_options']= array( xPDO::OPT_CACHE_PATH => $properties['cache_path'], @@ -18,7 +18,7 @@ $properties['mysql_array_driverOptions']= array(); /* sqlsrv */ -$properties['sqlsrv_string_dsn_test']= 'sqlsrv:server=(local);database=modx_modx'; +$properties['sqlsrv_string_dsn_test']= 'sqlsrv:server=(local);database=modx'; $properties['sqlsrv_string_dsn_nodb']= 'sqlsrv:server=(local)'; $properties['sqlsrv_string_dsn_error']= 'sqlsrv:server=xyz;123'; $properties['sqlsrv_string_username']= ''; diff --git a/_build/build.schema.php b/_build/build.schema.php index a46daa6..01e0e89 100644 --- a/_build/build.schema.php +++ b/_build/build.schema.php @@ -90,7 +90,6 @@ function __construct(& \$xpdo) { $generator->parseSchema($sources['model'] . 'schema/'.PKG_NAME_LOWER.'.'.$driver.'.schema.xml', $sources['model']); } - $mtime= microtime(); $mtime= explode(" ", $mtime); $mtime= $mtime[1] + $mtime[0]; diff --git a/_build/build.transport.php b/_build/build.transport.php index d1f211b..eed7ff9 100644 --- a/_build/build.transport.php +++ b/_build/build.transport.php @@ -39,7 +39,7 @@ require_once MODX_CORE_PATH . 'model/modx/modx.class.php'; $modx= new modX(); -$modx->initialize('mgr'); +$modx->initialize('mgr'); echo '
'; /* used for nice formatting of log messages */
 $modx->setLogLevel(modX::LOG_LEVEL_INFO);
 $modx->setLogTarget('ECHO');
@@ -50,23 +50,39 @@
 $builder->registerNamespace(PKG_NAME_LOWER,false,true,'{core_path}components/'.PKG_NAME_LOWER.'/');
 
 /* add plugin */
-$modx->log(modX::LOG_LEVEL_INFO,'Packaging in plugin...');
-$plugin= $modx->newObject('modPlugin');
+$modx->log(modX::LOG_LEVEL_INFO,'Packaging in Redirector plugin...');
+
+$plugin = $modx->newObject('modPlugin');
+
 $plugin->fromArray(array(
     'id' => 1,
     'name' => 'Redirector',
     'description' => 'Handles site redirects.',
     'plugincode' => getSnippetContent($sources['elements'].'plugins/plugin.redirector.php'),
 ),'',true,true);
-    $events = array();
-    $events['OnPageNotFound']= $modx->newObject('modPluginEvent');
-    $events['OnPageNotFound']->fromArray(array(
-        'event' => 'OnPageNotFound',
-        'priority' => 0,
-        'propertyset' => 0,
-    ),'',true,true);
-    $plugin->addMany($events);
-    unset($events);
+
+$events = array();
+$events['OnPageNotFound'] = $modx->newObject('modPluginEvent');
+$events['OnPageNotFound']->fromArray(array(
+    'event' => 'OnPageNotFound',
+    'priority' => 0,
+    'propertyset' => 0,
+),'',true,true);
+$events['OnDocFormRender'] = $modx->newObject('modPluginEvent');
+$events['OnDocFormRender']->fromArray(array(
+    'event' => 'OnDocFormRender',
+    'priority' => 0,
+    'propertyset' => 0,
+),'',true,true);
+$events['OnDocFormSave'] = $modx->newObject('modPluginEvent');
+$events['OnDocFormSave']->fromArray(array(
+    'event' => 'OnDocFormSave',
+    'priority' => 0,
+    'propertyset' => 0,
+),'',true,true);
+
+$plugin->addMany($events);
+unset($events);
 
 $attributes= array(
     xPDOTransport::UNIQUE_KEY => 'name',
@@ -94,6 +110,21 @@
 ));
 $builder->putVehicle($vehicle);
 
+/* settings */
+$settings = include_once $sources['data'].'transport.settings.php';
+$attributes= array(
+    xPDOTransport::UNIQUE_KEY => 'key',
+    xPDOTransport::PRESERVE_KEYS => true,
+    xPDOTransport::UPDATE_OBJECT => false,
+);
+if (!is_array($settings)) { $modx->log(modX::LOG_LEVEL_FATAL,'Adding settings failed.'); }
+foreach ($settings as $setting) {
+    $vehicle = $builder->createVehicle($setting,$attributes);
+    $builder->putVehicle($vehicle);
+}
+$modx->log(modX::LOG_LEVEL_INFO,'Packaged in '.count($settings).' system settings.'); flush();
+unset($settings,$setting,$attributes);
+
 /* load menu */
 $modx->log(modX::LOG_LEVEL_INFO,'Packaging in menu...');
 $menu = include $sources['data'].'transport.menu.php';
@@ -111,10 +142,12 @@
         ),
     ),
 ));
+
 $modx->log(modX::LOG_LEVEL_INFO,'Adding in PHP resolvers...');
 $vehicle->resolve('php',array(
     'source' => $sources['resolvers'] . 'resolve.tables.php',
 ));
+
 $builder->putVehicle($vehicle);
 unset($vehicle,$menu);
 
diff --git a/_build/data/transport.plugins.php b/_build/data/transport.plugins.php
index 019c8d2..fc9bd32 100644
--- a/_build/data/transport.plugins.php
+++ b/_build/data/transport.plugins.php
@@ -12,14 +12,32 @@
     'description' => 'Handles site redirects.',
     'plugincode' => file_get_contents($sources['elements'].'plugins/plugin.redirector.php'),
 ),'',true,true);
-    $events = array();
-    $events['OnPageNotFound']= $modx->newObject('modPluginEvent');
-    $events['OnPageNotFound']->fromArray(array(
-        'event' => 'OnPageNotFound',
-        'priority' => 0,
-        'propertyset' => 0,
-    ),'',true,true);
-    $plugins[1]->addMany($events);
-    unset($events);
+
+$events = array();
+$events['OnPageNotFound']= $modx->newObject('modPluginEvent');
+$events['OnPageNotFound']->fromArray(array(
+    'event' => 'OnPageNotFound',
+    'priority' => 0,
+    'propertyset' => 0, 
+),'',true,true);
+
+/* new OnDocFormRender event, added by cc */
+$events['OnDocFormRender'] = $modx->newObject('modPluginEvent');
+$events['OnDocFormRender']->fromArray(array(
+    'event' => 'OnDocFormRender',
+    'priority' => 0,
+    'propertyset' => 0,
+),'',true,true);
+
+/* new OnDocFormSave event, added by cc */
+$events['OnDocFormSave'] = $modx->newObject('modPluginEvent');
+$events['OnDocFormSave']->fromArray(array(
+    'event' => 'OnDocFormSave',
+    'priority' => 0,
+    'propertyset' => 0,
+),'',true,true);
+
+$plugins[1]->addMany($events);
+unset($events);
 
 return $plugins;
\ No newline at end of file
diff --git a/_build/data/transport.settings.php b/_build/data/transport.settings.php
new file mode 100644
index 0000000..53fa7d5
--- /dev/null
+++ b/_build/data/transport.settings.php
@@ -0,0 +1,23 @@
+ array(
+        'on_alias_update' => 'Yes',
+    ),
+);
+
+$settings = array();
+foreach ($s as $area => $sets) {
+    foreach ($sets as $key => $value) {
+        $settings['redirector.'.$key] = $modx->newObject('modSystemSetting');
+        $settings['redirector.'.$key]->set('key', 'redirector.'.$key);
+        $settings['redirector.'.$key]->fromArray(array(
+            'value' => $value,
+            'xtype' => 'textfield',
+            'namespace' => 'redirector',
+            'area' => $area
+        ));
+    }
+}
+
+return $settings;
\ No newline at end of file
diff --git a/core/components/redirector/docs/readme.txt b/core/components/redirector/docs/readme.txt
index 0fd2d5d..0de7ad0 100644
--- a/core/components/redirector/docs/readme.txt
+++ b/core/components/redirector/docs/readme.txt
@@ -6,3 +6,5 @@ Since: April 21st, 2010
 Author: Shaun McCormick  and Jason Coward 
 
 Handles 301 redirects for your site.
+
+**** New feature added by Chris Cherrett : Redirect created on alias update. Enable/disable via System Settings. ****
\ No newline at end of file
diff --git a/core/components/redirector/elements/plugins/plugin.redirector.php b/core/components/redirector/elements/plugins/plugin.redirector.php
index fa7e854..68a2807 100644
--- a/core/components/redirector/elements/plugins/plugin.redirector.php
+++ b/core/components/redirector/elements/plugins/plugin.redirector.php
@@ -2,53 +2,86 @@
 /**
  * @package redirector
  */
+
 /* load redirector class */
 $corePath =  $modx->getOption('redirector.core_path',$scriptProperties,$modx->getOption('core_path').'components/redirector/');
 $redirector = $modx->getService('redirector','Redirector',$corePath.'model/redirector/',$scriptProperties);
 if (!($redirector instanceof Redirector)) return '';
 
-/* handle redirects */
-$search = $_SERVER['REQUEST_URI'];
-$baseUrl = $modx->getOption('base_url',null,MODX_BASE_URL);
-if (!empty($baseUrl) && $baseUrl != '/' && $baseUrl != ' ') {
-    $search = str_replace($baseUrl,'',$search);
-}
-$search = ltrim($search,'/');
-$extPos = strrpos($search, '.');
-if ($extPos) {
-    if ($search) {
-        $redirect = $modx->getObject('modRedirect', array(
-            'pattern' => $search,
-            'active' => 1,
-        ));
-        if ($redirect) {
-            $target = $redirect->get('target');
-            $modx->parser->processElementTags('', $target, true, true);
-            if ($target != $modx->resourceIdentifier && $target != $search) {
-                if (!strpos($target, '://')) {
-                    $target = $modx->getOption('site_url').$target;
+switch ($modx->event->name) {
+    case 'OnPageNotFound':    
+        $search = $_SERVER['REQUEST_URI'];
+        $baseUrl = $modx->getOption('base_url',null,MODX_BASE_URL);
+        if (!empty($baseUrl) && $baseUrl != '/' && $baseUrl != ' ') {
+            $search = str_replace($baseUrl,'',$search);
+        }
+        $search = ltrim($search,'/');
+        $extPos = strrpos($search, '.');
+        if ($extPos) {
+            if ($search) {
+                $redirect = $modx->getObject('modRedirect', array(
+                    'pattern' => $search,
+                    'active' => 1,
+                ));
+                if ($redirect) { 
+                    $target = $redirect->get('target');
+                    $modx->parser->processElementTags('', $target, true, true);
+                    if ($target != $modx->resourceIdentifier && $target != $search) {
+                        if (!strpos($target, '://')) {
+                            $target = $modx->getOption('site_url').$target;
+                        }
+                        $modx->log(modX::LOG_LEVEL_INFO, 'Redirector plugin redirecting request for ' . $search . ' to ' . $target);
+                        header('HTTP/1.1 301 Moved Permanently');
+                        $modx->sendRedirect($target);
+                    }
                 }
-                $modx->log(modX::LOG_LEVEL_INFO, 'Redirector plugin redirecting request for ' . $search . ' to ' . $target);
-                header('HTTP/1.1 301 Moved Permanently');
-                $modx->sendRedirect($target);
             }
+            $search = substr($search, 0, $extPos);
         }
-    }
-    $search = substr($search, 0, $extPos);
-}
-if ($search) {
-    $redirect = $modx->getObject('modRedirect', array('pattern' => $search, 'active' => 1));
-    if ($redirect) {
-        $target = $redirect->get('target');
-        $modx->parser->processElementTags('', $target, true, true);
-        if ($target != $modx->resourceIdentifier && $target != $search) {
-            if (!strpos($target, '://')) {
-                $target = $modx->getOption('site_url').$target;
+        if ($search) {
+            $redirect = $modx->getObject('modRedirect', array('pattern' => $search, 'active' => 1));
+            if ($redirect) {
+                $target = $redirect->get('target');
+                $modx->parser->processElementTags('', $target, true, true);
+                if ($target != $modx->resourceIdentifier && $target != $search) {
+                    if (!strpos($target, '://')) {
+                        $target = $modx->getOption('site_url').$target;
+                    }
+                    $modx->log(modX::LOG_LEVEL_INFO, 'Redirector plugin redirecting request for ' . $search . ' to ' . $target);
+                    header('HTTP/1.1 301 Moved Permanently');
+                    $modx->sendRedirect($target);
+                }
+            }
+        }  
+        break;
+    case 'OnDocFormRender':
+        if ($mode == 'upd')
+            $_SESSION['modx_resource_alias'] = $resource->get('alias');
+        break;
+    case 'OnDocFormSave':
+        /* if alias has changed, add to redirects */  
+        $on_alias_update = $modx->getOption('redirector.on_alias_update',null,'No');
+        $new_alias = $resource->get('alias');
+        
+        if ($mode == 'upd' && $on_alias_update == 'Yes') {            
+            $old_alias = $_SESSION['modx_resource_alias'];            
+            if ($old_alias != $new_alias) {
+                /* alias changed */
+                $redirect = $modx->getObject('modRedirect', array('pattern' => $old_alias, 'active' => 1));  
+                if (empty($redirect)) {
+                    /* no record for old alias */
+                    $new_redirect = $modx->newObject('modRedirect');        
+                    $new_redirect->fromArray(array('pattern' => $old_alias, 'target' => $new_alias, 'active' => 1));
+
+                    if ($new_redirect->save() == false) {
+                        return $modx->error->failure($modx->lexicon('redirector.redirect_err_save'));
+                    }
+                }
             }
-            $modx->log(modX::LOG_LEVEL_INFO, 'Redirector plugin redirecting request for ' . $search . ' to ' . $target);
-            header('HTTP/1.1 301 Moved Permanently');
-            $modx->sendRedirect($target);
         }
-    }
+        
+        $_SESSION['modx_resource_alias'] = $new_alias;
+        break;
 }
+
 return;
\ No newline at end of file
diff --git a/core/components/redirector/model/redirector/metadata.mysql.php b/core/components/redirector/model/redirector/metadata.mysql.php
new file mode 100644
index 0000000..1ce2540
--- /dev/null
+++ b/core/components/redirector/model/redirector/metadata.mysql.php
@@ -0,0 +1,8 @@
+ 
+  array (
+    0 => 'modRedirect',
+  ),
+);
\ No newline at end of file
diff --git a/core/components/redirector/model/redirector/metadata.sqlsrv.php b/core/components/redirector/model/redirector/metadata.sqlsrv.php
new file mode 100644
index 0000000..1ce2540
--- /dev/null
+++ b/core/components/redirector/model/redirector/metadata.sqlsrv.php
@@ -0,0 +1,8 @@
+ 
+  array (
+    0 => 'modRedirect',
+  ),
+);
\ No newline at end of file
diff --git a/core/components/redirector/model/redirector/mysql/modredirect.map.inc.php b/core/components/redirector/model/redirector/mysql/modredirect.map.inc.php
index 26e89b4..0d6ec09 100644
--- a/core/components/redirector/model/redirector/mysql/modredirect.map.inc.php
+++ b/core/components/redirector/model/redirector/mysql/modredirect.map.inc.php
@@ -4,7 +4,9 @@
  */
 $xpdo_meta_map['modRedirect']= array (
   'package' => 'redirector',
+  'version' => NULL,
   'table' => 'redirects',
+  'extends' => 'xPDOSimpleObject',
   'fields' => 
   array (
     'pattern' => '',
diff --git a/core/components/redirector/model/redirector/sqlsrv/modredirect.map.inc.php b/core/components/redirector/model/redirector/sqlsrv/modredirect.map.inc.php
index cc0098d..965b605 100644
--- a/core/components/redirector/model/redirector/sqlsrv/modredirect.map.inc.php
+++ b/core/components/redirector/model/redirector/sqlsrv/modredirect.map.inc.php
@@ -4,7 +4,9 @@
  */
 $xpdo_meta_map['modRedirect']= array (
   'package' => 'redirector',
+  'version' => NULL,
   'table' => 'redirects',
+  'extends' => 'xPDOSimpleObject',
   'fields' => 
   array (
     'pattern' => '',
diff --git a/core/components/redirector/model/schema/redirector.sqlsrv.schema.xml b/core/components/redirector/model/schema/redirector.sqlsrv.schema.xml
index cba3ef4..e3d9c14 100644
--- a/core/components/redirector/model/schema/redirector.sqlsrv.schema.xml
+++ b/core/components/redirector/model/schema/redirector.sqlsrv.schema.xml
@@ -3,6 +3,6 @@
     
         
         
-	    
+        
     
 
\ No newline at end of file

From 89f50af50d9c667f71697f4167ac8c8082d231b5 Mon Sep 17 00:00:00 2001
From: chrischerrett 
Date: Mon, 19 Nov 2012 13:45:56 +0000
Subject: [PATCH 2/8] Added readme.txt for github

---
 readme.txt | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100644 readme.txt

diff --git a/readme.txt b/readme.txt
new file mode 100644
index 0000000..a6ac81e
--- /dev/null
+++ b/readme.txt
@@ -0,0 +1,8 @@
+Forked from https://github.com/splittingred/Redirector
+
+*** Now creates 301 redirect records automatically whenever a resource alias is modified ***
+
+- Modified build.transport.php to support two new events, OnDocFormRender and OnDocFormSave
+- Modified plugin.redirector.php to capture alias prior to save (OnDocFormRender). If the alias has changed and the system settings permit then add a new redirect record (OnDocFormSave)
+- Created new system setting: redirector.on_alias_update (Yes/No)
+- Updated readme.txt
\ No newline at end of file

From 65a7bab1ef23a551c754ed7fea300945629a63b3 Mon Sep 17 00:00:00 2001
From: chrischerrett 
Date: Mon, 19 Nov 2012 15:08:45 +0000
Subject: [PATCH 3/8] readme.txt update

---
 _build/build.transport.php | 4 ++--
 readme.txt                 | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/_build/build.transport.php b/_build/build.transport.php
index eed7ff9..bd4a085 100644
--- a/_build/build.transport.php
+++ b/_build/build.transport.php
@@ -14,8 +14,8 @@
 /* define package names */
 define('PKG_NAME','Redirector');
 define('PKG_NAME_LOWER','redirector');
-define('PKG_VERSION','1.0.3');
-define('PKG_RELEASE','pl');
+define('PKG_VERSION','1.0.4');
+define('PKG_RELEASE','beta');
 
 /* define build paths */
 $root = dirname(dirname(__FILE__)).'/';
diff --git a/readme.txt b/readme.txt
index a6ac81e..1020dcc 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,6 +1,6 @@
-Forked from https://github.com/splittingred/Redirector
+

Create redirect on alias update

-*** Now creates 301 redirect records automatically whenever a resource alias is modified *** +Now creates records automatically whenever a resource alias is modified. Forked from https://github.com/splittingred/Redirector. - Modified build.transport.php to support two new events, OnDocFormRender and OnDocFormSave - Modified plugin.redirector.php to capture alias prior to save (OnDocFormRender). If the alias has changed and the system settings permit then add a new redirect record (OnDocFormSave) From 2156a3acde1065a5230d575ba1556594dedf7c71 Mon Sep 17 00:00:00 2001 From: chrischerrett Date: Mon, 19 Nov 2012 15:09:56 +0000 Subject: [PATCH 4/8] created correct github README --- readme.txt => README | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename readme.txt => README (100%) diff --git a/readme.txt b/README similarity index 100% rename from readme.txt rename to README From 4ce4bedcd1b134636065f3fd352a377928f20730 Mon Sep 17 00:00:00 2001 From: chrischerrett Date: Mon, 19 Nov 2012 15:15:17 +0000 Subject: [PATCH 5/8] readme.md added --- README => README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename README => README.md (52%) diff --git a/README b/README.md similarity index 52% rename from README rename to README.md index 1020dcc..2aacd51 100644 --- a/README +++ b/README.md @@ -1,8 +1,8 @@ -

Create redirect on alias update

+## Create redirect on alias update Now creates records automatically whenever a resource alias is modified. Forked from https://github.com/splittingred/Redirector. -- Modified build.transport.php to support two new events, OnDocFormRender and OnDocFormSave -- Modified plugin.redirector.php to capture alias prior to save (OnDocFormRender). If the alias has changed and the system settings permit then add a new redirect record (OnDocFormSave) -- Created new system setting: redirector.on_alias_update (Yes/No) -- Updated readme.txt \ No newline at end of file +* Modified build.transport.php to support two new events, OnDocFormRender and OnDocFormSave +* Modified plugin.redirector.php to capture alias prior to save (OnDocFormRender). If the alias has changed and the system settings permit then add a new redirect record (OnDocFormSave) +* Created new system setting: redirector.on_alias_update (Yes/No) +* Updated readme.txt \ No newline at end of file From 22cb0005279b11b5e26ad3c8dff60a5f6a4027ba Mon Sep 17 00:00:00 2001 From: chrischerrett Date: Mon, 19 Nov 2012 15:21:12 +0000 Subject: [PATCH 6/8] Modified version to read 1.0.4-beta --- _build/build.transport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_build/build.transport.php b/_build/build.transport.php index bd4a085..205f638 100644 --- a/_build/build.transport.php +++ b/_build/build.transport.php @@ -20,7 +20,7 @@ /* define build paths */ $root = dirname(dirname(__FILE__)).'/'; $sources = array( - 'root' => $root, + 'root' => $root, 'build' => $root . '_build/', 'data' => $root . '_build/data/', 'resolvers' => $root . '_build/resolvers/', From 32fca63c26318fc5f751d56da0ede7bdac44e6a4 Mon Sep 17 00:00:00 2001 From: chrischerrett Date: Tue, 20 Nov 2012 08:29:39 +0000 Subject: [PATCH 7/8] - Previous commits omitted the sample build configs. Reintroduced. - Removed local build configs from repo. - docs/readme.txt entry moved to docs/changelog.txt --- .gitignore | 2 + _build/build.config.php | 20 ---------- _build/build.properties.php | 37 ------------------- core/components/redirector/docs/changelog.txt | 4 ++ core/components/redirector/docs/readme.txt | 4 +- 5 files changed, 7 insertions(+), 60 deletions(-) delete mode 100644 _build/build.config.php delete mode 100644 _build/build.properties.php diff --git a/.gitignore b/.gitignore index 093e541..a4e3d5d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ core.config.php config.core.php .idea nbproject +/_build/build.properties.php +/_build/build.config.php \ No newline at end of file diff --git a/_build/build.config.php b/_build/build.config.php deleted file mode 100644 index 459d682..0000000 --- a/_build/build.config.php +++ /dev/null @@ -1,20 +0,0 @@ - $properties['cache_path'], - xPDO::OPT_HYDRATE_FIELDS => true, - xPDO::OPT_HYDRATE_RELATED_OBJECTS => true, - xPDO::OPT_HYDRATE_ADHOC_FIELDS => true, -); -$properties['mysql_array_driverOptions']= array(); - -/* sqlsrv */ -$properties['sqlsrv_string_dsn_test']= 'sqlsrv:server=(local);database=modx'; -$properties['sqlsrv_string_dsn_nodb']= 'sqlsrv:server=(local)'; -$properties['sqlsrv_string_dsn_error']= 'sqlsrv:server=xyz;123'; -$properties['sqlsrv_string_username']= ''; -$properties['sqlsrv_string_password']= ''; -$properties['sqlsrv_array_options']= array( - xPDO::OPT_CACHE_PATH => $properties['cache_path'], - xPDO::OPT_HYDRATE_FIELDS => true, - xPDO::OPT_HYDRATE_RELATED_OBJECTS => true, - xPDO::OPT_HYDRATE_ADHOC_FIELDS => true, -); -$properties['sqlsrv_array_driverOptions']= array(/*PDO::SQLSRV_ATTR_DIRECT_QUERY => false*/); - -/* PHPUnit test config */ -$properties['xpdo_driver']= 'mysql'; -$properties['logLevel']= xPDO::LOG_LEVEL_INFO; -/* $properties['debug']= -1; */ \ No newline at end of file diff --git a/core/components/redirector/docs/changelog.txt b/core/components/redirector/docs/changelog.txt index 8f1194f..68e6b66 100644 --- a/core/components/redirector/docs/changelog.txt +++ b/core/components/redirector/docs/changelog.txt @@ -1,5 +1,9 @@ Changelog file for Redirector component. +Redirector 1.0.4 (beta) +==================================== +- Redirect created on alias update. Enable/disable via System Settings + Redirector 1.0.3 ==================================== - Add sqlsrv support diff --git a/core/components/redirector/docs/readme.txt b/core/components/redirector/docs/readme.txt index 0de7ad0..7c3e511 100644 --- a/core/components/redirector/docs/readme.txt +++ b/core/components/redirector/docs/readme.txt @@ -5,6 +5,4 @@ Version: 1.0 Since: April 21st, 2010 Author: Shaun McCormick and Jason Coward -Handles 301 redirects for your site. - -**** New feature added by Chris Cherrett : Redirect created on alias update. Enable/disable via System Settings. **** \ No newline at end of file +Handles 301 redirects for your site. \ No newline at end of file From b9ca66565e0a600e853a7c27d26c7c8c33322587 Mon Sep 17 00:00:00 2001 From: chrischerrett Date: Tue, 20 Nov 2012 08:30:36 +0000 Subject: [PATCH 8/8] - Previous commits omitted the sample build configs. Reintroduced. --- _build/build.config.sample.php | 18 +++++++++++++++ _build/build.properties.sample.php | 37 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 _build/build.config.sample.php create mode 100644 _build/build.properties.sample.php diff --git a/_build/build.config.sample.php b/_build/build.config.sample.php new file mode 100644 index 0000000..da5f036 --- /dev/null +++ b/_build/build.config.sample.php @@ -0,0 +1,18 @@ + $properties['cache_path'], + xPDO::OPT_HYDRATE_FIELDS => true, + xPDO::OPT_HYDRATE_RELATED_OBJECTS => true, + xPDO::OPT_HYDRATE_ADHOC_FIELDS => true, +); +$properties['mysql_array_driverOptions']= array(); + +/* sqlsrv */ +$properties['sqlsrv_string_dsn_test']= 'sqlsrv:server=(local);database=modx_modx'; +$properties['sqlsrv_string_dsn_nodb']= 'sqlsrv:server=(local)'; +$properties['sqlsrv_string_dsn_error']= 'sqlsrv:server=xyz;123'; +$properties['sqlsrv_string_username']= ''; +$properties['sqlsrv_string_password']= ''; +$properties['sqlsrv_array_options']= array( + xPDO::OPT_CACHE_PATH => $properties['cache_path'], + xPDO::OPT_HYDRATE_FIELDS => true, + xPDO::OPT_HYDRATE_RELATED_OBJECTS => true, + xPDO::OPT_HYDRATE_ADHOC_FIELDS => true, +); +$properties['sqlsrv_array_driverOptions']= array(/*PDO::SQLSRV_ATTR_DIRECT_QUERY => false*/); + +/* PHPUnit test config */ +$properties['xpdo_driver']= 'mysql'; +$properties['logLevel']= xPDO::LOG_LEVEL_INFO; +/* $properties['debug']= -1; */ \ No newline at end of file