1
0
Fork 0

saved searches on network page

This commit is contained in:
Friendika 2011-09-04 17:35:06 -07:00
parent f6a43afb8d
commit 481853d2cc
8 changed files with 108 additions and 7 deletions

View file

@ -7,9 +7,9 @@ require_once('include/text.php');
require_once("include/pgettext.php"); require_once("include/pgettext.php");
define ( 'FRIENDIKA_VERSION', '2.2.1092' ); define ( 'FRIENDIKA_VERSION', '2.2.1093' );
define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
define ( 'DB_UPDATE_VERSION', 1085 ); define ( 'DB_UPDATE_VERSION', 1086 );
define ( 'EOL', "<br />\r\n" ); define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );

View file

@ -613,3 +613,11 @@ CREATE TABLE IF NOT EXISTS `deliverq` (
`item` INT NOT NULL , `item` INT NOT NULL ,
`contact` INT NOT NULL `contact` INT NOT NULL
) ENGINE = MyISAM DEFAULT CHARSET=utf8; ) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `search` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`uid` INT NOT NULL ,
`term` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
INDEX ( `uid` ),
INDEX ( `term` )
) ENGINE = MyISAM DEFAULT CHARSET=utf8;

View file

@ -170,7 +170,7 @@ EOT;
$selected = (($group_id == $rr['id']) ? ' class="group-selected" ' : ''); $selected = (($group_id == $rr['id']) ? ' class="group-selected" ' : '');
$o .= ' <li class="sidebar-group-li">' $o .= ' <li class="sidebar-group-li">'
. (($edit) ? "<a href=\"group/{$rr['id']}\" title=\"" . t('Edit') . (($edit) ? "<a href=\"group/{$rr['id']}\" title=\"" . t('Edit')
. "\" ><img src=\"images/spencil.gif\" alt=\"" . t('Edit') . "\"></a> " : "") . "\" class=\"groupsideedit\" ><img src=\"images/spencil.gif\" alt=\"" . t('Edit') . "\"></a> " : "")
. (($cid) ? '<input type="checkbox" class="' . (($selected) ? 'ticked' : 'unticked') . '" onclick="contactgroupChangeMember(' . $rr['id'] . ',' . $cid . ');return true;" ' . (($cid) ? '<input type="checkbox" class="' . (($selected) ? 'ticked' : 'unticked') . '" onclick="contactgroupChangeMember(' . $rr['id'] . ',' . $cid . ');return true;" '
. ((in_array($rr['id'],$member_of)) ? ' checked="checked" ' : '') . '/>' : '') . ((in_array($rr['id'],$member_of)) ? ' checked="checked" ' : '') . '/>' : '')
. "<a href=\"$each/{$rr['id']}\" class=\"sidebar-group-element\" $selected >{$rr['name']}</a></li>\r\n"; . "<a href=\"$each/{$rr['id']}\" class=\"sidebar-group-element\" $selected >{$rr['name']}</a></li>\r\n";

View file

@ -602,12 +602,14 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
if(! function_exists('search')) { if(! function_exists('search')) {
function search($s,$id='search-box',$url='/search') { function search($s,$id='search-box',$url='/search',$save = false) {
$a = get_app(); $a = get_app();
$o = '<div id="' . $id . '">'; $o = '<div id="' . $id . '">';
$o .= '<form action="' . $a->get_baseurl() . $url . '" method="get" >'; $o .= '<form action="' . $a->get_baseurl() . $url . '" method="get" >';
$o .= '<input type="text" name="search" id="search-text" value="' . $s .'" />'; $o .= '<input type="text" name="search" id="search-text" value="' . $s .'" />';
$o .= '<input type="submit" name="submit" id="search-submit" value="' . t('Search') . '" />'; $o .= '<input type="submit" name="submit" id="search-submit" value="' . t('Search') . '" />';
if($save)
$o .= '<input type="submit" name="save" id="search-save" value="' . t('Save') . '" />';
$o .= '</form></div>'; $o .= '</form></div>';
return $o; return $o;
}} }}

View file

