Exemple #1
0
 /**
  * Return select object for the Restudy Kanji list.
  * 
  * @param  integer   $userId
  * 
  * @return coreDatabaseSelect
  */
 public static function getAllRestudyKanjiSelect($userId)
 {
     $select = self::getInstance()->select(array('reviews.framenum', 'keyword', 'successcount', 'failurecount', 'ts_lastreview' => 'UNIX_TIMESTAMP(lastreview)'))->joinLeftUsing(KanjisPeer::getInstance()->getName(), 'framenum')->where('leitnerbox=1 AND totalreviews>0');
     return self::filterByUserId($select, $userId);
 }
Exemple #2
0
 /**
  * Takes a string of Japanese text and returns the kanji with links to
  * the Study page, and the title attribute contains the RTK keyword.
  * 
  * @param string $compound 
  * 
  * @return string  Html markup
  */
 public static function getKeywordizedCompound($compound)
 {
     $chars = CJK::splitU($compound);
     //DBG::out(print_r($chars, true));
     $s = '';
     coreToolkit::loadHelpers(array('Tag', 'Url'));
     foreach ($chars as $c) {
         if (false !== ($framenum = rtkBook::getIndexForKanji($c))) {
             $keyword = KanjisPeer::getKeyword($framenum);
             // FIXME - internal uri should be '@study_edit?id=' once it goes to production site..
             $url = link_to($c, 'http://kanji.koohii.com/study/kanji/' . $c, array('title' => $keyword));
             $s = $s . $url;
         } else {
             $s = $s . $c;
         }
     }
     //DBG::out($s);exit;
     return $s;
 }
Exemple #3
0
 /**
  * Returns Select object for My Stories component.
  * 
  * @param
  * @return
  */
 public static function getMyStoriesSelect($user_id)
 {
     return self::getInstance()->select(array('stories.framenum', 'kanji', 'keyword', 'story' => 'text', 'stars', 'kicks', 'updated_on', 'dispdate' => 'DATE_FORMAT(updated_on, \'%b. %e, %Y\')'))->joinUsing(KanjisPeer::getInstance()->getName(), 'framenum')->joinLeft(StoryScoresPeer::TABLE, sprintf('authorid=%d AND stories.framenum=storiesscores.framenum', $user_id))->where('userid = ?', $user_id);
 }
Exemple #4
0
echo $kanjiData->framenum;
?>
</span>
        <div class="kanji"><?php 
echo cjk_lang_ja($kanjiData->kanji);
?>
</div>
        <span class="strokecount" title="Stroke count">[<?php 
echo $kanjiData->strokecount;
?>
]</span>
      </div>

      <div class="right">
        <div class="keyword"><?php 
echo KanjisPeer::getDisplayKeyword($kanjiData->keyword);
?>
</div>

        <?php 
echo form_errors();
?>

        <div id="storybox">

          <?php 
# Story Edit
?>
          <div id="storyedit" style="display:none;">

            <?php 
Exemple #5
0
 /**
  * Ajax handler for Shared Stories component.
  * 
  * uid & sid identify the story to vote/report/copy.
  * 
  * Post:
  * 
  *   request     "star": star story
  *               "report": report story
  *               "copy": copy story
  *   uid         User id of the Story's author
  *   sid         Story id (framenum)
  * 
  * @return 
  */
 public function executeAjax($request)
 {
     if ($request->getMethod() === coreRequest::GET) {
         // reload component
         $framenum = $request->getParameter('framenum', false);
         if (!BaseValidators::validateInteger($framenum)) {
             throw new rtkAjaxException('Bad request.');
         }
         $kanjiData = (object) KanjisPeer::getKanjiById($framenum);
         return $this->renderComponent('study', 'SharedStories', array('framenum' => $framenum, 'kanjiData' => $kanjiData));
     } else {
         $sRequest = $request->getParameter('request', '');
         $sUid = $request->getParameter('uid');
         $sSid = $request->getParameter('sid');
         if (!preg_match('/^(star|report|copy)$/', $sRequest) || !BaseValidators::validateInteger($sUid) || !BaseValidators::validateInteger($sSid)) {
             throw new rtkAjaxException('Badrequest');
         }
         if ($sRequest === 'copy') {
             // get unformatted story with original tags for copy story feature
             $oStory = StoriesPeer::getStory($sUid, $sSid);
             if ($oStory) {
                 $oJSON = new stdClass();
                 $oJSON->text = $oStory->text;
                 return $this->renderText(coreJson::encode($oJSON));
             }
         } elseif ($sRequest === 'star') {
             $oJSON = StoryVotesPeer::starStory($this->getUser()->getUserId(), $sUid, $sSid);
             return $this->renderText(coreJson::encode($oJSON));
         } elseif ($sRequest === 'report') {
             $oJSON = StoryVotesPeer::reportStory($this->getUser()->getUserId(), $sUid, $sSid);
             return $this->renderText(coreJson::encode($oJSON));
         }
     }
     throw new rtkAjaxException('Badrequest');
 }
Exemple #6
0
 /**
  * Takes a string of Japanese text and returns the kanji with links to
  * the Study page, and the title attribute contains the RTK keyword.
  * 
  * @param string $compound 
  * 
  * @return string  Html markup
  */
 public static function getKeywordizedCompound($compound)
 {
     $chars = CJK::splitU($compound);
     //DBG::out(print_r($chars, true));
     $s = '';
     coreToolkit::loadHelpers(array('Tag', 'Url'));
     foreach ($chars as $c) {
         if (false !== ($framenum = rtkBook::getIndexForKanji($c))) {
             $keyword = KanjisPeer::getKeyword($framenum);
             $url = link_to($c, '@study_edit?id=' . $c, array('title' => $keyword));
             $s = $s . $url;
         } else {
             $s = $s . $c;
         }
     }
     //DBG::out($s);exit;
     return $s;
 }