Esempio n. 1
0
 public function getRebuild($id = 0)
 {
     $row = DB::table('tb_module')->where('module_id', $id)->get();
     if (count($row) <= 0) {
         return Redirect::to($this->module)->with('message', SiteHelpers::alert('error', 'Can not find module'));
     }
     $row = $row[0];
     $this->data['row'] = $row;
     $config = SiteHelpers::CF_decode_json($row->module_config);
     $class = $row->module_name;
     $ctr = ucwords($row->module_name);
     $path = $row->module_name;
     // build Field entry
     $f = '';
     $req = '';
     // End Build Field Entry
     $codes = array('controller' => ucwords($class), 'class' => $class, 'fields' => $f, 'required' => $req, 'table' => $row->module_db, 'title' => $row->module_title, 'note' => $row->module_note, 'key' => $row->module_db_key, 'sql_select' => $config['sql_select'], 'sql_where' => $config['sql_where'], 'sql_group' => $config['sql_group']);
     if (!isset($config['form_layout'])) {
         $config['form_layout'] = array('column' => 1, 'title' => $row->module_title, 'format' => 'grid', 'display' => 'horizontal');
     }
     $codes['form_javascript'] = SiteHelpers::toJavascript($config['forms'], $path, $class);
     $codes['form_entry'] = SiteHelpers::toForm($config['forms'], $config['form_layout']);
     $codes['form_display'] = isset($config['form_layout']['display']) ? $config['form_layout']['display'] : 'horizontal';
     $codes['form_view'] = SiteHelpers::toView($config['grid']);
     // Start Native CRUD
     if ($row->module_db_key == '') {
         // No CRUD
         $controller = file_get_contents(app_path() . '/views/admin/module/template/controller_view.tpl');
         $grid = file_get_contents(app_path() . '/views/admin/module/template/grid_view.tpl');
     } else {
         $controller = file_get_contents(app_path() . '/views/admin/module/template/controller.tpl');
         $grid = file_get_contents(app_path() . '/views/admin/module/template/grid.tpl');
     }
     $view = file_get_contents(app_path() . '/views/admin/module/template/view.tpl');
     $form = file_get_contents(app_path() . '/views/admin/module/template/form.tpl');
     $model = file_get_contents(app_path() . '/views/admin/module/template/model.tpl');
     $build_controller = SiteHelpers::blend($controller, $codes);
     $build_view = SiteHelpers::blend($view, $codes);
     $build_form = SiteHelpers::blend($form, $codes);
     $build_grid = SiteHelpers::blend($grid, $codes);
     $build_model = SiteHelpers::blend($model, $codes);
     if (!is_dir(app_path() . "/views/{$class}")) {
         mkdir(app_path() . "/views/{$class}", 0777);
     }
     if (!is_null(Input::get('rebuild'))) {
         // rebuild spesific files
         if (Input::get('c') == 'y') {
             file_put_contents(app_path() . "/controllers/{$ctr}Controller.php", $build_controller);
         }
         if (Input::get('m') == 'y') {
             file_put_contents(app_path() . "/models/{$ctr}.php", $build_model);
         }
         if (Input::get('g') == 'y') {
             file_put_contents(app_path() . "/views/{$class}/index.blade.php", $build_grid);
         }
         if ($row->module_db_key != '') {
             if (Input::get('f') == 'y') {
                 file_put_contents(app_path() . "/views/{$class}/form.blade.php", $build_form);
             }
             if (Input::get('v') == 'y') {
                 file_put_contents(app_path() . "/views/{$class}/view.blade.php", $build_view);
             }
         }
     } else {
         file_put_contents(app_path() . "/controllers/{$ctr}Controller.php", $build_controller);
         file_put_contents(app_path() . "/models/{$ctr}.php", $build_model);
         file_put_contents(app_path() . "/views/{$class}/index.blade.php", $build_grid);
         if ($row->module_db_key != '') {
             file_put_contents(app_path() . "/views/{$class}/form.blade.php", $build_form);
             file_put_contents(app_path() . "/views/{$class}/view.blade.php", $build_view);
         }
     }
     // end Native CRUD
     self::createRouters();
     return Redirect::to('module')->with('messagetext', 'Code Script has been replaced successfull')->with('msgstatus', 'success');
 }
