3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Content;
24 use Friendica\Model\FileTag;
27 * A content helper class for displaying items
32 * Return array with details for categories and folders for an item
35 * @return [array, array]
38 * [ // categories array
40 * 'name': 'category name',
41 * 'removeurl': 'url to remove this category',
42 * 'first': 'is the first in this array? true/false',
43 * 'last': 'is the last in this array? true/false',
49 * 'name': 'folder name',
50 * 'removeurl': 'url to remove this folder',
51 * 'first': 'is the first in this array? true/false',
52 * 'last': 'is the last in this array? true/false',
58 public function determineCategoriesTerms(array $item)
64 foreach (FileTag::fileToArray($item['file'] ?? '', 'category') as $savedFolderName) {
65 if (!empty($item['author-link'])) {
66 $url = $item['author-link'] . "?category=" . rawurlencode($savedFolderName);
71 'name' => $savedFolderName,
73 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : ""),
80 if (count($categories)) {
81 $categories[count($categories) - 1]['last'] = true;
84 if (local_user() == $item['uid']) {
85 foreach (FileTag::fileToArray($item['file'] ?? '') as $savedFolderName) {
87 'name' => $savedFolderName,
89 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : ""),
97 if (count($folders)) {
98 $folders[count($folders) - 1]['last'] = true;
101 return [$categories, $folders];