mirror of
https://github.com/friendica/friendica
synced 2025-04-25 01:10:12 +00:00
Move mod/filerm to src/Module/FilerM
This commit is contained in:
parent
0046e62077
commit
a052b098fc
4 changed files with 55 additions and 43 deletions
51
src/Module/Filer/RemoveTag.php
Normal file
51
src/Module/Filer/RemoveTag.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Module\Filer;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Model\FileTag;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
/**
|
||||
* Remove a tag from a file
|
||||
*/
|
||||
class RemoveTag extends BaseModule
|
||||
{
|
||||
public static function content()
|
||||
{
|
||||
if (!local_user()) {
|
||||
throw new HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
$app = self::getApp();
|
||||
$logger = $app->getLogger();
|
||||
|
||||
$item_id = (($app->argc > 1) ? intval($app->argv[1]) : 0);
|
||||
|
||||
$term = XML::unescape(trim(defaults($_GET, 'term', '')));
|
||||
$cat = XML::unescape(trim(defaults($_GET, 'cat', '')));
|
||||
|
||||
$category = (($cat) ? true : false);
|
||||
|
||||
if ($category) {
|
||||
$term = $cat;
|
||||
}
|
||||
|
||||
$logger->info('Filer - Remove Tag', [
|
||||
'term' => $term,
|
||||
'item' => $item_id,
|
||||
'category' => ($category ? 'true' : 'false')
|
||||
]);
|
||||
|
||||
if ($item_id && strlen($term)) {
|
||||
if (FileTag::unsaveFile(local_user(), $item_id, $term, $category)) {
|
||||
info('Item removed');
|
||||
}
|
||||
} else {
|
||||
info('Item was not deleted');
|
||||
}
|
||||
|
||||
$app->internalRedirect('/network?f=&file=' . rawurlencode($term));
|
||||
}
|
||||
}
|
55
src/Module/Filer/SaveTag.php
Normal file
55
src/Module/Filer/SaveTag.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Module\Filer;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Model;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
/**
|
||||
* Shows a dialog for adding tags to a file
|
||||
*/
|
||||
class SaveTag extends BaseModule
|
||||
{
|
||||
public static function init()
|
||||
{
|
||||
if (!local_user()) {
|
||||
info(L10n::t('You must be logged in to use this module'));
|
||||
self::getApp()->internalRedirect();
|
||||
}
|
||||
}
|
||||
|
||||
public static function rawContent()
|
||||
{
|
||||
$a = self::getApp();
|
||||
$logger = $a->getLogger();
|
||||
|
||||
$term = XML::unescape(trim(defaults($_GET, 'term', '')));
|
||||
// @TODO: Replace with parameter from router
|
||||
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
||||
|
||||
$logger->info('filer', ['tag' => $term, 'item' => $item_id]);
|
||||
|
||||
if ($item_id && strlen($term)) {
|
||||
// file item
|
||||
Model\FileTag::saveFile(local_user(), $item_id, $term);
|
||||
info(L10n::t('Filetag %s saved to item', $term));
|
||||
}
|
||||
|
||||
// return filer dialog
|
||||
$filetags = PConfig::get(local_user(), 'system', 'filetags');
|
||||
$filetags = Model\FileTag::fileToList($filetags, 'file');
|
||||
$filetags = explode(",", $filetags);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
|
||||
echo Renderer::replaceMacros($tpl, [
|
||||
'$field' => ['term', L10n::t("Save to Folder:"), '', '', $filetags, L10n::t('- select -')],
|
||||
'$submit' => L10n::t('Save'),
|
||||
]);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue