Registrierung deaktiviert
This commit is contained in:
parent
e5b6116ab3
commit
204f94e740
@ -61,4 +61,8 @@ return [
|
|||||||
// Session\Validator\HttpUserAgent::class,
|
// Session\Validator\HttpUserAgent::class,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
"userManager" => [
|
||||||
|
"canRegister" => false
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -1,18 +1,84 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
|
|
||||||
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
|
|
||||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Application\Controller;
|
namespace WordRotator\Controller;
|
||||||
|
|
||||||
use Ainias\Core\Controller\JsonController;
|
use Ainias\Core\Controller\OnlineController;
|
||||||
|
use Ainias\Core\Controller\ServiceActionController;
|
||||||
|
use Zend\View\Model\ViewModel;
|
||||||
|
|
||||||
class IndexController extends JsonController
|
class IndexController extends OnlineController
|
||||||
{
|
{
|
||||||
public function clockAction()
|
const LENGTH_WORDS_MIN = 12;
|
||||||
|
const LENGTH_WORDS_MAX = 12;
|
||||||
|
|
||||||
|
const NUMBER_WORDS_TO_CHECK_SIMULTANEOUSLY = 8;
|
||||||
|
|
||||||
|
public function indexAction()
|
||||||
{
|
{
|
||||||
return ["date" => (new \DateTime())->format("H:i:s, Y-m-d")];
|
/** @var SelectWordsBot $bot */
|
||||||
|
// $bot = $this->get(SelectWordsBot::class);
|
||||||
|
// $bot->setWebhook("");
|
||||||
|
// $bot->handleUpdates($bot->getUpdates());
|
||||||
|
// $bot->sendWordToCheck();
|
||||||
|
return new ViewModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function selectWordsAction()
|
||||||
|
{
|
||||||
|
/** @var WordManager $wordManager */
|
||||||
|
$wordManager = $this->get(WordManager::class);
|
||||||
|
$wordsNotChecked = $wordManager->countNotChecked(self::LENGTH_WORDS_MIN, self::LENGTH_WORDS_MAX);
|
||||||
|
$wordsDeleted = $wordManager->countDeleted(self::LENGTH_WORDS_MIN, self::LENGTH_WORDS_MAX);
|
||||||
|
$wordsChecked = $wordManager->countChecked(self::LENGTH_WORDS_MIN, self::LENGTH_WORDS_MAX);
|
||||||
|
$wordsUnsure = $wordManager->countUnsure(self::LENGTH_WORDS_MIN, self::LENGTH_WORDS_MAX);
|
||||||
|
|
||||||
|
$wordsToCheck = [];
|
||||||
|
for ($i = 0; $i < self::NUMBER_WORDS_TO_CHECK_SIMULTANEOUSLY; $i++) {
|
||||||
|
$wordsToCheck[] = $wordManager->getRandomWordNotChecked(self::LENGTH_WORDS_MIN, self::LENGTH_WORDS_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ViewModel([
|
||||||
|
"wordsNotChecked" => $wordsNotChecked,
|
||||||
|
"wordsDeleted" => $wordsDeleted,
|
||||||
|
"wordsChecked" => $wordsChecked,
|
||||||
|
"wordsUnsure" => $wordsUnsure,
|
||||||
|
"wordsToCheck" => $wordsToCheck,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function changeCheckedAction()
|
||||||
|
{
|
||||||
|
$request = $this->getRequest();
|
||||||
|
|
||||||
|
if (!$request->isPost()) {
|
||||||
|
return $this->triggerDispatchError(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$wordId = $request->getPost("wordId", "");
|
||||||
|
$action = $request->getPost("action", "");
|
||||||
|
|
||||||
|
/** @var WordManager $wordManager */
|
||||||
|
$wordManager = $this->get(WordManager::class);
|
||||||
|
$word = $wordManager->getEntityById($wordId);
|
||||||
|
|
||||||
|
if ($word == null) {
|
||||||
|
return $this->triggerDispatchError(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$word = WordManager::doAction($word, $action);
|
||||||
|
$wordManager->save($word);
|
||||||
|
|
||||||
|
$randomWordNotChecked = $wordManager->getRandomWordNotChecked(self::LENGTH_WORDS_MIN, self::LENGTH_WORDS_MAX);
|
||||||
|
|
||||||
|
$this->layout("layout/ajaxData");
|
||||||
|
$viewModel = new ViewModel();
|
||||||
|
$viewModel->setTemplate("ajax/json");
|
||||||
|
$viewModel->setVariable("json", [
|
||||||
|
"result" => true,
|
||||||
|
"data" => [
|
||||||
|
"newWord" => $wordManager->wordToArray($randomWordNotChecked),
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
return $viewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user