[COMPONENT] Posting form restructure and minor fixes
This commit is contained in:
parent
a8e43a4867
commit
bc66e2c2a2
@ -29,6 +29,7 @@ use App\Entity\FileToNote;
|
|||||||
use App\Entity\Note;
|
use App\Entity\Note;
|
||||||
use App\Util\Common;
|
use App\Util\Common;
|
||||||
use Component\Media\Media;
|
use Component\Media\Media;
|
||||||
|
use Component\Posting\Controller as C;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
@ -36,36 +37,47 @@ use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
|||||||
|
|
||||||
class Posting extends Module
|
class Posting extends Module
|
||||||
{
|
{
|
||||||
|
public function onAddRoute($r)
|
||||||
|
{
|
||||||
|
$r->connect('note_new', '/note/new/{reply_to<\d*>}',
|
||||||
|
[C\Post::class, 'note'], []);
|
||||||
|
}
|
||||||
|
|
||||||
public function onStartTwigPopulateVars(array &$vars)
|
public function onStartTwigPopulateVars(array &$vars)
|
||||||
{
|
{
|
||||||
if (Common::user() == null) {
|
if (Common::user() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$to_options = ['public' => _m('public'), 'instance' => _m('instance')];
|
$to_options = ['public' => _m('public'), 'instance' => _m('instance'), 'private' => _m('private')];
|
||||||
|
|
||||||
$id = Common::actor()->getId();
|
$id = Common::actor()->getId();
|
||||||
$to_tags = DB::dql('select c.tag from App\Entity\GSActorCircle c where c.tagger = :tagger', ['tagger' => $id]);
|
$to_tags = [];
|
||||||
foreach ($to_tags as $t) {
|
foreach (DB::dql('select c.tag from App\Entity\GSActorCircle c where c.tagger = :tagger', ['tagger' => $id]) as $t) {
|
||||||
$t = $t['tag'];
|
$t = $t['tag'];
|
||||||
$to_options[$t] = $t;
|
$to_tags[$t] = $t;
|
||||||
}
|
}
|
||||||
|
|
||||||
$empty_string = ['how are you feeling?...', 'Something to share?...', 'How was your day?...'];
|
$empty_string = ['How are you feeling?...', 'Something to share?...', 'How was your day?...'];
|
||||||
$rand_keys = array_rand($empty_string, 1);
|
$rand_keys = array_rand($empty_string, 1);
|
||||||
|
|
||||||
$request = $vars['request'];
|
$request = $vars['request'];
|
||||||
$form = Form::create([
|
$form = Form::create([
|
||||||
['content', TextareaType::class, [
|
['content', TextareaType::class, [
|
||||||
'label' => ' ',
|
'label' => ' ',
|
||||||
'data' => $empty_string[$rand_keys],
|
'data' => _m($empty_string[$rand_keys]),
|
||||||
]],
|
]],
|
||||||
['attachments', FileType::class, ['label' => _m(' '), 'multiple' => true, 'required' => false]],
|
['attachments', FileType::class, ['label' => _m(' '), 'multiple' => true, 'required' => false]],
|
||||||
['scope', ChoiceType::class, [
|
['visibility', ChoiceType::class, [
|
||||||
|
'label' => 'Visibility:',
|
||||||
|
'expanded' => true,
|
||||||
|
'choices' => $to_options,
|
||||||
|
]],
|
||||||
|
['to', ChoiceType::class, [
|
||||||
'label' => 'To:',
|
'label' => 'To:',
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => $to_options,
|
'choices' => $to_tags,
|
||||||
]],
|
]],
|
||||||
['send', SubmitType::class, ['label' => _m('Send')]],
|
['send', SubmitType::class, ['label' => _m('Send')]],
|
||||||
]);
|
]);
|
||||||
|
Loading…
Reference in New Issue
Block a user