diff options
Diffstat (limited to 'include')
-rwxr-xr-x | include/contact_widgets.php | 28 | ||||
-rwxr-xr-x | include/conversation.php | 2 | ||||
-rwxr-xr-x | include/diaspora.php | 6 | ||||
-rwxr-xr-x | include/items.php | 9 | ||||
-rw-r--r-- | include/text.php | 119 |
5 files changed, 162 insertions, 2 deletions
diff --git a/include/contact_widgets.php b/include/contact_widgets.php index 7346b95af..e0f37f078 100755 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -103,3 +103,31 @@ function fileas_widget($baseurl,$selected = '') { )); } +function categories_widget($baseurl,$selected = '') { + $a = get_app(); + + $saved = get_pconfig($a->profile['profile_uid'],'system','filetags'); + if(! strlen($saved)) + return; + + $matches = false; + $terms = array(); + $cnt = preg_match_all('/<(.*?)>/',$saved,$matches,PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $unescaped = xmlify(file_tag_decode($mtch[1])); + $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : '')); + } + } + + return replace_macros(get_markup_template('categories_widget.tpl'),array( + '$title' => t('Categories'), + '$desc' => '', + '$sel_all' => (($selected == '') ? 'selected' : ''), + '$all' => t('Everything'), + '$terms' => $terms, + '$base' => $baseurl, + + )); +} + diff --git a/include/conversation.php b/include/conversation.php index 5a922b2b5..df92a40ed 100755 --- a/include/conversation.php +++ b/include/conversation.php @@ -974,6 +974,8 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { '$shortnoloc' => t('clear location'), '$title' => "", '$placeholdertitle' => t('Set title'), + '$category' => "", + '$placeholdercategory' => t('Categories (comma-separated list)'), '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$shortpermset' => t('permissions'), diff --git a/include/diaspora.php b/include/diaspora.php index 104ccadf2..04238f17c 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1920,6 +1920,7 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) { $images = array(); + $title = $item['title']; $body = $item['body']; /* @@ -1944,9 +1945,12 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) { } } */ - $body = xmlify(html_entity_decode(bb2diaspora($body))); + if(strlen($title)) + $body = xmlify('**' . html_entity_decode($title) . '**' . "\n") . $body; + + if($item['attach']) { $cnt = preg_match_all('/href=\"(.*?)\"(.*?)title=\"(.*?)\"/ism',$item['attach'],$matches,PREG_SET_ORDER); if(cnt) { diff --git a/include/items.php b/include/items.php index e09b888ca..ee6960534 100755 --- a/include/items.php +++ b/include/items.php @@ -435,8 +435,15 @@ function get_atom_elements($feed,$item) { $res['body'] = @html2bbcode($res['body']); } - else + elseif(! $have_real_body) { + + // it's not one of our messages and it has no tags + // so it's probably just text. We'll escape it just to be safe. + $res['body'] = escape_tags($res['body']); + } + + // this tag is obsolete but we keep it for really old sites $allow = $item->get_item_tags(NAMESPACE_DFRN,'comment-allow'); if($allow && $allow[0]['data'] == 1) diff --git a/include/text.php b/include/text.php index 191f4fca8..5456b5ad3 100644 --- a/include/text.php +++ b/include/text.php @@ -225,6 +225,9 @@ if(! function_exists('paginate')) { function paginate(&$a) { $o = ''; $stripped = preg_replace('/(&page=[0-9]*)/','',$a->query_string); + +// $stripped = preg_replace('/&zrl=(.*?)([\?&]|$)/ism','',$stripped); + $stripped = str_replace('q=','',$stripped); $stripped = trim($stripped,'/'); $pagenum = $a->pager['page']; @@ -725,6 +728,8 @@ function smilies($s, $sample = false) { '\\o/', 'o.O', 'O.o', + 'o_O', + 'O_o', ":'(", ":-!", ":-/", @@ -759,6 +764,8 @@ function smilies($s, $sample = false) { '<img src="' . $a->get_baseurl() . '/images/smiley-thumbsup.gif" alt="\\o/" />', '<img src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="o.O" />', '<img src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="O.o" />', + '<img src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="o_O" />', + '<img src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="O_o" />', '<img src="' . $a->get_baseurl() . '/images/smiley-cry.gif" alt=":\'(" />', '<img src="' . $a->get_baseurl() . '/images/smiley-foot-in-mouth.gif" alt=":-!" />', '<img src="' . $a->get_baseurl() . '/images/smiley-undecided.gif" alt=":-/" />', @@ -1314,6 +1321,118 @@ function file_tag_file_query($table,$s,$type = 'file') { return " AND " . (($table) ? dbesc($table) . '.' : '') . "file regexp '" . dbesc($str) . "' "; } +// ex. given music,video return <music><video> or [music][video] +function file_tag_list_to_file($list,$type = 'file') { + $tag_list = ''; + if(strlen($list)) { + $list_array = explode(",",$list); + if($type == 'file') { + $lbracket = '['; + $rbracket = ']'; + } + else { + $lbracket = '<'; + $rbracket = '>'; + } + + foreach($list_array as $item) { + if(strlen($item)) { + $tag_list .= $lbracket . file_tag_encode(trim($item)) . $rbracket; + } + } + } + return $tag_list; +} + +// ex. given <music><video>[friends], return music,video or friends +function file_tag_file_to_list($file,$type = 'file') { + $matches = false; + $list = ''; + if($type == 'file') { + $cnt = preg_match_all('/\[(.*?)\]/',$file,$matches,PREG_SET_ORDER); + } + else { + $cnt = preg_match_all('/<(.*?)>/',$file,$matches,PREG_SET_ORDER); + } + if($cnt) { + foreach($matches as $mtch) { + if(strlen($list)) + $list .= ','; + $list .= file_tag_decode($mtch[1]); + } + } + + return $list; +} + +function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') { + // $file_old - categories previously associated with an item + // $file_new - new list of categories for an item + + if(! intval($uid)) + return false; + + if($file_old == $file_new) + return true; + + $saved = get_pconfig($uid,'system','filetags'); + if(strlen($saved)) { + if($type == 'file') { + $lbracket = '['; + $rbracket = ']'; + } + else { + $lbracket = '<'; + $rbracket = '>'; + } + + $filetags_updated = $saved; + + // check for new tags to be added as filetags in pconfig + $new_tags = array(); + $check_new_tags = explode(",",file_tag_file_to_list($file_new,$type)); + + foreach($check_new_tags as $tag) { + if(! stristr($saved,$lbracket . file_tag_encode($tag) . $rbracket)) + $new_tags[] = $tag; + } + + $filetags_updated .= file_tag_list_to_file(implode(",",$new_tags),$type); + + // check for deleted tags to be removed from filetags in pconfig + $deleted_tags = array(); + $check_deleted_tags = explode(",",file_tag_file_to_list($file_old,$type)); + + foreach($check_deleted_tags as $tag) { + if(! stristr($file_new,$lbracket . file_tag_encode($tag) . $rbracket)) + $deleted_tags[] = $tag; + } + + foreach($deleted_tags as $key => $tag) { + $r = q("select file from item where uid = %d " . file_tag_file_query('item',$tag,$type), + intval($uid) + ); + + if(count($r)) { + unset($deleted_tags[$key]); + } + else { + $filetags_updated = str_replace($lbracket . file_tag_encode($tag) . $rbracket,'',$filetags_updated); + } + } + + if($saved != $filetags_updated) { + set_pconfig($uid,'system','filetags', $filetags_updated); + } + return true; + } + else + if(strlen($file_new)) { + set_pconfig($uid,'system','filetags', $file_new); + } + return true; +} + function file_tag_save_file($uid,$item,$file) { $result = false; if(! intval($uid)) |