1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ubiquity\scaffolding; |
4
|
|
|
|
5
|
|
|
use Ajax\semantic\html\elements\HtmlButton; |
6
|
|
|
use Ubiquity\controllers\Startup; |
7
|
|
|
use Ubiquity\utils\http\USession; |
8
|
|
|
use Ubiquity\controllers\admin\UbiquityMyAdminBaseController; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Ubiquity\scaffolding$AdminScaffoldController |
12
|
|
|
* This class is part of Ubiquity |
13
|
|
|
* |
14
|
|
|
* @author jcheron <[email protected]> |
15
|
|
|
* @version 1.0.0 |
16
|
|
|
* |
17
|
|
|
*/ |
18
|
|
|
class AdminScaffoldController extends ScaffoldController { |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* |
22
|
|
|
* @var UbiquityMyAdminBaseController |
23
|
|
|
*/ |
24
|
|
|
private $controller; |
25
|
|
|
private $jquery; |
26
|
|
|
|
27
|
15 |
|
public function __construct(UbiquityMyAdminBaseController $controller, $jquery) { |
28
|
15 |
|
$this->controller = $controller; |
29
|
15 |
|
$this->jquery = $jquery; |
30
|
15 |
|
} |
31
|
|
|
|
32
|
6 |
|
public function getTemplateDir() { |
33
|
6 |
|
return Startup::getFrameworkDir () . "/admin/templates/"; |
34
|
|
|
} |
35
|
|
|
|
36
|
6 |
|
public function showSimpleMessage($content, $type, $title = null, $icon = "info", $timeout = NULL, $staticName = null) { |
37
|
6 |
|
return $this->controller->showSimpleMessage ( $content, $type, $title, $icon, $timeout, $staticName ); |
38
|
|
|
} |
39
|
|
|
|
40
|
1 |
|
protected function _addMessageForRouteCreation($path, $jsCallback = "") { |
41
|
1 |
|
$msgContent = "<br>Created route : <b>" . $path . "</b>"; |
42
|
1 |
|
$msgContent .= "<br>You need to re-init Router cache to apply this update:"; |
43
|
1 |
|
$btReinitCache = new HtmlButton ( "bt-init-cache", "(Re-)Init router cache", "orange" ); |
44
|
1 |
|
$btReinitCache->addIcon ( "refresh" ); |
45
|
1 |
|
$msgContent .= " " . $btReinitCache; |
46
|
1 |
|
$this->jquery->getOnClick ( "#bt-init-cache", $this->controller->_getFiles ()->getAdminBaseRoute () . "/_refreshCacheControllers", "#messages", [ "attr" => "","hasLoader" => false,"dataType" => "html","jsCallback" => $jsCallback ] ); |
47
|
1 |
|
return $msgContent; |
48
|
|
|
} |
49
|
|
|
|
50
|
5 |
|
protected function storeControllerNameInSession($controller) { |
51
|
5 |
|
USession::addOrRemoveValueFromArray ( "filtered-controllers", $controller, true ); |
52
|
5 |
|
} |
53
|
|
|
|
54
|
|
|
public static function createClass($controller, $jquery, $template, $classname, $namespace, $uses, $extendsOrImplements, $classContent) { |
55
|
|
|
$self = new AdminScaffoldController ( $controller, $jquery ); |
56
|
|
|
return $self->_createClass ( $template, $classname, $namespace, $uses, $extendsOrImplements, $classContent ); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public static function createMethod($controller, $jquery, $access, $name, $parameters, $return, $content, $comment) { |
60
|
|
|
$self = new AdminScaffoldController ( $controller, $jquery ); |
61
|
|
|
return $self->_createMethod ( $access, $name, $parameters, $return, $content, $comment ); |
62
|
|
|
} |
63
|
|
|
|
64
|
1 |
|
public function initRestCache($refresh = true) { |
65
|
1 |
|
$this->controller->initRestCache ( $refresh ); |
66
|
1 |
|
} |
67
|
|
|
|
68
|
1 |
|
public function _refreshRest($refresh = false) { |
69
|
1 |
|
$this->controller->_refreshRest ( $refresh ); |
70
|
1 |
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
|