Exemplo n.º 1
0
 public function action_index()
 {
     $data["trial"] = Model_Content::find("all", ["where" => [["type_id", -1], ["deleted_at", 0]], "order_by" => [["number", "asc"], ["text_type_id", "asc"]]]);
     $data["enchant"] = Model_Content::find("all", ["where" => [["type_id", 0], ["deleted_at", 0]], "order_by" => [["number", "asc"], ["text_type_id", "asc"]]]);
     $view = View::forge("teachers/textbooks", $data);
     $this->template->content = $view;
 }
Exemplo n.º 2
0
 public function action_index()
 {
     $data["trial"] = Model_Content::find("all", ["where" => [["type_id", -1], ["deleted_at", 0]], "order_by" => [["number", "asc"], ["text_type_id", "asc"]]]);
     $data["enchantJS"] = Model_Content::find("all", ["where" => [["type_id", 0], ["deleted_at", 0]], "order_by" => [["number", "asc"], ["text_type_id", "asc"]]]);
     $data["count_text_enchant"] = Model_Content::find("all", ["where" => [["type_id", 0], ["deleted_at", 0], ["text_type_id", 0]], "order_by" => [["number", "asc"], ["text_type_id", "asc"]]]);
     $data["user"] = $this->user;
     $data["count_enchant"] = Model_Lessontime::count(["where" => [["language", 0], ["student_id", $this->user->id], ["status", 2], ["deleted_at", 0]]]);
     $data["done_html"] = Model_Lessontime::count(["where" => [["student_id", $this->user->id], ["status", 2], ["language", 0]]]);
     $data["pasts"] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", 0)], ["deleted_at", 0]]]);
     $data["donetrial"] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", -1)], ["deleted_at", 0]]]);
     $view = View::forge("students/textbooks", $data);
     $this->template->content = $view;
 }
Exemplo n.º 3
0
 public function post_changecontenttype()
 {
     $code = 0;
     $message = "ok";
     if ($this->auth_status) {
         $content = Model_Content::find(Input::post("id", 0));
         if ($content != null) {
             $content->type_id = Input::post("type_id", 0);
             $content->text_type_id = Input::post("text_type_id", 0);
             $content->exam = NULL;
             $content->save();
         } else {
             $code = 404;
             $message = "Content not found.";
         }
     } else {
         $code = 500;
         $message = "Auth error.";
     }
     $this->response(array('code' => $code, 'message' => $message));
 }
Exemplo n.º 4
0
            echo $reservation->number;
            ?>
 / 12 Lessons
						<?php 
        } else {
            ?>
							<span class="icon-course1"><?php 
            echo Model_Lessontime::getCourse($reservation->language);
            ?>
</span>
						<?php 
        }
        ?>
					</div>
					<?php 
        $text = Model_Content::find("first", ["where" => [["number", $reservation->number], ["type_id", $reservation->language], ["text_type_id", 0], ["deleted_at", 0]]]);
        if ($text != null) {
            ?>
					<p class="textbook"><?php 
            echo Html::anchor("contents/{$text->path}", '<i class="fa fa-fw fa-book"></i> ', ["target" => "_blank"]);
            ?>
</p>
					<?php 
        }
        ?>
				</li>
				<?php 
    }
    ?>
			</ul>
			<?php 
Exemplo n.º 5
0
 public function action_index()
 {
     if (Input::post("t_id", 0) != 0) {
         $content = Model_Content::find(Input::post("t_id", 0));
         if ($content != null) {
             $content->text_type_id = Input::post("text_type_id", 0);
             $content->save();
         }
     }
     if (Input::post("n_id", 0) != 0) {
         $content = Model_Content::find(Input::post("n_id", 0));
         if ($content != null) {
             $content->number = Input::post("number", 0);
             $content->save();
         }
     }
     if (Input::post("e_id", 0) != 0) {
         $content = Model_Content::find(Input::post("e_id", 0));
         if ($content != null) {
             $content->exam = Input::post("course_val", 0);
             $content->text_type_id = 2;
             $content->save();
         }
     }
     // add
     if (Input::post("type", null) != null and Security::check_token()) {
         if (is_uploaded_file($_FILES["file"]["tmp_name"])) {
             $ext = explode(".", $_FILES["file"]["name"]);
             if (strtolower($ext[1]) == "pdf" or strtolower($ext[1]) == "doc" or strtolower($ext[1]) == "docx") {
                 $filename = str_replace("/", "", $_FILES["file"]["name"]);
                 $filepath = DOCROOT . "contents/" . $filename;
                 if (move_uploaded_file($_FILES["file"]["tmp_name"], $filepath)) {
                     chmod($filepath, 0644);
                     // save
                     $cs = Input::post("course");
                     $courses = NULL;
                     if (null != Input::post("course")) {
                         foreach ($cs as $course) {
                             $courses = $courses . $course;
                         }
                         $content = Model_Content::forge();
                         $content->path = $filename;
                         $content->type_id = Input::post("type");
                         $content->number = 0;
                         $content->text_type_id = 2;
                         $content->exam = $courses;
                         $content->save();
                     } else {
                         $content = Model_Content::forge();
                         $content->path = $filename;
                         $content->type_id = Input::post("type");
                         $content->number = Input::post("number");
                         $content->text_type_id = Input::post("text_type");
                         $content->exam = NULL;
                         $content->save();
                     }
                 } else {
                     Response::redirect("/admin/contents/?e=1");
                 }
             } else {
                 Response::redirect("/admin/contents/?e=1");
             }
         }
     }
     $where = [["deleted_at", 0]];
     if (Input::get("search_type", 0) != 0) {
         array_push($where, ["type_id" => Input::get("search_type", 0) - 1]);
     }
     $data["contents"] = Model_Content::find("all", ["where" => $where, "order_by" => [["type_id", "asc"], ["number", "asc"], ["text_type_id", "asc"]]]);
     $config = array('pagination_url' => "?search_type=" . Input::get("search_type", 0), 'uri_segment' => "p", 'num_links' => 9, 'per_page' => 100, 'total_items' => count($data["contents"]));
     $data["pager"] = Pagination::forge('mypagination', $config);
     $data["contents"] = array_slice($data["contents"], $data["pager"]->offset, $data["pager"]->per_page);
     $view = View::forge("admin/contents/index", $data);
     $this->template->content = $view;
 }