1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
<?php
$ptr_sessions = session_start() ;
// -------------------------------------------------------------------------------------------------------------------------------------------------------- //
require_once $_SERVER["DOCUMENT_ROOT"] . "/class/nucleus.php" ;
require_once $_SERVER["DOCUMENT_ROOT"] . "/config/equate.php" ;
// -------------------------------------------------------------------------------------------------------------------------------------------------------- //
class myIterator {
//
==> line 9 private $debug, $start, $end, $curr ;
/**
* Constructor
*
*/
function __construct($start=0,$end=0,$debug=false)
{ $this->debug = $debug = true ; // $ET
$this->start = $start ;
$this->end = $end ;
$this->rewind() ;
if ($this->debug)
user_error("__setScreen[__construct]", E_USER_NOTICE) ;
}
/**
* Destructor
*
*/
function __destruct()
{ }
/**
* Iterator methods
*
*/
function rewind() {
$this->curr = $this->start ;
}
function key() {
return($this->curr) ;
}
function current() {
return(pow($this->curr,2)) ;
}
function next() {
if ($this->valid())
$this->curr++ ;
}
function valid() {
return( ($this->curr <= $this->end) ? true : false ) ;
}
/**
* End of Iterator methods
*
*/
}
class setScreen {
// -------------------------------------------------------------------------------------------------------------------------------------------------------- //
private $debug, $i ;
private $max ;
protected $TBL_screen = array() ;
// -------------------------------------------------------------------------------------------------------------------------------------------------------- //
// 0 1 2 3 4 5 6 7 8
// -------------------------------------------------------------------------------------------------------------------------------------------------------- //
private $const = array( SCREEN , TITLE , SUBTITLE , FORM , MENU , SUBMENU , KLIMSG , MUSTMBER , BOTTOM ) ;
private $must = array( True , True , False , True , True , False , True , True , False ) ;
private $Ok = array() ;
private $iter ;
// -------------------------------------------------------------------------------------------------------------------------------------------------------- //
/**
* Constructor
*
*/
public function __construct($debug=false)
{ $this->debug = $debug ;
$this->max = count($this->must) ;
if ($this->debug)
print("+++++++++++construct[setScreen] starting" . CRLF) ;
$this->iter = new myIterator(0,$this->max) ;
$this->cntMust = 0 ;
for ($i = 0 ; $i < $this->max ; $i++)
{ $this->Ok[$i][NAME ] = $this->const[$i] ;
$this->Ok[$i][MUST ] = $this->must [$i] ;
$this->Ok[$i][SET] = false ;
if ($this->Ok[$i][MUST ])
$this->cntMust++ ;
}
//
// Essai avec Iterator
// ===================
/*
$this->cntMust = 0 ;
while( $this->iter->valid() )
{
$this->iter->next() ;
}
*/
}
/**
* Destructor
*
*/
public function __destruct()
{ if ($this->debug)
print("+++++++++++Destruct[setScreen]" . CRLF) ;
}
/**
* Executor
*
*/
public function execute()
{ if ($this->debug)
print("+++++++++++executing[setScreen] started" . CRLF) ;
try {
if ($this->debug)
print("+++++++++++construct[setScreen] started" . CRLF) ;
if ($this->validate())
{
/**
* Si Ok, on appelle le skeleton
* °°°°°°°°°°°°°°°°°°°°°°°°°°°°°
*/
if ($this->debug)
{ print("Going to Nucleus ......" . CRLF) ;
user_error("Going to Nucleus...." , E_USER_NOTICE) ;
print_r($this->TBL_screen) ; echo CRLF ;
}
/**
* Set some default values...
*
*/
if (!isset($this->TBL_screen[BOTTOM]))
$this->TBL_screen[BOTTOM] = NULL ;
$this->TBL_screen[SITE] = "[Jecrapahute]" ;
//
$this->MasterInst = Nucleus::getInstance($this->TBL_screen, $debug=FALSE ) ;
$this->MasterInst->execute() ;
}
} catch (Exception $E)
{
throw Nucleus::display_exception($E) ;
}
}
/**
* Validation finale, avons-nous tout ce qu'il nous faut ?
*
*/
private function validate()
{ //
// check if one MUST screen property is filled
// MAYBE, both throw EXECPTIONS are redondant!
// -------------------------------------------
$must = 0 ;
for ($i = 0 ; $i < $this->max ; $i++)
{ if ($this->Ok[$i][MUST])
if ($this->Ok[$i][SET])
$must++;
else
throw new EXCEPTION("MUST properpy[".$name."] not set for SCREEN definition") ;
// else
}
if ($must < $this->cntMust)
throw new EXCEPTION("MUST properpy is missing not set for SCREEN definition") ;
return(true) ;
}
/**
* Validation de l'instruction : __setParam
*
*/
public function __setParam($name,$value)
{ //
// check if filled
// check for duplicated
// check if property recognized
// ----------------------------
if (empty($name))
{ throw new EXCEPTION("__setParam ERROR - name of property empty for SCREEN definition") ;
}
else
{ $name = strtoupper($name) ;
for ($i = 0 ; $i < $this->max ; $i++)
{ if ( strcmp( strtoupper($this->Ok[$i][NAME]) , $name ) == 0 )
if ($this->Ok[$i][SET] == true)
throw new EXCEPTION("Duplicated variable[".$name."] for SCREEN definition") ;
else
{ $this->Ok[$i][NAME] = $name ;
$this->Ok[$i][SET] = true ;
$this->Ok[$i][INIT] = $value ;
//
// Construction du tableau associatif à passer au skeleton
// =======================================================
$this->TBL_screen[$name] = $value ;
return ;
}
}
throw new EXCEPTION("__setParam ERROR - name of property not recognized[".$name."] for __setParam function") ;
}
}
}
?> |
Partager