From 41e899ee7712a17f4a0a917b7fbdbd9fecacc79d Mon Sep 17 00:00:00 2001 From: KHysiek Date: Thu, 30 Aug 2012 00:27:54 +0300 Subject: [PATCH 1/3] Update core/components/articles/model/articles/articlesrouter.class.php Fixes for Tags and Archives not working in FURL mode when Articles' container is site_start. --- .../model/articles/articlesrouter.class.php | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/core/components/articles/model/articles/articlesrouter.class.php b/core/components/articles/model/articles/articlesrouter.class.php index 4fbca95..4fcafd9 100644 --- a/core/components/articles/model/articles/articlesrouter.class.php +++ b/core/components/articles/model/articles/articlesrouter.class.php @@ -52,17 +52,29 @@ public function route() { /* get resource to redirect to */ $resourceId = false; $prefix = 'arc_'; + $startPageResId = false; + $startPagePrefix = ''; + $startPageId = $this->modx->getOption('site_start'); foreach ($containerIds as $archive) { $archive = explode(':',$archive); $archiveId = $archive[0]; $alias = array_search($archiveId,$this->modx->aliasMap); + if ($alias && ($startPageId == $archiveId)) { + $startPageResId = $archiveId; + if (isset($archive[1])) $startPagePrefix = $archive[1]; + } if ($alias && strpos($search,$alias) !== false) { $search = str_replace($alias,'',$search); $resourceId = $archiveId; if (isset($archive[1])) $prefix = $archive[1]; } } - if (!$resourceId) return false; + if (!$resourceId) { + if ($startPageResId) { + $resourceId = $startPageResId; + $prefix = $startPagePrefix; + } else return false; + } /* figure out archiving */ $params = explode('/', $search); @@ -85,13 +97,21 @@ public function route() { /* normal yyyy/mm/dd or yyyy/mm */ } else { /* set Archivist parameters for date-based archives */ - $_GET[$prefix.'year'] = $params[0]; - if (isset($params[1])) $_GET[$prefix.'month'] = $params[1]; - if (isset($params[2])) $_GET[$prefix.'day'] = $params[2]; + $pyear = $params[0]; + $pmonth = 1; + $pday = 1; + if (isset($params[1])) $pmonth = $params[1]; + if (isset($params[2])) $pday = $params[2]; + if (checkdate($pmonth, $pday, $pyear)) { + $_GET[$prefix.'year'] = $params[0]; + if (isset($params[1])) $_GET[$prefix.'month'] = $params[1]; + if (isset($params[2])) $_GET[$prefix.'day'] = $params[2]; + $result = true; + } else return false; } /* forward */ $this->modx->sendForward($resourceId); return true; } -} +} \ No newline at end of file From ef3b722b20ff481bca7c3ccac7cbc9e4ba94f47a Mon Sep 17 00:00:00 2001 From: KHysiek Date: Thu, 30 Aug 2012 00:31:41 +0300 Subject: [PATCH 2/3] Update core/components/articles/model/articles/articlesrouter.class.php Source beautification --- .../model/articles/articlesrouter.class.php | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/core/components/articles/model/articles/articlesrouter.class.php b/core/components/articles/model/articles/articlesrouter.class.php index 4fcafd9..3c7d016 100644 --- a/core/components/articles/model/articles/articlesrouter.class.php +++ b/core/components/articles/model/articles/articlesrouter.class.php @@ -52,29 +52,29 @@ public function route() { /* get resource to redirect to */ $resourceId = false; $prefix = 'arc_'; - $startPageResId = false; - $startPagePrefix = ''; - $startPageId = $this->modx->getOption('site_start'); + $startPageResId = false; + $startPagePrefix = ''; + $startPageId = $this->modx->getOption('site_start'); foreach ($containerIds as $archive) { $archive = explode(':',$archive); $archiveId = $archive[0]; $alias = array_search($archiveId,$this->modx->aliasMap); - if ($alias && ($startPageId == $archiveId)) { + if ($alias && ($startPageId == $archiveId)) { $startPageResId = $archiveId; if (isset($archive[1])) $startPagePrefix = $archive[1]; - } + } if ($alias && strpos($search,$alias) !== false) { $search = str_replace($alias,'',$search); $resourceId = $archiveId; if (isset($archive[1])) $prefix = $archive[1]; } } - if (!$resourceId) { - if ($startPageResId) { - $resourceId = $startPageResId; - $prefix = $startPagePrefix; - } else return false; - } + if (!$resourceId) { + if ($startPageResId) { + $resourceId = $startPageResId; + $prefix = $startPagePrefix; + } else return false; + } /* figure out archiving */ $params = explode('/', $search); @@ -97,17 +97,16 @@ public function route() { /* normal yyyy/mm/dd or yyyy/mm */ } else { /* set Archivist parameters for date-based archives */ - $pyear = $params[0]; - $pmonth = 1; - $pday = 1; - if (isset($params[1])) $pmonth = $params[1]; - if (isset($params[2])) $pday = $params[2]; - if (checkdate($pmonth, $pday, $pyear)) { + $pyear = $params[0]; + $pmonth = 1; + $pday = 1; + if (isset($params[1])) $pmonth = $params[1]; + if (isset($params[2])) $pday = $params[2]; + if (checkdate($pmonth, $pday, $pyear)) { $_GET[$prefix.'year'] = $params[0]; if (isset($params[1])) $_GET[$prefix.'month'] = $params[1]; if (isset($params[2])) $_GET[$prefix.'day'] = $params[2]; - $result = true; - } else return false; + } else return false; } /* forward */ From f7b55363e12c52ebe825ed68fd57024c0e034ba7 Mon Sep 17 00:00:00 2001 From: KHysiek Date: Thu, 17 Apr 2014 11:19:49 +0200 Subject: [PATCH 3/3] Update articlesrouter.class.php Updater for 1.7.6 --- .../model/articles/articlesrouter.class.php | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/core/components/articles/model/articles/articlesrouter.class.php b/core/components/articles/model/articles/articlesrouter.class.php index 3c7d016..5167da3 100644 --- a/core/components/articles/model/articles/articlesrouter.class.php +++ b/core/components/articles/model/articles/articlesrouter.class.php @@ -18,6 +18,8 @@ * Place, Suite 330, Boston, MA 02111-1307 USA * * @package articles + * + * File updated for 1.7.6 */ class ArticlesRouter { /** @var modX $modx */ @@ -54,38 +56,43 @@ public function route() { $prefix = 'arc_'; $startPageResId = false; $startPagePrefix = ''; - $startPageId = $this->modx->getOption('site_start'); + $startPageId = $this->modx->getOption('site_start'); foreach ($containerIds as $archive) { + if (empty($archive)) continue; $archive = explode(':',$archive); $archiveId = $archive[0]; - $alias = array_search($archiveId,$this->modx->aliasMap); - if ($alias && ($startPageId == $archiveId)) { + + if (method_exists($this->modx->context, 'getResourceURI')) { + $alias = $this->modx->context->getResourceURI($archiveId); + } else { + $alias = is_array($this->modx->aliasMap) ? array_search($archiveId, $this->modx->aliasMap) : ''; + } + if ($alias && $startPageId == $archiveId) { $startPageResId = $archiveId; if (isset($archive[1])) $startPagePrefix = $archive[1]; } - if ($alias && strpos($search,$alias) !== false) { - $search = str_replace($alias,'',$search); + if ($alias && strpos($search, $alias) === 0) { + $search = substr($search, strlen($alias)); $resourceId = $archiveId; if (isset($archive[1])) $prefix = $archive[1]; } } - if (!$resourceId) { - if ($startPageResId) { - $resourceId = $startPageResId; - $prefix = $startPagePrefix; - } else return false; - } - + if (!$resourceId) { + if ($startPageResId) { + $resourceId = $startPageResId; + $prefix = $startPagePrefix; + } else return false; + } /* figure out archiving */ $params = explode('/', $search); if (count($params) < 1) return false; /* tag handling! */ if ($params[0] == 'tags') { - $_GET['tag'] = $params[1]; + $_REQUEST[$prefix.'author'] = $_GET['tag'] = urldecode($params[1]); /* author based */ } else if ($params[0] == 'user' || $params[0] == 'author') { - $_GET[$prefix.'author'] = $params[1]; + $_REQUEST[$prefix.'author'] = $_GET[$prefix.'author'] = urldecode($params[1]); /* numeric "archives/1234" */ } else if ($params[0] == 'archives' && !empty($params[1])) { @@ -97,20 +104,21 @@ public function route() { /* normal yyyy/mm/dd or yyyy/mm */ } else { /* set Archivist parameters for date-based archives */ - $pyear = $params[0]; - $pmonth = 1; - $pday = 1; - if (isset($params[1])) $pmonth = $params[1]; - if (isset($params[2])) $pday = $params[2]; - if (checkdate($pmonth, $pday, $pyear)) { - $_GET[$prefix.'year'] = $params[0]; - if (isset($params[1])) $_GET[$prefix.'month'] = $params[1]; - if (isset($params[2])) $_GET[$prefix.'day'] = $params[2]; - } else return false; + $pyear = $params[0]; + $pmonth = 1; + $pday = 1; + if (isset($params[1])) $pmonth = $params[1]; + if (isset($params[2])) $pday = $params[2]; + if (checkdate($pmonth, $pday, $pyear)) { + $_REQUEST[$prefix.'year'] = $_GET[$prefix.'year'] = $params[0]; + if (isset($params[1])) $_REQUEST[$prefix.'month'] = $_GET[$prefix.'month'] = $params[1]; + if (isset($params[2])) $_REQUEST[$prefix.'day'] = $_GET[$prefix.'day'] = $params[2]; + $result = true; + } else return false; } /* forward */ $this->modx->sendForward($resourceId); return true; } -} \ No newline at end of file +}