⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bake.php.svn-base

📁 j2me is based on j2mepolish, client & server for mobile application. server part
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
#!/usr/bin/php -q<?php/* SVN FILE: $Id: bake.php 4202 2006-12-25 12:06:13Z phpnut $ *//** * Command-line code generation utility to automate programmer chores. * * Bake is CakePHP's code generation script, which can help you kickstart * application development by writing fully functional skeleton controllers, * models, and views. Going further, Bake can also write Unit Tests for you. * * PHP versions 4 and 5 * * CakePHP :  Rapid Development Framework <http://www.cakephp.org/> * Copyright (c)	2005, Cake Software Foundation, Inc. *								1785 E. Sahara Avenue, Suite 490-204 *								Las Vegas, Nevada 89104 * * Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * * @filesource * @copyright		Copyright (c) 2005, Cake Software Foundation, Inc. * @link				http://www.cakefoundation.org/projects/info/cakephp CakePHP Project * @package			cake * @subpackage		cake.cake.scripts.bake * @since			CakePHP v 0.10.0.1232 * @version			$Revision: 4202 $ * @modifiedby		$LastChangedBy: phpnut $ * @lastmodified	$Date: 2006-12-25 06:06:13 -0600 (Mon, 25 Dec 2006) $ * @license			http://www.opensource.org/licenses/mit-license.php The MIT License */	define ('DS', DIRECTORY_SEPARATOR);	if (function_exists('ini_set')) {		ini_set('display_errors', '1');		ini_set('error_reporting', '7');	}	$app = null;	$root = dirname(dirname(dirname(__FILE__)));	$core = null;	$here = $argv[0];	$help = null;	$project = null;	for ($i = 1; $i < count($argv); $i += 2) {		switch ($argv[$i]) {			case '-a':			case '-app':				$app = $argv[$i + 1];			break;			case '-c':			case '-core':				$core = $argv[$i + 1];			break;			case '-r':			case '-root':				$root = $argv[$i + 1];			break;			case '-h':			case '-help':				$help = true;			break;			case '-p':			case '-project':				$project = true;				$projectPath = $argv[$i + 1];				$app = $argv[$i + 1];			break;		}	}	if(!$app && isset($argv[1])) {		$app = $argv[1];	} elseif(!$app) {		$app = 'app';	}	if(!is_dir($app)) {		$project = true;		$projectPath = $app;	}	if($project) {		$app = $projectPath;	}	$shortPath = str_replace($root, '', $app);	$shortPath = str_replace('..'.DS, '', $shortPath);	$shortPath = str_replace(DS.DS, DS, $shortPath);	$pathArray = explode(DS, $shortPath);	if(end($pathArray) != '') {		$appDir = array_pop($pathArray);	} else {		array_pop($pathArray);		$appDir = array_pop($pathArray);	}	$rootDir = implode(DS, $pathArray);	$rootDir = str_replace(DS.DS, DS, $rootDir);	if(!$rootDir) {		$rootDir = $root;		$projectPath = $root.DS.$appDir;	}	define ('ROOT', $rootDir);	define ('APP_DIR', $appDir);	define ('DEBUG', 1);		if(!empty($core)){		define('CAKE_CORE_INCLUDE_PATH', dirname($core));	}else{		define('CAKE_CORE_INCLUDE_PATH', $root);       	}	if(function_exists('ini_set')) {		ini_set('include_path',ini_get('include_path').													PATH_SEPARATOR.CAKE_CORE_INCLUDE_PATH.DS.													PATH_SEPARATOR.ROOT.DS.APP_DIR.DS);		define('APP_PATH', null);		define('CORE_PATH', null);	} else {		define('APP_PATH', ROOT . DS . APP_DIR . DS);		define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);	}	require_once (CORE_PATH.'cake'.DS.'basics.php');	require_once (CORE_PATH.'cake'.DS.'config'.DS.'paths.php');	require_once (CORE_PATH.'cake'.DS.'dispatcher.php');	require_once (CORE_PATH.'cake'.DS.'scripts'.DS.'templates'.DS.'skel'.DS.'config'.DS.'core.php');	uses ('inflector', 'model'.DS.'model');	require_once (CORE_PATH.'cake'.DS.'app_model.php');	require_once (CORE_PATH.'cake'.DS.'app_controller.php');	uses ('neat_array', 'model'.DS.'connection_manager', 'controller'.DS.'controller', 'session',			'configure', 'security', DS.'controller'.DS.'scaffold');	$pattyCake = new Bake();	if($help === true)	{		$pattyCake->help();		exit();	}	if($project === true)	{		$pattyCake->project($projectPath);		exit();	}	$pattyCake->main();/** * Bake is a command-line code generation utility for automating programmer chores. * * @package		cake * @subpackage	cake.cake.scripts */class Bake {/** * Standard input stream. * * @var filehandle */	var $stdin;/** * Standard output stream. * * @var filehandle */	var $stdout;/** * Standard error stream. * * @var filehandle */	var $stderr;/** * Associated controller name. * * @var string */	var $controllerName = null;/** * If true, Bake will ask for permission to perform actions. * * @var boolean */	var $interactive = false;	var $__modelAlias = false;/** * Private helper function for constructor * @access private */	function __construct() {		$this->stdin = fopen('php://stdin', 'r');		$this->stdout = fopen('php://stdout', 'w');		$this->stderr = fopen('php://stderr', 'w');		$this->welcome();	}/** * Constructor. * * @return Bake */	function Bake() {		return $this->__construct();	}/** * Main-loop method. * */	function main() {		$this->stdout('');		$this->stdout('');		$this->stdout('Baking...');		$this->hr();		$this->stdout('Name: '. APP_DIR);		$this->stdout('Path: '. ROOT.DS.APP_DIR);		$this->hr();		if(!file_exists(CONFIGS.'database.php')) {			$this->stdout('');			$this->stdout('Your database configuration was not found. Take a moment to create one:');			$this->doDbConfig();		}		require_once (CONFIGS.'database.php');		$this->stdout('[M]odel');		$this->stdout('[C]ontroller');		$this->stdout('[V]iew');		$invalidSelection = true;		while ($invalidSelection) {			$classToBake = strtoupper($this->getInput('What would you like to Bake?', array('M', 'V', 'C')));			switch($classToBake) {				case 'M':					$invalidSelection = false;					$this->doModel();					break;				case 'V':					$invalidSelection = false;					$this->doView();					break;				case 'C':					$invalidSelection = false;					$this->doController();					break;				default:					$this->stdout('You have made an invalid selection. Please choose a type of class to Bake by entering M, V, or C.');			}		}	}/** * Database configuration setup. * */	function doDbConfig() {		$this->hr();		$this->stdout('Database Configuration:');		$this->hr();		$driver = '';		while ($driver == '') {			$driver = $this->getInput('What database driver would you like to use?', array('mysql','mysqli','mssql','sqlite','postgres', 'odbc'), 'mysql');			if ($driver == '') {				$this->stdout('The database driver supplied was empty. Please supply a database driver.');			}		}		switch($driver) {			case 'mysql':			$connect = 'mysql_connect';			break;			case 'mysqli':			$connect = 'mysqli_connect';			break;			case 'mssql':			$connect = 'mssql_connect';			break;			case 'sqlite':			$connect = 'sqlite_open';			break;			case 'postgres':			$connect = 'pg_connect';			break;			case 'odbc':			$connect = 'odbc_connect';			break;			default:			$this->stdout('The connection parameter could not be set.');			break;		}		$host = '';		while ($host == '') {			$host = $this->getInput('What is the hostname for the database server?', null, 'localhost');			if ($host == '') {				$this->stdout('The host name you supplied was empty. Please supply a hostname.');			}		}		$login = '';		while ($login == '') {			$login = $this->getInput('What is the database username?', null, 'root');			if ($login == '') {				$this->stdout('The database username you supplied was empty. Please try again.');			}		}		$password = '';		$blankPassword = false;		while ($password == '' && $blankPassword == false) {			$password = $this->getInput('What is the database password?');			if ($password == '') {				$blank = $this->getInput('The password you supplied was empty. Use an empty password?', array('y', 'n'), 'n');				if($blank == 'y')				{					$blankPassword = true;				}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -