index.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. if (cfr('MODELS')) {
  3. $models = new Models();
  4. //model creation
  5. if (ubRouting::checkPost(array($models::PROUTE_NEWMODELNAME, $models::PROUTE_NEWMODELTPL))) {
  6. $creationResult = $models->create(ubRouting::post($models::PROUTE_NEWMODELNAME), ubRouting::post($models::PROUTE_NEWMODELTPL));
  7. if ($creationResult) {
  8. show_error($creationResult);
  9. } else {
  10. ubRouting::nav($models::URL_ME);
  11. }
  12. }
  13. //model deletion
  14. if (ubRouting::checkGet($models::ROUTE_DELMODEL)) {
  15. $deletionResult = $models->delete(ubRouting::get($models::ROUTE_DELMODEL));
  16. if ($deletionResult) {
  17. show_error($deletionResult);
  18. } else {
  19. ubRouting::nav($models::URL_ME);
  20. }
  21. }
  22. //model editing
  23. if (ubRouting::checkPost(array($models::PROUTE_ED_MODELID, $models::PROUTE_ED_MODELNAME, $models::PROUTE_ED_MODELTPL))) {
  24. $edModelId = ubRouting::post($models::PROUTE_ED_MODELID);
  25. $edName = ubRouting::post($models::PROUTE_ED_MODELNAME);
  26. $edTemplate = ubRouting::post($models::PROUTE_ED_MODELTPL);
  27. $editingResult = $models->save($edModelId, $edName, $edTemplate);
  28. if ($editingResult) {
  29. show_error($editingResult);
  30. } else {
  31. ubRouting::nav($models::URL_ME);
  32. }
  33. }
  34. //module controls here
  35. show_window('',$models->renderControls());
  36. //some interfaces
  37. if (ubRouting::checkGet($models::ROUTE_CREATEMODEL)) {
  38. show_window(__('Create new model'), $models->renderCreationForm());
  39. } else {
  40. show_window(__('Available models'), $models->renderList());
  41. }
  42. } else {
  43. show_error(__('Access denied'));
  44. }