public function index() { // index is called when http request = ./trip $request = PRequest::get()->request; if (!isset($request[1])) { $request[1] = ''; } // Enable ViewWrap for cleaner code $P = PVars::getObj('page'); $vw = new ViewWrap($this->_view); // Show the teaser $this->showTeaser(); // then include the col2-stylesheet $P->addStyles .= $vw->customStyles(); $member = $this->_model->getLoggedInMember(); switch ($request[1]) { case 'create': if (!$member) { return false; } $P->content .= $vw->createForm(); break; case 'show': if (isset($request[2]) && $request[2]) { if ($request[2] == 'my') { $this->showMyTrips(); } else { $this->showTrips($request[2]); } } else { $this->showAllTrips(); } break; case 'search': if (isset($_GET['s'])) { $search = $_GET['s']; if (strlen($_GET['s']) >= 3) { //$tagsposts = $this->_model->getTaggedPostsIt($search); $trip_data = $this->_model->getTripsDataForLocation($search); $trips = $this->_model->getTripsForLocation(); } else { $error = 'To few arguments'; $trip_data = array(); $trips = false; //$tagsposts = false; } $P->content .= $vw->searchPage($trips, $trip_data); } break; case 'reorder': $this->reorder($_GET['triplist']); break; case 'edit': if (isset($request[2]) && $request[2]) { $this->editTrip((int) $request[2]); break; } case 'del': if (isset($request[2]) && $request[2]) { $this->delTrip((int) $request[2]); break; } default: if (intval($request[1])) { return $this->showTrip($request[1]); } else { if ($member) { $this->showAllTrips(); } else { $this->notLoggedIn(); } break; } } // Show the user functions in the sidebar $P->newBar .= $vw->userbar(); }