1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 14:46:56 +02:00

Issue #4352 Added canonical for home page and frontpage setting.

This commit is contained in:
Cameron
2021-01-19 13:31:20 -08:00
parent f091709847
commit e57b1a9b61
7 changed files with 166 additions and 77 deletions

View File

@@ -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);
}
}