adding site_search.php

This commit is contained in:
hyung-hwan 2022-05-27 13:18:21 +00:00
parent 503c02aaac
commit d416ece01e

View File

@ -0,0 +1,222 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<script type="text/javascript" src="<?php print base_url_make('/js/codepot.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/common.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/project.css')?>" />
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/font-awesome.min.css')?>" />
<script type="text/javascript" src="<?php print base_url_make('/js/jquery.min.js')?>"></script>
<script type="text/javascript" src="<?php print base_url_make('/js/jquery-ui.min.js')?>"></script>
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/jquery-ui.css')?>" />
<script type="text/javascript">
var site_url = "<?php print site_url(); ?>";
var initial_needle = "<?php print addslashes($search->needle); ?>";
function render_search_list (json)
{
if (json.status == 'ok')
{
var status = json.status;
var list = $("#site_search_mainarea_result_list");
list.empty (); // empty the list first.
for (i = 0; i < json.results.length; i++)
{
var p = json.results[i];
var li;
if (p.type == 'wiki')
{
li = codepot_sprintf(
'<li><a href="%s/project/home/%s">%s</a> - <a href="%s/wiki/show/%s/%s">%s</a><div>%s</div></li>',
site_url, p.projectid, p.projectid,
site_url, p.projectid, codepot_ascii_to_hex(p.name), codepot_htmlspecialchars(p.name),
codepot_htmlspecialchars(p.partial_text));
}
else if (p.type == 'wiki_attachment')
{
li = codepot_sprintf(
'<li><a href="%s/project/home/%s">%s</a> - <a href="%s/wiki/show/%s/%s">%s</a><div><a href="%s/wiki/attachment/%s/%s/%s">%s</a></div></li>',
site_url, p.projectid, p.projectid,
site_url, p.projectid, codepot_ascii_to_hex(p.wikiname), codepot_htmlspecialchars(p.wikiname),
site_url, p.projectid, codepot_ascii_to_hex(p.wikiname), codepot_ascii_to_hex(p.name), codepot_htmlspecialchars(p.name));
}
else if (p.type == 'issue')
{
li = codepot_sprintf(
'<li><a href="%s/project/home/%s">%s</a> - <a href="%s/issue/show/%s/%s">%s</a><div>%s</div><div>%s</div></li>',
site_url, p.projectid, p.projectid,
site_url, p.projectid, codepot_ascii_to_hex(p.issueid), codepot_htmlspecialchars(p.issueid),
codepot_htmlspecialchars(p.summary),
codepot_htmlspecialchars(p.partial_text));
}
else if (p.type == 'issue_file')
{
li = codepot_sprintf(
'<li><a href="%s/project/home/%s">%s</a> - <a href="%s/issue/show/%s/%s">%s</a> - <a href="%s/issue/file/%s/%s/%s">%s</a><div>%s</div></li>',
site_url, p.projectid, p.projectid,
site_url, p.projectid, codepot_ascii_to_hex(p.issueid), codepot_htmlspecialchars(p.issueid),
site_url, p.projectid, codepot_ascii_to_hex(p.issueid), codepot_ascii_to_hex(p.filename), codepot_htmlspecialchars(p.filename),
codepot_htmlspecialchars(p.partial_text));
}
else if (p.type == 'file_holder')
{
li = codepot_sprintf(
'<li><a href="%s/project/home/%s">%s</a> - %s <a href="%s/file/show/%s/%s">%s</a><div>%s</div></li>',
site_url, p.projectid, p.projectid,
codepot_htmlspecialchars(p.tag),
site_url, p.projectid, codepot_ascii_to_hex(p.name), codepot_htmlspecialchars(p.name),
codepot_htmlspecialchars(p.partial_text));
}
else if (p.type == 'file')
{
li = codepot_sprintf(
'<li><a href="%s/project/home/%s">%s</a> - <a href="%s/file/show/%s/%s">%s</a> - <a href="%s/file/get/%s/%s">%s</a><div>%s</div></li>',
site_url, p.projectid, p.projectid,
site_url, p.projectid, codepot_ascii_to_hex(p.name), codepot_htmlspecialchars(p.name),
site_url, p.projectid, codepot_ascii_to_hex(p.filename), codepot_htmlspecialchars(p.filename),
codepot_htmlspecialchars(p.partial_text));
}
else
{
continue;
}
list.append (li);
}
}
else
{
/* TODO: show error */
}
}
function start_search ()
{
var raw_filter = $('#site_search_form').serialize();
var hex_filter = codepot_ascii_to_hex(raw_filter);
$.ajax({
url: codepot_merge_path("<?php print site_url(); ?>", "/site/enjson_search/" + hex_filter),
dataType: "json",
success: function(data) { render_search_list (data); }
});
}
$(function () {
// Empty the page indicators generated by the server side.
// as i want the next page or the previous page to be loaded dynamically
// without killing the original pagination available.
$("#site_search_mainarea_result_pages").empty();
$("#site_search_mainarea_search_button").button().click (start_search);
$("#site_search_mainarea_search_form").accordion({
collapsible: true,
heightStyle: "content"
});
$("#site_search_scope").change (start_search);
$("#site_search_needle").on('keypress',
function(e) {
if (e.which == 13)
{
start_search();
return false;
}
return true;
}
);
if (initial_needle != '') start_search ();
});
</script>
<title><?php print $this->lang->line('Projects')?></title>
</head>
<body>
<div class="content" id="site_search_content">
<!---------------------------------------------------------------------------->
<?php $this->load->view ('taskbar'); ?>
<!---------------------------------------------------------------------------->
<?php
$this->load->view (
'projectbar',
array (
'banner' => $this->lang->line('Search'),
'page' => array (
'type' => '',
'id' => ''
),
'ctxmenuitems' => array (
/*
array ("project/create", '<i class="fa fa-plus"></i> ' . $this->lang->line('New'), 'site_search_new'),
array ("project/map", $this->lang->line('Graph'), 'site_search_map')
*/
)
)
);
?>
<!---------------------------------------------------------------------------->
<div class="mainarea" id="site_search_mainarea">
<div id="site_search_mainarea_search_form" class="collapsible-box">
<div id="site_search_mainarea_search_form_header" class="collapsible-box-header">
<span><?php print $this->lang->line('Filters'); ?></span>
</div>
<form id="site_search_form" class="collapsible-box-form">
<?php
print form_dropdown('scope',
array(
'all' => $this->lang->line('All'),
'files' => $this->lang->line('Files'),
'issues' => $this->lang->line('Issues'),
'wikis' => $this->lang->line('Wikis')
),
set_value('scope', $search->scope), 'id="site_search_scope"');
print form_input('needle', set_value('needle', $search->needle), 'id="site_search_needle"');
printf ('<a id="site_search_mainarea_search_button" href="#">%s</a>', $this->lang->line('Search'));
?>
</form>
</div>
<div class="result" id="site_search_mainarea_result">
<ul id="site_search_mainarea_result_list"></ul>
</div> <!-- site_search_mainarea_result -->
</div> <!-- site_search_mainarea -->
<div class='codepot-footer-pusher'></div> <!-- for sticky footer -->
</div> <!-- site_search_content -->
<!---------------------------------------------------------------------------->
<?php $this->load->view ('footer'); ?>
<!---------------------------------------------------------------------------->
</body>
</html>