Skip to content

Commit eaface8

Browse files
author
yishuo
committed
2011/9/19/ v0.8 主线分支合并
git-svn-id: http://svn.simba.taobao.com/svn/PW_WindFramework/trunk@2727 18ba2127-5a84-46d4-baec-3457e417f034
1 parent 5c64c46 commit eaface8

253 files changed

Lines changed: 9963 additions & 10205 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

_compile/compile.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* 动态编译脚本,开发环境执行此文件,动态生成过程文件
4+
* @author wuq
5+
**/
6+
error_reporting(E_ALL);
7+
define('WIND_DEBUG', 1);
8+
include '../wind/Wind.php';
9+
define('_COMPILE_PATH', dirname(__FILE__) . '/');
10+
Wind::clear();
11+
Wind::import('WIND:base.*', true);
12+
Wind::import('WIND:filter.*', true);
13+
Wind::import('WIND:web.*', true);
14+
Wind::import('WIND:router.*', true);
15+
Wind::import('WIND:http.request.*', true);
16+
Wind::import('WIND:http.response.*', true);
17+
Wind::import('WIND:utility.*', true);
18+
19+
$imports = Wind::getImports();
20+
/* 载入需要的文件信息 */
21+
Wind::import('WIND:utility.WindPack');
22+
Wind::import('WIND:utility.WindFile');
23+
Wind::import('WIND:utility.WindString');
24+
Wind::import('WIND:parser.WindConfigParser');
25+
26+
/* 打包 */
27+
$pack = new WindPack();
28+
$fileList = array();
29+
$content = array();
30+
foreach ($imports as $key => $value) {
31+
$_key = Wind::getRealPath($key);
32+
$fileList[$_key] = array($key, $value);
33+
$content[$value] = parseFilePath($key);
34+
}
35+
$pack->setContentInjectionCallBack('addImports');
36+
$pack->packFromFileList($fileList, _COMPILE_PATH . 'wind_basic.php', WindPack::STRIP_PHP, true);
37+
WindFile::write(_COMPILE_PATH . 'wind_imports.php', '<?php return ' . WindString::varToString($content) . ';');
38+
39+
/* 编译配置文件信息 */
40+
$windConfigParser = new WindConfigParser();
41+
$dh = opendir(_COMPILE_PATH . 'config');
42+
while (($file = readdir($dh)) !== false) {
43+
if (is_file(_COMPILE_PATH . 'config/' . $file) && $file !== '.' && $file !== '..') {
44+
$result = $windConfigParser->parse(_COMPILE_PATH . 'config/' . $file);
45+
$file = preg_replace('/\.(\w)*$/i', '', $file);
46+
WindFile::write(_COMPILE_PATH . $file . '.php', '<?php return ' . WindString::varToString($result) . ';');
47+
//WindFile::write(WIND_PATH . $file . '.php', '<?php return ' . WindString::varToString($result) . ';');
48+
}
49+
}
50+
51+
echo 'compile successful!';
52+
53+
/*********************************************************************/
54+
/* 向wind包中注入imports文件目录信息 */
55+
function addImports() {
56+
$_content = WindString::varToString($GLOBALS['imports']);
57+
$_content = str_replace(array("\r\n", "\t", " "), '', $_content);
58+
return 'Wind::setImports(' . $_content . ')';
59+
}
60+
61+
/* 清理所有缓存 */
62+
function parseFilePath($filePath) {
63+
list($namespace, $filePath) = explode(':', $filePath);
64+
return str_replace('.', '/', $filePath);
65+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- <component name='' path='' initMethod='' scope="application/singleton/prototype/"
4+
proxy='' destroy=''> -->
5+
<!-- <property property-name='' ref/value/path=''> -->
6+
<!-- <constructor-arg ref/value/path=''> -->
7+
<!-- <config resource=''> -->
8+
<!-- </component> -->
9+
10+
<components>
11+
<component name='windApplication' path='WIND:web.WindWebApplication'
12+
scope='singleton'>
13+
<properties>
14+
<property name='dispatcher' ref='dispatcher' />
15+
<property name='handlerAdapter' ref='router' />
16+
</properties>
17+
</component>
18+
<component name='windLogger' path='WIND:log.WindLogger'
19+
scope='singleton' destroy='flush'>
20+
<constructor-args>
21+
<constructor-arg name='0' value='DATA:log' />
22+
<constructor-arg name='1' value='2' />
23+
</constructor-args>
24+
</component>
25+
<component name='dispatcher' path='WIND:web.WindDispatcher'
26+
scope='application'>
27+
</component>
28+
<component name='forward' path='WIND:web.WindForward' scope='prototype'>
29+
<properties>
30+
<property name='windView' ref='windView' />
31+
</properties>
32+
</component>
33+
<component name='router' path='WIND:router.WindRouter' scope="application">
34+
</component>
35+
<component name='urlHelper' path='WIND:web.WindUrlHelper'
36+
scope='application'>
37+
</component>
38+
<component name='windView' path='WIND:viewer.WindView' scope='prototype'>
39+
<config>
40+
<template-dir>template</template-dir>
41+
<template-ext>htm</template-ext>
42+
<is-compile>0</is-compile>
43+
<compile-dir>compile.template</compile-dir>
44+
<compile-ext>tpl</compile-ext>
45+
<layout></layout>
46+
<theme></theme>
47+
</config>
48+
<properties>
49+
<property name='viewResolver' ref='viewResolver' />
50+
<property name='viewCache' ref='viewCache' />
51+
</properties>
52+
</component>
53+
<component name='viewResolver' path='WIND:viewer.WindViewerResolver'
54+
scope='prototype'>
55+
<properties>
56+
<property name='windLayout' ref='layout' />
57+
</properties>
58+
</component>
59+
<component name='layout' path='WIND:viewer.WindLayout' scope='prototype'>
60+
</component>
61+
<component name='template' path='WIND:viewer.compiler.WindViewTemplate'
62+
scope='prototype'>
63+
</component>
64+
<component name='db' path='WIND:db.WindConnection' scope='singleton'>
65+
<config resource='db_config.xml' />
66+
</component>
67+
<component name='errorMessage' path='WIND:core.web.WindErrorMessage'
68+
scope='prototype'>
69+
</component>
70+
71+
<component name='configParser' path='WIND:parser.WindConfigParser'
72+
scope='singleton'>
73+
</component>
74+
<!--windCache组件:框架默认缓存机制;当wind_config中‘iscache’属性标签值为‘0’时该功能关闭。 默认windCache组件定义如下定义 -->
75+
<component name='windCache' path='WIND:cache.strategy.WindFileCache'
76+
scope='singleton'>
77+
<!-- dbCache 需要配置properties属性 -->
78+
<!--<properties> <property name='connection' ref='db' /> </properties> -->
79+
<config>
80+
<dir>DATA:caches</dir>
81+
<suffix>php</suffix>
82+
<expires>0</expires>
83+
</config>
84+
</component>
85+
<component name='windSession' path='WIND:http.session.WindSession'
86+
scope='singleton' destroy='commit'>
87+
<constructor-args>
88+
<constructor-arg name='0' ref='windCache' />
89+
</constructor-args>
90+
</component>
91+
</components>

_compile/readme

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
运行:
2+
compile.php
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<?php
2-
Wind::import('WIND:core.web.WindController');
32
/**
4-
* Enter description here ...
5-
*
63
* the last known user to change this file in the repository <$LastChangedBy$>
74
* @author Qiong Wu <[email protected]>
85
* @version $Id$
@@ -11,9 +8,8 @@
118
class IndexController extends WindController {
129

1310
public function run() {
14-
echo 'Hello world';
15-
exit();
11+
echo 'hello world!';
1612
}
17-
13+
1814
}
1915
?>

demos/helloworld/index.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
2-
require_once (dirname(__FILE__) . '/../../wind/wind.php');
3-
$start = microtime(true);
4-
//Wind::perLoadCoreLibrary(COMPILE_LIBRARY_PATH);
5-
Wind::run();
6-
echo microtime(true) - $start;
7-
?>
2+
error_reporting(E_ALL);
3+
define('WIND_DEBUG', 0);
4+
require_once ('../../wind/Wind.php');
5+
Wind::application()->run();
6+

docs/config/components_config.xml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- <component name='' path='' initMethod='' scope="application/singleton/prototype/"
4+
proxy='' destroy=''> -->
5+
<!-- <property property-name='' ref/value/path=''> -->
6+
<!-- <constructor-arg ref/value/path=''> -->
7+
<!-- <config resource=''> -->
8+
<!-- </component> -->
9+
<!--
10+
组件的配置标签说明:
11+
name: 组件的名字,唯一用于在应用中获取对应组件的对象实例
12+
path: 该组件的实现
13+
scope: 组件对象的范围: {singleton: 单例; application: 整个应用; prototype: 当前使用}
14+
initMethod: 在应用对象生成时执行的方法
15+
destroy: 在应用结束的时候执行的操作
16+
proxy: 组件是否用代理的方式调用
17+
18+
constructor-args:构造方法的参数
19+
constructor-arg:
20+
name:参数的位置,起始位置从0开始,第一个参数为0,第二个参数为1
21+
参数的值的表示方式有一下几种:
22+
ref: 该属性是一个对象,ref的值对应着组件的名字
23+
value: 一个字串值
24+
path: path指向的类的实例将会被创建传递给该属性
25+
26+
properties: 属性的配置,表现为组件中的类属性
27+
property:
28+
name:属性名称
29+
属性值的表示方式有以下几种:
30+
ref: 该属性是一个对象,ref的值对应着组件的名字,表现为在组件中获取方式为“_get+属性名()”称来获取
31+
value: 一个字串值
32+
path: path指向的类的实例将会被创建传递给该属性
33+
34+
35+
config: 组件的配置-该值对应的配置会通过setConfig接口传递给组件;
36+
resource: 指定一个外部地址,将会去包含该文件
37+
-->
38+
<components>
39+
<component name='windApplication' path='WIND:web.WindWebApplication'
40+
scope='singleton'>
41+
<properties>
42+
<property name='dispatcher' ref='dispatcher' />
43+
<property name='handlerAdapter' ref='router' />
44+
</properties>
45+
</component>
46+
<component name='windLogger' path='WIND:log.WindLogger'
47+
scope='singleton' destroy='flush'>
48+
<constructor-args>
49+
<constructor-arg name='0' value='DATA:log' />
50+
<constructor-arg name='1' value='2' />
51+
</constructor-args>
52+
</component>
53+
<component name='dispatcher' path='WIND:web.WindDispatcher'
54+
scope='application'>
55+
</component>
56+
<component name='forward' path='WIND:web.WindForward' scope='prototype'>
57+
<properties>
58+
<property name='windView' ref='windView' />
59+
</properties>
60+
</component>
61+
<component name='router' path='WIND:router.WindRouter' scope="application">
62+
</component>
63+
<component name='urlHelper' path='WIND:web.WindUrlHelper'
64+
scope='application'>
65+
</component>
66+
<component name='windView' path='WIND:viewer.WindView' scope='prototype'>
67+
<config>
68+
<template-dir>template</template-dir>
69+
<template-ext>htm</template-ext>
70+
<is-compile>0</is-compile>
71+
<compile-dir>compile.template</compile-dir>
72+
<compile-ext>tpl</compile-ext>
73+
<layout></layout>
74+
<theme></theme>
75+
</config>
76+
<properties>
77+
<property name='viewResolver' ref='viewResolver' />
78+
<property name='viewCache' ref='viewCache' />
79+
</properties>
80+
</component>
81+
<component name='viewResolver' path='WIND:viewer.WindViewerResolver'
82+
scope='prototype'>
83+
<properties>
84+
<property name='windLayout' ref='layout' />
85+
</properties>
86+
</component>
87+
<component name='layout' path='WIND:viewer.WindLayout' scope='prototype'>
88+
</component>
89+
<component name='template' path='WIND:viewer.compiler.WindViewTemplate'
90+
scope='prototype'>
91+
</component>
92+
<component name='db' path='WIND:db.WindConnection' scope='singleton'>
93+
<config resource='db_config.xml' />
94+
</component>
95+
<component name='errorMessage' path='WIND:core.web.WindErrorMessage'
96+
scope='prototype'>
97+
</component>
98+
99+
<component name='configParser' path='WIND:parser.WindConfigParser'
100+
scope='singleton'>
101+
</component>
102+
<!--windCache组件:框架默认缓存机制;当wind_config中‘iscache’属性标签值为‘0’时该功能关闭。 默认windCache组件定义如下定义 -->
103+
<component name='windCache' path='WIND:cache.strategy.WindFileCache'
104+
scope='singleton'>
105+
<!-- dbCache 需要配置properties属性 -->
106+
<!--<properties> <property name='connection' ref='db' /> </properties> -->
107+
<config>
108+
<dir>DATA:caches</dir>
109+
<suffix>php</suffix>
110+
<expires>0</expires>
111+
</config>
112+
</component>
113+
<component name='windSession' path='WIND:http.session.WindSession'
114+
scope='singleton' destroy='commit'>
115+
<constructor-args>
116+
<constructor-arg name='0' ref='windCache' />
117+
</constructor-args>
118+
</component>
119+
</components>

docs/config/db_config.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<!-- WIND:db.WindConnection 配置格式,适合单链接应用,同时不支持连接池 -->
4+
<WIND>
5+
<!-- 链接的DSN,方式:类型:name=value; 链接类型mysql host为localhost,链接的数据库名字为test, 链接端口为3306 -->
6+
<dsn>mysql:host=localhost;dbname=test;port=3306</dsn>
7+
<!-- 链接数据库的用户名 -->
8+
<user>root</user>
9+
<!-- 链接数据库的密码 -->
10+
<pwd>root</pwd>
11+
<!-- 存取数据库的链接字符集 -->
12+
<charset>utf8</charset>
13+
<!-- 表前缀,需要“{}”符号,将表名进行标识,才能进行正确替换 -->
14+
<tableprefix>pw_</tableprefix>
15+
</WIND>
16+
17+
<!-- WIND:db.WindConnectionManager 配置格式 ,支持链接池,允许配置多个链接-->
18+
<WIND>
19+
<!-- except: 配置多链接的分配规则 -->
20+
<connections except='*:(db1);user*,tablename2:(db1|db2);'>
21+
<!-- 各个链接的配置,配置格式如单个链接的配置 -->
22+
<connection name='db1'>
23+
<dsn>mysql:host=localhost;dbname=test</dsn>
24+
<user>root</user>
25+
<pwd>root</pwd>
26+
<charset>utf8</charset>
27+
<tableprefix>pw_</tableprefix>
28+
</connection>
29+
<connection name='db2'>
30+
<dsn>mysql:host=localhost;dbname=test</dsn>
31+
<user>root</user>
32+
<pwd>root</pwd>
33+
<charset>utf8</charset>
34+
<tableprefix>pw_</tableprefix>
35+
</connection>
36+
</connections>
37+
</WIND>

docs/config/dbcache_config.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!-- 数据库缓存的配置信息 -->
3+
<WIND>
4+
<!-- 缓存文件的过期时间 -->
5+
<expires>0</expires>
6+
<!-- 缓存key的前缀 -->
7+
<key-prefix></key-prefix>
8+
<!-- 缓存key安全盐码 -->
9+
<security-code></security-code>
10+
<!-- db链接配置名字 -->
11+
<dbconfig-name></dbconfig-name>
12+
<!-- 缓存的表名 -->
13+
<table-name>pw_cache</table-name>
14+
<!-- 缓存的key字段名称 -->
15+
<field-key>key</field-key>
16+
<!-- 缓存的value字段名称 -->
17+
<field-value>value</field-value>
18+
<!-- 缓存的过期时间字段名称 -->
19+
<field-expire>expire</field-expire>
20+
</WIND>

docs/config/filecache_config.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!-- 文件缓存配置 -->
3+
<WIND>
4+
<!-- 缓存文件的过期时间 -->
5+
<expires>0</expires>
6+
<!-- 缓存key的前缀 -->
7+
<key-prefix></key-prefix>
8+
<!-- 缓存key安全盐码 -->
9+
<security-code></security-code>
10+
11+
<!-- 缓存文件的保存路径(支持命名空间的方式配置该路径) -->
12+
<dir>WIND:_compile</dir>
13+
<!-- 缓存文件的后缀 -->
14+
<suffix>php</suffix>
15+
<!-- 缓存的目录支持级别 -->
16+
<dir-level>0</dir-level>
17+
</WIND>
File renamed without changes.

0 commit comments

Comments
 (0)