3 namespace Friendica\Module;
5 use Friendica\BaseModule;
6 use Friendica\Core\L10n;
7 use Friendica\Core\PConfig;
8 use Friendica\Core\Renderer;
10 use Friendica\Util\XML;
13 * Shows a dialog for adding tags to a file
15 class Filer extends BaseModule
17 public static function init()
20 info(L10n::t('You must be logged in to use this module'));
21 self::getApp()->internalRedirect();
25 public static function content()
28 $logger = $a->getLogger();
30 $term = XML::unescape(trim(defaults($_GET, 'term', '')));
31 $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
33 $logger->info('filer', ['tag' => $term, 'item' => $item_id]);
35 if ($item_id && strlen($term)) {
37 Model\FileTag::saveFile(local_user(), $item_id, $term);
38 info(L10n::t('Filetag %s saved to item', $term));
41 // return filer dialog
42 $filetags = PConfig::get(local_user(), 'system', 'filetags');
43 $filetags = Model\FileTag::fileToList($filetags, 'file');
44 $filetags = explode(",", $filetags);
46 $tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
47 return Renderer::replaceMacros($tpl, [
48 '$field' => ['term', L10n::t("Save to Folder:"), '', '', $filetags, L10n::t('- select -')],
49 '$submit' => L10n::t('Save'),