[+] BO : Module controllers can now create custom rewrite in SEO page
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14950 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
1 parent
6e8d4f587e
commit
3a46ce1a35
4 files changed
+68
-10
No files matched your search
@@ -444,6 +444,17 @@ class DispatcherCore
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a route exists
|
||||||
|
*
|
||||||
|
* @param string $route_id
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasRoute($route_id)
|
||||||
|
{
|
||||||
|
return isset($this->routes[$route_id]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a keyword is written in a route rule
|
* Check if a keyword is written in a route rule
|
||||||
*
|
*
|
||||||
@@ -597,6 +608,14 @@ class DispatcherCore
|
|||||||
foreach ($route['params'] as $k => $v)
|
foreach ($route['params'] as $k => $v)
|
||||||
$_GET[$k] = $v;
|
$_GET[$k] = $v;
|
||||||
|
|
||||||
|
// A patch for module friendly urls
|
||||||
|
if (preg_match('#module-([a-z0-9_-]+)-([a-z0-9]+)$#i', $controller, $m))
|
||||||
|
{
|
||||||
|
$_GET['module'] = $m[1];
|
||||||
|
$_GET['fc'] = 'module';
|
||||||
|
$controller = $m[2];
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_GET['fc']) && $_GET['fc'] == 'module')
|
if (isset($_GET['fc']) && $_GET['fc'] == 'module')
|
||||||
$this->front_controller = self::FC_MODULE;
|
$this->front_controller = self::FC_MODULE;
|
||||||
break;
|
break;
|
||||||
|
|||||||
+5
-1
@@ -306,7 +306,11 @@ class LinkCore
|
|||||||
$params['module'] = $module;
|
$params['module'] = $module;
|
||||||
$params['controller'] = $controller ? $controller : 'default';
|
$params['controller'] = $controller ? $controller : 'default';
|
||||||
|
|
||||||
return $url.Dispatcher::getInstance()->createUrl('module', $params, $this->allow);
|
// If the module has its own route ... just use it !
|
||||||
|
if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller))
|
||||||
|
return $this->getPageLink('module-'.$module.'-'.$controller, $params);
|
||||||
|
else
|
||||||
|
return $url.Dispatcher::getInstance()->createUrl('module', $params, $this->allow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+15
-3
@@ -67,7 +67,16 @@ class MetaCore extends ObjectModel
|
|||||||
|
|
||||||
foreach ($files as $file)
|
foreach ($files as $file)
|
||||||
if (preg_match('/^[a-z0-9_.-]*\.php$/i', $file) && !in_array(strtolower(str_replace('Controller.php', '', $file)), $exlude_pages))
|
if (preg_match('/^[a-z0-9_.-]*\.php$/i', $file) && !in_array(strtolower(str_replace('Controller.php', '', $file)), $exlude_pages))
|
||||||
$selected_pages[] = strtolower(str_replace('Controller.php', '', $file));
|
$selected_pages[strtolower(str_replace('Controller.php', '', $file))] = strtolower(str_replace('Controller.php', '', $file));
|
||||||
|
|
||||||
|
// Add modules controllers to list (this function is cool !)
|
||||||
|
foreach (glob(_PS_MODULE_DIR_.'*/controllers/front/*.php') as $file)
|
||||||
|
{
|
||||||
|
$filename = basename($file, '.php');
|
||||||
|
$module = basename(dirname(dirname(dirname($file))));
|
||||||
|
$selected_pages[$module.' - '.$filename] = 'module-'.$module.'-'.$filename;
|
||||||
|
}
|
||||||
|
|
||||||
// Exclude page already filled
|
// Exclude page already filled
|
||||||
if ($exclude_filled)
|
if ($exclude_filled)
|
||||||
{
|
{
|
||||||
@@ -79,8 +88,11 @@ class MetaCore extends ObjectModel
|
|||||||
// Add selected page
|
// Add selected page
|
||||||
if ($add_page)
|
if ($add_page)
|
||||||
{
|
{
|
||||||
$selected_pages[] = $add_page;
|
$name = $add_page;
|
||||||
sort($selected_pages);
|
if (preg_match('#module-([a-z0-9_-]+)-([a-z0-9]+)$#i', $add_page, $m))
|
||||||
|
$add_page = $m[1].' - '.$m[2];
|
||||||
|
$selected_pages[$add_page] = $name;
|
||||||
|
asort($selected_pages);
|
||||||
}
|
}
|
||||||
return $selected_pages;
|
return $selected_pages;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,9 +167,25 @@ class AdminMetaControllerCore extends AdminController
|
|||||||
public function renderForm()
|
public function renderForm()
|
||||||
{
|
{
|
||||||
$files = Meta::getPages(true, ($this->object->page ? $this->object->page : false));
|
$files = Meta::getPages(true, ($this->object->page ? $this->object->page : false));
|
||||||
$pages = array();
|
$pages = array(
|
||||||
foreach ($files as $file)
|
'common' => array(
|
||||||
$pages[] = array('page' => $file);
|
'name' => $this->l('Default pages'),
|
||||||
|
'query' => array(),
|
||||||
|
),
|
||||||
|
'module' => array(
|
||||||
|
'name' => $this->l('Modules pages'),
|
||||||
|
'query' => array(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($files as $name => $file)
|
||||||
|
{
|
||||||
|
$k = (preg_match('#^module-#', $file)) ? 'module' : 'common';
|
||||||
|
$pages[$k]['query'][] = array(
|
||||||
|
'id' => $file,
|
||||||
|
'page' => $name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$this->fields_form = array(
|
$this->fields_form = array(
|
||||||
'legend' => array(
|
'legend' => array(
|
||||||
@@ -185,10 +201,17 @@ class AdminMetaControllerCore extends AdminController
|
|||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'label' => $this->l('Page:'),
|
'label' => $this->l('Page:'),
|
||||||
'name' => 'page',
|
'name' => 'page',
|
||||||
|
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'query' => $pages,
|
'optiongroup' => array(
|
||||||
'id' => 'page',
|
'label' => 'name',
|
||||||
'name' => 'page',
|
'query' => $pages,
|
||||||
|
),
|
||||||
|
'options' => array(
|
||||||
|
'id' => 'id',
|
||||||
|
'name' => 'page',
|
||||||
|
'query' => 'query',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
'desc' => $this->l('Name of the related page'),
|
'desc' => $this->l('Name of the related page'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
|
|||||||
Reference in new issue
Block a user