Пример #1
0
 function create_demo()
 {
     $db_line = color(str_repeat('=', 80), 'N') . "\n";
     $line = color(str_repeat('-', 80), 'w') . "\n";
     echo $db_line;
     $results = array();
     $migrations = array('event' => array(), 'attendee' => array(), 'tag' => array(), 'tag_event_map' => array());
     array_walk($migrations, function ($value, $key) use(&$results) {
         array_push($results, implode("\n", array_map(function ($result) {
             $count = 1;
             return color('  Create: ', 'g') . str_replace(FCPATH, '', $result, $count);
         }, create_migration(BASEPATH . 'cmd/templates/demo/' . $key . '/', $key, 'add'))));
     });
     echo implode("\n", $results) . "\n" . $line;
     $results = array();
     $models = array('event' => array('-p' => array('cover')), 'attendee' => array(), 'tag' => array(), 'tag_event_map' => array());
     array_walk($models, function ($value, $key) use(&$results) {
         array_push($results, implode("\n", array_map(function ($result) {
             $count = 1;
             return color('  Create: ', 'g') . str_replace(FCPATH, '', $result, $count);
         }, create_model(BASEPATH . 'cmd/templates/demo/' . $key . '/', $key, isset($value['-p']) ? $value['-p'] : array(), isset($value['-f']) ? $value['-f'] : array()))));
     });
     echo implode("\n", $results) . "\n" . $line;
     $results = array();
     $cells = array('demo' => array('main_menu'));
     array_walk($cells, function ($value, $key) use(&$results) {
         array_push($results, implode("\n", array_map(function ($result) {
             $count = 1;
             return color('  Create: ', 'g') . str_replace(FCPATH, '', $result, $count);
         }, create_cell(BASEPATH . 'cmd/templates/demo/cell/', $key, $value))));
     });
     echo implode("\n", $results) . "\n" . $line;
     $results = array();
     $controllers = array('events' => array(), 'tags' => array());
     array_walk($controllers, function ($value, $key) use(&$results) {
         array_push($results, implode("\n", array_map(function ($result) {
             $count = 1;
             return color('  Create: ', 'g') . str_replace(FCPATH, '', $result, $count);
         }, create_controller(BASEPATH . 'cmd/templates/demo/' . singularize($key) . '/', $key, 'site', array('index', 'show', 'add', 'create', 'edit', 'update', 'destroy')))));
     });
     echo implode("\n", $results) . "\n" . $line;
     $results = run_migration(null);
     echo color('注意! ', 'r');
     echo implode("\n", $results) . "\n";
     $results = array();
     array_push($results, "migrations(" . implode(', ', array_keys($migrations)) . ")");
     array_push($results, "models(" . implode(', ', array_keys($models)) . ")");
     array_push($results, "cells(" . implode(', ', array_keys($cells)) . ")");
     array_push($results, "controllers(" . implode(', ', array_keys($controllers)) . ")");
     return $results;
 }
Пример #2
0
$temp_path = BASEPATH . 'cmd/templates/create/';
//       file     type         name              action
// =============================================================
// php   create   controller   controller_name   [site | admin | delay]
// php   create   model        model_name        [[(-p | -pic) column_name1, column_name2...] | [(-f | -file) column_name1, column_name2...]]
// php   create   migration    table_name        [(-a | -add) | (-e | -edit) | (-d | -delete | -del | -drop)]
// php   create   cell         cell_name         [method_name1, method_name2...]
// php   create   demo
// php   create   search       search_name
$file = array_shift($argv);
$type = array_shift($argv);
$name = array_shift($argv);
$action = !in_array(strtolower($type), array('model')) ? array_shift($argv) : $argv;
switch (strtolower($type)) {
    case 'controller':
        $results = create_controller($temp_path, $name, $action);
        break;
    case 'model':
        $params = params($action, array('-p', '-f', '-pic', '-file'));
        $images = array_merge($images = isset($params['-p']) ? $params['-p'] : array(), isset($params['-pic']) ? $params['-pic'] : array());
        $files = array_merge($files = isset($params['-f']) ? $params['-f'] : array(), isset($params['-file']) ? $params['-file'] : array());
        $results = create_model($temp_path, $name, $images, $files);
        break;
    case 'migration':
        $results = create_migration($temp_path, $name, $action);
        break;
    case 'cell':
        $results = create_cell($temp_path, $name, array_merge(array($action), $argv));
        break;
    case 'demo':
        include 'functions/demo.php';
Пример #3
0
function create_crude($name, $empty)
{
    create_controller($name, $empty);
    create_model($name);
    create_routing($name);
    create_tables();
    echo "Crud " . $name . " created with success\n";
}
Пример #4
0
    $query_for_column = "DESCRIBE  {$table_name}";
    // find the column name from selected table
    $result_for_table_column = mysql_query($query_for_column);
    if (!$result_for_table_column) {
        echo "DB Error, could not list columns\n";
        echo 'MySQL Error: ' . mysql_error();
        die;
    }
    while ($columns = mysql_fetch_row($result_for_table_column)) {
        //print_r($columns);
        array_push($arr, $columns);
    }
    $table_name_to_class = create_table_to_class_name($table_name);
    create_model($arr, $table_name, $table_name_to_class);
    create_view($arr, $table_name, $table_name_to_class);
    create_controller($arr, $table_name, $table_name_to_class);
    create_route_file($arr, $table_name, $table_name_to_class);
    create_language_file($arr, $table_name, $table_name_to_class);
}
//print_r($arr[0]);die();
/* $sql = "DROP TABLE $table_name";
$retval = mysql_query( $sql );
if(! $retval )
{
  die('Could not delete table: ' . mysql_error());
}
else
	echo "Table deleted successfully\n"; */
function create_route_file($arr, $table_name, $table_name_to_class)
{
    $file = fopen("data/application/route_file.php", "a");