diff --git a/class2.php b/class2.php
index d393169e7..2559e482f 100755
--- a/class2.php
+++ b/class2.php
@@ -1712,6 +1712,20 @@ if(!isset($_E107['no_online']))
}
$dbg->logTime('(After Go online)');
+$dbg->logTime('Frontpage detection');
+
+$fpUrl = str_replace(SITEURL, '', rtrim(e_REQUEST_URL, '?/'));
+$fpPref = e107::getFrontpage();
+
+if($fpUrl === $fpPref)
+{
+ e107::canonical('_SITEURL_');
+}
+unset($fpUrl, $fpPref);
+
+
+
+
/**
* Set Cookie
diff --git a/e107_admin/frontpage.php b/e107_admin/frontpage.php
index a0f719bb3..96f1884aa 100644
--- a/e107_admin/frontpage.php
+++ b/e107_admin/frontpage.php
@@ -32,7 +32,7 @@ $mes = e107::getMessage();
$frontPref = e107::pref('core'); // Get prefs
// Get list of possible options for front page
-
+ $front_page = array();
// Welcome message is 'hardcoded' intentionally
$front_page['wmessage'] = array(
'page' => 'index.php',
@@ -91,10 +91,10 @@ if(is_array($frontPref['frontpage']))
$i = 1;
foreach($frontPref['frontpage'] as $class => $val)
{
- if($class == 'all')
+ if($class == 'all' || $class === 0)
{
$class = e_UC_PUBLIC;
- $gotpub = TRUE;
+ $gotpub = true;
}
if($val)
{ // Only add non-null pages
diff --git a/e107_core/controllers/index/index.php b/e107_core/controllers/index/index.php
index 2a3f37e69..5e53ccf9f 100644
--- a/e107_core/controllers/index/index.php
+++ b/e107_core/controllers/index/index.php
@@ -25,9 +25,8 @@ class core_index_index_controller extends eController
* - http://NotMysite.com/someurl/ (redirect) - really not sure who'd need that...
* @throws eException
*/
- public function actionIndex()
- {
- $pref = eFront::app()->getPref();
+ public function actionIndex($fpref =null) // used for testing.
+ {
$tp = e107::getParser();
$indexRoute = 'index/index/index';
@@ -36,71 +35,17 @@ class core_index_index_controller extends eController
include (e_BASE.'index_include.php');
}
- $location = '';
- $class_list = explode(',', USERCLASS_LIST);
+ $location = e107::getFrontpage();
- if (isset($pref['frontpage']['all']) && $pref['frontpage']['all'])
- { // 0.7 method
- $location = $pref['frontpage']['all'];
- }
- else
- { // This is the 'new' method - assumes $pref['frontpage'] is an ordered list of rules
- if(!empty($pref['frontpage']))
- {
- foreach ($pref['frontpage'] as $fk=>$fp)
- {
- if (in_array($fk, $class_list))
- {
- $location = $fp;
- break;
- }
- }
- }
- }
-
- if (!$location)
- { // Try and use the 'old' method (this bit can go later)
- if (ADMIN)
- {
- $location = $pref['frontpage'][e_UC_ADMIN];
- }
- elseif (USER)
- { // This is the key bit - what to do for a 'normal' logged in user
- // We have USERCLASS_LIST - comma separated. Also e_CLASS_REGEXP
- $inclass = false;
- foreach ($class_list as $fp_class)
- {
- if (!$inclass && check_class($fp_class['userclass_id']))
- {
- $location = $pref['frontpage'][$fp_class['userclass_id']];
- $inclass = true;
- }
- }
- $location = $location ? $location : $pref['frontpage'][e_UC_MEMBER];
- }
- else
- {
- $location = $pref['frontpage'][e_UC_GUEST];
- }
- }
-
- $location = trim($location);
- $request = $this->getRequest();
-
- // Defaults to news
- if(!$location) $location = 'url:/news';
- // Former Welcome Message front-page. Should be handled by current theme layout
- elseif($location == 'index.php' || $location == 'url:/' || $location == 'route:/' || $location == '/')
+ if($location === false)
{
define('e_FRONTPAGE', true);
$this->_forward('front');
return;
}
- elseif($location[0] === '{')
- {
- $location = $tp->replaceConstants($location, true);
- }
+
+ $request = $this->getRequest();
// new url format; if set to 'url:' only it'll resolve current main module (if any)
if(strpos($location, 'url:') === 0)
{
@@ -153,13 +98,16 @@ class core_index_index_controller extends eController
elseif(strpos($location, '.php') !== false)
{
list($page, $qstr) = explode("?", $location."?");
-
$request->setLegacyPage($page)
->setLegacyQstring($qstr);
$request->routed = true;
define('e_FRONTPAGE', true);
+ define('e_URL_LEGACY', $location);
+
eFront::isLegacy('{e_BASE}'.$page);
+ e107::canonical('_SITEURL_');
+
return;
}
// Redirect
@@ -183,4 +131,5 @@ class core_index_index_controller extends eController
// switch off tablerender
$this->getResponse()->setParam('render', false);
}
+
}
diff --git a/e107_core/shortcodes/single/wmessage.php b/e107_core/shortcodes/single/wmessage.php
index 724d9498a..8332c492c 100644
--- a/e107_core/shortcodes/single/wmessage.php
+++ b/e107_core/shortcodes/single/wmessage.php
@@ -20,11 +20,11 @@ function wmessage_shortcode($parm='')
// return;
}
*/
-
+ $front_qry = '';
if ($parm != 'force')
{
$full_url = 'news.php'; // Set a default in case
- $front_qry = '';
+
$uc_array = explode(',', USERCLASS_LIST);
if(varset($pref['frontpage']))
{
@@ -112,4 +112,3 @@ function wmessage_shortcode($parm='')
}
}
}
-?>
\ No newline at end of file
diff --git a/e107_handlers/application.php b/e107_handlers/application.php
index cf0d0d79b..5044351ce 100644
--- a/e107_handlers/application.php
+++ b/e107_handlers/application.php
@@ -106,6 +106,12 @@ class e_url
$pref = e107::getPref();
$tp = e107::getParser();
+ if(empty($this->_request)) // likely 'index.php' ie. the home page.
+ {
+ $this->_request = e107::getFrontPage();
+ e107::canonical('_SITEURL_');
+ }
+
if(empty($this->_config) || empty($this->_request) || $this->_request === 'index.php' || $this->isLegacy() === true)
{
return false;
@@ -187,6 +193,18 @@ class e_url
{
define('e_PAGE', basename($file));
}
+
+
+ $fpUrl = str_replace(SITEURL, '', rtrim(e_REQUEST_URL, '?/'));
+ $fpPref = e107::getFrontpage();
+
+ if($fpUrl === $fpPref)
+ {
+
+ }
+ unset($fpUrl, $fpPref);
+
+
$this->_include= $file;
return true;
// exit;
@@ -1255,6 +1273,7 @@ class eRouter
{
$f = e107::getFile();
$ret = array('core' => array(), 'plugin' => array(), 'override' => array());
+ $plugins = array();
if($type == 'all' || $type = 'core')
{
diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php
index e22e5a590..ccdaf79d6 100644
--- a/e107_handlers/e107_class.php
+++ b/e107_handlers/e107_class.php
@@ -361,6 +361,83 @@ class e107
}
}
+ /**
+ * Returns the frontpage setting (ie. selected in e107_admin/frontpage.php) for the current user.
+ * @return string
+ */
+ public static function getFrontpage()
+ {
+
+ $fpref = e107::getPref('frontpage');
+ $location = '';
+ $class_list = explode(',', USERCLASS_LIST);
+
+ if(isset($fpref['all']) && $fpref['all'])
+ { // 0.7 method
+ $location = $fpref['all'];
+ }
+ else
+ { // This is the 'new' method - assumes $fpref is an ordered list of rules
+ if(!empty($fpref))
+ {
+ foreach($fpref as $fk => $fp)
+ {
+ if(in_array($fk, $class_list))
+ {
+ $location = $fp;
+ break;
+ }
+ }
+ }
+ }
+
+ if(!$location)
+ { // Try and use the 'old' method (this bit can go later)
+ if(ADMIN)
+ {
+ $location = $fpref[e_UC_ADMIN];
+ }
+ elseif(USER)
+ { // This is the key bit - what to do for a 'normal' logged in user
+ // We have USERCLASS_LIST - comma separated. Also e_CLASS_REGEXP
+ $inclass = false;
+ foreach($class_list as $fp_class)
+ {
+ if(!$inclass && check_class($fp_class['userclass_id']))
+ {
+ $location = $fpref[$fp_class['userclass_id']];
+ $inclass = true;
+ }
+ }
+ $location = $location ? $location : $fpref[e_UC_MEMBER];
+ }
+ else
+ {
+ $location = $fpref[e_UC_GUEST];
+ }
+ }
+
+ $location = trim($location);
+
+
+ // Defaults to news
+ if(!$location)
+ {
+ $location = 'url:/news';
+ }
+ // Former Welcome Message front-page. Should be handled by current theme layout
+ elseif($location == 'index.php' || $location == 'url:/' || $location == 'route:/' || $location == '/')
+ {
+ $location = false;
+ }
+ elseif($location[0] === '{')
+ {
+ $location = e107::getParser()->replaceConstants($location, true);
+ }
+
+ return $location;
+ }
+
/**
* Cloning is not allowed
*
@@ -3771,7 +3848,7 @@ class e107
/**
* Quick method to set alias - uses e107::url format.
- * @param string $plugin if empty will return the last assigned canonical url.
+ * @param string $plugin if empty will return the last assigned canonical url._SITEURL_ will set canonical to the SITEURL.
* @param string|array $key
* @param array $row
*/
@@ -3785,21 +3862,35 @@ class e107
return $alreadyDone;
}
- if(empty($alreadyDone) && $url = e107::url($plugin, $key, $row, array('mode' => 'full')))
+ if(empty($alreadyDone))
{
- self::getJs()->addLink(array('rel'=>"canonical", "href" => $url));
- e107::setRegistry('core/e107/canonical', $url);
+ if($plugin === '_SITEURL_')
+ {
+ $url = SITEURL;
+ }
+ else
+ {
+ $url = e107::url($plugin, $key, $row, array('mode' => 'full'));
+ }
+
+ if(!empty($url))
+ {
+ self::getJs()->addLink(array('rel'=>"canonical", "href" => $url));
+ e107::setRegistry('core/e107/canonical', $url);
+ $message = "Debug: Setting Canonical URL: ".$url."";
+ }
+
}
if(!empty($alreadyDone))
{
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
- $url = "More than one canonical was set: ".print_a($backtrace[1], true);
+ $message = "Debug: More than one canonical was attempted. This was ignored: ".print_a($backtrace[1], true);
}
- if(deftrue('e_DEBUG_CANONICAL'))
+ if(deftrue('e_DEBUG_CANONICAL') && !empty($message))
{
- self::getMessage()->addInfo("Debug Canonical URL: ".$url."");
+ self::getMessage()->addInfo($message);
}
}
diff --git a/e107_plugins/page/e_frontpage.php b/e107_plugins/page/e_frontpage.php
index cdcfb8aff..d7bca9970 100644
--- a/e107_plugins/page/e_frontpage.php
+++ b/e107_plugins/page/e_frontpage.php
@@ -21,14 +21,31 @@ class page_frontpage // include plugin-folder in the name.
$sql = e107::getDb();
$config = array();
+ // require_once(e_PLUGIN."page/includes/pageHelper.php");
+
// Retrieve all custom pages
- if($sql->select('page', 'page_id, page_title, page_sef', "menu_name IS NULL OR menu_name=''"))
+ if($sql->select('page', 'page_id, page_title, page_sef, page_chapter', "menu_name IS NULL OR menu_name=''"))
{
$config['title'] = FRTLAN_30;
while($row = $sql->fetch())
{
- $config['page'][] = array('page' => 'page.php?'.$row['page_id'], 'title' => $row['page_title']); // TODO SEF URL
+ /*if(!empty($row['page_chapter']))
+ {
+ pageHelper::addSefFields($row, 'page_chapter');
+ $url = e107::url('page/view', $row);
+ }
+ else
+ {
+ $url = e107::url('page/view/other', $row);
+ }*/
+
+ /**
+ * Do NOT add SEF to the 'page' value below.
+ * XXX legacy URL method uses page.php?x to 'include' the file on the frontpage.
+ * XXX Switching to sef will cause a redirect on SITEURL to the SEF url instead.
+ */
+ $config['page'][] = array('page' => 'page.php?'.$row['page_id'], 'title' => $row['page_title']);
}
}