From e6c93e4146f79cb251f32b06d4a29e7af9c269ac Mon Sep 17 00:00:00 2001 From: zottel Date: Fri, 11 Oct 2013 10:50:06 +0200 Subject: fix alt_pager to work if item count is higher than page['itemspage'] (threads) --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 8f700458c..a3f2a651c 100755 --- a/include/text.php +++ b/include/text.php @@ -364,7 +364,7 @@ function alt_pager(&$a, $i, $more = '', $less = '') { return replace_macros(get_markup_template('alt_pager.tpl'),array( '$has_less' => (($a->pager['page'] > 1) ? true : false), - '$has_more' => (($i > 0 && $i == $a->pager['itemspage']) ? true : false), + '$has_more' => (($i > 0 && $i >= $a->pager['itemspage']) ? true : false), '$less' => $less, '$more' => $more, '$url' => $url, -- cgit v1.2.3 From db42e4d2f92dacb02662dc298871300dfea75651 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 13 Oct 2013 21:14:04 -0700 Subject: attachment icons revisited --- include/text.php | 78 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 28 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index a3f2a651c..bcb1f9438 100755 --- a/include/text.php +++ b/include/text.php @@ -1015,45 +1015,30 @@ function unobscure(&$item) { } - -function prepare_body(&$item,$attach = false) { - - $a = get_app(); - - - - call_hooks('prepare_body_init', $item); - - unobscure($item); - - $s = prepare_text($item['body'],$item['mimetype']); - - $prep_arr = array('item' => $item, 'html' => $s); - call_hooks('prepare_body', $prep_arr); - $s = $prep_arr['html']; - - if(! $attach) { - return $s; - } - +function theme_attachments(&$item) { $arr = json_decode_plus($item['attach']); - if(count($arr)) { - $s .= '
'; + if(is_array($arr) && count($arr)) { + $attaches = array(); foreach($arr as $r) { - $matches = false; $icon = ''; $icontype = substr($r['type'],0,strpos($r['type'],'/')); switch($icontype) { case 'video': + $icon = 'icon-facetime-video'; + break; case 'audio': + $icon = 'icon-volume-up'; + break; case 'image': + $icon = 'icon-camera'; + break; case 'text': - $icon = '
'; + $icon = 'icon-align-justify'; break; default: - $icon = '
'; + $icon = 'icon-question'; break; } @@ -1062,12 +1047,49 @@ function prepare_body(&$item,$attach = false) { $title = t('unknown.???'); $title .= ' ' . $r['length'] . ' ' . t('bytes'); - $url = $a->get_baseurl() . '/magic?f=&hash=' . $item['author_xchan'] . '&dest=' . $r['href'] . '/' . $r['revision']; + $url = z_root() . '/magic?f=&hash=' . $item['author_xchan'] . '&dest=' . $r['href'] . '/' . $r['revision']; $s .= '' . $icon . ''; + $attaches[] = array('title' => $title, 'url' => $url, 'icon' => $icon ); + } - $s .= '
'; + + } + $s = replace_macros(get_markup_template('item_attach.tpl'), array( + '$attaches' => $attaches + )); + + return $s; + +} + + + +function prepare_body(&$item,$attach = false) { + + $a = get_app(); + + + + call_hooks('prepare_body_init', $item); + + unobscure($item); + + $s = prepare_text($item['body'],$item['mimetype']); + + $prep_arr = array('item' => $item, 'html' => $s); + call_hooks('prepare_body', $prep_arr); + $s = $prep_arr['html']; + + if(! $attach) { + return $s; + } + + + $s .= theme_attachments($item); + + // At some point in time, posttags were removed from the threaded conversation templates, but remained in the search_item template. // Code to put them back was added into include/conversation.php and/or include/ItemObject.php but under new class names // Then it was discovered that the following bits remained of the old code. -- cgit v1.2.3 From 4f2c056d6d00257fccae356f4fdf6c0c971c9b60 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 14 Oct 2013 04:49:28 -0700 Subject: template and icons for categories and "file as" --- include/text.php | 92 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index bcb1f9438..125e1182f 100755 --- a/include/text.php +++ b/include/text.php @@ -1032,7 +1032,7 @@ function theme_attachments(&$item) { $icon = 'icon-volume-up'; break; case 'image': - $icon = 'icon-camera'; + $icon = 'icon-picture'; break; case 'text': $icon = 'icon-align-justify'; @@ -1065,6 +1065,48 @@ function theme_attachments(&$item) { } +function format_categories(&$item,$writeable) { + + $s = ''; + $terms = get_terms_oftype($item['term'],TERM_CATEGORY); + if($terms) { + $categories = array(); + foreach($terms as $t) { + $term = htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8') ; + $removelink = (($writeable) ? z_root() . '/filerm/' . $item['id'] . '?f=&cat=' . urlencode($t['term']) : ''); + $categories[] = array('term' => $term, 'writeable' => $writeable, 'removelink' => $removelink); + } + } + $s = replace_macros(get_markup_template('item_categories.tpl'),array( + '$remove' => t('remove category'), + '$categories' => $categories + )); + return $s; +} + + +function format_filer(&$item) { + + $s = ''; + $terms = get_terms_oftype($item['term'],TERM_FILE); + if($terms) { + $categories = array(); + foreach($terms as $t) { + $term = htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8') ; + $removelink = z_root() . '/filerm/' . $item['id'] . '?f=&term=' . urlencode($t['term']); + $categories[] = array('term' => $term, 'removelink' => $removelink); + } + } + $s = replace_macros(get_markup_template('item_filer.tpl'),array( + '$remove' => t('remove from file'), + '$categories' => $categories + )); + return $s; +} + + + + function prepare_body(&$item,$attach = false) { @@ -1090,54 +1132,12 @@ function prepare_body(&$item,$attach = false) { $s .= theme_attachments($item); -// At some point in time, posttags were removed from the threaded conversation templates, but remained in the search_item template. -// Code to put them back was added into include/conversation.php and/or include/ItemObject.php but under new class names -// Then it was discovered that the following bits remained of the old code. -// Commented out, but we may decide to use this instead of the other version and put all the tag rendering in one place. In the other -// location it is more theme-able. -// if(is_array($item['term']) && count($item['term'])) { -// $tstr = ''; -// foreach($item['term'] as $t) { -// $t1 = format_term_for_display($t); -// if($t1) { -// if($tstr) -// $tstr .= ' '; -// $tstr .= $t1; -// } -// } -// if($tstr) -// $s .= '
'; -// } - $writeable = ((get_observer_hash() == $item['owner_xchan']) ? true : false); - $x = ''; - $terms = get_terms_oftype($item['term'],TERM_CATEGORY); - if($terms) { - foreach($terms as $t) { - if(strlen($x)) - $x .= ','; - $x .= htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8') - . (($writeable) ? ' ' . t('[remove]') . '' : ''); - } - if(strlen($x)) - $s .= '
' . t('Categories:') . ' ' . $x . '
'; - + $s .= format_categories($item,$writeable); - } - - $x = ''; - $terms = get_terms_oftype($item['term'],TERM_FILE); - if($terms) { - foreach($terms as $t) { - if(strlen($x)) - $x .= '   '; - $x .= htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8') - . ' ' . t('[remove]') . ''; - } - if(strlen($x) && (local_user() == $item['uid'])) - $s .= '
' . t('Filed under:') . ' ' . $x . '
'; - } + if(local_user() == $item['uid']) + $s .= format_filer($item); // Look for spoiler $spoilersearch = '
'; -- cgit v1.2.3 From 9787872778d02d770431386853fa3313f453398e Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 14 Oct 2013 15:34:47 -0700 Subject: linkify post categories --- include/text.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 125e1182f..ff75535b0 100755 --- a/include/text.php +++ b/include/text.php @@ -1024,6 +1024,9 @@ function theme_attachments(&$item) { $icon = ''; $icontype = substr($r['type'],0,strpos($r['type'],'/')); + // FIXME This should probably be a giant "if" statement in the template so that we don't have icon names + // embedded in php code + switch($icontype) { case 'video': $icon = 'icon-facetime-video'; @@ -1073,8 +1076,10 @@ function format_categories(&$item,$writeable) { $categories = array(); foreach($terms as $t) { $term = htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8') ; + if(! trim($term)) + continue; $removelink = (($writeable) ? z_root() . '/filerm/' . $item['id'] . '?f=&cat=' . urlencode($t['term']) : ''); - $categories[] = array('term' => $term, 'writeable' => $writeable, 'removelink' => $removelink); + $categories[] = array('term' => $term, 'writeable' => $writeable, 'removelink' => $removelink, 'url' => $t['url']); } } $s = replace_macros(get_markup_template('item_categories.tpl'),array( @@ -1093,6 +1098,8 @@ function format_filer(&$item) { $categories = array(); foreach($terms as $t) { $term = htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8') ; + if(! trim($term)) + continue; $removelink = z_root() . '/filerm/' . $item['id'] . '?f=&term=' . urlencode($t['term']); $categories[] = array('term' => $term, 'removelink' => $removelink); } -- cgit v1.2.3 From c48da79adf648370beeeb0bab18f89963babebaa Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 20 Oct 2013 20:29:52 -0700 Subject: link to source - if it's on the display page link to original source (probably on a different site). All other conversations link to 'llink' which is a local copy and may provide a richer possibility of interactions, especially if you're logged in locally and it's your own copy of the post. --- include/text.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index ff75535b0..1ff9d27cb 100755 --- a/include/text.php +++ b/include/text.php @@ -1337,11 +1337,16 @@ function feed_salmonlinks($nick) { } -function get_plink($item) { - $a = get_app(); - if (x($item,'plink') && ($item['item_private'] != 1)) { +function get_plink($item,$mode) { + $a = get_app(); + if($mode == 'display') + $key = 'plink'; + else + $key = 'llink'; + + if (x($item,$key) && ($item['item_private'] != 1)) { return array( - 'href' => zid($item['plink']), + 'href' => zid($item[$key]), 'title' => t('link to source'), ); } -- cgit v1.2.3