From 82f7f33cf58774ac6b07acd64fe0b49cd5b0aa30 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 4 Sep 2011 19:58:03 -0700 Subject: [PATCH] bookmarks + bug #140 --- boot.php | 2 +- database.sql | 1 + include/items.php | 7 +++++++ .../plugins/bbcode/editor_plugin_src.js | 2 ++ mod/item.php | 17 ++++++++++++++--- mod/network.php | 10 +++++++++- mod/parse_url.php | 8 ++++++-- update.php | 7 ++++++- view/theme/loozah/style.css | 3 ++- 9 files changed, 48 insertions(+), 9 deletions(-) diff --git a/boot.php b/boot.php index 7534046f2e..a196ccadc4 100644 --- a/boot.php +++ b/boot.php @@ -9,7 +9,7 @@ require_once("include/pgettext.php"); define ( 'FRIENDIKA_VERSION', '2.2.1093' ); define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); -define ( 'DB_UPDATE_VERSION', 1086 ); +define ( 'DB_UPDATE_VERSION', 1087 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/database.sql b/database.sql index 343d4c4971..ff339929ea 100644 --- a/database.sql +++ b/database.sql @@ -206,6 +206,7 @@ CREATE TABLE IF NOT EXISTS `item` ( `pubmail` tinyint(1) NOT NULL DEFAULT '0', `visible` tinyint(1) NOT NULL DEFAULT '0', `starred` tinyint(1) NOT NULL DEFAULT '0', + `bookmark` tinyint(1) NOT NULL DEFAULT '0', `unseen` tinyint(1) NOT NULL DEFAULT '1', `deleted` tinyint(1) NOT NULL DEFAULT '0', `last-child` tinyint(1) unsigned NOT NULL DEFAULT '1', diff --git a/include/items.php b/include/items.php index 6ded6f87c4..facd8b2d4d 100644 --- a/include/items.php +++ b/include/items.php @@ -378,6 +378,10 @@ function get_atom_elements($feed,$item) { if($dguid) $res['guid'] = unxmlify($dguid[0]['data']); + $bm = $item->get_item_tags(NAMESPACE_DFRN,'bookmark'); + if($bm) + $res['bookmark'] = ((unxmlify($bm[0]['data']) === 'true') ? 1 : 0); + /** * If there's a copy of the body content which is guaranteed to have survived mangling in transit, use it. @@ -733,6 +737,7 @@ function item_store($arr,$force_parent = false) { $arr['deny_cid'] = ((x($arr,'deny_cid')) ? trim($arr['deny_cid']) : ''); $arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : ''); $arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0 ); + $arr['bookmark'] = ((x($arr,'bookmark')) ? intval($arr['bookmark']) : 0 ); $arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : ''); $arr['tag'] = ((x($arr,'tag')) ? notags(trim($arr['tag'])) : ''); $arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : ''); @@ -1706,6 +1711,8 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { if($item['extid']) $o .= '' . xmlify($item['extid']) . '' . "\r\n"; + if($item['bookmark']) + $o .= 'true' . "\r\n"; if($item['app']) $o .= '' . "\r\n"; diff --git a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js index db676cd908..789e75c399 100644 --- a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js +++ b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js @@ -70,6 +70,7 @@ // example: to [b] + rep(/(.*?)<\/a>/gi,"[bookmark=$1]$2[/bookmark]"); rep(/(.*?)<\/a>/gi,"[url=$1]$2[/url]"); rep(/(.*?)<\/span>/gi,"[size=$1]$2[/size]"); rep(/(.*?)<\/span>/gi,"[color=$1]$2[/color]"); @@ -119,6 +120,7 @@ rep(/\[\/i\]/gi,""); rep(/\[u\]/gi,""); rep(/\[\/u\]/gi,""); + rep(/\[bookmark=([^\]]+)\](.*?)\[\/bookmark\]/gi,"$2"); rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"$2"); rep(/\[url\](.*?)\[\/url\]/gi,"$1"); rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,""); diff --git a/mod/item.php b/mod/item.php index 6ecca8f4a1..b4ec7666fd 100644 --- a/mod/item.php +++ b/mod/item.php @@ -332,6 +332,15 @@ function item_post(&$a) { } } + // embedded bookmark in post? convert to regular url and set bookmark flag + + $bookmark = 0; + if(preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/m",$body,$match)) { + $bookmark = 1; + $body = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/m",'[url=$1]$2[/url]',$body); + } + + /** * Fold multi-line [code] sequences */ @@ -509,6 +518,7 @@ function item_post(&$a) { $datarray['private'] = $private; $datarray['pubmail'] = $pubmail_enable; $datarray['attach'] = $attachments; + $datarray['bookmark'] = intval($bookmark); $datarray['thr-parent'] = $thr_parent; /** @@ -551,8 +561,8 @@ function item_post(&$a) { $r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `author-name`, `author-link`, `author-avatar`, `created`, `edited`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`, - `tag`, `inform`, `verb`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach` ) - VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s' )", + `tag`, `inform`, `verb`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark` ) + VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d )", dbesc($datarray['guid']), intval($datarray['uid']), dbesc($datarray['type']), @@ -585,7 +595,8 @@ function item_post(&$a) { dbesc($datarray['deny_gid']), intval($datarray['private']), intval($datarray['pubmail']), - dbesc($datarray['attach']) + dbesc($datarray['attach']), + intval($datarray['bookmark']) ); $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", diff --git a/mod/network.php b/mod/network.php index 663814ab78..1434f5d312 100644 --- a/mod/network.php +++ b/mod/network.php @@ -14,7 +14,10 @@ function network_init(&$a) { $a->page['aside'] = ''; $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'] : '') + . ((x($_GET,'bmark')) ? '?bmark=' . $_GET['bmark'] : ''); if(x($_GET,'save')) { $r = q("select * from `search` where `uid` = %d and `term` = '%s' limit 1", @@ -114,6 +117,7 @@ function network_content(&$a, $update = 0) { $cid = ((x($_GET['cid'])) ? intval($_GET['cid']) : 0); $star = ((x($_GET['star'])) ? intval($_GET['star']) : 0); + $bmark = ((x($_GET['bmark'])) ? intval($_GET['bmark']) : 0); if(($a->argc > 2) && $a->argv[2] === 'new') $nouveau = true; @@ -174,6 +178,7 @@ function network_content(&$a, $update = 0) { . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '') . ((x($_GET,'search')) ? '&search=' . $_GET['search'] : '') . ((x($_GET,'star')) ? '&star=' . $_GET['star'] : '') + . ((x($_GET,'bmark')) ? '&bmark=' . $_GET['bmark'] : '') . "'; var profile_page = " . $a->pager['page'] . "; \r\n"; } @@ -195,6 +200,9 @@ function network_content(&$a, $update = 0) { $star_sql = (($star) ? " AND `starred` = 1 " : ''); + if($bmark) + $star_sql .= " AND `bookmark` = 1 "; + $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $star_sql ) "; if($group) { diff --git a/mod/parse_url.php b/mod/parse_url.php index b10d11c4bd..79c336ddcc 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -13,7 +13,7 @@ function parse_url_content(&$a) { $text = null; - $template = "
%s%s
"; + $template = "
%s%s
"; $arr = array('url' => $url, 'text' => ''); @@ -121,6 +121,10 @@ function parse_url_content(&$a) { $title = str_replace("\n",'',$title); - echo sprintf($template,$url,($title) ? $title : $url,$text); + $result = sprintf($template,$url,($title) ? $title : $url,$text); + + logger('parse_url: returns: ' . $result); + + echo $result; killme(); } diff --git a/update.php b/update.php index 3d7b31813e..f94e78d727 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@