return true;
}
+
+/**
+ * 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) {
+ $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])),
+ 'removeurl' => $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])),
+ 'removeurl' => $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);
+}
+
+
/**
* Recursively prepare a thread for HTML
*/
$body = prepare_body($item,true);
+ list($categories, $folders) = get_cats_and_terms($item);
+
+
+
$tmp_item = array(
// collapse comments in template. I don't like this much...
'comment_firstcollapsed' => $firstcollapsed,
'tags' => template_escape($tags),
'hashtags' => template_escape($hashtags),
'mentions' => template_escape($mentions),
+ 'categories' => $categories,
+ 'folders' => $folders,
'body' => template_escape($body),
'text' => strip_tags(template_escape($body)),
'id' => $item['item_id'],
$body = prepare_body($item,true);
+ list($categories, $folders) = get_cats_and_terms($item);
//$tmp_item = replace_macros($tpl,array(
$tmp_item = array(
'template' => $tpl,
'tags' => template_escape($tags),
'hashtags' => template_escape($hashtags),
'mentions' => template_escape($mentions),
+ 'categories' => $categories,
+ 'folders' => $folders,
'text' => strip_tags(template_escape($body)),
'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'])),
$o = replace_macros($page_template, array(
'$baseurl' => $a->get_baseurl($ssl_state),
+ '$remove' => t('remove'),
'$mode' => $mode,
'$user' => $a->user,
'$threads' => $threads,
}
$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
$spoilersearch = '<blockquote class="spoiler">';