Ubiquity  2.0.3
php rapid development framework
UbiquityMyAdminBaseController.php
Go to the documentation of this file.
1 <?php
2 
4 
24 use Ajax\JsUtils;
49 
56  private $adminData;
57 
62  private $adminViewer;
63 
68  private $adminFiles;
69 
74 
75  private $globalMessage;
76 
77  public function initialize() {
78  ob_start ( array (__class__,'_error_handler' ) );
79  if (URequest::isAjax () === false) {
80  $semantic = $this->jquery->semantic ();
81  $mainMenuElements = $this->_getAdminViewer ()->getMainMenuElements ();
82  $elements = [ "UbiquityMyAdmin" ];
83  $dataAjax = [ "index" ];
84  $hrefs=[$this->_getAdminFiles()->getAdminBaseRoute()."/index"];
85  foreach ( $mainMenuElements as $elm => $values ) {
86  $elements [] = $elm;
87  $dataAjax [] = $values [0];
88  $hrefs[]= $this->_getAdminFiles()->getAdminBaseRoute()."/".$values [0];
89  }
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 );
95  $mn->setSecondary ();
96  $mn->getOnClick ( "Admin", "#main-content", [ "attr" => "data-ajax","historize"=>true ] );
97  $this->jquery->compile ( $this->view );
98  $this->loadView ( $this->_getAdminFiles ()->getViewHeader () );
99  }
100  }
101 
102  public static function _error_handler($buffer) {
103  $e = error_get_last ();
104  if ($e) {
105  if ($e ['file'] != 'xdebug://debug-eval' && !UResponse::isJSON()) {
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']) {
113  case E_ERROR :
114  case E_PARSE :
115  return $message;
116  default :
117  return str_replace ( $e ['message'], "", $buffer ) . $message;
118  }
119  }else{
120  return str_replace ( $e ['message'], "", $buffer );
121  }
122  }
123  return $buffer;
124  }
125 
126  public function finalize() {
127  if (! URequest::isAjax ()) {
128  $this->loadView ( "@framework/Admin/main/vFooter.html", [ "js" => $this->initializeJs () ] );
129  }
130  ob_end_flush ();
131  }
132 
133  protected function initializeJs() {
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});
139  editor.setOptions({
140  maxLines: maxLines,
141  minLines: 2,
142  showInvisibles: true,
143  showGutter: !readOnly,
144  showPrintMargin: false,
145  readOnly: readOnly,
146  showLineNumbers: !readOnly,
147  highlightActiveLine: !readOnly,
148  highlightGutterLine: !readOnly
149  });
150  };';
151  return $this->jquery->inline ( $js );
152  }
153 
154  public function index() {
155  $semantic = $this->jquery->semantic ();
156  $array = $this->_getAdminViewer ()->getMainMenuElements ();
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 );
160  $this->loadView ( $this->_getAdminFiles ()->getViewIndex () );
161  }
162 
163  public function models($hasHeader = true) {
164  $semantic = $this->jquery->semantic ();
165  $header = "";
166  if ($hasHeader === true) {
167  $header = $this->getHeader ( "models" );
168  $stepper = $this->_getModelsStepper ();
169  }
170  if ($this->_isModelsCompleted () || $hasHeader !== true) {
171  try {
172  $dbs = $this->getTableNames ();
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";
178  $find = UFileSystem::tryToRequire ( $file );
179  if ($find) {
180  $count = DAO::count ( $model );
181  $item = $menu->addItem ( ucfirst ( $table ) );
182  $item->addLabel ( $count );
183  $tbl = OrmUtils::getTableName ( $model );
184  $item->setProperty ( "data-ajax", $tbl );
185  }
186  }
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 ) {
190  throw $e;
191  $this->showSimpleMessage ( "Models cache is not created!&nbsp;", "error","Exception", "warning circle", null, "errorMsg" );
192  }
193  $this->jquery->compile ( $this->view );
194  $this->loadView ( $this->_getAdminFiles ()->getViewDataIndex () );
195  } else {
196  echo $header;
197  echo $stepper;
198  echo "<div id='models-main'>";
199  $this->_loadModelStep ();
200  echo "</div>";
201  echo $this->jquery->compile ( $this->view );
202  }
203  }
204 
205  public function controllers() {
206  $baseRoute=$this->_getAdminFiles()->getAdminBaseRoute();
207  $this->getHeader ( "controllers" );
208  $controllersNS = Startup::getNS ( 'controllers' );
209  $controllersDir = ROOT . str_replace ( "\\", DS, $controllersNS );
210  $this->showSimpleMessage ( "Controllers directory is <b>" . UFileSystem::cleanPathname ( $controllersDir ) . "</b>", "info",null, "info circle", null, "msgControllers" );
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");
219  $bt->asButton();
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");
225  $this->_refreshControllers ();
226  $this->jquery->compile ( $this->view );
227  $this->loadView ( $this->_getAdminFiles ()->getViewControllersIndex () );
228  }
229 
230  public function _refreshControllers($refresh = false) {
231  $dt = $this->_getAdminViewer ()->getControllersDataTable ( ControllerAction::init () );
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 ] );
237  $this->addNavigationTesting ();
238  if ($refresh === "refresh") {
239  echo $dt;
240  echo $this->jquery->compile ( $this->view );
241  }
242  }
243 
244  public function routes() {
245  $this->getHeader ( "routes" );
246  $this->showSimpleMessage ( "Router cache entry is <b>" . CacheManager::$cache->getEntryKey ( "controllers\\routes.default" ) . "</b>", "info",null, "info circle", null, "msgRoutes" );
247  $routes = CacheManager::getRoutes ();
248  $this->_getAdminViewer ()->getRoutesDataTable ( Route::init ( $routes ) );
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 );
253  $this->addNavigationTesting ();
254  $this->jquery->compile ( $this->view );
255  $this->loadView ( $this->_getAdminFiles ()->getViewRoutesIndex (), [ "url" => Startup::getConfig () ["siteUrl"] ] );
256  }
257 
258  protected function addNavigationTesting() {
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 ] );
262  }
263 
264  public function cache() {
265  $this->getHeader ( "cache" );
266  $this->showSimpleMessage ( CacheManager::$cache->getCacheInfo (), "info",null, "info circle", null, "msgCache" );
267 
268  $cacheFiles = CacheManager::$cache->getCacheFiles ( 'controllers' );
269  $cacheFiles = \array_merge ( $cacheFiles, CacheManager::$cache->getCacheFiles ( 'models' ) );
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 ();
274  $this->_getAdminViewer ()->getCacheDataTable ( $cacheFiles );
275  $this->jquery->compile ( $this->view );
276  $this->loadView ( $this->_getAdminFiles ()->getViewCacheIndex () );
277  }
278 
279  public function rest() {
280  $this->getHeader ( "rest" );
281  $this->showSimpleMessage ( "Router Rest cache entry is <b>" . CacheManager::$cache->getEntryKey ( "controllers\\routes.rest" ) . "</b>", "info","Rest service", "info circle", null, "msgRest" );
282  $this->_refreshRest ();
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()}" );
285  $token = "";
286  if (isset ( $_SESSION ["_token"] )) {
287  $token = $_SESSION ["_token"];
288  }
289  $this->jquery->getOnClick ( "#bt-new-resource", $this->_getAdminFiles ()->getAdminBaseRoute () . "/_frmNewResource", "#div-new-resource", [ "attr" => "" ] );
290  $this->jquery->compile ( $this->view );
291  $this->loadView ( $this->_getAdminFiles ()->getViewRestIndex (), [ "token" => $token ] );
292  }
293 
294  public function config($hasHeader = true) {
295  $config=Startup::getConfig();
296  if ($hasHeader === true)
297  $this->getHeader ( "config" );
298  $this->_getAdminViewer ()->getConfigDataElement ( $config );
299  $this->jquery->getOnClick("#edit-config-btn", $this->_getAdminFiles()->getAdminBaseRoute() . "/formConfig/ajax","#action-response",["jsCallback"=>'$("#config-div").hide();']);
300  $this->jquery->compile ( $this->view );
301  $this->loadView ( $this->_getAdminFiles ()->getViewConfigIndex () );
302  }
303 
304  public function logs() {
305  $this->getHeader ( "logs" );
306  $this->jquery->compile ( $this->view );
307 
308  $this->loadView ( $this->_getAdminFiles ()->getViewLogsIndex () );
309  }
310 
311  public function seo() {
312  $this->getHeader ( "seo" );
313  $this->_seo ();
314  $this->jquery->compile ( $this->view );
315  $this->loadView ( $this->_getAdminFiles ()->getViewSeoIndex () );
316  }
317 
318  protected function _seo() {
319  $ctrls = ControllerSeo::init ();
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;' );
327  }
328  } ] );
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' );
335  return $bt;
336  }
337  } );
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!' );
343  return $elm;
344  }
345  return $value;
346  } );
347  $dtCtrl->addDeleteButton ( false, [ ], function ($bt) {
348  $bt->setProperty ( 'class', 'ui circular basic red right floated icon button _delete' );
349  } );
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' );
359  return $dtCtrl;
360  }
361 
362  public function git($hasMessage = true) {
363  $loader = '<div class="ui active inline centered indeterminate text loader">Waiting for git operation...</div>';
364  $this->getHeader ( "git" );
365  $gitRepo = $this->_getRepo ();
366  $initializeBt = "";
367  $pushPullBts = "";
368  $gitIgnoreBt = "";
369  $btRefresh = "";
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" => "" ] );
374  if ($hasMessage)
375  $this->showSimpleMessage ( "<b>{$gitRepo->getName()}</b> respository is not initialized!", "warning",null, "warning circle", null, "init-message" );
376  } else {
377  if ($hasMessage) {
378  $this->showSimpleMessage ( "<b>{$gitRepo->getName()}</b> repository is correctly initialized.", "info",null, "info circle", null, "init-message" );
379  }
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 ] );
391  }
392 
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 ();
395  $this->_getAdminViewer ()->getGitFilesDataTable ( $files );
396  $this->_getAdminViewer ()->getGitCommitsDataTable ( $gitRepo->getCommits () );
397 
398  $this->jquery->exec('$("#lbl-changed").toggle('.((sizeof($files)>0)?"true":"false").');',true);
399 
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 ] );
406  }
407 
408  protected function getHeader($key) {
409  $semantic = $this->jquery->semantic ();
410  $header = $semantic->htmlHeader ( "header", 3 );
411  $e = $this->_getAdminViewer ()->getMainMenuElements () [$key];
412  $header->asTitle ( $e [0], $e [2] );
413  $header->addIcon ( $e [1] );
414  $header->setBlock ()->setInverted ();
415  return $header;
416  }
417 
418  public function _showDiagram() {
419  if (URequest::isPost ()) {
420  if (isset ( $_POST ["model"] )) {
421  $model = $_POST ["model"];
422  $model = \str_replace ( "|", "\\", $model );
423  $modal = $this->jquery->semantic ()->htmlModal ( "diagram", "Class diagram : " . $model );
424  $yuml = $this->_getClassToYuml ( $model, $_POST );
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();" );
430  echo $modal;
431  echo $this->jquery->compile ( $this->view );
432  }
433  }
434  }
435 
436  private function _getClassToYuml($model, $post) {
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 );
442  }
443  } else {
444  $yuml = new ClassToYuml ( $model, ! isset ( $_POST ["refresh"] ) );
445  $yuml->init ( true, true );
446  }
447  return $yuml;
448  }
449 
450  private function _getClassesToYuml($post) {
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"] ) );
454  } else {
455  $yuml = new ClassesToYuml ( ! isset ( $_POST ["refresh"] ), ! isset ( $_POST ["refresh"] ) );
456  }
457  return $yuml;
458  }
459 
460  public function _updateDiagram() {
461  if (URequest::isPost ()) {
462  if (isset ( $_POST ["model"] )) {
463  $model = $_POST ["model"];
464  $model = \str_replace ( "|", "\\", $model );
465  $type = $_POST ["type"];
466  $size = $_POST ["size"];
467  $yuml = $this->_getClassToYuml ( $model, $_POST );
468  echo $this->_getYumlImage ( $type . $size, $yuml . "" );
469  echo $this->jquery->compile ( $this->view );
470  }
471  }
472  }
473 
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 );
503  return $menu;
504  }
505 
506  public function _showAllClassesDiagram() {
507  $yumlContent = new ClassesToYuml ();
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 );
514  $diagram = $this->_getYumlImage ( "plain", $yumlContent );
515  $this->jquery->execAtLast ( '$("#all-classes-diagram-tab .item").tab();' );
516  $this->jquery->compile ( $this->view );
517  $this->loadView ( $this->_getAdminFiles ()->getViewClassesDiagram (), [ "diagram" => $diagram ] );
518  }
519 
520  public function _updateAllClassesDiagram() {
521  if (URequest::isPost ()) {
522  $type = $_POST ["type"];
523  $size = $_POST ["size"];
524  $yumlContent = $this->_getClassesToYuml ( $_POST );
525  $this->jquery->exec ( '$("#yuml-code").html("' . \htmlentities ( $yumlContent . "" ) . '")', true );
526  echo $this->_getYumlImage ( $type . $size, $yumlContent );
527  echo $this->jquery->compile ();
528  }
529  }
530 
531  protected function _getYumlImage($sizeType, $yumlContent) {
532  return "<img src='http://yuml.me/diagram/" . $sizeType . "/class/" . $yumlContent . "'>";
533  }
534 
535  public function showDatabaseCreation() {
536  $config = Startup::getConfig ();
537  $models = $this->getModels ();
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 );
554 
555  $segment->addContent ( $list );
556  $this->jquery->compile ( $this->view );
557  $this->loadView ( $this->_getAdminFiles ()->getViewDatabaseIndex () );
558  }
559 
560  public function _runPostWithParams($method = "post", $type = "parameter", $origine = "routes") {
561  if (URequest::isPost ()) {
562  $model = null;
563  $actualParams = [ ];
564  $url = $_POST ["url"];
565  if (isset ( $_POST ["method"] ))
566  $method = $_POST ["method"];
567  if (isset ( $_POST ["model"] )) {
568  $model = $_POST ["model"];
569  }
570 
571  if ($origine === "routes") {
572  $responseElement = "#modal";
573  $responseURL = "/_runAction";
574  $jqueryDone = "html";
575  $toUpdate = "";
576  } else {
577  $toUpdate = $_POST ["toUpdate"];
578  $responseElement = "#" . $toUpdate;
579  $responseURL = "/_saveRequestParams/" . $type;
580  $jqueryDone = "replaceWith";
581  }
582  if (isset ( $_POST ["actualParams"] )) {
583  $actualParams = $this->_getActualParamsAsArray ( $_POST ["actualParams"] );
584  }
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" );
588  $index = 0;
589  foreach ( $actualParams as $name => $value ) {
590  $this->_addNameValueParamFields ( $frm, $type, $name, $value, $index ++ );
591  }
592  $this->_addNameValueParamFields ( $frm, $type, "", "", $index ++ );
593 
594  $fieldsButton = $frm->addFields ();
595  $fieldsButton->addClass ( "_notToClone" );
596  $fieldsButton->addButton ( "clone", "Add " . $type, "yellow" )->setTagName ( "div" );
597  if (isset ( $model )) {
598  $model = UbiquityUtils::getModelsName ( Startup::getConfig (), $model );
599  $modelFields = OrmUtils::getSerializableFields ( $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();
606  var count=0;
607  var empty=null;
608  $('#frmParams input[name=\'name[]\']').each(function(){
609  if($(this).val()==text) count++;
610  if($(this).val()=='') empty=this;
611  });
612  if(count<1){
613  if(empty==null){
614  $('#clone').click();
615  var inputs=$('.fields:not(._notToClone)').last().find('input');
616  inputs.first().val($(this).text());
617  }else{
618  $(empty).val($(this).text());
619  }
620  }
621  " );
622  }
623  }
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 );
634  } );
635  $this->jquery->click ( "[data-mem]", "
636  var objects=JSON.parse($(this).text());
637  $.each(objects, function(name, value) {
638  $('#clone').click();
639  var inputs=$('.fields:not(._notToClone)').last().find('input');
640  inputs.first().val(name);
641  inputs.last().val(value);
642  });
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)
647  $(this).remove();
648  });
649  " );
650  }
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 );
661  $(this).val('');
662  });
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 );
669 
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 );
674  }
675  }
676 
677  protected function _getActualParamsAsArray($urlEncodedParams) {
678  $result = [ ];
679  $params = [ ];
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 ++) {
686  $name = $names [$i];
687  if (UString::isNotNull ( $name )) {
688  if (isset ( $values [$i] ))
689  $result [$name] = $values [$i];
690  }
691  }
692  }
693  return $result;
694  }
695 
696  protected function _addNameValueParamFields($frm, $type, $name, $value, $index) {
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" );
702  }
703 
704  public function _deleteCookie($index, $type = "post") {
705  $name = $type . "[" . $index . "]";
706  if (isset ( $_COOKIE [$type] [$index] )) {
707  \setcookie ( $name, "", \time () - 3600, "/", "127.0.0.1" );
708  }
709  }
710 
711  private function _setPostCookie($content, $method = "post", $index = null) {
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" );
718  }
719  } else {
720  if (! isset ( $index ))
721  $index = 0;
722  setcookie ( $method . "[" . $index . "]", $content, \time () + 36000, "/", "127.0.0.1" );
723  }
724  }
725 
726  private function _setGetCookie($index, $content) {
727  setcookie ( "get[" . $index . "]", $content, \time () + 36000, "/", "127.0.0.1" );
728  }
729 
730  public function _runAction($frm = null) {
731  if (URequest::isPost ()) {
732  $url = URequest::cleanUrl ( $_POST ["url"] );
733  unset ( $_POST ["url"] );
734  $method = $_POST ["method"];
735  unset ( $_POST ["method"] );
736  $newParams = null;
737  $postParams = $_POST;
738  if (\sizeof ( $_POST ) > 0) {
739  if (\strtoupper ( $method ) === "POST" && $frm !== "frmGetParams") {
740  $postParams = [ ];
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];
746  }
747  if (\sizeof ( $postParams ) > 0) {
748  $this->_setPostCookie ( \json_encode ( $postParams ) );
749  }
750  } else {
751  $newParams = $_POST;
752  $this->_setGetCookie ( $url, \json_encode ( $newParams ) );
753  }
754  }
755  $modal = $this->jquery->semantic ()->htmlModal ( "response", \strtoupper ( $method ) . ":" . $url );
756  $params = $this->getRequiredRouteParameters ( $url, $newParams );
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" );
761  $paramsValues = $this->_getParametersFromCookie ( $url, $params );
762  foreach ( $paramsValues as $param => $value ) {
763  $frm->addInput ( $param, \ucfirst ( $param ) )->addRule ( "empty" )->setValue ( $value );
764  }
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');" );
770  } else {
771  $this->jquery->ajax ( $method, $url, '#content-response.content', [ "params" => \json_encode ( $postParams ) ] );
772  }
773  $modal->addAction ( "Close" );
774  $this->jquery->exec ( "$('.dimmer.modals.page').html('');$('#response').modal('show');", true );
775  echo $modal;
776  echo $this->jquery->compile ( $this->view );
777  }
778  }
779 
780  private function _getParametersFromCookie($url, $params) {
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];
787  }
788  }
789  }
790  return $result;
791  }
792 
793  private function getRequiredRouteParameters(&$url, $newParams = null) {
794  $url = stripslashes ( $url );
795  $route = Router::getRouteInfo ( $url );
796  if ($route === false) {
797  $ns = Startup::getNS ();
798  $u = \explode ( "/", $url );
799  $controller = $ns . $u [0];
800  if (\sizeof ( $u ) > 1)
801  $action = $u [1];
802  else
803  $action = "index";
804  if (isset ( $newParams ) && \sizeof ( $newParams ) > 0) {
805  $url = $u [0] . "/" . $action . "/" . \implode ( "/", \array_values ( $newParams ) );
806  return [ ];
807  }
808  } else {
809  if (isset ( $newParams ) && \sizeof ( $newParams ) > 0) {
810  $routeParameters = $route ["parameters"];
811  $i = 0;
812  foreach ( $newParams as $v ) {
813  if (isset ( $routeParameters [$i] ))
814  $result [( int ) $routeParameters [$i ++]] = $v;
815  }
816  ksort ( $result );
817 
818  $url = vsprintf ( \preg_replace ( '#\([^\)]+\)#', '%s', $url ), $result );
819  return [ ];
820  }
821  $controller = $route ["controller"];
822  $action = $route ["action"];
823  }
824  if (\class_exists ( $controller )) {
825  if (\method_exists ( $controller, $action )) {
826  $method = new \ReflectionMethod ( $controller, $action );
827  return \array_map ( function ($e) {
828  return $e->name;
829  }, \array_slice ( $method->getParameters (), 0, $method->getNumberOfRequiredParameters () ) );
830  }
831  }
832  return [ ];
833  }
834 
835  protected function _createController($controllerName, $variables = [], $ctrlTemplate = 'controller.tpl', $hasView = false, $jsCallback = "") {
836  $message = "";
837  $frameworkDir = Startup::getFrameworkDir ();
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 . ";";
845  }
846  $msgView = "";
847  $indexContent = "";
848  if ($hasView) {
849  $viewDir = ROOT . DS . "views" . DS . $controllerName . DS;
850  UFileSystem::safeMkdir ( $viewDir );
851  $viewName = $viewDir . DS . "index.html";
852  UFileSystem::openReplaceWriteFromTemplateFile ( $frameworkDir . "/admin/templates/view.tpl", $viewName, [ "%controllerName%" => $controllerName,"%actionName%" => "index" ] );
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\");";
855  }
856  $variables = \array_merge ( $variables, [ "%controllerName%" => $controllerName,"%indexContent%" => $indexContent,"%namespace%" => $namespace ] );
857  UFileSystem::openReplaceWriteFromTemplateFile ( $frameworkDir . "/admin/templates/" . $ctrlTemplate, $filename, $variables );
858  $msgContent = "The <b>" . $controllerName . "</b> controller has been created in <b>" . UFileSystem::cleanFilePathname( $filename ) . "</b>." . $msgView;
859  if (isset ( $variables ["%path%"] ) && $variables ["%path%"] !== "") {
860  $msgContent .= $this->_addMessageForRouteCreation ( $variables ["%path%"], $jsCallback );
861  }
862  USession::addOrRemoveValueFromArray("filtered-controllers",$controllersNS."\\".$controllerName);
863  $message = $this->showSimpleMessage ( $msgContent, "success", null,"checkmark circle", NULL, "msgGlobal" );
864  } else {
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" );
866  }
867  return $message;
868  }
869 
870  protected function _addMessageForRouteCreation($path, $jsCallback = "") {
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 .= "&nbsp;" . $btReinitCache;
876  $this->jquery->getOnClick ( "#bt-init-cache", $this->_getAdminFiles ()->getAdminBaseRoute () . "/_refreshCacheControllers", "#messages", [ "attr" => "","hasLoader" => false,"dataType" => "html","jsCallback" => $jsCallback ] );
877  return $msgContent;
878  }
879 
880  protected function getAdminData() {
881  return new CRUDDatas();
882  }
883 
884  protected function getUbiquityMyAdminViewer() {
885  return new UbiquityMyAdminViewer ( $this );
886  }
887 
888  protected function getUbiquityMyAdminModelViewer() {
889  return new ModelViewer( $this );
890  }
891 
892  protected function getUbiquityMyAdminFiles() {
893  return new UbiquityMyAdminFiles ();
894  }
895 
896  private function getSingleton($value, $method) {
897  if (! isset ( $value )) {
898  $value = $this->$method ();
899  }
900  return $value;
901  }
902 
907  public function _getAdminData():CRUDDatas {
908  return $this->getSingleton ( $this->adminData, "getAdminData" );
909  }
910 
914  public function _getModelViewer(){
915  return $this->getSingleton($this->adminModelViewer, "getUbiquityMyAdminModelViewer");
916  }
917 
922  public function _getAdminViewer() {
923  return $this->getSingleton ( $this->adminViewer, "getUbiquityMyAdminViewer" );
924  }
925 
930  public function _getAdminFiles() {
931  return $this->getSingleton ( $this->adminFiles, "getUbiquityMyAdminFiles" );
932  }
933 
934  protected function getTableNames() {
935  return $this->_getAdminData ()->getTableNames ();
936  }
937 
938  public function _getBaseRoute(){
939  return $this->_getAdminFiles ()->getAdminBaseRoute ();
940  }
941  public function _getInstancesFilter($model) {
942  return "1=1";
943  }
944 
945 }
static isPost()
Returns true if the request is sent by the POST method.
Definition: URequest.php:109
The base class for displaying datas in CRUD controllers.
Definition: CRUDDatas.php:11
static getModelsName($config, $name)
loadView($viewName, $pData=NULL, $asString=false)
static getRouteInfo($path)
Definition: Router.php:74
_diagramMenu($url="/_updateDiagram", $params="{}", $responseElement="#diag-class", $type="plain", $size=";scale:100")
_loadModelStep($engineering=null, $newStep=null)
_createController($controllerName, $variables=[], $ctrlTemplate='controller.tpl', $hasView=false, $jsCallback="")
static getNS($part="controllers")
Definition: Startup.php:45
Base class for controllers.
Definition: Controller.php:18
static openReplaceWriteFromTemplateFile($source, $destination, $keyAndValues)
Definition: UFileSystem.php:73
static isAjax()
Returns true if the request is an Ajax request.
Definition: URequest.php:101
static count($className, $condition='')
Returns the number of objects of $className from the database respecting the condition possibly passe...
Definition: DAO.php:347
static getTableName($class)
Definition: OrmUtils.php:62
showSimpleMessage($content, $type, $title=null, $icon="info", $timeout=NULL, $staticName=null)
static addOrRemoveValueFromArray($arrayKey, $value, $add=true)
Adds or removes a value from an array in session.
Definition: USession.php:46
static getSerializableFields($class)
Definition: OrmUtils.php:217
_runPostWithParams($method="post", $type="parameter", $origine="routes")