]> git.mxchange.org Git - friendica.git/commitdiff
bookmarks + bug #140
authorFriendika <info@friendika.com>
Mon, 5 Sep 2011 02:58:03 +0000 (19:58 -0700)
committerFriendika <info@friendika.com>
Mon, 5 Sep 2011 02:58:03 +0000 (19:58 -0700)
boot.php
database.sql
include/items.php
library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js
mod/item.php
mod/network.php
mod/parse_url.php
update.php
view/theme/loozah/style.css

index 7534046f2ec57b49ad1bde6cd53902252b17947c..a196ccadc416eb377aa9fba7c724d9a8b9214b0d 100644 (file)
--- 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',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
index 343d4c4971ba71701bc278e7ff7b8f388fe6fae9..ff339929ea99b96d8f7cbed521896517d6d35ab5 100644 (file)
@@ -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',
index 6ded6f87c4cf8f0b01e0797e50e9e445d3a8a827..facd8b2d4df313e9ed99b2fa24ead393dd2d6873 100644 (file)
@@ -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 .= '<dfrn:extid>' . xmlify($item['extid']) . '</dfrn:extid>' . "\r\n";
+       if($item['bookmark'])
+               $o .= '<dfrn:bookmark>true</dfrn:bookmark>' . "\r\n";
 
        if($item['app'])
                $o .= '<statusnet:notice_info local_id="' . $item['id'] . '" source="' . xmlify($item['app']) . '" ></statusnet:notice_info>' . "\r\n";
index db676cd908d75c25e0de3d9662d7b80f2db388d3..789e75c399a5b921cd3ee94d1c25ea221552ff2f 100644 (file)
@@ -70,6 +70,7 @@
 
 \r
                        // example: <strong> to [b]\r
+                       rep(/<a class=\"bookmark\" href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[bookmark=$1]$2[/bookmark]");\r
                        rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");\r
                        rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");\r
                        rep(/<span style=\"color:(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");\r
                        rep(/\[\/i\]/gi,"</em>");\r
                        rep(/\[u\]/gi,"<u>");\r
                        rep(/\[\/u\]/gi,"</u>");\r
+                       rep(/\[bookmark=([^\]]+)\](.*?)\[\/bookmark\]/gi,"<a class=\"bookmark\" href=\"$1\">$2</a>");\r
                        rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");\r
                        rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");\r
                        rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");\r
index 6ecca8f4a1d7df82c35a832dc481b0537b964a60..b4ec7666fd9fb250111a9dda056cdd6637da4d36 100644 (file)
@@ -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",
index 663814ab7816da3af05e83ec8ac768b24445301e..1434f5d31264fc6d3f10ab8c3dbd08b7f4c586e2 100644 (file)
@@ -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'] . "; </script>\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) {
index b10d11c4bdc44ca686229f64a59bc6a20ad19940..79c336ddccad66f84b5869778e5d33e099aed4ed 100644 (file)
@@ -13,7 +13,7 @@ function parse_url_content(&$a) {
 
        $text = null;
 
-       $template = "<br /><a href=\"%s\" >%s</a>%s<br />";
+       $template = "<br /><a class=\"bookmark\" href=\"%s\" >%s</a>%s<br />";
 
 
        $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();
 }
index 3d7b31813e1dcbab8746070897df69a83a2e41ff..f94e78d727f666e75db21ff490252f8ed343a137 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define( 'UPDATE_VERSION' , 1086 );
+define( 'UPDATE_VERSION' , 1087 );
 
 /**
  *
@@ -721,3 +721,8 @@ function update_1085() {
        INDEX ( `term` )
        ) ENGINE = MYISAM ");
 }
+
+function update_1086() {
+       q("ALTER TABLE `item` ADD `bookmark` tinyint(1) NOT NULL DEFAULT '0' AFTER `starred` ");
+}
+
index b97f27510b5143c14e506699583b44b7207bb261..41de9b3e4bb9e22dfbeac67b426331ee07a85fe0 100644 (file)
@@ -2424,7 +2424,8 @@ a.mail-list-link {
 }
 
 #netsearch-box {
-       margin-top: 20px;       
+       margin-top: 20px;
+       width: 150px;   
 }
 
 #netsearch-box #search-submit {