3 namespace Friendica\Content;
5 use Friendica\Model\FileTag;
8 * A content helper class for displaying items
13 * Return array with details for categories and folders for an item
16 * @return [array, array]
19 * [ // categories array
21 * 'name': 'category name',
22 * 'removeurl': 'url to remove this category',
23 * 'first': 'is the first in this array? true/false',
24 * 'last': 'is the last in this array? true/false',
30 * 'name': 'folder name',
31 * 'removeurl': 'url to remove this folder',
32 * 'first': 'is the first in this array? true/false',
33 * 'last': 'is the last in this array? true/false',
39 public function determineCategoriesTerms(array $item)
45 foreach (FileTag::fileToArray($item['file'] ?? '', 'category') as $savedFolderName) {
46 if (!empty($item['author-link'])) {
47 $url = $item['author-link'] . "?category=" . rawurlencode($savedFolderName);
52 'name' => $savedFolderName,
54 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&cat=' . rawurlencode($savedFolderName) : ""),
61 if (count($categories)) {
62 $categories[count($categories) - 1]['last'] = true;
65 if (local_user() == $item['uid']) {
66 foreach (FileTag::fileToArray($item['file'] ?? '') as $savedFolderName) {
68 'name' => $savedFolderName,
70 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . rawurlencode($savedFolderName) : ""),
78 if (count($folders)) {
79 $folders[count($folders) - 1]['last'] = true;
82 return [$categories, $folders];