当前位置:网站首页>正确处理页面控制器woopagecontroller.php,当提交表单时是否跳转正确的页面
正确处理页面控制器woopagecontroller.php,当提交表单时是否跳转正确的页面
2022-07-30 12:49:00 【cdcdhj】
注册表类文件registry.php
<?php
abstract class woo_base_Registry{
abstract protected function get($key);
abstract protected function set($key,$val);
}
class woo_base_RequestRegistry extends woo_base_Registry{
private $values=array();
private static $instance;
private function __construct(){
}
static function instance(){
if(!isset(self::$instance)){
self::$instance=new self();
}
return self::$instance;
}
protected function set($key,$val){
$this->values[$key]=$val;
}
protected function get($key){
if(isset($this->values[$key])){
return $this->values[$key];
}
return null;
}
static function setRequest(woo_controller_Request $request){
return self::instance()->set('request',$request);
}
static function getRequest(){
return self::instance()->get('request');
}
}
class woo_base_SessionRegistry extends woo_base_Registry{
private static $instance;
private function __construct(){
session_start();
}
static function instance(){
if(!isset(self::$instance)){
self::$instance=new self();
}
return self::$instance;
}
protected function set($key,$val){
$_SESSION[__CLASS__][$key]=$val;
}
protected function get($key){
if(isset($_SESSION[__CLASS__][$key])){
return $_SESSION[__CLASS__][$key];
}
return null;
}
function setComplex(Complex $complex){
self::instance()->set('complex',$complex);
}
function getComplex(){
return self::instance()->get('complex');
}
}
class woo_base_ApplicationRegistry extends woo_base_Registry{
private static $instance;
protected $freezdir="data";
protected $values=array();
protected $mtimes=array();
private $compute,$appcontroller,$map;
private function __construct(){
}
static function instance(){
if(!isset(self::$instance)){
self::$instance=new self();
}
return self::$instance;
}
static function getDsn(){
return self::instance()->get('dsn');
}
static function setDsn($dsn){
self::instance()->set('dsn',$dsn);
}
static function setStatus($status){
self::instance()->set('command',$status);
}
static function getStatus(){
return self::instance()->get('command');
}
static function appController(){
return self::instance()->getAppcontroller();
}
static function getAppcontroller(){
return $this->appcontroller=new woo_controller_AppController();
}
static function setControllerMap($map){
$this->map=$map;
}
static function getControllerMap(){
return $this->map;
}
function getCompute(){
return $this->compute=new applicationRegistry_compute();
}
protected function set($key,$val){
return $this->getCompute()->set($key,$val);
}
protected function get($key){
return $this->getCompute()->get($key);
}
}
class applicationRegistry_compute extends woo_base_ApplicationRegistry{
protected function set($key,$val){
$this->values[$key]=$val;
$path=$this->freezdir . DIRECTORY_SEPARATOR .$key;
file_put_contents($path,serialize($val));
$this->mtimes[$key]=time();
}
protected function get($key){
return $this->getFile($key);
return $this->getVal($key);
return null;
}
function getFile($key){
$path=$this->freezdir . DIRECTORY_SEPARATOR .$key;
if(file_exists($path)){
clearstatcache();
$mtime=filemtime($path);
if(!isset($this->mtimes[$key])){
$this->mtimes[$key]=0;}
if($mtime > $this->mtimes[$key]){
$this->mtimes[$key]=$mtime;
$data=file_get_contents($path);
return ($this->values[$key]=unserialize($data));
}
}
}
function getVal($key){
if(isset($this->values[$key])){
return $this->values[$key];
}
}
}
class woo_controller_Request{
private $properties;
private $feedback=array();
private $command=array();
private $cmd;
function __construct(){
$this->init();
woo_base_RequestRegistry::setRequest($this);
}
function init(){
if(isset($_SERVER['REQUEST_METHOD'])){
$this->properties=$_REQUEST;
return;
}
foreach($_SERVER['argv'] as $arg){
if(strpos($arg,'=')){
list($key,$val)=explode('=',$arg);
$this->setProperty($key,$val);
}
}
}
function setProperty($key,$val){
$this->properties[$key]=$val;
}
function getProperty($key){
if(isset($this->properties[$key])){
return $this->properties[$key];
}
}
function setLastCommand($key){
array_push($this->command,$key);
}
function getLastCommand(){
if(count($this->command)>0){
return end($this->command);
}
}
function setFeedback($msg){
array_push($this->feedback,$msg);
}
function getFeedback(){
return $this->feedback;
}
function getFeedbackString($separator="\n"){
return implode($separator,$this->feedback);
}
function setCommand(woo_command_Command $cmd){
$this->cmd=$cmd;
}
}
/** applicationRegistry_compute::setDsn('8.8.8.8'); echo applicationRegistry_compute::getDsn('dsn'); $controller=new woo_controller_Request(); $controller->setFeedback('这是注册表'); echo $controller->getProperty('a'); print_r(woo_base_RequestRegistry::instance()->getRequest()); **/
?>
第二个文件页面控制器woopagecontroller.php
<?php
require("Registry.php");
require("woodomainvenue.php");
abstract class woo_controller_PageController{
private $request;
function __construct(){
$request=woo_base_RequestRegistry::getRequest();
if(is_null($request)){
$request=new woo_controller_Request();}
$this->request=$request;
}
abstract function process();
function forward($resource){
include($resource);
exit(0);
}
function getRequest(){
return $this->request;
}
}
class woo_controller_AddVenueController extends woo_controller_PageController{
function process(){
try{
$request=$this->getRequest();
$name=$request->getProperty('venue_name');
if(is_null($request->getProperty('submitted'))){
$request->setFeedback("choose a name for the venue");
$this->forward("addvenue.php");
}else if($name==''){
$request->setFeedback("name is a required field");
$this->forward("addvenue.php");
}else{
$venue=new woo_domain_Venue(null,$name);
$this->forward("listvenue.html");
//return $venue;
}
}catch(Exception $e){
$this->forward('error.php');
}
}
}
$controller=new woo_controller_AddVenueController();
$controller->process();
?>
第三个文件addvenue.php文件,在浏览器中访问addvenue.php,当提交给woopagecontroller.php处理时会正确跳转到指定的文件listvenue.html
<html>
<head>
<title>Add Venue</title>
</head>
<body>
<h1>Add Venue</h1>
<table>
<tr>
</td>
</td>
</tr>
</table>
<form action="woopagecontroller.php" method="get">
<input type="submit" name="submitted" value="提交"/>
<input type="text" name="venue_name"/>
</form>
</body>
</html>
边栏推荐
- 腰部外骨骼机器人线性自抗扰控制器参数优化
- 刷屏了!!!
- R语言ggplot2可视化:使用ggpubr包的ggboxplot函数可视化分组箱图、使用ggpar函数改变图形化参数(ylim、修改可视化图像y轴坐标轴数值范围)
- 如何将EasyCVR平台RTSP接入的设备数据迁移到EasyNVR中?
- no matching host key type found. Their offer: ssh-rsa
- CMake库搜索函数居然不搜索LD_LIBRARY_PATH
- 【微信小程序】一文带你搞懂小程序的页面配置和网络数据请求
- 【Kaggle比赛常用trick】K折交叉验证、TTA
- What are the hard-core upgrades and applications that cannot be missed in Greenplum 6.0?
- Greenplum 6.0有哪些不可错过的硬核升级与应用?
猜你喜欢

