[+] 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:
@@ -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
|
||||
*
|
||||
@@ -597,6 +608,14 @@ class DispatcherCore
|
||||
foreach ($route['params'] as $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')
|
||||
$this->front_controller = self::FC_MODULE;
|
||||
break;
|
||||
|
||||
+5
-1
@@ -306,7 +306,11 @@ class LinkCore
|
||||
$params['module'] = $module;
|
||||
$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)
|
||||
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
|
||||
if ($exclude_filled)
|
||||
{
|
||||
@@ -79,8 +88,11 @@ class MetaCore extends ObjectModel
|
||||
// Add selected page
|
||||
if ($add_page)
|
||||
{
|
||||
$selected_pages[] = $add_page;
|
||||
sort($selected_pages);
|
||||
$name = $add_page;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -167,9 +167,25 @@ class AdminMetaControllerCore extends AdminController
|
||||
public function renderForm()
|
||||
{
|
||||
$files = Meta::getPages(true, ($this->object->page ? $this->object->page : false));
|
||||
$pages = array();
|
||||
foreach ($files as $file)
|
||||
$pages[] = array('page' => $file);
|
||||
$pages = array(
|
||||
'common' => array(
|
||||
'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(
|
||||
'legend' => array(
|
||||
@@ -185,10 +201,17 @@ class AdminMetaControllerCore extends AdminController
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Page:'),
|
||||
'name' => 'page',
|
||||
|
||||
'options' => array(
|
||||
'query' => $pages,
|
||||
'id' => 'page',
|
||||
'name' => 'page',
|
||||
'optiongroup' => array(
|
||||
'label' => 'name',
|
||||
'query' => $pages,
|
||||
),
|
||||
'options' => array(
|
||||
'id' => 'id',
|
||||
'name' => 'page',
|
||||
'query' => 'query',
|
||||
),
|
||||
),
|
||||
'desc' => $this->l('Name of the related page'),
|
||||
'required' => true,
|
||||
|
||||
Reference in New Issue
Block a user