コード例 #1
0
ファイル: actions.php プロジェクト: kc5nra/RevTK
 /**
  * Study Page Search
  * 
  * Convert the search term to a framenum parameter and forward to index.
  * 
  * @url  /study/search/:search
  *
  */
 public function executeEdit($request)
 {
     $search = trim($request->getParameter('id', ''));
     if (!empty($search)) {
         $search = CJK::normalizeFullWidthRomanCharacters($search);
         // update search box with cleaned up search term
         $request->setParameter('search', str_replace('_', '/', $search));
         $framenum = KanjisPeer::getFramenumForSearch($search);
     }
     if ($request->getMethod() === coreRequest::POST) {
         // Handle POST request from EditStory component.
         $this->forward404Unless(BaseValidators::validateInteger($framenum) && intval($framenum));
         // Learned kanji (doLearned.x, from input type="image")
         if ($request->hasParameter('doLearned_x')) {
             LearnedKanjiPeer::addKanji($this->getUser()->getUserId(), $framenum);
             // redirect to next restudy kanji
             $next = ReviewsPeer::getNextUnlearnedKanji($this->getUser()->getUserId());
             if ($next !== false) {
                 $this->redirect('study/edit?id=' . $next);
             }
         }
     }
     $request->setParameter('framenum', $framenum);
     if ($framenum) {
         $this->framenum = $framenum;
         $this->kanjiData = (object) KanjisPeer::getKanjiById($this->framenum);
         $this->getResponse()->setTitle('Study: ' . $this->kanjiData->kanji . ' "' . $this->kanjiData->keyword . '"');
     } else {
         $this->framenum = false;
     }
 }
コード例 #2
0
ファイル: actions.php プロジェクト: nikitakit/RevTK
 /**
  * Study Page Search
  * 
  * Convert the search term to a framenum parameter and forward to index.
  * 
  * @url  /study/search/:search
  *
  */
 public function executeEdit($request)
 {
     // searching or browsing (previous, next buttons)
     if ($request->getMethod() === coreRequest::GET) {
         // get search term from url
         $search = trim($request->getParameter('id', ''));
         if (!empty($search)) {
             $search = CJK::normalizeFullWidthRomanCharacters($search);
             // replace characters that caused problems (dashes) with wildcard for SQL
             $search = str_replace('-', '%', $search);
             $framenum = KanjisPeer::getFramenumForSearch($search);
         }
     } else {
         // POST handled by EditStoryComponent, LearnedKanji handled here
         $framenum = $request->getParameter('framenum', false);
         // Handle POST request from EditStory component.
         $this->forward404Unless(BaseValidators::validateInteger($framenum) && intval($framenum));
         // Learned kanji (doLearned.x, from input type="image")
         if ($request->hasParameter('doLearned_x')) {
             LearnedKanjiPeer::addKanji($this->getUser()->getUserId(), $framenum);
             // redirect to next restudy kanji
             $next = ReviewsPeer::getNextUnlearnedKanji($this->getUser()->getUserId());
             if ($next !== false) {
                 $this->redirect('study/edit?id=' . $next);
             }
         }
     }
     if ($framenum) {
         $this->kanjiData = (object) KanjisPeer::getKanjiById($framenum);
         $this->getResponse()->setTitle('Study: ' . $this->kanjiData->kanji . ' "' . $this->kanjiData->keyword . '"');
         // replace search term with frame number in search box
         $request->setParameter('search', $this->kanjiData->framenum);
     } else {
         // search gave no results
         $this->kanjiData = false;
     }
 }