00001 <?php
00002 require_once
TM_PATH . 'constants.php';
00003
00014 class JuelichData {
00015
00016 var
$formVars = array();
00017 var
$appData = array('parameter' => array(),
00018 'l10n' => L_DEUTSCH,
00019 'group0' => '',
00020 'group1' => '',
00021 'group2' => '',
00022 'group3' => '',
00023 'mode' => M_TEXT,
00024 'moduleString' => NULL,
00025 'title' => NULL,
00026 'tplName' => NULL,
00027 'modelIds' => NULL,
00028 'detailId' => NULL,
00029 'module' => '',
00030 'modelSort' => 'p_preis',
00031 'modelName' => NULL,
00032 'dependDetail' =>
false,
00033 'dependId' => NULL,
00034 'mDbData' => array('
short' => array(),
00035 '
long' => array(),
00036 'table' => NULL,
00037 'l10n' =>
false,
00038 'dpExtra' => array(),
00039 'dpTable' => NULL
00040 )
00041 );
00043 function
JuelichData() {
00044 $this->
getFormData();
00045 }
00046
00054 function
getFormVar($key) {
00055
return $this->
getVar($this->formVars, $key);
00056 }
00057
00065 function
getAppData($key) {
00066
return $this->
getVar($this->appData, $key);
00067 }
00068
00076 function &
getAppDataContainer() {
00077
return $this->appData;
00078 }
00079
00087 function
getPathInfo() {
00088
if (empty($_SERVER['PATH_INFO'])) {
00089 include_once
TM_PATH . 'juelich/web/
JuelichError.php';
00090 $error =
new JuelichError;
00091 $error->printError(5, 'PATH_INFO nicht vorhanden.');
00092
exit();
00093 }
00094 $pi = $_SERVER['PATH_INFO'];
00095
$l = strlen($pi);
00096
if (
$l == 1) {
00097 include_once
TM_PATH . 'juelich/web/
JuelichError.php';
00098 $error =
new JuelichError;
00099 $error->printError(5, 'PATH_INFO zu kurz.');
00100
exit();
00101 }
00102
$s = 0;
00103
if($pi[
$l - 1] ==
'/') {
00104 ++
$s;
00105 }
00106
return substr($pi, 1, $l - 1 - $s);
00107 }
00108
00114 function
setModuleDbdata() {
00115
if (empty($this->appData['module'])) {
00116
return;
00117 }
00118 $mData = $this->appData['module']->webData;
00119 $short = array();
00120 $long = array();
00121 foreach ($mData as $d) {
00122 $tmp = explode(
',', str_replace(
' ', '', $d[1]));
00123
if ($d[0]) {
00124 $short = array_merge($
short, $tmp);
00125 $long = array_merge($
long, $tmp);
00126 }
00127
else {
00128 $long = array_merge($
long, $tmp);
00129 }
00130 }
00131 $short = array_unique($
short);
00132 $long = array_unique($
long);
00133 $dp = array();
00134 $dpTable = '';
00135
if ($this->appData['dependDetail']) {
00136 $tmp = array();
00137 $dFields = $this->appData['module']->depend['primaryFields'];
00138 $dpTable = $this->appData['module']->depend['primaryTable'];
00139 $dp = explode(
',', str_replace(
' ', '', $dFields));
00140
$s = count($dp);
00141 foreach ($
long as $l) {
00142
if (!in_array($l, $dp)) {
00143 array_push($tmp, $l);
00144 }
00145 }
00146 $long = $tmp;
00147
for ($i = 0; $i <
$s; ++$i) {
00148 $dp[$i] = $dp[$i] . ' AS prim_' . $dp[$i];
00149 }
00150 }
00151 $this->appData['mDbData']['
short'] = $short;
00152 $this->appData['mDbData']['
long'] = $long;
00153 $this->appData['mDbData']['table'] = $this->appData['module']->table;
00154 $this->appData['mDbData']['l10n'] = $this->appData['module']->l10nData;
00155 $this->appData['mDbData']['dpExtra'] = $dp;
00156 $this->appData['mDbData']['dpTable'] = $dpTable;
00157
return;
00158 }
00159
00167 function
getModuleDbData($field) {
00168
return $this->
getVar($this->appData['mDbData'], $field);
00169 }
00170
00178 function
existsFormVar($key) {
00179
return $this->
existsVar($this->formVars, $key);
00180 }
00181
00187 function
setIndexPageVars() {
00188 $this->appData['module'] =
"index_fake";
00189 $this->appData['mode'] =
M_TEXT;
00190 $this->appData['group0'] =
"text";
00191 $this->appData['title'] =
"Optische und elektronische Geräte Jülich - Bonn - Mikroskope - Ferngläser - Lupen - Spektive Teleskope";
00192 $this->appData['tplName'] =
"text-index";
00193
return;
00194 }
00195
00202 function
setModelName($name) {
00203
if (!empty($name)) {
00204 $pos = strpos($name,
'_', 0);
00205
if ($pos ===
false) {
00206 $this->appData['modelName'] = $name;
00207
return;
00208 }
00209 $name = substr($name, 0, $pos);
00210 $this->appData['modelName'] = $name;
00211 }
00212
return;
00213 }
00214
00221 function
setTitle($title) {
00222
if (!empty($title)) {
00223 $this->appData['title'] = $title;
00224 }
00225 }
00226
00227
# privat
00228
00233 function
getFormData() {
00234
while (list($key, $value) = each($_POST)) {
00235 $this->formVars[$key] = $value;
00236 }
00237
while (list($key, $value) = each($_GET)) {
00238 $this->formVars[$key] = $value;
00239 }
00240 }
00241
00250 function
getVar(&$container, $key) {
00251
if (isset($container[$key])) {
00252
return $container[$key];
00253 }
00254
if (
JUELICH_DEBUG) {
00255 echo
"JuelichData->getVar, Warnung: $key nicht vorhanden.<br>";
00256 }
00257
return '';
00258 }
00259
00268 function
existsVar(&$container, $key) {
00269
if (isset($container[$key])) {
00270
return true;
00271 }
00272
return false;
00273 }
00274
00275 }
00276
00277 ?>