/** * Make the field headers for the admin view. */ function make_fields_header($fields) { $out = ''; $limit = count($fields) > 3 ? 3 : count($fields); if ($limit === 1) { $width = 84; } elseif ($limit === 2) { $width = 42; } else { $width = 28; } for ($i = 0; $i < $limit; $i++) { $out .= sprintf("\t\t<th width=\"%d%%\">{\" %s \"}</th>\n", $width, cli\Filter::label($fields[$i]->name)); } return $out; }
$fields[$k]->comma = ''; } } $data = array('appname' => $name, 'plural' => $plural, 'fields' => $fields, 'pkey' => $pkey, 'open_tag' => '<?php', 'close_tag' => '?>', 'backslash' => '\\'); mkdir('apps/' . $plural . '/conf', 0755, true); mkdir('apps/' . $plural . '/forms', 0755, true); mkdir('apps/' . $plural . '/handlers', 0755, true); mkdir('apps/' . $plural . '/lib', 0755, true); mkdir('apps/' . $plural . '/models', 0755, true); mkdir('apps/' . $plural . '/views', 0755, true); require_once 'apps/cli/lib/CRUDHelpers.php'; file_put_contents('apps/' . $plural . '/conf/config.php', $tpl->render('cli/crud-app/config', $data)); file_put_contents('apps/' . $plural . '/conf/acl.php', $tpl->render('cli/crud-app/acl', $data)); file_put_contents('apps/' . $plural . '/conf/install_mysql.sql', $tpl->render('cli/crud-app/install_mysql', $data)); file_put_contents('apps/' . $plural . '/conf/install_pgsql.sql', $tpl->render('cli/crud-app/install_pgsql', $data)); file_put_contents('apps/' . $plural . '/conf/install_sqlite.sql', $tpl->render('cli/crud-app/install_sqlite', $data)); file_put_contents('apps/' . $plural . '/forms/add.php', $tpl->render('cli/crud-app/add_form', $data)); file_put_contents('apps/' . $plural . '/forms/edit.php', $tpl->render('cli/crud-app/edit_form', $data)); file_put_contents('apps/' . $plural . '/models/' . cli\Filter::camel($name) . '.php', $tpl->render('cli/crud-app/model', $data)); file_put_contents('apps/' . $plural . '/handlers/admin.php', $tpl->render('cli/crud-app/admin_handler', $data)); file_put_contents('apps/' . $plural . '/handlers/index.php', $tpl->render('cli/crud-app/index_handler', $data)); file_put_contents('apps/' . $plural . '/handlers/add.php', $tpl->render('cli/crud-app/add_handler', $data)); file_put_contents('apps/' . $plural . '/handlers/edit.php', $tpl->render('cli/crud-app/edit_handler', $data)); file_put_contents('apps/' . $plural . '/handlers/delete.php', $tpl->render('cli/crud-app/delete_handler', $data)); file_put_contents('apps/' . $plural . '/handlers/install.php', $tpl->render('cli/crud-app/install_handler', $data)); file_put_contents('apps/' . $plural . '/handlers/upgrade.php', $tpl->render('cli/crud-app/upgrade_handler', $data)); file_put_contents('apps/' . $plural . '/views/index.html', $tpl->render('cli/crud-app/index_view', $data)); file_put_contents('apps/' . $plural . '/views/add.html', $tpl->render('cli/crud-app/add_view', $data)); file_put_contents('apps/' . $plural . '/views/edit.html', $tpl->render('cli/crud-app/edit_view', $data)); file_put_contents('apps/' . $plural . '/views/admin.html', $tpl->render('cli/crud-app/admin_view', $data)); Cli::out('App created in apps/' . $plural, 'success');