mirror of
https://github.com/friendica/friendica
synced 2024-12-25 02:40:16 +00:00
Merge pull request #492 from fabrixxm/blog-like
More data in $item array
This commit is contained in:
commit
58399c854f
4 changed files with 107 additions and 29 deletions
|
@ -350,6 +350,7 @@ function visible_activity($item) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively prepare a thread for HTML
|
* Recursively prepare a thread for HTML
|
||||||
*/
|
*/
|
||||||
|
@ -629,6 +630,10 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr
|
||||||
|
|
||||||
$body = prepare_body($item,true);
|
$body = prepare_body($item,true);
|
||||||
|
|
||||||
|
list($categories, $folders) = get_cats_and_terms($item);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$tmp_item = array(
|
$tmp_item = array(
|
||||||
// collapse comments in template. I don't like this much...
|
// collapse comments in template. I don't like this much...
|
||||||
'comment_firstcollapsed' => $firstcollapsed,
|
'comment_firstcollapsed' => $firstcollapsed,
|
||||||
|
@ -640,6 +645,8 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr
|
||||||
'tags' => template_escape($tags),
|
'tags' => template_escape($tags),
|
||||||
'hashtags' => template_escape($hashtags),
|
'hashtags' => template_escape($hashtags),
|
||||||
'mentions' => template_escape($mentions),
|
'mentions' => template_escape($mentions),
|
||||||
|
'categories' => $categories,
|
||||||
|
'folders' => $folders,
|
||||||
'body' => template_escape($body),
|
'body' => template_escape($body),
|
||||||
'text' => strip_tags(template_escape($body)),
|
'text' => strip_tags(template_escape($body)),
|
||||||
'id' => $item['item_id'],
|
'id' => $item['item_id'],
|
||||||
|
@ -892,6 +899,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
|
||||||
|
|
||||||
$body = prepare_body($item,true);
|
$body = prepare_body($item,true);
|
||||||
|
|
||||||
|
list($categories, $folders) = get_cats_and_terms($item);
|
||||||
//$tmp_item = replace_macros($tpl,array(
|
//$tmp_item = replace_macros($tpl,array(
|
||||||
$tmp_item = array(
|
$tmp_item = array(
|
||||||
'template' => $tpl,
|
'template' => $tpl,
|
||||||
|
@ -908,6 +916,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
|
||||||
'tags' => template_escape($tags),
|
'tags' => template_escape($tags),
|
||||||
'hashtags' => template_escape($hashtags),
|
'hashtags' => template_escape($hashtags),
|
||||||
'mentions' => template_escape($mentions),
|
'mentions' => template_escape($mentions),
|
||||||
|
'categories' => $categories,
|
||||||
|
'folders' => $folders,
|
||||||
'text' => strip_tags(template_escape($body)),
|
'text' => strip_tags(template_escape($body)),
|
||||||
'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'),
|
'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'),
|
||||||
'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
|
'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
|
||||||
|
@ -985,6 +995,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
|
||||||
|
|
||||||
$o = replace_macros($page_template, array(
|
$o = replace_macros($page_template, array(
|
||||||
'$baseurl' => $a->get_baseurl($ssl_state),
|
'$baseurl' => $a->get_baseurl($ssl_state),
|
||||||
|
'$remove' => t('remove'),
|
||||||
'$mode' => $mode,
|
'$mode' => $mode,
|
||||||
'$user' => $a->user,
|
'$user' => $a->user,
|
||||||
'$threads' => $threads,
|
'$threads' => $threads,
|
||||||
|
|
|
@ -1016,35 +1016,8 @@ function prepare_body($item,$attach = false) {
|
||||||
}
|
}
|
||||||
$s .= '<div class="clear"></div></div>';
|
$s .= '<div class="clear"></div></div>';
|
||||||
}
|
}
|
||||||
$matches = false;
|
|
||||||
$cnt = preg_match_all('/<(.*?)>/',$item['file'],$matches,PREG_SET_ORDER);
|
|
||||||
if($cnt) {
|
|
||||||
// logger('prepare_text: categories: ' . print_r($matches,true), LOGGER_DEBUG);
|
|
||||||
foreach($matches as $mtch) {
|
|
||||||
if(strlen($x))
|
|
||||||
$x .= ',';
|
|
||||||
$x .= xmlify(file_tag_decode($mtch[1]))
|
|
||||||
. ((local_user() == $item['uid']) ? ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&cat=' . xmlify(file_tag_decode($mtch[1])) . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>' : '');
|
|
||||||
}
|
|
||||||
if(strlen($x))
|
|
||||||
$s .= '<div class="categorytags"><span>' . t('Categories:') . ' </span>' . $x . '</div>';
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
$matches = false;
|
|
||||||
$x = '';
|
|
||||||
$cnt = preg_match_all('/\[(.*?)\]/',$item['file'],$matches,PREG_SET_ORDER);
|
|
||||||
if($cnt) {
|
|
||||||
// logger('prepare_text: filed_under: ' . print_r($matches,true), LOGGER_DEBUG);
|
|
||||||
foreach($matches as $mtch) {
|
|
||||||
if(strlen($x))
|
|
||||||
$x .= ' ';
|
|
||||||
$x .= xmlify(file_tag_decode($mtch[1])) . ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&term=' . xmlify(file_tag_decode($mtch[1])) . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>';
|
|
||||||
}
|
|
||||||
if(strlen($x) && (local_user() == $item['uid']))
|
|
||||||
$s .= '<div class="filesavetags"><span>' . t('Filed under:') . ' </span>' . $x . '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look for spoiler
|
// Look for spoiler
|
||||||
$spoilersearch = '<blockquote class="spoiler">';
|
$spoilersearch = '<blockquote class="spoiler">';
|
||||||
|
|
||||||
|
@ -1098,6 +1071,72 @@ function prepare_text($text) {
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns
|
||||||
|
* [
|
||||||
|
* //categories [
|
||||||
|
* {
|
||||||
|
* 'name': 'category name',
|
||||||
|
* 'removeurl': 'url to remove this category',
|
||||||
|
* 'first': 'is the first in this array? true/false',
|
||||||
|
* 'last': 'is the last in this array? true/false',
|
||||||
|
* } ,
|
||||||
|
* ....
|
||||||
|
* ],
|
||||||
|
* // folders [
|
||||||
|
* 'name': 'folder name',
|
||||||
|
* 'removeurl': 'url to remove this folder',
|
||||||
|
* 'first': 'is the first in this array? true/false',
|
||||||
|
* 'last': 'is the last in this array? true/false',
|
||||||
|
* } ,
|
||||||
|
* ....
|
||||||
|
* ]
|
||||||
|
* ]
|
||||||
|
*/
|
||||||
|
function get_cats_and_terms($item) {
|
||||||
|
$a = get_app();
|
||||||
|
$categories = array();
|
||||||
|
$folders = array();
|
||||||
|
|
||||||
|
$matches = false; $first = true;
|
||||||
|
$cnt = preg_match_all('/<(.*?)>/',$item['file'],$matches,PREG_SET_ORDER);
|
||||||
|
if($cnt) {
|
||||||
|
foreach($matches as $mtch) {
|
||||||
|
$categories[] = array(
|
||||||
|
'name' => xmlify(file_tag_decode($mtch[1])),
|
||||||
|
'url' => "#",
|
||||||
|
'removeurl' => ((local_user() == $item['uid'])?$a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&cat=' . xmlify(file_tag_decode($mtch[1])):""),
|
||||||
|
'first' => $first,
|
||||||
|
'last' => false
|
||||||
|
);
|
||||||
|
$first = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($categories)) $categories[count($categories)-1]['last'] = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$matches = false; $first = true;
|
||||||
|
$cnt = preg_match_all('/\[(.*?)\]/',$item['file'],$matches,PREG_SET_ORDER);
|
||||||
|
if($cnt) {
|
||||||
|
foreach($matches as $mtch) {
|
||||||
|
$folders[] = array(
|
||||||
|
'name' => xmlify(file_tag_decode($mtch[1])),
|
||||||
|
'url' => "#",
|
||||||
|
'removeurl' => ((local_user() == $item['uid'])?$a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&term=' . xmlify(file_tag_decode($mtch[1])):""),
|
||||||
|
'first' => $first,
|
||||||
|
'last' => false
|
||||||
|
);
|
||||||
|
$first = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($folders)) $folders[count($folders)-1]['last'] = true;
|
||||||
|
|
||||||
|
return array($categories, $folders);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return atom link elements for all of our hubs
|
* return atom link elements for all of our hubs
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -143,9 +143,19 @@ class Item extends BaseObject {
|
||||||
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate));
|
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate));
|
||||||
|
|
||||||
$tags=array();
|
$tags=array();
|
||||||
|
$hashtags = array();
|
||||||
|
$mentions = array();
|
||||||
foreach(explode(',',$item['tag']) as $tag){
|
foreach(explode(',',$item['tag']) as $tag){
|
||||||
$tag = trim($tag);
|
$tag = trim($tag);
|
||||||
if ($tag!="") $tags[] = bbcode($tag);
|
if ($tag!="") {
|
||||||
|
$t = bbcode($tag);
|
||||||
|
$tags[] = $t;
|
||||||
|
if($t[0] == '#')
|
||||||
|
$hashtags[] = $t;
|
||||||
|
elseif($t[0] == '@')
|
||||||
|
$mentions[] = $t;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$like = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : '');
|
$like = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : '');
|
||||||
|
@ -195,11 +205,17 @@ class Item extends BaseObject {
|
||||||
|
|
||||||
$body = prepare_body($item,true);
|
$body = prepare_body($item,true);
|
||||||
|
|
||||||
|
list($categories, $folders) = get_cats_and_terms($item);
|
||||||
|
|
||||||
$tmp_item = array(
|
$tmp_item = array(
|
||||||
'template' => $this->get_template(),
|
'template' => $this->get_template(),
|
||||||
|
|
||||||
'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
|
'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
|
||||||
'tags' => $tags,
|
'tags' => $tags,
|
||||||
|
'hashtags' => $hashtags,
|
||||||
|
'mentions' => $mentions,
|
||||||
|
'categories' => $categories,
|
||||||
|
'folders' => $folders,
|
||||||
'body' => template_escape($body),
|
'body' => template_escape($body),
|
||||||
'text' => strip_tags(template_escape($body)),
|
'text' => strip_tags(template_escape($body)),
|
||||||
'id' => $this->get_id(),
|
'id' => $this->get_id(),
|
||||||
|
@ -266,6 +282,11 @@ class Item extends BaseObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->is_toplevel()) {
|
||||||
|
$result['total_comments_num'] = $total_children;
|
||||||
|
$result['total_comments_text'] = tt('comment', 'comments', $total_children);
|
||||||
|
}
|
||||||
|
|
||||||
$result['private'] = $item['private'];
|
$result['private'] = $item['private'];
|
||||||
$result['toplevel'] = ($this->is_toplevel() ? 'toplevel_item' : '');
|
$result['toplevel'] = ($this->is_toplevel() ? 'toplevel_item' : '');
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,13 @@
|
||||||
include_once($file);
|
include_once($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "Directory: object\n";
|
||||||
|
$files = glob('object/*.php');
|
||||||
|
foreach($files as $file) {
|
||||||
|
echo $file . "\n";
|
||||||
|
include_once($file);
|
||||||
|
}
|
||||||
|
|
||||||
echo "Directory: addon\n";
|
echo "Directory: addon\n";
|
||||||
$dirs = glob('addon/*');
|
$dirs = glob('addon/*');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue