<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[kakapo's nest]]></title> 
<link>http://www.kakapo.cn/blog/index.php</link> 
<description><![CDATA[My Technical Knowledge Management System]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[kakapo's nest]]></copyright>
<item>
<link>http://www.kakapo.cn/blog/read.php?117</link>
<title><![CDATA[KFC应用开发规范(3)_视图模板开发]]></title> 
<author>kakapo &lt;kakapowu@gmail.com&gt;</author>
<category><![CDATA[Documents]]></category>
<pubDate>Fri, 10 Aug 2007 10:09:17 +0000</pubDate> 
<guid>http://www.kakapo.cn/blog/read.php?117</guid> 
<description>
<![CDATA[ 
	原理: 引入模板引擎类，根据其语法规范，将网页制作成模板文件。<br/><br/>规范：<br/>1. 一套模板风格以一个目录名放在View目录下;<br/>2. 模板名称组成: 控制器名_功能名.html 例如user_closet.html<br/><br/>注意事项：<br/>1.模板的开发规范根据不用模板引擎而不同。<br/>2.KFC会将一些全局变量自动赋值到模板文件中以供使用,这些全局变量为：网站基本信息 $GLOBALS['gSiteInfo']和 语言包$GLOBALS['gLang']<br/><br/>范例：<br/><br/>使用phpTemplate引擎的模板:<br/><br/>header.html文件<br/><div class="code"><br/>&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;<br/>&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<br/>&lt;head&gt;<br/>&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=&lt;?=$webcharset?&gt;&quot; /&gt;<br/>&lt;title&gt;&lt;?=$site_name?&gt;&lt;/title&gt;<br/>&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?=$image_site_url?&gt;/css/personal.css&quot; type=&quot;text/css&quot; /&gt;<br/>&lt;/head&gt;<br/></div><br/><br/>其他文件<br/><div class="code"><br/>&lt;? include &quot;header.html&quot;;?&gt;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&quot;menu&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a href=&quot;?action=defaults&amp;view=defaults&quot; id=&quot;menu1&quot; class=&quot;menuvisited&quot;&gt;显示资料&lt;/a&gt;&lt;/li&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a href=&quot;?action=defaults&amp;view=editinfo&quot; id=&quot;menu2&quot;&gt;修改资料&lt;/a&gt;&lt;/li&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a href=&quot;?action=defaults&amp;view=changepwd&quot; id=&quot;menu3&quot;&gt;修改密码&lt;/a&gt;&lt;/li&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&lt;/div&gt;<br/>&nbsp;&nbsp;&lt;div id=&quot;main&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;? include &quot;left.html&quot;;?&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=&quot;profileinfo&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;用 户 名：&lt;?=$loginuser&#91;&#039;user_name&#039;&#93;?&gt;&lt;/li&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;昵　　称：&lt;?=$loginuser&#91;&#039;user_nickname&#039;&#93;?&gt;&lt;/li&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;性　　别：&lt;? if($loginuser&#91;&#039;user_gender&#039;&#93;==0) echo &quot;男生&quot;;if($loginuser&#91;&#039;user_gender&#039;&#93;==1) echo &quot;女生&quot;;?&gt;&lt;/li&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;地　　区：&lt;?=$loginuser&#91;&#039;user_city&#039;&#93;?&gt;&lt;/li&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;保密邮箱：&lt;?=$loginuser&#91;&#039;user_email&#039;&#93;?&gt;&lt;/li&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br/>&nbsp;&nbsp;&lt;/div&gt;<br/>&lt;/div&gt;<br/>&lt;/div&gt;<br/>&lt;!--end content --&gt;<br/>&lt;? include &quot;footer.html&quot;;?&gt;<br/></div><br/><br/><br/>Tags - <a href="http://www.kakapo.cn/blog/tag.php?tag=kfc" rel="tag">kfc</a> , <a href="http://www.kakapo.cn/blog/tag.php?tag=%25E5%25BC%2580%25E5%258F%2591%25E8%25A7%2584%25E8%258C%2583" rel="tag">开发规范</a>
]]>
</description>
</item><item>
<link>http://www.kakapo.cn/blog/read.php?116</link>
<title><![CDATA[KFC应用开发规范(2)_业务模型开发]]></title> 
<author>kakapo &lt;kakapowu@gmail.com&gt;</author>
<category><![CDATA[Documents]]></category>
<pubDate>Fri, 10 Aug 2007 10:07:25 +0000</pubDate> 
<guid>http://www.kakapo.cn/blog/read.php?116</guid> 
<description>
<![CDATA[ 
	 <br/>原理: 分析业务逻辑，抽象出接口，开发底层的业务类，提供给控制层使用。<br/><br/>规范:<br/>1. 模型文件命名为 foo.class.php;<br/>2. 类名跟文件名"."号的最前头一致, class foo&#123;&#125;;<br/><br/>API：<br/>resource parent::dbConnect(array $options); <br/><br/>注意事项：<br/>由于数据库操作类有多种选择adodb,peardb,pdo,database，所以开发人员要熟悉这些类的使用方法。<br/><br/>类书写范例<br/><div class="code"><br/>&lt;?php<br/>/*<br/>* 需要数据库操作的要 继承 Model<br/>* &nbsp;<br/>*/<br/>class UserWealthManage extends Model &#123;<br/>&nbsp;&nbsp;// php5 的写法<br/>&nbsp;&nbsp;private &nbsp;$mydb=&quot;&quot;;<br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;/**<br/>&nbsp;&nbsp;* 选择php5 构造函数<br/>&nbsp;&nbsp;*<br/>&nbsp;&nbsp;*/<br/>&nbsp;&nbsp;function __construct()&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;mydb = parent::dbConnect($GLOBALS&#91;&#039;gDataBase1&#039;&#93;);<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;/**<br/>&nbsp;&nbsp;* 或者php4 构造函数，这里只是为了说明KFC框架类库本身兼容php4，php5，<br/> &nbsp; &nbsp; &nbsp; &nbsp;* 但是应用项目最好采用php5的类规范来开发。<br/>&nbsp;&nbsp;*<br/>&nbsp;&nbsp;*/<br/>&nbsp;&nbsp;function UserWealthManage()&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;mydb = parent::dbConnect($GLOBALS&#91;&#039;gDataBase1&#039;&#93;);<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;/**<br/>&nbsp;&nbsp;* 获取用户<br/>&nbsp;&nbsp;*@params int $user_id<br/>&nbsp;&nbsp;*@return mixed<br/>&nbsp;&nbsp;*/<br/>&nbsp;&nbsp;function GetUserWealth($user_id)&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$n=floor($user_id/100000);<br/>&nbsp;&nbsp;&nbsp;&nbsp;$table = &quot;user_&quot;.($n+1).&quot;0w&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$query = &quot;select * from $table where user_id=&quot;.$user_id;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$user_wealth = $this-&gt;mydb-&gt;getAll($query);<br/>&nbsp;&nbsp;&nbsp;&nbsp;if($user_wealth!==false)&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $user_wealth;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;else&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;/**<br/>&nbsp;&nbsp;* 解析字符串<br/>&nbsp;&nbsp;*@params string $str<br/>&nbsp;&nbsp;*@return array<br/>&nbsp;&nbsp;*/<br/>&nbsp;&nbsp;function ParseItemStr($str)&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;if(!empty($str))&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(substr($str,-1,1)==&#039;;&#039;) $str = substr($str,0,-1);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$arrs = array();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$array = array();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$arrs = explode(&quot;;&quot;,$str);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach ($arrs as $k=&gt;$v)&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$array&#91;$k&#93; = explode(&quot;,&quot;,$v);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unset($arrs);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $array;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp;function __destruct()&#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;unset($this-&gt;mydb);<br/> &nbsp; &nbsp; &nbsp; &#125;<br/>&nbsp;&nbsp;<br/>&#125;<br/><br/><br/><br/>?&gt;<br/><br/></div><br/><br/><span style="font-size: 18px;">轻量级数据库类database.class.php API</span><br/><br/>//初始化参数<br/>class database($database_type,$host,$database,$user,$password,$port=false,$dsn=false);<br/><br/>//连接数据库<br/>boolen connect(void);<br/><br/>//返回false 或者 连接资源 <br/>mixed query(string $sql_statement, array $array ='');<br/><br/>// 执行结果<br/>boolen execute(string $sql_statement, array $array ='')<br/><br/>//返回根据从结果集取得的行生成的数组，如果没有更多行则返回 FALSE。 <br/>mixed fetchRow(resource $result)<br/><br/>//只返回一行<br/>mixed getRow(resource $result);<br/><br/>// 取得结果集中行的数目<br/>mixed countRows(resource result);<br/><br/>// 取得所有数据<br/>array getAll(string $sql_statement, array $array ='');<br/><br/><div class="code"><br/>&lt;?php<br/>// 应用举例<br/>$db = new database($options&#91;&#039;type&#039;&#93;,$options&#91;&#039;host&#039;&#93;,$options&#91;&#039;dbname&#039;&#93;,$options&#91;&#039;user&#039;&#93;,<br/>&nbsp;&nbsp;&nbsp;&nbsp;$options&#91;&#039;passwd&#039;&#93;,$options&#91;&#039;port&#039;&#93;);<br/><br/>// 获取结果<br/>$result = $db-&gt;query(&quot;select * from user where user_id=?&quot;, array($user_id));<br/>while($row = $db-&gt;fetchRow($result))&#123;<br/>&nbsp;&nbsp;$array&#91;&#93; = $row;<br/>&#125;<br/><br/>// 取得行数<br/>$num = $db-&gt;countRow($result);<br/><br/>// 执行操作<br/>$r = $db-&gt;execute(&quot;update user set user_name=&#039;ddd&#039; where user_id=&#039;&#123;$user_id&#125;&#039;&quot;);<br/>if($r)&#123;<br/>&nbsp;&nbsp;return true;<br/>else<br/> &nbsp; &nbsp;return false;<br/><br/>// 取得一行<br/>$row = $db-&gt;getRow(&quot;select * from user where user_id=?&quot;, array($user_id));<br/><br/>// 取得所有<br/>$array = $db-&gt;getAll(&quot;select * from user where 1&quot;);<br/><br/><br/><br/>?&gt;<br/></div><br/>Tags - <a href="http://www.kakapo.cn/blog/tag.php?tag=kfc" rel="tag">kfc</a> , <a href="http://www.kakapo.cn/blog/tag.php?tag=%25E5%25BC%2580%25E5%258F%2591%25E8%25A7%2584%25E8%258C%2583" rel="tag">开发规范</a>
]]>
</description>
</item><item>
<link>http://www.kakapo.cn/blog/read.php?115</link>
<title><![CDATA[KFC应用开发规范(1)_控制器开发]]></title> 
<author>kakapo &lt;kakapowu@gmail.com&gt;</author>
<category><![CDATA[Documents]]></category>
<pubDate>Fri, 10 Aug 2007 09:57:47 +0000</pubDate> 
<guid>http://www.kakapo.cn/blog/read.php?115</guid> 
<description>
<![CDATA[ 
	原理：利用面向对象的思维，将功能点定义为类的方法；将应用功能模块定义为一个类；<br/><br/>规范：<br/>1. 控制器文件命名为 foo.class.php;<br/>2. 类名跟文件名"."号的最前头一致，class foo&#123;&#125;；<br/>3. 类的方法命名采用"view_"或者"op_" 小写开头; 剩下功能描述部分(功能名)只能为大小写字母和数字组成，如view_home1 , op_saveForm<br/> &nbsp;<span style="color: #DC143C;">*不带view_和op_ 开头的类方法不会做为应用项目系统的权限点；</span><br/><br/>API 接口：<br/>// 权限验证 <br/>void &nbsp; parent::authenticate(); <br/><br/>// 引入业务模型<br/>object $this->includeModel(string $model_name);<br/><br/>// 引入外部组件<br/>object $this->addComponent($com_name);<br/><br/>// 赋值到模板，跟smarty一样<br/>void &nbsp; $this->assign('var',$value);<br/><br/>// 显示模板<br/>void &nbsp; $this->display($tpl_name);<br/><br/>// 显示提示信息<br/>void &nbsp; show_message(string $message);<br/><br/>// 返回<br/>void &nbsp; goback();<br/><br/>// 跳转到其他页面<br/>void &nbsp; Redirect(string $url,int $type);<br/> &nbsp;<br/> &nbsp;类书写范例<br/><div class="code"><br/> &nbsp;&lt;?php<br/> &nbsp;class foo extends Controller&#123;<br/> &nbsp;<br/> &nbsp;/**<br/> &nbsp; * _constructor KFC自带的仿构造函数，会在类实例化时自动执行<br/> &nbsp; * @access public<br/> &nbsp; * @return void<br/> &nbsp; */<br/> &nbsp;function _constructor()&#123;<br/> &nbsp; &nbsp; &nbsp; // 权限验证<br/> &nbsp; &nbsp; &nbsp; parent::authenticate();<br/> &nbsp;&#125;<br/> &nbsp;/**<br/> &nbsp; * URL访问：?action=foo&amp;view=home&amp;var=1111<br/> &nbsp; * @access public<br/> &nbsp; * @return void<br/> &nbsp; */<br/> &nbsp; &nbsp; &nbsp; <br/> &nbsp;function view_home()&#123;<br/> &nbsp; &nbsp; &nbsp; &nbsp; <br/> &nbsp; &nbsp; // 初始化外部变量<br/> &nbsp; &nbsp; $var = isset($_GET&#91;&#039;var&#039;&#93;)?$_GET&#91;&#039;var&#039;&#93;:&#039;&#039;;<br/> &nbsp; &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; // 引入业务模型<br/> &nbsp; &nbsp; &nbsp; &nbsp; $userManage = $this-&gt;includeModel(&quot;UserManage&quot;);<br/> &nbsp; &nbsp; &nbsp; &nbsp; $userinfo = $userManage-&gt;getUserInfo(22);<br/><br/><br/> &nbsp; &nbsp; &nbsp;// 引入外部组件<br/> &nbsp; &nbsp; &nbsp;$phpmailer = $this-&gt;addComponent(&#039;phpmailer&#039;);<br/> &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp;<br/> &nbsp; &nbsp;// 赋值到模板，跟smarty一样<br/> &nbsp; &nbsp; &nbsp;$this-&gt;assign(&quot;var&quot;,$var);<br/> &nbsp; &nbsp; &nbsp;// 显示模板<br/> &nbsp; &nbsp; &nbsp;$this-&gt;display(&quot;foo_home.html&quot;);<br/> &nbsp;&#125;<br/> &nbsp;/**<br/> &nbsp; * 处理POST提交的操作：在form表单需要插入<br/> &nbsp; * &lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;foo&quot;&gt;<br/> &nbsp; * &lt;input type=&quot;hidden&quot; name=&quot;op&quot; value=&quot;saveForm&quot;&gt;<br/> &nbsp; * @access public<br/> &nbsp; * @return void<br/> &nbsp; */<br/> &nbsp;function op_saveForm()&#123;<br/> &nbsp; &nbsp; // $KFC_POST 获取了$_POST的所有数据；<br/> &nbsp; &nbsp; global $KFC_POST;<br/><br/> &nbsp; &nbsp; print_r($KFC_POST);<br/><br/> &nbsp; &nbsp; //....<br/> &nbsp; &nbsp; // 实际业务编程<br/><br/> &nbsp; &nbsp; <br/><br/> &nbsp; &nbsp; // 完成后需要跳转 几个内置函数可以参考使用<br/><br/> &nbsp; &nbsp; // 显示提示信息<br/> &nbsp; &nbsp; show_message(&quot;操作成功！&quot;);<br/> &nbsp; &nbsp; // 返回<br/> &nbsp; &nbsp; goback();<br/> &nbsp; &nbsp; // 相当于 show_message_goback(&quot;操作成功！&quot;);<br/><br/> &nbsp; &nbsp; //或者跳转到其他页面<br/> &nbsp; &nbsp; //类型1 使用php的header;类型2 使用js的location.href;类型3 使用setTimeout跳转;<br/> &nbsp; &nbsp; Redirect(&quot;http://www.google.cn&quot;,1);<br/><br/> &nbsp;&#125;<br/><br/> &nbsp;function otherFunction()&#123;<br/> &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; // 编程<br/><br/> &nbsp; &nbsp; return ;<br/> &nbsp;&#125;<br/><br/> &nbsp;&#125;<br/> &nbsp;?&gt;<br/></div><br/>Tags - <a href="http://www.kakapo.cn/blog/tag.php?tag=kfc" rel="tag">kfc</a> , <a href="http://www.kakapo.cn/blog/tag.php?tag=%25E5%25BC%2580%25E5%258F%2591%25E8%25A7%2584%25E8%258C%2583" rel="tag">开发规范</a>
]]>
</description>
</item><item>
<link>http://www.kakapo.cn/blog/read.php?106</link>
<title><![CDATA[创建Hello World.]]></title> 
<author>kakapo &lt;kakapowu@gmail.com&gt;</author>
<category><![CDATA[Documents]]></category>
<pubDate>Wed, 13 Jun 2007 03:02:27 +0000</pubDate> 
<guid>http://www.kakapo.cn/blog/read.php?106</guid> 
<description>
<![CDATA[ 
	在用KFC的自动安装程序启动了项目之后，在根目录下会出现应用项目名称，控制器目录Controllers下有一个默认文件defaults.class.php，里面有hello world举例存在。本文要描述的是如何手动启动KFC的应用项目。<br/><br/>第一步：在网站根目录下，首先将整个KFC框架拷贝过来，然后分别创建目录<strong>Controllers</strong>(控制器)，<strong>Models</strong>(业务模型)，<strong>Views</strong>(模板视图)，<strong>tmp</strong>(缓存目录)，<strong>Languages</strong>(语言包目录)，<strong>public</strong>(公共目录)，<strong>Plugins</strong>(外部插件目录)。<br/>在public目录下再分别创建目录<strong>flashs</strong>,<strong>images</strong>,<strong>javascripts</strong>,<strong>stylesheets</strong>,<strong>htmls</strong>，这些目录将存放全站共享的静态文件。<br/><br/>第二步：创建配置文件config.ini.php,代码如下：<br/><div class="code"><br/>&lt;?php<br/>//Application<br/><br/>//use dev, online<br/>define(&quot;APP_STATUS&quot;, &#039;dev&#039;);<br/><br/>// define application directory<br/>define(&quot;APP_DIR&quot;, dirname(__file__)); &nbsp;<br/><br/>// define systems KFC directory, it can be relative<br/>define(&#039;KFC_DIR&#039;, APP_DIR . &quot;/KFC&quot;); <br/><br/>// define language<br/>define(&quot;APP_LANG&quot;,&#039;en&#039;);<br/><br/>// use database or not<br/>define(&quot;USE_DATABASE&quot;,0);<br/><br/>// define session save handle (file, mysql, memcache)<br/>define(&quot;SESSION_HANDLE&quot;,&#039;file&#039;);<br/><br/> &nbsp;<br/>// turns off access to post variables through anything<br/>define(&#039;HIDE_POST&#039;, 1); <br/>// disallow spaces in url parameters, helps prevent sql injection.<br/>define(&#039;STRIP_URL_VARS&#039; ,1); <br/><br/>//Global-Site Settings<br/>$GLOBALS&#91;&#039;gSiteInfo&#039;&#93;&#91;&#039;site_name&#039;&#93; = &#039;KFC Demo&#039;;<br/>$GLOBALS&#91;&#039;gSiteInfo&#039;&#93;&#91;&#039;version&#039;&#93; = &#039;v1.0&#039;;<br/>$GLOBALS&#91;&#039;gSiteInfo&#039;&#93;&#91;&#039;site_url&#039;&#93; = &#039;http://localhost/&#039;;<br/>$GLOBALS&#91;&#039;gSiteInfo&#039;&#93;&#91;&#039;site_title&#039;&#93; = &quot;KFC PHP Framework&quot;;<br/>$GLOBALS&#91;&#039;gSiteInfo&#039;&#93;&#91;&#039;webcharset&#039;&#93; = &#039;utf-8&#039;;<br/>$GLOBALS&#91;&#039;gSiteInfo&#039;&#93;&#91;&#039;pagenum&#039;&#93; = 15;<br/><br/><br/>?&gt;<br/></div><br/><br/>第三步：创建一个入口文件index.php，代码如下：<br/><br/><div class="code"><br/>&lt;?php<br/>include(dirname(__file__) . &quot;/config.ini.php&quot;);<br/>include(KFC_DIR . &quot;/KFC.php&quot;);<br/>$start_time = getmicrotime();<br/><br/>// new application<br/>$kfc = &amp;new KFC(APP_DIR,0);<br/><br/>// set defaults controller (option)<br/>$kfc-&gt;setDefController(&#039;defaults&#039;);<br/><br/>// set default view style<br/>$kfc-&gt;setDefView(&#039;defaults&#039;);<br/><br/><br/>$kfc-&gt;run();<br/><br/>$end_time = getmicrotime();<br/>echo &quot;&lt;center&gt;执行时间: &quot;.($end_time-$start_time).&quot;&lt;/center&gt;&quot;;<br/>?&gt;<br/><br/></div><br/><br/>第四步：在Controllers下面创建一个目录index(必须跟入口文件名称一致)，然后在index目录下创建一个默认控制器文件defaults.class.php,代码如下：<br/><div class="code"><br/>&lt;?php<br/>class defaults extends Controller&#123;<br/> &nbsp;<br/> &nbsp;function view_defaults()&#123;<br/> &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; //example use tpl <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$assign&#91;&#039;homepage&#039;&#93;&#91;&#039;name&#039;&#93; = &quot;Hello World!&quot;;<br/> &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$this-&gt;assign($assign);<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$this-&gt;display(&quot;index.html&quot;);<br/> &nbsp; &nbsp; &nbsp;<br/> &nbsp;&#125;<br/><br/>&#125;<br/>?&gt;<br/><br/></div><br/><br/>第五步：在Views目录下创建defaults目录，做为默认主题模板。然后在defaults目录下创建模板index.html<br/>代码如下：<br/><div class="code"><br/><br/>&lt;html&gt;<br/>&lt;base href=&quot;&lt;?=$site_url?&gt;&quot;&gt;<br/>&lt;title&gt;&lt;?=$site_title?&gt;&lt;/title&gt;<br/>&lt;body&gt;<br/>&lt;?=$homepage&#91;&#039;name&#039;&#93;?&gt;<br/>&lt;/body&gt;<br/>&lt;/html&gt;<br/></div><br/><br/>第六步：完成，在浏览器输入http://localhost/index.php<br/>Tags - <a href="http://www.kakapo.cn/blog/tag.php?tag=kfc" rel="tag">kfc</a>
]]>
</description>
</item><item>
<link>http://www.kakapo.cn/blog/read.php?83</link>
<title><![CDATA[KFC中文手册整理]]></title> 
<author>kakapo &lt;kakapowu@gmail.com&gt;</author>
<category><![CDATA[Documents]]></category>
<pubDate>Thu, 08 Mar 2007 07:35:54 +0000</pubDate> 
<guid>http://www.kakapo.cn/blog/read.php?83</guid> 
<description>
<![CDATA[ 
	第一章. <a href="http://www.kakapo.cn/blog/read.php?43" target="_blank">简介和缘起</a><br/><br/>第二章. <a href="http://www.kakapo.cn/blog/read.php?44" target="_blank">基本思想</a><br/><br/>第三章. <a href="http://www.kakapo.cn/blog/read.php?81" target="_blank">KFC执行流程图</a><br/><br/>第四章. <a href="http://www.kakapo.cn/blog/read.php?48" target="_blank">目录结构和文件</a><br/><br/>第五章. <a href="http://www.kakapo.cn/blog/read.php?82" target="_blank">安装和配置</a><br/><br/>第六章. <a href="http://www.kakapo.cn/blog/read.php?106" target="_blank">创建Hello World.</a><br/><br/>第七章. 业务模型开发<br/><br/>第八章. 缓存的使用<br/><br/>第九章. 权限模块<br/><br/>第十章. 组件的扩展<br/><br/><br/>Tags - <a href="http://www.kakapo.cn/blog/tag.php?tag=kfc" rel="tag">kfc</a>
]]>
</description>
</item><item>
<link>http://www.kakapo.cn/blog/read.php?82</link>
<title><![CDATA[安装和配置]]></title> 
<author>kakapo &lt;kakapowu@gmail.com&gt;</author>
<category><![CDATA[Documents]]></category>
<pubDate>Thu, 08 Mar 2007 07:21:09 +0000</pubDate> 
<guid>http://www.kakapo.cn/blog/read.php?82</guid> 
<description>
<![CDATA[ 
	KFC因为提供了安装程序，使启动一个应用项目变得非常简单。KFC框架本身不用安装。<br/><br/>安装：<br/>1. &nbsp;下载源文件压缩包，上传至网站空间，解压缩后出现KFC、admin、install、Docs和install.php等，admin为示例应用项目(demo)；<br/>2. &nbsp;运行install.php，按照提示操作自动创建新的应用项目(需要保证根目录权限为777）。否则手动按照示例项目先创建应用项目目录，然后逐步创建其他目录和入口文件，配置文件等。<br/>3. &nbsp;将web服务器documentroot目录修改指到项目目录下。(使用虚拟主机空间的用户只需要在步骤2选择在根目录下安装项目，步骤3就不用做了)。<br/><br/>配置：<br/>应用项目安装完成之后，程序员可以修改的配置地方只有两个文件，入口文件和配置文件。一般情况下，入口文件在确定了默认启动控制器，默认模板风格，数据库引擎类，模板引擎类，是否启动权限验证，是否采用缓存之后就不需要修改了。剩下可以修改的配置全在config.ini.php。除了安装时KFC框架必需的静态配置之外，程序员还可以根据项目要求增加配置参数。<br/>Tags - <a href="http://www.kakapo.cn/blog/tag.php?tag=kfc" rel="tag">kfc</a>
]]>
</description>
</item><item>
<link>http://www.kakapo.cn/blog/read.php?81</link>
<title><![CDATA[KFC执行流程图]]></title> 
<author>kakapo &lt;kakapowu@gmail.com&gt;</author>
<category><![CDATA[Documents]]></category>
<pubDate>Thu, 08 Mar 2007 07:05:01 +0000</pubDate> 
<guid>http://www.kakapo.cn/blog/read.php?81</guid> 
<description>
<![CDATA[ 
	KFC系统的执行过程如下图所示：<br/><a href="http://www.kakapo.cn/blog/attachment/1173337471_0.gif" target="_blank"><img src="http://www.kakapo.cn/blog/attachment/1173337471_0.gif" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>Tags - <a href="http://www.kakapo.cn/blog/tag.php?tag=kfc" rel="tag">kfc</a>
]]>
</description>
</item><item>
<link>http://www.kakapo.cn/blog/read.php?48</link>
<title><![CDATA[目录结构和文件]]></title> 
<author>kakapo &lt;kakapowu@gmail.com&gt;</author>
<category><![CDATA[Documents]]></category>
<pubDate>Sat, 09 Dec 2006 07:19:43 +0000</pubDate> 
<guid>http://www.kakapo.cn/blog/read.php?48</guid> 
<description>
<![CDATA[ 
	KFC目录结构图<br/><a href="http://www.kakapo.cn/blog/attachment/kfc_menu_1.jpg" target="_blank"><img src="http://www.kakapo.cn/blog/attachment/kfc_menu_1.jpg" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>Common 目录存放config.php基本配置，error.php错误处理工具，globals.php全局定义，utils.php常用工具。<br/>Components 目录存放外部精选的组件，libs/ 目录放着组件源代码。<br/>Core 目录存放核心组件。<br/><br/> KFC框架的核心文件叫KFC.php，这个文件要解决的问题有下面几个：<br/>1、引入框架全局文件，包含静态变量，全局变量，内置常用方法，错误处理方法等。<br/>2、设置应用系统路径、启动控制器、启动必需组件及注册session所需变量；<br/>3、采用URL mapping (URL 镜像)机制，让程序员能很方便的找到网页执行程序的位置。简单的说是，一个方法处理一个网页，一个控制类是一些处理相关网页的方法的集合。<br/><br/>举例：<br/><div class="code"><br/>http://localhots/index.php?action=user&amp;view=login<br/>其中user指向控制器Controllers目录下用户控制器类文件user.php里的类Class user&#123;&#125;，login指向Class user&#123;&#125;的一个方法$user::login()。<br/>action表示将要启用的控制器；view表示这是一个GET方式，需要一个模板；而POST方式将由变量op来表示，一般情况下POST方法不需要模板<br/></div><br/><br/><br/><br/>示例应用系统admin的目录结构图：<br/> &nbsp; <a href="http://www.kakapo.cn/blog/attachment/admin_demo_1.jpg" target="_blank"><img src="http://www.kakapo.cn/blog/attachment/admin_demo_1.jpg" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/>Models &nbsp; &nbsp; &nbsp; 目录存放应用系统的数据业务模型，一般为的业务处理类。<br/>Views &nbsp; &nbsp; &nbsp; &nbsp; 目录存放着模板文件；<br/>Controllers 目录存放控制器文件，这些文件分别归类在以入口文件名命名的目录下，每个文件是处理相关网页集合的类，都要继承KFC框架的核心类Class Controller&#123;&#125;，以获得调用组件的方法。<br/>Languages &nbsp;目录存放语言包文件；<br/>Plugins &nbsp; &nbsp; &nbsp; 目录存放一些此项目所需的其他插件，KFC框架没有的；需要使用时由程序员自己引入。<br/>public &nbsp; &nbsp; &nbsp; &nbsp; 目录将存放images，flash，javascripts，css，html等静态文件。<br/>tmp &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;是一个缓存目录，需要定义为777，具有可写入可操作。比如存放smarty的编译文件等。<br/>config.ini.php &nbsp;是应用系统的基本配置文件；<br/>admin.php &nbsp; 应用系统的一个入口，负责引入KFC.php文件并执行页面程序。<br/>.htaccess &nbsp; 为apache的权限控制文件，常用来配置url_rewrite规则。<br/><br/><br/><br/><br/><br/>Tags - <a href="http://www.kakapo.cn/blog/tag.php?tag=kfc" rel="tag">kfc</a>
]]>
</description>
</item><item>
<link>http://www.kakapo.cn/blog/read.php?44</link>
<title><![CDATA[基本思想]]></title> 
<author>kakapo &lt;kakapowu@gmail.com&gt;</author>
<category><![CDATA[Documents]]></category>
<pubDate>Mon, 04 Dec 2006 15:39:00 +0000</pubDate> 
<guid>http://www.kakapo.cn/blog/read.php?44</guid> 
<description>
<![CDATA[ 
	 &nbsp; &nbsp; <span style="font-size: 14px;"><strong>组件的选择和准备</strong></span><br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 一般成熟稳定的工具类不只有一个类，而是多个类的有机组合，它能够完美体现程序设计方法，特别是面向对象开发的思维精华。每个工具类都有自己特定的应用范畴，譬如phpmailer就专门为了发送邮件的。而且这种工具类一般都有使用demo，甚至还有用户使用手册(end- user document). 比如adodb,smarty。它们也经常有升级版本，不断的debug。具有以上特征的类可以定义为成熟优秀的工具类。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;在KFC框架里面，每个这样的工具类都被放在Components/libs库中，分别独立存放自己的目录里，方便以后升级覆盖。然后，通过一个Class Component&#123;&#125;抽象出它们共有的属性和方法。于是每个工具类就被KFC当作了一个个组件，分别用 Class component_toolname&#123;&#125; 继承并扩展父类Class Component&#123;&#125;，具体实现本组件的细节部分，完成本组件的实例化，随时准备好被应用系统调用。以后扩展组件库，每引进一个成熟的php工具类，都如法炮制。<br/> &nbsp; &nbsp; &nbsp; &nbsp;<br/> &nbsp; &nbsp;<span style="font-size: 14px;"><strong>组件的调用和搭配</strong></span><br/> &nbsp; &nbsp; &nbsp; &nbsp;组件的调用是由控制器类来完成的。命名为Class Controller&#123;&#125;，同时这个类还要有调用业务模型Model接口，视图View接口。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;首先，KFC将所有组件分为必需的和可选的两种类型，避免了执行时间的浪费。必需的组件必须在应用系统初始化的时候就被默认调用，可选的组件在编程过程中根据实际事务灵活调用。通常来说必需的组件有数据库封装类，模板引擎类，Session管理类等等。国外的Zoop框架就要求所需组件都必须在初始化时调用，但是在应用系统中并不是每个执行页面都会用上所有组件，造成了执行效率降低。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;其次，必需组件的选用决定了应用系统的开发效率和执行速度。通过必需组件的灵活搭配，可以适应不同的应用需求。例如后台开发可以使用peardb ＋smarty，强大的smarty可以帮助提高编程速度。前台开发用adodb＋phptemplate，利用adodb实现数据对象的缓存。小型前台(如企业网站)如果为了追求轻便快速，可以采用超轻量级的database+phptemplate；<br/><br/> &nbsp; &nbsp; &nbsp;<span style="font-size: 14px;"><strong>关于控制器</strong></span><br/> &nbsp; &nbsp; &nbsp; &nbsp;Class Controller&#123;&#125;核心文件需要被应用系统的控制器类继承，因为它提供了灵活调用可选组件的方法。同时也负责了应用系统启动需要的基本环境搭建工作。比如调用语言包和引入应用系统全局配置。<br/><br/>Tags - <a href="http://www.kakapo.cn/blog/tag.php?tag=kfc" rel="tag">kfc</a>
]]>
</description>
</item><item>
<link>http://www.kakapo.cn/blog/read.php?43</link>
<title><![CDATA[简介和缘起]]></title> 
<author>kakapo &lt;kakapowu@gmail.com&gt;</author>
<category><![CDATA[Documents]]></category>
<pubDate>Thu, 30 Nov 2006 15:09:43 +0000</pubDate> 
<guid>http://www.kakapo.cn/blog/read.php?43</guid> 
<description>
<![CDATA[ 
	 &nbsp; &nbsp; &nbsp; &nbsp; KFC, 全称是Kindly Fast Component (友好性、快速性、组件化)，是一个php开发框架。核心思想是友好引入现有的优秀的php工具类，将其作为框架可选的组件。不断开发自己的内置的核心的组件。在按需调用的原则下，通过组件的优化搭配实现快速的执行效率。以MVC模式开发，以面向对象思想编程。兼容php4与php5。<br/><br/> &nbsp; &nbsp; &nbsp;研究了不少php开发框架，其中有些是重新构建自己的基础工具类，比如数据库抽象类，模板引擎类。虽然这些框架的作者本着快速的想法重新开发这样的工具类为自己的框架所用，但是，这造成大量的功能相同使用方法不同的工具类出现，同质化现象严重，给新手造成选择和使用的麻烦。比如国外的<a href="http://www.cakephp.org/" target="_blank">CakePHP</a>和国内的<a href="http://fcs.org.cn/blog/" target="_blank">ThinkPHP</a>。想使用这些框架的phper都要重新学习熟悉这些常用工具的使用方法。其实，php数据库抽象类开发的最成熟的当数<a href="http://adodb.sourceforge.net/" target="_blank">adodb</a>以及<a href="http://pear.php.net/DB" target="_blank">peardb</a>。当我开始减少使用mysql_connect()后，就开始学习并熟练掌握peardb、adodb，后者更强大。<br/><br/> &nbsp; &nbsp; &nbsp; 还有，在模板引擎类方面，最强大的当数php官方发布的<a href="http://smarty.php.net/" target="_blank">Smarty</a>。但是一些人认为smarty太庞大太复杂而放弃它，认为学习smary像在重新学习一门语言，转而去选用其他小巧灵活的模板引擎，像<a href="http://www.thewebmasters.net/php/FastTemplate.phtml" target="_blank">FastTemplate</a>或者<a href="http://smarttemplate.yi.org/" target="_blank">SmartTemplate</a>。如果他们没有真正了解smarty就放弃了它的话，我认为这是一种放弃了西瓜而去捡芝麻的做法。<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;开发框架基本上离不开数据库抽象类和模板引擎类。我相信不少phper也会有自己常用的这两种工具类，甚至还掌握了更多的成熟的优秀的工具类。比如发布邮件的<a href="http://phpmailer.sourceforge.net/" target="_blank">phpmailer</a>，操作xml的<a href="http://www.domit.de/" target="_blank">domit</a>，创建rss的<a href="http://feedcreator.org/" target="_blank">Feedcreator</a>等等。还有pear库里面更多的类等待探索。既然有这么多优秀的工具类存在，而且有持续的升级版本出现，为什么不借鉴来使用呢？所以KFC提倡“拿来主义”，取其精华，为我所用。<br/><br/><br/>Tags - <a href="http://www.kakapo.cn/blog/tag.php?tag=kfc" rel="tag">kfc</a>
]]>
</description>
</item>
</channel>
</rss>