<?php class PrevWordCallbackHandler extends CallBackhandler { public static $key= "prevWord"; public static $spliter= "-"; function execute() { $wordAndIndex = explode(static::$spliter,$this->data); $searchedWord = $wordAndIndex[0]; $this->currentWordIndex = $wordAndIndex[1]; $this->searchedWord = $searchedWord; $this->translations = $this->getTG()->getDB()->getTrnslations( $searchedWord, $this->getTG()->getLang($searchedWord) ); $this->updateMessage($this->translations[$this->currentWordIndex-1]); } public function getParent() : EvaluationSystem{ return parent::getParent(); } public function getTG() : TranslateGerman { return parent::getSM(); } private function hasPrev(){ return $this->currentWordIndex > 1; } private function updateMessage($word) { $likeButton = $this->getTG()->getButtonService()->findButton(LikeWordCallbackHandler::$key); $dislikeButton = $this->getTG()->getButtonService()->findButton(DislikeWordCallbackHandler::$key); $prevButton = $this->getTG()->getButtonService()->findButton(PrevWordCallbackHandler::$key); $likeButton->setData($word['id']); $likeButton->setText("👍 ".$word['plusRate']); $dislikeButton->setData($word['id']); $dislikeButton->setText("👎 ".$word['minusRate']); $prevButtonData = $this->searchedWord.NextWordCallbackHandler::$spliter.($this->currentWordIndex-1); $prevButton->setData($prevButtonData); if(!$this->hasPrev()){ $this->getTG()->getButtonService()->deleteButton(PrevWordCallbackHandler::$key); } $nextButton = $this->getTG()->getButtonService()->findButton(NextWordCallbackHandler::$key); $nextButtonData = $this->searchedWord.NextWordCallbackHandler::$spliter.($this->currentWordIndex-1); $nextButton->setData($nextButtonData); $nextButton->setText("کلمه بعدی"); if(!$nextButton->getUsed()){ $this->getTG()->getButtonService()->addButton($nextButton); } $this->getTG()->getButtonService()->rebuildKeyboard(); $this->getTG()->editMultpleButtonsMessage( $this->getTG()->styleTranslation($word), $this->getTG()->getButtonService()->getKeyboardMarkedup() ); } } ?>
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
learn | Folder | 2755 |
|
|
DeDeTextTranslateCallbackHandler.class.php | File | 2.7 KB | 0755 |
|
DeFaTextTranslateCallbackHandler.class.php | File | 2.71 KB | 0755 |
|
DislikeWordCallbackHandler.class.php | File | 1.55 KB | 0755 |
|
FaDeTextTranslateCallbackHandler.class.php | File | 2.71 KB | 0755 |
|
LikeWordCallbackHandler.class.php | File | 1.53 KB | 0755 |
|
NextWordCallbackHandler.class.php | File | 2.61 KB | 0755 |
|
NotFoundCallbackHandler.class.php | File | 509 B | 0755 |
|
PrevWordCallbackHandler.class.php | File | 2.36 KB | 0755 |
|
ReportCallbackHandler.class.php | File | 1.21 KB | 0755 |
|
UserWantsEvaluateCallbackHandler.class.php | File | 1.96 KB | 0755 |
|