EGOCMS  24.0
EGOTEC Content-Managament-System
Ego_Request.php
gehe zur Dokumentation dieser Datei
1 <?php
13 class Ego_Request {
19  protected $site = null;
20 
26  protected $page = null;
27 
33  protected $auth = null;
34 
40  protected $smarty = null;
41 
50  public function __construct($site, $page, $auth, &$smarty) {
51  $this->site = $site;
52  $this->page = $page;
53  $this->auth = $auth;
54  $this->smarty = $smarty;
55  $this->smarty->assign(array(
56  'site' => $this->site,
57  'page' => $this->page,
58  'auth' => $this->auth
59  ));
60  }
61 
69  public function __call($function, $params) {
70  $key = 'Json.magic'.md5(serialize(array($function, $this->page->field['type'])));
71  $magic_file = $this->site->getCacheEntry($key);
72  if ($magic_file === null) {
73  $files = array(
74  "{$this->page->field['type']}/json.{$function}.php"
75  );
76  $types = explode('/', $this->page->field['type']);
77  while (array_pop($types)) {
78  if (!empty($types)) {
79  $files[] = implode('/', $types) . "/json.{$function}.php";
80  }
81  }
82  $files[] = "json.{$function}.php";
83  foreach ($files as $file) {
84  if ($found = $this->site->getSiteFile($file)) {
85  $magic_file = $found;
86  $this->site->setCacheEntry($key, $magic_file);
87  break;
88  }
89  }
90 
91  // Auch wenn keine Magic Methode gefunden wurde, das Ergebnis zwischenspeichern
92  if ($magic_file === null) {
93  $this->site->setCacheEntry($key, '');
94  }
95  }
96  if (!file_exists($magic_file)) {
97  throw new BadMethodCallException('Invalid method', 0);
98  }
99  require_once $magic_file;
100  if (!function_exists($function)) {
101  throw new BadMethodCallException('Invalid method', 1);
102  }
103  return call_user_func($function, $this->site, $this->page, $this->auth, $this->smarty, $params);
104  }
105 
111  protected function getError() {
112  return $GLOBALS['return']['error'];
113  }
114 
121  protected function setError($error) {
122  $GLOBALS['return']['error'] = $error;
123  }
124 }
125 ?>
__call($function, $params)
Definition: Ego_Request.php:69
setError($error)
__construct($site, $page, $auth, &$smarty)
Definition: Ego_Request.php:50