当前位置:中国站长下载文章中心网页编程PHP编程 → 理解PHP中的MVC编程之MVC框架简介

理解PHP中的MVC编程之MVC框架简介

减小字体 增大字体 作者:编辑整理  来源:互联网  发布时间:2008-9-15 22:05:21
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)。

上一页  [1] [2] [3]