示例#1
0
 public function returnEvent($id, $videos = false, $posts = false)
 {
     $token = "batb_" . $id . "_" . $videos . "_" . $posts;
     if (($event = Cache::read($token, "1min")) === false || isset($_SERVER['DEVSERVER'])) {
         //lets get the general event deatils
         $event = $this->find("first", array("conditions" => array("BatbEvent.id" => $id), "contain" => array()));
         //lets grab all the matches
         $players = $event['BatbEvent']['num_players'];
         $num_brackets = BatbMatch::totalBrackets($players);
         $brackets = array();
         $contain = array("Player1User", "Player2User");
         if ($videos) {
             $contain[] = "PreGameVideo";
             $contain[] = "BattleVideo";
             $contain[] = "PostGameVideo";
         } else {
             if ($posts) {
                 $contain = array("BattlePost" => array("DailyopMediaItem" => array("MediaFile", "order" => array("DailyopMediaItem.display_weight" => "ASC"))), "PreGamePost" => array("DailyopMediaItem" => array("MediaFile", "order" => array("DailyopMediaItem.display_weight" => "ASC"))), "PostGamePost" => array("DailyopMediaItem" => array("MediaFile", "order" => array("DailyopMediaItem.display_weight" => "ASC"))), "Player1User", "Player2User");
                 //$contain = array();
             }
         }
         for ($num_brackets; $num_brackets >= 0; $num_brackets--) {
             $matches = $this->BatbMatch->find("all", array("conditions" => array("BatbMatch.batb_event_id" => $event['BatbEvent']['id'], "BatbMatch.bracket_num" => $num_brackets), "order" => array("BatbMatch.match_num" => "ASC"), "contain" => $contain));
             if ($posts) {
                 App::import("Model", "Dailyop");
                 $dailyop = new Dailyop();
                 foreach ($matches as $k => $v) {
                     if (!empty($v['BatbMatch']['pregame_dailyop_id'])) {
                         $matches[$k]['PreGamePost'] = $dailyop->returnPost(array("Dailyop.id" => $v['BatbMatch']['pregame_dailyop_id']));
                     }
                     if (!empty($v['BatbMatch']['battle_dailyop_id'])) {
                         $matches[$k]['BattlePost'] = $dailyop->returnPost(array("Dailyop.id" => $v['BatbMatch']['battle_dailyop_id']));
                     }
                     if (!empty($v['BatbMatch']['postgame_dailyop_id'])) {
                         $matched[$k]['PostGamePost'] = $dailyop->returnPost(array("Dailyop.id" => $v['BatbMatch']['postgame_dailyop_id']));
                     }
                 }
             }
             $brackets[$num_brackets] = $matches;
         }
         $event['Brackets'] = $brackets;
         Cache::write($token, $event, "1min");
     }
     return $event;
 }
示例#2
0
 public function parse($url)
 {
     $params = parent::parse($url);
     if (empty($params)) {
         return false;
     }
     App::import("Model", "DailyopSection");
     $sec = new DailyopSection();
     $sections = $sec->returnSections();
     $token = Set::extract("/DailyopSection[uri=" . $params['section'] . "]", $sections);
     if (isset($token[0]['DailyopSection']['uri'])) {
         //check to see if we can find the post, and if so, then cache that shit so we can posible use it in the dailyops controller and change the action to view
         if (!empty($params['uri'])) {
             //load up the daily ops model
             App::import("Model", "Dailyop");
             $dop = new Dailyop();
             $slug = md5($_SERVER['REQUEST_URI']);
             //hack it so the router thinks we are admin on dev server;
             //this will allow the router to pass in unpublished posts;
             //auth control will be handled by the controller
             if (!isset($_SERVER['DEVSERVER'])) {
                 $_SERVER['DEVSERVER'] = 0;
             }
             $post = $dop->returnPost(array("Dailyop.uri" => $params['uri'], "DailyopSection.uri" => $params['section']), $_SERVER['DEVSERVER']);
             if (isset($post['Dailyop']['id'])) {
                 $params['action'] = "view";
             } else {
                 if (!empty($params['uri'])) {
                     $params['action'] = $params['uri'];
                 }
             }
         }
         //check the directive
         if (!empty($token[0]['DailyopSection']['directive'])) {
             $params['controller'] = $token[0]['DailyopSection']['directive'];
         } else {
             $params['controller'] = "dailyops";
         }
         return $params;
     }
     return false;
 }
示例#3
0
 public function returnMatch($id, $usePosts = false, $users = false)
 {
     $cache_token = "batb_match_" . $id . "_" . $usePosts . "_" . $users;
     $contain = array("PreGameVideo", "BattleVideo", "PostGameVideo");
     if ($usePosts) {
         $contain = array();
     }
     if ($users) {
         $contain[] = "Player1User";
         $contain[] = "Player2User";
     }
     if (($match = Cache::read($cache_token, "1min")) === false) {
         $match = $this->find("first", array("conditions" => array("BatbMatch.id" => $id), "contain" => $contain));
         if ($usePosts) {
             App::import("Model", "Dailyop");
             $dailyop = new Dailyop();
             if (!empty($match['BatbMatch']['pregame_dailyop_id'])) {
                 $match['PreGamePost'] = $dailyop->returnPost(array("Dailyop.id" => $match['BatbMatch']['pregame_dailyop_id']));
             }
             if (!empty($match['BatbMatch']['battle_dailyop_id'])) {
                 $match['BattlePost'] = $dailyop->returnPost(array("Dailyop.id" => $match['BatbMatch']['battle_dailyop_id']));
             }
             if (!empty($match['BatbMatch']['postgame_dailyop_id'])) {
                 $match['PostGamePost'] = $dailyop->returnPost(array("Dailyop.id" => $match['BatbMatch']['postgame_dailyop_id']));
             }
         }
         Cache::write($cache_token, $match, "1min");
     }
     return $match;
 }