Exemple #1
0
 public function action_index()
 {
     $this->template->scripts = array("public/js/mvp/mvp.js");
     $tag = Model_Setting::getSetting(Model_Setting::MVP_TAG);
     if (!empty($tag)) {
         $tgMod = ORM::factory("tag", $tag);
         $tgMod2 = ORM::factory("tag", $tag);
         $photo1 = $tgMod->photos->where("moderation_status_id", "=", Model_ModerationStatus::APPROVED)->order_by(DB::expr('RAND()'))->find();
         $photo2 = $tgMod2->photos->where("moderation_status_id", "=", Model_ModerationStatus::APPROVED)->order_by(DB::expr('RAND()'))->find();
     } else {
         $photo1 = ORM::factory("photo")->where("moderation_status_id", "=", Model_ModerationStatus::APPROVED)->order_by(DB::expr('RAND()'))->find();
         $photo2 = ORM::factory("photo")->where("moderation_status_id", "=", Model_ModerationStatus::APPROVED)->order_by(DB::expr('RAND()'))->find();
     }
     while ($photo2->id == $photo1->id) {
         if (!empty($tag)) {
             $tgMod2 = ORM::factory("tag", $tag);
             $photo2 = $tgMod2->photos->where("moderation_status_id", "=", Model_ModerationStatus::APPROVED)->order_by(DB::expr('RAND()'))->find();
         } else {
             $photo2 = ORM::factory("photo")->where("moderation_status_id", "=", Model_ModerationStatus::APPROVED)->order_by(DB::expr('RAND()'))->find();
         }
     }
     $_SESSION['photo1'] = $photo1->id;
     $_SESSION['photo2'] = $photo2->id;
     $this->template->top = View::factory("mvp/index");
     $this->template->top->photo1 = $photo1;
     $this->template->top->photo2 = $photo2;
 }
Exemple #2
0
 public function action_index()
 {
     $this->template->content = View::factory("admin/mvp/index");
     $this->template->content->currentTag = null;
     $tag = ORM::factory("tag", Model_Setting::getSetting(Model_Setting::MVP_TAG));
     if ($tag->loaded()) {
         $this->template->content->currentTag = $tag->name;
     }
 }