Skip to content

Commit d014b5d

Browse files
author
yishuo
committed
Merged revision(s) 3385-3387, 3390-3532 from laboratory/trunk:
message queue ........ NEW - bug 266: 添加基于phpredis扩展的redisCache支持 http://bugs.phpwind-inc.com/show_bug.cgi?id=266 ........ NEW - bug 266: 添加基于phpredis扩展的redisCache支持 http://bugs.phpwind-inc.com/show_bug.cgi?id=266 ........ NEW - bug 267: bug// db.WindConnectionManager bug修复 http://bugs.phpwind-inc.com/show_bug.cgi?id=267 ........ 接口更新 ........ Merged revision(s) 3391-3397 from trunk: 修复,error args 不能传递问题 ........ 每次链接用完重置一下初始值 ........ 每次链接用完重置一下初始值 ........ ........ docs下config更新 ........ docs下config更新 ........ 组件策略修改 ........ blog 优化 ........ blog 优化 ........ blog 优化 ........ blog 优化 ........ blog 优化 ........ NEW - bug 269: bug // base.WindFactory.resolveConfig 当resource的值为空时不解析 http://bugs.phpwind-inc.com/show_bug.cgi?id=269 ........ error page 优化 ........ NEW - bug 270: bug // viewer.AbstractWindTemplateCompiler 属性值未定义错误 http://bugs.phpwind-inc.com/show_bug.cgi?id=270 ........ RESOLVED - bug 271: bug // web.WindErrorHandler 错误标识错误 http://bugs.phpwind-inc.com/show_bug.cgi?id=271 ........ NEW - bug 272: ResultSet bug,参数变量错误 http://bugs.phpwind-inc.com/show_bug.cgi?id=272 ........ 结构调整,frontController,request,response 调整 ........ 删除 collections 组建 ........ 删除 mq 组建 ........ 结构调整,frontController,request,response 调整 ........ 结构调整,frontController,request,response 调整 ........ 结构调整,frontController,request,response 调整 ........ demo风格修改 ........ 删除编译文件 ........ dbCache的batchGet返回数据格式错误,需要对应上key ........ 错误信息提示 ........ 默认路由不需要urlDecode会自动解析 ........ 发送的数据需要区分递交数据方式,除了get方式递交数据外,其他方式递交数据不需要urlencode ........ 将urlencode urldecode 统一更改为 rawurlencode rawurldecode ........ 将urlencode urldecode 统一更改为 rawurlencode rawurldecode ........ http transfer 接口调整 去掉一些冗余的接口定义 重构一些代码 ........ http transfer 接口调整 去掉一些冗余的接口定义 重构一些代码 ........ urlhelper.argsToUrl 未支持$encode参数 顺便重构了一下代码 ........ AbstractWindHttp 单利模式改造,去掉单利模式 ........ 配置中 通配符 支持 通配符格式 {m/c/a},支持参数分别为m,c,a ........ 优化AbstractWindRouter.setParams方法~ ........ 配置中 通配符 支持 通配符格式 {m/c/a},支持参数分别为m,c,a ........ 注释优化,优化注释中代码使用示例 ........ 更名组件配置文件名,模式开头+components后缀 ........ 初步优化module,删除不建议使用方法以及属性 ........ 优化 应用及前端控制器,将相关组件梳理到配置中~ ........ 初步优化module,删除不建议使用方法以及属性 ........ createApplication公共接口,bug修复, ........ createApplication公共接口,bug修复, ........ createApplication公共接口,bug修复, ........ createApplication公共接口,bug修复, ........ createApplication公共接口,bug修复, ........ createApplication公共接口,bug修复, ........ createApplication公共接口,bug修复, ........ createApplication公共接口,bug修复, ........ createApplication公共接口,bug修复, ........ createApplication公共接口,bug修复, ........ 初步优化module,删除不建议使用方法以及属性 ........ 初步优化module,删除不建议使用方法以及属性 ........ 初步优化module,删除不建议使用方法以及属性 ........ 修复邮箱编码问题 ........ WindString::strLen中设置的编码有问题[http://bugs.phpwind-inc.com/show_bug.cgi?id=270] ........ NEW - bug 271: i18n组件,当解析不成功时,应该返回原信息,而不是截断后的串 http://bugs.phpwind-inc.com/show_bug.cgi?id=271 ........ NEW - bug 273: 模板编译internal标签时候,正则匹配字串时候将多次赋值,当脚本达到一定长度时候,可能造成web服务器崩溃 http://bugs.phpwind-inc.com/show_bug.cgi?id=273 ........ windHttpRequest在获取pathinfo的方法中去除urlDecode[bugs.phpwind-inc.com/show_bug.cgi?id=274] ........ 效率优化 ........ 效率优化 ........ 效率优化 ........ Bug 275 - 系统工具整理之自动安装流程及优化 ........ 效率优化 ........ 效率优化 ........ 效率优化 ........ 注释完善 ........ bug 修复 ........ bug 修复 ........ bug 修复 ........ bug 修复 ........ bug 修复 ........ bug 修复 ........ 新增命令行模式~ ........ 组件配置 ........ 组件配置 ........ 组件配置 ........ 组件配置 ........ 组件配置 ........ 组件配置 ........ 效率优化 ........ 效率优化 ........ bug 修复 ........ bug 修复 ........ bug 修复 ........ bug 修复 ........ bug 修复 ........ bug 修复 ........ git-svn-id: http://svn.simba.taobao.com/svn/PW_WindFramework/trunk@3534 18ba2127-5a84-46d4-baec-3457e417f034
1 parent e5c7d8b commit d014b5d

