2012-03-13 21:13:03 -04:00
|
|
|
<?php
|
2018-01-22 07:29:50 -05:00
|
|
|
/**
|
|
|
|
* @file mod/filer.php
|
|
|
|
*/
|
2017-04-30 00:07:00 -04:00
|
|
|
use Friendica\App;
|
2018-01-22 07:29:50 -05:00
|
|
|
use Friendica\Core\L10n;
|
2018-10-29 17:20:46 -04:00
|
|
|
use Friendica\Core\Logger;
|
2017-11-06 21:22:52 -05:00
|
|
|
use Friendica\Core\PConfig;
|
2018-10-31 10:35:50 -04:00
|
|
|
use Friendica\Core\Renderer;
|
2018-10-30 14:51:45 -04:00
|
|
|
use Friendica\Model\FileTag;
|
2017-04-30 00:07:00 -04:00
|
|
|
|
2018-01-22 07:29:50 -05:00
|
|
|
require_once 'include/items.php';
|
2012-03-13 21:13:03 -04:00
|
|
|
|
2018-01-22 07:29:50 -05:00
|
|
|
function filer_content(App $a)
|
|
|
|
{
|
2016-12-20 05:56:34 -05:00
|
|
|
if (! local_user()) {
|
2012-03-13 21:13:03 -04:00
|
|
|
killme();
|
|
|
|
}
|
|
|
|
|
2018-07-18 15:41:24 -04:00
|
|
|
$term = unxmlify(trim(defaults($_GET, 'term', '')));
|
2012-03-31 18:25:17 -04:00
|
|
|
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
2012-03-13 21:13:03 -04:00
|
|
|
|
2018-10-29 17:20:46 -04:00
|
|
|
Logger::log('filer: tag ' . $term . ' item ' . $item_id);
|
2012-03-13 21:13:03 -04:00
|
|
|
|
2018-01-22 07:29:50 -05:00
|
|
|
if ($item_id && strlen($term)) {
|
2012-03-28 04:49:34 -04:00
|
|
|
// file item
|
2018-10-30 14:51:45 -04:00
|
|
|
FileTag::saveFile(local_user(), $item_id, $term);
|
2012-03-28 04:49:34 -04:00
|
|
|
} else {
|
|
|
|
// return filer dialog
|
2018-01-22 07:29:50 -05:00
|
|
|
$filetags = PConfig::get(local_user(), 'system', 'filetags');
|
2018-10-30 14:51:45 -04:00
|
|
|
$filetags = FileTag::fileToList($filetags, 'file');
|
2018-01-22 07:29:50 -05:00
|
|
|
$filetags = explode(",", $filetags);
|
2012-12-22 14:57:29 -05:00
|
|
|
|
2018-10-31 10:44:06 -04:00
|
|
|
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
|
2018-10-31 10:35:50 -04:00
|
|
|
$o = Renderer::replaceMacros($tpl, [
|
2018-01-22 07:29:50 -05:00
|
|
|
'$field' => ['term', L10n::t("Save to Folder:"), '', '', $filetags, L10n::t('- select -')],
|
|
|
|
'$submit' => L10n::t('Save'),
|
2018-01-15 08:05:12 -05:00
|
|
|
]);
|
2017-01-09 07:12:54 -05:00
|
|
|
|
2012-03-28 04:49:34 -04:00
|
|
|
echo $o;
|
|
|
|
}
|
2012-03-13 21:13:03 -04:00
|
|
|
killme();
|
|
|
|
}
|