@ -16,8 +16,26 @@ function network_init(&$a) {
$search = ((x($_GET,'search')) ? escape_tags($_GET['search']) : ''); $search = ((x($_GET,'search')) ? escape_tags($_GET['search']) : '');
$srchurl = '/network' . ((x($_GET,'cid')) ? '?cid=' . $_GET['cid'] : '') . ((x($_GET,'star')) ? '?star=' . $_GET['star'] : ''); $srchurl = '/network' . ((x($_GET,'cid')) ? '?cid=' . $_GET['cid'] : '') . ((x($_GET,'star')) ? '?star=' . $_GET['star'] : '');
if(x($_GET,'save')) {
$r = q("select * from `search` where `uid` = %d and `term` = '%s' limit 1",
intval(local_user()),
dbesc($search)
);
if(! count($r)) {
q("insert into `search` ( `uid`,`term` ) values ( %d, '%s') ",
intval(local_user()),
dbesc($search)
);
}
}
if(x($_GET,'remove')) {
q("delete from `search` where `uid` = %d and `term` = '%s' limit 1",
intval(local_user()),
dbesc($search)
);
}
$a->page['aside'] .= search($search,'netsearch-box',$srchurl); $a->page['aside'] .= search($search,'netsearch-box',$srchurl,true);
$a->page['aside'] .= '<div id="network-new-link">'; $a->page['aside'] .= '<div id="network-new-link">';
@ -49,8 +67,34 @@ function network_init(&$a) {
$a->page['aside'] .= '</div>'; $a->page['aside'] .= '</div>';
$a->page['aside'] .= group_side('network','network',true,$group_id); $a->page['aside'] .= group_side('network','network',true,$group_id);
$a->page['aside'] .= saved_searches();
} }
function saved_searches() {
$o = '';
$r = q("select `term` from `search` WHERE `uid` = %d",
intval(local_user())
);
if(count($r)) {
$o .= '<h3>' . t('Saved Searches') . '</h3>' . "\r\n";
$o .= '<div id="saved-search-list"><ul id="saved-search-ul">' . "\r\n";
foreach($r as $rr) {
$o .= '<li class="saved-search-li clear"><a href="network/?f=&remove=1&search=' . $rr['term'] . '" class="icon drophide savedsearchdrop" title="' . t('Remove term') . '" onclick="return confirmDelete();" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a> <a href="network/?f&search=' . $rr['term'] . '" class="savedsearchterm" >' . $rr['term'] . '</a></li>' . "\r\n";
}
$o .= '</ul></div>' . "\r\n";
}
return $o;
}
function network_content(&$a, $update = 0) { function network_content(&$a, $update = 0) {

View file

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1085 ); define( 'UPDATE_VERSION' , 1086 );
/** /**
* *
@ -704,10 +704,20 @@ function update_1083() {
`cmd` CHAR( 32 ) NOT NULL , `cmd` CHAR( 32 ) NOT NULL ,
`item` INT NOT NULL , `item` INT NOT NULL ,
`contact` INT NOT NULL `contact` INT NOT NULL
) ENGINE = MYISAM ;"); ) ENGINE = MYISAM ");
} }
function update_1084() { function update_1084() {
q("ALTER TABLE `contact` ADD `attag` CHAR( 255 ) NOT NULL AFTER `nick` "); q("ALTER TABLE `contact` ADD `attag` CHAR( 255 ) NOT NULL AFTER `nick` ");
} }
function update_1085() {
q("CREATE TABLE IF NOT EXISTS `search` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`uid` INT NOT NULL ,
`term` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
INDEX ( `uid` ),
INDEX ( `term` )
) ENGINE = MYISAM ");
}

View file

@ -1811,6 +1811,24 @@ a.mail-list-link {
margin-top: 10px; margin-top: 10px;
} }
#search-save {
margin-left: 5px;
}
.groupsideedit {
margin-right: 10px;
}
#saved-search-ul {
list-style-type: none;
}
.savedsearchdrop, .savedsearchterm {
float: left;
margin-top: 10px;
}
.savedsearchterm {
margin-left: 10px;
}
#side-follow-wrapper { #side-follow-wrapper {
margin-top: 20px; margin-top: 20px;
} }

View file

@ -1871,6 +1871,25 @@ a.mail-list-link {
margin-top: 10px; margin-top: 10px;
} }
#search-save {
margin-left: 5px;
}
.groupsideedit {
margin-right: 10px;
}
#saved-search-ul {
list-style-type: none;
}
.savedsearchdrop, .savedsearchterm {
float: left;
margin-top: 10px;
}
.savedsearchterm {
margin-left: 10px;
}
#side-follow-wrapper { #side-follow-wrapper {
margin-top: 20px; margin-top: 20px;
} }