33 files changed

+650
-568
lines changed

demos/blog/compile/template/index.tpl

Lines changed: 0 additions & 72 deletions
This file was deleted.

demos/blog/compile/template/layout.tpl

Lines changed: 0 additions & 49 deletions
This file was deleted.

demos/blog/conf/config.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
return array(
3+
//重载了系统组件中的db组件的定义,将db组件的config指向应用根目录下的db_config.php
4+
//我们可以通过这种方式重载任何系统组件的定义,也可以定义新的组件。组件名称不能重复。
5+
//支持resource的配置方式
6+
'components' => array(
7+
'db' => array(
8+
'config' => array(
9+
'resource' => 'conf.db_config.php',
10+
)
11+
)
12+
),
13+
//应用配置,支持多个应用配置。一个应用支持多个modules(业务模块),每个modules都有一个别名用于访问。
14+
//当不输入任何modules时访问‘default’默认模块
15+
'web-apps' => array(
16+
'blog' => array(
17+
'modules' => array(
18+
'default' => array(
19+
//应用控制器访问路径定义,当前定义的路径是当前应用根目录下的‘controller/’
20+
'controller-path' => 'controller',
21+
//应用控制器后缀定义
22+
'controller-suffix' => 'Controller',
23+
//模板目录定义
24+
'template-dir' => 'template',
25+
//编译文件目录定义
26+
'compile-dir' => 'data.compile',
27+
//错误处理句柄定义
28+
'error-handler' => 'controller.ErrorController',
29+
)
30+
),
31+
//过滤器配置,在这里部署了一个form表单过滤器
32+
'filters' => array(
33+
'user' => array(
34+
'class' => 'WIND:web.filter.WindFormFilter',
35+
'pattern' => 'default/Index/(login|dreg)',
36+
'form' => 'service.UserForm'
37+
)
38+
)
39+
)
40+
)
41+
);
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
2+
23
return array(
34
'dsn' => 'mysql:host=localhost;dbname=test',
45
'user' => 'root',
56
'pwd' => 'phpwind.net',
6-
'charset' => 'utf8'
7-
);
7+
'charset' => 'utf8');

demos/blog/config/config.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

demos/blog/config/route_config.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

