Skip to content

Commit

Permalink
Added useful configurations for the search reports
Browse files Browse the repository at this point in the history
  • Loading branch information
rasseljandavid committed Dec 9, 2011
1 parent 470b5fc commit 0cc39f7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
Expand Up @@ -41,6 +41,7 @@
<li><a href="#tab11"><em>{"Error Messages"|gettext}</em></a></li> <li><a href="#tab11"><em>{"Error Messages"|gettext}</em></a></li>
<li><a href="#tab12"><em>{"PDF Generation"|gettext}</em></a></li> <li><a href="#tab12"><em>{"PDF Generation"|gettext}</em></a></li>
<li><a href="#tab13"><em>{"Minify"|gettext}</em></a></li> <li><a href="#tab13"><em>{"Minify"|gettext}</em></a></li>
<li><a href="#tab14"><em>{"Search Report"|gettext}</em></a></li>
{/if} {/if}
</ul> </ul>
<div class="yui-content"> <div class="yui-content">
Expand Down Expand Up @@ -222,8 +223,15 @@
{control type="text" name="sc[MINIFY_MAX_FILES]" label='Maximum # of files that can be specified in the \'f\' GET parameter'|gettext value=$smarty.const.MINIFY_MAX_FILES} {control type="text" name="sc[MINIFY_MAX_FILES]" label='Maximum # of files that can be specified in the \'f\' GET parameter'|gettext value=$smarty.const.MINIFY_MAX_FILES}
{control type="text" name="sc[MINIFY_URL_LENGTH]" label="The length of minification url"|gettext value=$smarty.const.MINIFY_URL_LENGTH} {control type="text" name="sc[MINIFY_URL_LENGTH]" label="The length of minification url"|gettext value=$smarty.const.MINIFY_URL_LENGTH}
{control type="checkbox" postfalse=1 name="sc[MINIFY_ERROR_LOGGER]" label="Enable logging of minify error messages to FirePHP?"|gettext checked=$smarty.const.MINIFY_ERROR_LOGGER value=1} {control type="checkbox" postfalse=1 name="sc[MINIFY_ERROR_LOGGER]" label="Enable logging of minify error messages to FirePHP?"|gettext checked=$smarty.const.MINIFY_ERROR_LOGGER value=1}

</div> </div>

<div id="tab14">
<h2>{"Search Report Configuration"|gettext}</h2>

{control type="text" name="sc[TOP_SEARCH]" label="Number of Top Search Queries"|gettext value=$smarty.const.TOP_SEARCH}
{control type="checkbox" postfalse=1 name="sc[INCLUDE_AJAX_SEARCH]" label="Include ajax search in reports?"|gettext checked=$smarty.const.INCLUDE_AJAX_SEARCH value=1}
{control type="checkbox" postfalse=1 name="sc[INCLUDE_ANONYMOUS_SEARCH]" label="Include unregistered users search?"|gettext checked=$smarty.const.INCLUDE_ANONYMOUS_SEARCH value=1}
</div>
{/if} {/if}
</div> </div>
</div> </div>
Expand Down
10 changes: 6 additions & 4 deletions framework/modules/ecommerce/controllers/storeController.php
Expand Up @@ -1158,10 +1158,12 @@ function search_by_model() {
public function search() { public function search() {
global $db, $user; global $db, $user;


$qry = trim($this->params['query']); if(INCLUDE_AJAX_SEARCH == 1) {
if(!empty($qry)) { $qry = trim($this->params['query']);
$search = new search(); if(!empty($qry)) {
$r = $search->getSearchResults($this->params['query']); $search = new search();
$r = $search->getSearchResults($this->params['query']);
}
} }
//$this->params['query'] = str_ireplace('-','\-',$this->params['query']); //$this->params['query'] = str_ireplace('-','\-',$this->params['query']);
$terms = explode(" ",$this->params['query']); $terms = explode(" ",$this->params['query']);
Expand Down
10 changes: 8 additions & 2 deletions framework/modules/search/controllers/searchController.php
Expand Up @@ -200,11 +200,17 @@ public function searchQueryReport() {


public function topSearchReport() { public function topSearchReport() {
global $db; global $db;
$limit = TOP_SEARCH;

if(empty($limit)) {
$limit = 10;
}

$count = $db->countObjects('search_queries'); $count = $db->countObjects('search_queries');


$records = $db->selectObjectsBySql("SELECT COUNT(query) cnt, query FROM " .DB_TABLE_PREFIX . "_search_queries GROUP BY query ORDER BY cnt DESC LIMIT 0, 10"); $records = $db->selectObjectsBySql("SELECT COUNT(query) cnt, query FROM " .DB_TABLE_PREFIX . "_search_queries GROUP BY query ORDER BY cnt DESC LIMIT 0, {$limit}");


assign_to_template(array('records'=>$records, 'total'=>$count)); assign_to_template(array('records'=>$records, 'total'=>$count, 'limit' => $limit));
} }




Expand Down
15 changes: 9 additions & 6 deletions framework/modules/search/models/search.php
Expand Up @@ -36,12 +36,15 @@ public function getSearchResults($terms) {


if (SAVE_SEARCH_QUERIES) if (SAVE_SEARCH_QUERIES)
{ {
$queryObj = new stdClass();
$queryObj->user_id = $user->id; if(INCLUDE_ANONYMOUS_SEARCH == 1 || $user->id <> 0) {
$queryObj->query = $terms; $queryObj = new stdClass();
$queryObj->timestamp = time(); $queryObj->user_id = $user->id;

$queryObj->query = $terms;
$db->insertObject($queryObj, 'search_queries'); $queryObj->timestamp = time();

$db->insertObject($queryObj, 'search_queries');
}
} }


//setup the sql query //setup the sql query
Expand Down
4 changes: 2 additions & 2 deletions framework/modules/search/views/search/topSearchReport.tpl
Expand Up @@ -21,7 +21,7 @@
<div class="module topsearchquery report"> <div class="module topsearchquery report">
<div class="info-header"> <div class="info-header">


<h1>{$moduletitle|default:"Top 10 Search Queries Report"|gettext}</h1> <h1>{$moduletitle|default:"Top `$limit` Search Queries Report"|gettext}</h1>
</div> </div>


<table class="exp-skin-table"> <table class="exp-skin-table">
Expand All @@ -37,7 +37,7 @@
<tr class="{cycle values='odd,even'}"> <tr class="{cycle values='odd,even'}">
<td>{counter}</td> <td>{counter}</td>
<td>{$query->query}</td> <td>{$query->query}</td>
<td>{(($query->cnt / $total)*100)|number_format:2}</td> <td>{(($query->cnt / $total)*100)|number_format:2} %</td>
</tr> </tr>
{foreachelse} {foreachelse}
<td colspan="3">No Search Query Data</td> <td colspan="3">No Search Query Data</td>
Expand Down

0 comments on commit 0cc39f7

Please sign in to comment.