Esempio n. 2
0
 public function getRebuild(Request $request, $id = 0)
 {
     $row = \DB::table('tb_module')->where('module_id', $id)->get();
     if (count($row) <= 0) {
         return Redirect::to('sximo/module')->with('messagetext', 'Can not find module')->with('msgstatus', 'error');
     }
     $row = $row[0];
     $this->data['row'] = $row;
     $config = \SiteHelpers::CF_decode_json($row->module_config);
     $class = $row->module_name;
     $ctr = ucwords($row->module_name);
     $path = $row->module_name;
     // build Field entry
     $f = '';
     $req = '';
     // End Build Field Entry
     $codes = array('controller' => ucwords($class), 'class' => $class, 'fields' => $f, 'required' => $req, 'table' => $row->module_db, 'title' => $row->module_title, 'note' => $row->module_note, 'key' => $row->module_db_key, 'sql_select' => $config['sql_select'], 'sql_where' => $config['sql_where'], 'sql_group' => $config['sql_group']);
     if (!isset($config['form_layout'])) {
         $config['form_layout'] = array('column' => 1, 'title' => $row->module_title, 'format' => 'grid', 'display' => 'horizontal');
     }
     $codes['form_javascript'] = \SiteHelpers::toJavascript($config['forms'], $path, $class);
     $codes['form_entry'] = \SiteHelpers::toForm($config['forms'], $config['form_layout']);
     $codes['form_display'] = isset($config['form_layout']['display']) ? $config['form_layout']['display'] : 'horizontal';
     $codes['form_view'] = \SiteHelpers::toView($config['grid']);
     $codes['masterdetailmodel'] = '';
     $codes['masterdetailinfo'] = '';
     $codes['masterdetailgrid'] = '';
     $codes['masterdetailsave'] = '';
     $codes['masterdetailform'] = '';
     $codes['masterdetailview'] = '';
     $codes['masterdetailjs'] = '';
     $codes['masterdetaildelete'] = '';
     /* Master detail */
     if (isset($config['subgrid']) && count($config['subgrid']) >= 1) {
         $md = \SiteHelpers::toMasterDetail($config['subgrid'][0]);
         $codes['masterdetailmodel'] = $md['masterdetailmodel'];
         $codes['masterdetailinfo'] = $md['masterdetailinfo'];
         $codes['masterdetailgrid'] = $md['masterdetailgrid'];
         $codes['masterdetailsave'] = $md['masterdetailsave'];
         $codes['masterdetailform'] = $md['masterdetailform'];
         $codes['masterdetailjs'] = $md['masterdetailjs'];
         $codes['masterdetailview'] = $md['masterdetailview'];
         $codes['masterdetaildelete'] = $md['masterdetaildelete'];
     }
     /* End Master Detail */
     $dir = base_path() . '/resources/views/' . $class;
     $dirC = app_path() . '/Http/Controllers/';
     $dirM = app_path() . '/Models/';
     if (!is_dir($dir)) {
         mkdir($dir, 0777);
     }
     // BLANK TEMPLATE
     if ($row->module_type == 'generic') {
         $template = base_path() . '/resources/views/sximo/module/template/blank/';
         $controller = file_get_contents($template . 'controller.tpl');
         $grid = file_get_contents($template . 'grid.tpl');
         $view = file_get_contents($template . 'view.tpl');
         $form = file_get_contents($template . 'form.tpl');
         $model = file_get_contents($template . 'model.tpl');
         $build_controller = \SiteHelpers::blend($controller, $codes);
         $build_view = \SiteHelpers::blend($view, $codes);
         $build_form = \SiteHelpers::blend($form, $codes);
         $build_grid = \SiteHelpers::blend($grid, $codes);
         $build_model = \SiteHelpers::blend($model, $codes);
         file_put_contents($dirC . "{$ctr}Controller.php", $build_controller);
         file_put_contents($dirM . "{$ctr}.php", $build_model);
         file_put_contents($dir . "/index.blade.php", $build_grid);
         file_put_contents($dir . "/form.blade.php", $build_form);
         file_put_contents($dir . "/view.blade.php", $build_view);
     }
     if ($row->module_type == 'report') {
         $template = base_path() . '/resources/views/sximo/module/template/report/';
         $controller = file_get_contents($template . 'controller.tpl');
         $grid = file_get_contents($template . 'grid.tpl');
         $model = file_get_contents($template . 'model.tpl');
         $build_controller = \SiteHelpers::blend($controller, $codes);
         $build_grid = \SiteHelpers::blend($grid, $codes);
         $build_model = \SiteHelpers::blend($model, $codes);
         file_put_contents($dirC . "{$ctr}Controller.php", $build_controller);
         file_put_contents($dirM . "{$ctr}.php", $build_model);
         file_put_contents($dir . "/index.blade.php", $build_grid);
     }
     if ($row->module_type == 'addon') {
         $template = base_path() . '/resources/views/sximo/module/template/native/';
         $controller = file_get_contents($template . 'controller.tpl');
         $grid = file_get_contents($template . 'grid.tpl');
         $view = file_get_contents($template . 'view.tpl');
         $form = file_get_contents($template . 'form.tpl');
         $model = file_get_contents($template . 'model.tpl');
         $build_controller = \SiteHelpers::blend($controller, $codes);
         $build_view = \SiteHelpers::blend($view, $codes);
         $build_form = \SiteHelpers::blend($form, $codes);
         $build_grid = \SiteHelpers::blend($grid, $codes);
         $build_model = \SiteHelpers::blend($model, $codes);
         if (!is_null($request->input('rebuild'))) {
             // rebuild spesific files
             if ($request->input('c') == 'y') {
                 file_put_contents($dirC . "{$ctr}Controller.php", $build_controller);
             }
             if ($request->input('m') == 'y') {
                 file_put_contents($dirM . "{$ctr}.php", $build_model);
             }
             if ($request->input('g') == 'y') {
                 file_put_contents($dir . "/index.blade.php", $build_grid);
             }
             if ($row->module_db_key != '') {
                 if ($request->input('f') == 'y') {
                     file_put_contents($dir . "/form.blade.php", $build_form);
                 }
                 if ($request->input('v') == 'y') {
                     file_put_contents($dir . "/view.blade.php", $build_view);
                 }
             }
         } else {
             file_put_contents($dirC . "{$ctr}Controller.php", $build_controller);
             file_put_contents($dirM . "{$ctr}.php", $build_model);
             file_put_contents($dir . "/index.blade.php", $build_grid);
             file_put_contents($dir . "/form.blade.php", $build_form);
             file_put_contents($dir . "/view.blade.php", $build_view);
         }
     }
     self::createRouters();
     return Redirect::to('sximo/module')->with('messagetext', 'Code Script has been replaced successfull')->with('msgstatus', 'success');
 }
