2014-08-18 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_ui.php, operation/search_helps.php,
	operation/search_results.php, operation/search_helps.getdata.php,
	general/pandora_help.php: added feature to search into the help
	files, it is in the search bar header.
	
	* operation/search_main.php: fixed the search any term of several
	words separated with whitespaces.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10435 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2014-08-18 14:50:07 +00:00
parent 7b91329e6f
commit 0d003c8840
7 changed files with 196 additions and 12 deletions

View File

@ -1,3 +1,13 @@
2014-08-18 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_ui.php, operation/search_helps.php,
operation/search_results.php, operation/search_helps.getdata.php,
general/pandora_help.php: added feature to search into the help
files, it is in the search bar header.
* operation/search_main.php: fixed the search any term of several
words separated with whitespaces.
2014-08-18 Alejandro Gallardo <alejandro.gallardo@artica.es>
* pandoradb.sql,

View File

@ -38,6 +38,7 @@ if (! isset($_SESSION['id_usuario'])) {
}
$user_language = get_user_language ($_SESSION['id_usuario']);
if (file_exists ('../include/languages/'.$user_language.'.mo')) {
$l10n = new gettext_reader (new CachedFileReader ('../include/languages/'.$user_language.'.mo'));
$l10n->load_tables();
@ -45,6 +46,7 @@ if (file_exists ('../include/languages/'.$user_language.'.mo')) {
/* Possible file locations */
$safe_language = safe_url_extraclean ($user_language, "en");
$safe_id = safe_url_extraclean ($id, "");
$files = array ($config["homedir"]."/include/help/".$safe_language."/help_".$safe_id.".php",
$config["homedir"].ENTERPRISE_DIR."/include/help/".$safe_language."/help_".$safe_id.".php",

View File

@ -0,0 +1,87 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
$searchHelps = true;
$maps = false;
if ($searchHelps) {
$keywords = io_safe_output($config['search_keywords']);
$help_directory = $config['homedir'] . "/include/help";
$user_language = get_user_language ($_SESSION['id_usuario']);
if ($user_language === 'en_GB') {
$user_language = 'en';
}
//Check the language directory help exists.
if (is_dir($help_directory . '/' . $user_language)) {
$helps = array();
$help_directory = $help_directory . '/' . $user_language;
$helps_files = scandir($help_directory);
foreach ($helps_files as $help_file) {
if (strstr($help_file, '.php') !== false) {
$help_id = str_replace(array('help_', '.php'), '', $help_file);
$content = file_get_contents($help_directory . '/' . $help_file);
preg_match('/<h1>(.*)<\/h1>/im', $content, $matchs);
$title = null;
if (!empty($matchs)) {
$title = $matchs[1];
}
//The name is the equal to the file
$content = strip_tags($content);
$count = preg_match_all("/" . $keywords . "/im", $content, $m);
if ($count != 0) {
//Search in the file
if (!empty($title)) {
$helps[$title] = array(
'id' => $help_id,
'count' => $count);
}
else {
$helps[] = array(
'id' => $help_id,
'count' => $count);
}
}
}
}
if (empty($helps)) {
$helps = false;
$totalHelps = 0;
}
else {
$totalHelps = count($helps);
}
}
else {
$totalHelps = 0;
}
}
?>

View File

@ -0,0 +1,61 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
$totalHelps = check_acl($config["id_user"], 0, "IR");
if ($helps === false || !$searchHelps) {
echo "<br><div class='nf'>" . __("Zero results found.") .
sprintf(__('You can find more help in the <a style="text-decoration: underline;" href="%s">Pandora\'s wiki</a>'),
"http://wiki.pandorafms.com/index.php?search=" . $config['search_keywords']) .
"</div>\n";
}
else {
$table->width = "98%";
$table->class = "databox";
$table->size = array();
$table->size[0] = "95%";
$table->size[1] = "5%";
$table->head = array ();
$table->head[0] = __('Name');
$table->head[1] = __('Matches');
$table->align = array ();
$table->align[1] = "center";
$table->data = array ();
foreach ($helps as $iterator => $help) {
if (is_numeric($iterator)) {
$name = $help['id'];
}
else {
$name = $iterator;
}
$table->data[] = array(
"<a href=\"javascript: open_help('" . $help['id'] . "','');\">" . $name . "</a>",
$help['count']
);
}
echo "<br />";
html_print_table ($table);
unset($table);
}
?>

View File

@ -23,6 +23,7 @@ $searchGraphs = check_acl($config["id_user"], 0, "RR");
$searchMaps = check_acl($config["id_user"], 0, "RR");
$searchReports = check_acl ($config["id_user"], 0, "RR");
$searchUsers = check_acl($config['id_user'], 0, "UM");
$searchHelps = true;
echo '<br><div style="margin:auto; width:90%; padding: 10px; background: #fff">';
@ -45,35 +46,39 @@ $table->style[9] = 'font-weight: bold; text-align: center;';
$table->style[10] = 'font-weight: bold; text-align: center;';
$table->style[11] = 'font-weight: bold; text-align: center;';
$table->style[13] = 'font-weight: bold; text-align: center;';
$table->style[15] = 'font-weight: bold; text-align: center;';
$table->data[0][0] = html_print_image ("images/agent.png", true, array ("title" => __('Agents found')));
$table->data[0][1] = "<a href='index.php?search_category=agents&keywords=".$keyword."&head_search_keywords=Search'>" .
$table->data[0][1] = "<a href='index.php?search_category=agents&keywords=" . $config['search_keywords'] . "&head_search_keywords=Search'>" .
sprintf(__("%s Found"), $totalAgents) . "</a>";
$table->data[0][2] = html_print_image ("images/module.png", true, array ("title" => __('Modules found')));
$table->data[0][3] = "<a href='index.php?search_category=modules&keywords=".$keyword."&head_search_keywords=Search'>" .
$table->data[0][3] = "<a href='index.php?search_category=modules&keywords=" . $config['search_keywords'] . "&head_search_keywords=Search'>" .
sprintf(__("%s Found"), $totalModules) . "</a>";
$table->data[0][4] = html_print_image ("images/bell.png", true, array ("title" => __('Alerts found')));
$table->data[0][5] = "<a href='index.php?search_category=alerts&keywords=".$keyword."&head_search_keywords=Search'>" .
$table->data[0][5] = "<a href='index.php?search_category=alerts&keywords=" . $config['search_keywords'] . "&head_search_keywords=Search'>" .
sprintf(__("%s Found"), $totalAlerts) . "</a>";
$table->data[0][6] = html_print_image ("images/input_user.png", true, array ("title" => __('Users found')));
$table->data[0][7] = "<a href='index.php?search_category=users&keywords=".$keyword."&head_search_keywords=Search'>" .
$table->data[0][7] = "<a href='index.php?search_category=users&keywords=" . $config['search_keywords'] . "&head_search_keywords=Search'>" .
sprintf(__("%s Found"), $totalUsers) . "</a>";
$table->data[0][8] = html_print_image ("images/chart_curve.png", true, array ("title" => __('Graphs found')));
$table->data[0][9] = "<a href='index.php?search_category=graphs&keywords=".$keyword."&head_search_keywords=Search'>" .
$table->data[0][9] = "<a href='index.php?search_category=graphs&keywords=" . $config['search_keywords'] . "&head_search_keywords=Search'>" .
sprintf(__("%s Found"), $totalGraphs) . "</a>";
$table->data[0][10] = html_print_image ("images/reporting.png", true, array ("title" => __('Reports found')));
$table->data[0][11] = "<a href='index.php?search_category=reports&keywords=".$keyword."&head_search_keywords=Search'>" .
$table->data[0][11] = "<a href='index.php?search_category=reports&keywords=" . $config['search_keywords'] . "&head_search_keywords=Search'>" .
sprintf(__("%s Found"), $totalReports) . "</a>";
$table->data[0][12] = html_print_image ("images/visual_console_green.png", true, array ("title" => __('Maps found')));
$table->data[0][13] = "<a href='index.php?search_category=maps&keywords=".$keyword."&head_search_keywords=Search'>" .
$table->data[0][13] = "<a href='index.php?search_category=maps&keywords=" . $config['search_keywords'] . "&head_search_keywords=Search'>" .
sprintf(__("%s Found"), $totalMaps) . "</a>";
$table->data[0][14] = html_print_image ("images/help.png", true, array ("title" => __('Helps found')));
$table->data[0][15] = "<a href='index.php?search_category=helps&keywords=" . $config['search_keywords'] . "&head_search_keywords=Search'>" .
sprintf(__("%s Found"), $totalHelps) . "</a>";
html_print_table($table);
if ($searchAgents && $totalAgents > 0) {
echo $list_agents;
echo "<a href='index.php?search_category=agents&keywords=".$keyword."&head_search_keywords=Search'>" .
echo "<a href='index.php?search_category=agents&keywords=" . $config['search_keywords'] . "&head_search_keywords=Search'>" .
sprintf(__('Show %s of %s. View all matches'),
$count_agents_main, $totalAgents) .
"</a>";

View File

@ -24,6 +24,7 @@ $searchAgents = $searchAlerts = $searchModules = check_acl($config['id_user'], 0
$searchUsers = check_acl($config['id_user'], 0, "UM");
$searchMaps = $searchReports = $searchGraphs = check_acl($config["id_user"], 0, "IR");
$searchMain = true;
$searchHelps = true;
$arrayKeywords = explode('&#x20;', $config['search_keywords']);
@ -136,6 +137,16 @@ else {
$modules_tab = '';
}
if ($searchHelps) {
$helps_tab = array('text' => "<a href='index.php?search_category=helps&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
. html_print_image ("images/help_w.png", true,
array ("title" => __('Helps'))) . "</a>",
'active' => $searchTab == "helps");
}
else {
$helps_tab = '';
}
$onheader = array('main' => $main_tab,
'agents' => $agents_tab,
'modules' => $modules_tab,
@ -143,9 +154,12 @@ $onheader = array('main' => $main_tab,
'users' => $users_tab,
'graphs' => $graphs_tab,
'reports' => $reports_tab,
'maps' => $maps_tab);
'maps' => $maps_tab,
'helps' => $helps_tab);
ui_print_page_header (__("Search").": \"".$config['search_keywords']."\"", "images/zoom_mc.png", false, "", false, $onheader);
ui_print_page_header (__("Search") .
": \"" . $config['search_keywords'] . "\"",
"images/zoom_mc.png", false, "", false, $onheader);
$only_count = false;
switch ($searchTab) {
@ -160,6 +174,7 @@ switch ($searchTab) {
require_once('search_reports.getdata.php');
require_once('search_maps.getdata.php');
require_once('search_modules.getdata.php');
require_once('search_helps.getdata.php');
require_once('search_main.php');
break;
@ -191,5 +206,9 @@ switch ($searchTab) {
require_once('search_modules.getdata.php');
require_once('search_modules.php');
break;
case 'helps':
require_once('search_helps.getdata.php');
require_once('search_helps.php');
break;
}
?>