Witam,
czy moglibyście przedstawić mi najprostszy sposób skonstruowania 'strony' (opartej na klasach), w której automatycznie zmienia się tytuł, opis, słowa kluczowe i nawigacja po otworzeniu danego modułu (includowanej strony) ?
<?php require_once(\"class/kernel.php\"); $kernel = kernel::getInstance(); $kernel->load_module(\"strona_glowna\"); $smarty = new Smarty(); $smarty->assign('page', $kernel->module->modules[\"strona_glowna\"]->display_content()); ?>
<?php require_once(\"class/module.php\"); class kernel { public $module; private function __construct() { $this->module = module::getInstance(); } public function getInstance() { if ($inst == NULL) { $inst = new kernel(); } return $inst; } public function load_module($name) { $this->module->load($name); } } ?>
<?php class module { private $DB = null; public function getInstance() { if ($inst == NULL) { $inst = new module(); } return $inst; } private function __construct() { $this->DB = DB::getInstance(); } public function load($name) { if($this->check($name)) { require_once(\"modules/\" . $name . \"index.php\"); $this->modules[$name] = new $name; } else { // TODO error handler } } protected function check($name) { $result = $this->DB->query(\"SELECT * FROM modules WHERE name=`\". $name .\"`\"); return $result->numRows(); } } ?>