private function RenderMasterIndexController() { // $modelPath = join(".", array_filter(array( $this->subFolder,$model))); $viewPath = join(".", array_filter(array($this->subFolder, $table))); //$routePath = join(DIRECTORY_SEPARATOR, array_filter(array($this->subFolder, $model))); // $index = "return view('{{viewpath}}.Masterindex');"; $stub = file_get_contents(__DIR__ . '/stubs/MasterIndexController.stub'); $stub = str_replace('{{namespace}}', $this->rootNameSpace . '\\Http\\Controllers\\' . UCfirst($this->subFolder), $stub); $stub = str_replace('{{rootNamespace}}', $this->rootNameSpace, $stub); $stub = str_replace('{{class}}', 'MasterIndexController', $stub); $stub = str_replace('{{index}}', $index, $stub); $stub = str_replace('{{controllerComments}}', $this->controllercomments, $stub); //these must come last $stub = str_replace('{{viewpath}}', $viewPath, $stub); //$stub = str_replace('{{routepath}}', $routePath, $stub); return $stub; }
function constructSmarty($parser) { global $mod_strings; $smarty = new Sugar_Smarty(); $smarty->assign('translate', true); $smarty->assign('language', $parser->getLanguage()); $smarty->assign('view', $this->editLayout); $smarty->assign('module', "ModuleBuilder"); $smarty->assign('field_defs', $parser->getFieldDefs()); $smarty->assign('action', 'listViewSave'); $smarty->assign('view_module', $this->editModule); if (!empty($this->subpanel)) { $smarty->assign('subpanel', $this->subpanel); $smarty->assign('subpanelLabel', $this->subpanelLabel); if (!$this->fromModuleBuilder) { $subList = SubPanel::getModuleSubpanels($this->editModule); $subRef = $subList[strtolower($this->subpanel)]; $subTitleKey = !empty($subRef) ? $subRef : "LBL_" . strtoupper($this->subpanel) . "_SUBPANEL_TITLE"; $subTitle = !empty($subRef) ? translate($subTitleKey, $this->editModule) : UCfirst($this->subpanel); $smarty->assign('subpanel_label', $subTitleKey); $smarty->assign('subpanel_title', $subTitle); } } $helpName = $this->subpanel ? 'subPanelEditor' : 'listViewEditor'; $smarty->assign('helpName', $helpName); $smarty->assign('helpDefault', 'modify'); $smarty->assign('title', $this->_constructTitle()); $groups = array(); foreach ($parser->columns as $column => $function) { // update this so that each field has a properties set // properties are name, value, title (optional) $groups[$GLOBALS['mod_strings'][$column]] = $parser->{$function}(); // call the parser functions to populate the list view columns, by default 'default', 'available' and 'hidden' } foreach ($groups as $groupKey => $group) { foreach ($group as $fieldKey => $field) { if (isset($field['width'])) { if (substr($field['width'], -1, 1) == '%') { $groups[$groupKey][$fieldKey]['width'] = substr($field['width'], 0, strlen($field['width']) - 1); } } } } $smarty->assign('groups', $groups); $smarty->assign('from_mb', $this->fromModuleBuilder); global $image_path; $imageSave = SugarThemeRegistry::current()->getImage('studio_save', '', null, null, '.gif', $mod_strings['LBL_BTN_SAVE']); // $imageHelp = SugarThemeRegistry::current()->getImage('help') ; $history = $parser->getHistory(); $histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")"; if ($this->subpanel) { $histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$this->subpanel}\")"; } $restoreAction = "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'"; if ($this->subpanel) { $restoreAction = "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"{$this->subpanel}\")'"; } $buttons = array(); $buttons[] = array('id' => 'savebtn', 'name' => 'savebtn', 'image' => $imageSave, 'text' => !$this->fromModuleBuilder ? $GLOBALS['mod_strings']['LBL_BTN_SAVEPUBLISH'] : $GLOBALS['mod_strings']['LBL_BTN_SAVE'], 'actionScript' => "onclick='studiotabs.generateGroupForm(\"edittabs\");if (countListFields()==0) ModuleBuilder.layoutValidation.popup() ; else ModuleBuilder.handleSave(\"edittabs\" )'"); $buttons[] = array('id' => 'spacer', 'width' => '50px'); $buttons[] = array('id' => 'historyBtn', 'name' => 'historyBtn', 'text' => translate('LBL_HISTORY'), 'actionScript' => "onclick='{$histaction}'"); $buttons[] = array('id' => 'historyDefault', 'name' => 'historyDefault', 'text' => translate('LBL_RESTORE_DEFAULT'), 'actionScript' => $restoreAction); $smarty->assign('buttons', $this->_buildImageButtons($buttons)); $editImage = SugarThemeRegistry::current()->getImage('edit_inline', '', null, null, '.gif', $mod_strings['LBL_EDIT']); $smarty->assign('editImage', $editImage); $deleteImage = SugarThemeRegistry::current()->getImage('delete_inline', '', null, null, '.gif', $mod_strings['LBL_MB_DELETE']); $smarty->assign('deleteImage', $deleteImage); $smarty->assign('MOD', $GLOBALS['mod_strings']); if ($this->fromModuleBuilder) { $smarty->assign('MB', true); $smarty->assign('view_package', $_REQUEST['view_package']); $mb = new ModuleBuilder(); $module =& $mb->getPackageModule($_REQUEST['view_package'], $this->editModule); $smarty->assign('current_mod_strings', $module->getModStrings()); if ($this->subpanel) { if (isset($_REQUEST['local'])) { $smarty->assign('local', '1'); } $smarty->assign("subpanel", $this->subpanel); } else { $smarty->assign('description', $GLOBALS['mod_strings']['LBL_LISTVIEW_DESCRIPTION']); } } else { if ($this->subpanel) { $smarty->assign("subpanel", "{$this->subpanel}"); } else { $smarty->assign('description', $GLOBALS['mod_strings']['LBL_LISTVIEW_DESCRIPTION']); } } return $smarty; }
public function RenderRESTController($table, $model) { $this->BuildControllerComments(); $modelPath = join(".", array_filter(array($this->subFolder, $model))); $viewPath = join(".", array_filter(array($this->subFolder, $table))); $routePath = join(DIRECTORY_SEPARATOR, array_filter(array($this->subFolder, $model))); $fieldList = $this->GetQuoteDelimitedFieldList($table); //create the basic REST view responses $index = "return view('{{viewpath}}.index')->with('{{model}}s', \\" . $this->rootNameSpace . "\\{{model}}::paginate(10));"; $create = "return view('{{viewpath}}.create');"; $store = "\\" . $this->rootNameSpace . "\\{{model}}::create(\\Request::all());\n"; $store .= $this->GetIndent(8) . "return redirect('{{routepath}}')->with('message', 'Your record has been saved.');\n"; $show = "return view('{{viewpath}}.show')->with('{{model}}', \\" . $this->rootNameSpace . "\\{{model}}::find(\$id));\n"; $edit = "return view('{{viewpath}}.edit')->with('{{model}}', \\" . $this->rootNameSpace . "\\{{model}}::find(\$id));\n"; $update = $this->GetUpdateFunction($table); $destroy = "//Sorry, you'll have to add the destroy code yourself, hopefully after you've configured authentication"; $destroy .= "// \${{model}} = {{model}}::find(\$id);"; $destroy .= "// \${{model}}->delete();"; $stub = file_get_contents($this->stubfolder . '/' . 'controller.stub'); $stub = str_replace('{{namespace}}', $this->rootNameSpace . '\\Http\\Controllers\\' . UCfirst($this->subFolder), $stub); $stub = str_replace('{{rootNamespace}}', $this->rootNameSpace, $stub); $stub = str_replace('{{class}}', UCfirst($model) . "Controller", $stub); $stub = str_replace('{{index}}', $index, $stub); $stub = str_replace('{{create}}', $create, $stub); $stub = str_replace('{{store}}', $store, $stub); $stub = str_replace('{{show}}', $show, $stub); $stub = str_replace('{{edit}}', $edit, $stub); $stub = str_replace('{{update}}', $update, $stub); $stub = str_replace('{{destroy}}', $destroy, $stub); $stub = str_replace('{{controllerComments}}', $this->controllercomments, $stub); //these must come last $stub = str_replace('{{viewpath}}', $viewPath, $stub); $stub = str_replace('{{routepath}}', $routePath, $stub); $stub = str_replace('{{modelpath}}', $modelPath, $stub); $stub = str_replace('{{model}}', $model, $stub); $stub = str_replace('{{table}}', $table, $stub); return $stub; }