This commit is contained in:
silas 2018-07-14 18:09:00 +02:00
parent 31691c465b
commit 013783322f
106 changed files with 3429 additions and 432 deletions

0
.idea/misc.xml generated Normal file → Executable file
View File

0
.idea/modules.xml generated Normal file → Executable file
View File

0
.idea/php.xml generated Normal file → Executable file
View File

0
.idea/scopes/html.xml generated Normal file → Executable file
View File

0
.idea/scopes/js.xml generated Normal file → Executable file
View File

0
.idea/scopes/scss.xml generated Normal file → Executable file
View File

0
.idea/scopes/translator.xml generated Normal file → Executable file
View File

0
.idea/vcs.xml generated Normal file → Executable file
View File

0
.idea/watcherTasks.xml generated Normal file → Executable file
View File

1
.idea/wordRotator.iml generated Normal file → Executable file
View File

@ -3,7 +3,6 @@
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$"> <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/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" /> <excludeFolder url="file://$MODULE_DIR$/vendor/true/punycode" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />

0
bin/build.js Normal file → Executable file
View File

2
bin/concatTranslator.js Normal file → Executable file
View File

@ -37,7 +37,7 @@ for (var i = 0, n = moduleDirs.length; i < n; i++) {
for (var lang in translations) for (var lang in translations)
{ {
console.log(translations[lang]); // console.log(translations[lang]);
var langTranslations = JSON.stringify(translations[lang]); var langTranslations = JSON.stringify(translations[lang]);
fs.writeFile(outputDir+"/"+lang+".json", langTranslations, err => { fs.writeFile(outputDir+"/"+lang+".json", langTranslations, err => {
if (err){ if (err){

1
log/error.log Normal file → Executable file
View 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: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: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-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
View 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: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: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-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
View File

0
log/php_exceptions.log Normal file → Executable file
View File

0
orga/database.sql Normal file → Executable file
View File

0
orga/deleteLevels.txt Normal file → Executable file
View File

0
orga/requirements.list Normal file → Executable file
View File

0
public/.htaccess Normal file → Executable file
View File

0
public/core/css/core.css Normal file → Executable file
View File

0
public/core/css/flashMessenger.css Normal file → Executable file
View File

0
public/core/css/foundation.css vendored Normal file → Executable file
View File

0
public/core/css/framework.css Normal file → Executable file
View File

0
public/core/css/settingsSite.css Normal file → Executable file
View File

0
public/core/css/style.css Normal file → Executable file
View File

0
public/core/css/theme.css Normal file → Executable file
View File

0
public/core/html/load.html Normal file → Executable file
View File

0
public/core/html/settings.html Normal file → Executable file
View File

0
public/core/html/smartList.html Normal file → Executable file
View File

0
public/css/wordRotator.css Normal file → Executable file
View File

0
public/html/application/end.html Normal file → Executable file
View File

0
public/html/application/level.html Normal file → Executable file
View File

0
public/html/application/sync.html Normal file → Executable file
View File

0
public/img/share.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 558 B

After

Width:  |  Height:  |  Size: 558 B

0
public/img/sms.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

0
public/img/telegram.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 999 B

After

Width:  |  Height:  |  Size: 999 B

0
public/img/test.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

0
public/img/whatsapp.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

3408
public/js/app.js Normal file → Executable file

File diff suppressed because it is too large Load Diff

0
public/js/lang/de.json Normal file → Executable file
View File

0
public/js/lang/en.json Normal file → Executable file
View File

0
public/js/manifest.json Normal file → Executable file
View File

0
public/pwaAssets/css/pwaAssets.css Normal file → Executable file
View File

0
public/pwaAssets/html/fragment/tabbedFragment.html Normal file → Executable file
View File

0
public/userManagement/html/403.html Normal file → Executable file
View File

0
public/userManagement/html/editUserRoles.html Normal file → Executable file
View File

0
public/userManagement/html/forgotPassword.html Normal file → Executable file
View File

View File

0
public/userManagement/html/fragments/userSettings.html Normal file → Executable file
View File

0
public/userManagement/html/login.html Normal file → Executable file
View File

0
public/userManagement/html/registration.html Normal file → Executable file
View File

0
public/userManagement/html/setNewPassword.html Normal file → Executable file
View File

0
public/version/1/listjs/list.min.js vendored Normal file → Executable file
View File

0
rollup.config.js Normal file → Executable file
View File

21
src/js/init.js Normal file → Executable file
View File

@ -8,6 +8,13 @@ import {
Translator, Translator,
WhatsappShareButton WhatsappShareButton
} from "./lib/pwa-lib"; } 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 './settings'
// import {ClockSite} from "../module/Application/pwa/js/site/ClockSite"; // import {ClockSite} from "../module/Application/pwa/js/site/ClockSite";
import {LevelSite} from "../module/Application/pwa/js/site/LevelSite"; import {LevelSite} from "../module/Application/pwa/js/site/LevelSite";
@ -31,13 +38,13 @@ let app = new App();
app.setAddThemeAction(true); app.setAddThemeAction(true);
app.addDefaultAction(Translator.generateChangeLanguageMenuAction()); app.addDefaultAction(Translator.generateChangeLanguageMenuAction());
//bridge für Android // bridge für Android
// window["ThemeManager"] = ThemeManager; window["ThemeManager"] = ThemeManager;
// window["ThemeManager"]["addChangeListener"] = ThemeManager.addChangeListener; window["ThemeManager"]["addChangeListener"] = ThemeManager.addChangeListener;
// window["app"] = app; window["app"] = app;
// window["app"]["refreshCurrentSite"] = app.refreshCurrentSite; window["app"]["refreshCurrentSite"] = app.refreshCurrentSite;
// window["Translator"] = Translator; window["Translator"] = Translator;
// window["Translator"]["setLanguage"] = Translator.setLanguage; window["Translator"]["setLanguage"] = Translator.setLanguage;
InitPromise.resolve(app).then(function(){ InitPromise.resolve(app).then(function(){
app.start(SynchronizeSite); app.start(SynchronizeSite);

0
src/js/lib/pwa-assets.js Normal file → Executable file
View File

19
src/js/lib/pwa-code-management.js Normal file → Executable file
View File

@ -2,30 +2,25 @@ import { DataManager } from './pwa-core.js';
import { AbstractSite, FlashMessenger, Helper, InitPromise, Translator } from './pwa-lib.js'; import { AbstractSite, FlashMessenger, Helper, InitPromise, Translator } from './pwa-lib.js';
class Code { class Code {
constructor(args) constructor(args) {
{ if (typeof args === "string") {
if (typeof args === "string")
{
args = { args = {
"code":args "code": args
}; };
} }
this.args = args; this.args = args;
this.isCacheable = false; this.isCacheable = false;
} }
setIsCacheable(isCacheable) setIsCacheable(isCacheable) {
{
this.isCacheable = isCacheable; this.isCacheable = isCacheable;
} }
getIsCacheable() getIsCacheable() {
{
return this.isCacheable; return this.isCacheable;
} }
activate() activate() {
{
return DataManager.send("c/code", this.args); return DataManager.send("c/code", this.args);
} }
} }
@ -62,7 +57,7 @@ class CodeSite extends AbstractSite {
} }
InitPromise.addPromise(function (app) { InitPromise.addPromise(function (app) {
app.addDeepLink("code", CodeSite.name); app.addDeepLink("code", CodeSite);
}); });
export { Code, CodeSite }; export { Code, CodeSite };

0
src/js/lib/pwa-core.js Normal file → Executable file
View File

0
src/js/lib/pwa-cronjob.js Normal file → Executable file
View File

0
src/js/lib/pwa-lib.js Normal file → Executable file
View File

14
src/js/lib/pwa-user-management.js Normal file → Executable file
View File

@ -1801,7 +1801,7 @@ class UserSite extends AbstractSite$1{
onConstruct(args) { onConstruct(args) {
if (!UserManager.hasAccess(this._access)) if (!UserManager.hasAccess(this._access))
{ {
this.startSite(Achievement.name); this.startSite(Achievement);
this.finish({ this.finish({
"error":403 "error":403
}); });
@ -1813,7 +1813,7 @@ class UserSite extends AbstractSite$1{
onStart(args) { onStart(args) {
if (!UserManager.hasAccess(this._access)) if (!UserManager.hasAccess(this._access))
{ {
this.startSite(Achievement.name); this.startSite(Achievement);
this.finish({ this.finish({
"error":403 "error":403
}); });
@ -2082,7 +2082,7 @@ class EditUserRolesSite extends UserSite {
InitPromise.addPromise(function (app) { InitPromise.addPromise(function (app) {
app.addDeepLink("userRoles", EditUserRolesSite.name); app.addDeepLink("userRoles", EditUserRolesSite.name);
app.addDefaultAction(new UserAction('userRoles', function(){ app.addDefaultAction(new UserAction('userRoles', function(){
app.startSite(EditUserRolesSite.name); app.startSite(EditUserRolesSite);
}, null, 1100, "admin")); }, null, 1100, "admin"));
}); });
@ -2121,7 +2121,7 @@ class LoginSite extends UserSite{
}); });
this.findBy("#forgot-password-link").addEventListener("click", function(){ this.findBy("#forgot-password-link").addEventListener("click", function(){
self.startSite(Achievement.name); self.startSite(Achievement);
self.finish(); self.finish();
}); });
} }
@ -2129,7 +2129,7 @@ class LoginSite extends UserSite{
InitPromise.addPromise(function(app){ InitPromise.addPromise(function(app){
app.addDeepLink("login", LoginSite); app.addDeepLink("login", LoginSite);
app.addDefaultAction(new UserAction('login', function(){ app.addDefaultAction(new UserAction('login', function(){
app.startSite(LoginSite.name); app.startSite(LoginSite);
}, Menu.SHOW_NEVER, 1100, "offline")); }, Menu.SHOW_NEVER, 1100, "offline"));
app.addDefaultAction(new UserAction('logout', function(){ app.addDefaultAction(new UserAction('logout', function(){
UserManager.logOut(); UserManager.logOut();
@ -2157,7 +2157,7 @@ class RegistrationSite extends UserSite {
InitPromise.addPromise(function (app) { InitPromise.addPromise(function (app) {
app.addDeepLink("registration", RegistrationSite); app.addDeepLink("registration", RegistrationSite);
app.addDefaultAction(new UserAction('registration', function(){ app.addDefaultAction(new UserAction('registration', function(){
app.startSite(RegistrationSite.name); app.startSite(RegistrationSite);
}, null, 1100, "offline")); }, null, 1100, "offline"));
}); });
@ -2178,7 +2178,7 @@ class SetNewPasswordSite extends UserSite {
let self = this; let self = this;
(new Form(formElem, "c/code", "post")).onSubmit(function(res){ (new Form(formElem, "c/code", "post")).onSubmit(function(res){
FlashMessenger.addMessage(FlashMessenger.MESSAGE_TYPE_SUCCESS, Translator.translate("password-updated")); FlashMessenger.addMessage(FlashMessenger.MESSAGE_TYPE_SUCCESS, Translator.translate("password-updated"));
self.startSite(Achievement.name); self.startSite(Achievement);
self.finish(); self.finish();
}); });
} }

66
src/module/Application/config/routes/routes.sync.php Normal file → Executable file
View File

@ -16,17 +16,17 @@ return array(
'route' => '/wordRotator', 'route' => '/wordRotator',
], ],
'child_routes' => [ 'child_routes' => [
// 'words' => [ 'words' => [
// 'type' => Segment::class, 'type' => Segment::class,
// 'options' => [ 'options' => [
// 'route' => '/words', 'route' => '/words',
// 'defaults' => [ 'defaults' => [
// 'controller' => SyncController::class, 'controller' => SyncController::class,
// 'action' => 'getWords', 'action' => 'getWords',
// 'resource' => 'default', 'resource' => 'default',
// ] ]
// ], ],
// ], ],
'levels' => [ 'levels' => [
'type' => Segment::class, 'type' => Segment::class,
'options' => [ 'options' => [
@ -38,28 +38,28 @@ return array(
] ]
], ],
], ],
// 'getAuthToken' => [ 'getAuthToken' => [
// 'type' => Segment::class, 'type' => Segment::class,
// 'options' => [ 'options' => [
// 'route' => '/token', 'route' => '/token',
// 'defaults' => [ 'defaults' => [
// 'controller' => SyncController::class, 'controller' => SyncController::class,
// 'action' => 'getAuthToken', 'action' => 'getAuthToken',
// 'resource' => 'default', 'resource' => 'default',
// ] ]
// ], ],
// ], ],
// 'rate' => [ 'rate' => [
// 'type' => Segment::class, 'type' => Segment::class,
// 'options' => [ 'options' => [
// 'route' => '/rate', 'route' => '/rate',
// 'defaults' => [ 'defaults' => [
// 'controller' => SyncController::class, 'controller' => SyncController::class,
// 'action' => 'rate', 'action' => 'rate',
// 'resource' => 'default', 'resource' => 'default',
// ] ]
// ], ],
// ], ],
], ],
], ],
], ],

0
src/module/Application/pwa/html/application/end.html Normal file → Executable file
View File

0
src/module/Application/pwa/html/application/level.html Normal file → Executable file
View File

0
src/module/Application/pwa/html/application/sync.html Normal file → Executable file
View File

0
src/module/Application/pwa/js/WordRotatorDb.js Normal file → Executable file
View File

0
src/module/Application/pwa/js/site/EndSite.js Normal file → Executable file
View File

12
src/module/Application/pwa/js/site/LevelSite.js Normal file → Executable file
View File

@ -25,18 +25,6 @@ export class LevelSite extends AbstractSite {
} }
onConstruct(args) { 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); this.levelCounter = Helper.nonNull(localStorage.getItem("levelCounter"), 1);
return super.onConstruct(args); return super.onConstruct(args);
} }

0
src/module/Application/pwa/js/site/SynchronizeSite.js Normal file → Executable file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

0
src/module/Application/pwa/translations/de.json Normal file → Executable file
View File

0
src/module/Application/pwa/translations/en.json Normal file → Executable file
View File

316
src/module/Application/src/Controller/SyncController.php Normal file → Executable file
View File

@ -28,79 +28,79 @@ class SyncController extends JsonController
const MAX_RATINGS_PER_LEVEL = 2; const MAX_RATINGS_PER_LEVEL = 2;
// public function getAuthTokenAction() public function getAuthTokenAction()
// { {
// if (!$this->getRequest()->isPost()) { if (!$this->getRequest()->isPost()) {
// return $this->triggerDispatchError(404); 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 getWordsAction() /** @var AuthTokenManager $authTokenManager */
// { $authTokenManager = $this->get(AuthTokenManager::class);
// $request = $this->getRequest();
// if (!$request->isPost()) { $token = new AuthToken();
// return $this->triggerDispatchError(); $name = $this->getRequest()->getPost("name");
// } if (trim($name) == "") {
// return $this->triggerDispatchError(400);
// $this->getEventManager()->trigger(Module::EVENT_LOG, null, array( }
// "message" => "Synchronized Words: " . $request->toString(), $token->setName($name);
// "level" => Logger::INFO $token->setToken($authTokenManager->generateNewAuthToken());
// )); $authTokenManager->save($token);
//
// $currentRun = (int)$request->getPost("currentRun", null); $this->layout("layout/ajaxData");
// $dateLastSync = $request->getPost("dateLastSync", null); $viewModel = new ViewModel();
// if ($dateLastSync != null) { $viewModel->setTemplate("ajax/json");
// try { $viewModel->setVariable("json", [
// $dateLastSync = \DateTime::createFromFormat(self::DATETIME_SYNC_FORMAT, $dateLastSync); "result" => true,
// } catch (\Throwable $t) { "data" => [
// $dateLastSync = null; "authToken" => $token->getToken(),
// } ],
// } ]);
// return $viewModel;
// /** @var WordManager $wordManager */ }
// $wordManager = $this->get(WordManager::class);
// $newDate = new \DateTime(); public function getWordsAction()
// $words = $wordManager->wordsToArray($wordManager->findNewerThan($dateLastSync, $currentRun)); {
// $numberWordsToSync = $wordManager->countNewerThan($dateLastSync); $request = $this->getRequest();
// if (!$request->isPost()) {
// $this->layout("layout/ajaxData"); return $this->triggerDispatchError();
// $viewModel = new ViewModel(); }
// $viewModel->setTemplate("ajax/json");
// $viewModel->setVariable("json", [ $this->getEventManager()->trigger(Module::EVENT_LOG, null, array(
// "result" => true, "message" => "Synchronized Words: " . $request->toString(),
// "data" => [ "level" => Logger::INFO
// "countWords" => $numberWordsToSync, ));
// "currentSyncDate" => $newDate->format(self::DATETIME_SYNC_FORMAT),
// "currentRun" => $currentRun, $currentRun = (int)$request->getPost("currentRun", null);
// "maxRuns" => ceil($numberWordsToSync / SyncController::SYNC_MAX_WORDS), $dateLastSync = $request->getPost("dateLastSync", null);
// "words" => $words, if ($dateLastSync != null) {
// ], try {
// ]); $dateLastSync = \DateTime::createFromFormat(self::DATETIME_SYNC_FORMAT, $dateLastSync);
// return $viewModel; } 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() public function getLevelsAction()
{ {
@ -129,91 +129,91 @@ class SyncController extends JsonController
]; ];
} }
// public function rateAction() public function rateAction()
// { {
// $request = $this->getRequest(); $request = $this->getRequest();
// if (!$request->isPost()) { if (!$request->isPost()) {
// return $this->triggerDispatchError(404); return $this->triggerDispatchError(404);
// } }
//
// $this->getEventManager()->trigger(Module::EVENT_LOG, null, array( $this->getEventManager()->trigger(Module::EVENT_LOG, null, array(
// "message" => "Synchronized Level: " . $request->toString(), "message" => "Synchronized Level: " . $request->toString(),
// "level" => Logger::INFO "level" => Logger::INFO
// )); ));
//
// /** @var AuthTokenManager $authTokenManager */ /** @var AuthTokenManager $authTokenManager */
// $authTokenManager = $this->get(AuthTokenManager::class); $authTokenManager = $this->get(AuthTokenManager::class);
// $authToken = $authTokenManager->findOneByToken($request->getPost("authToken")); $authToken = $authTokenManager->findOneByToken($request->getPost("authToken"));
//
// if ($authToken == null) { if ($authToken == null) {
// return $this->triggerDispatchError(403); return $this->triggerDispatchError(403);
// } }
//
// /** @var RatingManager $ratingManager */ /** @var RatingManager $ratingManager */
// $ratingManager = $this->get(RatingManager::class); $ratingManager = $this->get(RatingManager::class);
//
// /** @var LevelManager $levelManager */ /** @var LevelManager $levelManager */
// $levelManager = $this->get(LevelManager::class); $levelManager = $this->get(LevelManager::class);
// $levelsArray = json_decode($request->getPost("levels"), true); $levelsArray = json_decode($request->getPost("levels"), true);
//
// $levels = []; $levels = [];
// foreach ($levelsArray as $levelArray) { foreach ($levelsArray as $levelArray) {
// $levelManager->beginTransaction(); $levelManager->beginTransaction();
//
// $words = json_encode($levelArray["words"]); $words = json_encode($levelArray["words"]);
// $rotations = json_encode($levelArray["rotations"]); $rotations = json_encode($levelArray["rotations"]);
// $level = $levelManager->findOneBy([ $level = $levelManager->findOneBy([
// "words" => $words, "words" => $words,
// "positions" => $rotations, "positions" => $rotations,
// "renderer" => $levelArray["rendererType"], "renderer" => $levelArray["rendererType"],
// "lang" => $levelArray["language"], "lang" => $levelArray["language"],
// ]); ]);
// if ($level == null) { if ($level == null) {
// $level = new Level(); $level = new Level();
// $level->setDeleted(false); $level->setDeleted(false);
// $level->setWords($words); $level->setWords($words);
// $level->setPositions($rotations); $level->setPositions($rotations);
// $level->setRenderer($levelArray["rendererType"]); $level->setRenderer($levelArray["rendererType"]);
// $level->setLang($levelArray["language"]); $level->setLang($levelArray["language"]);
// $level->setLastUpdated(new \DateTime()); $level->setLastUpdated(new \DateTime());
// $level->setDeleted(false); $level->setDeleted(false);
// $level->setDifficulty($levelArray["difficulty"]); $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); // $levelManager->save($level);
// } }
// $rating = $ratingManager->findOneBy([
// "level" => $level, $ratingManager->save($rating);
// "authToken" => $authToken, $levelManager->endTransaction();
// ]); $levels[] = $level;
// }
// if ($rating == null) { $this->layout("layout/ajaxData");
// $rating = new Rating(); $viewModel = new ViewModel();
// $rating->setAuthToken($authToken); $viewModel->setTemplate("ajax/json");
// $rating->setLevel($level); $viewModel->setVariable("json", [
// $level->getRatings()->add($rating); "result" => true,
// } "data" => [
// "levels" => $levelManager->levelsToArray($levels),
// $ratingScore = $levelArray["rating"]; ],
// $rating->setRating($ratingScore); ]);
// return $viewModel;
// 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;
// }
} }

0
src/module/Application/src/Model/AuthToken.php Normal file → Executable file
View File

0
src/module/Application/src/Model/Level.php Normal file → Executable file
View File

View File

View File

View File

View File

0
src/module/Application/src/Model/Rating.php Normal file → Executable file
View File

View File

View File

Some files were not shown because too many files have changed in this diff Show More