demos/blog/controller/ErrorController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class ErrorController extends WindErrorHandler {
1616
*/
1717
public function run() {
1818
$this->setLayout('layout');
19-
$this->setGlobal($this->getRequest()->getBaseUrl(true) . '/static/images', 'images');
20-
$this->setGlobal($this->getRequest()->getBaseUrl(true) . '/static/images', 'css');
19+
$this->setGlobal($this->getRequest()->getBaseUrl(true) . '/template/images', 'images');
20+
$this->setGlobal($this->getRequest()->getBaseUrl(true) . '/template/images', 'css');
2121
$topic = "Blog Error";
2222
$this->setOutput($topic, "errorHeader");
2323
$this->setOutput($this->urlReferer, "baseUrl");
Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
Wind::import('model.UserForm');
32
/**
43
* 默认的 controller
54
*
@@ -10,85 +9,75 @@
109
* @package demos.blog.controller
1110
*/
1211
class IndexController extends WindController {
13-
/**
14-
* @var UserForm
15-
*/
16-
private $userInfo;
17-
/**
18-
* @var WindSession
19-
*/
20-
private $session;
2112

2213
/* (non-PHPdoc)
2314
* @see WindSimpleController::beforeAction()
2415
*/
2516
public function beforeAction($handlerAdapter) {
2617
parent::beforeAction($handlerAdapter);
27-
$this->session = $this->getSystemFactory()->getInstance('windSession');
28-
$this->userInfo = $this->session->get('user');
2918
$this->setLayout('layout');
30-
$this->setGlobal($this->getRequest()->getBaseUrl(true) . '/static/images', 'images');
31-
$this->setGlobal($this->getRequest()->getBaseUrl(true) . '/static/images', 'css');
3219
$this->setOutput('utf8', 'charset');
20+
$this->setGlobal($this->getRequest()->getBaseUrl(true) . '/template/images', 'images');
21+
$this->setGlobal($this->getRequest()->getBaseUrl(true) . '/template/images', 'css');
3322
}
3423

3524
/* (non-PHPdoc)
3625
* @see WindController::run()
3726
*/
3827
public function run() {
39-
$this->setOutput($this->userInfo, 'userInfo');
28+
Wind::import('service.UserForm');
29+
$userService = $this->load();
30+
$userInfo = $userService->isLogin();
31+
$this->setOutput($userInfo, 'userInfo');
4032
$this->setTemplate('index');
4133
}
4234

35+
/**
36+
* 访问用户注册页面
37+
*/
38+
public function regAction() {
39+
$this->setTemplate('reg');
40+
}
41+
4342
/**
4443
* 用户登录
4544
*/
4645
public function loginAction() {
47-
if ($this->userInfo) $this->showMessage('已登录,请先注销.');
46+
$userService = $this->load();
47+
$userInfo = $userService->isLogin();
48+
if ($userInfo) $this->showMessage('已登录~');
49+
4850
/* @var $userForm UserForm */
4951
$userForm = $this->getInput("userForm");
5052
if (!$userForm) $this->showMessage('获取用户登录数据失败');
5153

52-
/* @var $db WindConnection */
53-
$db = $this->getSystemFactory()->getInstance('db');
54-
$stmt = $db->createStatement('SELECT userid FROM user WHERE username=:username AND password =:password');
55-
if (!$stmt->getValue(array('username' => $userForm->getUsername(), 'password' => $userForm->getPassword()))) {
56-
$this->showMessage('登录失败.');
57-
}
58-
$this->session->set('user', $userForm);
54+
if (!$userService->login($userForm)) $this->showMessage('登录失败.');
5955
$this->forwardRedirect(WindUrlHelper::createUrl('run'));
6056
}
6157

62-
/**
63-
* 访问用户注册页面
64-
*/
65-
public function regAction() {
66-
$this->setTemplate('reg');
67-
}
68-
6958
/**
7059
* 处理用户注册表单
7160
*/
7261
public function dregAction() {
73-
$this->session->destroy();
74-
if ($userForm = $this->getInput("userForm")) {
75-
$db = $this->getSystemFactory()->getInstance('db');
76-
$stmt = $db->createStatement('SELECT * FROM user WHERE username=:username');
77-
if ($stmt->getOne(array(':username' => $userForm->getUsername()))) $this->showMessage('该用户已经注册.');
78-
if (!$db->execute(
79-
"INSERT INTO user SET " . $db->sqlSingle(
80-
array('username' => $userForm->getUsername(), 'password' => $userForm->getPassword())))) $this->showMessage(
81-
'注册失败.');
82-
$this->setOutput($userForm, 'userInfo');
83-
}
62+
$userService = $this->load();
63+
$userForm = $this->getInput("userForm");
64+
if (!$userService->register($userForm)) $this->showMessage('注册失败.');
65+
$this->setOutput($userForm, 'userInfo');
8466
$this->setTemplate('reg');
8567
}
8668

8769
/**
8870
* 用户退出
8971
*/
9072
public function logoutAction() {
91-
$this->session->destroy();
73+
$this->load()->logout();
9274
$this->forwardRedirect(WindUrlHelper::createUrl('run'));
9375
}
76+
77+
/**
78+
* @return UserService
79+
*/
80+
private function load() {
81+
return Wind::getApp()->getWindFactory()->createInstance(Wind::import('service.UserService'));
82+
}
9483
}

demos/blog/index.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
33
define('WIND_DEBUG', 1);
44
require_once '../../wind/Wind.php';
5-
6-
Wind::application('blog', 'config/config.php')->run();
5+
Wind::application('blog', 'conf/config.php')->run();
76

0 commit comments

Comments
 (0)