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 rawContent()
28 $logger = $a->getLogger();
30 $term = XML::unescape(trim(defaults($_GET, 'term', '')));
31 // @TODO: Replace with parameter from router
32 $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
34 $logger->info('filer', ['tag' => $term, 'item' => $item_id]);
36 if ($item_id && strlen($term)) {
38 Model\FileTag::saveFile(local_user(), $item_id, $term);
39 info(L10n::t('Filetag %s saved to item', $term));
42 // return filer dialog
43 $filetags = PConfig::get(local_user(), 'system', 'filetags');
44 $filetags = Model\FileTag::fileToList($filetags, 'file');
45 $filetags = explode(",", $filetags);
47 $tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
48 echo Renderer::replaceMacros($tpl, [
49 '$field' => ['term', L10n::t("Save to Folder:"), '', '', $filetags, L10n::t('- select -')],
50 '$submit' => L10n::t('Save'),