Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

55 lines
1.3 KiB

  1. <?php
  2. namespace Friendica\Module\Filer;
  3. use Friendica\BaseModule;
  4. use Friendica\Core\L10n;
  5. use Friendica\Core\Renderer;
  6. use Friendica\DI;
  7. use Friendica\Model;
  8. use Friendica\Util\XML;
  9. /**
  10. * Shows a dialog for adding tags to a file
  11. */
  12. class SaveTag extends BaseModule
  13. {
  14. public static function init(array $parameters = [])
  15. {
  16. if (!local_user()) {
  17. info(L10n::t('You must be logged in to use this module'));
  18. DI::baseUrl()->redirect();
  19. }
  20. }
  21. public static function rawContent(array $parameters = [])
  22. {
  23. $a = DI::app();
  24. $logger = DI::logger();
  25. $term = XML::unescape(trim($_GET['term'] ?? ''));
  26. // @TODO: Replace with parameter from router
  27. $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
  28. $logger->info('filer', ['tag' => $term, 'item' => $item_id]);
  29. if ($item_id && strlen($term)) {
  30. // file item
  31. Model\FileTag::saveFile(local_user(), $item_id, $term);
  32. info(L10n::t('Filetag %s saved to item', $term));
  33. }
  34. // return filer dialog
  35. $filetags = DI::pConfig()->get(local_user(), 'system', 'filetags', '');
  36. $filetags = Model\FileTag::fileToArray($filetags);
  37. $tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
  38. echo Renderer::replaceMacros($tpl, [
  39. '$field' => ['term', L10n::t("Save to Folder:"), '', '', $filetags, L10n::t('- select -')],
  40. '$submit' => L10n::t('Save'),
  41. ]);
  42. exit;
  43. }
  44. }