public function start_control($compiler, $node) { echo "<?\n"; ?> $_formControlModel = Model::getModel('<?php echo $node->getAttribute("model"); ?> '); if(!isset($MVC_CURRENT_MODEL)) { $MVC_CURRENT_MODEL = $_formControlModel; } <?php echo "\n?>"; $parameters = ViewCompiler::attributesAsArray($node->attributes); /* * See if we need to automatically create a controller for this save action */ if ($node->getAttribute("autocreate-controller") == "true") { $target = ControllerGenerator::generateSaveController($compiler->controller, $compiler->method, $node->getAttribute("model"), $node->getAttribute("redirect")); $parameters["method"] = "post"; $parameters["action"] = $target; } unset($parameters["model"]); unset($parameters["redirect"]); unset($parameters["autocreate-controller"]); echo $this->html->startElement("form", $parameters); return true; }
private static function addRoute($requestPath, $targetFile, $className) { // Update routing $currentRoutes = array(); if (class_exists("AutoRoutes")) { $currentRoutes = AutoRoutes::$AUTO_ROUTES; } $currentRoutes[$requestPath] = array("file" => $targetFile, "class" => $className); ControllerGenerator::writeRoutes($currentRoutes); }
public function actionNewCtrl() { $model = new DevGenNewCtrl(); $href = ""; if (isset($_POST['DevGenNewCtrl'])) { $s = $_POST['DevGenNewCtrl']; $s['ctrlName'] = $s['ctrlName'] . "Controller"; $href = Yii::app()->createUrl('/dev/genCtrl/index', ['active' => $s['module'] . "." . $s['ctrlName']]); ControllerGenerator::create($s['module'], $s['ctrlName']); } $this->renderForm('DevGenNewCtrl', $model, ['href' => $href], ['layout' => '//layouts/blank']); }
public function execute($params) { $parser = new YAMLParser(); $yaml_configuration = $parser->parse($params[0]); print_r($yaml_configuration); if (!isset($yaml_configuration['crud'])) { Makiavelo::info("**** ERROR ****"); Makiavelo::info("CRUD key not found on yaml file, cancelling generation..."); } else { $crud_info = $yaml_configuration['crud']; $this->en_name = $crud_info['entity']['name']; if (isset($crud_info['entity']['validations'])) { $this->generateValidations($crud_info['entity']['validations']); } $this->generateEntity($crud_info['entity']); $this->generateViews($crud_info['entity']); $this->generateSQL(); $this->generateRoutes(); $contGen = new ControllerGenerator(); $contGen->execute(array($this->en_name, "no-views")); } }
public function start_control($compiler, $node) { /* Generate the controller based on the code */ $code = ViewCompiler::collect($node); $path = ControllerGenerator::generateBasicController($compiler->controller, $compiler->method, $code); // If we don't have a parent, we create a hidden DIV that we can use to find our parent // and attach result to the parent of that div $divName = "mvcHiddenDiv" . time() . rand(100, 999); if (!$node->hasAttribute("target")) { ?> <div id="<?php echo $divName; ?> " style="display: none"></div> <?php } /* * Create JavaScript -functions to invoke this Ajax-script. If we have execute-on -defined, we automatically * create a <script>-wrapper and a function, if not, we assume the tag's inside a <script>-tag */ if ($node->hasAttribute("execute-on")) { ob_start(); } ?> $.post('<?php echo $path; ?> ', { <?php /* * See which JS -variables to export to the PHP -script. If the code automatically generates * a function, then we export any parameters, if it's embedded in JS -code, we can * define the exported variables with the "export" parameter. Both expect a comma-separated * list */ $exportVariables = $node->hasAttribute("parameters") ? explode(", ", $node->getAttribute("parameters")) : ($node->hasAttribute("export") ? explode(",", $node->getAttribute("export")) : array()); if (!empty($exportVariables)) { foreach ($exportVariables as &$param) { $param = "'{$param}': {$param}"; } echo join($exportVariables, ","); } ?> }, function(data) { <?php if ($node->hasAttribute("target")) { ?> $('<?php echo $node->getAttribute("target"); ?> ').append(data); <?php } else { ?> $('#<?php echo $divName; ?> ').parent().append(data) $('#<?php echo $divName; ?> ').remove(); <?php } ?> }); <?php /* * If we define the "execute-on" -parameter, then we create a function automatically. * * TODO: Would be nice if this could be automatically bound to events, e.g: * * execute-on="$('#foo').blur" */ if ($node->hasAttribute("execute-on")) { $script = ob_get_contents(); ob_end_clean(); ?> <script language="JavaScript" type="text/javascript"> <!-- function <?php echo $node->getAttribute("execute-on"); ?> (<?php echo $node->getAttribute("parameters"); ?> ) { <?php echo $script; ?> } //--> </script> <?php } return false; }
/** * List the CrudIgniter options * * @since 1.0 * @access public * @return void */ public function listOptions() { $result = ConsoleIgniter::writeQuestion('What do you want to generate?', array('MODEL', 'VIEW', 'CONTROLLER', 'EXIT'), 0); $generator = null; $result = strtolower($result); switch ($result) { case 0: if (class_exists('MY_ModelGenerator')) { $generator = new MY_ModelGenerator(); } else { $generator = new ModelGenerator(); } break; case 1: if (class_exists('MY_ViewGenerator')) { $generator = new MY_ViewGenerator(); } else { $generator = new ViewGenerator(); } break; case 2: if (class_exists('MY_ControllerGenerator')) { $generator = new MY_ControllerGenerator(); } else { $generator = new ControllerGenerator(); } break; default: ConsoleIgniter::bye(); } $generator->generate(); ConsoleIgniter::bye(); }
<div ui-layout class="sub" options="{ flow : 'column' }"> <div ui-layout-container size='60%' min-size="300px"> <div ui-header> <?php echo $controller; ?> <br> </div> <div ui-content> <table class="table table-responsive" style="background:#f6f6f6;"> <tr> <td><b>Source Code</b></td> </tr> <tr> <td><span class="code" style="word-wrap:break-word;"><?php echo ControllerGenerator::controllerPath($class, $type); ?> </span></td> </tr> </table> <div ui-header> <div class="btn btn-xs btn-success pull-right" style="margin-top:4px;" ng-click="new ()"> <i class="fa fa-plus"></i> New </div> Action List </div> <div class="action-list"> <table class="table-responsive table table-bordered"> <thead> <tr colspan=2 style="background:#f6f6f6;">
<?php ## AUTOGENERATED OPTIONS - DO NOT EDIT $options = array('mode' => 'custom', 'layout' => array('size' => '200', 'sizetype' => 'px', 'type' => 'menu', 'name' => 'col1', 'file' => 'application.modules.dev.menus.GenCtrl', 'title' => 'Controller List', 'icon' => 'fa-slack', 'inlineJS' => 'GenCtrl.js')); ## END OF AUTOGENERATED OPTIONS return ControllerGenerator::listCtrlForMenuTree();