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) {
47 'name' => $savedFolderName,
49 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&cat=' . rawurlencode($savedFolderName) : ""),
56 if (count($categories)) {
57 $categories[count($categories) - 1]['last'] = true;
60 if (local_user() == $item['uid']) {
61 foreach (FileTag::fileToArray($item['file'] ?? '') as $savedFolderName) {
63 'name' => $savedFolderName,
65 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . rawurlencode($savedFolderName) : ""),
73 if (count($folders)) {
74 $folders[count($folders) - 1]['last'] = true;
77 return [$categories, $folders];