Skip to content

Commit

Permalink
Work on the search and advanced search module
Browse files Browse the repository at this point in the history
  • Loading branch information
alvinBM committed Jan 18, 2024
1 parent fb3532c commit e469922
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 118 deletions.
32 changes: 17 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 50 additions & 60 deletions modules/advanced_search/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,10 @@ protected function output() {
*/
class Hm_Output_advanced_search_content_start extends Hm_Output_Module {
protected function output() {
return '<div class="search_content"><div class="content_title">'.
'<img width="16" height="16" src="'.Hm_Image_Sources::$plus.'" '.
'alt="'.$this->trans('Expand all').'" class="adv_expand_all">'.
'<img width="16" height="16" src="'.Hm_Image_Sources::$minus.'" '.
'alt="'.$this->trans('Expand all').'" class="adv_collapse_all">'.
$this->trans('Advanced Search').'</div>';
return '<div class="search_content px-0"><div class="content_title d-flex align-items-center px-3">'.
'<i class="bi bi-caret-down-fill adv_expand_all cursor-pointer"></i>'.
'<i class="bi bi-caret-up adv_collapse_all cursor-pointer"></i>'.
'<lable class="ms-2">'.$this->trans('Advanced Search').'</label></div>';
}
}

Expand Down Expand Up @@ -223,88 +221,80 @@ protected function output() {
$this->targets().
$this->times().
$this->other().
'<div class="submit_section"><input type="button" id="adv_search" value="'.$this->trans('Search').'" />'.
' <input type="button" class="adv_reset" value="'.$this->trans('Reset').'" />';
'<div class="submit_section px-5"><input type="button" class="btn btn-success" id="adv_search" value="'.$this->trans('Search').'" />'.
' <input class="btn btn-light border" type="button" class="adv_reset" value="'.$this->trans('Reset').'" />';
}

protected function targets() {
return '<div data-target=".targets_section" class="settings_subtitle"><img width="16" height="16" alt="'.
$this->trans('targets').'" src="'.Hm_Image_Sources::$doc.'" />'.$this->trans('Targets').
return '<div data-target=".targets_section" class="settings_subtitle cursor-pointer px-3 py-2 "><i class="bi bi-file-earmark-fill me-2"></i>'.$this->trans('Targets').
'<span class="target_count">'.sprintf($this->trans('targets: %d'), 0).'</span></div>'.
'<div class="targets_section"><table id="adv_target" class="adv_targets"><tr><th>'.
'<input type="radio" value="TEXT" id="adv_msg" class="target_radio" checked="checked" '.
'name="target_type" /><label for="adv_msg">'.$this->trans('Entire message').'</label></th>'.
'<th><input type="radio" class="target_radio" value="BODY" name="target_type" id="adv_body" '.
'/><label for="adv_body">'.$this->trans('Body').'</label></th><td></td></tr><tr><th><input type="radio" '.
'class="target_radio" value="header" id="adv_header_radio" name="target_type" /><label for="adv_header_radio">'.
$this->trans('Header').'</label></th><td>'.'<select class="adv_header_select" ><option value="FROM">'.
'<div class="targets_section mx-5 py-4"><div class="col-lg-6 col-12" id="adv_target"><table class="adv_targets table table-borderless"><tr><th>'.
'<input type="radio" value="TEXT" id="adv_msg" class="target_radio form-check-input" checked="checked" '.
'name="target_type" /><label class="form-check-label ms-2" for="adv_msg">'.$this->trans('Entire message').'</label></th>'.
'<th><input type="radio" class="target_radio form-check-input" value="BODY" name="target_type" id="adv_body" '.
'/><label class="form-check-label ms-2" for="adv_body">'.$this->trans('Body').'</label></th><td></td></tr><tr><th><input type="radio" '.
'class="target_radio form-check-input" value="header" id="adv_header_radio" name="target_type" /><label class="form-check-label ms-2" for="adv_header_radio">'.
$this->trans('Header').'</label></th><td>'.'<select class="adv_header_select form-select" ><option value="FROM">'.
$this->trans('From').'</option><option value="SUBJECT">'.$this->trans('Subject').'</option><option value="TO">'.
$this->trans('To').'</option><option value="CC">'.$this->trans('Cc').'</option></select></td></tr>'.
'<tr><th><input type="radio" class="target_radio" value="custom" id="adv_custom" name="target_type" />'.
'<label for="adv_custom">'.$this->trans('Custom Header').'</label></th><td><input class="adv_custom_header" '.
'type="text" /></td></tr></table><img class="new_target" width="16" height="16" alt="'.$this->trans('Add').
'" src="'.Hm_Image_Sources::$plus.'" /></div>';
'<tr><th><input type="radio" class="target_radio form-check-input" value="custom" id="adv_custom" name="target_type" />'.
'<label class="form-check-label ms-2" for="adv_custom">'.$this->trans('Custom Header').'</label></th><td><input class="adv_custom_header form-control" '.
'type="text" /></td></tr></table></div><i class="bi bi-plus-circle new_target cursor-pointer ms-2"></i></div>';
}

protected function terms() {
return '<div data-target=".terms_section" class="settings_subtitle"><img width="16" height="16" alt="'.
$this->trans('terms').'" src="'.Hm_Image_Sources::$search.'" />'.$this->trans('Terms').
return '<div data-target=".terms_section" class="settings_subtitle cursor-pointer px-3 py-2 mt-3">'.
'<i class="bi bi-search me-2"></i>'.$this->trans('Terms').
'<span class="term_count">'.sprintf($this->trans('terms: %d'), 0).'</span></div>'.
'<div class="terms_section">'.
'<span id="adv_term_not" class="adv_term_nots"><input type="checkbox" value="not" id="adv_term_not" /> !</span>'.
'<input class="adv_terms" id="adv_term" type="text" /><img class="new_term" '.
'width="16" height="16" alt="'.$this->trans('Add').'" src="'.Hm_Image_Sources::$plus.'" /></div>';
'<div class="terms_section mx-5 py-4">'.
'<div class="d-flex align-items-center"><span id="adv_term_not" class="adv_term_nots"><input type="checkbox" class="form-check-input" value="not" id="adv_term_not" /> !</span>'.
'<input class="adv_terms form-control w-auto" id="adv_term" type="text" /><i class="bi bi-plus-circle new_term cursor-pointer ms-3"></i></div></div>';
}

protected function times() {
$from_time = strtotime("-1 year", time());
$from_date = date("Y-m-d", $from_time);
$to_time = strtotime("+1 day", time());
$to_date = date("Y-m-d", $to_time);
return '<div data-target=".time_section" class="settings_subtitle"><img width="16" height="16" alt="'.
$this->trans('time').'" src="'.Hm_Image_Sources::$calendar.'" />'.$this->trans('Time').
return '<div data-target=".time_section" class="settings_subtitle cursor-pointer px-3 py-2 "><i class="bi bi-calendar3-week-fill me-2"></i>'.$this->trans('Time').
'<span class="time_count">'.sprintf($this->trans('time ranges: %d'), 0).'</span></div>'.
'<div class="time_section"><span id="adv_time" class="adv_times">'.$this->trans('From').
' <input class="adv_time_fld_from" type="date" value="'.$this->html_safe($from_date).
'" /> '.$this->trans('To').' <input class="adv_time_fld_to" type="date" value="'.
$this->html_safe($to_date).'" /></span> <img class="new_time" width="16" height="16" alt="'.
$this->trans('Add').'" src="'.Hm_Image_Sources::$plus.'" /></div>';
'<div class="time_section mx-5 py-4"><span id="adv_time" class="adv_times d-flex align-items-center gap-2">'.$this->trans('From').
' <input class="adv_time_fld_from form-control w-auto" type="date" value="'.$this->html_safe($from_date).
'" /> '.$this->trans('To').' <input class="adv_time_fld_to form-control w-auto" type="date" value="'.
$this->html_safe($to_date).'" /></span><i class="bi bi-plus-circle new_time cursor-pointer"></i></div>';
}

protected function sources() {
return '<div data-target=".source_section" class="settings_subtitle"><img width="16" height="16" alt="'.
$this->trans('sources').'" src="'.Hm_Image_Sources::$folder.'" />'.$this->trans('Sources').
return '<div data-target=".source_section" class="settings_subtitle cursor-pointer px-3 py-2 "><i class="bi bi-folder-fill me-2"></i>'.$this->trans('Sources').
'<span class="source_count">'.sprintf($this->trans('sources: %d'), 0).'</span></div>'.
'<div class="source_section">'.$this->trans('IMAP').' <img class="adv_folder_select" width="16" '.
'height="16" alt="'.$this->trans('Add').'" src="'.Hm_Image_Sources::$plus.'" /><br /><div '.
'<div class="source_section mx-5 py-4">'.$this->trans('IMAP').' <i class="bi bi-plus-circle adv_folder_select cursor-pointer"></i><br /><div '.
'class="adv_folder_list"></div><div class="adv_source_list"></div></div>';
}

protected function other() {
return '<div data-target=".other_section" class="settings_subtitle"><img width="16" height="16" alt="'.
$this->trans('other').'" src="'.Hm_Image_Sources::$cog.'" />'.$this->trans('Other').
return '<div data-target=".other_section" class="settings_subtitle cursor-pointer px-3 py-2 "><i class="bi bi-gear-fill me-2"></i>'.$this->trans('Other').
'<span class="other_count">'.sprintf($this->trans('other settings: %d'), 0).'</span></div>'.
'<div class="other_section"><table><tr><th>'.$this->trans('Character set').'</th><td><select class="charset">'.
'<div class="other_section mx-5 py-4"><div class="col-lg-6 col-12"><table class="table table-borderless"><tr><th>'.$this->trans('Character set').'</th><td><select class="charset form-select w-auto">'.
'<option value="">'.$this->trans('Default').'</option><option value="UTF-8">UTF-8</option>'.
'<option value="ASCII">ASCII</option></select></td></tr><tr><th>'.$this->trans('Results per source').'</th>'.
'<td><input type="number" value="100" class="adv_source_limit" /></td></tr><tr><th>'.$this->trans('Flags').'</th><td>'.
'<div class="flags"><input id="adv_flag_read" class="adv_flag" value="SEEN" type="checkbox">'.
'<label for="adv_flag_read">'.$this->trans('Read').
' </label><input id="adv_flag_unread" class="adv_flag" value="UNSEEN" type="checkbox">'.
'<label for="adv_flag_unread">'.$this->trans('Unread').
'<br /></label><input id="adv_flag_answered" class="adv_flag" value="ANSWERED" type="checkbox">'.
'<label for="adv_flag_answered">'.$this->trans('Answered').
'</label><input id="adv_flag_unanswered" class="adv_flag" value="UNANSWERED" type="checkbox">'.
'<label for="adv_flag_unanswered">'.$this->trans('Unanswered').
'<br /></label><input id="adv_flag_flagged" class="adv_flag" value="FLAGGED" type="checkbox">'.
'<label for="adv_flag_flagged">'.$this->trans('Flagged').
'</label><input id="adv_flag_unflagged" class="adv_flag" value="UNFLAGGED" type="checkbox">'.
'<label for="adv_flag_unflagged">'.$this->trans('Unflagged').
'<br /></label><input id="adv_flag_deleted" class="adv_flag" value="DELETED" type="checkbox">'.
'<label for="adv_flag_deleted">'.$this->trans('Deleted').
'</label><input id="adv_flag_undeleted" class="adv_flag" value="UNDELETED" type="checkbox">'.
'<label for="adv_flag_undeleted">'.$this->trans('Not deleted').
'</label></div></td></tr></table></div>';
'<td><input type="number" value="100" class="adv_source_limit form-control" /></td></tr><tr><th>'.$this->trans('Flags').'</th><td>'.
'<div class="flags d-flex flex-column"><div><input id="adv_flag_read" class="adv_flag form-check-input" value="SEEN" type="checkbox">'.
'<label class="form-check-label ms-2" for="adv_flag_read">'.$this->trans('Read').
' </label></div><div><input id="adv_flag_unread" class="adv_flag form-check-input" value="UNSEEN" type="checkbox">'.
'<label class="form-check-label ms-2" for="adv_flag_unread">'.$this->trans('Unread').
'</label></div><div><input id="adv_flag_answered" class="adv_flag form-check-input" value="ANSWERED" type="checkbox">'.
'<label class="form-check-label ms-2" for="adv_flag_answered">'.$this->trans('Answered').
'</label></div><div><input id="adv_flag_unanswered" class="adv_flag form-check-input" value="UNANSWERED" type="checkbox">'.
'<label class="form-check-label ms-2" for="adv_flag_unanswered">'.$this->trans('Unanswered').
'</label></div><div><input id="adv_flag_flagged" class="adv_flag form-check-input" value="FLAGGED" type="checkbox">'.
'<label class="form-check-label ms-2" for="adv_flag_flagged">'.$this->trans('Flagged').
'</label></div><div><input id="adv_flag_unflagged" class="adv_flag form-check-input" value="UNFLAGGED" type="checkbox">'.
'<label class="form-check-label ms-2" for="adv_flag_unflagged">'.$this->trans('Unflagged').
'</label></div><div><input id="adv_flag_deleted" class="adv_flag form-check-input" value="DELETED" type="checkbox">'.
'<label class="form-check-label ms-2" for="adv_flag_deleted">'.$this->trans('Deleted').
'</label></div><div><input id="adv_flag_undeleted" class="adv_flag form-check-input" value="UNDELETED" type="checkbox">'.
'<label class="form-check-label ms-2" for="adv_flag_undeleted">'.$this->trans('Not deleted').
'</label></div></div></td></tr></table></div></div>';
}
}

