Merge pull request #4197 from rabuzarus/20180110_-_rename_saved_search_button

the "save" button is now 'follow' when searching for tags
This commit is contained in:
Michael Vogel 2018-01-10 20:31:44 +01:00 committed by GitHub
commit 7be65769c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 8 deletions

View file

@ -1034,22 +1034,34 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
} }
/** /**
* search box * Search box.
* *
* @param string $s search query * @param string $s Search query.
* @param string $id html id * @param string $id HTML id
* @param string $url search url * @param string $url Search url.
* @param boolean $savedsearch show save search button * @param bool $save Show save search button.
* @param bool $aside Display the search widgit aside.
*
* @return string Formatted HTML.
*/ */
function search($s, $id = 'search-box', $url = 'search', $save = false, $aside = true) { function search($s, $id = 'search-box', $url = 'search', $save = false, $aside = true)
{
$mode = 'text';
if (strpos($s, '#') === 0) {
$mode = 'tag';
}
$save_label = $mode === 'text' ? t('Save') : t('Follow');
$values = array( $values = array(
'$s' => htmlspecialchars($s), '$s' => htmlspecialchars($s),
'$id' => $id, '$id' => $id,
'$action_url' => $url, '$action_url' => $url,
'$search_label' => t('Search'), '$search_label' => t('Search'),
'$save_label' => t('Save'), '$save_label' => $save_label,
'$savedsearch' => Feature::isEnabled(local_user(),'savedsearch'), '$savedsearch' => Feature::isEnabled(local_user(),'savedsearch'),
'$search_hint' => t('@name, !forum, #tags, content'), '$search_hint' => t('@name, !forum, #tags, content'),
'$mode' => $mode
); );
if (!$aside) { if (!$aside) {

View file

@ -50,7 +50,12 @@ Some parts of this template will be moved by js to other places (see theme.js) -
{{if $savedsearch}} {{if $savedsearch}}
<form id="search-save-form" action="{{$action_url}}" method="get" > <form id="search-save-form" action="{{$action_url}}" method="get" >
<input type="hidden" name="search" value="{{$s}}" /> <input type="hidden" name="search" value="{{$s}}" />
<button class="btn btn-primary btn-sm btn-main pull-right" type="submit" name="save" id="search-save" value="{{$save_label}}"><i class="fa fa-floppy-o fa-2x" aria-hidden="true"></i></button> {{* In dependence of the search content we show different buttons *}}
{{if $mode == "tag"}}
<button class="btn btn-primary btn-sm btn-main pull-right" type="submit" name="save" id="search-save" title="{{$save_label}}" value="{{$save_label}}" data-toggle="tooltip"><i class="fa fa-plus fa-2x" aria-hidden="true"></i></button>
{{else}}
<button class="btn btn-primary btn-sm btn-main pull-right" type="submit" name="save" id="search-save" title="{{$save_label}}" value="{{$save_label}}" data-toggle="tooltip"><i class="fa fa-floppy-o fa-2x" aria-hidden="true"></i></button>
{{/if}}
</form> </form>
{{/if}} {{/if}}
</div> </div>