mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 02:55:13 +00:00
comanchify the savedsearch widget
This commit is contained in:
parent
251720bfd3
commit
ed9f108722
5 changed files with 118 additions and 3 deletions
|
@ -15,6 +15,10 @@ The ability to create multiple profiles which are visible only to specific perso
|
||||||
|
|
||||||
Provides the ability to use web page design feaures and create custom webpages from your own content and also to design the pages with page layouts, custom menus, and content blocks.
|
Provides the ability to use web page design feaures and create custom webpages from your own content and also to design the pages with page layouts, custom menus, and content blocks.
|
||||||
|
|
||||||
|
**Private Notes**
|
||||||
|
|
||||||
|
On pages where it is available (your matrix page and personal web pages) provide a "widget" to create and store personal reminders and notes.
|
||||||
|
|
||||||
**Enhanced Photo Albums**
|
**Enhanced Photo Albums**
|
||||||
|
|
||||||
Provides a photo album viewer that is a bit prettier than the normal interface.
|
Provides a photo album viewer that is a bit prettier than the normal interface.
|
||||||
|
|
|
@ -741,6 +741,20 @@ function search($s,$id='search-box',$url='/search',$save = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function searchbox($s,$id='search-box',$url='/search',$save = false) {
|
||||||
|
$a = get_app();
|
||||||
|
$o = '<div id="' . $id . '">';
|
||||||
|
$o .= '<form action="' . z_root() . '/' . $url . '" method="get" >';
|
||||||
|
$o .= '<input type="hidden" name="f" value="" />';
|
||||||
|
$o .= '<input type="text" class="icon-search" name="search" id="search-text" placeholder="" value="' . $s .'" onclick="this.submit();" />';
|
||||||
|
$o .= '<input type="submit" name="submit" id="search-submit" value="' . t('Search') . '" />';
|
||||||
|
if(feature_enabled(local_user(),'savedsearch'))
|
||||||
|
$o .= '<input type="submit" name="searchsave" id="search-save" value="' . t('Save') . '" />';
|
||||||
|
$o .= '</form></div>';
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function valid_email($x){
|
function valid_email($x){
|
||||||
|
|
||||||
if(get_config('system','disable_email_validation'))
|
if(get_config('system','disable_email_validation'))
|
||||||
|
|
|
@ -152,3 +152,86 @@ function widget_notes($arr) {
|
||||||
));
|
));
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function widget_savedsearch($arr) {
|
||||||
|
if((! local_user()) || (! feature_enabled(local_user(),'savedsearch')))
|
||||||
|
return '';
|
||||||
|
|
||||||
|
$a = get_app();
|
||||||
|
|
||||||
|
$search = ((x($_GET,'search')) ? $_GET['search'] : '');
|
||||||
|
|
||||||
|
if(x($_GET,'searchsave') && $search) {
|
||||||
|
$r = q("select * from `term` where `uid` = %d and `type` = %d and `term` = '%s' limit 1",
|
||||||
|
intval(local_user()),
|
||||||
|
intval(TERM_SAVEDSEARCH),
|
||||||
|
dbesc($search)
|
||||||
|
);
|
||||||
|
if(! $r) {
|
||||||
|
q("insert into `term` ( `uid`,`type`,`term` ) values ( %d, %d, '%s') ",
|
||||||
|
intval(local_user()),
|
||||||
|
intval(TERM_SAVEDSEARCH),
|
||||||
|
dbesc($search)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(x($_GET,'searchremove') && $search) {
|
||||||
|
q("delete from `term` where `uid` = %d and `type` = %d and `term` = '%s' limit 1",
|
||||||
|
intval(local_user()),
|
||||||
|
intval(TERM_SAVEDSEARCH),
|
||||||
|
dbesc($search)
|
||||||
|
);
|
||||||
|
$search = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$srchurl = $a->query_string;
|
||||||
|
|
||||||
|
$srchurl = rtrim(preg_replace('/searchsave\=[^\&].*?(\&|$)/is','',$srchurl),'&');
|
||||||
|
$hasq = ((strpos($srchurl,'?') !== false) ? true : false);
|
||||||
|
$srchurl = rtrim(preg_replace('/searchremove\=[^\&].*?(\&|$)/is','',$srchurl),'&');
|
||||||
|
$hasq = ((strpos($srchurl,'?') !== false) ? true : false);
|
||||||
|
|
||||||
|
$srchurl = rtrim(preg_replace('/search\=[^\&].*?(\&|$)/is','',$srchurl),'&');
|
||||||
|
$hasq = ((strpos($srchurl,'?') !== false) ? true : false);
|
||||||
|
|
||||||
|
$o = '';
|
||||||
|
|
||||||
|
$r = q("select `tid`,`term` from `term` WHERE `uid` = %d and `type` = %d ",
|
||||||
|
intval(local_user()),
|
||||||
|
intval(TERM_SAVEDSEARCH)
|
||||||
|
);
|
||||||
|
|
||||||
|
$saved = array();
|
||||||
|
|
||||||
|
if(count($r)) {
|
||||||
|
foreach($r as $rr) {
|
||||||
|
|
||||||
|
$saved[] = array(
|
||||||
|
'id' => $rr['tid'],
|
||||||
|
'term' => $rr['term'],
|
||||||
|
'dellink' => z_root() . '/' . $srchurl . (($hasq) ? '' : '?f=') . '&searchremove=1&search=' . urlencode($rr['term']),
|
||||||
|
'srchlink' => z_root() . '/' . $srchurl . (($hasq) ? '' : '?f=') . '&search=' . urlencode($rr['term']),
|
||||||
|
'displayterm' => htmlspecialchars($rr['term']),
|
||||||
|
'encodedterm' => urlencode($rr['term']),
|
||||||
|
'delete' => t('Remove term'),
|
||||||
|
'selected' => ($search==$rr['term']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$tpl = get_markup_template("saved_searches.tpl");
|
||||||
|
$o = replace_macros($tpl, array(
|
||||||
|
'$title' => t('Saved Searches'),
|
||||||
|
'$add' => t('add'),
|
||||||
|
'$searchbox' => searchbox('','netsearch-box',$srchurl . (($hasq) ? '' : '?f='),true),
|
||||||
|
'$saved' => $saved,
|
||||||
|
));
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ function network_init(&$a) {
|
||||||
$search = ((x($_GET,'search')) ? $_GET['search'] : '');
|
$search = ((x($_GET,'search')) ? $_GET['search'] : '');
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
if(x($_GET,'save') && $search) {
|
if(x($_GET,'save') && $search) {
|
||||||
$r = q("select * from `term` where `uid` = %d and `type` = %d and `term` = '%s' limit 1",
|
$r = q("select * from `term` where `uid` = %d and `type` = %d and `term` = '%s' limit 1",
|
||||||
intval(local_user()),
|
intval(local_user()),
|
||||||
|
@ -46,13 +46,13 @@ function network_init(&$a) {
|
||||||
dbesc($search)
|
dbesc($search)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
require_once('include/widgets.php');
|
require_once('include/widgets.php');
|
||||||
|
|
||||||
$a->set_widget('collections',widget_collections(array()));
|
$a->set_widget('collections',widget_collections(array()));
|
||||||
$a->set_widget('archives',posted_date_widget($a->get_baseurl() . '/network',local_user(),false));
|
$a->set_widget('archives',posted_date_widget($a->get_baseurl() . '/network',local_user(),false));
|
||||||
$a->set_widget('suggestions',widget_suggestions(array()));
|
$a->set_widget('suggestions',widget_suggestions(array()));
|
||||||
$a->set_widget('savedsearch',saved_searches($search));
|
$a->set_widget('savedsearch',widget_savedsearch(array()));
|
||||||
$a->set_widget('filer',fileas_widget($a->get_baseurl(true) . '/network',(x($_GET, 'file') ? $_GET['file'] : '')));
|
$a->set_widget('filer',fileas_widget($a->get_baseurl(true) . '/network',(x($_GET, 'file') ? $_GET['file'] : '')));
|
||||||
$a->set_widget('notes',widget_notes(array()));
|
$a->set_widget('notes',widget_notes(array()));
|
||||||
|
|
||||||
|
|
14
view/tpl/saved_searches.tpl
Normal file
14
view/tpl/saved_searches.tpl
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<div class="widget" id="saved-search-list">
|
||||||
|
<h3 id="search">{{$title}}</h3>
|
||||||
|
{{$searchbox}}
|
||||||
|
|
||||||
|
<ul id="saved-search-ul">
|
||||||
|
{{foreach $saved as $search}}
|
||||||
|
<li id="search-term-{{$search.id}}" class="saved-search-li clear">
|
||||||
|
<a title="{{$search.delete}}" onclick="return confirmDelete();" id="drop-saved-search-term-{{$search.id}}" href="{{$search.dellink}}"><i id="dropicon-saved-search-term-{{$search.id}}" class="icon-remove drop-icons iconspacer savedsearchdrop" ></i></a>
|
||||||
|
<a id="saved-search-term-{{$search.id}}" class="savedsearchterm{{if $search.selected}} search-selected{{/if}}" href="{{$search.srchlink}}">{{$search.displayterm}}</a>
|
||||||
|
</li>
|
||||||
|
{{/foreach}}
|
||||||
|
</ul>
|
||||||
|
<div class="clear"></div>
|
||||||
|
</div>
|
Loading…
Reference in a new issue