Example #1
0
 public function getLesson($r)
 {
     $book = new Dase_DBO_Book($this->db);
     $book->short_name = $r->get('short_name');
     $book->findOne();
     $lesson = new Dase_DBO_Lesson($this->db);
     $lesson->name = $r->get('lesson_name');
     $lesson->book_id = $book->id;
     $lesson->findOne();
     $lesson->getBook();
     $lesson->getWords();
     $t = new Dase_Template($r);
     //Simplified or Traditional Pref
     if (isset($_COOKIE['user_pref'])) {
         $pref = $_COOKIE['user_pref'];
         $t->assign('user_pref', $pref);
     } else {
         $t->assign('user_pref', 'simplified');
         setcookie('user_pref', 'simplified', time() + 60 * 60 * 24 * 14, '/');
     }
     //Card Preferences
     if (isset($_COOKIE['card_pref'])) {
         $pref = $_COOKIE['card_pref'];
         $t->assign('card_pref', $pref);
     } else {
         $t->assign('card_pref', 'pin-chi-eng');
         setcookie('card_pref', 'pin-chi-eng', time() + 60 * 60 * 24 * 14, '/');
     }
     $t->assign("book", $book);
     $t->assign("lesson", $lesson);
     $r->renderResponse($t->fetch('chinese_flashcards/lesson.tpl'));
 }
Example #2
0
 public function getLessons()
 {
     $lessons = new Dase_DBO_Lesson($this->db);
     $lessons->book_id = $this->id;
     $this->lessons = $lessons->findAll(1);
     return $this->lessons;
 }
<?php

include 'config.php';
$data = json_decode(file_get_contents('dump.json'), 1);
$books = new Dase_DBO_Book($db);
$i = 0;
foreach ($books->findAll(1) as $book) {
    $lesson = new Dase_DBO_Lesson($db);
    $lesson->book_id = $book->id;
    foreach ($lesson->findAll(1) as $less) {
        foreach ($data['items'] as $it) {
            $filename_prefix = $it['metadata']['filename_prefix'][0];
            $lesson_ident = $it['metadata']['lesson'][0];
            $english = $it['metadata']['english'][0];
            $simplified = $it['metadata']['simplified'][0];
            $traditional = $it['metadata']['traditional'][0];
            $word_index = $it['metadata']['word_index'][0];
            $pinyin = $it['metadata']['pinyin'][0];
            $sub_lesson = '';
            if (isset($it['metadata']['sub_lesson'])) {
                $sub_lesson = $it['metadata']['sub_lesson'][0];
                print $sub_lesson . "\n";
            }
            if ($filename_prefix == $book->ident && $less->name == $lesson_ident) {
                $word = new Dase_DBO_Word($db);
                $word->lesson_id = $less->id;
                $word->book_id = $lesson->book_id;
                $word->word_index = $word_index;
                $word->english = $english;
                $word->simplified = $simplified;
                $word->traditional = $traditional;
<?php

include 'config.php';
$words = new Dase_DBO_Word($db);
foreach ($words->findAll(1) as $word) {
    $lesson = new Dase_DBO_Lesson($db);
    $lesson->load($word->lesson_id);
    $word->book_id = $lesson->book_id;
    print $word;
    $word->update();
}