/** * Dispatch from URI (load the components) * @return boolean true on succes */ public function dispatch() { //do dispatching if ($this->state === "parsed") { $component = $this->uri->getComponent(); $command = $this->uri->getCommand(); if (!ecplocate("components." . $component . "." . $component)) { $component = "error"; $command = "unknown_component"; } ecpimport("components.componentcontroller"); //load the component interface! ecpimport("components." . $component . "." . $component); $componentname = "ECP_Comp_" . ucwords($component) . "_Controller"; if (class_exists($componentname)) { $this->controller = new $componentname(); $this->controller->command($command); $varr = $this->uri->getVars(); array_pop($varr); $this->controller->params($varr); $this->controller->execute(); } else { parent::addError("ECP_ROUTER::dispatch() - Couldn't open component because classname didn't exist. Component classnames wrong?"); return false; } return true; } else { parent::addError("ECP_ROUTER::dispatch() - Can't dispatch because uri isn't parsed yet!"); return false; } }
/** * Maakt een PDO object aan en include de benodigde klassen voor het tabelobject * Indien de naam bestaat uit meer dan 1 deel (bvb AanvraagOverleg) moet je aanvraag.overleg meegeven * @code * ECPFactory::getPDO("aanvraag.overleg"); //include "AanvraagOverleg.class.php" * @endcode * @param string $dbclass De naam van de tabelklasse * @return type */ public static function getPDO($dbclass) { $class = explode(".", $dbclass); $dbclass = ucfirst($class[0]) . ucfirst($class[1]); if (!self::$pdo) { //pdo aanmaken en dan de standaard klassen al includen... if (!self::$conf) { self::getConfig(); } //configuratie aanmaken indien nog niet bestaat self::$pdo = new PDO("mysql:host=" . self::$conf->host . ";dbname=" . self::$conf->db, self::$conf->user, self::$conf->password); ecpimport("database.util.Db2PhpEntityBase", "class"); ecpimport("database.util.Db2PhpEntityModificationTracking", "class"); ecpimport("database.util.DFCAggregate", "class"); ecpimport("database.util.DSC", "class"); } if (ecplocate("database.{$dbclass}", "class")) { //database klasse invoegen die methodes bevat om met data te werken... (indien bestaat) ecpimport("database.{$dbclass}", "class"); } elseif (ecplocate("database.overleggen.{$dbclass}", "trait")) { //database klasse invoegen die methodes bevat om met data te werken... (indien bestaat) ecpimport("database.overleggen.{$dbclass}", "trait"); } return self::$pdo; }
public function setUser($id) { $db = ECPFactory::getDbo(); $user = $db->newQuery("select", "user")->table("logins")->where("id", $id, "=")->execute(); if ($user->getRows()) { $u = $user->getSingleResult(); $this->guest = false; $this->id = $id; $u['profiel'] = strtolower($u['profiel']); $this->user = $u; ecpimport("user.usertype"); //usertype interface if (ecplocate("user.types.{$u['profiel']}")) { ecpimport("user.types.{$u['profiel']}"); //usertype class $classname = "ECP_User_" . $u['profiel']; $this->typeobj = new $classname(); } else { echo "fatal error.. usertype unknown<br/>Missing type is: {$u['profiel']}"; ecpexit(); } $this->locked = 1; } else { $this->guest = 1; $this->locked = 1; $this->user = array("naam" => "Gast", "type" => "Guest"); } }