Started work on Address
This commit is contained in:
@@ -6,6 +6,7 @@ include_once(realpath(dirname(__FILE__))."/mfBaseModel.php");
|
||||
class mfBaseController {
|
||||
protected $log;
|
||||
protected $needlogin = false;
|
||||
protected $request;
|
||||
private $mfAction;
|
||||
private $mfDBI;
|
||||
private $mfLayout;
|
||||
@@ -69,6 +70,8 @@ class mfBaseController {
|
||||
include MFBASECONTROLLER_INIT_INCLUDE_FILE;
|
||||
}
|
||||
|
||||
$this->request = new mfRequest($params);
|
||||
|
||||
// now run action
|
||||
if($params['action']) {
|
||||
$this->__call($params['action'],$params);
|
||||
|
||||
@@ -100,6 +100,12 @@ class mfBaseModel {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function update(Array $data) {
|
||||
foreach($data as $key => $value) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function save() {
|
||||
if(method_exists($this, "beforeSave")) {
|
||||
$this->beforeSave();
|
||||
|
||||
@@ -211,3 +211,12 @@ class mfLayout {
|
||||
return $this->inline->cycle[$this->inline->cyclecount++];
|
||||
}
|
||||
}
|
||||
|
||||
function __($string) {
|
||||
$lang = [];
|
||||
include(BASEDIR."/lang/de.php");
|
||||
if(array_key_exists($string, $lang['de'])) {
|
||||
return $lang['de'][$string];
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
class mfRequest {
|
||||
protected static $instance;
|
||||
protected $request = [];
|
||||
|
||||
public function __construct(Array $request = []) {
|
||||
if(count($request)) {
|
||||
$this->request = $request;
|
||||
} else {
|
||||
// get request from POST/GET
|
||||
if(isset($_POST) && isset($_GET)) {
|
||||
$this->request = array_merge($_GET, $_POST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function singleton($request = false) {
|
||||
if(!isset(self::$instance)) {
|
||||
$c=__CLASS__;
|
||||
self::$instance=new $c($request);
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function set($name, $value) {
|
||||
if($name) {
|
||||
$this->request[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function get($name = null) {
|
||||
if($name) {
|
||||
if(array_key_exists($name, $this->request)) {
|
||||
//var_dump($this->request);exit;
|
||||
return $this->request[$name];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
public function __get($name) {
|
||||
return $this->get($name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user