public static function getInstance() { if (!self::$_instance instanceof self) { self::$_instance = new self(); } return self::$_instance; }
public function __construct() { $this->db = Alxw::getInstance()->DB(); if ($this->db->query("show tables like 'Settings'")->num_rows() != 1) { $this->db->struct(array('key' => 'text', 'val' => 'text'))->create('Settings'); } }
public function run() { $is_match = false; foreach ($this->rules as $route => $callback) { if ('default' === $route) { continue; } if ($route == $this->url) { $is_match = true; $callback(); break; } } if (!$is_match) { $arr = explode('/', $this->url); if ($arr[1] === 'Activity' && isset($arr[2])) { Alxw::getInstance()->ClassLoader($arr[2]); } else { $this->rules['default'](); } } }
<?php /** Author: SpringHack - springhack@live.cn Last modified: 2015-12-06 03:11:43 Filename: index.php Description: Created by SpringHack using vim automatically. **/ //引入Alxw框架 require_once "Library/Alxw.php"; //默认路由规则 Alxw::getInstance()->Router()->add('default', function () { Alxw::getInstance()->ClassLoader('FNF'); }); //首页路由规则 Alxw::getInstance()->Router()->add('/', function () { Alxw::getInstance()->ClassLoader('Index'); }); //phpinfo规则 Alxw::getInstance()->Router()->add('/php', function () { phpinfo(); }); //启动路由 Alxw::getInstance()->Router()->run();
public function __construct() { $this->dom = Alxw::getInstance()->R()->Layout()->get('404'); $this->dom->show(); }
protected function setLayout($layout) { $this->Document = Alxw::getInstance()->R()->Layout()->get($layout); $this->HTML = $this->Document->HTML; }