78 ob_start ( array (__class__,
'_error_handler' ) );
80 $semantic = $this->jquery->semantic ();
82 $elements = [
"UbiquityMyAdmin" ];
83 $dataAjax = [
"index" ];
85 foreach ( $mainMenuElements as $elm => $values ) {
87 $dataAjax [] = $values [0];
88 $hrefs[]= $this->
_getAdminFiles()->getAdminBaseRoute().
"/".$values [0];
90 $mn = $semantic->htmlMenu (
"mainMenu", $elements );
91 $mn->getItem ( 0 )->addClass (
"header" )->addIcon (
"home big link" );
92 $mn->setPropertyValues (
"data-ajax", $dataAjax );
93 $mn->setPropertyValues (
"href", $hrefs );
94 $mn->setActiveItem ( 0 );
96 $mn->getOnClick (
"Admin",
"#main-content", [
"attr" =>
"data-ajax",
"historize"=>
true ] );
97 $this->jquery->compile ( $this->view );
103 $e = error_get_last ();
106 $staticName =
"msg-" . rand ( 0, 50 );
107 $message =
new HtmlMessage ( $staticName );
108 $message->addClass (
"error" );
109 $message->addHeader (
"Error" );
110 $message->addList ( [
"<b>Message :</b> " . $e [
'message'],
"<b>File :</b> " . $e [
'file'],
"<b>Line :</b> " . $e [
'line'] ] );
111 $message->setIcon (
"bug" );
112 switch ($e [
'type']) {
117 return str_replace ( $e [
'message'],
"", $buffer ) . $message;
120 return str_replace ( $e [
'message'],
"", $buffer );
134 $js =
'var setAceEditor=function(elementId,readOnly,mode,maxLines){ 135 mode=mode || "sql";readOnly=readOnly || false;maxLines=maxLines || 100; 136 var editor = ace.edit(elementId); 137 editor.setTheme("ace/theme/solarized_dark"); 138 editor.getSession().setMode({path:"ace/mode/"+mode, inline:true}); 142 showInvisibles: true, 143 showGutter: !readOnly, 144 showPrintMargin: false, 146 showLineNumbers: !readOnly, 147 highlightActiveLine: !readOnly, 148 highlightGutterLine: !readOnly 151 return $this->jquery->inline ( $js );
155 $semantic = $this->jquery->semantic ();
157 $this->
_getAdminViewer ()->getMainIndexItems (
"part1", \array_slice ( $array, 0, 4 ) );
158 $this->
_getAdminViewer ()->getMainIndexItems (
"part2", \array_slice ( $array, 4, 4 ) );
159 $this->jquery->compile ( $this->view );
163 public function models($hasHeader =
true) {
164 $semantic = $this->jquery->semantic ();
166 if ($hasHeader ===
true) {
173 $menu = $semantic->htmlMenu (
"menuDbs" );
174 $menu->setVertical ()->setInverted ();
175 foreach ( $dbs as $table ) {
176 $model = $this->
getModelsNS () .
"\\" . ucfirst ( $table );
177 $file = \str_replace (
"\\", DS, ROOT . DS . $model ) .
".php";
181 $item = $menu->addItem ( ucfirst ( $table ) );
182 $item->addLabel ( $count );
184 $item->setProperty (
"data-ajax", $tbl );
187 $menu->getOnClick ( $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/showTable",
"#divTable", [
"attr" =>
"data-ajax" ,
"historize"=>
true] );
188 $menu->onClick (
"$('.ui.label.left.pointing.teal').removeClass('left pointing teal');$(this).find('.ui.label').addClass('left pointing teal');" );
189 }
catch ( \Exception $e ) {
191 $this->
showSimpleMessage (
"Models cache is not created! ",
"error",
"Exception",
"warning circle", null,
"errorMsg" );
193 $this->jquery->compile ( $this->view );
198 echo
"<div id='models-main'>";
201 echo $this->jquery->compile ( $this->view );
209 $controllersDir = ROOT . str_replace (
"\\", DS, $controllersNS );
211 $frm = $this->jquery->semantic ()->htmlForm (
"frmCtrl" );
212 $frm->setValidationParams ( [
"on" =>
"blur",
"inline" =>
true ] );
213 $fields=$frm->addFields();
214 $input = $fields->addInput (
"name", null,
"text",
"",
"Controller name" )->addRules ( [ [
"empty",
"Controller name must have a value" ],
"regExp[/^[A-Za-z]\w*$/]" ] )->setWidth ( 8 );
215 $input->labeledCheckbox ( Direction::LEFT,
"View",
"v",
"slider" );
216 $input->addAction (
"Create controller",
true,
"plus",
true )->addClass (
"teal" )->asSubmit ();
217 $frm->setSubmitParams ( $baseRoute.
"/createController",
"#main-content");
218 $bt=$fields->addDropdown(
"crud-bt", [
"frmAddCrudController"=>
"CRUD controller",
"frmAddAuthController"=>
"Auth controller"],
"Create special controller");
220 $bt->addIcon(
"plus");
221 $this->jquery->getOnClick(
"#dropdown-crud-bt [data-value]",$baseRoute,
"#frm",[
"attr"=>
"data-value"]);
222 $bt=$fields->addButton(
"filter-bt",
"Filter controllers");
223 $bt->getOnClick($baseRoute.
"/frmFilterControllers",
"#frm",[
"attr"=>
""]);
224 $bt->addIcon(
"filter");
226 $this->jquery->compile ( $this->view );
232 $this->jquery->postOnClick (
"._route[data-ajax]", $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/routes",
"{filter:$(this).attr('data-ajax')}",
"#main-content" );
233 $this->jquery->postOnClick (
"._create-view", $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/_createView",
"{action:$(this).attr('data-action'),controller:$(this).attr('data-controller'),controllerFullname:$(this).attr('data-controllerFullname')}",
'$(self).closest("._views-container")', [
234 'hasLoader' =>
false ] );
235 $this->jquery->execAtLast (
"$('#bt-0-controllersAdmin._clickFirst').click();" );
236 $this->jquery->postOnClick (
"._add-new-action", $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/_newActionFrm",
"{controller:$(this).attr('data-controller')}",
"#modal", [
"hasLoader" =>
false ] );
238 if ($refresh ===
"refresh") {
240 echo $this->jquery->compile ( $this->view );
246 $this->
showSimpleMessage (
"Router cache entry is <b>" .
CacheManager::$cache->getEntryKey (
"controllers\\routes.default" ) .
"</b>",
"info",null,
"info circle", null,
"msgRoutes" );
249 $this->jquery->getOnClick (
"#bt-init-cache", $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/initCacheRouter",
"#divRoutes", [
"dataType" =>
"html",
"attr" =>
"" ] );
250 $this->jquery->postOnClick (
"#bt-filter-routes", $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/filterRoutes",
"{filter:$('#filter-routes').val()}",
"#divRoutes", [
"ajaxTransition" =>
"random" ] );
251 if (isset ( $_POST [
"filter"] ))
252 $this->jquery->exec (
"$(\"tr:contains('" . $_POST [
"filter"] .
"')\").addClass('warning');",
true );
254 $this->jquery->compile ( $this->view );
259 $this->jquery->postOnClick (
"._get", $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/_runAction",
"{method:'get',url:$(this).attr('data-url')}",
"#modal", [
"hasLoader" =>
false ] );
260 $this->jquery->postOnClick (
"._post", $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/_runAction",
"{method:'post',url:$(this).attr('data-url')}",
"#modal", [
"hasLoader" =>
false ] );
261 $this->jquery->postOnClick (
"._postWithParams", $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/_runPostWithParams",
"{url:$(this).attr('data-url')}",
"#modal", [
"attr" =>
"",
"hasLoader" =>
false ] );
270 $form = $this->jquery->semantic ()->htmlForm (
"frmCache" );
271 $radios = HtmlFormFields::checkeds (
"cacheTypes[]", [
"controllers" =>
"Controllers",
"models" =>
"Models",
"views" =>
"Views",
"queries" =>
"Queries",
"annotations" =>
"Annotations",
"seo" =>
"SEO" ],
"Display cache types: ", [
"controllers",
"models" ] );
272 $radios->postFormOnClick ( $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/setCacheTypes",
"frmCache",
"#dtCacheFiles tbody", [
"jqueryDone" =>
"replaceWith" ] );
273 $form->addField ( $radios )->setInline ();
275 $this->jquery->compile ( $this->view );
281 $this->
showSimpleMessage (
"Router Rest cache entry is <b>" .
CacheManager::$cache->getEntryKey (
"controllers\\routes.rest" ) .
"</b>",
"info",
"Rest service",
"info circle", null,
"msgRest" );
283 $this->jquery->getOnClick (
"#bt-init-rest-cache", $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/initRestCache",
"#divRest", [
"attr" =>
"",
"dataType" =>
"html" ] );
284 $this->jquery->postOn (
"change",
"#access-token", $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/_saveToken",
"{_token:$(this).val()}" );
286 if (isset ( $_SESSION [
"_token"] )) {
287 $token = $_SESSION [
"_token"];
289 $this->jquery->getOnClick (
"#bt-new-resource", $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/_frmNewResource",
"#div-new-resource", [
"attr" =>
"" ] );
290 $this->jquery->compile ( $this->view );
294 public function config($hasHeader =
true) {
296 if ($hasHeader ===
true)
299 $this->jquery->getOnClick(
"#edit-config-btn", $this->
_getAdminFiles()->getAdminBaseRoute() .
"/formConfig/ajax",
"#action-response",[
"jsCallback"=>
'$("#config-div").hide();']);
300 $this->jquery->compile ( $this->view );
306 $this->jquery->compile ( $this->view );
314 $this->jquery->compile ( $this->view );
320 $dtCtrl = $this->jquery->semantic ()->dataTable (
"seoCtrls",
"Ubiquity\controllers\admin\popo\ControllerSeo", $ctrls );
321 $dtCtrl->setFields ( [
'name',
'urlsFile',
'siteMapTemplate',
'route',
'inRobots',
'see' ] );
322 $dtCtrl->setIdentifierFunction (
'getName' );
323 $dtCtrl->setCaptions ( [
'Controller name',
'Urls file',
'SiteMap template',
'Route',
'In robots?',
'' ] );
324 $dtCtrl->fieldAsLabel (
'route',
'car', [
'jsCallback' =>
function ($lbl, $instance, $i, $index) {
325 if ($instance->getRoute () ==
"") {
326 $lbl->setProperty (
'style',
'display:none;' );
329 $dtCtrl->fieldAsCheckbox (
'inRobots', [
'type' =>
'toggle',
'disabled' =>
true ] );
330 $dtCtrl->setValueFunction (
'see',
function ($value, $instance, $index) {
331 if ($instance->urlExists ()) {
332 $bt =
new HtmlButton (
'see-' . $index,
'',
'_see circular basic right floated' );
333 $bt->setProperty (
"data-ajax", $instance->getName () );
334 $bt->asIcon (
'eye' );
338 $dtCtrl->setValueFunction (
'urlsFile',
function ($value, $instance, $index) {
339 if (! $instance->urlExists ()) {
340 $elm =
new HtmlSemDoubleElement (
'urls-' . $index,
'span',
'', $value );
341 $elm->addIcon (
"warning circle red" );
342 $elm->addPopup (
"Missing", $value .
' is missing!' );
347 $dtCtrl->addDeleteButton (
false, [ ],
function ($bt) {
348 $bt->setProperty (
'class',
'ui circular basic red right floated icon button _delete' );
350 $dtCtrl->setTargetSelector ( [
"delete" =>
"#messages" ] );
351 $dtCtrl->setUrls ( [
"delete" => $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/deleteSeoController" ] );
352 $dtCtrl->getOnRow (
'click', $this->
_getAdminFiles ()->getAdminBaseRoute () .
'/displaySiteMap',
'#seo-details', [
'attr' =>
'data-ajax',
'hasLoader' =>
false ] );
353 $dtCtrl->setHasCheckboxes (
true );
354 $dtCtrl->setSubmitParams ( $this->
_getAdminFiles ()->getAdminBaseRoute () .
'/generateRobots',
"#messages", [
'attr' =>
'',
'ajaxTransition' =>
'random' ] );
355 $dtCtrl->setActiveRowSelector (
'error' );
356 $this->jquery->getOnClick (
"._see", $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/seeSeoUrl",
"#messages", [
"attr" =>
"data-ajax" ] );
357 $this->jquery->execOn (
'click',
'#generateRobots',
'$("#frm-seoCtrls").form("submit");' );
358 $this->jquery->getOnClick (
'#addNewSeo', $this->
_getAdminFiles ()->getAdminBaseRoute () .
'/_newSeoController',
'#seo-details' );
362 public function git($hasMessage =
true) {
363 $loader =
'<div class="ui active inline centered indeterminate text loader">Waiting for git operation...</div>';
370 if (! $gitRepo->getInitialized ()) {
371 $initializeBt = $this->jquery->semantic ()->htmlButton (
"initialize-bt",
"Initialize repository",
"orange" );
372 $initializeBt->addIcon (
"magic" );
373 $initializeBt->getOnClick ( $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/gitInit",
"#main-content", [
"attr" =>
"" ] );
375 $this->
showSimpleMessage (
"<b>{$gitRepo->getName()}</b> respository is not initialized!",
"warning",null,
"warning circle", null,
"init-message" );
378 $this->
showSimpleMessage (
"<b>{$gitRepo->getName()}</b> repository is correctly initialized.",
"info",null,
"info circle", null,
"init-message" );
380 $pushPullBts = $this->jquery->semantic ()->htmlButtonGroups (
"push-pull-bts", [
"3-Push",
"1-Pull" ] );
381 $pushPullBts->addIcons ( [
"upload",
"download" ] );
382 $pushPullBts->setPropertyValues (
"data-ajax", [
"gitPush",
"gitPull" ] );
383 $pushPullBts->addPropertyValues (
"class", [
"blue",
"black" ] );
384 $pushPullBts->getOnClick ( $this->
_getAdminFiles ()->getAdminBaseRoute (),
"#messages", [
"attr" =>
"data-ajax",
"ajaxLoader" => $loader ] );
385 $pushPullBts->setPropertyValues (
"style",
"width: 260px;" );
386 $gitIgnoreBt = $this->jquery->semantic ()->htmlButton (
"gitIgnore-bt",
".gitignore" );
387 $gitIgnoreBt->getOnClick ( $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/gitIgnoreEdit",
"#frm", [
"attr" =>
"" ] );
388 $btRefresh = $this->jquery->semantic ()->htmlButton (
"refresh-bt",
"Refresh files",
"green" );
389 $btRefresh->addIcon (
"sync alternate" );
390 $btRefresh->getOnClick ( $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/refreshFiles",
"#dtGitFiles", [
"attr" =>
"",
"jqueryDone" =>
"replaceWith",
"hasLoader" =>
false ] );
393 $this->jquery->exec (
'$.fn.form.settings.rules.checkeds=function(value){var fields = $("[name=\'files-to-commit[]\']:checked");return fields.length>0;};',
true );
394 $files=$gitRepo->getFiles ();
396 $this->
_getAdminViewer ()->getGitCommitsDataTable ( $gitRepo->getCommits () );
398 $this->jquery->exec(
'$("#lbl-changed").toggle('.((
sizeof($files)>0)?
"true":
"false").
');',
true);
400 $this->jquery->getOnClick (
"#settings-btn", $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/frmSettings",
"#frm" );
401 $this->jquery->exec (
'$("#commit-frm").form({"fields":{"summary":{"rules":[{"type":"empty"}]},"files-to-commit[]":{"rules":[{"type":"checkeds","prompt":"You must select at least 1 file!"}]}},"on":"blur","onSuccess":function(event,fields){' . $this->jquery->postFormDeferred ( $this->_getAdminFiles ()->getAdminBaseRoute () .
"/commit",
"commit-frm",
"#messages", [
402 "preventDefault" =>
true,
"stopPropagation" =>
true,
"ajaxLoader" => $loader ] ) .
';return false;}});',
true );
403 $this->jquery->exec (
'$("#git-tabs .item").tab();',
true );
404 $this->jquery->compile ( $this->view );
405 $this->
loadView ( $this->
_getAdminFiles ()->getViewGitIndex (), [
"repo" => $gitRepo,
"initializeBt" => $initializeBt,
"gitIgnoreBt" => $gitIgnoreBt,
"pushPullBts" => $pushPullBts,
"btRefresh" => $btRefresh ] );
409 $semantic = $this->jquery->semantic ();
410 $header = $semantic->htmlHeader (
"header", 3 );
412 $header->asTitle ( $e [0], $e [2] );
413 $header->addIcon ( $e [1] );
414 $header->setBlock ()->setInverted ();
420 if (isset ( $_POST [
"model"] )) {
421 $model = $_POST [
"model"];
422 $model = \str_replace (
"|",
"\\", $model );
423 $modal = $this->jquery->semantic ()->htmlModal (
"diagram",
"Class diagram : " . $model );
425 $menu = $this->
_diagramMenu (
"/_updateDiagram",
"{model:'" . $_POST [
"model"] .
"',refresh:'true'}",
"#diag-class" );
426 $modal->setContent ( [ $menu,
"<div id='diag-class' class='ui center aligned grid' style='margin:10px;'>",$this->
_getYumlImage (
"plain", $yuml .
"" ),
"</div>" ] );
427 $modal->addAction (
"Close" );
428 $this->jquery->exec (
"$('#diagram').modal('show');",
true );
429 $modal->onHidden (
"$('#diagram').remove();" );
431 echo $this->jquery->compile ( $this->view );
437 if (isset ( $post [
"properties"] )) {
438 $props = \array_flip ( $post [
"properties"] );
439 $yuml =
new ClassToYuml ( $model, isset ( $props [
"displayProperties"] ), isset ( $props [
"displayAssociations"] ), isset ( $props [
"displayMethods"] ), isset ( $props [
"displayMethodsParams"] ), isset ( $props [
"displayPropertiesTypes"] ), isset ( $props [
"displayAssociationClassProperties"] ) );
440 if (isset ( $props [
"displayAssociations"] )) {
441 $yuml->init (
true,
true );
444 $yuml =
new ClassToYuml ( $model, ! isset ( $_POST [
"refresh"] ) );
445 $yuml->init (
true,
true );
451 if (isset ( $post [
"properties"] )) {
452 $props = \array_flip ( $post [
"properties"] );
453 $yuml =
new ClassesToYuml ( isset ( $props [
"displayProperties"] ), isset ( $props [
"displayAssociations"] ), isset ( $props [
"displayMethods"] ), isset ( $props [
"displayMethodsParams"] ), isset ( $props [
"displayPropertiesTypes"] ) );
455 $yuml =
new ClassesToYuml ( ! isset ( $_POST [
"refresh"] ), ! isset ( $_POST [
"refresh"] ) );
462 if (isset ( $_POST [
"model"] )) {
463 $model = $_POST [
"model"];
464 $model = \str_replace (
"|",
"\\", $model );
465 $type = $_POST [
"type"];
466 $size = $_POST [
"size"];
469 echo $this->jquery->compile ( $this->view );
482 private function _diagramMenu($url =
"/_updateDiagram", $params =
"{}", $responseElement =
"#diag-class", $type =
"plain", $size =
";scale:100") {
483 $params = JsUtils::_implodeParams ( [
"$('#frmProperties').serialize()",$params ] );
484 $menu =
new HtmlMenu (
"menu-diagram" );
485 $popup = $menu->addPopupAsItem (
"Display",
"Parameters" );
486 $list =
new HtmlList (
"lst-checked" );
487 $list->addCheckedList ( [
"displayPropertiesTypes" =>
"Types" ], [
"Properties",
"displayProperties" ], [
"displayPropertiesTypes" ],
true,
"properties[]" );
488 $list->addCheckedList ( [
"displayMethodsParams" =>
"Parameters" ], [
"Methods",
"displayMethods" ], [ ],
true,
"properties[]" );
489 $list->addCheckedList ( [
"displayAssociationClassProperties" =>
"Associated class members" ], [
"Associations",
"displayAssociations" ], [
"displayAssociations" ],
true,
"properties[]" );
490 $btApply =
new HtmlButton (
"bt-apply",
"Apply",
"green fluid" );
491 $btApply->postOnClick ( $this->
_getAdminFiles ()->getAdminBaseRoute () . $url, $params, $responseElement, [
"ajaxTransition" =>
"random",
"params" => $params,
"attr" =>
"",
"jsCallback" =>
"$('#Parameters').popup('hide');" ] );
492 $list->addItem ( $btApply );
493 $popup->setContent ( $list );
494 $ddScruffy =
new HtmlDropdown (
"ddScruffy", $type, [
"nofunky" =>
"Boring",
"plain" =>
"Plain",
"scruffy" =>
"Scruffy" ],
true );
495 $ddScruffy->setValue (
"plain" )->asSelect (
"type" );
496 $this->jquery->postOn (
"change",
"#type", $this->
_getAdminFiles ()->getAdminBaseRoute () . $url, $params, $responseElement, [
"ajaxTransition" =>
"random",
"attr" =>
"" ] );
497 $menu->addItem ( $ddScruffy );
498 $ddSize =
new HtmlDropdown (
"ddSize", $size, [
";scale:180" =>
"Huge",
";scale:120" =>
"Big",
";scale:100" =>
"Normal",
";scale:80" =>
"Small",
";scale:60" =>
"Tiny" ],
true );
499 $ddSize->asSelect (
"size" );
500 $this->jquery->postOn (
"change",
"#size", $this->
_getAdminFiles ()->getAdminBaseRoute () . $url, $params, $responseElement, [
"ajaxTransition" =>
"random",
"attr" =>
"" ] );
501 $menu->wrap (
"<form id='frmProperties' name='frmProperties'>",
"</form>" );
502 $menu->addItem ( $ddSize );
508 $menu = $this->
_diagramMenu (
"/_updateAllClassesDiagram",
"{refresh:'true'}",
"#diag-class" );
509 $this->jquery->exec (
'$("#modelsMessages-success").hide()',
true );
510 $menu->compile ( $this->jquery, $this->view );
511 $form = $this->jquery->semantic ()->htmlForm (
"frm-yuml-code" );
512 $textarea = $form->addTextarea (
"yuml-code",
"Yuml code", \str_replace (
",",
",\n", $yumlContent .
"" ) );
513 $textarea->getField ()->setProperty (
"rows", 20 );
515 $this->jquery->execAtLast (
'$("#all-classes-diagram-tab .item").tab();' );
516 $this->jquery->compile ( $this->view );
522 $type = $_POST [
"type"];
523 $size = $_POST [
"size"];
525 $this->jquery->exec (
'$("#yuml-code").html("' . \htmlentities ( $yumlContent .
"" ) .
'")',
true );
527 echo $this->jquery->compile ();
532 return "<img src='http://yuml.me/diagram/" . $sizeType .
"/class/" . $yumlContent .
"'>";
538 $segment = $this->jquery->semantic ()->htmlSegment (
"menu" );
539 $segment->setTagName (
"form" );
540 $header =
new HtmlHeader (
"", 5,
"Database creation" );
541 $header->addIcon (
"plus" );
542 $segment->addContent ( $header );
543 $input =
new HtmlFormInput (
"dbName" );
544 $input->setValue ( $config [
"database"] [
"dbName"] );
545 $input->getField ()->setFluid ();
546 $segment->addContent ( $input );
547 $list =
new HtmlList (
"lst-checked" );
548 $list->addCheckedList ( [
"dbCreation" =>
"Creation",
"dbUse" =>
"Use" ], [
"Database",
"db" ], [
"use",
"creation" ],
false,
"dbProperties[]" );
549 $list->addCheckedList ( $models, [
"Models [tables]",
"modTables" ], \array_keys ( $models ),
false,
"tables[]" );
550 $list->addCheckedList ( [
"manyToOne" =>
"ManyToOne",
"oneToMany" =>
"oneToMany" ], [
"Associations",
"displayAssociations" ], [
"displayAssociations" ],
false,
"associations[]" );
551 $btApply =
new HtmlButton (
"bt-apply",
"Create SQL script",
"green fluid" );
552 $btApply->postFormOnClick ( $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/createSQLScript",
"menu",
"#div-create", [
"ajaxTransition" =>
"random",
"attr" =>
"" ] );
553 $list->addItem ( $btApply );
555 $segment->addContent ( $list );
556 $this->jquery->compile ( $this->view );
564 $url = $_POST [
"url"];
565 if (isset ( $_POST [
"method"] ))
566 $method = $_POST [
"method"];
567 if (isset ( $_POST [
"model"] )) {
568 $model = $_POST [
"model"];
571 if ($origine ===
"routes") {
572 $responseElement =
"#modal";
573 $responseURL =
"/_runAction";
574 $jqueryDone =
"html";
577 $toUpdate = $_POST [
"toUpdate"];
578 $responseElement =
"#" . $toUpdate;
579 $responseURL =
"/_saveRequestParams/" . $type;
580 $jqueryDone =
"replaceWith";
582 if (isset ( $_POST [
"actualParams"] )) {
585 $modal = $this->jquery->semantic ()->htmlModal (
"response-with-params",
"Parameters for the " . \strtoupper ( $method ) .
":" . $url );
586 $frm = $this->jquery->semantic ()->htmlForm (
"frmParams" );
587 $frm->addMessage (
"msg",
"Enter your " . $type .
"s.", \ucfirst ( $method ) .
" " . $type .
"s",
"info circle" );
589 foreach ( $actualParams as $name => $value ) {
594 $fieldsButton = $frm->addFields ();
595 $fieldsButton->addClass (
"_notToClone" );
596 $fieldsButton->addButton (
"clone",
"Add " . $type,
"yellow" )->setTagName (
"div" );
597 if (isset ( $model )) {
600 if (\
sizeof ( $modelFields ) > 0) {
601 $modelFields = \array_combine ( $modelFields, $modelFields );
602 $ddModel = $fieldsButton->addDropdown (
"bt-addModel", $modelFields,
"Add " . $type .
"s from " . $model );
603 $ddModel->asButton ();
604 $this->jquery->click (
"#dropdown-bt-addModel .item",
" 605 var text=$(this).text(); 608 $('#frmParams input[name=\'name[]\']').each(function(){ 609 if($(this).val()==text) count++; 610 if($(this).val()=='') empty=this; 615 var inputs=$('.fields:not(._notToClone)').last().find('input'); 616 inputs.first().val($(this).text()); 618 $(empty).val($(this).text()); 624 if (isset ( $_COOKIE [$method] ) && \
sizeof ( $_COOKIE [$method] ) > 0) {
625 $dd = $fieldsButton->addDropdownButton (
"btMem",
"Memorized " . $type .
"s", $_COOKIE [$method] )->getDropdown ()->setPropertyValues (
"data-mem", \array_map (
"addslashes", $_COOKIE [$method] ) );
626 $cookiesIndex = \array_keys ( $_COOKIE [$method] );
627 $dd->each (
function ($i, $item) use ($cookiesIndex) {
628 $bt =
new HtmlButton (
"bt-" . $item->getIdentifier () );
629 $bt->asIcon (
"remove" )->addClass (
"basic _deleteParam" );
630 $bt->getOnClick ( $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/_deleteCookie", null, [
"attr" =>
"data-value" ] );
631 $bt->setProperty (
"data-value", $cookiesIndex [$i] );
632 $bt->onClick (
"$(this).parents('.item').remove();" );
633 $item->addContent ( $bt,
true );
635 $this->jquery->click (
"[data-mem]",
" 636 var objects=JSON.parse($(this).text()); 637 $.each(objects, function(name, value) { 639 var inputs=$('.fields:not(._notToClone)').last().find('input'); 640 inputs.first().val(name); 641 inputs.last().val(value); 643 $('.fields:not(._notToClone)').each(function(){ 644 var inputs=$(this).find('input'); 645 if(inputs.last().val()=='' && inputs.last().val()=='') 646 if($('.fields').length>2) 651 $this->jquery->click (
"._deleteParameter",
" 652 if($('.fields').length>2) 653 $(this).parents('.fields').remove(); 654 ",
true,
true,
true );
655 $this->jquery->click (
"#clone",
" 656 var cp=$('.fields:not(._notToClone)').last().clone(true); 657 var num = parseInt( cp.prop('id').match(/\d+/g), 10 ) +1; 658 cp.find( '[id]' ).each( function() { 659 var num = $(this).attr('id').replace( /\d+$/, function( strId ) { return parseInt( strId ) + 1; } ); 660 $(this).attr( 'id', num ); 663 cp.insertBefore($('#clone').closest('.fields'));" );
664 $frm->setValidationParams ( [
"on" =>
"blur",
"inline" =>
true ] );
665 $frm->setSubmitParams ( $this->
_getAdminFiles ()->getAdminBaseRoute () . $responseURL, $responseElement, [
"jqueryDone" => $jqueryDone,
"params" =>
"{toUpdate:'" . $toUpdate .
"',method:'" . \strtoupper ( $method ) .
"',url:'" . $url .
"'}" ] );
666 $modal->setContent ( $frm );
667 $modal->addAction (
"Validate" );
668 $this->jquery->click (
"#action-response-with-params-0",
"$('#frmParams').form('submit');",
false,
false,
false );
670 $modal->addAction (
"Close" );
671 $this->jquery->exec (
"$('.dimmer.modals.page').html('');$('#response-with-params').modal('show');",
true );
672 echo $modal->compile ( $this->jquery, $this->view );
673 echo $this->jquery->compile ( $this->view );
680 \parse_str ( urldecode ( $urlEncodedParams ), $params );
681 if (isset ( $params [
"name"] )) {
682 $names = $params [
"name"];
683 $values = $params [
"value"];
684 $count = \sizeof ( $names );
685 for($i = 0; $i < $count; $i ++) {
688 if (isset ( $values [$i] ))
689 $result [$name] = $values [$i];
697 $fields = $frm->addFields ();
698 $fields->addInput (
"name[]", \ucfirst ( $type ) .
" name" )->getDataField ()->setIdentifier (
"name-" . $index )->setProperty (
"value", $name );
699 $input = $fields->addInput (
"value[]", \ucfirst ( $type ) .
" value" );
700 $input->getDataField ()->setIdentifier (
"value-" . $index )->setProperty (
"value", $value );
701 $input->addAction (
"",
true,
"remove" )->addClass (
"icon basic _deleteParameter" );
705 $name = $type .
"[" . $index .
"]";
706 if (isset ( $_COOKIE [$type] [$index] )) {
707 \setcookie ( $name,
"", \time () - 3600,
"/",
"127.0.0.1" );
712 if (isset ( $_COOKIE [$method] )) {
713 $cookieValues = \array_values ( $_COOKIE [$method] );
714 if ((\array_search ( $content, $cookieValues )) ===
false) {
715 if (! isset ( $index ))
716 $index = \sizeof ( $_COOKIE [$method] );
717 setcookie ( $method .
"[" . $index .
"]", $content, \time () + 36000,
"/",
"127.0.0.1" );
720 if (! isset ( $index ))
722 setcookie ( $method .
"[" . $index .
"]", $content, \time () + 36000,
"/",
"127.0.0.1" );
727 setcookie (
"get[" . $index .
"]", $content, \time () + 36000,
"/",
"127.0.0.1" );
733 unset ( $_POST [
"url"] );
734 $method = $_POST [
"method"];
735 unset ( $_POST [
"method"] );
737 $postParams = $_POST;
738 if (\
sizeof ( $_POST ) > 0) {
739 if (\strtoupper ( $method ) ===
"POST" && $frm !==
"frmGetParams") {
741 $keys = $_POST [
"name"];
742 $values = $_POST [
"value"];
743 for($i = 0; $i < \sizeof ( $values ); $i ++) {
744 if (JString::isNotNull ( $keys [$i] ))
745 $postParams [$keys [$i]] = $values [$i];
747 if (\
sizeof ( $postParams ) > 0) {
755 $modal = $this->jquery->semantic ()->htmlModal (
"response", \strtoupper ( $method ) .
":" . $url );
757 if (\
sizeof ( $params ) > 0) {
758 $toPost = \array_merge ( $postParams, [
"method" => $method,
"url" => $url ] );
759 $frm = $this->jquery->semantic ()->htmlForm (
"frmGetParams" );
760 $frm->addMessage (
"msg",
"You must complete the following parameters before continuing navigation testing",
"Required URL parameters",
"info circle" );
762 foreach ( $paramsValues as $param => $value ) {
763 $frm->addInput ( $param, \ucfirst ( $param ) )->addRule (
"empty" )->setValue ( $value );
765 $frm->setValidationParams ( [
"on" =>
"blur",
"inline" =>
true ] );
766 $frm->setSubmitParams ( $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/_runAction",
"#modal", [
"params" => \json_encode ( $toPost ) ] );
767 $modal->setContent ( $frm );
768 $modal->addAction (
"Validate" );
769 $this->jquery->click (
"#action-response-0",
"$('#frmGetParams').form('submit');" );
771 $this->jquery->ajax ( $method, $url,
'#content-response.content', [
"params" => \json_encode ( $postParams ) ] );
773 $modal->addAction (
"Close" );
774 $this->jquery->exec (
"$('.dimmer.modals.page').html('');$('#response').modal('show');",
true );
776 echo $this->jquery->compile ( $this->view );
781 $result = \array_fill_keys ( $params,
"" );
782 if (isset ( $_COOKIE [
"get"] )) {
783 if (isset ( $_COOKIE [
"get"] [$url] )) {
784 $values = \json_decode ( $_COOKIE [
"get"] [$url],
true );
785 foreach ( $params as $p ) {
786 $result [$p] = @$values [$p];
794 $url = stripslashes ( $url );
796 if ($route ===
false) {
798 $u = \explode (
"/", $url );
799 $controller = $ns . $u [0];
800 if (\
sizeof ( $u ) > 1)
804 if (isset ( $newParams ) && \
sizeof ( $newParams ) > 0) {
805 $url = $u [0] .
"/" . $action .
"/" . \implode (
"/", \array_values ( $newParams ) );
809 if (isset ( $newParams ) && \
sizeof ( $newParams ) > 0) {
810 $routeParameters = $route [
"parameters"];
812 foreach ( $newParams as $v ) {
813 if (isset ( $routeParameters [$i] ))
814 $result [( int ) $routeParameters [$i ++]] = $v;
818 $url = vsprintf ( \preg_replace (
'#\([^\)]+\)#',
'%s', $url ), $result );
821 $controller = $route [
"controller"];
822 $action = $route [
"action"];
824 if (\class_exists ( $controller )) {
825 if (\method_exists ( $controller, $action )) {
826 $method = new \ReflectionMethod ( $controller, $action );
827 return \array_map (
function ($e) {
829 }, \array_slice ( $method->getParameters (), 0, $method->getNumberOfRequiredParameters () ) );
835 protected function _createController($controllerName, $variables = [], $ctrlTemplate =
'controller.tpl', $hasView =
false, $jsCallback =
"") {
838 $controllersNS = \rtrim (
Startup::getNS (
"controllers" ),
"\\" );
839 $controllersDir = ROOT . DS . str_replace (
"\\", DS, $controllersNS );
840 $controllerName = \ucfirst ( $controllerName );
841 $filename = $controllersDir . DS . $controllerName .
".php";
842 if (\file_exists ( $filename ) ===
false) {
843 if ($controllersNS !==
"") {
844 $namespace =
"namespace " . $controllersNS .
";";
849 $viewDir = ROOT . DS .
"views" . DS . $controllerName . DS;
851 $viewName = $viewDir . DS .
"index.html";
853 $msgView =
"<br>The default view associated has been created in <b>" .
UFileSystem::cleanPathname ( ROOT . DS . $viewDir ) .
"</b>";
854 $indexContent =
"\$this->loadView(\"" . $controllerName .
"/index.html\");";
856 $variables = \array_merge ( $variables, [
"%controllerName%" => $controllerName,
"%indexContent%" => $indexContent,
"%namespace%" => $namespace ] );
858 $msgContent =
"The <b>" . $controllerName .
"</b> controller has been created in <b>" .
UFileSystem::cleanFilePathname( $filename ) .
"</b>." . $msgView;
859 if (isset ( $variables [
"%path%"] ) && $variables [
"%path%"] !==
"") {
863 $message = $this->
showSimpleMessage ( $msgContent,
"success", null,
"checkmark circle", NULL,
"msgGlobal" );
865 $message = $this->
showSimpleMessage (
"The file <b>" . $filename .
"</b> already exists.<br>Can not create the <b>" . $controllerName .
"</b> controller!",
"warning",null,
"warning circle", 100000,
"msgGlobal" );
871 $msgContent =
"<br>Created route : <b>" . $path .
"</b>";
872 $msgContent .=
"<br>You need to re-init Router cache to apply this update:";
873 $btReinitCache =
new HtmlButton (
"bt-init-cache",
"(Re-)Init router cache",
"orange" );
874 $btReinitCache->addIcon (
"refresh" );
875 $msgContent .=
" " . $btReinitCache;
876 $this->jquery->getOnClick (
"#bt-init-cache", $this->
_getAdminFiles ()->getAdminBaseRoute () .
"/_refreshCacheControllers",
"#messages", [
"attr" =>
"",
"hasLoader" =>
false,
"dataType" =>
"html",
"jsCallback" => $jsCallback ] );
897 if (! isset ( $value )) {
898 $value = $this->$method ();
908 return $this->
getSingleton ( $this->adminData,
"getAdminData" );
915 return $this->
getSingleton($this->adminModelViewer,
"getUbiquityMyAdminModelViewer");
923 return $this->
getSingleton ( $this->adminViewer,
"getUbiquityMyAdminViewer" );
931 return $this->
getSingleton ( $this->adminFiles,
"getUbiquityMyAdminFiles" );
_getParametersFromCookie($url, $params)
getUbiquityMyAdminFiles()
static isPost()
Returns true if the request is sent by the POST method.
The base class for displaying datas in CRUD controllers.
static getModelsName($config, $name)
loadView($viewName, $pData=NULL, $asString=false)
_setPostCookie($content, $method="post", $index=null)
static getRouteInfo($path)
_diagramMenu($url="/_updateDiagram", $params="{}", $responseElement="#diag-class", $type="plain", $size=";scale:100")
_loadModelStep($engineering=null, $newStep=null)
static tryToRequire($file)
_updateAllClassesDiagram()
static cleanFilePathname($path)
static _error_handler($buffer)
_getActualParamsAsArray($urlEncodedParams)
_createController($controllerName, $variables=[], $ctrlTemplate='controller.tpl', $hasView=false, $jsCallback="")
_deleteCookie($index, $type="post")
getUbiquityMyAdminModelViewer()
_refreshRest($refresh=false)
static getNS($part="controllers")
static cleanPathname($path)
Base class for controllers.
getUbiquityMyAdminViewer()
static openReplaceWriteFromTemplateFile($source, $destination, $keyAndValues)
_setGetCookie($index, $content)
static isAjax()
Returns true if the request is an Ajax request.
static count($className, $condition='')
Returns the number of objects of $className from the database respecting the condition possibly passe...
_refreshControllers($refresh=false)
static getTableName($class)
_getYumlImage($sizeType, $yumlContent)
getRequiredRouteParameters(&$url, $newParams=null)
showSimpleMessage($content, $type, $title=null, $icon="info", $timeout=NULL, $staticName=null)
getSingleton($value, $method)
_addMessageForRouteCreation($path, $jsCallback="")
_getClassToYuml($model, $post)
_getInstancesFilter($model)
_addNameValueParamFields($frm, $type, $name, $value, $index)
static addOrRemoveValueFromArray($arrayKey, $value, $add=true)
Adds or removes a value from an array in session.
static getSerializableFields($class)
_runPostWithParams($method="post", $type="parameter", $origine="routes")