59 $this->jquery = $controller->jquery;
64 return [
"models" => [
"Models",
"sticky note",
"Used to perform CRUD operations on data." ],
"routes" => [
"Routes",
"car",
"Displays defined routes with annotations" ],
"controllers" => [
"Controllers",
"heartbeat",
"Displays controllers and actions" ],
65 "cache" => [
"Cache",
"lightning",
"Annotations, models, router and controller cache" ],
"rest" => [
"Rest",
"server",
"Restfull web service" ],
"config" => [
"Config",
"settings",
"Configuration variables" ],
"git" => [
"Git",
"github",
"Git versioning" ],
66 "seo" => [
"Seo",
"google",
"Search Engine Optimization" ],
"logs" => [
"Logs",
"bug",
"Log files" ] ];
72 foreach ( $routes as $route ) {
73 $errors = \array_merge ( $errors, $route->getMessages () );
75 if (\
sizeof ( $errors ) > 0) {
76 $messages = $this->controller->showSimpleMessage ( $errors,
"error",
"Error",
"warning" );
78 $dt = $this->jquery->semantic ()->dataTable ( $dtName,
"Ubiquity\controllers\admin\popo\Route", $routes );
79 $dt->setIdentifierFunction (
function ($i, $instance) {
80 return $instance->getId ();
82 $dt->setFields ( [
"path",
"methods",
"controller",
"action",
"cache",
"expired",
"name" ] );
83 $dt->setCaptions ( [
"Path",
"Methods",
"Controller",
"Action & parameters",
"Cache",
"Expired",
"Name",
"" ] );
84 $dt->fieldAsLabel (
"path",
"car" );
89 $dt->onRowClick (
'$("#filter-routes").val($(this).find(".ui.label").text());' );
90 $dt->onPreCompile (
function ($dTable) {
91 $dTable->setColAlignment ( 7, TextAlignment::RIGHT );
92 $dTable->setColAlignment ( 5, TextAlignment::CENTER );
95 $dt->setActiveRowSelector (
"warning" );
96 $dt->wrap ( $messages );
97 $dt->setEdition ()->addClass (
"compact" );
103 $controllers=array_filter($controllers,
function($item) use ($filteredCtrls){
104 return array_search($item->getController(), $filteredCtrls)!==
false;
106 $dt = $this->jquery->semantic ()->dataTable (
"dtControllers",
"Ubiquity\controllers\admin\popo\ControllerAction", $controllers );
107 $dt->setFields ( [
"controller",
"action",
"dValues" ] );
108 $dt->setIdentifierFunction (
function ($i, $instance) {
109 return \urlencode ( $instance->getController () );
111 $dt->setCaptions ( [
"Controller",
"Action [routes]",
"Default values",
"" ] );
113 $dt->setValueFunction (
"controller",
function ($v, $instance, $index) {
114 $bts =
new HtmlButtonGroups (
"bt-" . \urlencode ( $v ), [ $v ] );
115 $bts->addClass (
"basic" );
116 $bt = $bts->getItem ( 0 );
117 $bt->addClass (
"_clickFirst" )->setIdentifier (
"bt-0-" . $v );
118 $bt->addIcon (
"heartbeat",
true,
true );
120 $dd = $bts->addDropdown ( [
"Add new action in <b>{$v}</b>..." ] );
121 $dd->setIcon (
"plus" );
122 $item = $dd->getItem ( 0 );
123 $item->addClass (
"_add-new-action" )->setProperty (
"data-controller", $instance->getController () );
124 $bt->onClick (
"$(\"tr[data-ajax='" . \urlencode ( $instance->getController () ) .
"'] td:not([rowspan])\").toggle(!$(this).hasClass('active'));" );
127 $dt->setValueFunction (
"action",
function ($v, $instance, $index) {
130 $r = new \ReflectionMethod ( $instance->getController (), $action );
131 $lines = file ( $r->getFileName () );
132 $params = $instance->getParameters ();
133 \array_walk ( $params,
function (&$item) {
136 $params =
" (" . \implode (
" , ", $params ) .
")";
137 $v =
new HtmlSemDoubleElement (
"",
"span",
"",
"<b>" . $v .
"</b>" );
138 $v->setProperty (
"style",
"color: #3B83C0;" );
139 $v->addIcon (
"lightning" );
140 $v .=
new HtmlSemDoubleElement (
"",
"span",
"", $params );
141 $annots = $instance->getAnnots ();
142 foreach ( $annots as $path => $annotDetail ) {
143 $lbl =
new HtmlLabel (
"", $path,
"car" );
144 $lbl->setProperty (
"data-ajax", \htmlspecialchars ( ($path) ) );
145 $lbl->addClass (
"_route" );
146 $v .=
" " . $lbl;
148 $v = \array_merge ( [ $v,
"<span class='_views-container'>" ], $this->
getActionViews ( $instance->getController (),
$controller, $action, $r, $lines ) );
152 $dt->onPreCompile (
function ($dt) {
153 $dt->setColAlignment ( 3, TextAlignment::RIGHT );
154 $dt->getHtmlComponent ()->mergeIdentiqualValues ( 0 );
156 $dt->setEdition (
true );
157 $dt->addClass (
"compact" );
163 $list = $this->jquery->semantic ()->htmlList (
"lst-filter" );
164 $list->addCheckedList ( array_combine($controllers,$controllers),
"<i class='heartbeat icon'></i> Controllers", $selecteds,
false,
"filtered-controllers[]" );
171 foreach ( $loadedViews as $view ) {
172 if (\file_exists ( ROOT . DS .
"views" . DS . $view )) {
173 $lbl =
new HtmlLabel (
"lbl-view-" .
$controller . $action . $view, $view,
"browser",
"span" );
174 $lbl->addClass (
"violet" );
175 $lbl->addPopupHtml (
"<i class='icon info circle green'></i> <b>" . $view .
"</b> is ok." );
177 $lbl =
new HtmlLabel (
"lbl-view-" .
$controller . $action . $view, $view,
"warning",
"span" );
178 $lbl->addClass (
"orange" );
179 $lbl->addPopupHtml (
"<i class='icon warning circle'></i> <b>" . $view .
"</b> file is missing." );
184 if (! \file_exists ( ROOT . DS .
"views" . DS . $viewname )) {
185 $bt =
new HtmlButton (
"",
"Create view " . $viewname );
186 $bt->setProperty (
"data-action", $action );
187 $bt->setProperty (
"data-controller",
$controller );
188 $bt->setProperty (
"data-controllerFullname", $controllerFullname );
189 $bt->addClass (
"_create-view visibleover basic violet mini" )->setProperty (
"style",
"visibility: hidden;" )->addIcon (
"plus" );
191 } elseif (\array_search ( $viewname, $loadedViews ) ===
false) {
192 $lbl =
new HtmlLabel (
"lbl-view-" .
$controller . $action . $viewname, $viewname,
"browser",
"span" );
193 $lbl->addPopupHtml (
"<i class='icon warning circle'></i> <b>" . $viewname .
"</b> exists but is never loaded in action <b>" . $action .
"</b>." );
200 $dt->addFieldButtons ( [
"GET",
"POST" ],
true,
function (HtmlButtonGroups $bts, $instance, $index) {
201 $path = $instance->getPath ();
202 $path = \str_replace (
"(.*?)",
"", $path );
203 $path = \str_replace (
"(index/)?",
"", $path );
204 $bts->setIdentifier (
"bts-" . $instance->getId () .
"-" . $index );
205 $bts->getItem ( 0 )->addClass (
"_get" )->setProperty (
"data-url", $path );
206 $bts->getItem ( 1 )->addClass (
"_post" )->setProperty (
"data-url", $path );
207 $item = $bts->addDropdown ( [
"Post with parameters..." ] )->getItem ( 0 );
208 $item->addClass (
"_postWithParams" )->setProperty (
"data-url", $path );
213 $dt = $this->jquery->semantic ()->dataTable (
"dtCacheFiles",
"Ubiquity\controllers\admin\popo\CacheFile", $cacheFiles );
214 $dt->setFields ( [
"type",
"name",
"timestamp",
"size" ] );
215 $dt->setCaptions ( [
"Type",
"Name",
"Timestamp",
"Size",
"" ] );
216 $dt->setValueFunction (
"type",
function ($v, $instance, $index) {
217 $item = $this->jquery->semantic ()->htmlDropdown (
"dd-type-" . $v, $v );
218 $item->addItems ( [
"Delete all",
"(Re-)Init cache" ] );
219 $item->setPropertyValues (
"data-ajax", $v );
220 $item->getItem ( 0 )->addClass (
"_delete-all" );
221 if ($instance->getFile () ===
"")
222 $item->getItem ( 0 )->setDisabled ();
223 $item->getItem ( 1 )->addClass (
"_init" );
224 if ($instance->getType () !==
"Models" && $instance->getType () !==
"Controllers")
225 $item->getItem ( 1 )->setDisabled ();
226 $item->asButton ()->addIcon (
"folder",
true,
true );
229 $dt->addDeleteButton (
true, [ ],
function ($o, $instance) {
230 if ($instance->getFile () ==
"")
232 $type = $instance->getType ();
233 $o->setProperty (
"data-type", $type );
234 $type = \strtolower ( $type );
235 if ($type ==
'models' || $type ==
'controllers') {
236 $o->setProperty (
"data-key", $instance->getName () );
238 $o->setProperty (
"data-key", $instance->getFile () );
241 $dt->setIdentifierFunction (
"getFile" );
242 $dt->setValueFunction (
"timestamp",
function ($v) {
244 return date ( DATE_RFC2822, $v );
246 $dt->setValueFunction (
"size",
function ($v) {
248 return self::formatBytes ( $v );
250 $dt->setValueFunction (
"name",
function ($name, $instance, $i) {
251 if (JString::isNotNull ( $name )) {
252 $link =
new HtmlLink (
"lnl-" . $i );
253 $link->setContent ( $name );
254 $link->addIcon (
"edit" );
255 $link->addClass (
"_lnk" );
256 $link->setProperty (
"data-type", $instance->getType () );
257 $link->setProperty (
"data-ajax", $instance->getFile () );
258 $link->setProperty (
"data-key", $instance->getName () );
262 $dt->onPreCompile (
function ($dt) {
263 $dt->getHtmlComponent ()->mergeIdentiqualValues ( 0 );
265 $this->jquery->postOnClick (
"._lnk", $this->controller->_getAdminFiles ()->getAdminBaseRoute () .
"/_showFileContent",
"{key:$(this).attr('data-key'),type:$(this).attr('data-type'),filename:$(this).attr('data-ajax')}",
"#modal", [
"hasLoader" => false ] );
266 $this->jquery->postFormOnClick (
"._delete", $this->controller->_getAdminFiles ()->getAdminBaseRoute () .
"/deleteCacheFile",
"frmCache",
"#dtCacheFiles tbody", [
"jqueryDone" =>
"replaceWith",
"params" =>
"{type:$(this).attr('data-type'),toDelete:$(this).attr('data-key')}" ] );
267 $this->jquery->postFormOnClick (
"._delete-all", $this->controller->_getAdminFiles ()->getAdminBaseRoute () .
"/deleteAllCacheFiles",
"frmCache",
"#dtCacheFiles tbody", [
"jqueryDone" =>
"replaceWith",
"params" =>
"{type:$(this).attr('data-ajax')}" ] );
268 $this->jquery->postFormOnClick (
"._init", $this->controller->_getAdminFiles ()->getAdminBaseRoute () .
"/initCacheType",
"frmCache",
"#dtCacheFiles tbody", [
"jqueryDone" =>
"replaceWith",
"params" =>
"{type:$(this).attr('data-ajax')}" ] );
273 $de = $this->jquery->semantic ()->dataElement (
"dtStructure", $datas );
274 $fields = \array_keys ( $datas );
275 $de->setFields ( $fields );
276 $de->setCaptions ( $fields );
277 foreach ( $fields as $key ) {
278 $de->setValueFunction ( $key,
function ($value) {
279 if ($value instanceof \stdClass) {
280 $value = ( array ) $value;
282 return \print_r ( $value,
true );
289 $tabs = $this->jquery->semantic ()->htmlTab (
"tabsRest" );
291 foreach ( $datas as
$controller => $restAttributes ) {
293 $list =
new HtmlList (
"attributes", [ [
"heartbeat",
"Controller",
$controller ],[
"car",
"Route",$restAttributes [
"restAttributes"] [
"route"] ] ] );
294 $list->setHorizontal ();
297 $desc = $parser->getDescriptionAsHtml ();
298 if (isset ( $desc )) {
299 $doc =
new HtmlMessage (
"msg-doc-controller-" .
$controller, $desc );
300 $doc->setIcon (
"help blue circle" )->setDismissable ()->addClass (
"transition hidden" );
303 $routes =
Route::init ( $restAttributes [
"routes"] );
305 foreach ( $routes as $route ) {
306 $errors = \array_merge ( $errors, $route->getMessages () );
308 $resource = $restAttributes [
"restAttributes"] [
"resource"];
309 $tab = $tabs->addTab ( $resource, [ $doc,$list,$this->
_getRestRoutesDataTable ( $routes,
"dtRest", $resource, $restAttributes [
"restAttributes"] [
"authorizations"] ) ] );
310 if (\
sizeof ( $errors ) > 0) {
311 $tab->menuTab->addLabel (
"error" )->setColor (
"red" )->addIcon (
"warning sign" );
312 $tab->addContent ( $this->controller->showSimpleMessage ( \array_values ( $errors ),
"error",null,
"warning" ), true );
315 $tab->menuTab->addIcon (
"help circle blue" )->onClick (
"$('#" . $doc->getIdentifier () .
"').transition('horizontal flip');" );
322 $dt = $this->jquery->semantic ()->dataTable ( $dtName,
"Ubiquity\controllers\admin\popo\Route", $routes );
323 $dt->setIdentifierFunction (
function ($i, $instance) {
324 return $instance->getPath ();
326 $dt->setFields ( [
"path",
"methods",
"action",
"cache",
"expired" ] );
327 $dt->setCaptions ( [
"Path",
"Methods",
"Action & Parameters",
"Cache",
"Exp?",
"" ] );
328 $dt->fieldAsLabel (
"path",
"car" );
331 $dt->setValueFunction (
"action",
function ($v, $instance) use ($authorizations) {
333 if (\array_search ( $v, $authorizations ) !==
false) {
334 $auth =
new HtmlIcon (
"lock-" . $instance->getController () . $v,
"lock alternate" );
335 $auth->addPopup (
"Authorization",
"This route require a valid access token" );
338 "<span style=\"color: #3B83C0;\">" . $v .
"</span>" . $instance->getCompiledParams () .
"<i class='ui icon help circle blue hidden transition _showMsgHelp' id='" . JString::cleanIdentifier (
"help-" . $instance->getAction () . $instance->getController () ) .
"' data-show='" . JString::cleanIdentifier (
"msg-help-" . $instance->getAction () . $instance->getController () ) .
"'></i>",
343 $dt->addFieldButton (
"Test",
true,
function ($bt, $instance) use ($resource) {
345 $bt->setProperty (
"data-action", $instance->getAction () )->setProperty (
"data-controller", \urlencode ( $instance->getController () ) );
347 $dt->onPreCompile (
function ($dTable) {
348 $dTable->setColAlignment ( 5, TextAlignment::RIGHT );
349 $dTable->setColAlignment ( 4, TextAlignment::CENTER );
351 $dt->setEdition ()->addClass (
"compact" );
356 $dt->setValueFunction (
"methods",
function ($v) {
359 if (! \is_array ( $v )) {
362 $result =
new HtmlLabelGroups (
"lbls-method", $v, [
"color" =>
"grey" ] );
369 $dt->setValueFunction (
"cache",
function ($v, $instance) {
370 $ck =
new HtmlFormCheckbox (
"ck-" . $instance->getPath (), $instance->getDuration () .
"" );
378 $dt->setValueFunction (
"expired",
function ($v, $instance, $index) {
381 if ($instance->getCache ()) {
382 if (\
sizeof ( $instance->getParameters () ) === 0 || $instance->getParameters () === null)
384 if ($expired ===
false) {
385 $icon =
"hourglass full";
386 } elseif ($expired ===
true) {
387 $icon =
"hourglass empty orange";
392 return new HtmlIcon (
"", $icon );
397 $dt->setValueFunction (
"action",
function ($v, $instance) {
398 $result =
"<span style=\"font-weight: bold;color: #3B83C0;\">" . $v .
"</span>";
399 $result .= $instance->getCompiledParams ();
400 if (! \method_exists ( $instance->getController (), $v )) {
401 $errorLbl =
new HtmlIcon (
"error-" . $v,
"warning sign red" );
402 $errorLbl->addPopup (
"",
"Missing method!" );
403 return [ $result,$errorLbl ];
410 $de = $this->jquery->semantic ()->dataElement (
"deConfig", $config );
411 $fields = \array_keys ( $config );
412 $de->setFields ( $fields );
413 $de->setCaptions ( $fields );
414 $de->setValueFunction (
"database",
function ($v, $instance, $index) {
415 $dbDe =
new DataElement (
"", $v );
416 $dbDe->setFields ( [
"type",
"dbName",
"serverName",
"port",
"user",
"password",
"options",
"cache" ] );
417 $dbDe->setCaptions ( [
"Type",
"dbName",
"serverName",
"port",
"user",
"password",
"options",
"cache" ] );
420 $de->setValueFunction(
"cache",
function ($v, $instance, $index) {
421 $dbDe =
new DataElement (
"", $v );
422 $dbDe->setFields ( [
"directory",
"system",
"params" ] );
423 $dbDe->setCaptions ( [
"directory",
"system",
"params" ] );
426 $de->setValueFunction (
"templateEngineOptions",
function ($v, $instance, $index) {
427 $teoDe =
new DataElement (
"", $v );
428 $teoDe->setFields ( [
"cache" ] );
429 $teoDe->setCaptions ( [
"cache" ] );
430 $teoDe->fieldAsCheckbox (
"cache", [
"class" =>
"ui checkbox slider" ] );
433 $de->setValueFunction (
"mvcNS",
function ($v, $instance, $index) {
434 $mvcDe =
new DataElement (
"", $v );
435 $mvcDe->setFields ( [
"models",
"controllers",
"rest" ] );
436 $mvcDe->setCaptions ( [
"Models",
"Controllers",
"Rest" ] );
439 $de->setValueFunction (
"di",
function ($v, $instance, $index) use ($config) {
440 $diDe =
new DataElement (
"", $v );
441 $keys = \array_keys ( $config [
"di"] );
442 $diDe->setFields ( $keys );
443 foreach ( $keys as $key ) {
444 $diDe->setValueFunction ( $key,
function ($value) use ($config, $key) {
445 $r = $config [
'di'] [$key];
446 if (\is_callable ( $r ))
453 $de->setValueFunction (
"isRest",
function ($v) use ($config) {
454 $r = $config [
"isRest"];
455 if (\is_callable ( $r ))
459 $de->fieldAsCheckbox (
"test", [
"class" =>
"ui checkbox slider" ] );
460 $de->fieldAsCheckbox (
"debug", [
"class" =>
"ui checkbox slider" ] );
465 $bt=(
new HtmlButton($id,$caption))->setToggle($active)->setTagName(
"a");
466 $bt->addIcon(
"caret square down",
false,
true);
474 $input->getField()->labeled($lbl);
479 if($value instanceof \stdClass){
480 $value=(array) $value;
482 if(is_array($value)){
485 $value=str_replace(
'"',
"'", $value);
490 $de = $this->jquery->semantic ()->dataElement (
"frmDeConfig", $config );
491 $keys=array_keys($config);
493 $de->setDefaultValueFunction(
function($name,$value){
496 $input=
new HtmlFormInput($name,null,
"text",$value);
499 $fields = \array_keys ( $config );
500 $de->setFields ( $fields );
501 $de->setCaptions ( $fields );
502 $de->setCaptionCallback(
function(&$captions,$instance) use($keys){
504 $dbBt->on(
"toggled",
'if(!event.active) { 505 var text=$("[name=database-type]").val()+"://"+$("[name=database-user]").val()+":"+$("[name=database-password]").val()+"@"+$("[name=database-serverName]").val()+":"+$("[name=database-port]").val()+"/"+$("[name=database-dbName]").val(); 506 event.caption.html(text); 508 $captions[array_search(
"database", $keys)]=$dbBt;
511 $captions[array_search(
"di", $keys)]=$this->
getCaptionToggleButton(
"di-bt",
"Dependency injection",
"active");
515 $de->setValueFunction (
"database",
function ($v, $instance, $index) {
517 $dbDe =
new DataElement (
"de-database", $v );
518 $dbDe->setDefaultValueFunction(
function($name,$value){
520 $input=
new HtmlFormInput(
"database-".$name,null,
"text",$value);
523 $dbDe->setFields ( [
"type",
"dbName",
"serverName",
"port",
"user",
"password",
"options",
"cache" ] );
524 $dbDe->setCaptions ( [
"Type",
"dbName",
"serverName",
"port",
"user",
"password",
"options",
"cache" ] );
525 $dbDe->fieldAsInput(
"password",[
"inputType"=>
"password",
"name"=>
"database-password"]);
526 $dbDe->fieldAsInput(
"port",[
"name"=>
"database-port",
"inputType"=>
"number",
"jsCallback"=>
function($elm){$elm->getDataField()->setProperty(
"min",0);$elm->getDataField()->setProperty(
"max",3306);}]);
527 $dbDe->fieldAsDropDown(
"type",array_combine($drivers, $drivers),
false,[
"name"=>
"database-type"]);
528 $dbDe->fieldAsInput(
"cache",[
"name"=>
"database-cache",
"jsCallback"=>
function($elm,$object){
529 $ck=$elm->labeledCheckbox();
530 $ck->on(
"click",
'$("[name=database-cache]").prop("disabled",$(this).checkbox("is unchecked"));');
531 if($object->cache!==
false){
532 $ck->setChecked(
true);
535 $dbDe->setValueFunction(
"dbName",
function($value){
536 $input=
new HtmlFormInput(
"database-dbName",null,
"text",$value);
537 $bt=$input->addAction(
"Test");
538 $bt->addClass(
"black");
539 $bt->postFormOnClick($this->controller->_getAdminFiles()->getAdminBaseRoute() .
"/_checkDbStatus",
"frm-frmDeConfig",
"#db-status",[
"jqueryDone"=>
"replaceWith",
"hasLoader"=>
"internal"]);
540 return $this->
labeledInput($input,
'<i id="db-status" class="ui question icon"></i> '.$value);
543 $dbDe->setStyle(
"display: none;");
544 $caption=
"<div class='toggle-caption'>".$v->type.
"://".$v->user.
":".$v->password.
"@".$v->serverName.
":".$v->port.
"/".$v->dbName.
"</div>";
545 return [$dbDe,$caption];
547 $de->setValueFunction(
"cache",
function ($v, $instance, $index) {
548 $dbDe =
new DataElement (
"de-cache", $v );
549 $dbDe->setDefaultValueFunction(
function($name,$value){
551 $input=
new HtmlFormInput(
"cache-".$name,null,
"text",$value);
554 $dbDe->setFields ( [
"directory",
"system",
"params" ] );
555 $dbDe->setCaptions ( [
"directory",
"system",
"params" ] );
556 $dbDe->setStyle(
"display: none;");
559 $de->setValueFunction (
"templateEngineOptions",
function ($v, $instance, $index) {
560 $teoDe =
new DataElement (
"de-template-engine", $v );
561 $teoDe->setFields ( [
"cache" ] );
562 $teoDe->setCaptions ( [
"cache" ] );
563 $teoDe->fieldAsCheckbox (
"cache", [
"class" =>
"ui checkbox slider",
"name"=>
"templateEngineOptions-cache" ] );
566 $de->setValueFunction (
"mvcNS",
function ($v, $instance, $index) {
567 $mvcDe =
new DataElement (
"deMvcNS", $v );
568 $mvcDe->setDefaultValueFunction(
function($name,$value){
return new HtmlFormInput(
"mvcNS-".$name,null,
"text",$value);});
569 $mvcDe->setFields ( [
"models",
"controllers",
"rest" ] );
570 $mvcDe->setCaptions ( [
"Models",
"Controllers",
"Rest" ] );
571 $mvcDe->setStyle(
"display: none;");
575 $de->setValueFunction (
"di",
function ($v, $instance, $index) use ($config) {
576 $diDe =
new DataElement (
"di", $v );
577 $diDe->setDefaultValueFunction(
function($name,$value){
return new HtmlFormInput(
"di-".$name,null,
"text",$value);});
578 $keys = \array_keys ( $config [
"di"] );
579 $diDe->setFields ( $keys );
580 foreach ( $keys as $key ) {
581 $diDe->setValueFunction ( $key,
function ($value) use ($config, $key) {
582 $input=
new HtmlFormTextarea(
"di-".$key);
583 $df=$input->getDataField();
584 $df->setProperty(
"rows",
"5");
585 $df->setProperty(
"data-editor",
"true");
586 $r = $config [
'di'] [$key];
587 if (\is_callable ( $r )){
590 $input->setValue($value);
594 $diDe->onPreCompile (
function () use (&$diDe) {
595 $diDe->getHtmlComponent ()->setColWidth(0, 1);
599 $de->setValueFunction (
"isRest",
function ($v) use ($config) {
600 $r = $config [
"isRest"];
601 $input=
new HtmlFormTextarea(
"isRest");
602 $df=$input->getDataField();
603 $df->setProperty(
"rows",
"3");
604 $df->setProperty(
"data-editor",
"true");
605 if (\is_callable ( $r )){
608 $input->setValue($value);
611 $de->fieldAsCheckbox (
"test", [
"class" =>
"ui checkbox slider" ] );
612 $de->fieldAsCheckbox (
"debug", [
"class" =>
"ui checkbox slider" ] );
615 $("textarea[data-editor]").each(function() { 616 var textarea = $(this); 617 var mode = textarea.data("editor"); 618 var editDiv = $("<div>", { 619 position: "absolute", 621 height: textarea.height(), 622 "class": textarea.attr("class") 623 }).insertBefore(textarea); 624 textarea.css("display", "none"); 625 var editor = ace.edit(editDiv[0]); 626 editDiv.css("border-radius","4px"); 627 editor.$blockScrolling = Infinity ; 628 editor.renderer.setShowGutter(textarea.data("gutter")); 629 editor.getSession().setValue(textarea.val()); 630 editor.getSession().setMode({path:"ace/mode/php", inline:true}); 631 editor.setTheme("ace/theme/solarized_dark"); 632 $("#frm-frmDeConfig").on("ajaxSubmit",function() { 633 textarea.val(editor.getSession().getValue()); 638 $this->jquery->exec($js,
true);
639 $form=$de->getForm();
640 $form->setValidationParams([
"inline"=>
true,
"on"=>
"blur"]);
642 $de->addSubmitInToolbar(
"save-config-btn",
"Save configuration",
"basic inverted",$this->controller->_getAdminFiles()->getAdminBaseRoute().
"/submitConfig/all",
"#action-response");
643 $de->addButtonInToolbar(
"Cancel edition")->onClick(
'$("#config-div").show();$("#action-response").html("");');
644 $de->getToolbar()->setSecondary()->wrap(
'<div class="ui inverted top attached segment">',
'</div>');
647 $form->addExtraFieldRules(
"siteUrl", [
"empty",
"url"]);
648 $form->addExtraFieldRule(
"siteUrl",
"regExp",
"siteUrl must ends with /",
"/^.*?\/$/");
649 $form->addExtraFieldRule(
"database-dbName",
"empty");
650 $form->addExtraFieldRule(
"database-options",
"regExp",
"Expression must be an array",
"/^array\(.*?\)$/");
651 $form->addExtraFieldRule(
"database-options",
"checkArray",
"Expression is not a valid php array");
652 $form->addExtraFieldRule(
"database-cache",
"checkClass[Ubiquity\\cache\\database\\DbCache]",
"Class {value} does not exists or is not a subclass of {ruleValue}");
653 $form->setOptional(
"database-cache");
655 $form->addExtraFieldRule(
"cache-directory",
"checkDirectory[app]",
"{value} directory does not exists");
656 $form->addExtraFieldRule(
"templateEngine",
"checkClass[Ubiquity\\views\\engine\\TemplateEngine]",
"Class {value} does not exists or is not a subclass of {ruleValue}");
657 $form->addExtraFieldRule(
"cache-system",
"checkClass[Ubiquity\\cache\\system\\AbstractDataCache]",
"Class {value} does not exists or is not a subclass of {ruleValue}");
658 $form->addExtraFieldRule(
"cache-params",
"checkArray",
"Expression is not a valid php array");
660 $form->addExtraFieldRule(
"mvcNS-models",
"checkDirectory[app]",
"{value} directory does not exists");
661 $form->addExtraFieldRule(
"mvcNS-controllers",
"checkDirectory[app]",
"{value} directory does not exists");
663 $form->addExtraFieldRule(
"mvcNS-rest",
"checkDirectory[app/".$controllersNS.
"]",
Startup::getNS().
"{value} directory does not exists");
666 $this->jquery->exec(Rule::ajax($this->jquery,
"checkArray", $this->controller->_getAdminFiles()->getAdminBaseRoute() .
"/_checkArray",
"{_value:value}",
"result=data.result;",
"post"),
true);
667 $this->jquery->exec(Rule::ajax($this->jquery,
"checkDirectory", $this->controller->_getAdminFiles()->getAdminBaseRoute() .
"/_checkDirectory",
"{_value:value,_ruleValue:ruleValue}",
"result=data.result;",
"post"),
true);
668 $this->jquery->exec(Rule::ajax($this->jquery,
"checkClass", $this->controller->_getAdminFiles()->getAdminBaseRoute() .
"/_checkClass",
"{_value:value,_ruleValue:ruleValue}",
"result=data.result;",
"post"),
true);
670 return $de->asForm();
674 $base = log ( $size, 1024 );
675 $suffixes = array (
'o',
'Ko',
'Mo',
'Go',
'To' );
676 return round ( pow ( 1024, $base - floor ( $base ) ), $precision ) .
' ' . $suffixes [floor ( $base )];
680 $items = $this->jquery->semantic ()->htmlItems ( $identifier );
682 $items->fromDatabaseObjects ( $array,
function ($e) {
683 $item =
new HtmlItem (
"" );
684 $item->addIcon ( $e [1] .
" bordered circular" )->setSize (
"big" );
685 $item->addItemHeaderContent ( $e [0], [ ], $e [2] );
686 $item->setProperty (
"data-ajax", $e [0] );
689 $items->getOnClick ( $this->controller->_getAdminFiles ()->getAdminBaseRoute (),
"#main-content", [
"attr" =>
"data-ajax",
"historize"=>true ] );
690 return $items->addClass (
"divided relaxed link" );
694 $list = $this->jquery->semantic ()->htmlList (
"dtGitFiles" );
695 $elements = array_map (
function ($element) {
696 return "<i class='" .
GitFileStatus::getIcon ( $element->getStatus () ) .
" icon'></i> " . $element->getName ();
698 $list->addCheckedList ( $elements,
"<i class='file icon'></i> Files", array_keys ( $elements ),
false,
"files-to-commit[]" );
699 $this->jquery->getOnClick (
"#dtGitFiles label[data-value]", $this->controller->_getAdminFiles ()->getAdminBaseRoute () .
"/changesInfiles",
"#changesInFiles-div", [
"attr" =>
"data-value",
"preventDefault" =>
false,
"stopPropagation" => true ] );
705 $dt = $this->jquery->semantic ()->dataTable (
"dtCommits",
"Ubiquity\utils\git\GitCommit", $commits );
706 foreach ( $commits as $commit ) {
707 if (! $commit->getPushed ()) {
712 $dt->setColor (
"green" );
713 $dt->setIdentifierFunction (
"getLHash" );
714 $dt->setFields ( [
"cHash",
"author",
"cDate",
"summary" ] );
715 $dt->setCaptions ( [
"Hash",
"Author",
"Date",
"Summary" ] );
716 $dt->setActiveRowSelector ();
717 $dt->onRowClick ( $this->jquery->getDeferred ( $this->controller->_getAdminFiles ()->getAdminBaseRoute () .
"/changesInCommit",
"#changesInCommit-div", [
"attr" =>
"data-ajax" ] ) );
718 $dt->setValueFunction ( 0,
function ($value, $instance) {
719 if ($instance->getPushed ()) {
720 return "<i class='ui green check square icon'></i>" . $value;
722 return "<i class='ui external square alternate icon'></i>" . $value;
724 $dt->onNewRow (
function ($row, $object) {
725 if ($object->getPushed ())
726 $row->addClass (
"positive" );
728 $this->jquery->exec (
'$("#htmlbuttongroups-push-pull-bts-0").prop("disabled",' . ($notPushed ?
"false" :
"true") .
');',
true );
733 $frm = $this->jquery->semantic ()->dataForm (
"frmGitSettings", $gitRepo );
734 $frm->setFields ( [
"name\n",
"name",
"remoteUrl",
"user",
"password" ] );
735 $frm->setCaptions ( [
" Git repository settings",
"Repository name",
"Remote URL",
"User name",
"password" ] );
736 $frm->fieldAsMessage ( 0, [
"icon" => HtmlIconGroups::corner (
"git",
"settings" ) ] );
737 $frm->setSubmitParams ( $this->controller->_getAdminFiles ()->getAdminBaseRoute () .
"/updateGitParams",
"#main-content" );
738 $frm->fieldAsInput ( 1 );
739 $frm->fieldAsInput ( 3, [
"rules" => [
"empty" ] ] );
740 $frm->fieldAsInput ( 4, [
"inputType" =>
"password" ] );
741 $frm->addDividerBefore (
"user",
"gitHub" );
static getAvailableDrivers()
labeledInput($input, $value)
getControllersDataTable($controllers)
static init($key, $value)
Initialize the key in Session if key does not exists.
static remove($array, $search)
_getRestRoutesDataTable($routes, $dtName, $resource, $authorizations)
static formatBytes($size, $precision=2)
getRoutesDataTable($routes, $dtName="dtRoutes")
getGitCommitsDataTable($commits)
gitFrmSettings(RepositoryGit $gitRepo)
getCacheDataTable($cacheFiles)
getConfigDataElement($config)
getConfigDataForm($config)
__construct(UbiquityMyAdminBaseController $controller)
getCaptionToggleButton($id, $caption, $active="")
getFilterControllers($controllers)
static getNS($part="controllers")
addGetPostButtons(DataTable $dt)
_cleanStdClassValue($value)
getModelsStructureDataTable($datas)
static docClassParser($classname)
_dtExpired(DataTable $dt)
_dtMethods(DataTable $dt)
getGitFilesDataTable($files)
static isExpired($path, $duration)
static closure_dump(\Closure $c)
static cleanClassname($classname)
getMainIndexItems($identifier, $array)
static getLoadedViews(\ReflectionMethod $r, $lines)
getActionViews($controllerFullname, $controller, $action, \ReflectionMethod $r, $lines)
static getClassSimpleName($classnameWithNamespace)
static asPhpArray($array, $prefix="", $depth=1, $format=false)