function add() { if ($_POST) { if ($this->_validate()) { $base_path = MODPATH . $_POST['name'] . '/'; mkdir($base_path); mkdir($base_path . 'controllers'); mkdir($base_path . 'models'); $data = array('module' => $_POST['name'], 'base_class' => $_POST['controller_base_class']); $view = widget_view('templates/template_controller', $data, true); $f = fopen($base_path . 'controllers/' . $data['module'] . '.php', 'w'); fputs($f, $view, strlen($view)); fclose($f); $data = array('module' => $_POST['name'], 'base_class' => $_POST['model_base_class']); $view = widget_view('templates/template_model', $data, true); $f = fopen($base_path . 'models/' . $data['module'] . '_model.php', 'w'); fputs($f, $view, strlen($view)); fclose($f); if (!empty($_POST['create_table'])) { $sql = 'CREATE TABLE IF NOT EXISTS `' . $_POST['name'] . '` ( `id` INT(11) unsigned NOT NULL AUTO_INCREMENT,' . "\n"; foreach ($_POST['fields'] as $key => $field) { $type = strtoupper($_POST['types'][$key]); $size = $_POST['sizes'][$key]; $extra = $_POST['extras'][$key]; if ($type == 'DATETIME' || $type == 'DATE' || $type == 'TEXT') { $size = ''; } if (empty($size)) { if ($type == 'VARCHAR') { $size = '(255)'; } else { $size = ''; } } else { $size = '(' . $size . ')'; } $sql .= '`' . $field . '` ' . $type . $size . ' ' . $extra . ' NOT NULL,' . "\n"; } $sql .= '`status` INT(11) unsigned NOT NULL, `created_time` DATETIME NOT NULL, `created_by` VARCHAR(255) NOT NULL, `updated_time` DATETIME NOT NULL, `updated_by` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM' . "\n"; $this->_model()->query($sql); } redirect('module/listing'); } } else { $_POST['controller_base_class'] = 'app_crud_controller'; $_POST['model_base_class'] = 'app_base_model'; } $this->_data['type_options'] = array('INT' => 'INT', 'VARCHAR' => 'VARCHAR', 'TEXT' => 'TEXT', 'DATETIME' => 'DATETIME', 'DOUBLE' => 'DOUBLE'); }
function _post_controller() { if (empty($this->_view)) { $this->_view = $this->_name . '/' . $this->uri->rsegments[2]; } if (!$this->input->is_ajax_request() && !empty($this->_layout_view)) { $view = $this->_layout_view; $data = array(); } else { $view = $this->_view; $data = $this->_data; } widget_view($view, $data); }
">Logout</a></li> </ul> </li> </ul> </div> </div> </div> <?php } ?> <div id="layout-body" class="layout-body"> <div class="wrapper"> <div id="layout-content" class="the-content"> <?php echo widget_view($CI->_view, $CI->_data); ?> </div> </div> </div> <div id="layout-footer" class="layout-footer"> <div class="wrapper"> <div id="footer-copyright" class="footer-copyright"> <p> Copyright © 2011 <a href="http://xinix.co.id" target="blank">Xinix Technology</a>. All rights reserved. <?php //if ($CI->config->item('debug')): ?> <a href="#" id="profiler_btn">( time: {elapsed_time}, mem: {memory_usage} )</a> <?php