Esempio n. 3
0
 function rebuild($id = 0)
 {
     $row = $this->db->get_where('tb_module', array('module_id' => $id))->row();
     if (count($row) <= 0) {
         redirect('sximo/module', 301);
     }
     $this->data['row'] = $row;
     $config = SiteHelpers::CF_decode_json($row->module_config);
     $class = $row->module_name;
     $ctr = ucwords($row->module_name);
     $path = $row->module_name;
     // build Field entry
     $f = '';
     $req = '';
     $codes = array('controller' => ucwords($class), 'class' => $class, 'fields' => $f, 'required' => $req, 'table' => $row->module_db, 'title' => $row->module_title, 'note' => $row->module_note, 'key' => $row->module_db_key, 'sql_select' => $config['sql_select'], 'sql_where' => $config['sql_where'], 'sql_group' => $config['sql_group']);
     if (!isset($config['form_layout'])) {
         $config['form_layout'] = array('column' => 1, 'title' => $row->module_title, 'format' => 'grid', 'display' => 'horizontal');
     }
     $codes['form_javascript'] = SiteHelpers::toJavascript($config['forms'], $path, $class);
     $codes['form_entry'] = SiteHelpers::toForm($config['forms'], $config['form_layout']);
     $codes['form_display'] = isset($config['form_layout']['display']) ? $config['form_layout']['display'] : 'horizontal';
     $codes['form_view'] = SiteHelpers::toView($config['grid']);
     // Start Native CRUD
     if ($row->module_db_key == '') {
         // No CRUD
         $controller = file_get_contents('application/views/sximo/module/template/controller_view.tpl');
         $grid = file_get_contents('application/views/sximo/module/template/index_view.tpl');
     } else {
         $controller = file_get_contents('application/views/sximo/module/template/controller.tpl');
         $grid = file_get_contents('application/views/sximo/module/template/index.tpl');
     }
     $view = file_get_contents('application/views/sximo/module/template/view.tpl');
     $form = file_get_contents('application/views/sximo/module/template/form.tpl');
     $model = file_get_contents('application/views/sximo/module/template/model.tpl');
     $build_controller = SiteHelpers::blend($controller, $codes);
     $build_view = SiteHelpers::blend($view, $codes);
     $build_form = SiteHelpers::blend($form, $codes);
     $build_grid = SiteHelpers::blend($grid, $codes);
     $build_model = SiteHelpers::blend($model, $codes);
     if (!is_dir("application/views/{$class}")) {
         mkdir("application/views/{$class}", 0777);
     }
     if ($this->input->get('rebuild') != '') {
         // rebuild spesific files
         if ($this->input->get('c') == 'y') {
             file_put_contents("application/controllers/{$class}.php", $build_controller);
         }
         if ($this->input->get('m') == 'y') {
             file_put_contents("application/models/{$class}model.php", $build_model);
         }
         if ($this->input->get('g') == 'y') {
             file_put_contents("application/views/{$class}/index.php", $build_grid);
         }
         if ($row->module_db_key != '') {
             if ($this->input->get('f') == 'y') {
                 file_put_contents("application/views/{$class}/form.php", $build_form);
             }
             if ($this->input->get('v') == 'y') {
                 file_put_contents("application/views/{$class}/view.php", $build_view);
             }
         }
     } else {
         file_put_contents("application/controllers/{$class}.php", $build_controller);
         file_put_contents("application/models/{$class}model.php", $build_model);
         file_put_contents("application/views/{$class}/index.php", $build_grid);
         if ($row->module_db_key != '') {
             file_put_contents("application/views/{$class}/form.php", $build_form);
             file_put_contents("application/views/{$class}/view.php", $build_view);
         }
     }
     $this->session->set_flashdata('message', SiteHelpers::alert('success', 'Code Script has been replaced successfull'));
     redirect('sximo/module', 301);
 }