
~~~由于工作原因 近段时间无法持续更新~~请大家见谅~~
index.php引导文件
error_reporting(E_ALL|E_STRICT);
date_default_timezone_set('Asia/Shanghai');
//目录分隔符号
$ds = DIRECTORY_SEPARATOR;
//路径分隔符号
$ps = PATH_SEPARATOR;
$ABS_ROOT_PATH = realpath(dirname(__FILE__));
$REL_ROOT_PATH = substr($_SERVER['PHP_SELF'], 0 , strpos($_SERVER['PHP_SELF'],'/index.php'));
set_include_path('.'.PATH_SEPARATOR.'./library'
.PATH_SEPARATOR.'./application/models/'
.PATH_SEPARATOR.get_include_path());
require('Zend/Loader.php');
//自动加载类
function __autoload($class){
Zend_Loader::loadClass($class);
}
//数据库配置
$dbParams = new Zend_Config_Ini('./config/database.ini','CMSDB');
$db = Zend_Db::factory($dbParams->adapter,$dbParams->toArray());
$db->query("set names {$dbParams->charset};");
Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('db',$db);
//SMARTY配置
$smartyParams = new Zend_Config_Ini('./config/smarty.ini', 'Smarty');
$smarty = new Custom_View_Smarty($smartyParams->toArray());
Zend_Registry::set('smarty',$smarty);
//初始控制器
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setControllerDirectory(array(
'default' => './application/modules/default/controllers',
'admin' => './application/modules/admin/controllers'
));
$frontController->addModuleDirectory('./application/modules');
$frontController->setParam('noViewRenderer',true);
$frontController->setBaseUrl($REL_ROOT_PATH);
try{
$frontController->dispatch();
}catch(Zend_Controller_Dispatcher_Exception $e){
$frontController->getResponse()->setHttpResponseCode(404);
$frontController->getResponse()->__toString();
}
database.ini
[CMSDB]
adapter=pdo_mysql
host=localhost
username=root
password=
dbname=cms
charset=gbk
smarty.ini
[Smarty]
left_delimiter = "{"
right_delimiter = "}"
template_dir = "./www/templates"
compile_dir = "./www/templates_c"
application\modules\default\controllers\IndexController.php
class IndexController extends Zend_Controller_Action
{
public function init()
{
$this->db = Zend_Registry::get('db');
$this->smarty = Zend_Registry::get('smarty');
}
public function indexAction()
{
echo 'Hello from IndexController';
$this->smarty->display('index.html');
}
public function __call($method, $args)
{
if ('Action' == substr($method, -6))
{
// If the action method was not found, forward to the index action
//如果action方法没有找到,则转向到index action
return $this->_forward('index');
}
// all other methods throw an exception
//所有其他的方法则扔出一个错误信息
throw new Exception('Invalid method "' . $method . '" called');
}
public function noRouterAction()
{
$this->_redirect('/');
}
}
application\modules\admin\controllers\IndexController.php
class Admin_IndexController extends Zend_Controller_Action
{
public function init()
{}
public function indexAction()
{
echo 'Hello from Admin_IndexController-indexAction';
}
}
/********************************************************************************************************
感谢ZF MSN群里的 Haohappy,beyond_dream,萧林,Ken,周超,黔驴,phpwb
和phpeye论坛里的wanghaozi,linren119 等等
~~~给我的热心帮助~~谢谢大家~~^*^
版本:ZFRC2
更新日期:2007年6月26日
********************************************************************************************************/
DEMO主要功能~~都是一些常用的 必须的功能哈~~希望大家能用到
简单的数组显示/smarty---SmartyController.php
简单的数据操作/sql-----SqlController.php
综合:验证用户是否可以访问+采用Smarty的视图 + 数据表单(添加、修改、删除)+翻页的操作/form----FormController.php
用户认证操作/auth----AuthController.php
SESSION的一些简单操作/session----SessionController.php

附件下载:更新于20070626~~~
附件下载
版本原因 暂停下载 敬请谅解
版本日志:
0623:这次版本改动很小~~修改了smarty view 添加了auth~~如果有错误请更帖~~我会尽快修正~~谢谢

0626:这次版本添加了一个翻页功能,还添加了一些SESSION的简单操作
[
本帖最后由 mmocom 于 2008-1-2 17:21 编辑 ]