力扣——11.盛最多水的容器

13-GuliMall 基础篇总结

js 构造函数 return 非空对象,其实例化的对象在原型上的差异

There is no one of the strongest kings in the surveillance world!

Why is Prometheus a monitoring artifact sufficient to replace Zabbix?

Using Baidu EasyDL to realize the recognition of the chef's hat of the bright kitchen

Raja Koduri澄清Arc GPU跳票传闻 AXG年底前新推四条产品线

Go 事,Gopher 要学的数字类型,变量,常量,运算符 ,第2篇

北上广线下活动丨年底最不可错过的技术聚会都齐了

当下,产业园区发展面临的十大问题
随机推荐
维护数千规模MySQL实例,数据库灾备体系构建指南
【河北工业大学】考研初试复试资料分享
湖仓一体电商项目(一):项目背景和架构介绍
R语言筛选时间序列数据的子集(subset time series data)、使用window函数筛选连续日期时间范围内的数据(start参数和end参数分别指定起始和结束时间)
【23考研】408代码题参考模板——顺序表
基于柔性人机接口的人机协调运动控制方法
Mysql batch insert transaction unique key repeated processing
腾讯称电竞人才缺口200万;华为鸿蒙3.0正式发布;乐视推行每周工作4天半?...丨黑马头条...
dolphinscheduler添加hana支持
剑指 Offer 05. 替换空格
New:WebKitX ActiveX :::Crack
R语言向前或者向后移动时间序列数据(自定义滞后或者超前的期数):使用dplyr包中的lag函数将时间序列数据向后移动一天(设置参数n为负值)
重建丢失的数据
R语言ggplot2可视化:使用ggpubr包的ggboxplot函数可视化分组箱图、使用ggpar函数改变图形化参数(ylim、修改可视化图像y轴坐标轴数值范围)
展厅全息投影所具备的三大应用特点
R语言ggplot2可视化:使用ggpubr包的ggboxplot函数可视化箱图、width参数自定义箱图中箱体的宽度
Vivado安装后添加器件库
数字化时代,寻求企业财务转型路径的最优解
腰部外骨骼机器人线性自抗扰控制器参数优化
How to solve the problem that the page does not display the channel configuration after the EasyNVR is updated to (V5.3.0)?