|
@@ -260,6 +260,14 @@ class GenController {
|
|
}
|
|
}
|
|
public function saveShowView(GenController $controller, GenControllerMethod $method)
|
|
public function saveShowView(GenController $controller, GenControllerMethod $method)
|
|
{
|
|
{
|
|
|
|
+ // delete sub links and action links
|
|
|
|
+ if(file_exists(resource_path("views/{$controller->root}/{$controller->parentControllerName}/subs.blade.php"))) {
|
|
|
|
+ unlink(resource_path("views/{$controller->root}/{$controller->parentControllerName}/subs.blade.php"));
|
|
|
|
+ }
|
|
|
|
+ if(file_exists(resource_path("views/{$controller->root}/{$controller->parentControllerName}/actions.blade.php"))) {
|
|
|
|
+ unlink(resource_path("views/{$controller->root}/{$controller->parentControllerName}/actions.blade.php"));
|
|
|
|
+ }
|
|
|
|
+
|
|
$text = file_get_contents(base_path('generatecv/tree-templates/show.template.blade.php'));
|
|
$text = file_get_contents(base_path('generatecv/tree-templates/show.template.blade.php'));
|
|
$text = str_replace("_NAME_", $this->snakeToTitleCase($controller->name), $text);
|
|
$text = str_replace("_NAME_", $this->snakeToTitleCase($controller->name), $text);
|
|
$text = str_replace("_UID_", '<?= $record->uid ?>', $text);
|
|
$text = str_replace("_UID_", '<?= $record->uid ?>', $text);
|
|
@@ -278,13 +286,29 @@ class GenController {
|
|
foreach ($controller->methods as $meth) {
|
|
foreach ($controller->methods as $meth) {
|
|
echo $meth->name . "\n";
|
|
echo $meth->name . "\n";
|
|
if(strpos($meth->name, "SUB_") !== 0) continue;
|
|
if(strpos($meth->name, "SUB_") !== 0) continue;
|
|
- $display = substr($meth->name, 4);
|
|
|
|
|
|
+ $display = $this->snakeToTitleCase(substr($meth->name, 4));
|
|
$subLinks[] = "<a " .
|
|
$subLinks[] = "<a " .
|
|
"href='/{$controller->parentControllerName}/view/<?= \$record->uid ?>/{$meth->name}' " .
|
|
"href='/{$controller->parentControllerName}/view/<?= \$record->uid ?>/{$meth->name}' " .
|
|
"class='d-block p-3 py-2 border-bottom'>$display</a>";
|
|
"class='d-block p-3 py-2 border-bottom'>$display</a>";
|
|
}
|
|
}
|
|
file_put_contents($subLinksView, implode("\n", $subLinks));
|
|
file_put_contents($subLinksView, implode("\n", $subLinks));
|
|
- // echo "Generated " . $subLinksView . "\n";
|
|
|
|
|
|
+ echo "Generated " . $subLinksView . "\n";
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+ // generate action links if not existing
|
|
|
|
+ $actionLinksView = resource_path("views/{$controller->root}/{$controller->parentControllerName}/actions.blade.php");
|
|
|
|
+ //if(!file_exists($actionLinksView)) {
|
|
|
|
+ $actionLinks = [];
|
|
|
|
+ foreach ($controller->methods as $meth) {
|
|
|
|
+ echo $meth->name . "\n";
|
|
|
|
+ if(strpos($meth->name, "ACTION_") !== 0) continue;
|
|
|
|
+ $display = $this->camelToTitleCase(substr($meth->name, 7));
|
|
|
|
+ $actionLinks[] = "<a " .
|
|
|
|
+ "href='/{$controller->parentControllerName}/view/<?= \$record->uid ?>/{$meth->name}' " .
|
|
|
|
+ "class='d-block btn btn-sm btn-default m-3'>$display</a>";
|
|
|
|
+ }
|
|
|
|
+ file_put_contents($actionLinksView, implode("\n", $actionLinks));
|
|
|
|
+ echo "Generated " . $actionLinksView . "\n";
|
|
//}
|
|
//}
|
|
|
|
|
|
$text = file_get_contents(base_path('generatecv/tree-templates/sub.template.blade.php'));
|
|
$text = file_get_contents(base_path('generatecv/tree-templates/sub.template.blade.php'));
|
|
@@ -297,6 +321,7 @@ class GenController {
|
|
if($method->name === 'SUB_dashboard') {
|
|
if($method->name === 'SUB_dashboard') {
|
|
$html = file_get_contents(base_path('generatecv/tree-templates/dashboard.template.blade.php'));
|
|
$html = file_get_contents(base_path('generatecv/tree-templates/dashboard.template.blade.php'));
|
|
$text = str_replace("_SUB_VIEW_", $html, $text);
|
|
$text = str_replace("_SUB_VIEW_", $html, $text);
|
|
|
|
+ $text = str_replace("_ACTION_LINKS_VIEW_", "{$controller->root}/{$controller->parentControllerName}/actions", $text);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
$text = str_replace("_SUB_VIEW_", "Content from<br><b>{$controller->root}/{$controller->name}/{$method->name}.blade.php</b>", $text);
|
|
$text = str_replace("_SUB_VIEW_", "Content from<br><b>{$controller->root}/{$controller->name}/{$method->name}.blade.php</b>", $text);
|
|
@@ -342,6 +367,10 @@ class GenController {
|
|
private function snakeToTitleCase($text) {
|
|
private function snakeToTitleCase($text) {
|
|
return ucwords(str_replace("_", " ", $text));
|
|
return ucwords(str_replace("_", " ", $text));
|
|
}
|
|
}
|
|
|
|
+ private function camelToTitleCase($text) {
|
|
|
|
+ $text = preg_replace("/([A-Z])/", " $1", $text);
|
|
|
|
+ return ucwords($text);
|
|
|
|
+ }
|
|
private function file_force_contents($dir, $contents){
|
|
private function file_force_contents($dir, $contents){
|
|
$dir = str_replace("\\", "/", $dir);
|
|
$dir = str_replace("\\", "/", $dir);
|
|
$dir = str_replace( '//', '/', $dir);
|
|
$dir = str_replace( '//', '/', $dir);
|