- ·上一篇文章:PHP程序员的优化调试技术和技巧
- ·下一篇文章:使用 PHP 5.0创建图形的巧妙方法
理解PHP中的MVC编程之MVC框架简介
tsintoourframework's
*mold.IfitextendsfrombothFR_ModuleandFR_Auththenitshouldbe
*goodtorun.
*
*@authorJoeStump<joe@joestump.net>
*@static
*@parammixed$module
*@returnbool
*/
publicstaticfunctionisValid($module)
{
return(is_object($module)&&
$moduleinstanceofFR_Module&&
$moduleinstanceofFR_Auth);
}
//}}}
//{{{__destruct()
publicfunction__destruct()
{
parent::__destruct();
}
//}}}
}
?>
presenter.php-表述层的核心。
<?php
classFR_Presenter
{
//{{{factory($type,FR_Module$module)
/**
*factory
*
*@authorJoeStump<joe@joestump.net>
*@accesspublic
*@paramstring$typePresentationtype(ourview)
*@parammixed$moduleOurmodule,whichthepresenterwilldisplay
*@returnmixedPEAR_Erroronfailureoravalidpresenter
*@static
*/
staticpublicfunctionfactory($type,FR_Module$module)
{
$file=FR_BASE_PATH.'/includes/Presenter/'.$type.'.php';
if(include($file)){
$class='FR_Presenter_'.$type;
if(class_exists($class)){
$presenter=new$class($module);
if($presenterinstanceofFR_Presenter_common){
return$presenter;
}
returnPEAR::raiseError('Invalidpresentationclass:'.$type);
}
returnPEAR::raiseError('Presentationclassnotfound:'.$type);
}
returnPEAR::raiseError('Presenterfilenotfound:'.$type);
}
//}}}
}
?>
下一篇里,我将介绍控制器(MVC中的Controller,本文的index.php)的构造。第三篇里,我将介绍表述层(MVC里面的View)。第四篇里,我将用具体模块为例建立一个应用(MVC里面的Module或Model)。
*mold.IfitextendsfrombothFR_ModuleandFR_Auththenitshouldbe
*goodtorun.
*
*@authorJoeStump<joe@joestump.net>
*@static
*@parammixed$module
*@returnbool
*/
publicstaticfunctionisValid($module)
{
return(is_object($module)&&
$moduleinstanceofFR_Module&&
$moduleinstanceofFR_Auth);
}
//}}}
//{{{__destruct()
publicfunction__destruct()
{
parent::__destruct();
}
//}}}
}
?>
presenter.php-表述层的核心。
<?php
classFR_Presenter
{
//{{{factory($type,FR_Module$module)
/**
*factory
*
*@authorJoeStump<joe@joestump.net>
*@accesspublic
*@paramstring$typePresentationtype(ourview)
*@parammixed$moduleOurmodule,whichthepresenterwilldisplay
*@returnmixedPEAR_Erroronfailureoravalidpresenter
*@static
*/
staticpublicfunctionfactory($type,FR_Module$module)
{
$file=FR_BASE_PATH.'/includes/Presenter/'.$type.'.php';
if(include($file)){
$class='FR_Presenter_'.$type;
if(class_exists($class)){
$presenter=new$class($module);
if($presenterinstanceofFR_Presenter_common){
return$presenter;
}
returnPEAR::raiseError('Invalidpresentationclass:'.$type);
}
returnPEAR::raiseError('Presentationclassnotfound:'.$type);
}
returnPEAR::raiseError('Presenterfilenotfound:'.$type);
}
//}}}
}
?>
下一篇里,我将介绍控制器(MVC中的Controller,本文的index.php)的构造。第三篇里,我将介绍表述层(MVC里面的View)。第四篇里,我将用具体模块为例建立一个应用(MVC里面的Module或Model)。
