/** * aangepaste parseData functie die overweg kan met 1 rij ipv een array met daarin een array * * @param unknown_type $data * @return unknown */ function parseData($data) { $result = array(); $result['gebruikersnaam'] = $data["uid"][0]; $result['voornaam'] = $data["ugentpreferredgivenname"][0]; $result['achternaam'] = $data["ugentpreferredsn"][0]; $result['email'] = $data["mail"][0]; $kot = $data["ugentdormpostaladdress"][0]; if ($kot != "") { $kot = explode("\$", $kot); if (strpos(" " . $kot[0], "HOME")) { //VUILE LDAP HACK :( $kot[0] = $kot[0] == "HOME BERTHA DE VRIES" ? "HOME BERTHA DE VRIESE" : $kot[0]; $home = Home::getHome("ldapNaam", $kot[0]); $result['homeId'] = $home->getId(); $result['home'] = $home->getLangeNaam(); $temp = explode(":", $kot[1]); if (sizeof($temp) > 1) { $result['kamer'] = $temp[1]; } else { $temp = explode("(", $kot[1]); $temp = explode(")", $temp[1]); if (sizeof($temp) > 1) { $result['kamer'] = $home->getKamerPrefix() . "." . $temp[0]; } else { $temp = explode("K. ", $kot[1]); $result['kamer'] = $home->getKamerPrefix() . "." . converteer($temp[0]); //er wordt nog een oud kamernummer gebruikt } } } } return $result; }
public function __construct() { $this->splitUrl(); if (!$this->url_controller) { require APP . 'controllers/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controllers/' . $this->url_controller . '.php')) { require APP . 'controllers/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { $this->url_controller->index(); } else { header('location: ' . URL . 'error'); } } } else { header('location: ' . URL . 'error'); } }
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->splitUrl(); // check for controller: no controller given ? then load start-page if (!$this->url_controller) { require APP . 'controller/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controller/' . $this->url_controller . '.php')) { // here we did check for controller: does such a controller exist ? // if so, then load this file and create this controller require APP . 'controller/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { header('location: ' . URL . 'error'); } } } else { header('location: ' . URL . 'error'); } }
public function __construct() { // create array with URL parts in $url $this->splitUrl(); // check for controller: no controller given ? then load start-page if (!$this->url_controller) { require APP . 'controller/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controller/' . $this->url_controller . '.php')) { // here we did check for controller: does such a controller exist ? // if so, then load this file and create this controller require APP . 'controller/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { // Call the method and pass arguments to it call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { // If no parameters are given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { header('location: ' . URL . '/not_found'); } } } else { header('location: ' . URL . '/not_found'); } }
public function index() { $aViewParameter = array(); $aViewParameter['page'] = 'home'; $this->load->model('analog_model'); $aViewParameter['sucess'] = '0'; $aObjHome = new Home(); $aObjHome->checkSettingsSaved(); $sResponse = get_rlb_status(); $sValves = $sResponse['valves']; $sRelays = $sResponse['relay']; $sPowercenter = $sResponse['powercenter']; $sPump = array($sResponse['pump_seq_0_st'], $sResponse['pump_seq_1_st'], $sResponse['pump_seq_2_st']); $aViewParameter['sValves'] = $sValves; $aViewParameter['sRelays'] = $sRelays; $aViewParameter['sPowercenter'] = $sPowercenter; $aViewParameter['sPump'] = $sPump; $aViewParameter['relay_count'] = strlen($sRelays); $aViewParameter['valve_count'] = strlen($sValves); $aViewParameter['power_count'] = strlen($sPowercenter); $aViewParameter['pump_count'] = count($sPump); if ($this->input->post('command') == 'Save') { $sDeviceName = $this->input->post('sDeviceName'); $this->analog_model->saveAnalogDevice($sDeviceName); $aViewParameter['sucess'] = '1'; } $aAllAnalogDevice = $this->analog_model->getAllAnalogDevice(); $aAllANalogDeviceDirection = $this->analog_model->getAllAnalogDeviceDirection(); $aViewParameter['aResponse'] = array('AP0' => $sResponse['AP0'], 'AP1' => $sResponse['AP1'], 'AP2' => $sResponse['AP2'], 'AP3' => $sResponse['AP3']); $aViewParameter['aAllAnalogDevice'] = $aAllAnalogDevice; $aViewParameter['aAllANalogDeviceDirection'] = $aAllANalogDeviceDirection; $this->load->view('Analog', $aViewParameter); }
public static function run($url) { if (!empty($url) && strtolower($url) != "home") { $url = explode("/", $url); $class = ucfirst(strtolower($url[0])); if (count($url) > 1) { $method = $url[1] ? strtolower($url[1]) : null; if (count($url) > 2) { $param = $url[2] ? $url[2] : null; } } if (file_exists(DIR_CONTROLLER . $class . '.php')) { $obj = new $class(); if (isset($method) && method_exists($obj, $method)) { if (isset($param)) { $obj->{$method}($param); } else { $obj->{$method}(); } } else { if (isset($method)) { include DIR_BASE . 'app/view/erro500.php'; } } $obj->show(); } else { include DIR_BASE . 'app/view/erro500.php'; } } else { $obj = new Home(); $obj->show(); } }
public function __construct() { $this->getUrlWithoutModRewrite(); if (!$this->url_controller) { require APP . 'controllers/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controllers/' . $this->url_controller . '.php')) { require APP . 'controllers/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { // Llama el metodo y le pasa los argumentos call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { //Si no hay parametros llama a el metodo sin argumentos. $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { // Si no se define alguna accion defino por defecto la index $this->url_controller->index(); } else { //Si la accion no existe lanzo el error require APP . 'controllers/error.php'; $page = new Error(); $page->index(); } } } else { require APP . 'controllers/error.php'; $page = new Error(); $page->index(); } }
function get() { $profile_uid = intval($_GET['p']) ? intval($_GET['p']) : -1; $load = argc() > 1 && argv(1) == 'load' ? 1 : 0; header("Content-type: text/html"); echo "<!DOCTYPE html><html><body>\r\n"; echo array_key_exists('msie', $_GET) && $_GET['msie'] == 1 ? '<div>' : '<section>'; $mod = new Home(); $text = $mod->get($profile_uid, $load); $pattern = "/<img([^>]*) src=\"([^\"]*)\"/"; $replace = "<img\${1} dst=\"\${2}\""; // $text = preg_replace($pattern, $replace, $text); /* if(! $load) { $replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />'; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; $text = preg_replace($pattern, $replace, $text); $pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i"; $text = preg_replace($pattern, $replace, $text); $pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i"; $text = preg_replace($pattern, $replace, $text); $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i"; $text = preg_replace($pattern, $replace, $text); } */ echo str_replace("\t", ' ', $text); echo array_key_exists('msie', $_GET) && $_GET['msie'] == 1 ? '</div>' : '</section>'; echo "</body></html>\r\n"; // logger('update_home: ' . $text); killme(); }
public function get_article_list($start = 0, $limit = 10, $keyword, $type = 1) { $obj = new Home(); $query = $this->article_model->get_article_list($type, $start, $limit, $keyword); if ($query != NULL) { $i = 0; foreach ($query->result() as $q) { $path = !isset($q->path_image) ? "" : $q->path_image; $title = !isset($q->title) ? "" : $q->title; $tag = !isset($q->tag) ? "" : $q->tag; $article_id = !isset($q->article_id) ? "" : $q->article_id; $read_more = base_url("article/read/" . $article_id . "/" . $obj->slug($title) . ""); $year = !isset($q->year) ? 0 : $q->year; $month = !isset($q->month) ? 0 : $q->month; $day = !isset($q->day) ? 0 : $q->day; $default = base_url('assets/img/article/default-image.png'); $article_id = !isset($q->article_id) ? "" : $q->article_id; $read_more = base_url("article/read/" . $year . '/' . $month . '/' . $day . '/' . $article_id . "/" . $this->slug($title) . ""); $title = $type == 2 || $type == 3 || $type == 4 ? $this->global_common->get_title(26, $title) : $title; $img = "<p><a target='_blank' href='" . $read_more . "'>"; //$img .= "<img class='img-responsive opacity' width='480px' src='". base_url($path) ."' alt='".$title."'/>"; $img .= "<img class='img-responsive opacity lazy' width='480px' src='" . $default . "' data-original='" . base_url($path) . "' alt='" . $title . "'>"; $img .= "</a></p>"; $category = !isset($q->category) ? "" : $q->category; $recent_article_category = "<a href='" . base_url('article/page/0/0/' . $category) . "'>" . $category . "</a>"; $data[$i] = array("article_id" => $article_id, "article_category_id" => !isset($q->article_category_id) ? "" : $q->article_category_id, "image_id" => !isset($q->image_id) ? "" : $q->image_id, "title" => "<a href='" . $read_more . "'>" . $title . "</a>", "read_more" => "<a class='btn btn-primary' href='" . $read_more . "'>Read More</a>", "tag" => $this->global_common->get_list_tag($tag, 'article'), "summary" => !isset($q->summary) ? "" : $obj->get_preview_summary($q->summary), "full_name" => !isset($q->nama_lengkap) ? "" : $q->nama_lengkap, "created_date" => !isset($q->created_date) ? "" : $q->created_date, "image" => $img, "recent_article_category" => $recent_article_category, "count_article_comment" => $this->article_model->count_article_comment($article_id)->count_article_comment, "count_article_stat" => $this->article_model->count_article_stat($article_id)->count_article_stat); $i++; } } else { $data = NULL; } return $data; }
function sitemap($t) { $result = $this->sitemap_model->get_url_sitemap($t); $home = new Home(); if ($result != false) { foreach ($result as $row) { $date = explode(" ", $row->created_date); $y = explode("-", $date[0]); $m = explode("-", $date[0]); $d = explode("-", $date[0]); if ($t == 'article') { $url = base_url("article/read/" . $y[0] . '/' . $m[1] . '/' . $d[2] . '/' . $row->article_id . "/" . $home->slug($row->title) . ""); } if ($t == 'news') { $url = base_url("news/read/" . $y[0] . '/' . $m[1] . '/' . $d[2] . '/' . $row->news_id . "/" . $home->slug($row->title) . ""); } if ($t == 'video') { $url = base_url("video/watch/" . $y[0] . '/' . $m[1] . '/' . $d[2] . '/' . $row->video_id . "/" . $home->slug($row->title) . ""); } $datetime = new DateTime($row->created_date); $data[] = array("loc" => $url, "lastmod" => $datetime->format('Y-m-d\\TH:i:sP'), "priority" => 0.5, "changefreq" => "daily"); } } return $data; }
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->splitUrl(); // check for controller: no controller given ? then load start-page if ($this->url_controller) { $controller = ucfirst(strtolower($this->url_controller)); $pathController = APP . "controllers/{$controller}.controller.php"; if (file_exists($pathController)) { // llamamos al archivo controlador require $pathController; $action = strtolower($this->url_action) . 'Action'; if (!empty($this->url_params)) { $this->url_controller = new $controller($this->url_params); } else { $this->url_controller = new $controller(); } // comprobamos si la accion existe if (method_exists($this->url_controller, $action)) { $this->url_controller->{$action}($this->url_params); } else { $params = array_merge(array($this->url_action), $this->url_params); $this->url_controller->index($params); } } else { header('location: ' . URL . 'error'); } } elseif (!$this->url_controller) { require APP . 'controllers/Home.controller.php'; $page = new Home(); $page->index(); } }
/** * @test * @group session * @group blacklist */ public function testWebDriver() { $home_page = new Home(self::$session); $home_page->open(); $schedule_page = $home_page->navigate_to('Schedule'); $schedule_page->open_session('WebDriver!'); $this->assertEquals($schedule_page->title, "WebDriver!"); }
/** * * @param $controller */ function enter($controller) { // Call a given controller, except when the segment1 is "null", in which, call Home. if ($controller != "null") { $instance = new $controller(); $instance->main(); } else { $instance = new Home(); $instance->main(); } }
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->getUrlWithoutModRewrite(); $GLOBALS["beans"] = new stdClass(); $this->openDatabaseConnection(); $this->loadModels(); $this->loadHelpers(); date_default_timezone_set('UTC'); // check for controller: no controller given ? then load start-page if (!$this->url_controller) { require APP . 'controllers/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controllers/' . $this->url_controller . '.php')) { // here we did check for controller: does such a controller exist ? // If user is not logged in, restrict to the login page only $this->checkLoggedIn(); // if so, then load this file and create this controller // example: if controller would be "car", then this line would translate into: $this->car = new car(); require APP . 'controllers/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { // Call the method and pass arguments to it call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { // If no parameters are given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { // defined action not existent: show the error page require APP . 'controllers/error.php'; $page = new Error(); $page->index(); } } } else { require APP . 'controllers/error.php'; $page = new Error(); $page->index(); } }
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->getUrlWithoutModRewrite(); // check for controller: no controller given ? then load start-page if (!$this->url_controller) { require APP . 'controllers/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controllers/' . $this->url_controller . '.php')) { // here we did check for controller: does such a controller exist ? // if so, then load this file and create this controller // example: if controller would be "car", then this line would translate into: $this->car = new car(); require APP . 'controllers/' . $this->url_controller . '.php'; /** * Bad workaround due to list being a reserved keyword. Should probably rename to something other than list in production. **/ if ($this->url_controller == 'list') { $this->url_controller = new days(); } else { $this->url_controller = new $this->url_controller(); } // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { // Call the method and pass arguments to it call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { // If no parameters are given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { // defined action not existent: show the error page require APP . 'controllers/error.php'; $page = new Error(); $page->index(); } } } else { require APP . 'controllers/error.php'; $page = new Error(); $page->index(); } }
public static function errors($code = 404, $title = '', $message = '') { $ajax = Request::ajax(); if (!$code) { $code = 500; $title = 'Internal Server Error'; $message = 'We got problems over here. Please try again later!'; } else { if ($code == 404) { $title = 'Oops! You\'re lost.'; $message = 'We can not find the page you\'re looking for.'; } } if (Request::ajax()) { return Response::json(['error' => ['message' => $message]], $code); } $arrData = []; $arrData['content'] = View::make('frontend.errors.error')->with(['title' => $title, 'code' => $code, 'message' => $message]); $arrData['metaInfo'] = Home::getMetaInfo(); $arrData['metaInfo']['meta_title'] = $title; $arrData['types'] = Home::getTypes(); $arrData['categories'] = Home::getCategories(); $arrData['headerMenu'] = Menu::getCache(['header' => true]); return View::make('frontend.layout.default')->with($arrData); }
/** * Process incoming parameters and display the page. * * @return void * @access public */ public function launch() { global $interface; global $configArray; if (isset($_POST['submit'])) { $result = $this->sendEmail($_POST['to'], $_POST['from'], $_POST['message']); if (!PEAR::isError($result)) { include_once 'Home.php'; Home::launch(); exit; } else { $interface->assign('errorMsg', $result->getMessage()); } } // Display Page $interface->assign('formTargetPath', '/MetaLib/' . urlencode($_GET['id']) . '/Email'); $interface->assign('recordId', urlencode($_GET['id'])); if (isset($_GET['lightbox'])) { $interface->assign('title', $_GET['message']); return $interface->fetch('MetaLib/email.tpl'); } else { $interface->setPageTitle('Email Record'); $interface->assign('subTemplate', 'email.tpl'); $interface->setTemplate('view-alt.tpl'); $interface->display('layout.tpl', 'RecordEmail' . $_GET['id']); } }
/** * Process incoming parameters and display the page. * * @return void * @access public */ public function launch() { global $interface; global $configArray; if (isset($_POST['submit'])) { $result = $this->sendEmail($_POST['from'], $_POST['message']); if (!PEAR::isError($result)) { include_once 'Home.php'; Home::launch(); exit; } else { $interface->assign('errorMsg', $result->getMessage()); } } // Display Page $institutionDetails = $this->recordDriver->getInstitutionDetails(); $datasources = getExtraConfigArray('datasources'); if (!$institutionDetails['institution']) { $interface->assign('institution', $configArray['Site']['title']); $interface->assign('datasource', $configArray['Site']['title']); } else { $interface->assign('institution', $institutionDetails['institution']); $interface->assign('datasource', $institutionDetails['datasource']); } $interface->assign('formTargetPath', '/MetaLib/Record?id=' . urlencode($_GET['id']) . '/Feedback'); if (isset($_GET['lightbox'])) { $interface->assign('title', $_GET['message']); return $interface->fetch('Record/Feedback.tpl'); } else { $interface->setPageTitle('Give Feedback on a Record'); $interface->assign('subTemplate', 'Feedback.tpl'); $interface->setTemplate('view-alt.tpl'); $interface->display('layout.tpl', 'RecordFeedback' . $_GET['id']); } }
function beforeRoute($f3) { parent::beforeRoute($f3); if ($this->me->isAdmin()) { $f3->reroute('/home/admin/server/'); } $this->server = new \Server(); }
/** * Load your component. * * @param \Cx\Core\ContentManager\Model\Entity\Page $page The resolved page */ public function load(\Cx\Core\ContentManager\Model\Entity\Page $page) { global $_CORELANG, $subMenuTitle, $objTemplate; switch ($this->cx->getMode()) { case \Cx\Core\Core\Controller\Cx::MODE_BACKEND: $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'LegacyContentMaster.html'); $cachedRoot = $this->cx->getTemplate()->getRoot(); $this->cx->getTemplate()->setRoot($this->getDirectory() . '/View/Template/Backend'); $objTemplate->setVariable('CONTAINER_DASHBOARD_CLASS', 'dashboard'); $objFWUser = \FWUser::getFWUserObject(); $subMenuTitle = $_CORELANG['TXT_WELCOME_MESSAGE'] . ", <a href='index.php?cmd=Access&act=user&tpl=modify&id=" . $objFWUser->objUser->getId() . "' title='" . $objFWUser->objUser->getId() . "'>" . ($objFWUser->objUser->getProfileAttribute('firstname') || $objFWUser->objUser->getProfileAttribute('lastname') ? htmlentities($objFWUser->objUser->getProfileAttribute('firstname'), ENT_QUOTES, CONTREXX_CHARSET) . ' ' . htmlentities($objFWUser->objUser->getProfileAttribute('lastname'), ENT_QUOTES, CONTREXX_CHARSET) : htmlentities($objFWUser->objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET)) . "</a>"; $objAdminNav = new Home(); $objAdminNav->getPage(); $this->cx->getTemplate()->setRoot($cachedRoot); break; } }
function __construct() { //get url $url = isset($_GET['url']) ? $_GET['url'] : null; $url = rtrim($url, '/'); $url = explode('/', $url); //print_r($url); if (empty($url[0])) { require 'controllers/home.php'; $controller = new Home(); $controller->index(); return false; } //load controler with file $file = 'controllers/' . $url[0] . '.php'; //check if file exists if (file_exists($file)) { require $file; } else { require 'controllers/error.php'; $controller = new Error(); throw new Exception("The file: {$file} Does not exist!"); return false; } //initialize controler and load model $controller = new $url[0](); $controller->LoadModel($url[0]); //if function was set load function, else load index if (isset($url[2])) { if (method_exists($controller, $url[1])) { $controller->{$url[1]}($url[2]); } else { echo "Napaka: funkcija {$url['1']} ne obstaja."; } return false; } elseif (isset($url[1])) { if (method_exists($controller, $url[1])) { $controller->{$url[1]}(); } else { echo "Napaka: funkcija {$url['1']} ne obstaja."; } return false; } else { $controller->index(); } }
function beforeRoute($f3) { parent::beforeRoute($f3); if (!$this->me->isAdmin()) { $f3->reroute('/logout'); } $this->seller = new \User(); }
function __construct() { $url = isset($_GET["url"]) ? $_GET["url"] : null; $url = rtrim($url, '/'); $url = explode('/', $url); if (empty($url[0])) { // If Empty array then invoke Defualt Home page require 'Controller/Home.php'; $controller = new Home(); echo "I am here"; $controller->loadModel("home"); $controller->index(); return false; } $file = 'Controller/' . $url[0] . '.php'; //Check File Is exist in the Controller if (file_exists($file)) { require $file; } else { $this->error(); } $controller = new $url[0](); // Home Controller $controller->loadModel($url[0]); if (isset($url[2])) { //Check Function parameter is set in the URL $_method_name = 'execute' . $url[1]; if (method_exists($controller, $_method_name)) { $controller->{'execute' . $url[1]}($url[2]); } else { $this->error(); } } else { if (isset($url[1])) { $_method_name = 'execute' . $url[1]; if (method_exists($controller, $_method_name)) { $controller->{'execute' . $url[1]}(); } else { $this->error(); } } else { $controller->index(); } } }
public function __construct() { $this->product = new ProductModel(); $this->client = new ClientModel(); $this->category = new CategoryModel(); $this->subcategory = new SubcategoryModel(); self::$fb = new FacebookLogin(); self::$go = new GoogleLogin(); }
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->splitUrl(); // check for controller: does such a controller exist ? if (file_exists('./application/controller/' . $this->url_controller . '.php')) { // if so, then load this file and create this controller // example: if controller would be "car", then this line would translate into: $this->car = new car(); require './application/controller/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { // call the method and pass the arguments to it if (isset($this->url_parameter_3)) { // will translate to something like $this->home->method($param_1, $param_2, $param_3); $this->url_controller->{$this->url_action}($this->url_parameter_1, $this->url_parameter_2, $this->url_parameter_3); } elseif (isset($this->url_parameter_2)) { // will translate to something like $this->home->method($param_1, $param_2); $this->url_controller->{$this->url_action}($this->url_parameter_1, $this->url_parameter_2); } elseif (isset($this->url_parameter_1)) { // will translate to something like $this->home->method($param_1); $this->url_controller->{$this->url_action}($this->url_parameter_1); } else { // if no parameters given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); } } else { // default/fallback: call the index() method of a selected controller if (method_exists($this->url_controller, 'index')) { $this->url_controller->index(); } else { // invalid URL, so simply show home/index require './application/controller/home.php'; $home = new Home(); $home->index(); } } } else { // invalid URL, so simply show home/index require './application/controller/home.php'; $home = new Home(); $home->index(); } }
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->splitUrl(); // check for controller: no controller given ? then load start-page if (!$this->url_controller) { require APP . 'controller/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controller/' . $this->url_controller . '.php')) { // here we did check for controller: does such a controller exist ? // if so, then load this file and create this controller // example: if controller would be "car", then this line would translate into: $this->car = new car(); require APP . 'controller/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { // Call the method and pass arguments to it call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { // If no parameters are given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { header('HTTP/1.0 404 Not Found'); require APP . 'controller/error.php'; $cont_error = new Error("Esa acción no existe"); $cont_error->index(); } } } else { header('HTTP/1.0 404 Not Found'); require APP . 'controller/error.php'; $cont_error = new Error("Ese controlador no existe"); $cont_error->index(); } }
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->splitUrl(); // check for controller: no controller given ? then load start-page if (!$this->url_controller) { require APP . 'controller/Home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controller/' . $this->url_controller . '.php')) { // here we did check for controller: does such a controller exist ? // if so, then load this file and create this controller // example: if controller would be "car", then this line would translate into: $this->car = new car(); require APP . 'controller/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { // Call the method and pass arguments to it call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { // If no parameters are given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); } } else { if (is_numeric($this->url_action)) { // no action defined: call the default index() method of a selected controller $this->url_controller->index($this->url_action); } elseif (strlen($this->url_action) == 0) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { new Alert('warning', "exclamation-triangle", "Ce lien n'existe pas..."); header('location: ' . URL . 'erreur'); } } } else { new Alert('warning', "exclamation-triangle", "Ce lien n'existe pas..."); header('location: ' . URL . 'erreur'); } }
public function map() { if ($this->routes[0] === "" && empty($this->routes[1])) { $home = new Home(); return $home->index(); } elseif ("" !== $this->routes[0] && !isset($this->routes[1])) { $className = ucfirst($this->routes[0]); $c = new $className($this->db); return $c->index(); } elseif ("" !== $this->routes[0] && $this->routes[1] !== "" && !isset($this->routes[2])) { $className = ucfirst($this->routes[0]); $method = strtolower($this->routes[1]); $c = new $className($this->db); return $c->{$method}($con = null); } elseif ("" !== $this->routes[0] && $this->routes[1] !== "" && $this->routes[2] !== "") { $className = ucfirst($this->routes[0]); $method = strtolower($this->routes[1]); $c = new $className(); return $c->{$method}($this->routes[2]); } }
function __construct() { $url = isset($_GET['url']) ? $_GET['url'] : null; $url = rtrim($url, '/'); $url = explode('/', $url); //print_r($url); if (empty($url[0])) { require 'controllers/home.php'; $controller = new Home(); $controller->index(); return false; } $file = 'controllers/' . $url[0] . '.php'; if (file_exists($file)) { require $file; } else { $this->error(); exit; } $controller = new $url[0](); $controller->loadModel($url[0]); // calling methods if (isset($url[2])) { if (method_exists($controller, $url[1])) { $controller->{$url[1]}($url[2]); } else { $this->error(); } } else { if (isset($url[1])) { if (method_exists($controller, $url[1])) { $controller->{$url[1]}(); } else { $this->error(); } } else { $controller->index(); } } }
/** * instellen van de home en het korte kamernummer op * basis van het lange kamernummer */ private function calculateHome() { //opsplitsen in delen $gebouw = substr($this->kamernummerLang, 0, 5); $verdiep = substr($this->kamernummerLang, 6, 3); $lokaal = substr($this->kamernummerLang, 10, 3); //opzoeken van de naam van de home $this->home = Home::getHome("kamerPrefix", $gebouw); //instellen van het kamernummer $this->kamernummerKort = $verdiep / 10 - 10 . substr($lokaal, 1, 2); //instellen van verdiep $this->verdiep = $verdiep / 10 - 10; }