Created
March 16, 2015 13:14
-
-
Save thirdknife/c18bd8afd40634d7995b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class People extends MY_Controller | |
| { | |
| public function __construct() | |
| { | |
| parent::__construct(); | |
| $this->data['meta'] = array( | |
| 'messages' => array(), | |
| 'errors' => array(), | |
| ); | |
| $this->load->helper(array('url', 'form')); | |
| $this->data['nav']['people']['active'] = 1; | |
| } | |
| public function index(){ | |
| $this->data['bodyclass'] = 'peoplelanding'; | |
| $this->data['title'] = 'First Round Capital : The Team'; | |
| $this->load->model('People_model'); | |
| $this->data['people'] = $this->People_model->get_all_for_index(); | |
| $this->renderTemplate('people/index'); | |
| return; | |
| } | |
| public function view($id = null){ | |
| if (is_numeric($id)){ | |
| $this->load->model('People_model'); | |
| $this->load->model('People_model', "Team_model"); | |
| $person = $this->People_model->lookup_single_by_id($id); | |
| if($person->team == 'None'){ | |
| $person->team = 'Community'; | |
| } | |
| $_team = $this->Team_model->get_all_for_index(array('team' => $person->team)); | |
| $_team = $_team[$person->team]; | |
| // find the one that matches $person->id, then step back one and step forward one. | |
| $previous = count($_team) - 1; // if on first, this will pull last | |
| $next = 0; // if on last, this will pull first. | |
| foreach($_team as $key => $member){ | |
| if($member->id == $person->id){ | |
| // error_log("found"); | |
| if($key != 0) | |
| $previous = $key - 1; | |
| if($key != (count($_team) - 1)) | |
| $next = $key + 1; | |
| error_log($next); | |
| $this->data['previous'] = $_team[$previous]; | |
| $this->data['next'] = $_team[$next]; | |
| } | |
| } | |
| }else{ | |
| echo 'No ID, '. $id; | |
| } | |
| if(!$person){ | |
| echo '404, '; //TODO 404 | |
| return false; | |
| } | |
| if($person->team == 'Community'){ | |
| $this->communityDetail($person); | |
| }else{ | |
| $this->teamDetail($person); | |
| } | |
| return; | |
| } | |
| public function person_lookup($name = '', $third = false){ | |
| if($name == 'profile'){ | |
| if($third){ | |
| redirect('/team/' . $third); | |
| return; | |
| } | |
| redirect('/people/'); | |
| } | |
| if($name == 'cfralic'){ | |
| redirect('/team/Chris_Fralic'); | |
| } | |
| $name = str_replace("%20", " ", $name); | |
| $name = str_replace("_", " ", $name); | |
| $this->load->model('People_model'); | |
| $person = $this->People_model->lookup_single_by_name($name); | |
| $this->view($person->id); | |
| return; | |
| } | |
| public function investment(){ | |
| $this->data['bodyclass'] = 'peoplelanding'; | |
| $this->data['title'] = 'The First Round Team'; | |
| $this->load->model('People_model'); | |
| $this->data['people'] = $this->People_model->get_all_for_index(); | |
| $this->renderTemplate('people/investment'); | |
| } | |
| private function teamDetail($person){ | |
| $this->data['subnav'] = $this->People_model->get_team(array('team'=>$person->team)); | |
| $this->data['bodyclass'] = 'personteamdetail'; | |
| $this->data['title'] = 'First Round : ' . $person->name; | |
| $this->data['person'] = $person; | |
| $this->load->model('Library_model'); | |
| $this->data['articles'] = $this->Library_model->get_from_author($person->id); | |
| $this->renderTemplate('people/team'); | |
| return; | |
| } | |
| private function communityDetail($person){ | |
| $this->data['bodyclass'] = 'personcommunitydetail'; | |
| $this->data['title'] = 'First Round : ' . $person->name; | |
| $this->data['person'] = $person; | |
| $this->renderTemplate('people/community'); | |
| return; | |
| } | |
| private function renderTemplate($_view = null){ | |
| //check on messages | |
| // $this->data['meta']['messages'] = $this->session->flashdata('messages'); | |
| // array_merge($this->data['meta']['errors'], is_array($flash = $this->session->flashdata('errors')) ? $flash : array() ); | |
| $this->load->view('header', $this->data); | |
| $this->load->view($_view, $this->data); | |
| $this->load->view('footer', $this->data); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment