[*] BO : the global search now looks into the modules

This commit is contained in:
DamienMetzger committed 2012-11-22 17:41:12 +01:00
1 parent d2023a5105
commit 849b96ab9c
3 files changed
+46 -2

No files matched your search

@@ -40,7 +40,7 @@ $(function() {
{else} {else}
<h3>{l s='Features matching your query'} : {$query}</h3> <h3>{l s='Features matching your query'} : {$query}</h3>
<table class="table" cellpadding="0" cellspacing="0"> <table class="table" cellpadding="0" cellspacing="0">
{foreach $features key=key item=feature } {foreach $features key=key item=feature}
{foreach $feature key=k item=val name=feature_list} {foreach $feature key=k item=val name=feature_list}
<tr> <tr>
<th>{if $smarty.foreach.feature_list.first}{$key}{/if}</th> <th>{if $smarty.foreach.feature_list.first}{$key}{/if}</th>
@@ -54,13 +54,29 @@ $(function() {
<div class="clear">&nbsp;</div> <div class="clear">&nbsp;</div>
{/if} {/if}
{/if} {/if}
{if isset($modules)}
{if !$modules}
<h3>{l s='No modules matching your query'} : {$query}</h3>
{else}
<h3>{l s='Modules matching your query'} : {$query}</h3>
<table class="table" cellpadding="0" cellspacing="0">
{foreach $modules key=key item=module}
<tr>
<th><a href="{$module->linkto|escape:'htmlall':'UTF-8'}">{$module->displayName}</a></th>
<td><a href="{$module->linkto|escape:'htmlall':'UTF-8'}">{$module->description}</a></td>
</tr>
{/foreach}
</table>
<div class="clear">&nbsp;</div>
{/if}
{/if}
{if isset($categories)} {if isset($categories)}
{if !$categories} {if !$categories}
<h3>{l s='No categories matching your query'} : {$query}</h3> <h3>{l s='No categories matching your query'} : {$query}</h3>
{else} {else}
<h3>{l s='Categories matching your query'} : {$query}</h3> <h3>{l s='Categories matching your query'} : {$query}</h3>
<table cellspacing="0" cellpadding="0" class="table"> <table cellspacing="0" cellpadding="0" class="table">
{foreach $categories key=key item=category } {foreach $categories key=key item=category}
<tr class="alt_row"> <tr class="alt_row">
<td>{$category}</td> <td>{$category}</td>
</tr> </tr>
@@ -168,6 +168,7 @@
<option value="3" {if {$search_type} == 3} selected="selected" {/if}>{l s='orders'}</option> <option value="3" {if {$search_type} == 3} selected="selected" {/if}>{l s='orders'}</option>
<option value="4" {if {$search_type} == 4} selected="selected" {/if}>{l s='invoices'}</option> <option value="4" {if {$search_type} == 4} selected="selected" {/if}>{l s='invoices'}</option>
<option value="5" {if {$search_type} == 5} selected="selected" {/if}>{l s='carts'}</option> <option value="5" {if {$search_type} == 5} selected="selected" {/if}>{l s='carts'}</option>
<option value="7" {if {$search_type} == 7} selected="selected" {/if}>{l s='modules'}</option>
</select> </select>
<input type="submit" id="bo_search_submit" class="button" value="{l s='Search'}"/> <input type="submit" id="bo_search_submit" class="button" value="{l s='Search'}"/>
</form> </form>
@@ -132,6 +132,17 @@ class AdminSearchControllerCore extends AdminController
} }
/* IP */ /* IP */
// 6 - but it is included in the customer block // 6 - but it is included in the customer block
/* Module search */
if (!$searchType || $searchType == 7)
{
/* Handle module name */
if ($searchType == 7 && Validate::isModuleName($this->query) AND ($module = Module::getInstanceByName($this->query)) && Validate::isLoadedObject($module))
Tools::redirectAdmin('index.php?tab=AdminModules&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name).'&token='.Tools::getAdminTokenLite('AdminModules'));
/* Normal catalog search */
$this->searchModule();
}
} }
$this->display = 'view'; $this->display = 'view';
} }
@@ -168,6 +179,18 @@ class AdminSearchControllerCore extends AdminController
{ {
$this->_list['customers'] = Customer::searchByName($this->query); $this->_list['customers'] = Customer::searchByName($this->query);
} }
public function searchModule()
{
$this->_list['modules'] = array();
$all_modules = Module::getModulesOnDisk(true, true, Context::getContext()->employee->id);
foreach ($all_modules as $module)
if (stripos($module->name, $this->query) || stripos($module->displayName, $this->query) || stripos($module->description, $this->query))
{
$module->linkto = 'index.php?tab=AdminModules&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name).'&token='.Tools::getAdminTokenLite('AdminModules');
$this->_list['modules'][] = $module;
}
}
/** /**
* Search a feature in all store * Search a feature in all store
@@ -360,6 +383,10 @@ class AdminSearchControllerCore extends AdminController
$view = $helper->generateList($this->_list['orders'], $this->fields_list['orders']); $view = $helper->generateList($this->_list['orders'], $this->fields_list['orders']);
$this->tpl_view_vars['orders'] = $view; $this->tpl_view_vars['orders'] = $view;
} }
if (isset($this->_list['modules']))
$this->tpl_view_vars['modules'] = $this->_list['modules'];
return parent::renderView(); return parent::renderView();
} }
} }