update
0
.idea/misc.xml
generated
Normal file → Executable file
0
.idea/modules.xml
generated
Normal file → Executable file
0
.idea/php.xml
generated
Normal file → Executable file
0
.idea/scopes/html.xml
generated
Normal file → Executable file
0
.idea/scopes/js.xml
generated
Normal file → Executable file
0
.idea/scopes/scss.xml
generated
Normal file → Executable file
0
.idea/scopes/translator.xml
generated
Normal file → Executable file
0
.idea/vcs.xml
generated
Normal file → Executable file
0
.idea/watcherTasks.xml
generated
Normal file → Executable file
1
.idea/wordRotator.iml
generated
Normal file → Executable file
@ -3,7 +3,6 @@
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/module/Application/src" isTestSource="false" packagePrefix="Application\" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/module/Application/pwa/html" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/true/punycode" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
|
||||
0
bin/build.js
Normal file → Executable file
2
bin/concatTranslator.js
Normal file → Executable file
@ -37,7 +37,7 @@ for (var i = 0, n = moduleDirs.length; i < n; i++) {
|
||||
|
||||
for (var lang in translations)
|
||||
{
|
||||
console.log(translations[lang]);
|
||||
// console.log(translations[lang]);
|
||||
var langTranslations = JSON.stringify(translations[lang]);
|
||||
fs.writeFile(outputDir+"/"+lang+".json", langTranslations, err => {
|
||||
if (err){
|
||||
|
||||
1
log/error.log
Normal file → Executable file
@ -4,3 +4,4 @@
|
||||
2018-05-23T08:29:19+02:00 ERR (3): Unable to resolve service "Application\Model\Manager\LevelManager" to a factory; are you certain you provided it during configuration? - ErrorCode: 0 File: /var/www/pwa/wordRotator/vendor/zendframework/zend-servicemanager/src/ServiceManager.php Line: 687
|
||||
2018-05-23T08:29:41+02:00 ERR (3): Unable to resolve service "Application\Model\Manager\LevelManager" to a factory; are you certain you provided it during configuration? - ErrorCode: 0 File: /var/www/pwa/wordRotator/vendor/zendframework/zend-servicemanager/src/ServiceManager.php Line: 687
|
||||
2018-05-23T08:43:12+02:00 ERR (3): Unable to resolve service "Application\Model\Manager\LevelManager" to a factory; are you certain you provided it during configuration? - ErrorCode: 0 File: /var/www/pwa/wordRotator/vendor/zendframework/zend-servicemanager/src/ServiceManager.php Line: 687
|
||||
2018-07-11T20:46:07+02:00 ERR (3): Your proxy directory "data/DoctrineORMModule/Proxy" must be writable - ErrorCode: 0 File: /var/www/pwa/wordRotator/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Exception/UnexpectedValueException.php Line: 40
|
||||
|
||||
1
log/log.log
Normal file → Executable file
@ -4,3 +4,4 @@
|
||||
2018-05-23T08:29:19+02:00 ERR (3): Unable to resolve service "Application\Model\Manager\LevelManager" to a factory; are you certain you provided it during configuration? - ErrorCode: 0 File: /var/www/pwa/wordRotator/vendor/zendframework/zend-servicemanager/src/ServiceManager.php Line: 687
|
||||
2018-05-23T08:29:41+02:00 ERR (3): Unable to resolve service "Application\Model\Manager\LevelManager" to a factory; are you certain you provided it during configuration? - ErrorCode: 0 File: /var/www/pwa/wordRotator/vendor/zendframework/zend-servicemanager/src/ServiceManager.php Line: 687
|
||||
2018-05-23T08:43:12+02:00 ERR (3): Unable to resolve service "Application\Model\Manager\LevelManager" to a factory; are you certain you provided it during configuration? - ErrorCode: 0 File: /var/www/pwa/wordRotator/vendor/zendframework/zend-servicemanager/src/ServiceManager.php Line: 687
|
||||
2018-07-11T20:46:07+02:00 ERR (3): Your proxy directory "data/DoctrineORMModule/Proxy" must be writable - ErrorCode: 0 File: /var/www/pwa/wordRotator/vendor/doctrine/common/lib/Doctrine/Common/Proxy/Exception/UnexpectedValueException.php Line: 40
|
||||
|
||||
0
log/php_error.log
Normal file → Executable file
0
log/php_exceptions.log
Normal file → Executable file
0
orga/database.sql
Normal file → Executable file
0
orga/deleteLevels.txt
Normal file → Executable file
0
orga/requirements.list
Normal file → Executable file
0
public/.htaccess
Normal file → Executable file
0
public/core/css/core.css
Normal file → Executable file
0
public/core/css/flashMessenger.css
Normal file → Executable file
0
public/core/css/foundation.css
vendored
Normal file → Executable file
0
public/core/css/framework.css
Normal file → Executable file
0
public/core/css/settingsSite.css
Normal file → Executable file
0
public/core/css/style.css
Normal file → Executable file
0
public/core/css/theme.css
Normal file → Executable file
0
public/core/html/load.html
Normal file → Executable file
0
public/core/html/settings.html
Normal file → Executable file
0
public/core/html/smartList.html
Normal file → Executable file
0
public/css/wordRotator.css
Normal file → Executable file
0
public/html/application/end.html
Normal file → Executable file
0
public/html/application/level.html
Normal file → Executable file
0
public/html/application/sync.html
Normal file → Executable file
0
public/img/share.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 558 B After Width: | Height: | Size: 558 B |
0
public/img/sms.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
0
public/img/telegram.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 999 B After Width: | Height: | Size: 999 B |
0
public/img/test.png
Normal file → Executable file
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
0
public/img/whatsapp.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
3408
public/js/app.js
Normal file → Executable file
0
public/js/lang/de.json
Normal file → Executable file
0
public/js/lang/en.json
Normal file → Executable file
0
public/js/manifest.json
Normal file → Executable file
0
public/pwaAssets/css/pwaAssets.css
Normal file → Executable file
0
public/pwaAssets/html/fragment/tabbedFragment.html
Normal file → Executable file
0
public/userManagement/html/403.html
Normal file → Executable file
0
public/userManagement/html/editUserRoles.html
Normal file → Executable file
0
public/userManagement/html/forgotPassword.html
Normal file → Executable file
0
public/userManagement/html/fragments/passwordSettings.html
Normal file → Executable file
0
public/userManagement/html/fragments/userSettings.html
Normal file → Executable file
0
public/userManagement/html/login.html
Normal file → Executable file
0
public/userManagement/html/registration.html
Normal file → Executable file
0
public/userManagement/html/setNewPassword.html
Normal file → Executable file
0
public/version/1/listjs/list.min.js
vendored
Normal file → Executable file
0
rollup.config.js
Normal file → Executable file
21
src/js/init.js
Normal file → Executable file
@ -8,6 +8,13 @@ import {
|
||||
Translator,
|
||||
WhatsappShareButton
|
||||
} from "./lib/pwa-lib";
|
||||
|
||||
import "./lib/pwa-lib"
|
||||
import "./lib/pwa-core"
|
||||
import "./lib/pwa-assets"
|
||||
import "./lib/pwa-code-management"
|
||||
import "./lib/pwa-user-management"
|
||||
|
||||
import './settings'
|
||||
// import {ClockSite} from "../module/Application/pwa/js/site/ClockSite";
|
||||
import {LevelSite} from "../module/Application/pwa/js/site/LevelSite";
|
||||
@ -31,13 +38,13 @@ let app = new App();
|
||||
app.setAddThemeAction(true);
|
||||
app.addDefaultAction(Translator.generateChangeLanguageMenuAction());
|
||||
|
||||
//bridge für Android
|
||||
// window["ThemeManager"] = ThemeManager;
|
||||
// window["ThemeManager"]["addChangeListener"] = ThemeManager.addChangeListener;
|
||||
// window["app"] = app;
|
||||
// window["app"]["refreshCurrentSite"] = app.refreshCurrentSite;
|
||||
// window["Translator"] = Translator;
|
||||
// window["Translator"]["setLanguage"] = Translator.setLanguage;
|
||||
// bridge für Android
|
||||
window["ThemeManager"] = ThemeManager;
|
||||
window["ThemeManager"]["addChangeListener"] = ThemeManager.addChangeListener;
|
||||
window["app"] = app;
|
||||
window["app"]["refreshCurrentSite"] = app.refreshCurrentSite;
|
||||
window["Translator"] = Translator;
|
||||
window["Translator"]["setLanguage"] = Translator.setLanguage;
|
||||
|
||||
InitPromise.resolve(app).then(function(){
|
||||
app.start(SynchronizeSite);
|
||||
|
||||
0
src/js/lib/pwa-assets.js
Normal file → Executable file
19
src/js/lib/pwa-code-management.js
Normal file → Executable file
@ -2,30 +2,25 @@ import { DataManager } from './pwa-core.js';
|
||||
import { AbstractSite, FlashMessenger, Helper, InitPromise, Translator } from './pwa-lib.js';
|
||||
|
||||
class Code {
|
||||
constructor(args)
|
||||
{
|
||||
if (typeof args === "string")
|
||||
{
|
||||
constructor(args) {
|
||||
if (typeof args === "string") {
|
||||
args = {
|
||||
"code":args
|
||||
"code": args
|
||||
};
|
||||
}
|
||||
this.args = args;
|
||||
this.isCacheable = false;
|
||||
}
|
||||
|
||||
setIsCacheable(isCacheable)
|
||||
{
|
||||
setIsCacheable(isCacheable) {
|
||||
this.isCacheable = isCacheable;
|
||||
}
|
||||
|
||||
getIsCacheable()
|
||||
{
|
||||
getIsCacheable() {
|
||||
return this.isCacheable;
|
||||
}
|
||||
|
||||
activate()
|
||||
{
|
||||
activate() {
|
||||
return DataManager.send("c/code", this.args);
|
||||
}
|
||||
}
|
||||
@ -62,7 +57,7 @@ class CodeSite extends AbstractSite {
|
||||
}
|
||||
|
||||
InitPromise.addPromise(function (app) {
|
||||
app.addDeepLink("code", CodeSite.name);
|
||||
app.addDeepLink("code", CodeSite);
|
||||
});
|
||||
|
||||
export { Code, CodeSite };
|
||||
|
||||
0
src/js/lib/pwa-core.js
Normal file → Executable file
0
src/js/lib/pwa-cronjob.js
Normal file → Executable file
0
src/js/lib/pwa-lib.js
Normal file → Executable file
14
src/js/lib/pwa-user-management.js
Normal file → Executable file
@ -1801,7 +1801,7 @@ class UserSite extends AbstractSite$1{
|
||||
onConstruct(args) {
|
||||
if (!UserManager.hasAccess(this._access))
|
||||
{
|
||||
this.startSite(Achievement.name);
|
||||
this.startSite(Achievement);
|
||||
this.finish({
|
||||
"error":403
|
||||
});
|
||||
@ -1813,7 +1813,7 @@ class UserSite extends AbstractSite$1{
|
||||
onStart(args) {
|
||||
if (!UserManager.hasAccess(this._access))
|
||||
{
|
||||
this.startSite(Achievement.name);
|
||||
this.startSite(Achievement);
|
||||
this.finish({
|
||||
"error":403
|
||||
});
|
||||
@ -2082,7 +2082,7 @@ class EditUserRolesSite extends UserSite {
|
||||
InitPromise.addPromise(function (app) {
|
||||
app.addDeepLink("userRoles", EditUserRolesSite.name);
|
||||
app.addDefaultAction(new UserAction('userRoles', function(){
|
||||
app.startSite(EditUserRolesSite.name);
|
||||
app.startSite(EditUserRolesSite);
|
||||
}, null, 1100, "admin"));
|
||||
});
|
||||
|
||||
@ -2121,7 +2121,7 @@ class LoginSite extends UserSite{
|
||||
});
|
||||
|
||||
this.findBy("#forgot-password-link").addEventListener("click", function(){
|
||||
self.startSite(Achievement.name);
|
||||
self.startSite(Achievement);
|
||||
self.finish();
|
||||
});
|
||||
}
|
||||
@ -2129,7 +2129,7 @@ class LoginSite extends UserSite{
|
||||
InitPromise.addPromise(function(app){
|
||||
app.addDeepLink("login", LoginSite);
|
||||
app.addDefaultAction(new UserAction('login', function(){
|
||||
app.startSite(LoginSite.name);
|
||||
app.startSite(LoginSite);
|
||||
}, Menu.SHOW_NEVER, 1100, "offline"));
|
||||
app.addDefaultAction(new UserAction('logout', function(){
|
||||
UserManager.logOut();
|
||||
@ -2157,7 +2157,7 @@ class RegistrationSite extends UserSite {
|
||||
InitPromise.addPromise(function (app) {
|
||||
app.addDeepLink("registration", RegistrationSite);
|
||||
app.addDefaultAction(new UserAction('registration', function(){
|
||||
app.startSite(RegistrationSite.name);
|
||||
app.startSite(RegistrationSite);
|
||||
}, null, 1100, "offline"));
|
||||
});
|
||||
|
||||
@ -2178,7 +2178,7 @@ class SetNewPasswordSite extends UserSite {
|
||||
let self = this;
|
||||
(new Form(formElem, "c/code", "post")).onSubmit(function(res){
|
||||
FlashMessenger.addMessage(FlashMessenger.MESSAGE_TYPE_SUCCESS, Translator.translate("password-updated"));
|
||||
self.startSite(Achievement.name);
|
||||
self.startSite(Achievement);
|
||||
self.finish();
|
||||
});
|
||||
}
|
||||
|
||||
66
src/module/Application/config/routes/routes.sync.php
Normal file → Executable file
@ -16,17 +16,17 @@ return array(
|
||||
'route' => '/wordRotator',
|
||||
],
|
||||
'child_routes' => [
|
||||
// 'words' => [
|
||||
// 'type' => Segment::class,
|
||||
// 'options' => [
|
||||
// 'route' => '/words',
|
||||
// 'defaults' => [
|
||||
// 'controller' => SyncController::class,
|
||||
// 'action' => 'getWords',
|
||||
// 'resource' => 'default',
|
||||
// ]
|
||||
// ],
|
||||
// ],
|
||||
'words' => [
|
||||
'type' => Segment::class,
|
||||
'options' => [
|
||||
'route' => '/words',
|
||||
'defaults' => [
|
||||
'controller' => SyncController::class,
|
||||
'action' => 'getWords',
|
||||
'resource' => 'default',
|
||||
]
|
||||
],
|
||||
],
|
||||
'levels' => [
|
||||
'type' => Segment::class,
|
||||
'options' => [
|
||||
@ -38,28 +38,28 @@ return array(
|
||||
]
|
||||
],
|
||||
],
|
||||
// 'getAuthToken' => [
|
||||
// 'type' => Segment::class,
|
||||
// 'options' => [
|
||||
// 'route' => '/token',
|
||||
// 'defaults' => [
|
||||
// 'controller' => SyncController::class,
|
||||
// 'action' => 'getAuthToken',
|
||||
// 'resource' => 'default',
|
||||
// ]
|
||||
// ],
|
||||
// ],
|
||||
// 'rate' => [
|
||||
// 'type' => Segment::class,
|
||||
// 'options' => [
|
||||
// 'route' => '/rate',
|
||||
// 'defaults' => [
|
||||
// 'controller' => SyncController::class,
|
||||
// 'action' => 'rate',
|
||||
// 'resource' => 'default',
|
||||
// ]
|
||||
// ],
|
||||
// ],
|
||||
'getAuthToken' => [
|
||||
'type' => Segment::class,
|
||||
'options' => [
|
||||
'route' => '/token',
|
||||
'defaults' => [
|
||||
'controller' => SyncController::class,
|
||||
'action' => 'getAuthToken',
|
||||
'resource' => 'default',
|
||||
]
|
||||
],
|
||||
],
|
||||
'rate' => [
|
||||
'type' => Segment::class,
|
||||
'options' => [
|
||||
'route' => '/rate',
|
||||
'defaults' => [
|
||||
'controller' => SyncController::class,
|
||||
'action' => 'rate',
|
||||
'resource' => 'default',
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
0
src/module/Application/pwa/html/application/end.html
Normal file → Executable file
0
src/module/Application/pwa/html/application/level.html
Normal file → Executable file
0
src/module/Application/pwa/html/application/sync.html
Normal file → Executable file
0
src/module/Application/pwa/js/WordRotatorDb.js
Normal file → Executable file
0
src/module/Application/pwa/js/site/EndSite.js
Normal file → Executable file
12
src/module/Application/pwa/js/site/LevelSite.js
Normal file → Executable file
@ -25,18 +25,6 @@ export class LevelSite extends AbstractSite {
|
||||
}
|
||||
|
||||
onConstruct(args) {
|
||||
let a0 = -1;
|
||||
let a1 = 1;
|
||||
for(let i = 0; i < 10; i++)
|
||||
{
|
||||
let tmp = 3*a1-2*a0;
|
||||
console.log("reg", i+2, tmp);
|
||||
console.log("other", i+2, Math.pow(2, i+3)-3);
|
||||
a0=a1;
|
||||
a1=tmp;
|
||||
}
|
||||
|
||||
|
||||
this.levelCounter = Helper.nonNull(localStorage.getItem("levelCounter"), 1);
|
||||
return super.onConstruct(args);
|
||||
}
|
||||
|
||||
0
src/module/Application/pwa/js/site/SynchronizeSite.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Level/FourWordsLevel.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Level/FourWordsLevel12.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Level/FourWordsLevel8.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Level/Level.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Level/LevelHelper.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Level/RowLevel.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Level/RowLevel10.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Level/RowLevel8.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Level/SimpleLevel.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Level/SixWordsRowLevel.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Level/SixWordsRowLevel12.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Level/SixWordsRowLevel8.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Segment/LeafSegment.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Segment/ParentSegment.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Segment/RowSegment.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Segment/Segment.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Segment/TemplateContainer.js
Normal file → Executable file
0
src/module/Application/pwa/js/wordrotator/Segment/TriangleSegment.js
Normal file → Executable file
0
src/module/Application/pwa/translations/de.json
Normal file → Executable file
0
src/module/Application/pwa/translations/en.json
Normal file → Executable file
316
src/module/Application/src/Controller/SyncController.php
Normal file → Executable file
@ -28,79 +28,79 @@ class SyncController extends JsonController
|
||||
|
||||
const MAX_RATINGS_PER_LEVEL = 2;
|
||||
|
||||
// public function getAuthTokenAction()
|
||||
// {
|
||||
// if (!$this->getRequest()->isPost()) {
|
||||
// return $this->triggerDispatchError(404);
|
||||
// }
|
||||
//
|
||||
// /** @var AuthTokenManager $authTokenManager */
|
||||
// $authTokenManager = $this->get(AuthTokenManager::class);
|
||||
//
|
||||
// $token = new AuthToken();
|
||||
// $name = $this->getRequest()->getPost("name");
|
||||
// if (trim($name) == "") {
|
||||
// return $this->triggerDispatchError(400);
|
||||
// }
|
||||
// $token->setName($name);
|
||||
// $token->setToken($authTokenManager->generateNewAuthToken());
|
||||
// $authTokenManager->save($token);
|
||||
//
|
||||
// $this->layout("layout/ajaxData");
|
||||
// $viewModel = new ViewModel();
|
||||
// $viewModel->setTemplate("ajax/json");
|
||||
// $viewModel->setVariable("json", [
|
||||
// "result" => true,
|
||||
// "data" => [
|
||||
// "authToken" => $token->getToken(),
|
||||
// ],
|
||||
// ]);
|
||||
// return $viewModel;
|
||||
// }
|
||||
public function getAuthTokenAction()
|
||||
{
|
||||
if (!$this->getRequest()->isPost()) {
|
||||
return $this->triggerDispatchError(404);
|
||||
}
|
||||
|
||||
// public function getWordsAction()
|
||||
// {
|
||||
// $request = $this->getRequest();
|
||||
// if (!$request->isPost()) {
|
||||
// return $this->triggerDispatchError();
|
||||
// }
|
||||
//
|
||||
// $this->getEventManager()->trigger(Module::EVENT_LOG, null, array(
|
||||
// "message" => "Synchronized Words: " . $request->toString(),
|
||||
// "level" => Logger::INFO
|
||||
// ));
|
||||
//
|
||||
// $currentRun = (int)$request->getPost("currentRun", null);
|
||||
// $dateLastSync = $request->getPost("dateLastSync", null);
|
||||
// if ($dateLastSync != null) {
|
||||
// try {
|
||||
// $dateLastSync = \DateTime::createFromFormat(self::DATETIME_SYNC_FORMAT, $dateLastSync);
|
||||
// } catch (\Throwable $t) {
|
||||
// $dateLastSync = null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /** @var WordManager $wordManager */
|
||||
// $wordManager = $this->get(WordManager::class);
|
||||
// $newDate = new \DateTime();
|
||||
// $words = $wordManager->wordsToArray($wordManager->findNewerThan($dateLastSync, $currentRun));
|
||||
// $numberWordsToSync = $wordManager->countNewerThan($dateLastSync);
|
||||
//
|
||||
// $this->layout("layout/ajaxData");
|
||||
// $viewModel = new ViewModel();
|
||||
// $viewModel->setTemplate("ajax/json");
|
||||
// $viewModel->setVariable("json", [
|
||||
// "result" => true,
|
||||
// "data" => [
|
||||
// "countWords" => $numberWordsToSync,
|
||||
// "currentSyncDate" => $newDate->format(self::DATETIME_SYNC_FORMAT),
|
||||
// "currentRun" => $currentRun,
|
||||
// "maxRuns" => ceil($numberWordsToSync / SyncController::SYNC_MAX_WORDS),
|
||||
// "words" => $words,
|
||||
// ],
|
||||
// ]);
|
||||
// return $viewModel;
|
||||
// }
|
||||
/** @var AuthTokenManager $authTokenManager */
|
||||
$authTokenManager = $this->get(AuthTokenManager::class);
|
||||
|
||||
$token = new AuthToken();
|
||||
$name = $this->getRequest()->getPost("name");
|
||||
if (trim($name) == "") {
|
||||
return $this->triggerDispatchError(400);
|
||||
}
|
||||
$token->setName($name);
|
||||
$token->setToken($authTokenManager->generateNewAuthToken());
|
||||
$authTokenManager->save($token);
|
||||
|
||||
$this->layout("layout/ajaxData");
|
||||
$viewModel = new ViewModel();
|
||||
$viewModel->setTemplate("ajax/json");
|
||||
$viewModel->setVariable("json", [
|
||||
"result" => true,
|
||||
"data" => [
|
||||
"authToken" => $token->getToken(),
|
||||
],
|
||||
]);
|
||||
return $viewModel;
|
||||
}
|
||||
|
||||
public function getWordsAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
if (!$request->isPost()) {
|
||||
return $this->triggerDispatchError();
|
||||
}
|
||||
|
||||
$this->getEventManager()->trigger(Module::EVENT_LOG, null, array(
|
||||
"message" => "Synchronized Words: " . $request->toString(),
|
||||
"level" => Logger::INFO
|
||||
));
|
||||
|
||||
$currentRun = (int)$request->getPost("currentRun", null);
|
||||
$dateLastSync = $request->getPost("dateLastSync", null);
|
||||
if ($dateLastSync != null) {
|
||||
try {
|
||||
$dateLastSync = \DateTime::createFromFormat(self::DATETIME_SYNC_FORMAT, $dateLastSync);
|
||||
} catch (\Throwable $t) {
|
||||
$dateLastSync = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** @var WordManager $wordManager */
|
||||
$wordManager = $this->get(WordManager::class);
|
||||
$newDate = new \DateTime();
|
||||
$words = $wordManager->wordsToArray($wordManager->findNewerThan($dateLastSync, $currentRun));
|
||||
$numberWordsToSync = $wordManager->countNewerThan($dateLastSync);
|
||||
|
||||
$this->layout("layout/ajaxData");
|
||||
$viewModel = new ViewModel();
|
||||
$viewModel->setTemplate("ajax/json");
|
||||
$viewModel->setVariable("json", [
|
||||
"result" => true,
|
||||
"data" => [
|
||||
"countWords" => $numberWordsToSync,
|
||||
"currentSyncDate" => $newDate->format(self::DATETIME_SYNC_FORMAT),
|
||||
"currentRun" => $currentRun,
|
||||
"maxRuns" => ceil($numberWordsToSync / SyncController::SYNC_MAX_WORDS),
|
||||
"words" => $words,
|
||||
],
|
||||
]);
|
||||
return $viewModel;
|
||||
}
|
||||
|
||||
public function getLevelsAction()
|
||||
{
|
||||
@ -129,91 +129,91 @@ class SyncController extends JsonController
|
||||
];
|
||||
}
|
||||
|
||||
// public function rateAction()
|
||||
// {
|
||||
// $request = $this->getRequest();
|
||||
// if (!$request->isPost()) {
|
||||
// return $this->triggerDispatchError(404);
|
||||
// }
|
||||
//
|
||||
// $this->getEventManager()->trigger(Module::EVENT_LOG, null, array(
|
||||
// "message" => "Synchronized Level: " . $request->toString(),
|
||||
// "level" => Logger::INFO
|
||||
// ));
|
||||
//
|
||||
// /** @var AuthTokenManager $authTokenManager */
|
||||
// $authTokenManager = $this->get(AuthTokenManager::class);
|
||||
// $authToken = $authTokenManager->findOneByToken($request->getPost("authToken"));
|
||||
//
|
||||
// if ($authToken == null) {
|
||||
// return $this->triggerDispatchError(403);
|
||||
// }
|
||||
//
|
||||
// /** @var RatingManager $ratingManager */
|
||||
// $ratingManager = $this->get(RatingManager::class);
|
||||
//
|
||||
// /** @var LevelManager $levelManager */
|
||||
// $levelManager = $this->get(LevelManager::class);
|
||||
// $levelsArray = json_decode($request->getPost("levels"), true);
|
||||
//
|
||||
// $levels = [];
|
||||
// foreach ($levelsArray as $levelArray) {
|
||||
// $levelManager->beginTransaction();
|
||||
//
|
||||
// $words = json_encode($levelArray["words"]);
|
||||
// $rotations = json_encode($levelArray["rotations"]);
|
||||
// $level = $levelManager->findOneBy([
|
||||
// "words" => $words,
|
||||
// "positions" => $rotations,
|
||||
// "renderer" => $levelArray["rendererType"],
|
||||
// "lang" => $levelArray["language"],
|
||||
// ]);
|
||||
// if ($level == null) {
|
||||
// $level = new Level();
|
||||
// $level->setDeleted(false);
|
||||
// $level->setWords($words);
|
||||
// $level->setPositions($rotations);
|
||||
// $level->setRenderer($levelArray["rendererType"]);
|
||||
// $level->setLang($levelArray["language"]);
|
||||
// $level->setLastUpdated(new \DateTime());
|
||||
// $level->setDeleted(false);
|
||||
// $level->setDifficulty($levelArray["difficulty"]);
|
||||
public function rateAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
if (!$request->isPost()) {
|
||||
return $this->triggerDispatchError(404);
|
||||
}
|
||||
|
||||
$this->getEventManager()->trigger(Module::EVENT_LOG, null, array(
|
||||
"message" => "Synchronized Level: " . $request->toString(),
|
||||
"level" => Logger::INFO
|
||||
));
|
||||
|
||||
/** @var AuthTokenManager $authTokenManager */
|
||||
$authTokenManager = $this->get(AuthTokenManager::class);
|
||||
$authToken = $authTokenManager->findOneByToken($request->getPost("authToken"));
|
||||
|
||||
if ($authToken == null) {
|
||||
return $this->triggerDispatchError(403);
|
||||
}
|
||||
|
||||
/** @var RatingManager $ratingManager */
|
||||
$ratingManager = $this->get(RatingManager::class);
|
||||
|
||||
/** @var LevelManager $levelManager */
|
||||
$levelManager = $this->get(LevelManager::class);
|
||||
$levelsArray = json_decode($request->getPost("levels"), true);
|
||||
|
||||
$levels = [];
|
||||
foreach ($levelsArray as $levelArray) {
|
||||
$levelManager->beginTransaction();
|
||||
|
||||
$words = json_encode($levelArray["words"]);
|
||||
$rotations = json_encode($levelArray["rotations"]);
|
||||
$level = $levelManager->findOneBy([
|
||||
"words" => $words,
|
||||
"positions" => $rotations,
|
||||
"renderer" => $levelArray["rendererType"],
|
||||
"lang" => $levelArray["language"],
|
||||
]);
|
||||
if ($level == null) {
|
||||
$level = new Level();
|
||||
$level->setDeleted(false);
|
||||
$level->setWords($words);
|
||||
$level->setPositions($rotations);
|
||||
$level->setRenderer($levelArray["rendererType"]);
|
||||
$level->setLang($levelArray["language"]);
|
||||
$level->setLastUpdated(new \DateTime());
|
||||
$level->setDeleted(false);
|
||||
$level->setDifficulty($levelArray["difficulty"]);
|
||||
$levelManager->save($level);
|
||||
}
|
||||
$rating = $ratingManager->findOneBy([
|
||||
"level" => $level,
|
||||
"authToken" => $authToken,
|
||||
]);
|
||||
|
||||
if ($rating == null) {
|
||||
$rating = new Rating();
|
||||
$rating->setAuthToken($authToken);
|
||||
$rating->setLevel($level);
|
||||
$level->getRatings()->add($rating);
|
||||
}
|
||||
|
||||
$ratingScore = $levelArray["rating"];
|
||||
$rating->setRating($ratingScore);
|
||||
|
||||
if ($level->getRatings()->count() >= self::MAX_RATINGS_PER_LEVEL || $ratingScore < 0) {
|
||||
$level->setDeleted(true);
|
||||
$level->setLastUpdated(new \DateTime());
|
||||
// $levelManager->save($level);
|
||||
// }
|
||||
// $rating = $ratingManager->findOneBy([
|
||||
// "level" => $level,
|
||||
// "authToken" => $authToken,
|
||||
// ]);
|
||||
//
|
||||
// if ($rating == null) {
|
||||
// $rating = new Rating();
|
||||
// $rating->setAuthToken($authToken);
|
||||
// $rating->setLevel($level);
|
||||
// $level->getRatings()->add($rating);
|
||||
// }
|
||||
//
|
||||
// $ratingScore = $levelArray["rating"];
|
||||
// $rating->setRating($ratingScore);
|
||||
//
|
||||
// if ($level->getRatings()->count() >= self::MAX_RATINGS_PER_LEVEL || $ratingScore < 0) {
|
||||
// $level->setDeleted(true);
|
||||
// $level->setLastUpdated(new \DateTime());
|
||||
//// $levelManager->save($level);
|
||||
// }
|
||||
//
|
||||
// $ratingManager->save($rating);
|
||||
// $levelManager->endTransaction();
|
||||
// $levels[] = $level;
|
||||
// }
|
||||
// $this->layout("layout/ajaxData");
|
||||
// $viewModel = new ViewModel();
|
||||
// $viewModel->setTemplate("ajax/json");
|
||||
// $viewModel->setVariable("json", [
|
||||
// "result" => true,
|
||||
// "data" => [
|
||||
// "levels" => $levelManager->levelsToArray($levels),
|
||||
// ],
|
||||
// ]);
|
||||
// return $viewModel;
|
||||
// }
|
||||
}
|
||||
|
||||
$ratingManager->save($rating);
|
||||
$levelManager->endTransaction();
|
||||
$levels[] = $level;
|
||||
}
|
||||
$this->layout("layout/ajaxData");
|
||||
$viewModel = new ViewModel();
|
||||
$viewModel->setTemplate("ajax/json");
|
||||
$viewModel->setVariable("json", [
|
||||
"result" => true,
|
||||
"data" => [
|
||||
"levels" => $levelManager->levelsToArray($levels),
|
||||
],
|
||||
]);
|
||||
return $viewModel;
|
||||
}
|
||||
}
|
||||