-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2d38a78
Showing
40 changed files
with
3,122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* leguan Framework | ||
* | ||
* @link http://github.com/usheweb/leguan | ||
* @copyright Copyright (c) 2014 ushe (http://leguan.usheweb.com/) | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
//应用公共配置文件 | ||
return array( | ||
/*数据库相关*/ | ||
'dbDsn' => '', | ||
'dbEngine' => 'mysql', | ||
'dbName' => 'leguan', | ||
'dbHost' => '127.0.0.1', | ||
'dbPort' => '', | ||
'dbUser'=>'root', | ||
'dbPwd' =>'', | ||
'dbPrefix' => 'lg_' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php | ||
|
||
return array( | ||
'test' => 'test'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
/** | ||
* leguan Framework | ||
* | ||
* @link http://github.com/usheweb/leguan | ||
* @copyright Copyright (c) 2014 ushe (http://leguan.usheweb.com/) | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
namespace Index\Controller; | ||
|
||
use \Leguan\Controller\Controller; | ||
use \Usheweb\Chapter\Chapter; | ||
|
||
class IndexController extends Controller | ||
{ | ||
public function indexAction() | ||
{ | ||
$table = 'article'; | ||
|
||
$condition = array('click' => array('>',5,'or'),'id'=>array('in',array(1,3,5))); | ||
$article = $this->Db->table($table)->where($condition)->field('id,title')->select(); | ||
|
||
$view = $this->view; | ||
$view->assign('author', 'ushe'); | ||
$view->assign('script', '<script>alert("Leguan")</script>'); | ||
$view->assign('article', $article); | ||
$view->assign('age',20); | ||
$view->list = array('apple','pear','orange'); | ||
$view->display(); | ||
echo "<br>"; | ||
echo $this->Debug->execTime(); | ||
} | ||
|
||
public function dbAction() | ||
{ | ||
$values = array("title"=>"new 'title",'description' => 'test'); | ||
$table = 'article'; | ||
//$this->Debug->dump($this->Db->query('insert into `lg_article` set title = ?,description = ?;')); | ||
//echo $this->Db->table($table)->values($values)->add(); | ||
|
||
$this->Debug->dump( | ||
$this->Sql->table($table)->where( | ||
array('click' => array('>',5,'or'),'id'=>array('in',array(1,3,5))))->field('id,title')->select() | ||
); | ||
} | ||
|
||
public function chapterAction() | ||
{ | ||
$chapter = new Chapter(); | ||
$chapter->show(); | ||
} | ||
|
||
public function cacheAction() | ||
{ | ||
$arr = array('a',123); | ||
$this->cache->write('test_arr', $arr); | ||
$this->debug->dump($this->cache->read('test_arr')); | ||
} | ||
|
||
public function readcacheAction() | ||
{ | ||
$arr = $this->cache->read('test_arr'); | ||
$this->debug->dump($arr); | ||
} | ||
|
||
public function defaultAction() | ||
{ | ||
echo 'defaultAction'; | ||
} | ||
|
||
public function uploadAction() | ||
{ | ||
$this->view->assign('upload', new \Usheweb\Upload\Upload()); | ||
$this->view->display(); | ||
} | ||
|
||
public function doUploadAction() | ||
{ | ||
if(!$this->request->isPost()){ | ||
return; | ||
} | ||
|
||
$upload = new \Usheweb\Upload\Upload(); | ||
$this->debug->dump($upload->run()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
return 'a:2:{i:0;s:1:"a";i:1;i:123;}'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
/** | ||
* leguan Framework 入口文件 | ||
* | ||
* @link http://github.com/usheweb/leguan | ||
* @copyright Copyright (c) 2014 ushe (http://leguan.usheweb.com/) | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
define('IS_DEBUG', true); | ||
define('APP_NAME', 'appliction'); | ||
|
||
require "library\Leguan\Bootstrap\Start.php"; | ||
\Leguan\Bootstrap\Start::run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
Navicat MySQL Data Transfer | ||
Source Server : 本地 | ||
Source Server Version : 50524 | ||
Source Host : localhost:3306 | ||
Source Database : leguan | ||
Target Server Type : MYSQL | ||
Target Server Version : 50524 | ||
File Encoding : 65001 | ||
Date: 2014-10-14 23:57:55 | ||
*/ | ||
|
||
SET FOREIGN_KEY_CHECKS=0; | ||
|
||
-- ---------------------------- | ||
-- Table structure for `lg_article` | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `lg_article`; | ||
CREATE TABLE `lg_article` ( | ||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | ||
`title` char(100) DEFAULT NULL, | ||
`click` int(11) unsigned NOT NULL DEFAULT '0', | ||
`description` varchar(255) DEFAULT NULL, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8; | ||
|
||
-- ---------------------------- | ||
-- Records of lg_article | ||
-- ---------------------------- | ||
INSERT INTO `lg_article` VALUES ('1', 'title2', '0', 'description3'); | ||
INSERT INTO `lg_article` VALUES ('2', 'title', '0', 'description'); | ||
INSERT INTO `lg_article` VALUES ('3', '1', '0', null); | ||
INSERT INTO `lg_article` VALUES ('4', 'new \'title', '0', 'test'); | ||
INSERT INTO `lg_article` VALUES ('5', 'new \'title', '10', 'test'); | ||
INSERT INTO `lg_article` VALUES ('6', 'new \'title', '0', 'test'); | ||
INSERT INTO `lg_article` VALUES ('7', 'new \'title', '0', 'test'); | ||
INSERT INTO `lg_article` VALUES ('8', 'new \'title', '0', 'test'); | ||
INSERT INTO `lg_article` VALUES ('9', 'new \'title', '0', 'test'); | ||
INSERT INTO `lg_article` VALUES ('10', 'new \'title', '0', 'test'); | ||
INSERT INTO `lg_article` VALUES ('11', 'new \'title', '0', 'test'); | ||
INSERT INTO `lg_article` VALUES ('12', 'new \'title', '0', 'test'); | ||
INSERT INTO `lg_article` VALUES ('13', 'new \'title', '0', 'test'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
/** | ||
* leguan Framework | ||
* | ||
* @link http://github.com/usheweb/leguan | ||
* @copyright Copyright (c) 2014 ushe (http://leguan.usheweb.com/) | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
namespace Leguan\Bootstrap; | ||
|
||
/** | ||
* leguan 核心控制类 | ||
*/ | ||
class Leguan | ||
{ | ||
//对象实例 | ||
private static $_obj = array(); | ||
|
||
/** | ||
* 添加对象 | ||
* | ||
* @exception $name已经存在 | ||
* @param $name string | ||
* @param $obj mixed | ||
* @return void | ||
*/ | ||
public static function set($name, $obj) | ||
{ | ||
$name = ucwords($name); | ||
if (isset(self::$_obj[$name])) { | ||
throw new \Exception("{$name}".'已在Leguan::$_obj中', 1); | ||
} | ||
|
||
self::$_obj[$name] = $obj; | ||
} | ||
|
||
/** | ||
* 删除对象 | ||
* @exception $name不存在 | ||
* @param $name string | ||
* @return void | ||
*/ | ||
public static function del($name) | ||
{ | ||
if (!isset(self::$_obj[$name])) { | ||
throw new \Exception("{$name}".'不在Leguan::$_obj中', 1); | ||
} | ||
|
||
unset(self::$_obj[$name]); | ||
} | ||
|
||
/** | ||
* 清除对象 | ||
*/ | ||
public static function clear() | ||
{ | ||
self::$_obj = array(); | ||
} | ||
|
||
/** | ||
* 获取对象 | ||
* | ||
* @exception $name不存在 | ||
* @param $name string | ||
* @return mixed | ||
*/ | ||
public static function get($name) | ||
{ | ||
$name = ucwords($name); | ||
if (!isset(self::$_obj[$name])) { | ||
$obj = "\\Leguan\\{$name}\\{$name}"; | ||
self::$_obj[$name] = new $obj(); | ||
} | ||
|
||
return self::$_obj[$name]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
/** | ||
* leguan Framework | ||
* | ||
* @link http://github.com/usheweb/leguan | ||
* @copyright Copyright (c) 2014 ushe (http://leguan.usheweb.com/) | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
namespace Leguan\Bootstrap; | ||
|
||
/** | ||
* 路径信息类 | ||
*/ | ||
class Path | ||
{ | ||
//路径信息 | ||
private $_path = array(); | ||
|
||
public function __construct() | ||
{ | ||
$this->_init(); | ||
} | ||
|
||
/** | ||
* 初始化路径信息 | ||
*/ | ||
private function _init() | ||
{ | ||
$this->_path['root'] = realpath(''); | ||
$this->_path['ds'] = DIRECTORY_SEPARATOR; | ||
$this->_path['ps'] = PATH_SEPARATOR; | ||
$this->_path['lib'] = $this->_path['root'] . $this->_path['ds'] . 'library'; | ||
$this->_path['app'] = $this->_path['root'] . $this->_path['ds'] . APP_NAME; | ||
$this->_path['data'] = $this->_path['root'] . $this->_path['ds'] . 'data'; | ||
$this->_path['view'] = $this->_path['root'] . $this->_path['ds'] . 'themes'; | ||
$this->_path['upload'] = $this->_path['root'] . $this->_path['ds'] . 'uploads'; | ||
|
||
$this->_path['cache'] = $this->_path['data'] . $this->_path['ds'] . 'cache'; | ||
$this->_path['log'] = $this->_path['data'] . $this->_path['ds'] . 'log'; | ||
|
||
$this->_path['html'] = $this->_path['cache'] . $this->_path['ds'] . 'html'; | ||
$this->_path['data'] = $this->_path['cache'] . $this->_path['ds'] . 'data'; | ||
|
||
$this->_path['appCommon'] = $this->_path['app'] . $this->_path['ds'] . 'Common'; | ||
$this->_path['appConfig'] = $this->_path['appCommon'] . $this->_path['ds'] . 'Config'; | ||
} | ||
|
||
public function __get($name) | ||
{ | ||
if (isset($this->_path[$name])) { | ||
return $this->_path[$name]; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public function __set($name, $value) | ||
{ | ||
$this->add($name, $value); | ||
} | ||
|
||
/** | ||
* 添加路径信息 | ||
* | ||
* @exception $name路径信息存在 | ||
* @param $name string | ||
* @param $value string | ||
* @return void | ||
*/ | ||
public function add($name, $value) | ||
{ | ||
if (isset($this->_path[$name])) { | ||
throw new \Exception("$name".'已在Path::$_path中', 1); | ||
} | ||
|
||
$this->_path[$name] = $value; | ||
} | ||
|
||
/** | ||
* 删除路径信息 | ||
* | ||
* @exception $name路径信息不存在 | ||
* @param $name | ||
* @return string | ||
*/ | ||
public function del($name) | ||
{ | ||
if(!isset($this->_path[$name])){ | ||
throw new \Exception("$name".'不在Path::$_path中', 1); | ||
} | ||
|
||
unset($this->_path[$name]); | ||
} | ||
|
||
/** | ||
* 清除路径信息 | ||
*/ | ||
public function clear() | ||
{ | ||
$this->_path = array(); | ||
} | ||
|
||
/** | ||
* 获取路径中文件扩展名 | ||
*/ | ||
public function getExtension($path) | ||
{ | ||
return pathinfo($path, PATHINFO_EXTENSION); | ||
} | ||
} |
Oops, something went wrong.