28 protected $messages=[
"error" => [ ],
"info" => [ ] ];
38 abstract protected function showSimpleMessage($content, $type, $icon=
"info", $timeout=NULL, $staticName=null);
52 $result=\ob_get_clean();
53 $message=$this->
showSimpleMessage(
"",
"success",
"check mark", null,
"msg-create-models");
54 $message->addHeader(
"Models creation");
55 $message->addList(\explode(
"\n", \str_replace(
"\n\n",
"\n", \trim($result))));
64 $niveauMax=$this->activeStep - 1;
66 while ( $nbChecked <= $niveauMax && $this->
hasNoError() && isset($steps[$nbChecked]) ) {
70 if ($this->
hasError() && !isset($niveau)) {
71 $this->activeStep=$nbChecked - 1;
72 $this->steps[$this->engineering][$this->activeStep][0]=
"warning sign red";
98 $db=$config[
"database"];
100 $this->
_addErrorMessage(
"warning",
"connection to the database is not established (probably in <b>app/config/services.php</b> file).");
102 if ($db[
"dbName"] !==
"") {
103 $this->
_addInfoMessage($infoIcon,
"Attempt to connect to the database <b>" . $db[
"dbName"] .
"</b> ...");
104 $db=
new Database($db[
"type"], $db[
"dbName"], @$db[
"serverName"], @$db[
"port"], @$db[
"user"], @$db[
"password"], @$db[
"options"], @$db[
"cache"]);
107 }
catch ( \Exception $e ) {
111 $this->
_addInfoMessage($infoIcon,
"The connection to the database <b>" . $db[
"dbName"] .
"</b> is established.");
115 protected function checkModels($config, $infoIcon=
"sticky note") {
117 $modelsNS=@$config[
"mvcNS"][
"models"];
118 $this->
_addInfoMessage($infoIcon,
"Models namespace <b>" . $modelsNS .
"</b> is ok.");
120 if (\file_exists($dir) ===
false) {
121 $this->
_addErrorMessage(
"warning",
"The directory <b>" . $dir .
"</b> does not exists.");
123 $this->
_addInfoMessage($infoIcon,
"The directory for models namespace <b>" . $dir .
"</b> exists.");
125 if (\
sizeof($files) === 0) {
126 $this->
_addErrorMessage(
"warning",
"No file found in <b>" . $dir .
"</b> folder.");
128 foreach ( $files as $file ) {
130 $parts=\explode(
"\\", $completeName);
131 $classname=\array_pop($parts);
132 $ns=\implode(
"\\", $parts);
133 if ($ns !== $modelsNS) {
134 $this->
_addErrorMessage(
"warning",
"The namespace <b>" . $ns .
"</b> would be <b>" . $modelsNS .
"</b> for the class <b>" . $classname .
"</b>.");
136 $this->
_addInfoMessage($infoIcon,
"The namespace for the class <b>" . $classname .
"</b> is ok.");
146 if ($instanceCache === null) {
160 self::missingKeyInConfigMessage(
"Cache directory is not well configured in <b>app/config/config.php</b>", [
"cache" ]);
162 if (!isset($config[
"cache"][
"directory"]) ||
UString::isNull($config[
"cache"][
"directory"])) {
163 self::missingKeyInConfigMessage(
"Cache directory is not well configured in <b>app/config/config.php</b>", [
"directory" ]);
166 $this->
_addInfoMessage($infoIcon,
"Models cache directory is well configured in config file.");
168 if (\file_exists($cacheDir) ===
false) {
169 $this->
_addErrorMessage(
"warning",
"The cache directory <b>" . $cacheDir .
"</b> does not exists.");
172 $this->
_addInfoMessage($infoIcon,
"Cache directory <b>" . $cacheDir .
"</b> exists.");
173 if (\file_exists($modelsCacheDir) ===
false) {
174 $this->
_addErrorMessage(
"warning",
"The models cache directory <b>" . $modelsCacheDir .
"</b> does not exists.");
176 $this->
_addInfoMessage($infoIcon,
"Models cache directory <b>" . $modelsCacheDir .
"</b> exists.");
187 foreach ( $files as $file ) {
190 $this->
_addErrorMessage(
"warning",
"The models cache entry does not exists for the class <b>" . $classname .
"</b>.");
192 $this->
_addInfoMessage($infoIcon,
"The models cache entry for <b>" . $classname .
"</b> exists.");
203 echo $messagesElmInfo;
207 echo $messagesElmError;
213 $buttons=$this->jquery->semantic()->htmlButtonGroups(
"step-actions");
217 $buttons->addItem(
"Show config file")->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/config",
"#action-response")->addIcon(
"settings");
218 $buttons->addItem(
"Edit config file")->addClass(
"orange")->addIcon(
"edit");
222 if ($this->engineering ===
"reverse")
223 $buttons->addItem(
"(Re-)Create database")->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/showDatabaseCreation",
"#main-content")->addIcon(
"database");
226 if ($this->engineering ===
"forward")
227 $buttons->addItem(
"(Re-)Create models")->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/createModels",
"#main-content", [
"attr" =>
"" ])->addIcon(
"sticky note");
229 $buttons->addItem(
"Import from Yuml")->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/_importFromYuml",
"#models-main", [
"attr" =>
"" ])->addIcon(
"sticky note");
231 $bt=$buttons->addItem(
"Classes diagram")->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/_showAllClassesDiagram",
"#action-response", [
"attr" =>
"",
"ajaxTransition" =>
"random" ]);
232 $bt->addIcon(
"sticky note outline");
234 $bt->addClass(
"disabled");
237 $buttons->addItem(
"(Re-)Init models cache")->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/_initModelsCache",
"#main-content")->addIcon(
"lightning");
241 if (isset($nextStep)) {
242 $bt=$buttons->addItem($nextStep[1]);
243 $bt->addIcon(
"angle double right",
false);
244 $bt->addLabel($nextStep[2],
true, $nextStep[0]);
245 $bt->getContent()[1]->addClass(
"green");
247 $bt->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/_loadModelStep/" . $this->engineering .
"/" . ($this->activeStep + 1),
"#models-main");
249 $bt->addClass(
"disabled");
252 $bt=$buttons->addItem(
"See datas")->addClass(
"black");
253 $bt->addIcon(
"unhide");
255 $bt->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/models/noHeader/",
"#models-main");
257 $bt->addClass(
"disabled");
260 echo
"<div>" . $buttons .
"</div><br>";
261 echo
"<div id='action-response'></div>";
265 if (\
sizeof($keys) > 0) {
266 $this->
_addErrorMessage(
"warning", $message .
" : parameters <b>[" . \Ajax\service\JArray::implode(
",", $keys) .
"]</b> are required.");
281 $this->messages[$key][]=
new InfoMessage($type, $content);
285 return \sizeof($this->messages[
"error"]) > 0;
289 return \sizeof($this->messages[
"error"]) == 0;
293 return \sizeof($this->messages[
"info"]) > 0;
297 $messagesElm=$this->jquery->semantic()->htmlMessage(
"modelsMessages-" . $type);
298 $messagesElm->addHeader($header);
299 if ($this->
hasError() && $type ===
"info")
300 $messagesElm->setIcon(
"info circle");
302 $messagesElm->setIcon($icon);
304 foreach ( $messagesToDisplay as $msg ) {
305 $elm=
new HtmlSemDoubleElement(
"",
"li",
"", $msg->getContent());
306 $elm->addIcon($msg->getType());
310 $messagesElm->addClass($type);
_addMessage($key, $type, $content)
_addInfoMessage($type, $content)
createModels($singleTable=null)
static getClassFullNameFromFile($filePathName)
get the full name (name \ namespace) of a class from its file path result example: (string) "I\Am\The...
showSimpleMessage($content, $type, $icon="info", $timeout=NULL, $staticName=null)
checkModelsCacheFiles($config, $infoIcon="lightning")
static modelCacheExists($classname)
_modelCheckOneNiveau($name)
static cleanPathname($path)
static startProd(&$config)
Starts the cache for production.
static getModelsFiles(&$config, $silent=false)
checkDatabase($config, $infoIcon="database")
displayModelsMessages($type, $messagesToDisplay)
This class is responsible for storing Arrays in PHP files.
_addErrorMessage($type, $content)
static isConnected()
Returns true if the connection to the database is estabished.
displayMessages($type, $messagesToDisplay, $header="", $icon="")
checkArrayCache($config, $infoIcon="lightning")
static getCacheDirectories(&$config, $silent=false)
missingKeyInConfigMessage($message, $keys)
static checkModelsConfig()
checkModels($config, $infoIcon="sticky note")
checkModelsCache($config, $infoIcon="lightning")