Expand All @@ -314,7 +304,7 @@ protected function other() {
*/
class Hm_Output_advanced_search_form_end extends Hm_Output_Module {
protected function output() {
return '</div><div class="content_title search_result_title"><img width="16" height="16" src="'.
return '</div><div class="content_title search_result_title mb-3 px-3"><img width="16" height="16" src="'.
Hm_Image_Sources::$env_closed.'" alt="'.$this->trans('Results').
'" class="adv_expand_all">'.$this->trans('Search Results').'</div>'.
'<div class="adv_controls">'.message_controls($this).' '.combined_sort_dialog($this).'</div>'.
Expand Down
10 changes: 0 additions & 10 deletions modules/advanced_search/site.css
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
.targets_section, .other_section, .submit_section, .time_section, .source_section, .terms_section { padding: 20px; padding-left: 60px; margin-bottom: 10px; }
.adv_controls { margin-left: 25px; display: none; }
.targets_section img, .time_section img, .source_section img, .terms_section img { cursor: pointer; margin-left: 10px; vertical-align: -3px; opacity: .4; }
.submit_section { margin-top: 20px; }
.other_section table, .targets_section table { width: 1%; white-space: nowrap; margin-bottom: 5px; }
.other_section th, .targets_section th { vertical-align: top; font-weight: normal; text-align: left; padding: 5px; padding-bottom: 10px; }
.other_section .flags { line-height: 150%; }
.andor { width: 200px; padding: 10px; text-align: center; }
.timeandor { width: 400px; padding: 10px; text-align: center; }
.adv_folder_list { width: 400px; }
.adv_source_list { margin-top: 10px; line-height: 150%; }
.adv_source_list img { margin-right: 10px; }
.adv_collapse_all, .adv_expand_all { margin-right: 10px; opacity: .4; vertical-align: -1px; cursor: pointer; }
.adv_expand_all { display: none; }
#adv_search { cursor: pointer; }
.search_result_title { margin-bottom: 20px; }
.source_count, .time_count, .target_count, .other_count, .term_count { display: none; float: right; margin-right: 30px; }
.imap_support_required { padding: 100px; text-align: center; font-size: 120%; color: #666; }
.adv_reset { margin-left: 20px; cursor: pointer; }
Expand Down
Loading

0 comments on commit e469922

Please sign in to comment.