27 protected $messages=[
"error" => [ ],
"info" => [ ] ];
37 abstract protected function showSimpleMessage($content, $type, $icon=
"info", $timeout=NULL, $staticName=null);
51 $result=\ob_get_clean();
52 $message=$this->
showSimpleMessage(
"",
"success",
"check mark", null,
"msg-create-models");
53 $message->addHeader(
"Models creation");
54 $message->addList(\explode(
"\n", \str_replace(
"\n\n",
"\n", \trim($result))));
63 $niveauMax=$this->activeStep - 1;
65 while ( $nbChecked <= $niveauMax && $this->
hasNoError() && isset($steps[$nbChecked]) ) {
69 if ($this->
hasError() && !isset($niveau)) {
70 $this->activeStep=$nbChecked - 1;
71 $this->steps[$this->engineering][$this->activeStep][0]=
"warning sign red";
97 $db=$config[
"database"];
99 $this->
_addErrorMessage(
"warning",
"connection to the database is not established (probably in <b>app/config/services.php</b> file).");
101 if ($db[
"dbName"] !==
"") {
102 $this->
_addInfoMessage($infoIcon,
"Attempt to connect to the database <b>" . $db[
"dbName"] .
"</b> ...");
103 $db=
new Database($db[
"type"], $db[
"dbName"], @$db[
"serverName"], @$db[
"port"], @$db[
"user"], @$db[
"password"], @$db[
"options"], @$db[
"cache"]);
106 }
catch ( \Exception $e ) {
110 $this->
_addInfoMessage($infoIcon,
"The connection to the database <b>" . $db[
"dbName"] .
"</b> is established.");
114 protected function checkModels($config, $infoIcon=
"sticky note") {
116 $modelsNS=@$config[
"mvcNS"][
"models"];
117 $this->
_addInfoMessage($infoIcon,
"Models namespace <b>" . $modelsNS .
"</b> is ok.");
119 if (\file_exists($dir) ===
false) {
120 $this->
_addErrorMessage(
"warning",
"The directory <b>" . $dir .
"</b> does not exists.");
122 $this->
_addInfoMessage($infoIcon,
"The directory for models namespace <b>" . $dir .
"</b> exists.");
124 if (\
sizeof($files) === 0) {
125 $this->
_addErrorMessage(
"warning",
"No file found in <b>" . $dir .
"</b> folder.");
127 foreach ( $files as $file ) {
129 $parts=\explode(
"\\", $completeName);
130 $classname=\array_pop($parts);
131 $ns=\implode(
"\\", $parts);
132 if ($ns !== $modelsNS) {
133 $this->
_addErrorMessage(
"warning",
"The namespace <b>" . $ns .
"</b> would be <b>" . $modelsNS .
"</b> for the class <b>" . $classname .
"</b>.");
135 $this->
_addInfoMessage($infoIcon,
"The namespace for the class <b>" . $classname .
"</b> is ok.");
145 if ($instanceCache === null) {
159 self::missingKeyInConfigMessage(
"Cache directory is not well configured in <b>app/config/config.php</b>", [
"cache" ]);
161 if (!isset($config[
"cache"][
"directory"]) ||
UString::isNull($config[
"cache"][
"directory"])) {
162 self::missingKeyInConfigMessage(
"Cache directory is not well configured in <b>app/config/config.php</b>", [
"directory" ]);
165 $this->
_addInfoMessage($infoIcon,
"Models cache directory is well configured in config file.");
167 if (\file_exists($cacheDir) ===
false) {
168 $this->
_addErrorMessage(
"warning",
"The cache directory <b>" . $cacheDir .
"</b> does not exists.");
171 $this->
_addInfoMessage($infoIcon,
"Cache directory <b>" . $cacheDir .
"</b> exists.");
172 if (\file_exists($modelsCacheDir) ===
false) {
173 $this->
_addErrorMessage(
"warning",
"The models cache directory <b>" . $modelsCacheDir .
"</b> does not exists.");
175 $this->
_addInfoMessage($infoIcon,
"Models cache directory <b>" . $modelsCacheDir .
"</b> exists.");
186 foreach ( $files as $file ) {
189 $this->
_addErrorMessage(
"warning",
"The models cache entry does not exists for the class <b>" . $classname .
"</b>.");
191 $this->
_addInfoMessage($infoIcon,
"The models cache entry for <b>" . $classname .
"</b> exists.");
202 echo $messagesElmInfo;
206 echo $messagesElmError;
212 $buttons=$this->jquery->semantic()->htmlButtonGroups(
"step-actions");
216 $buttons->addItem(
"Show config file")->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/config",
"#action-response")->addIcon(
"settings");
217 $buttons->addItem(
"Edit config file")->addClass(
"orange")->addIcon(
"edit");
221 if ($this->engineering ===
"reverse")
222 $buttons->addItem(
"(Re-)Create database")->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/showDatabaseCreation",
"#main-content")->addIcon(
"database");
225 if ($this->engineering ===
"forward")
226 $buttons->addItem(
"(Re-)Create models")->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/createModels",
"#main-content", [
"attr" =>
"" ])->addIcon(
"sticky note");
228 $buttons->addItem(
"Import from Yuml")->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/_importFromYuml",
"#models-main", [
"attr" =>
"" ])->addIcon(
"sticky note");
230 $bt=$buttons->addItem(
"Classes diagram")->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/_showAllClassesDiagram",
"#action-response", [
"attr" =>
"",
"ajaxTransition" =>
"random" ]);
231 $bt->addIcon(
"sticky note outline");
233 $bt->addClass(
"disabled");
236 $buttons->addItem(
"(Re-)Init models cache")->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/_initModelsCache",
"#main-content")->addIcon(
"lightning");
240 if (isset($nextStep)) {
241 $bt=$buttons->addItem($nextStep[1]);
242 $bt->addIcon(
"angle double right",
false);
243 $bt->addLabel($nextStep[2],
true, $nextStep[0]);
244 $bt->getContent()[1]->addClass(
"green");
246 $bt->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/_loadModelStep/" . $this->engineering .
"/" . ($this->activeStep + 1),
"#models-main");
248 $bt->addClass(
"disabled");
251 $bt=$buttons->addItem(
"See datas")->addClass(
"black");
252 $bt->addIcon(
"unhide");
254 $bt->getOnClick($this->
_getAdminFiles()->getAdminBaseRoute() .
"/models/noHeader/",
"#models-main");
256 $bt->addClass(
"disabled");
259 echo
"<div>" . $buttons .
"</div><br>";
260 echo
"<div id='action-response'></div>";
264 if (\
sizeof($keys) > 0) {
265 $this->
_addErrorMessage(
"warning", $message .
" : parameters <b>[" . \Ajax\service\JArray::implode(
",", $keys) .
"]</b> are required.");
280 $this->messages[$key][]=
new InfoMessage($type, $content);
284 return \sizeof($this->messages[
"error"]) > 0;
288 return \sizeof($this->messages[
"error"]) == 0;
292 return \sizeof($this->messages[
"info"]) > 0;
296 $messagesElm=$this->jquery->semantic()->htmlMessage(
"modelsMessages-" . $type);
297 $messagesElm->addHeader($header);
298 if ($this->
hasError() && $type ===
"info")
299 $messagesElm->setIcon(
"info circle");
301 $messagesElm->setIcon($icon);
303 foreach ( $messagesToDisplay as $msg ) {
304 $elm=
new HtmlSemDoubleElement(
"",
"li",
"", $msg->getContent());
305 $elm->addIcon($msg->getType());
309 $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)
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")