diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2012-08-02 11:09:40 +0000 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2012-08-02 11:09:40 +0000 |
commit | 6dfd5d507d9863f987b30b0a5ab4268aea2ed875 (patch) | |
tree | 9c3de66b4aaa1e6bfa3c6442d807ec70bc479d11 /poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts | |
parent | f4792ba1a7785220fef5adb1cb3e7ce8ac40152f (diff) | |
download | 2012-php-weave-6dfd5d507d9863f987b30b0a5ab4268aea2ed875.tar.gz 2012-php-weave-6dfd5d507d9863f987b30b0a5ab4268aea2ed875.tar.bz2 2012-php-weave-6dfd5d507d9863f987b30b0a5ab4268aea2ed875.zip |
J'étais parti sur un download pourri de Cake. Les gars on abusé sur GitHub.
git-svn-id: file:///var/svn/2012-php-weave/trunk@7 d972a294-176a-4cf9-8ea1-fcd5b0c30f5c
Diffstat (limited to 'poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts')
26 files changed, 0 insertions, 4822 deletions
diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/acl.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/acl.php deleted file mode 100644 index b4c7669..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/acl.php +++ /dev/null @@ -1,853 +0,0 @@ -#!/usr/bin/php -q -<?php -/* SVN FILE: $Id: acl.php 6305 2008-01-02 02:33:56Z phpnut $ */ -/** - * Short description for file. - * - * Long description for file - * - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.scripts - * @since CakePHP(tm) v 0.10.0.1232 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -/** - * Enter description here... - */ - define ('DS', DIRECTORY_SEPARATOR); - if (function_exists('ini_set')) { - ini_set('display_errors', '1'); - ini_set('error_reporting', '7'); - ini_set('max_execution_time',0); - } - - $app = 'app'; - $core = null; - $root = dirname(dirname(dirname(__FILE__))); - $here = $argv[0]; - $dataSource = 'default'; - $unset = array(); - for ($i = 1; $i < count($argv); $i++) { - // Process command-line modifiers here - switch (strtolower($argv[$i])) { - case '-app': - $app = $argv[$i + 1]; - $unset[$i] = $argv[$i]; - $unset[$i + 1] = $argv[$i + 1]; - break; - case '-core': - $core = $argv[$i + 1]; - $unset[$i] = $argv[$i]; - $unset[$i + 1] = $argv[$i + 1]; - break; - case '-root': - $root = $argv[$i + 1]; - $unset[$i] = $argv[$i]; - $unset[$i + 1] = $argv[$i + 1]; - break; - case '-datasource': - $dataSource = $argv[$i + 1]; - $unset[$i] = $argv[$i]; - $unset[$i + 1] = $argv[$i + 1]; - break; - } - } - - if (strlen($app) && $app[0] == DS) { - $cnt = substr_count($root, DS); - $app = str_repeat('..' . DS, $cnt) . $app; - } - define ('ROOT', $root.DS); - define ('APP_DIR', $app); - define ('DEBUG', 1);; - define('CAKE_CORE_INCLUDE_PATH', ROOT); - define('DATASOURCE', $dataSource); - - if (function_exists('ini_set')) { - ini_set('include_path',ini_get('include_path'). - PATH_SEPARATOR.CAKE_CORE_INCLUDE_PATH.DS. - PATH_SEPARATOR.CORE_PATH.DS. - PATH_SEPARATOR.ROOT.DS.APP_DIR.DS. - PATH_SEPARATOR.APP_DIR.DS. - PATH_SEPARATOR.APP_PATH); - 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 ('cake'.DS.'basics.php'); - require ('cake'.DS.'config'.DS.'paths.php'); - require (CONFIGS.'core.php'); - uses ('object', 'configure', 'neat_array', 'session', 'security', 'inflector', 'model'.DS.'connection_manager', - 'model'.DS.'datasources'.DS.'dbo_source', 'model'.DS.'model'); - require(CAKE.'app_model.php'); - uses ('controller'.DS.'components'.DS.'acl', 'controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aclnode', - 'controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aco', 'controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'acoaction', - 'controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aro'); - //Get and format args: first arg is the name of the script. - $serverArgs = $argv; - if (!empty($unset)) { - $serverArgs = array_values(array_diff($argv, $unset)); - } - - $wasted = array_shift($serverArgs); - $command = array_shift($serverArgs); - $args = $serverArgs; - $aclCLI = new AclCLI ($command, $args); -/** - * @package cake - * @subpackage cake.cake.scritps - */ -class AclCLI { -/** - * Enter description here... - * - * @var unknown_type - */ - var $stdin; -/** - * Enter description here... - * - * @var unknown_type - */ - var $stdout; -/** - * Enter description here... - * - * @var unknown_type - */ - var $stderr; -/** - * Enter description here... - * - * @var unknown_type - */ - var $acl; -/** - * Enter description here... - * - * @var unknown_type - */ - var $args; -/** - * Enter description here... - * - * @var unknown_type - */ - var $dataSource = 'default'; -/** - * Enter description here... - * - * @param unknown_type $command - * @param unknown_type $args - * @return AclCLI - */ - function AclCLI($command, $args) { - $this->__construct($command, $args); - } -/** - * Enter description here... - * - * @param unknown_type $command - * @param unknown_type $args - */ - function __construct ($command, $args) { - $this->stdin = fopen('php://stdin', 'r'); - $this->stdout = fopen('php://stdout', 'w'); - $this->stderr = fopen('php://stderr', 'w'); - - if (ACL_CLASSNAME != 'DB_ACL') { - $out = "--------------------------------------------------\n"; - $out .= "Error: Your current Cake configuration is set to \n"; - $out .= "an ACL implementation other than DB. Please change \n"; - $out .= "your core config to reflect your decision to use \n"; - $out .= "DB_ACL before attempting to use this script.\n"; - $out .= "--------------------------------------------------\n"; - $out .= "Current ACL Classname: " . ACL_CLASSNAME . "\n"; - $out .= "--------------------------------------------------\n"; - fwrite($this->stderr, $out); - exit(); - } - - if (!in_array($command, array('help'))) { - if (!file_exists(CONFIGS.'database.php')) { - $this->stdout(''); - $this->stdout('Your database configuration was not found.'); - $this->stdout('Take a moment to create one:'); - $this->doDbConfig(); - } - require_once (CONFIGS.'database.php'); - - if (!in_array($command, array('initdb'))) { - $this->dataSource = DATASOURCE; - $this->Acl = new AclComponent(); - $this->args = $args; - $this->db =& ConnectionManager::getDataSource($this->dataSource); - } - } - - switch ($command) { - case 'create': - $this->create(); - break; - case 'delete': - $this->delete(); - break; - case 'setParent': - $this->setParent(); - break; - case 'getPath': - $this->getPath(); - break; - case 'grant': - $this->grant(); - break; - case 'deny': - $this->deny(); - break; - case 'inherit': - $this->inherit(); - break; - case 'view': - $this->view(); - break; - case 'initdb': - $this->initdb(); - break; - case 'upgrade': - $this->upgradedb(); - break; - case 'help': - $this->help(); - break; - default: - fwrite($this->stderr, "Unknown ACL command '$command'.\nFor usage, try 'php acl.php help'.\n\n"); - break; - } - } -/** - * Enter description here... - * - */ - function create() { - $this->checkArgNumber(4, 'create'); - $this->checkNodeType(); - extract($this->__dataVars()); - - $parent = (is_numeric($this->args[2])) ? intval($this->args[2]) : $this->args[2]; - if (!$this->Acl->{$class}->create(intval($this->args[1]), $parent, $this->args[3])) { - $this->displayError("Parent Node Not Found", "There was an error creating the ".$class.", probably couldn't find the parent node.\n If you wish to create a new root node, specify the <parent_id> as '0'."); - } - $this->stdout("New $class '".$this->args[3]."' created.\n\n"); - } -/** - * Enter description here... - * - */ - function delete() { - $this->checkArgNumber(2, 'delete'); - $this->checkNodeType(); - extract($this->__dataVars()); - if (!$this->Acl->{$class}->delete($this->args[1])) { - $this->displayError("Node Not Deleted", "There was an error deleting the ".$class.". Check that the node exists.\n"); - } - $this->stdout("{$class} deleted.\n\n"); - } - -/** - * Enter description here... - * - */ - function setParent() { - $this->checkArgNumber(3, 'setParent'); - $this->checkNodeType(); - extract($this->__dataVars()); - if (!$this->Acl->{$class}->setParent($this->args[2], $this->args[1])) { - $this->stdout("Error in setting new parent. Please make sure the parent node exists, and is not a descendant of the node specified.\n"); - } else { - $this->stdout("Node parent set to ".$this->args[2]."\n\n"); - } - } -/** - * Enter description here... - * - */ - function getPath() { - $this->checkArgNumber(2, 'getPath'); - $this->checkNodeType(); - extract($this->__dataVars()); - $id = (is_numeric($this->args[2])) ? intval($this->args[1]) : $this->args[1]; - $nodes = $this->Acl->{$class}->getPath($id); - if (empty($nodes)) { - $this->displayError("Supplied Node '".$this->args[1]."' not found", "No tree returned."); - } - for ($i = 0; $i < count($nodes); $i++) { - $this->stdout(str_repeat(' ', $i) . "[" . $nodes[$i][$class]['id'] . "]" . $nodes[$i][$class]['alias'] . "\n"); - } - } -/** - * Enter description here... - * - */ - function grant() { - $this->checkArgNumber(3, 'grant'); - //add existence checks for nodes involved - $aro = $this->args[0]; - if (is_numeric($aro)) { - $aro = intval($aro); - } - $aco = $this->args[1]; - if (is_numeric($aco)) { - $aco = intval($aco); - } - if ($this->Acl->allow($aro, $aco, $this->args[2])) { - $this->stdout("Permission granted.\n"); - } else { - $this->stdout("Permission could not be granted.\n"); - } - } -/** - * Enter description here... - * - */ - function deny() { - $this->checkArgNumber(3, 'deny'); - //add existence checks for nodes involved - $aro = (is_numeric($this->args[0])) ? intval($this->args[0]) : $this->args[0]; - $aco = (is_numeric($this->args[1])) ? intval($this->args[1]) : $this->args[1]; - $aro = $this->args[0]; - if (is_numeric($aro)) { - $aro = intval($aro); - } - $aco = $this->args[1]; - if (is_numeric($aco)) { - $aco = intval($aco); - } - if ($this->Acl->deny($aro, $aco, $this->args[2])) { - $this->stdout("Permission denied.\n"); - } else { - $this->stdout("Permission could not be denied.\n"); - } - } -/** - * Enter description here... - * - */ - function inherit() { - $this->checkArgNumber(3, 'inherit'); - $aro = $this->args[0]; - if (is_numeric($aro)) { - $aro = intval($aro); - } - $aco = $this->args[1]; - if (is_numeric($aco)) { - $aco = intval($aco); - } - if ($this->Acl->inherit($aro, $aco, $this->args[2])) { - $this->stdout("Permission inherited.\n"); - } else { - $this->stdout("Permission could not be inherited.\n"); - } - } -/** - * Enter description here... - * - */ - function view() { - $this->checkArgNumber(1, 'view'); - $this->checkNodeType(); - extract($this->__dataVars()); - if (!is_null($this->args[1])) { - $conditions = $this->Acl->{$class}->_resolveID($this->args[1]); - } else { - $conditions = null; - } - $nodes = $this->Acl->{$class}->findAll($conditions, null, 'lft ASC'); - if (empty($nodes)) { - $this->displayError($this->args[1]." not found", "No tree returned."); - } - $right = array(); - - $this->stdout($class . " tree:\n"); - $this->stdout("------------------------------------------------\n"); - - for ($i = 0; $i < count($nodes); $i++) { - if (count($right) > 0) { - while ($right[count($right)-1] < $nodes[$i][$class]['rght']) { - if ($right[count($right)-1]) { - array_pop($right); - } else { - break; - } - } - } - $this->stdout(str_repeat(' ',count($right)) . "[" . $nodes[$i][$class]['id'] . "]" . $nodes[$i][$class]['alias']."\n"); - $right[] = $nodes[$i][$class]['rght']; - } - $this->stdout("------------------------------------------------\n"); - } -/** - * Enter description here... - * - */ - function initdb() { - $db =& ConnectionManager::getDataSource($this->dataSource); - $this->stdout("Initializing Database...\n"); - $this->stdout("Creating access control objects table (acos)...\n"); - $sql = " CREATE TABLE ".$db->fullTableName('acos')." ( - ".$db->name('id')." ".$db->column($db->columns['primary_key']).", - ".$db->name('object_id')." ".$db->column($db->columns['integer'])." default NULL, - ".$db->name('alias')." ".$db->column($db->columns['string'])." NOT NULL default '', - ".$db->name('lft')." ".$db->column($db->columns['integer'])." default NULL, - ".$db->name('rght')." ".$db->column($db->columns['integer'])." default NULL, - PRIMARY KEY (".$db->name('id').") - );"; - if ($db->query($sql) === false) { - die("Error: " . $db->lastError() . "\n\n"); - } - - $this->stdout("Creating access request objects table (aros)...\n"); - $sql2 = "CREATE TABLE ".$db->fullTableName('aros')." ( - ".$db->name('id')." ".$db->column($db->columns['primary_key']).", - ".$db->name('foreign_key')." ".$db->column($db->columns['integer'])." default NULL, - ".$db->name('alias')." ".$db->column($db->columns['string'])." NOT NULL default '', - ".$db->name('lft')." ".$db->column($db->columns['integer'])." default NULL, - ".$db->name('rght')." ".$db->column($db->columns['integer'])." default NULL, - PRIMARY KEY (".$db->name('id').") - );"; - if ($db->query($sql2) === false) { - die("Error: " . $db->lastError() . "\n\n"); - } - - $this->stdout("Creating relationships table (aros_acos)...\n"); - $sql3 = "CREATE TABLE ".$db->fullTableName('aros_acos')." ( - ".$db->name('id')." ".$db->column($db->columns['primary_key']).", - ".$db->name('aro_id')." ".$db->column($db->columns['integer'])." default NULL, - ".$db->name('aco_id')." ".$db->column($db->columns['integer'])." default NULL, - ".$db->name('_create')." ".$db->column($db->columns['integer'])." NOT NULL default '0', - ".$db->name('_read')." ".$db->column($db->columns['integer'])." NOT NULL default '0', - ".$db->name('_update')." ".$db->column($db->columns['integer'])." NOT NULL default '0', - ".$db->name('_delete')." ".$db->column($db->columns['integer'])." NOT NULL default '0', - PRIMARY KEY (".$db->name('id').") - );"; - if ($db->query($sql3) === false) { - die("Error: " . $db->lastError() . "\n\n"); - } - - $this->stdout("\nDone.\n"); - } - -/** - * Enter description here... - * - */ - function upgradedb() { - $db =& ConnectionManager::getDataSource($this->dataSource); - $this->stdout("Initializing Database...\n"); - $this->stdout("Upgrading table (aros)...\n"); - $sql = "ALTER TABLE ".$db->fullTableName('aros')." - CHANGE ".$db->name('user_id')." - ".$db->name('foreign_key')." - INT( 10 ) UNSIGNED NULL DEFAULT NULL;"; - $sql .= "ALTER TABLE " . $db->name('aros_acos') . " CHANGE " . $db->name('_create') - . " " . $db->name('_create') . " CHAR(2) NOT NULL DEFAULT '0';"; - $sql .= "ALTER TABLE " . $db->name('aros_acos') . " CHANGE " . $db->name('_update') - . " " . $db->name('_update') . " CHAR(2) NOT NULL DEFAULT '0';"; - $sql .= "ALTER TABLE " . $db->name('aros_acos') . " CHANGE " . $db->name('_read') - . " " . $db->name('_read') . " CHAR(2) NOT NULL DEFAULT '0';"; - $sql .= "ALTER TABLE " . $db->name('aros_acos') . " CHANGE " . $db->name('_delete') - . " " . $db->name('_delete') . " CHAR(2) NOT NULL DEFAULT '0';"; - if ($db->query($sql) === false) { - die("Error: " . $db->lastError() . "\n\n"); - } - $this->stdout("\nDatabase upgrade is complete.\n"); - } - -/** - * Enter description here... - * - */ - function help() { - $out = "Usage: php acl.php <command> <arg1> <arg2>...\n"; - $out .= "-----------------------------------------------\n"; - $out .= "Commands:\n"; - $out .= "\n"; - $out .= "\tcreate aro|aco <link_id> <parent_id> <alias>\n"; - $out .= "\t\tCreates a new ACL object under the parent specified by <parent_id>, an id/alias (see\n"; - $out .= "\t\t'view'). The link_id allows you to link a user object to Cake's\n"; - $out .= "\t\tACL structures. The alias parameter allows you to address your object\n"; - $out .= "\t\tusing a non-integer ID. Example: \"\$php acl.php create aro 57 0 John\"\n"; - $out .= "\t\twould create a new ARO object at the root of the tree, linked to 57\n"; - $out .= "\t\tin your users table, with an internal alias 'John'."; - $out .= "\n"; - $out .= "\n"; - $out .= "\tdelete aro|aco <id>\n"; - $out .= "\t\tDeletes the ACL object with the specified ID (see 'view').\n"; - $out .= "\n"; - $out .= "\n"; - $out .= "\tsetParent aro|aco <id> <parent_id>\n"; - $out .= "\t\tUsed to set the parent of the ACL object specified by <id> to the ID\n"; - $out .= "\t\tspecified by <parent_id>.\n"; - $out .= "\n"; - $out .= "\n"; - $out .= "\tgetPath aro|aco <id>\n"; - $out .= "\t\tReturns the path to the ACL object specified by <id>. This command is\n"; - $out .= "\t\tis useful in determining the inhertiance of permissions for a certain\n"; - $out .= "\t\tobject in the tree.\n"; - $out .= "\n"; - $out .= "\n"; - $out .= "\tgrant <Aro.alias|Aro.foreign_key> <Aco.alias|Aco.object_id> <aco_action>\n"; - $out .= "\t\tUse this command to grant ACL permissions. Once executed, the ARO\n"; - $out .= "\t\tspecified (and its children, if any) will have ALLOW access to the\n"; - $out .= "\t\tspecified ACO action (and the ACO's children, if any).\n"; - $out .= "\t\tIf an integer is passed permissions will be granted based on the foreign_key or object_id.\n"; - $out .= "\n"; - $out .= "\n"; - $out .= "\tdeny <Aro.alias|Aro.foreign_key> <Aco.alias|Aco.object_id> <aco_action>\n"; - $out .= "\t\tUse this command to deny ACL permissions. Once executed, the ARO\n"; - $out .= "\t\tspecified (and its children, if any) will have DENY access to the\n"; - $out .= "\t\tspecified ACO action (and the ACO's children, if any).\n"; - $out .= "\t\tIf an integer is passed permissions will be denied based on the foreign_key or object_id.\n"; - $out .= "\n"; - $out .= "\n"; - $out .= "\tinherit <Aro.alias|Aro.foreign_key> <Aco.alias|Aco.object_id> <aco_action>\n"; - $out .= "\t\tUse this command to force a child ARO object to inherit its\n"; - $out .= "\t\tpermissions settings from its parent.\n"; - $out .= "\t\tIf an integer is passed permissions will be inherited based on the foreign_key or object_id.\n"; - $out .= "\n"; - $out .= "\n"; - $out .= "\tview aro|aco [id]\n"; - $out .= "\t\tThe view command will return the ARO or ACO tree. The optional\n"; - $out .= "\t\tid/alias parameter allows you to return only a portion of the requested\n"; - $out .= "\t\ttree.\n"; - $out .= "\n"; - $out .= "\n"; - $out .= "\tinitdb\n"; - $out .= "\t\tUse this command to create the database tables needed to use DB ACL.\n"; - $out .= "\n"; - $out .= "\n"; - $out .= "\thelp\n"; - $out .= "\t\tDisplays this help message.\n"; - $out .= "\n"; - $out .= "\n"; - $this->stdout($out); - } -/** - * Enter description here... - * - * @param unknown_type $title - * @param unknown_type $msg - */ - function displayError($title, $msg) { - $out = "\n"; - $out .= "Error: $title\n"; - $out .= "$msg\n"; - $out .= "\n"; - $this->stdout($out); - exit(); - } - -/** - * Enter description here... - * - * @param unknown_type $expectedNum - * @param unknown_type $command - */ - function checkArgNumber($expectedNum, $command) { - if (count($this->args) < $expectedNum) { - $this->displayError('Wrong number of parameters: '.count($this->args), 'Please type \'php acl.php help\' for help on usage of the '.$command.' command.'); - } - } -/** - * Enter description here... - * - */ - function checkNodeType() { - if ($this->args[0] != 'aco' && $this->args[0] != 'aro') { - $this->displayError("Missing/Unknown node type: '".$this->args[0]."'", 'Please specify which ACL object type you wish to create.'); - } - } -/** - * Enter description here... - * - * @param unknown_type $type - * @param unknown_type $id - * @return unknown - */ - function nodeExists($type, $id) { - //$this->stdout("Check to see if $type with ID = $id exists...\n"); - extract($this->__dataVars($type)); - $conditions = $this->Acl->{$class}->_resolveID($id); - $possibility = $this->Acl->{$class}->findAll($conditions); - return $possibility; - } - -/** - * Enter description here... - * - * @param unknown_type $type - * @return unknown - */ - function __dataVars($type = null) { - if ($type == null) { - $type = $this->args[0]; - } - - $vars = array(); - $class = ucwords($type); - $vars['secondary_id'] = ($class == 'aro' ? 'foreign_key' : 'object_id'); - $vars['data_name'] = $type; - $vars['table_name'] = $type . 's'; - $vars['class'] = $class; - return $vars; - } -/** - * 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; - } - } - } - $database = ''; - - while ($database == '') { - $database = $this->getInput('What is the name of the database you will be using?', null, 'cake'); - - if ($database == '') { - $this->stdout('The database name you supplied was empty. Please try again.'); - } - } - - $prefix = ''; - - while ($prefix == '') { - $prefix = $this->getInput('Enter a table prefix?', null, 'n'); - } - if (low($prefix) == 'n') { - $prefix = ''; - } - - $this->stdout(''); - $this->hr(); - $this->stdout('The following database configuration will be created:'); - $this->hr(); - $this->stdout("Driver: $driver"); - $this->stdout("Connection: $connect"); - $this->stdout("Host: $host"); - $this->stdout("User: $login"); - $this->stdout("Pass: " . str_repeat('*', strlen($password))); - $this->stdout("Database: $database"); - $this->stdout("Table prefix: $prefix"); - $this->hr(); - $looksGood = $this->getInput('Look okay?', array('y', 'n'), 'y'); - - if (low($looksGood) == 'y' || low($looksGood) == 'yes') { - $this->bakeDbConfig($driver, $connect, $host, $login, $password, $database, $prefix); - } else { - $this->stdout('Bake Aborted.'); - } - } -/** - * Creates a database configuration file for Bake. - * - * @param string $host - * @param string $login - * @param string $password - * @param string $database - */ - function bakeDbConfig( $driver, $connect, $host, $login, $password, $database, $prefix) { - $out = "<?php\n"; - $out .= "class DATABASE_CONFIG {\n\n"; - $out .= "\tvar \$default = array(\n"; - $out .= "\t\t'driver' => '{$driver}',\n"; - $out .= "\t\t'connect' => '{$connect}',\n"; - $out .= "\t\t'host' => '{$host}',\n"; - $out .= "\t\t'login' => '{$login}',\n"; - $out .= "\t\t'password' => '{$password}',\n"; - $out .= "\t\t'database' => '{$database}', \n"; - $out .= "\t\t'prefix' => '{$prefix}' \n"; - $out .= "\t);\n"; - $out .= "}\n"; - $out .= "?>"; - $filename = CONFIGS.'database.php'; - $this->__createFile($filename, $out); - } -/** - * Prompts the user for input, and returns it. - * - * @param string $prompt Prompt text. - * @param mixed $options Array or string of options. - * @param string $default Default input value. - * @return Either the default value, or the user-provided input. - */ - function getInput($prompt, $options = null, $default = null) { - if (!is_array($options)) { - $print_options = ''; - } else { - $print_options = '(' . implode('/', $options) . ')'; - } - - if ($default == null) { - $this->stdout(''); - $this->stdout($prompt . " $print_options \n" . '> ', false); - } else { - $this->stdout(''); - $this->stdout($prompt . " $print_options \n" . "[$default] > ", false); - } - $result = trim(fgets($this->stdin)); - - if ($default != null && empty($result)) { - return $default; - } else { - return $result; - } - } -/** - * Outputs to the stdout filehandle. - * - * @param string $string String to output. - * @param boolean $newline If true, the outputs gets an added newline. - */ - function stdout($string, $newline = true) { - if ($newline) { - fwrite($this->stdout, $string . "\n"); - } else { - fwrite($this->stdout, $string); - } - } -/** - * Outputs to the stderr filehandle. - * - * @param string $string Error text to output. - */ - function stderr($string) { - fwrite($this->stderr, $string); - } -/** - * Outputs a series of minus characters to the standard output, acts as a visual separator. - * - */ - function hr() { - $this->stdout('---------------------------------------------------------------'); - } -/** - * Creates a file at given path. - * - * @param string $path Where to put the file. - * @param string $contents Content to put in the file. - * @return Success - */ - function __createFile ($path, $contents) { - $path = str_replace('//', '/', $path); - echo "\nCreating file $path\n"; - if (is_file($path) && $this->interactive === true) { - fwrite($this->stdout, "File exists, overwrite?" . " {$path} (y/n/q):"); - $key = trim(fgets($this->stdin)); - - if ($key=='q') { - fwrite($this->stdout, "Quitting.\n"); - exit; - } elseif ($key == 'a') { - $this->dont_ask = true; - } elseif ($key == 'y') { - } else { - fwrite($this->stdout, "Skip" . " {$path}\n"); - return false; - } - } - - if ($f = fopen($path, 'w')) { - fwrite($f, $contents); - fclose($f); - fwrite($this->stdout, "Wrote" . "{$path}\n"); - return true; - } else { - fwrite($this->stderr, "Error! Could not write to" . " {$path}.\n"); - return false; - } - } -} -?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/bake.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/bake.php deleted file mode 100644 index 2365ee8..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/bake.php +++ /dev/null @@ -1,2635 +0,0 @@ -#!/usr/bin/php -q -<?php -/* SVN FILE: $Id: bake.php 6305 2008-01-02 02:33:56Z 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(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.scripts.bake - * @since CakePHP(tm) v 0.10.0.1232 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @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'); - ini_set('max_execution_time',0); - } - - $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.'scripts'.DS.'templates'.DS.'skel'.DS.'config'.DS.'core.php'); - require_once (CORE_PATH.'cake'.DS.'dispatcher.php'); - uses('object', 'session', 'security', 'configure', 'inflector', 'model'.DS.'connection_manager'); - - $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; - } - } - } - $database = ''; - - while ($database == '') { - $database = $this->getInput('What is the name of the database you will be using?', null, 'cake'); - - if ($database == '') { - $this->stdout('The database name you supplied was empty. Please try again.'); - } - } - - $prefix = ''; - - while ($prefix == '') { - $prefix = $this->getInput('Enter a table prefix?', null, 'n'); - } - if (low($prefix) == 'n') { - $prefix = ''; - } - - $this->stdout(''); - $this->hr(); - $this->stdout('The following database configuration will be created:'); - $this->hr(); - $this->stdout("Driver: $driver"); - $this->stdout("Connection: $connect"); - $this->stdout("Host: $host"); - $this->stdout("User: $login"); - $this->stdout("Pass: " . str_repeat('*', strlen($password))); - $this->stdout("Database: $database"); - $this->stdout("Table prefix: $prefix"); - $this->hr(); - $looksGood = $this->getInput('Look okay?', array('y', 'n'), 'y'); - - if (low($looksGood) == 'y' || low($looksGood) == 'yes') { - $this->bakeDbConfig($driver, $connect, $host, $login, $password, $database, $prefix); - } else { - $this->stdout('Bake Aborted.'); - } - } -/** - * Action to create a Model. - * - */ - function doModel() - { - $this->hr(); - $this->stdout('Model Bake:'); - $this->hr(); - $this->interactive = true; - - $useTable = null; - $primaryKey = 'id'; - $validate = array(); - $associations = array(); - $useDbConfig = 'default'; - $this->__doList($useDbConfig); - - - $enteredModel = ''; - - while ($enteredModel == '') { - $enteredModel = $this->getInput('Enter a number from the list above, or type in the name of another model.'); - - if ($enteredModel == '' || intval($enteredModel) > count($this->__modelNames)) { - $this->stdout('Error:'); - $this->stdout("The model name you supplied was empty, or the number \nyou selected was not an option. Please try again."); - $enteredModel = ''; - } - } - - if (intval($enteredModel) > 0 && intval($enteredModel) <= count($this->__modelNames)) { - $currentModelName = $this->__modelNames[intval($enteredModel) - 1]; - } else { - $currentModelName = $enteredModel; - } - - $db =& ConnectionManager::getDataSource($useDbConfig); - - $useTable = Inflector::tableize($currentModelName); - $fullTableName = $db->fullTableName($useTable, false); - if (array_search($useTable, $this->__tables) === false) { - $this->stdout("\nGiven your model named '$currentModelName', Cake would expect a database table named '" . $fullTableName . "'."); - $tableIsGood = $this->getInput('do you want to use this table?', array('y','n'), 'y'); - } - - if (low($tableIsGood) == 'n' || low($tableIsGood) == 'no') { - $useTable = $this->getInput('What is the name of the table (enter "null" to use NO table)?'); - } - $tableIsGood = false; - while ($tableIsGood == false && low($useTable) != 'null') { - if (is_array($this->__tables) && !in_array($useTable, $this->__tables)) { - $fullTableName = $db->fullTableName($useTable, false); - $this->stdout($fullTableName . ' does not exist.'); - $useTable = $this->getInput('What is the name of the table (enter "null" to use NO table)?'); - $tableIsGood = false; - } else { - $tableIsGood = true; - } - } - $wannaDoValidation = $this->getInput('Would you like to supply validation criteria for the fields in your model?', array('y','n'), 'y'); - - if (in_array($useTable, $this->__tables)) { - loadModel(); - $tempModel = new Model(false, $useTable); - $modelFields = $db->describe($tempModel); - - if (!array_key_exists('id', $modelFields)) { - foreach ($modelFields as $name => $field) { - break; - } - $primaryKey = $this->getInput('What is the primaryKey?', null, $name); - } - } - $validate = array(); - - if (array_search($useTable, $this->__tables) !== false && (low($wannaDoValidation) == 'y' || low($wannaDoValidation) == 'yes')) { - foreach ($modelFields as $name => $field) { - $this->stdout(''); - $prompt = 'Name: ' . $name . "\n"; - $prompt .= 'Type: ' . $field['type'] . "\n"; - $prompt .= '---------------------------------------------------------------'."\n"; - $prompt .= 'Please select one of the following validation options:'."\n"; - $prompt .= '---------------------------------------------------------------'."\n"; - $prompt .= "1- VALID_NOT_EMPTY\n"; - $prompt .= "2- VALID_EMAIL\n"; - $prompt .= "3- VALID_NUMBER\n"; - $prompt .= "4- VALID_YEAR\n"; - $prompt .= "5- Do not do any validation on this field.\n\n"; - $prompt .= "... or enter in a valid regex validation string.\n\n"; - - if ($field['null'] == 1 || $name == $primaryKey || $name == 'created' || $name == 'modified') { - $validation = $this->getInput($prompt, null, '5'); - } else { - $validation = $this->getInput($prompt, null, '1'); - } - - switch ($validation) { - case '1': - $validate[$name] = 'VALID_NOT_EMPTY'; - break; - case '2': - $validate[$name] = 'VALID_EMAIL'; - break; - case '3': - $validate[$name] = 'VALID_NUMBER'; - break; - case '4': - $validate[$name] = 'VALID_YEAR'; - break; - case '5': - break; - default: - $validate[$name] = $validation; - break; - } - } - } - - $wannaDoAssoc = $this->getInput('Would you like to define model associations (hasMany, hasOne, belongsTo, etc.)?', array('y','n'), 'y'); - - if ((low($wannaDoAssoc) == 'y' || low($wannaDoAssoc) == 'yes')) { - $this->stdout('One moment while I try to detect any associations...'); - $possibleKeys = array(); - $i = 0; - foreach ($modelFields as $name => $field) { - $offset = strpos($name, '_id'); - if ($name != $primaryKey && $offset !== false) { - $tmpModelName = $this->__modelNameFromKey($name); - $associations['belongsTo'][$i]['alias'] = $tmpModelName; - $associations['belongsTo'][$i]['className'] = $tmpModelName; - $associations['belongsTo'][$i]['foreignKey'] = $name; - $i++; - } - } - $i = 0; - $j = 0; - foreach ($this->__tables as $otherTable) { - $tempOtherModel = & new Model(false, $otherTable); - $modelFieldsTemp = $db->describe($tempOtherModel); - foreach ($modelFieldsTemp as $name => $field) { - if ($field['type'] == 'integer' || $field['type'] == 'string') { - $possibleKeys[$otherTable][] = $name; - } - if ($name != $primaryKey && $name == $this->__modelKey($currentModelName)) { - $tmpModelName = $this->__modelName($otherTable); - $associations['hasOne'][$j]['alias'] = $tmpModelName; - $associations['hasOne'][$j]['className'] = $tmpModelName; - $associations['hasOne'][$j]['foreignKey'] = $name; - - $associations['hasMany'][$j]['alias'] = $tmpModelName; - $associations['hasMany'][$j]['className'] = $tmpModelName; - $associations['hasMany'][$j]['foreignKey'] = $name; - $j++; - } - } - $offset = strpos($otherTable, $useTable . '_'); - if ($offset !== false) { - $offset = strlen($useTable . '_'); - $tmpModelName = $this->__modelName(substr($otherTable, $offset)); - $associations['hasAndBelongsToMany'][$i]['alias'] = $tmpModelName; - $associations['hasAndBelongsToMany'][$i]['className'] = $tmpModelName; - $associations['hasAndBelongsToMany'][$i]['foreignKey'] = $this->__modelKey($currentModelName); - $associations['hasAndBelongsToMany'][$i]['associationForeignKey'] = $this->__modelKey($tmpModelName); - $associations['hasAndBelongsToMany'][$i]['joinTable'] = $otherTable; - $i++; - } - $offset = strpos($otherTable, '_' . $useTable); - if ($offset !== false) { - $tmpModelName = $this->__modelName(substr($otherTable, 0, $offset)); - $associations['hasAndBelongsToMany'][$i]['alias'] = $tmpModelName; - $associations['hasAndBelongsToMany'][$i]['className'] = $tmpModelName; - $associations['hasAndBelongsToMany'][$i]['foreignKey'] = $this->__modelKey($currentModelName); - $associations['hasAndBelongsToMany'][$i]['associationForeignKey'] = $this->__modelKey($tmpModelName); - $associations['hasAndBelongsToMany'][$i]['joinTable'] = $otherTable; - $i++; - } - } - $this->stdout('Done.'); - $this->hr(); - if (empty($associations)) { - $this->stdout('None found.'); - } else { - $this->stdout('Please confirm the following associations:'); - $this->hr(); - if (!empty($associations['belongsTo'])) { - $count = count($associations['belongsTo']); - for ($i = 0; $i < $count; $i++) { - if ($currentModelName == $associations['belongsTo'][$i]['alias']) { - $response = $this->getInput("{$currentModelName} belongsTo {$associations['belongsTo'][$i]['alias']}\nThis looks like a self join. Do you want to specify an alternate association alias?", array('y','n'), 'y'); - if ('y' == low($response) || 'yes' == low($response)) { - $associations['belongsTo'][$i]['alias'] = $this->getInput("So what is the alias?", null, $associations['belongsTo'][$i]['alias']); - } - if ($currentModelName != $associations['belongsTo'][$i]['alias']) { - $response = $this->getInput("$currentModelName belongsTo {$associations['belongsTo'][$i]['alias']}?", array('y','n'), 'y'); - } else { - $response = 'n'; - } - } else { - $response = $this->getInput("$currentModelName belongsTo {$associations['belongsTo'][$i]['alias']}?", array('y','n'), 'y'); - } - if ('n' == low($response) || 'no' == low($response)) { - unset($associations['belongsTo'][$i]); - } - } - $associations['belongsTo'] = array_merge($associations['belongsTo']); - } - - if (!empty($associations['hasOne'])) { - $count = count($associations['hasOne']); - for ($i = 0; $i < $count; $i++) { - if ($currentModelName == $associations['hasOne'][$i]['alias']) { - $response = $this->getInput("{$currentModelName} hasOne {$associations['hasOne'][$i]['alias']}\nThis looks like a self join. Do you want to specify an alternate association alias?", array('y','n'), 'y'); - if ('y' == low($response) || 'yes' == low($response)) { - $associations['hasOne'][$i]['alias'] = $this->getInput("So what is the alias?", null, $associations['hasOne'][$i]['alias']); - } - if ($currentModelName != $associations['hasOne'][$i]['alias']) { - $response = $this->getInput("$currentModelName hasOne {$associations['hasOne'][$i]['alias']}?", array('y','n'), 'y'); - } else { - $response = 'n'; - } - } else { - $response = $this->getInput("$currentModelName hasOne {$associations['hasOne'][$i]['alias']}?", array('y','n'), 'y'); - } - if ('n' == low($response) || 'no' == low($response)) { - unset($associations['hasOne'][$i]); - } - } - $associations['hasOne'] = array_merge($associations['hasOne']); - } - - if (!empty($associations['hasMany'])) { - $count = count($associations['hasMany']); - for ($i = 0; $i < $count; $i++) { - if ($currentModelName == $associations['hasMany'][$i]['alias']) { - $response = $this->getInput("{$currentModelName} hasMany {$associations['hasMany'][$i]['alias']}\nThis looks like a self join. Do you want to specify an alternate association alias?", array('y','n'), 'y'); - if ('y' == low($response) || 'yes' == low($response)) { - $associations['hasMany'][$i]['alias'] = $this->getInput("So what is the alias?", null, $associations['hasMany'][$i]['alias']); - } - if ($currentModelName != $associations['hasMany'][$i]['alias']) { - $response = $this->getInput("$currentModelName hasMany {$associations['hasMany'][$i]['alias']}?", array('y','n'), 'y'); - } else { - $response = 'n'; - } - } else { - $response = $this->getInput("$currentModelName hasMany {$associations['hasMany'][$i]['alias']}?", array('y','n'), 'y'); - } - if ('n' == low($response) || 'no' == low($response)) { - unset($associations['hasMany'][$i]); - } - } - $associations['hasMany'] = array_merge($associations['hasMany']); - } - - if (!empty($associations['hasAndBelongsToMany'])) { - $count = count($associations['hasAndBelongsToMany']); - for ($i = 0; $i < $count; $i++) { - if ($currentModelName == $associations['hasAndBelongsToMany'][$i]['alias']) { - $response = $this->getInput("{$currentModelName} hasAndBelongsToMany {$associations['hasAndBelongsToMany'][$i]['alias']}\nThis looks like a self join. Do you want to specify an alternate association alias?", array('y','n'), 'y'); - if ('y' == low($response) || 'yes' == low($response)) { - $associations['hasAndBelongsToMany'][$i]['alias'] = $this->getInput("So what is the alias?", null, $associations['hasAndBelongsToMany'][$i]['alias']); - } - if ($currentModelName != $associations['hasAndBelongsToMany'][$i]['alias']) { - $response = $this->getInput("$currentModelName hasAndBelongsToMany {$associations['hasAndBelongsToMany'][$i]['alias']}?", array('y','n'), 'y'); - } else { - $response = 'n'; - } - } else { - $response = $this->getInput("$currentModelName hasAndBelongsToMany {$associations['hasAndBelongsToMany'][$i]['alias']}?", array('y','n'), 'y'); - } - if ('n' == low($response) || 'no' == low($response)) { - unset($associations['hasAndBelongsToMany'][$i]); - } - } - $associations['hasAndBelongsToMany'] = array_merge($associations['hasAndBelongsToMany']); - } - } - $wannaDoMoreAssoc = $this->getInput('Would you like to define some additional model associations?', array('y','n'), 'y'); - - while ((low($wannaDoMoreAssoc) == 'y' || low($wannaDoMoreAssoc) == 'yes')) { - $assocs = array(1=>'belongsTo', 2=>'hasOne', 3=>'hasMany', 4=>'hasAndBelongsToMany'); - $bad = true; - while ($bad) { - $this->stdout('What is the association type?'); - $prompt = "1- belongsTo\n"; - $prompt .= "2- hasOne\n"; - $prompt .= "3- hasMany\n"; - $prompt .= "4- hasAndBelongsToMany\n"; - $assocType = intval($this->getInput($prompt, null, null)); - - if (intval($assocType) < 1 || intval($assocType) > 4) { - $this->stdout('The selection you entered was invalid. Please enter a number between 1 and 4.'); - } else { - $bad = false; - } - } - $this->stdout('For the following options be very careful to match your setup exactly. Any spelling mistakes will cause errors.'); - $this->hr(); - $associationName = $this->getInput('What is the name of this association?'); - $className = $this->getInput('What className will '.$associationName.' use?', null, $associationName ); - $suggestedForeignKey = null; - if ($assocType == '1') { - $showKeys = $possibleKeys[$useTable]; - $suggestedForeignKey = $this->__modelKey($associationName); - } else { - $otherTable = Inflector::tableize($className); - if (in_array($otherTable, $this->__tables)) { - if ($assocType < '4') { - $showKeys = $possibleKeys[$otherTable]; - } else { - $showKeys = null; - } - } else { - $otherTable = $this->getInput('What is the table for this class?'); - $showKeys = $possibleKeys[$otherTable]; - } - $suggestedForeignKey = $this->__modelKey($currentModelName); - } - if (!empty($showKeys)) { - $this->stdout('A helpful List of possible keys'); - for ($i = 0; $i < count($showKeys); $i++) { - $this->stdout($i + 1 . ". " . $showKeys[$i]); - } - $foreignKey = $this->getInput('What is the foreignKey? Choose a number.'); - if (intval($foreignKey) > 0 && intval($foreignKey) <= $i ) { - $foreignKey = $showKeys[intval($foreignKey) - 1]; - } - } - if (!isset($foreignKey)) { - $foreignKey = $this->getInput('What is the foreignKey? Specify your own.', null, $suggestedForeignKey); - } - if ($assocType == '4') { - $associationForeignKey = $this->getInput('What is the associationForeignKey?', null, $this->__modelKey($currentModelName)); - $joinTable = $this->getInput('What is the joinTable?'); - } - $associations[$assocs[$assocType]] = array_values($associations[$assocs[$assocType]]); - $count = count($associations[$assocs[$assocType]]); - $i = ($count > 0) ? $count : 0; - $associations[$assocs[$assocType]][$i]['alias'] = $associationName; - $associations[$assocs[$assocType]][$i]['className'] = $className; - $associations[$assocs[$assocType]][$i]['foreignKey'] = $foreignKey; - if ($assocType == '4') { - $associations[$assocs[$assocType]][$i]['associationForeignKey'] = $associationForeignKey; - $associations[$assocs[$assocType]][$i]['joinTable'] = $joinTable; - } - $wannaDoMoreAssoc = $this->getInput('Define another association?', array('y','n'), 'y'); - } - } - $this->stdout(''); - $this->hr(); - $this->stdout('The following model will be created:'); - $this->hr(); - $this->stdout("Model Name: $currentModelName"); - $this->stdout("DB Connection: " . ($usingDefault ? 'default' : $useDbConfig)); - $this->stdout("DB Table: " . $fullTableName); - if ($primaryKey != 'id') { - $this->stdout("Primary Key: " . $primaryKey); - } - $this->stdout("Validation: " . print_r($validate, true)); - - if (!empty($associations)) { - $this->stdout("Associations:"); - - if (count($associations['belongsTo'])) { - for ($i = 0; $i < count($associations['belongsTo']); $i++) { - $this->stdout(" $currentModelName belongsTo {$associations['belongsTo'][$i]['alias']}"); - } - } - - if (count($associations['hasOne'])) { - for ($i = 0; $i < count($associations['hasOne']); $i++) { - $this->stdout(" $currentModelName hasOne {$associations['hasOne'][$i]['alias']}"); - } - } - - if (count($associations['hasMany'])) { - for ($i = 0; $i < count($associations['hasMany']); $i++) { - $this->stdout(" $currentModelName hasMany {$associations['hasMany'][$i]['alias']}"); - } - } - - if (count($associations['hasAndBelongsToMany'])) { - for ($i = 0; $i < count($associations['hasAndBelongsToMany']); $i++) { - $this->stdout(" $currentModelName hasAndBelongsToMany {$associations['hasAndBelongsToMany'][$i]['alias']}"); - } - } - } - $this->hr(); - $looksGood = $this->getInput('Look okay?', array('y','n'), 'y'); - - if (low($looksGood) == 'y' || low($looksGood) == 'yes') { - if ($useTable == Inflector::tableize($currentModelName)) { - $useTable = null; - } - $this->bakeModel($currentModelName, $useDbConfig, $useTable, $primaryKey, $validate, $associations); - - if ($this->doUnitTest()) { - $this->bakeUnitTest('model', $currentModelName); - } - } else { - $this->stdout('Bake Aborted.'); - } - } -/** - * Action to create a View. - * - */ - function doView() { - $this->hr(); - $this->stdout('View Bake:'); - $this->hr(); - $uses = array(); - $wannaUseSession = 'y'; - $wannaDoScaffold = 'y'; - - - $useDbConfig = 'default'; - $this->__doList($useDbConfig, 'Controllers'); - - $enteredController = ''; - - while ($enteredController == '') { - $enteredController = $this->getInput('Enter a number from the list above, or type in the name of another controller.'); - - if ($enteredController == '' || intval($enteredController) > count($this->__controllerNames)) { - $this->stdout('Error:'); - $this->stdout("The Controller name you supplied was empty, or the number \nyou selected was not an option. Please try again."); - $enteredController = ''; - } - } - - if (intval($enteredController) > 0 && intval($enteredController) <= count($this->__controllerNames) ) { - $controllerName = $this->__controllerNames[intval($enteredController) - 1]; - } else { - $controllerName = Inflector::camelize($enteredController); - } - - $controllerPath = low(Inflector::underscore($controllerName)); - - $doItInteractive = $this->getInput("Would you like bake to build your views interactively?\nWarning: Choosing no will overwrite {$controllerClassName} views if it exist.", array('y','n'), 'y'); - - if (low($doItInteractive) == 'y' || low($doItInteractive) == 'yes') { - $this->interactive = true; - $wannaDoScaffold = $this->getInput("Would you like to create some scaffolded views (index, add, view, edit) for this controller?\nNOTE: Before doing so, you'll need to create your controller and model classes (including associated models).", array('y','n'), 'n'); - } - - $admin = null; - $admin_url = null; - if (low($wannaDoScaffold) == 'y' || low($wannaDoScaffold) == 'yes') { - $wannaDoAdmin = $this->getInput("Would you like to create the views for admin routing?", array('y','n'), 'n'); - } - - if ((low($wannaDoAdmin) == 'y' || low($wannaDoAdmin) == 'yes')) { - require(CONFIGS.'core.php'); - if (defined('CAKE_ADMIN')) { - $admin = CAKE_ADMIN . '_'; - $admin_url = '/'.CAKE_ADMIN; - } else { - $adminRoute = ''; - $this->stdout('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.'); - $this->stdout('What would you like the admin route to be?'); - $this->stdout('Example: www.example.com/admin/controller'); - while ($adminRoute == '') { - $adminRoute = $this->getInput("What would you like the admin route to be?", null, 'admin'); - } - if ($this->__addAdminRoute($adminRoute) !== true) { - $this->stdout('Unable to write to /app/config/core.php.'); - $this->stdout('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.'); - exit(); - } else { - $admin = $adminRoute . '_'; - $admin_url = '/'.$adminRoute; - } - } - } - if (low($wannaDoScaffold) == 'y' || low($wannaDoScaffold) == 'yes') { - $file = CONTROLLERS . $controllerPath . '_controller.php'; - - if (!file_exists($file)) { - $shortPath = str_replace(ROOT, null, $file); - $shortPath = str_replace('../', '', $shortPath); - $shortPath = str_replace('//', '/', $shortPath); - $this->stdout(''); - $this->stdout("The file '$shortPath' could not be found.\nIn order to scaffold, you'll need to first create the controller. "); - $this->stdout(''); - die(); - } else { - uses('controller'.DS.'controller'); - loadController($controllerName); - if ($admin) { - $this->__bakeViews($controllerName, $controllerPath, $admin, $admin_url); - } - $this->__bakeViews($controllerName, $controllerPath, null, null); - - $this->hr(); - $this->stdout(''); - $this->stdout('View Scaffolding Complete.'."\n"); - } - } else { - $actionName = ''; - - while ($actionName == '') { - $actionName = $this->getInput('Action Name? (use camelCased function name)'); - - if ($actionName == '') { - $this->stdout('The action name you supplied was empty. Please try again.'); - } - } - $this->stdout(''); - $this->hr(); - $this->stdout('The following view will be created:'); - $this->hr(); - $this->stdout("Controller Name: $controllerName"); - $this->stdout("Action Name: $actionName"); - $this->stdout("Path: app/views/" . $controllerPath . DS . Inflector::underscore($actionName) . '.thtml'); - $this->hr(); - $looksGood = $this->getInput('Look okay?', array('y','n'), 'y'); - - if (low($looksGood) == 'y' || low($looksGood) == 'yes') { - $this->bakeView($controllerName, $actionName); - } else { - $this->stdout('Bake Aborted.'); - } - } - } - - function __bakeViews($controllerName, $controllerPath, $admin= null, $admin_url = null) { - $controllerClassName = $controllerName.'Controller'; - $controllerObj = & new $controllerClassName(); - - if (!in_array('Html', $controllerObj->helpers)) { - $controllerObj->helpers[] = 'Html'; - } - if (!in_array('Form', $controllerObj->helpers)) { - $controllerObj->helpers[] = 'Form'; - } - - $controllerObj->constructClasses(); - $currentModelName = $controllerObj->modelClass; - $this->__modelClass = $currentModelName; - $modelKey = Inflector::underscore($currentModelName); - $modelObj =& ClassRegistry::getObject($modelKey); - $singularName = $this->__singularName($currentModelName); - $pluralName = $this->__pluralName($currentModelName); - $singularHumanName = $this->__singularHumanName($currentModelName); - $pluralHumanName = $this->__pluralHumanName($controllerName); - - $fieldNames = $controllerObj->generateFieldNames(null, false); - $indexView = null; - - if (!empty($modelObj->alias)) { - foreach ($modelObj->alias as $key => $value) { - $alias[] = $key; - } - } - $indexView .= "<div class=\"{$pluralName}\">\n"; - $indexView .= "<h2>List " . $pluralHumanName . "</h2>\n\n"; - $indexView .= "<table cellpadding=\"0\" cellspacing=\"0\">\n"; - $indexView .= "<tr>\n"; - - foreach ($fieldNames as $fieldName) { - $indexView .= "\t<th>".$fieldName['prompt']."</th>\n"; - } - $indexView .= "\t<th>Actions</th>\n"; - $indexView .= "</tr>\n"; - $indexView .= "<?php foreach (\${$pluralName} as \${$singularName}): ?>\n"; - $indexView .= "<tr>\n"; - $count = 0; - foreach ($fieldNames as $field => $value) { - if (isset($value['foreignKey'])) { - $otherModelName = $this->__modelName($value['model']); - $otherModelKey = Inflector::underscore($otherModelName); - $otherModelObj =& ClassRegistry::getObject($otherModelKey); - $otherControllerName = $this->__controllerName($otherModelName); - $otherControllerPath = $this->__controllerPath($otherControllerName); - if (is_object($otherModelObj)) { - $displayField = $otherModelObj->getDisplayField(); - $indexView .= "\t<td> <?php echo \$html->link(\$".$singularName."['{$alias[$count]}']['{$displayField}'], '{$admin_url}/" . $otherControllerPath . "/view/' .\$".$singularName."['{$alias[$count]}']['{$otherModelObj->primaryKey}'])?></td>\n"; - } else { - $indexView .= "\t<td><?php echo \$".$singularName."['{$modelObj->name}']['{$field}']; ?></td>\n"; - } - $count++; - } else { - $indexView .= "\t<td><?php echo \$".$singularName."['{$modelObj->name}']['{$field}']; ?></td>\n"; - } - } - $indexView .= "\t<td class=\"actions\">\n"; - $indexView .= "\t\t<?php echo \$html->link('View','{$admin_url}/{$controllerPath}/view/' . \$".$singularName."['{$modelObj->name}']['{$modelObj->primaryKey}'])?>\n"; - $indexView .= "\t\t<?php echo \$html->link('Edit','{$admin_url}/{$controllerPath}/edit/' . \$".$singularName."['{$modelObj->name}']['{$modelObj->primaryKey}'])?>\n"; - $indexView .= "\t\t<?php echo \$html->link('Delete','{$admin_url}/{$controllerPath}/delete/' . \$".$singularName."['{$modelObj->name}']['{$modelObj->primaryKey}'], null, 'Are you sure you want to delete id ' . \$".$singularName."['{$modelObj->name}']['{$modelObj->primaryKey}'])?>\n"; - $indexView .= "\t</td>\n"; - $indexView .= "</tr>\n"; - $indexView .= "<?php endforeach; ?>\n"; - $indexView .= "</table>\n\n"; - $indexView .= "<ul class=\"actions\">\n"; - $indexView .= "\t<li><?php echo \$html->link('New {$singularHumanName}', '{$admin_url}/{$controllerPath}/add'); ?></li>\n"; - $indexView .= "</ul>\n"; - $indexView .= "</div>"; - $viewView = null; - $viewView .= "<div class=\"{$singularName}\">\n"; - $viewView .= "<h2>View " . $singularHumanName . "</h2>\n\n"; - $viewView .= "<dl>\n"; - $count = 0; - foreach ($fieldNames as $field => $value) { - $viewView .= "\t<dt>" . $value['prompt'] . "</dt>\n"; - if (isset($value['foreignKey'])) { - $otherModelName = $this->__modelName($value['model']); - $otherModelKey = Inflector::underscore($otherModelName); - $otherModelObj =& ClassRegistry::getObject($otherModelKey); - $otherControllerName = $this->__controllerName($otherModelName); - $otherControllerPath = $this->__controllerPath($otherControllerName); - $displayField = $otherModelObj->getDisplayField(); - $viewView .= "\t<dd> <?php echo \$html->link(\$".$singularName."['{$alias[$count]}']['{$displayField}'], '{$admin_url}/" . $otherControllerPath . "/view/' .\$".$singularName."['{$alias[$count]}']['{$otherModelObj->primaryKey}'])?></dd>\n"; - $count++; - } else { - $viewView .= "\t<dd> <?php echo \$".$singularName."['{$modelObj->name}']['{$field}']?></dd>\n"; - } - } - $viewView .= "</dl>\n"; - $viewView .= "<ul class=\"actions\">\n"; - $viewView .= "\t<li><?php echo \$html->link('Edit " . $singularHumanName . "', '{$admin_url}/{$controllerPath}/edit/' . \$".$singularName."['{$modelObj->name}']['{$modelObj->primaryKey}']) ?> </li>\n"; - $viewView .= "\t<li><?php echo \$html->link('Delete " . $singularHumanName . "', '{$admin_url}/{$controllerPath}/delete/' . \$".$singularName."['{$modelObj->name}']['{$modelObj->primaryKey}'], null, 'Are you sure you want to delete: id ' . \$".$singularName."['{$modelObj->name}']['{$modelObj->primaryKey}'] . '?') ?> </li>\n"; - $viewView .= "\t<li><?php echo \$html->link('List " . $pluralHumanName ."', '{$admin_url}/{$controllerPath}/index') ?> </li>\n"; - $viewView .= "\t<li><?php echo \$html->link('New " . $singularHumanName . "', '{$admin_url}/{$controllerPath}/add') ?> </li>\n"; - foreach ( $fieldNames as $field => $value ) { - if ( isset( $value['foreignKey'] ) ) { - $otherModelName = $this->__modelName($value['model']); - if ($otherModelName != $currentModelName) { - $otherControllerName = $this->__controllerName($otherModelName); - $otherControllerPath = $this->__controllerPath($otherControllerName); - $otherSingularHumanName = $this->__singularHumanName($value['controller']); - $otherPluralHumanName = $this->__pluralHumanName($value['controller']); - $viewView .= "\t<li><?php echo \$html->link('List " . $otherSingularHumanName . "', '{$admin_url}/" . $otherControllerPath . "/index/')?> </li>\n"; - $viewView .= "\t<li><?php echo \$html->link('New " . $otherPluralHumanName . "', '{$admin_url}/" . $otherControllerPath . "/add/')?> </li>\n"; - } - } - } - $viewView .= "</ul>\n\n"; - - $viewView .= "</div>\n"; - - - foreach ($modelObj->hasOne as $associationName => $relation) { - $new = true; - - $otherModelName = $this->__modelName($relation['className']); - $otherControllerName = $this->__controllerName($otherModelName); - $otherControllerPath = $this->__controllerPath($otherControllerName); - $otherSingularName = $this->__singularName($associationName); - $otherPluralHumanName = $this->__pluralHumanName($associationName); - $otherSingularHumanName = $this->__singularHumanName($associationName); - - $viewView .= "<div class=\"related\">\n"; - $viewView .= "<h3>Related " . $otherPluralHumanName . "</h3>\n"; - $viewView .= "<?php if (!empty(\$".$singularName."['{$associationName}'])): ?>\n"; - $viewView .= "<dl>\n"; - $viewView .= "\t<?php foreach (\$".$singularName."['{$associationName}'] as \$field => \$value): ?>\n"; - $viewView .= "\t\t<dt><?php echo \$field ?></dt>\n"; - $viewView .= "\t\t<dd> <?php echo \$value ?></dd>\n"; - $viewView .= "\t<?php endforeach; ?>\n"; - $viewView .= "</dl>\n"; - $viewView .= "<?php endif; ?>\n"; - $viewView .= "<ul class=\"actions\">\n"; - $viewView .= "\t<li><?php echo \$html->link('Edit " . $otherSingularHumanName . "', '{$admin_url}/" .$otherControllerPath."/edit/' . \$".$singularName."['{$associationName}']['" . $modelObj->{$otherModelName}->primaryKey . "']);?></li>\n"; - $viewView .= "\t<li><?php echo \$html->link('New " . $otherSingularHumanName . "', '{$admin_url}/" .$otherControllerPath."/add/');?> </li>\n"; - $viewView .= "</ul>\n"; - $viewView .= "</div>\n"; - } - $relations = array_merge($modelObj->hasMany, $modelObj->hasAndBelongsToMany); - - foreach ($relations as $associationName => $relation) { - $otherModelName = $this->__modelName($relation['className']); - $otherControllerName = $this->__controllerName($otherModelName); - $otherControllerPath = $this->__controllerPath($otherControllerName); - $otherSingularName = $this->__singularName($associationName); - $otherPluralHumanName = $this->__pluralHumanName($associationName); - $otherSingularHumanName = $this->__singularHumanName($associationName); - $otherModelKey = Inflector::underscore($otherModelName); - $otherModelObj =& ClassRegistry::getObject($otherModelKey); - - $viewView .= "<div class=\"related\">\n"; - $viewView .= "<h3>Related " . $otherPluralHumanName . "</h3>\n"; - $viewView .= "<?php if (!empty(\$".$singularName."['{$associationName}'])):?>\n"; - $viewView .= "<table cellpadding=\"0\" cellspacing=\"0\">\n"; - $viewView .= "<tr>\n"; - $viewView .= "<?php foreach (\$".$singularName."['{$associationName}']['0'] as \$column => \$value): ?>\n"; - $viewView .= "<th><?php echo \$column?></th>\n"; - $viewView .= "<?php endforeach; ?>\n"; - $viewView .= "<th>Actions</th>\n"; - $viewView .= "</tr>\n"; - $viewView .= "<?php foreach (\$".$singularName."['{$associationName}'] as \$".$otherSingularName."):?>\n"; - $viewView .= "<tr>\n"; - $viewView .= "\t<?php foreach (\$".$otherSingularName." as \$column => \$value):?>\n"; - $viewView .= "\t\t<td><?php echo \$value;?></td>\n"; - $viewView .= "\t<?php endforeach;?>\n"; - $viewView .= "\t<td class=\"actions\">\n"; - $viewView .= "\t\t<?php echo \$html->link('View', '{$admin_url}/" . $otherControllerPath . "/view/' . \$".$otherSingularName."['{$otherModelObj->primaryKey}']);?>\n"; - $viewView .= "\t\t<?php echo \$html->link('Edit', '{$admin_url}/" . $otherControllerPath . "/edit/' . \$".$otherSingularName."['{$otherModelObj->primaryKey}']);?>\n"; - $viewView .= "\t\t<?php echo \$html->link('Delete', '{$admin_url}/" . $otherControllerPath . "/delete/' . \$".$otherSingularName."['{$otherModelObj->primaryKey}'], null, 'Are you sure you want to delete: id ' . \$".$otherSingularName."['{$otherModelObj->primaryKey}'] . '?');?>\n"; - $viewView .= "\t</td>\n"; - $viewView .= "</tr>\n"; - $viewView .= "<?php endforeach; ?>\n"; - $viewView .= "</table>\n"; - $viewView .= "<?php endif; ?>\n\n"; - $viewView .= "<ul class=\"actions\">\n"; - $viewView .= "\t<li><?php echo \$html->link('New " . $otherSingularHumanName . "', '{$admin_url}/" .$otherControllerPath."/add/');?> </li>\n"; - $viewView .= "</ul>\n"; - - $viewView .= "</div>\n"; - } - $addView = null; - $addView .= "<h2>New " . $singularHumanName . "</h2>\n"; - $addView .= "<form action=\"<?php echo \$html->url('{$admin_url}/{$controllerPath}/add'); ?>\" method=\"post\">\n"; - $addView .= $this->generateFields($controllerObj->generateFieldNames(null, true)); - $addView .= $this->generateSubmitDiv('Add'); - $addView .= "</form>\n"; - $addView .= "<ul class=\"actions\">\n"; - $addView .= "<li><?php echo \$html->link('List {$pluralHumanName}', '{$admin_url}/{$controllerPath}/index')?></li>\n"; - foreach ($modelObj->belongsTo as $associationName => $relation) { - $otherModelName = $this->__modelName($associationName); - if ($otherModelName != $currentModelName) { - $otherControllerName = $this->__controllerName($otherModelName); - $otherControllerPath = $this->__controllerPath($otherControllerName); - $otherSingularName = $this->__singularName($associationName); - $otherPluralName = $this->__pluralHumanName($associationName); - $addView .= "<li><?php echo \$html->link('View " . $otherPluralName . "', '{$admin_url}/" .$otherControllerPath."/index/');?></li>\n"; - $addView .= "<li><?php echo \$html->link('Add " . $otherPluralName . "', '{$admin_url}/" .$otherControllerPath."/add/');?></li>\n"; - } - } - $addView .= "</ul>\n"; - $editView = null; - $editView .= "<h2>Edit " . $singularHumanName . "</h2>\n"; - $editView .= "<form action=\"<?php echo \$html->url('{$admin_url}/{$controllerPath}/edit/'.\$html->tagValue('{$modelObj->name}/{$modelObj->primaryKey}')); ?>\" method=\"post\">\n"; - $editView .= $this->generateFields($controllerObj->generateFieldNames(null, true)); - $editView .= "<?php echo \$html->hidden('{$modelObj->name}/{$modelObj->primaryKey}')?>\n"; - $editView .= $this->generateSubmitDiv('Save'); - $editView .= "</form>\n"; - $editView .= "<ul class=\"actions\">\n"; - $editView .= "<li><?php echo \$html->link('Delete','{$admin_url}/{$controllerPath}/delete/' . \$html->tagValue('{$modelObj->name}/{$modelObj->primaryKey}'), null, 'Are you sure you want to delete: id ' . \$html->tagValue('{$modelObj->name}/{$modelObj->primaryKey}'));?>\n"; - $editView .= "<li><?php echo \$html->link('List {$pluralHumanName}', '{$admin_url}/{$controllerPath}/index')?></li>\n"; - foreach ($modelObj->belongsTo as $associationName => $relation) { - $otherModelName = $this->__modelName($associationName); - if ($otherModelName != $currentModelName) { - $otherControllerName = $this->__controllerName($otherModelName); - $otherControllerPath = $this->__controllerPath($otherControllerName); - $otherSingularName = $this->__singularName($associationName); - $otherPluralName = $this->__pluralHumanName($associationName); - $editView .= "<li><?php echo \$html->link('View " . $otherPluralName . "', '{$admin_url}/" .$otherControllerPath."/index/');?></li>\n"; - $editView .= "<li><?php echo \$html->link('Add " . $otherPluralName . "', '{$admin_url}/" .$otherControllerPath."/add/');?></li>\n"; - } - } - $editView .= "</ul>\n"; - - if (!file_exists(VIEWS.$controllerPath)) { - mkdir(VIEWS.$controllerPath); - } - $filename = VIEWS . $controllerPath . DS . $admin . 'index.thtml'; - $this->__createFile($filename, $indexView); - $filename = VIEWS . $controllerPath . DS . $admin . 'view.thtml'; - $this->__createFile($filename, $viewView); - $filename = VIEWS . $controllerPath . DS . $admin . 'add.thtml'; - $this->__createFile($filename, $addView); - $filename = VIEWS . $controllerPath . DS . $admin . 'edit.thtml'; - $this->__createFile($filename, $editView); - } -/** - * Action to create a Controller. - * - */ - function doController() { - $this->hr(); - $this->stdout('Controller Bake:'); - $this->hr(); - $uses = array(); - $helpers = array(); - $components = array(); - $wannaUseSession = 'y'; - $wannaDoScaffolding = 'y'; - - $useDbConfig = 'default'; - $this->__doList($useDbConfig, 'Controllers'); - - $enteredController = ''; - - while ($enteredController == '') { - $enteredController = $this->getInput('Enter a number from the list above, or type in the name of another controller.'); - - if ($enteredController == '' || intval($enteredController) > count($this->__controllerNames)) { - $this->stdout('Error:'); - $this->stdout("The Controller name you supplied was empty, or the number \nyou selected was not an option. Please try again."); - $enteredController = ''; - } - } - - if (intval($enteredController) > 0 && intval($enteredController) <= count($this->__controllerNames) ) { - $controllerName = $this->__controllerNames[intval($enteredController) - 1]; - } else { - $controllerName = Inflector::camelize($enteredController); - } - - $controllerPath = low(Inflector::underscore($controllerName)); - - $doItInteractive = $this->getInput("Would you like bake to build your controller interactively?\nWarning: Choosing no will overwrite {$controllerClassName} controller if it exist.", array('y','n'), 'y'); - - if (low($doItInteractive) == 'y' || low($doItInteractive) == 'yes') { - $this->interactive = true; - - $wannaUseScaffold = $this->getInput("Would you like to use scaffolding?", array('y','n'), 'y'); - - if (low($wannaUseScaffold) == 'n' || low($wannaUseScaffold) == 'no') { - - $wannaDoScaffolding = $this->getInput("Would you like to include some basic class methods (index(), add(), view(), edit())?", array('y','n'), 'n'); - - if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') { - $wannaDoAdmin = $this->getInput("Would you like to create the methods for admin routing?", array('y','n'), 'n'); - } - - $wannaDoUses = $this->getInput("Would you like this controller to use other models besides '" . $this->__modelName($controllerName) . "'?", array('y','n'), 'n'); - - if (low($wannaDoUses) == 'y' || low($wannaDoUses) == 'yes') { - $usesList = $this->getInput("Please provide a comma separated list of the classnames of other models you'd like to use.\nExample: 'Author, Article, Book'"); - $usesListTrimmed = str_replace(' ', '', $usesList); - $uses = explode(',', $usesListTrimmed); - } - $wannaDoHelpers = $this->getInput("Would you like this controller to use other helpers besides HtmlHelper and FormHelper?", array('y','n'), 'n'); - - if (low($wannaDoHelpers) == 'y' || low($wannaDoHelpers) == 'yes') { - $helpersList = $this->getInput("Please provide a comma separated list of the other helper names you'd like to use.\nExample: 'Ajax, Javascript, Time'"); - $helpersListTrimmed = str_replace(' ', '', $helpersList); - $helpers = explode(',', $helpersListTrimmed); - } - $wannaDoComponents = $this->getInput("Would you like this controller to use any components?", array('y','n'), 'n'); - - if (low($wannaDoComponents) == 'y' || low($wannaDoComponents) == 'yes') { - $componentsList = $this->getInput("Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, MyNiftyHelper'"); - $componentsListTrimmed = str_replace(' ', '', $componentsList); - $components = explode(',', $componentsListTrimmed); - } - - $wannaUseSession = $this->getInput("Would you like to use Sessions?", array('y','n'), 'y'); - } else { - $wannaDoScaffolding = 'n'; - } - } else { - $wannaDoScaffolding = $this->getInput("Would you like to include some basic class methods (index(), add(), view(), edit())?", array('y','n'), 'y'); - - if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') { - $wannaDoAdmin = $this->getInput("Would you like to create the methods for admin routing?", array('y','n'), 'y'); - } - } - - $admin = null; - $admin_url = null; - if ((low($wannaDoAdmin) == 'y' || low($wannaDoAdmin) == 'yes')) { - require(CONFIGS.'core.php'); - if (defined('CAKE_ADMIN')) { - $admin = CAKE_ADMIN.'_'; - $admin_url = '/'.CAKE_ADMIN; - } else { - $adminRoute = ''; - $this->stdout('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.'); - $this->stdout('What would you like the admin route to be?'); - $this->stdout('Example: www.example.com/admin/controller'); - while ($adminRoute == '') { - $adminRoute = $this->getInput("What would you like the admin route to be?", null, 'admin'); - } - if ($this->__addAdminRoute($adminRoute) !== true) { - $this->stdout('Unable to write to /app/config/core.php.'); - $this->stdout('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.'); - exit(); - } else { - $admin = $adminRoute . '_'; - $admin_url = '/'.$adminRoute; - } - } - } - - if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') { - $actions = $this->__bakeActions($controllerName, null, null, $wannaUseSession); - if ($admin) { - $actions .= $this->__bakeActions($controllerName, $admin, $admin_url, $wannaUseSession); - } - } - - if ($this->interactive === true) { - $this->stdout(''); - $this->hr(); - $this->stdout('The following controller will be created:'); - $this->hr(); - $this->stdout("Controller Name: $controllerName"); - if (low($wannaUseScaffold) == 'y' || low($wannaUseScaffold) == 'yes') { - $this->stdout(" var \$scaffold;"); - } - if (count($uses)) { - $this->stdout("Uses: ", false); - - foreach ($uses as $use) { - if ($use != $uses[count($uses) - 1]) { - $this->stdout(ucfirst($use) . ", ", false); - } else { - $this->stdout(ucfirst($use)); - } - } - } - - if (count($helpers)) { - $this->stdout("Helpers: ", false); - - foreach ($helpers as $help) { - if ($help != $helpers[count($helpers) - 1]) { - $this->stdout(ucfirst($help) . ", ", false); - } else { - $this->stdout(ucfirst($help)); - } - } - } - - if (count($components)) { - $this->stdout("Components: ", false); - - foreach ($components as $comp) { - if ($comp != $components[count($components) - 1]) { - $this->stdout(ucfirst($comp) . ", ", false); - } else { - $this->stdout(ucfirst($comp)); - } - } - } - $this->hr(); - $looksGood = $this->getInput('Look okay?', array('y','n'), 'y'); - - if (low($looksGood) == 'y' || low($looksGood) == 'yes') { - $this->bakeController($controllerName, $uses, $helpers, $components, $actions, $wannaUseScaffold); - - if ($this->doUnitTest()) { - $this->bakeUnitTest('controller', $controllerName); - } - } else { - $this->stdout('Bake Aborted.'); - } - } else { - $this->bakeController($controllerName, $uses, $helpers, $components, $actions, $wannaUseScaffold); - if ($this->doUnitTest()) { - $this->bakeUnitTest('controller', $controllerName); - } - exit(); - } - } - - function __bakeActions($controllerName, $admin = null, $admin_url = null, $wannaUseSession = 'y') { - $currentModelName = $this->__modelName($controllerName); - loadModel($currentModelName); - $modelObj =& new $currentModelName(); - $controllerPath = $this->__controllerPath($controllerName); - $pluralName = $this->__pluralName($currentModelName); - $singularName = $this->__singularName($currentModelName); - $singularHumanName = $this->__singularHumanName($currentModelName); - $pluralHumanName = $this->__pluralHumanName($controllerName); - if (!class_exists($currentModelName)) { - $this->stdout('You must have a model for this class to build scaffold methods. Please try again.'); - exit; - } - $actions .= "\n"; - $actions .= "\tfunction {$admin}index() {\n"; - $actions .= "\t\t\$this->{$currentModelName}->recursive = 0;\n"; - $actions .= "\t\t\$this->set('{$pluralName}', \$this->{$currentModelName}->findAll());\n"; - $actions .= "\t}\n"; - $actions .= "\n"; - $actions .= "\tfunction {$admin}view(\$id = null) {\n"; - $actions .= "\t\tif (!\$id) {\n"; - if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') { - $actions .= "\t\t\t\$this->Session->setFlash('Invalid id for {$singularHumanName}.');\n"; - $actions .= "\t\t\t\$this->redirect('{$admin_url}/{$controllerPath}/index');\n"; - } else { - $actions .= "\t\t\t\$this->flash('Invalid id for {$singularHumanName}', '{$admin_url}/{$controllerPath}/index');\n"; - } - $actions .= "\t\t}\n"; - $actions .= "\t\t\$this->set('".$singularName."', \$this->{$currentModelName}->read(null, \$id));\n"; - $actions .= "\t}\n"; - $actions .= "\n"; - $actions .= "\tfunction {$admin}add() {\n"; - $actions .= "\t\tif (empty(\$this->data)) {\n"; - - foreach ($modelObj->hasAndBelongsToMany as $associationName => $relation) { - if (!empty($associationName)) { - $otherModelName = $this->__modelName($associationName); - $otherSingularName = $this->__singularName($associationName); - $otherPluralName = $this->__pluralName($associationName); - $selectedOtherPluralName = 'selected' . ucfirst($otherPluralName); - $actions .= "\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n"; - $actions .= "\t\t\t\$this->set('{$selectedOtherPluralName}', null);\n"; - } - } - foreach ($modelObj->belongsTo as $associationName => $relation) { - if (!empty($associationName)) { - $otherModelName = $this->__modelName($associationName); - $otherSingularName = $this->__singularName($associationName); - $otherPluralName = $this->__pluralName($associationName); - $actions .= "\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n"; - } - } - $actions .= "\t\t\t\$this->render();\n"; - $actions .= "\t\t} else {\n"; - $actions .= "\t\t\t\$this->cleanUpFields();\n"; - $actions .= "\t\t\tif (\$this->{$currentModelName}->save(\$this->data)) {\n"; - if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') { - $actions .= "\t\t\t\t\$this->Session->setFlash('The ".$this->__singularHumanName($currentModelName)." has been saved');\n"; - $actions .= "\t\t\t\t\$this->redirect('{$admin_url}/{$controllerPath}/index');\n"; - } else { - $actions .= "\t\t\t\t\$this->flash('{$currentModelName} saved.', '{$admin_url}/{$controllerPath}/index');\n"; - } - $actions .= "\t\t\t} else {\n"; - if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') { - $actions .= "\t\t\t\t\$this->Session->setFlash('Please correct errors below.');\n"; - } - - foreach ($modelObj->hasAndBelongsToMany as $associationName => $relation) { - if (!empty($associationName)) { - $otherModelName = $this->__modelName($associationName); - $otherSingularName = $this->__singularName($associationName); - $otherPluralName = $this->__pluralName($associationName); - $selectedOtherPluralName = 'selected' . ucfirst($otherPluralName); - $actions .= "\t\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n"; - $actions .= "\t\t\t\tif (empty(\$this->data['{$associationName}']['{$associationName}'])) { \$this->data['{$associationName}']['{$associationName}'] = null; }\n"; - $actions .= "\t\t\t\t\$this->set('{$selectedOtherPluralName}', \$this->data['{$associationName}']['{$associationName}']);\n"; - } - } - foreach ($modelObj->belongsTo as $associationName => $relation) { - if (!empty($associationName)) { - $otherModelName = $this->__modelName($associationName); - $otherSingularName = $this->__singularName($associationName); - $otherPluralName = $this->__pluralName($associationName); - $actions .= "\t\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n"; - } - } - $actions .= "\t\t\t}\n"; - $actions .= "\t\t}\n"; - $actions .= "\t}\n"; - $actions .= "\n"; - $actions .= "\tfunction {$admin}edit(\$id = null) {\n"; - $actions .= "\t\tif (empty(\$this->data)) {\n"; - $actions .= "\t\t\tif (!\$id) {\n"; - if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') { - $actions .= "\t\t\t\t\$this->Session->setFlash('Invalid id for {$singularHumanName}');\n"; - $actions .= "\t\t\t\t\$this->redirect('{$admin_url}/{$controllerPath}/index');\n"; - } else { - $actions .= "\t\t\t\t\$this->flash('Invalid id for {$singularHumanName}', '{$admin_url}/{$controllerPath}/index');\n"; - } - $actions .= "\t\t\t}\n"; - $actions .= "\t\t\t\$this->data = \$this->{$currentModelName}->read(null, \$id);\n"; - - foreach ($modelObj->hasAndBelongsToMany as $associationName => $relation) { - if (!empty($associationName)) { - $otherModelName = $this->__modelName($associationName); - $otherSingularName = $this->__singularName($associationName); - $otherPluralName = $this->__pluralName($associationName); - $otherModelKey = Inflector::underscore($otherModelName); - $otherModelObj =& ClassRegistry::getObject($otherModelKey); - $selectedOtherPluralName = 'selected' . ucfirst($otherPluralName); - $actions .= "\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n"; - $actions .= "\t\t\tif (empty(\$this->data['{$associationName}'])) { \$this->data['{$associationName}'] = null; }\n"; - $actions .= "\t\t\t\$this->set('{$selectedOtherPluralName}', \$this->_selectedArray(\$this->data['{$associationName}']));\n"; - } - } - foreach ($modelObj->belongsTo as $associationName => $relation) { - if (!empty($associationName)) { - $otherModelName = $this->__modelName($associationName); - $otherSingularName = $this->__singularName($associationName); - $otherPluralName = $this->__pluralName($associationName); - $actions .= "\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n"; - } - } - $actions .= "\t\t} else {\n"; - $actions .= "\t\t\t\$this->cleanUpFields();\n"; - $actions .= "\t\t\tif (\$this->{$currentModelName}->save(\$this->data)) {\n"; - if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') { - $actions .= "\t\t\t\t\$this->Session->setFlash('The ".Inflector::humanize($currentModelName)." has been saved');\n"; - $actions .= "\t\t\t\t\$this->redirect('{$admin_url}/{$controllerPath}/index');\n"; - } else { - $actions .= "\t\t\t\t\$this->flash('{$currentModelName} saved.', '{$admin_url}/{$controllerPath}/index');\n"; - } - $actions .= "\t\t\t} else {\n"; - if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') { - $actions .= "\t\t\t\t\$this->Session->setFlash('Please correct errors below.');\n"; - } - - foreach ($modelObj->hasAndBelongsToMany as $associationName => $relation) { - if (!empty($associationName)) { - $otherModelName = $this->__modelName($associationName); - $otherSingularName = $this->__singularName($associationName); - $otherPluralName = $this->__pluralName($associationName); - $selectedOtherPluralName = 'selected' . ucfirst($otherPluralName); - $actions .= "\t\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n"; - $actions .= "\t\t\t\tif (empty(\$this->data['{$associationName}']['{$associationName}'])) { \$this->data['{$associationName}']['{$associationName}'] = null; }\n"; - $actions .= "\t\t\t\t\$this->set('{$selectedOtherPluralName}', \$this->data['{$associationName}']['{$associationName}']);\n"; - } - } - foreach ($modelObj->belongsTo as $associationName => $relation) { - if (!empty($associationName)) { - $otherModelName = $this->__modelName($associationName); - $otherSingularName = $this->__singularName($associationName); - $otherPluralName = $this->__pluralName($associationName); - $actions .= "\t\t\t\t\$this->set('{$otherPluralName}', \$this->{$currentModelName}->{$otherModelName}->generateList());\n"; - } - } - $actions .= "\t\t\t}\n"; - $actions .= "\t\t}\n"; - $actions .= "\t}\n"; - $actions .= "\n"; - $actions .= "\tfunction {$admin}delete(\$id = null) {\n"; - $actions .= "\t\tif (!\$id) {\n"; - if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') { - $actions .= "\t\t\t\$this->Session->setFlash('Invalid id for {$singularHumanName}');\n"; - $actions .= "\t\t\t\$this->redirect('{$admin_url}/{$controllerPath}/index');\n"; - } else { - $actions .= "\t\t\t\$this->flash('Invalid id for {$singularHumanName}', '{$admin_url}/{$controllerPath}/index');\n"; - } - $actions .= "\t\t}\n"; - $actions .= "\t\tif (\$this->{$currentModelName}->del(\$id)) {\n"; - if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') { - $actions .= "\t\t\t\$this->Session->setFlash('The ".$this->__singularHumanName($currentModelName)." deleted: id '.\$id.'');\n"; - $actions .= "\t\t\t\$this->redirect('{$admin_url}/{$controllerPath}/index');\n"; - } else { - $actions .= "\t\t\t\$this->flash('{$currentModelName} deleted: id '.\$id.'.', '{$admin_url}/{$controllerPath}/index');\n"; - } - $actions .= "\t\t}\n"; - $actions .= "\t}\n"; - $actions .= "\n"; - return $actions; - } -/** - * Action to create a Unit Test. - * - * @return Success - */ - function doUnitTest() { - if (is_dir(VENDORS.'simpletest') || is_dir(ROOT.DS.APP_DIR.DS.'vendors'.DS.'simpletest')) { - return true; - } - $unitTest = $this->getInput('Cake test suite not installed. Do you want to bake unit test files anyway?', array('y','n'), 'y'); - $result = low($unitTest) == 'y' || low($unitTest) == 'yes'; - - if ($result) { - $this->stdout("\nYou can download the Cake test suite from http://cakeforge.org/projects/testsuite/", true); - } - return $result; - } -/** - * Creates a database configuration file for Bake. - * - * @param string $host - * @param string $login - * @param string $password - * @param string $database - */ - function bakeDbConfig( $driver, $connect, $host, $login, $password, $database, $prefix) { - $out = "<?php\n"; - $out .= "class DATABASE_CONFIG {\n\n"; - $out .= "\tvar \$default = array(\n"; - $out .= "\t\t'driver' => '{$driver}',\n"; - $out .= "\t\t'connect' => '{$connect}',\n"; - $out .= "\t\t'host' => '{$host}',\n"; - $out .= "\t\t'login' => '{$login}',\n"; - $out .= "\t\t'password' => '{$password}',\n"; - $out .= "\t\t'database' => '{$database}', \n"; - $out .= "\t\t'prefix' => '{$prefix}' \n"; - $out .= "\t);\n"; - $out .= "}\n"; - $out .= "?>"; - $filename = CONFIGS.'database.php'; - $this->__createFile($filename, $out); - } -/** - * Assembles and writes a Model file. - * - * @param string $name - * @param object $useDbConfig - * @param string $useTable - * @param string $primaryKey - * @param array $validate - * @param array $associations - */ - function bakeModel($name, $useDbConfig = 'default', $useTable = null, $primaryKey = 'id', $validate=array(), $associations=array()) { - $out = "<?php\n"; - $out .= "class {$name} extends AppModel {\n\n"; - $out .= "\tvar \$name = '{$name}';\n"; - - if ($useDbConfig != 'default') { - $out .= "\tvar \$useDbConfig = '$useDbConfig';\n"; - } - - if ($useTable != null) { - $out .= "\tvar \$useTable = '$useTable';\n"; - } - - if ($primaryKey != 'id') { - $out .= "\tvar \$primaryKey = '$primaryKey';\n"; - } - - - if (count($validate)) { - $out .= "\tvar \$validate = array(\n"; - $keys = array_keys($validate); - for ($i = 0; $i < count($validate); $i++) { - $out .= "\t\t'" . $keys[$i] . "' => " . $validate[$keys[$i]] . ",\n"; - } - $out .= "\t);\n"; - } - $out .= "\n"; - - if (!empty($associations)) { - $out.= "\t//The Associations below have been created with all possible keys, those that are not needed can be removed\n"; - if (!empty($associations['belongsTo'])) { - $out .= "\tvar \$belongsTo = array(\n"; - - for ($i = 0; $i < count($associations['belongsTo']); $i++) { - $out .= "\t\t\t'{$associations['belongsTo'][$i]['alias']}' =>\n"; - $out .= "\t\t\t\tarray('className' => '{$associations['belongsTo'][$i]['className']}',\n"; - $out .= "\t\t\t\t\t\t'foreignKey' => '{$associations['belongsTo'][$i]['foreignKey']}',\n"; - $out .= "\t\t\t\t\t\t'conditions' => '',\n"; - $out .= "\t\t\t\t\t\t'fields' => '',\n"; - $out .= "\t\t\t\t\t\t'order' => '',\n"; - $out .= "\t\t\t\t\t\t'counterCache' => ''\n"; - $out .= "\t\t\t\t),\n\n"; - } - $out .= "\t);\n\n"; - } - - if (!empty($associations['hasOne'])) { - $out .= "\tvar \$hasOne = array(\n"; - - for ($i = 0; $i < count($associations['hasOne']); $i++) { - $out .= "\t\t\t'{$associations['hasOne'][$i]['alias']}' =>\n"; - $out .= "\t\t\t\tarray('className' => '{$associations['hasOne'][$i]['className']}',\n"; - $out .= "\t\t\t\t\t\t'foreignKey' => '{$associations['hasOne'][$i]['foreignKey']}',\n"; - $out .= "\t\t\t\t\t\t'conditions' => '',\n"; - $out .= "\t\t\t\t\t\t'fields' => '',\n"; - $out .= "\t\t\t\t\t\t'order' => '',\n"; - $out .= "\t\t\t\t\t\t'dependent' => ''\n"; - $out .= "\t\t\t\t),\n\n"; - } - $out .= "\t);\n\n"; - } - - if (!empty($associations['hasMany'])) { - $out .= "\tvar \$hasMany = array(\n"; - - for ($i = 0; $i < count($associations['hasMany']); $i++) { - $out .= "\t\t\t'{$associations['hasMany'][$i]['alias']}' =>\n"; - $out .= "\t\t\t\tarray('className' => '{$associations['hasMany'][$i]['className']}',\n"; - $out .= "\t\t\t\t\t\t'foreignKey' => '{$associations['hasMany'][$i]['foreignKey']}',\n"; - $out .= "\t\t\t\t\t\t'conditions' => '',\n"; - $out .= "\t\t\t\t\t\t'fields' => '',\n"; - $out .= "\t\t\t\t\t\t'order' => '',\n"; - $out .= "\t\t\t\t\t\t'limit' => '',\n"; - $out .= "\t\t\t\t\t\t'offset' => '',\n"; - $out .= "\t\t\t\t\t\t'dependent' => '',\n"; - $out .= "\t\t\t\t\t\t'exclusive' => '',\n"; - $out .= "\t\t\t\t\t\t'finderQuery' => '',\n"; - $out .= "\t\t\t\t\t\t'counterQuery' => ''\n"; - $out .= "\t\t\t\t),\n\n"; - } - $out .= "\t);\n\n"; - } - - if (!empty($associations['hasAndBelongsToMany'])) { - $out .= "\tvar \$hasAndBelongsToMany = array(\n"; - - for ($i = 0; $i < count($associations['hasAndBelongsToMany']); $i++) { - $out .= "\t\t\t'{$associations['hasAndBelongsToMany'][$i]['alias']}' =>\n"; - $out .= "\t\t\t\tarray('className' => '{$associations['hasAndBelongsToMany'][$i]['className']}',\n"; - $out .= "\t\t\t\t\t\t'joinTable' => '{$associations['hasAndBelongsToMany'][$i]['joinTable']}',\n"; - $out .= "\t\t\t\t\t\t'foreignKey' => '{$associations['hasAndBelongsToMany'][$i]['foreignKey']}',\n"; - $out .= "\t\t\t\t\t\t'associationForeignKey' => '{$associations['hasAndBelongsToMany'][$i]['associationForeignKey']}',\n"; - $out .= "\t\t\t\t\t\t'conditions' => '',\n"; - $out .= "\t\t\t\t\t\t'fields' => '',\n"; - $out .= "\t\t\t\t\t\t'order' => '',\n"; - $out .= "\t\t\t\t\t\t'limit' => '',\n"; - $out .= "\t\t\t\t\t\t'offset' => '',\n"; - $out .= "\t\t\t\t\t\t'unique' => '',\n"; - $out .= "\t\t\t\t\t\t'finderQuery' => '',\n"; - $out .= "\t\t\t\t\t\t'deleteQuery' => '',\n"; - $out .= "\t\t\t\t\t\t'insertQuery' => ''\n"; - $out .= "\t\t\t\t),\n\n"; - } - $out .= "\t);\n\n"; - } - } - $out .= "}\n"; - $out .= "?>"; - $filename = MODELS.Inflector::underscore($name) . '.php'; - $this->__createFile($filename, $out); - } -/** - * Assembles and writes a View file. - * - * @param string $controllerName - * @param string $actionName - * @param string $content - */ - function bakeView($controllerName, $actionName, $content = '') { - $out = "<h2>{$actionName}</h2>\n"; - $out .= $content; - if (!file_exists(VIEWS.$this->__controllerPath($controllerName))) { - mkdir(VIEWS.$this->__controllerPath($controllerName)); - } - $filename = VIEWS . $this->__controllerPath($controllerName) . DS . Inflector::underscore($actionName) . '.thtml'; - $this->__createFile($filename, $out); - } -/** - * Assembles and writes a Controller file. - * - * @param string $controllerName - * @param array $uses - * @param array $helpers - * @param array $components - * @param string $actions - */ - function bakeController($controllerName, $uses, $helpers, $components, $actions = '', $wannaUseScaffold = 'y') { - $out = "<?php\n"; - $out .= "class $controllerName" . "Controller extends AppController {\n\n"; - $out .= "\tvar \$name = '$controllerName';\n"; - if (low($wannaUseScaffold) == 'y' || low($wannaUseScaffold) == 'yes') { - $out .= "\tvar \$scaffold;\n"; - } else { - - if (count($uses)) { - $out .= "\tvar \$uses = array('" . $this->__modelName($controllerName) . "', "; - - foreach ($uses as $use) { - if ($use != $uses[count($uses) - 1]) { - $out .= "'" . $this->__modelName($use) . "', "; - } else { - $out .= "'" . $this->__modelName($use) . "'"; - } - } - $out .= ");\n"; - } - - $out .= "\tvar \$helpers = array('Html', 'Form' "; - if (count($helpers)) { - foreach ($helpers as $help) { - if ($help != $helpers[count($helpers) - 1]) { - $out .= ", '" . Inflector::camelize($help) . "'"; - } else { - $out .= ", '" . Inflector::camelize($help) . "'"; - } - } - } - $out .= ");\n"; - - if (count($components)) { - $out .= "\tvar \$components = array("; - - foreach ($components as $comp) { - if ($comp != $components[count($components) - 1]) { - $out .= "'" . Inflector::camelize($comp) . "', "; - } else { - $out .= "'" . Inflector::camelize($comp) . "'"; - } - } - $out .= ");\n"; - } - } - $out .= $actions; - $out .= "}\n"; - $out .= "?>"; - $filename = CONTROLLERS . $this->__controllerPath($controllerName) . '_controller.php'; - $this->__createFile($filename, $out); - } -/** - * Assembles and writes a unit test file. - * - * @param string $type One of "model", and "controller". - * @param string $className - */ - function bakeUnitTest($type, $className) { - $out = '<?php '."\n\n"; - $error = false; - switch ($type) { - case 'model': - $out .= "loadModel('$className');\n\n"; - $out .= "class {$className}TestCase extends UnitTestCase {\n"; - $out .= "\tvar \$object = null;\n\n"; - $out .= "\tfunction setUp() {\n\t\t\$this->object = new {$className}();\n"; - $out .= "\t}\n\n\tfunction tearDown() {\n\t\tunset(\$this->object);\n\t}\n"; - $out .= "\n\t/*\n\tfunction testMe() {\n"; - $out .= "\t\t\$result = \$this->object->doSomething();\n"; - $out .= "\t\t\$expected = 1;\n"; - $out .= "\t\t\$this->assertEqual(\$result, \$expected);\n\t}\n\t*/\n}"; - $path = MODEL_TESTS; - $filename = $this->__singularName($className).'.test.php'; - break; - case 'controller': - $out .= "loadController('$className');\n\n"; - $out .= "class {$className}ControllerTestCase extends UnitTestCase {\n"; - $out .= "\tvar \$object = null;\n\n"; - $out .= "\tfunction setUp() {\n\t\t\$this->object = new {$className}Controller();\n"; - $out .= "\t}\n\n\tfunction tearDown() {\n\t\tunset(\$this->object);\n\t}\n"; - $out .= "\n\t/*\n\tfunction testMe() {\n"; - $out .= "\t\t\$result = \$this->object->doSomething();\n"; - $out .= "\t\t\$expected = 1;\n"; - $out .= "\t\t\$this->assertEqual(\$result, \$expected);\n\t}\n\t*/\n}"; - $path = CONTROLLER_TESTS; - $filename = $this->__pluralName($className).'_controller.test.php'; - break; - default: - $error = true; - break; - } - $out .= "\n?>"; - - if (!$error) { - $this->stdout("Baking unit test for $className..."); - $path = explode(DS, $path); - foreach ($path as $i => $val) { - if ($val == '' || $val == '../') { - unset($path[$i]); - } - } - $path = implode(DS, $path); - $unixPath = DS; - if (strpos(PHP_OS, 'WIN') === 0) { - $unixPath = null; - } - if (!is_dir($unixPath.$path)) { - $create = $this->getInput("Unit test directory does not exist. Create it?", array('y','n'), 'y'); - if (low($create) == 'y' || low($create) == 'yes') { - $build = array(); - - foreach (explode(DS, $path) as $i => $dir) { - $build[] = $dir; - if (!is_dir($unixPath.implode(DS, $build))) { - mkdir($unixPath.implode(DS, $build)); - } - } - } else { - return false; - } - } - $this->__createFile($unixPath.$path.DS.$filename, $out); - } - } -/** - * Prompts the user for input, and returns it. - * - * @param string $prompt Prompt text. - * @param mixed $options Array or string of options. - * @param string $default Default input value. - * @return Either the default value, or the user-provided input. - */ - function getInput($prompt, $options = null, $default = null) { - if (!is_array($options)) { - $print_options = ''; - } else { - $print_options = '(' . implode('/', $options) . ')'; - } - - if ($default == null) { - $this->stdout(''); - $this->stdout($prompt . " $print_options \n" . '> ', false); - } else { - $this->stdout(''); - $this->stdout($prompt . " $print_options \n" . "[$default] > ", false); - } - $result = fgets($this->stdin); - - if($result === false){ - exit; - } - $result = trim($result); - - if ($default != null && empty($result)) { - return $default; - } else { - return $result; - } - } -/** - * Outputs to the stdout filehandle. - * - * @param string $string String to output. - * @param boolean $newline If true, the outputs gets an added newline. - */ - function stdout($string, $newline = true) { - if ($newline) { - fwrite($this->stdout, $string . "\n"); - } else { - fwrite($this->stdout, $string); - } - } -/** - * Outputs to the stderr filehandle. - * - * @param string $string Error text to output. - */ - function stderr($string) { - fwrite($this->stderr, $string, true); - } -/** - * Outputs a series of minus characters to the standard output, acts as a visual separator. - * - */ - function hr() { - $this->stdout('---------------------------------------------------------------'); - } -/** - * Creates a file at given path. - * - * @param string $path Where to put the file. - * @param string $contents Content to put in the file. - * @return Success - */ - function __createFile ($path, $contents) { - $path = str_replace('//', '/', $path); - echo "\nCreating file $path\n"; - if (is_file($path) && $this->interactive === true) { - fwrite($this->stdout, __("File exists, overwrite?", true). " {$path} (y/n/q):"); - $key = trim(fgets($this->stdin)); - - if ($key=='q') { - fwrite($this->stdout, __("Quitting.", true) ."\n"); - exit; - } elseif ($key == 'a') { - $this->dont_ask = true; - } elseif ($key == 'y') { - } else { - fwrite($this->stdout, __("Skip", true) ." {$path}\n"); - return false; - } - } - - if ($f = fopen($path, 'w')) { - fwrite($f, $contents); - fclose($f); - fwrite($this->stdout, __("Wrote", true) ."{$path}\n"); - return true; - } else { - fwrite($this->stderr, __("Error! Could not write to", true)." {$path}.\n"); - return false; - } - } -/** - * Takes an array of database fields, and generates an HTML form for a View. - * This is an extraction from the Scaffold functionality. - * - * @param array $fields - * @param boolean $readOnly - * @return Generated HTML and PHP. - */ - function generateFields( $fields, $readOnly = false ) { - $strFormFields = ''; - foreach ( $fields as $field ) { - if (isset( $field['type'])) { - if (!isset($field['required'])) { - $field['required'] = false; - } - - if (!isset( $field['errorMsg'])) { - $field['errorMsg'] = null; - } - - if (!isset( $field['htmlOptions'])) { - $field['htmlOptions'] = array(); - } - - if ( $readOnly ) { - $field['htmlOptions']['READONLY'] = "readonly"; - } - - switch( $field['type'] ) { - case "input" : - if (!isset( $field['size'])) { - $field['size'] = 60; - } - $strFormFields = $strFormFields.$this->generateInputDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['size'], $field['htmlOptions'] ); - break; - case "checkbox" : - $strFormFields = $strFormFields.$this->generateCheckboxDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['htmlOptions'] ); - break; - case "select"; - case "selectMultiple"; - if ( "selectMultiple" == $field['type'] ) { - $field['selectAttr']['multiple'] = 'multiple'; - $field['selectAttr']['class'] = 'selectMultiple'; - } - if (!isset( $field['selected'])) { - $field['selected'] = null; - } - if (!isset( $field['selectAttr'])) { - $field['selectAttr'] = null; - } - if (!isset( $field['optionsAttr'])) { - $field['optionsAttr'] = null; - } - if ($readOnly) { - $field['selectAttr']['DISABLED'] = true; - } - if (!isset( $field['options'])) { - $field['options'] = null; - } - $this->__modelAlias = null; - if (isset($field['foreignKey'])) { - $modelKey = Inflector::underscore($this->__modelClass); - $modelObj =& ClassRegistry::getObject($modelKey); - foreach ($modelObj->belongsTo as $associationName => $value) { - if ($field['model'] == $value['className']) { - $this->__modelAlias = $this->__modelName($associationName); - break; - } - } - } - $strFormFields = $strFormFields.$this->generateSelectDiv( $field['tagName'], $field['prompt'], $field['options'], $field['selected'], $field['selectAttr'], $field['optionsAttr'], $field['required'], $field['errorMsg'] ); - break; - case "area"; - if (!isset( $field['rows'])) { - $field['rows'] = 10; - } - if (!isset( $field['cols'])) { - $field['cols'] = 60; - } - $strFormFields = $strFormFields.$this->generateAreaDiv( $field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], $field['cols'], $field['rows'], $field['htmlOptions'] ); - break; - case "fieldset"; - $strFieldsetFields = $this->generateFields( $field['fields'] ); - $strFieldSet = sprintf( ' - <fieldset><legend>%s</legend><div class="notes"><h4>%s</h4><p class="last">%s</p></div>%s</fieldset>', - $field['legend'], $field['noteHeading'], $field['note'], $strFieldsetFields ); - $strFormFields = $strFormFields.$strFieldSet; - break; - case "hidden"; - //$strFormFields = $strFormFields . $this->Html->hiddenTag( $field['tagName']); - break; - case "date": - if (!isset($field['selected'])) { - $field['selected'] = null; - } - $strFormFields = $strFormFields . $this->generateDate($field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], null, $field['htmlOptions'], $field['selected']); - break; - case "datetime": - if (!isset($field['selected'])) { - $field['selected'] = null; - } - $strFormFields = $strFormFields . $this->generateDateTime($field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], null, $field['htmlOptions'], $field['selected']); - break; - case "time": - if (!isset($field['selected'])) { - $field['selected'] = null; - } - $strFormFields = $strFormFields . $this->generateTime($field['tagName'], $field['prompt'], $field['required'], $field['errorMsg'], null, $field['htmlOptions'], $field['selected']); - break; - default: - break; - } - } - } - return $strFormFields; - } -/** - * Generates PHP code for a View file that makes a textarea. - * - * @param string $tagName - * @param string $prompt - * @param boolean $required - * @param string $errorMsg - * @param integer $cols - * @param integer $rows - * @param array $htmlOptions - * @return Generated HTML and PHP. - */ - function generateAreaDiv($tagName, $prompt, $required=false, $errorMsg=null, $cols=60, $rows=10, $htmlOptions=null ) { - $htmlAttributes = $htmlOptions; - $htmlAttributes['cols'] = $cols; - $htmlAttributes['rows'] = $rows; - $str = "\t<?php echo \$html->textarea('{$tagName}', " . $this->__attributesToArray($htmlAttributes) . ");?>\n"; - $str .= "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Please enter the {$prompt}.');?>\n"; - $strLabel = "\n\t<?php echo \$form->labelTag( '{$tagName}', '{$prompt}' );?>\n"; - $divClass = "optional"; - - if ( $required ) { - $divClass = "required"; - } - $strError = ""; - $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); - return $this->divTag( $divClass, $divTagInside ); - } -/** - * Generates PHP code for a View file that makes a checkbox, wrapped in a DIV. - * - * @param string $tagName - * @param string $prompt - * @param boolean $required - * @param string $errorMsg - * @param array $htmlOptions - * @return Generated HTML and PHP. - */ - function generateCheckboxDiv($tagName, $prompt, $required=false, $errorMsg=null, $htmlOptions=null ) { - $htmlAttributes = $htmlOptions; - $strLabel = "\n\t<?php echo \$html->checkbox('{$tagName}', null, " . $this->__attributesToArray($htmlAttributes) . ");?>\n"; - $strLabel .= "\t<?php echo \$form->labelTag('{$tagName}', '{$prompt}');?>\n"; - $str = "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Please check the {$prompt}.');?>\n"; - $divClass = "optional"; - - if ($required) { - $divClass = "required"; - } - $strError = ""; - $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str); - return $this->divTag( $divClass, $divTagInside ); - } -/** - * Generates PHP code for a View file that makes a date-picker, wrapped in a DIV. - * - * @param string $tagName - * @param string $prompt - * @param boolean $required - * @param string $errorMsg - * @param integer $size - * @param array $htmlOptions - * @param string $selected - * @return Generated HTML and PHP. - */ - function generateDate($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null, $selected=null ) { - $str = "\t<?php echo \$html->dateTimeOptionTag('{$tagName}', 'MDY' , 'NONE', \$html->tagValue('{$tagName}'), " . $this->__attributesToArray($htmlOptions) . ");?>\n"; - $str .= "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Please select the {$prompt}.');?>\n"; - $strLabel = "\n\t<?php echo \$form->labelTag('{$tagName}', '{$prompt}');?>\n"; - $divClass = "optional"; - - if ($required) { - $divClass = "required"; - } - $strError = ""; - $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); - return $this->divTag( $divClass, $divTagInside ); - } -/** - * Generates PHP code for a View file that makes a time-picker, wrapped in a DIV. - * - * @param string $tagName - * @param string $prompt - * @param boolean $required - * @param string $errorMsg - * @param integer $size - * @param array $htmlOptions - * @param string $selected - * @return Generated HTML and PHP. - */ - function generateTime($tagName, $prompt, $required = false, $errorMsg = null, $size = 20, $htmlOptions = null, $selected = null) { - $str = "\n\t\<?php echo \$html->dateTimeOptionTag('{$tagName}', 'NONE', '24', \$html->tagValue('{$tagName}'), " . $this->__attributesToArray($htmlOptions) . ");?>\n"; - $strLabel = "\n\t<?php echo \$form->labelTag('{$tagName}', '{$prompt}');?>\n"; - $divClass = "optional"; - if ($required) { - $divClass = "required"; - } - $strError = ""; - $divTagInside = sprintf("%s %s %s", $strError, $strLabel, $str); - return $this->divTag($divClass, $divTagInside); - } -/** - * EGenerates PHP code for a View file that makes a datetime-picker, wrapped in a DIV. - * - * @param string $tagName - * @param string $prompt - * @param boolean $required - * @param string $errorMsg - * @param integer $size - * @param array $htmlOptions - * @param string $selected - * @return Generated HTML and PHP. - */ - function generateDateTime($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null, $selected = null ) { - $str = "\t<?php echo \$html->dateTimeOptionTag('{$tagName}', 'MDY' , '12', \$html->tagValue('{$tagName}'), " . $this->__attributesToArray($htmlOptions) . ");?>\n"; - $str .= "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Please select the {$prompt}.');?>\n"; - $strLabel = "\n\t<?php echo \$form->labelTag('{$tagName}', '{$prompt}');?>\n"; - $divClass = "optional"; - - if ($required) { - $divClass = "required"; - } - $strError = ""; - $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); - return $this->divTag( $divClass, $divTagInside ); - } -/** - * Generates PHP code for a View file that makes an INPUT field, wrapped in a DIV. - * - * @param string $tagName - * @param string $prompt - * @param boolean $required - * @param string $errorMsg - * @param integer $size - * @param array $htmlOptions - * @return Generated HTML and PHP. - */ - function generateInputDiv($tagName, $prompt, $required=false, $errorMsg=null, $size=20, $htmlOptions=null ) { - $htmlAttributes = $htmlOptions; - $htmlAttributes['size'] = $size; - $str = "\t<?php echo \$html->input('{$tagName}', " . $this->__attributesToArray($htmlAttributes) . ");?>\n"; - $str .= "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Please enter the {$prompt}.');?>\n"; - $strLabel = "\n\t<?php echo \$form->labelTag('{$tagName}', '{$prompt}');?>\n"; - $divClass = "optional"; - - if ($required) { - $divClass = "required"; - } - $strError = ""; - $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); - return $this->divTag( $divClass, $divTagInside ); - } - -/** - * Generates PHP code for a View file that makes a SELECT box, wrapped in a DIV. - * - * @param string $tagName - * @param string $prompt - * @param array $options - * @param string $selected - * @param array $selectAttr - * @param array $optionAttr - * @param boolean $required - * @param string $errorMsg - * @return Generated HTML and PHP. - */ - function generateSelectDiv($tagName, $prompt, $options, $selected=null, $selectAttr=null, $optionAttr=null, $required=false, $errorMsg=null) { - - if ($this->__modelAlias) { - $pluralName = $this->__pluralName($this->__modelAlias); - } else { - $tagArray = explode('/', $tagName); - $pluralName = $this->__pluralName($this->__modelNameFromKey($tagArray[1])); - } - $showEmpty = 'true'; - if ($required) { - $showEmpty = 'false'; - } - if ($selectAttr['multiple'] != 'multiple') { - $str = "\t<?php echo \$html->selectTag('{$tagName}', " . "\${$pluralName}, \$html->tagValue('{$tagName}'), " . $this->__attributesToArray($selectAttr) . ", " . $this->__attributesToArray($optionAttr) . ", " . $showEmpty . ");?>\n"; - $str .= "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Please select the {$prompt}.') ?>\n"; - } else { - $selectedPluralName = 'selected' . ucfirst($pluralName); - $selectAttr = am(array('multiple' => 'multiple', 'class' => 'selectMultiple'), $selectAttr); - $str = "\t<?php echo \$html->selectTag('{$tagName}', \${$pluralName}, \${$selectedPluralName}, " . $this->__attributesToArray($selectAttr) . ", " . $this->__attributesToArray($optionAttr) . ", " . $showEmpty . ");?>\n"; - $str .= "\t<?php echo \$html->tagErrorMsg('{$tagName}', 'Please select the {$prompt}.');?>\n"; - } - $strLabel = "\n\t<?php echo \$form->labelTag('{$tagName}', '{$prompt}');?>\n"; - $divClass = "optional"; - - if ($required) { - $divClass = "required"; - } - $strError = ""; - $divTagInside = sprintf( "%s %s %s", $strError, $strLabel, $str ); - return $this->divTag( $divClass, $divTagInside ); - } -/** - * Generates PHP code for a View file that makes a submit button, wrapped in a DIV. - * - * @param string $displayText - * @param array $htmlOptions - * @return Generated HTML. - */ - function generateSubmitDiv($displayText, $htmlOptions = null) { - $str = "\n\t<?php echo \$html->submit('{$displayText}');?>\n"; - $divTagInside = sprintf( "%s", $str ); - return $this->divTag( 'submit', $divTagInside); - } -/** - * Returns the text wrapped in an HTML DIV, followed by a newline. - * - * @param string $class - * @param string $text - * @return Generated HTML. - */ - function divTag($class, $text) { - return sprintf('<div class="%s">%s</div>', $class, $text ) . "\n"; - } -/** - * Parses the HTML attributes array, which is a common data structure in View files. - * Returns PHP code for initializing this array in a View file. - * - * @param array $htmlAttributes - * @return Generated PHP code. - */ - function __attributesToArray($htmlAttributes) { - if (is_array($htmlAttributes)) { - $keys = array_keys($htmlAttributes); - $vals = array_values($htmlAttributes); - $out = "array("; - - for ($i = 0; $i < count($htmlAttributes); $i++) { - if (substr($vals[$i], 0, 1) != '$') { - $out .= "'{$keys[$i]}' => '{$vals[$i]}', "; - } else { - $out .= "'{$keys[$i]}' => {$vals[$i]}, "; - } - } - if (substr($out, -2, 1) == ',') { - $out = substr($out, 0, strlen($out) - 2); - } - $out .= ")"; - return $out; - } else { - return 'array()'; - } - } -/** - * Outputs usage text on the standard output. - * - */ - function help() { - $this->stdout('CakePHP Bake:'); - $this->hr(); - $this->stdout('The Bake script generates controllers, views and models for your application.'); - $this->stdout('If run with no command line arguments, Bake guides the user through the class'); - $this->stdout('creation process. You can customize the generation process by telling Bake'); - $this->stdout('where different parts of your application are using command line arguments.'); - $this->stdout(''); - $this->hr(''); - $this->stdout('usage: php bake.php [command] [path...]'); - $this->stdout(''); - $this->stdout('commands:'); - $this->stdout(' -app [path...] Absolute path to Cake\'s app Folder.'); - $this->stdout(' -core [path...] Absolute path to Cake\'s cake Folder.'); - $this->stdout(' -help Shows this help message.'); - $this->stdout(' -project [path...] Generates a new app folder in the path supplied.'); - $this->stdout(' -root [path...] Absolute path to Cake\'s \app\webroot Folder.'); - $this->stdout(''); - } -/** - * Checks that given project path does not already exist, and - * finds the app directory in it. Then it calls __buildDirLayout() with that information. - * - * @param string $projectPath - */ - function project($projectPath = null) { - if ($projectPath != '') { - while ($this->__checkPath($projectPath) === true && $this->__checkPath(CONFIGS) === true) { - $response = $this->getInput('Bake -app in '.$projectPath, array('y','n'), 'y'); - if (low($response) == 'y') { - $this->main(); - exit(); - } else { - $projectPath = $this->getInput("What is the full path for this app including the app directory name?\nExample: ".ROOT.DS."myapp", null, ROOT.DS.'myapp'); - } - } - } else { - while ($projectPath == '') { - $projectPath = $this->getInput("What is the full path for this app including the app directory name?\nExample: ".ROOT.DS."myapp", null, ROOT.DS.'myapp'); - - if ($projectPath == '') { - $this->stdout('The directory path you supplied was empty. Please try again.'); - } - } - } - while ($newPath != 'y' && ($this->__checkPath($projectPath) === true || $projectPath == '')) { - $newPath = $this->getInput('Directory '.$projectPath.' exists. Overwrite (y) or insert a new path', null, 'y'); - if ($newPath != 'y') { - $projectPath = $newPath; - } - while ($projectPath == '') { - $projectPath = $this->getInput('The directory path you supplied was empty. Please try again.'); - } - } - $parentPath = explode(DS, $projectPath); - $count = count($parentPath); - $appName = $parentPath[$count - 1]; - if ($appName == '') { - $appName = $parentPath[$count - 2]; - } - $this->__buildDirLayout($projectPath, $appName); - exit(); - } -/** - * Returns true if given path is a directory. - * - * @param string $projectPath - * @return True if given path is a directory. - */ - function __checkPath($projectPath) { - if (is_dir($projectPath)) { - return true; - } else { - return false; - } - } -/** - * Looks for a skeleton template of a Cake application, - * and if not found asks the user for a path. When there is a path - * this method will make a deep copy of the skeleton to the project directory. - * A default home page will be added, and the tmp file storage will be chmod'ed to 0777. - * - * @param string $projectPath - * @param string $appName - */ - function __buildDirLayout($projectPath, $appName) { - $skel = ''; - if ($this->__checkPath(CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'scripts'.DS.'templates'.DS.'skel') === true) { - $skel = CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'scripts'.DS.'templates'.DS.'skel'; - } else { - - while ($skel == '') { - $skel = $this->getInput("What is the full path for the cake install app directory?\nExample: ", null, ROOT.'myapp'.DS); - - if ($skel == '') { - $this->stdout('The directory path you supplied was empty. Please try again.'); - } else { - while ($this->__checkPath($skel) === false) { - $skel = $this->getInput('Directory path does not exist please choose another:'); - } - } - } - } - $this->stdout(''); - $this->hr(); - $this->stdout("Skel Directory: $skel"); - $this->stdout("Will be copied to:"); - $this->stdout("New App Directory: $projectPath"); - $this->hr(); - $looksGood = $this->getInput('Look okay?', array('y', 'n', 'q'), 'y'); - - if (low($looksGood) == 'y' || low($looksGood) == 'yes') { - $verboseOuptut = $this->getInput('Do you want verbose output?', array('y', 'n'), 'n'); - $verbose = false; - - if (low($verboseOuptut) == 'y' || low($verboseOuptut) == 'yes') { - $verbose = true; - } - $this->__copydirr($skel, $projectPath, 0755, $verbose); - $this->hr(); - $this->stdout('Created: '.$projectPath); - $this->hr(); - $this->stdout('Creating welcome page'); - $this->hr(); - $this->__defaultHome($projectPath, $appName); - $this->stdout('Welcome page created'); - if (chmodr($projectPath.DS.'tmp', 0777) === false) { - $this->stdout('Could not set permissions on '. $projectPath.DS.'tmp'.DS.'*'); - $this->stdout('You must manually check that these directories can be wrote to by the server'); - } - return; - } elseif (low($looksGood) == 'q' || low($looksGood) == 'quit') { - $this->stdout('Bake Aborted.'); - } else { - $this->project(); - } - } -/** - * Recursive directory copy. - * - * @param string $fromDir - * @param string $toDir - * @param octal $chmod - * @param boolean $verbose - * @return Success. - */ - function __copydirr($fromDir, $toDir, $chmod = 0755, $verbose = false) { - $errors=array(); - $messages=array(); - - uses('folder'); - $folder = new Folder($toDir, true, 0755); - - if (!is_writable($toDir)) { - $errors[]='target '.$toDir.' is not writable'; - } - - if (!is_dir($fromDir)) { - $errors[]='source '.$fromDir.' is not a directory'; - } - - if (!empty($errors)) { - if ($verbose) { - foreach ($errors as $err) { - $this->stdout('Error: '.$err); - } - } - return false; - } - $exceptions=array('.','..','.svn'); - $handle = opendir($fromDir); - - while (false!==($item = readdir($handle))) { - if (!in_array($item,$exceptions)) { - $from = $folder->addPathElement($fromDir, $item); - $to = $folder->addPathElement($toDir, $item); - if (is_file($from)) { - if (@copy($from, $to)) { - chmod($to, $chmod); - touch($to, filemtime($from)); - $messages[]='File copied from '.$from.' to '.$to; - } else { - $errors[]='cannot copy file from '.$from.' to '.$to; - } - } - - if (is_dir($from)) { - if (@mkdir($to)) { - chmod($to,$chmod); - $messages[]='Directory created: '.$to; - } else { - $errors[]='cannot create directory '.$to; - } - $this->__copydirr($from,$to,$chmod,$verbose); - } - } - } - closedir($handle); - - if ($verbose) { - foreach ($errors as $err) { - $this->stdout('Error: '.$err); - } - foreach ($messages as $msg) { - $this->stdout($msg); - } - } - return true; - } - - function __addAdminRoute($name) { - $file = file_get_contents(CONFIGS.'core.php'); - if (preg_match('%([/\\t\\x20]*define\\(\'CAKE_ADMIN\',[\\t\\x20\'a-z]*\\);)%', $file, $match)) { - $result = str_replace($match[0], 'define(\'CAKE_ADMIN\', \''.$name.'\');', $file); - - if (file_put_contents(CONFIGS.'core.php', $result)) { - return true; - } else { - return false; - } - } else { - return false; - } - } -/** - * Outputs an ASCII art banner to standard output. - * - */ - function welcome() - { - $this->stdout(''); - $this->stdout(' ___ __ _ _ ___ __ _ _ __ __ __ _ _ ___ '); - $this->stdout('| |__| |_/ |__ |__] |__| |__] |__] |__| |_/ |__ '); - $this->stdout('|___ | | | \_ |___ | | | | |__] | | | \_ |___ '); - $this->hr(); - $this->stdout(''); - } -/** - * Writes a file with a default home page to the project. - * - * @param string $dir - * @param string $app - */ - function __defaultHome($dir, $app) { - $path = $dir.DS.'views'.DS.'pages'.DS; - include(CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'scripts'.DS.'templates'.DS.'views'.DS.'home.thtml'); - $this->__createFile($path.'home.thtml', $output); - } -/** - * creates the proper pluralize controller for the url - * - * @param string $name must be a controller name in pluralized form - * @return string $name - */ - function __controllerPath($name) { - return low(Inflector::underscore($name)); - } -/** - * creates the proper pluralize controller class name. - * - * @param string $name - * @return string $name - */ - function __controllerName($name) { - return Inflector::pluralize(Inflector::camelize($name)); - } -/** - * creates the proper singular model name. - * - * @param string $name - * @return string $name - */ - function __modelName($name) { - return Inflector::camelize(Inflector::singularize($name)); - } -/** - * creates the proper singular model key for associations. - * - * @param string $name - * @return string $name - */ - function __modelKey($name) { - return Inflector::underscore(Inflector::singularize($name)).'_id'; - } -/** - * creates the proper model name from a foreign key. - * - * @param string $key - * @return string $name - */ - function __modelNameFromKey($key) { - $name = str_replace('_id', '',$key); - return $this->__modelName($name); - } -/** - * creates the singular name for use in views. - * - * @param string $name - * @return string $name - */ - function __singularName($name) { - return Inflector::variable(Inflector::singularize($name)); - } -/** - * creates the plural name for views. - * - * @param string $name - * @return string $name - */ - function __pluralName($name) { - return Inflector::variable(Inflector::pluralize($name)); - } -/** - * creates the singular human name used in views - * - * @param string $name - * @return string $name - */ - function __singularHumanName($name) { - return Inflector::humanize(Inflector::underscore(Inflector::singularize($name))); - } -/** - * creates the plural humna name used in views - * - * @param string $name - * @return string $name - */ - function __pluralHumanName($name) { - return Inflector::humanize(Inflector::underscore(Inflector::pluralize($name))); - } -/** - * outputs the a list of possible models or controllers from database - * - * @param string $useDbConfig - * @param string $type = Models or Controllers - * @return output - */ - function __doList($useDbConfig = 'default', $type = 'Models') { - $db =& ConnectionManager::getDataSource($useDbConfig); - $usePrefix = empty($db->config['prefix']) ? '' : $db->config['prefix']; - if ($usePrefix) { - $tables = array(); - foreach ($db->listSources() as $table) { - if (!strncmp($table, $usePrefix, strlen($usePrefix))) { - $tables[] = substr($table, strlen($usePrefix)); - } - } - } else { - $tables = $db->listSources(); - } - $this->__tables = $tables; - $this->stdout('Possible '.$type.' based on your current database:'); - $this->__controllerNames = array(); - $this->__modelNames = array(); - $count = count($tables); - for ($i = 0; $i < $count; $i++) { - if (low($type) == 'controllers') { - $this->__controllerNames[] = $this->__controllerName($this->__modelName($tables[$i])); - $this->stdout($i + 1 . ". " . $this->__controllerNames[$i]); - } else { - $this->__modelNames[] = $this->__modelName($tables[$i]); - $this->stdout($i + 1 . ". " . $this->__modelNames[$i]); - } - } - } - -} -?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/.htaccess b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/.htaccess deleted file mode 100644 index 00d12ab..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/.htaccess +++ /dev/null @@ -1,5 +0,0 @@ -<IfModule mod_rewrite.c> - RewriteEngine on - RewriteRule ^$ webroot/ [L] - RewriteRule (.*) webroot/$1 [L] - </IfModule>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/app_controller.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/app_controller.php deleted file mode 100644 index 411f7f0..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/app_controller.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -/* SVN FILE: $Id: app_controller.php 6305 2008-01-02 02:33:56Z phpnut $ */ -/** - * Short description for file. - * - * This file is application-wide controller file. You can put all - * application-wide controller-related methods here. - * - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.app - * @since CakePHP(tm) v 0.2.9 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -/** - * Short description for class. - * - * Add your application-wide methods in the class below, your controllers - * will inherit them. - * - * @package cake - * @subpackage cake.app - */ -class AppController extends Controller { -} -?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/app_model.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/app_model.php deleted file mode 100644 index 37eaecc..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/app_model.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php -/* SVN FILE: $Id: app_model.php 6305 2008-01-02 02:33:56Z phpnut $ */ - -/** - * Application model for Cake. - * - * This file is application-wide model file. You can put all - * application-wide model-related methods here. - * - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.app - * @since CakePHP(tm) v 0.2.9 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ - -/** - * Application model for Cake. - * - * Add your application-wide methods in the class below, your models - * will inherit them. - * - * @package cake - * @subpackage cake.app - */ -class AppModel extends Model{ -} -?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/acl.ini.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/acl.ini.php deleted file mode 100644 index 8179591..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/acl.ini.php +++ /dev/null @@ -1,76 +0,0 @@ -;<?php die() ?> -; SVN FILE: $Id: acl.ini.php 6305 2008-01-02 02:33:56Z phpnut $ -;/** -; * Short description for file. -; * -; * -; * PHP versions 4 and 5 -; * -; * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> -; * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. -; * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project -; * @package cake -; * @subpackage cake.app.config -; * @since CakePHP(tm) v 0.10.0.1076 -; * @version $Revision: 6305 $ -; * @modifiedby $LastChangedBy: phpnut $ -; * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ -; * @license http://www.opensource.org/licenses/mit-license.php The MIT License -; */ - -; acl.ini.php - Cake ACL Configuration -; --------------------------------------------------------------------- -; Use this file to specify user permissions. -; aco = access control object (something in your application) -; aro = access request object (something requesting access) -; -; User records are added as follows: -; -; [uid] -; groups = group1, group2, group3 -; allow = aco1, aco2, aco3 -; deny = aco4, aco5, aco6 -; -; Group records are added in a similar manner: -; -; [gid] -; allow = aco1, aco2, aco3 -; deny = aco4, aco5, aco6 -; -; The allow, deny, and groups sections are all optional. -; NOTE: groups names *cannot* ever be the same as usernames! -; -; ACL permissions are checked in the following order: -; 1. Check for user denies (and DENY if specified) -; 2. Check for user allows (and ALLOW if specified) -; 3. Gather user's groups -; 4. Check group denies (and DENY if specified) -; 5. Check group allows (and ALLOW if specified) -; 6. If no aro, aco, or group information is found, DENY -; -; --------------------------------------------------------------------- - -;------------------------------------- -;Users -;------------------------------------- - -[username-goes-here] -groups = group1, group2 -deny = aco1, aco2 -allow = aco3, aco4 - -;------------------------------------- -;Groups -;------------------------------------- - -[groupname-goes-here] -deny = aco5, aco6 -allow = aco7, aco8
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/bootstrap.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/bootstrap.php deleted file mode 100644 index ef4cedf..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/bootstrap.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -/* SVN FILE: $Id: bootstrap.php 6305 2008-01-02 02:33:56Z phpnut $ */ -/** - * Short description for file. - * - * Long description for file - * - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config - * @since CakePHP(tm) v 0.10.8.2117 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -/** - * - * This file is loaded automatically by the app/webroot/index.php file after the core bootstrap.php is loaded - * This is an application wide file to load any function that is not used within a class define. - * You can also use this to include or require any files in your application. - * - */ -/** - * The settings below can be used to set additional paths to models, views and controllers. - * This is related to Ticket #470 (https://trac.cakephp.org/ticket/470) - * - * $modelPaths = array('full path to models', 'second full path to models', 'etc...'); - * $viewPaths = array('this path to views', 'second full path to views', 'etc...'); - * $controllerPaths = array('this path to controllers', 'second full path to controllers', 'etc...'); - * - */ -//EOF -?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/core.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/core.php deleted file mode 100644 index 77cf1ff..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/core.php +++ /dev/null @@ -1,146 +0,0 @@ -<?php -/* SVN FILE: $Id: core.php 6305 2008-01-02 02:33:56Z phpnut $ */ -/** - * This is core configuration file. - * - * Use it to configure core behaviour ofCake. - * - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config - * @since CakePHP(tm) v 0.2.9 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -/** - * If you do not have mod rewrite on your system - * or if you prefer to use CakePHP pretty urls. - * uncomment the line below. - * Note: If you do have mod rewrite but prefer the - * CakePHP pretty urls, you also have to remove the - * .htaccess files - * release/.htaccess - * release/app/.htaccess - * release/app/webroot/.htaccess - */ -// define ('BASE_URL', env('SCRIPT_NAME')); -/** - * Set debug level here: - * - 0: production - * - 1: development - * - 2: full debug with sql - * - 3: full debug with sql and dump of the current object - * - * In production, the "flash messages" redirect after a time interval. - * With the other debug levels you get to click the "flash message" to continue. - * - */ - define('DEBUG', 1); -/** - * Turn of caching checking wide. - * You must still use the controller var cacheAction inside you controller class. - * You can either set it controller wide, or in each controller method. - * use var $cacheAction = true; or in the controller method $this->cacheAction = true; - */ - define('CACHE_CHECK', false); -/** - * Error constant. Used for differentiating error logging and debugging. - * Currently PHP supports LOG_DEBUG - */ - define('LOG_ERROR', 2); -/** - * CakePHP includes 3 types of session saves - * database or file. Set this to your preferred method. - * If you want to use your own save handler place it in - * app/config/name.php DO NOT USE file or database as the name. - * and use just the name portion below. - * - * Setting this to cake will save files to /cakedistro/tmp directory - * Setting it to php will use the php default save path - * Setting it to database will use the database - * - */ - define('CAKE_SESSION_SAVE', 'php'); -/** - * If using you own table name for storing sessions - * set the table name here. - * DO NOT INCLUDE PREFIX IF YOU HAVE SET ONE IN database.php - * - */ - define('CAKE_SESSION_TABLE', 'cake_sessions'); -/** - * Set a random string of used in session. - * - */ - define('CAKE_SESSION_STRING', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi'); -/** - * Set the name of session cookie - * - */ - define('CAKE_SESSION_COOKIE', 'CAKEPHP'); -/** - * Set level of Cake security. - * - */ - define('CAKE_SECURITY', 'high'); -/** - * Set Cake Session time out. - * If CAKE_SECURITY define is set - * high: multiplied by 10 - * medium: is multiplied by 100 - * low is: multiplied by 300 - * - * Number below is seconds. - */ - define('CAKE_SESSION_TIMEOUT', '120'); -/** - * Uncomment the define below to use cake built in admin routes. - * You can set this value to anything you want. - * All methods related to the admin route should be prefixed with the - * name you set CAKE_ADMIN to. - * For example: admin_index, admin_edit - */ -// define('CAKE_ADMIN', 'admin'); -/** - * The define below is used to turn cake built webservices - * on or off. Default setting is off. - */ - define('WEBSERVICES', 'off'); -/** - * Compress output CSS (removing comments, whitespace, repeating tags etc.) - * This requires a/var/cache directory to be writable by the web server (caching). - * To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use Controller::cssTag(). - */ - define('COMPRESS_CSS', false); -/** - * If set to true, helpers would output data instead of returning it. - */ - define('AUTO_OUTPUT', false); -/** - * If set to false, session would not automatically be started. - */ - define('AUTO_SESSION', true); -/** - * Set the max size of file to use md5() . - */ - define('MAX_MD5SIZE', (5 * 1024) * 1024); -/** - * To use Access Control Lists with Cake... - */ - define('ACL_CLASSNAME', 'DB_ACL'); - define('ACL_FILENAME', 'dbacl' . DS . 'db_acl'); -?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/database.php.default b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/database.php.default deleted file mode 100644 index fbbb1a3..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/database.php.default +++ /dev/null @@ -1,74 +0,0 @@ -<?php -/* SVN FILE: $Id: database.php.default 6305 2008-01-02 02:33:56Z phpnut $ */ -/** - * This is core configuration file. - * - * Use it to configure core behaviour ofCake. - * - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config - * @since CakePHP(tm) v 0.2.9 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -/** - * In this file you set up your database connection details. - * - * @package cake - * @subpackage cake.config - */ -/** - * Database configuration class. - * You can specify multiple configurations for production, development and testing. - * - * driver => - * mysql, postgres, sqlite, adodb-drivername, pear-drivername - * - * connect => - * MySQL set the connect to either mysql_pconnect of mysql_connect - * PostgreSQL set the connect to either pg_pconnect of pg_connect - * SQLite set the connect to sqlite_popen sqlite_open - * ADOdb set the connect to one of these - * (http://phplens.com/adodb/supported.databases.html) and - * append it '|p' for persistent connection. (mssql|p for example, or just mssql for not persistent) - * - * host => - * the host you connect to the database - * MySQL 'localhost' to add a port number use 'localhost:port#' - * PostgreSQL 'localhost' to add a port number use 'localhost port=5432' - * - */ -class DATABASE_CONFIG -{ - var $default = array('driver' => 'mysql', - 'connect' => 'mysql_connect', - 'host' => 'localhost', - 'login' => 'user', - 'password' => 'password', - 'database' => 'project_name', - 'prefix' => ''); - - var $test = array('driver' => 'mysql', - 'connect' => 'mysql_connect', - 'host' => 'localhost', - 'login' => 'user', - 'password' => 'password', - 'database' => 'project_name-test', - 'prefix' => ''); -} -?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/inflections.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/inflections.php deleted file mode 100644 index e08a7d8..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/inflections.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php -/* SVN FILE: $Id: inflections.php 6305 2008-01-02 02:33:56Z phpnut $ */ -/** - * Custom Inflected Words. - * - * This file is used to hold words that are not matched in the normail Inflector::pluralize() and - * Inflector::singularize() - * - * PHP versions 4 and % - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config - * @since CakePHP(tm) v 1.0.0.2312 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -/** - * This is a key => value array of regex used to match words. - * If key matches then the value is returned. - * - * $pluralRules = array('/(s)tatus$/i' => '\1\2tatuses', '/^(ox)$/i' => '\1\2en', '/([m|l])ouse$/i' => '\1ice'); - */ - $pluralRules = array(); -/** - * This is a key only array of plural words that should not be inflected. - * Notice the last comma - * - * $uninflectedPlural = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox'); - */ - $uninflectedPlural = array(); -/** - * This is a key => value array of plural irregular words. - * If key matches then the value is returned. - * - * $irregularPlural = array('atlas' => 'atlases', 'beef' => 'beefs', 'brother' => 'brothers') - */ - $irregularPlural = array(); -/** - * This is a key => value array of regex used to match words. - * If key matches then the value is returned. - * - * $singularRules = array('/(s)tatuses$/i' => '\1\2tatus', '/(matr)ices$/i' =>'\1ix','/(vert|ind)ices$/i') - */ - $singularRules = array(); -/** - * This is a key only array of singular words that should not be inflected. - * You should not have to change this value below if you do change it use same format - * as the $uninflectedPlural above. - */ - $uninflectedSingular = $uninflectedPlural; -/** - * This is a key => value array of singular irregular words. - * Most of the time this will be a reverse of the above $irregularPlural array - * You should not have to change this value below if you do change it use same format - * - * $irregularSingular = array('atlases' => 'atlas', 'beefs' => 'beef', 'brothers' => 'brother') - */ - $irregularSingular = array_flip($irregularPlural); -?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/routes.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/routes.php deleted file mode 100644 index 45ae36a..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/routes.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -/* SVN FILE: $Id: routes.php 6305 2008-01-02 02:33:56Z phpnut $ */ -/** - * Short description for file. - * - * In this file, you set up routes to your controllers and their actions. - * Routes are very important mechanism that allows you to freely connect - * different urls to chosen controllers and their actions (functions). - * - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.app.config - * @since CakePHP(tm) v 0.2.9 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -/** - * Here, we are connecting '/' (base path) to controller called 'Pages', - * its action called 'display', and we pass a param to select the view file - * to use (in this case, /app/views/pages/home.thtml)... - */ - $Route->connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); -/** - * ...and connect the rest of 'Pages' controller's urls. - */ - $Route->connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); -/** - * Then we connect url '/test' to our test controller. This is helpfull in - * developement. - */ - $Route->connect('/tests', array('controller' => 'tests', 'action' => 'index')); -?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/sql/db_acl.sql b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/sql/db_acl.sql deleted file mode 100644 index 8c7aae8..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/sql/db_acl.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE `acos` ( - `id` int(11) NOT NULL auto_increment, - `model` varchar(255) NOT NULL default '', - `object_id` int(11) default NULL, - `alias` varchar(255) NOT NULL default '', - `lft` int(11) default NULL, - `rght` int(11) default NULL, - PRIMARY KEY (`id`) -); - -CREATE TABLE `aros` ( - `id` int(11) NOT NULL auto_increment, - `model` varchar(255) NOT NULL default '', - `user_id` int(11) default NULL, - `alias` varchar(255) NOT NULL default '', - `lft` int(11) default NULL, - `rght` int(11) default NULL, - PRIMARY KEY (`id`) -); - -CREATE TABLE `aros_acos` ( - `id` int(11) NOT NULL auto_increment, - `aro_id` int(11) default NULL, - `aco_id` int(11) default NULL, - `_create` int(1) NOT NULL default '0', - `_read` int(1) NOT NULL default '0', - `_update` int(1) NOT NULL default '0', - `_delete` int(11) NOT NULL default '0', - PRIMARY KEY (`id`) -); diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/sql/sessions.sql b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/sql/sessions.sql deleted file mode 100644 index 7166ae4..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/config/sql/sessions.sql +++ /dev/null @@ -1,11 +0,0 @@ --- @copyright Copyright 2005-2007, Cake Software Foundation, Inc. --- @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project --- @since CakePHP v 0.10.8.1997 --- @version $Revision: 4409 $ - -CREATE TABLE cake_sessions ( - id varchar(255) NOT NULL default '', - data text, - expires int(11) default NULL, - PRIMARY KEY (id) -);
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/controllers/pages_controller.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/controllers/pages_controller.php deleted file mode 100644 index b308565..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/controllers/pages_controller.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php -/* SVN FILE: $Id: pages_controller.php 6305 2008-01-02 02:33:56Z phpnut $ */ - -/** - * Short description for file. - * - * This file is application-wide controller file. You can put all - * application-wide controller-related methods here. - * - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.app.controllers - * @since CakePHP(tm) v 0.2.9 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ - -/** - * Short description for class. - * - * This file is application-wide controller file. You can put all - * application-wide controller-related methods here. - * - * Add your application-wide methods in the class below, your controllers - * will inherit them. - * - * @package cake - * @subpackage cake.app.controllers - */ -class PagesController extends AppController{ - -/** - * Enter description here... - * - * @var unknown_type - */ - var $name = 'Pages'; - -/** - * Enter description here... - * - * @var unknown_type - */ - var $helpers = array('Html'); - -/** - * This controller does not use a model - * - * @var $uses - */ - var $uses = null; - -/** - * Displays a view - * - */ - function display() { - if (!func_num_args()) { - $this->redirect('/'); - } - - $path=func_get_args(); - - if (!count($path)) { - $this->redirect('/'); - } - - $count =count($path); - $page =null; - $subpage=null; - $title =null; - - if (!empty($path[0])) { - $page = $path[0]; - } - - if (!empty($path[1])) { - $subpage = $path[1]; - } - - if (!empty($path[$count - 1])) { - $title = ucfirst($path[$count - 1]); - } - - $this->set('page', $page); - $this->set('subpage', $subpage); - $this->set('title', $title); - $this->render(join('/', $path)); - } -} -?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/index.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/index.php deleted file mode 100644 index bd8993b..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/index.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php -/* SVN FILE: $Id: index.php 6305 2008-01-02 02:33:56Z phpnut $ */ -/** - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.app - * @since CakePHP(tm) v 0.10.0.1076 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -require 'webroot' . DIRECTORY_SEPARATOR . 'index.php'; -?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/ajax.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/ajax.thtml deleted file mode 100644 index c6daffc..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/ajax.thtml +++ /dev/null @@ -1,30 +0,0 @@ -<?php -/* SVN FILE: $Id: ajax.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ - -/** - * - * - * - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts - * @since CakePHP(tm) v 0.10.0.1076 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -?> -<?php echo $content_for_layout; ?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/default.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/default.thtml deleted file mode 100644 index 0172200..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/default.thtml +++ /dev/null @@ -1,30 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> -<title>CakePHP(tm) : <?php echo $title_for_layout;?></title> -<link rel="icon" href="<?php echo $this->webroot . 'favicon.ico';?>" type="image/x-icon" /> -<link rel="shortcut icon" href="<?php echo $this->webroot . 'favicon.ico';?>" type="image/x-icon" /> -<?php echo $html->css('cake.generic');?> -</head> -<body> - <div id="container"> - <div id="header"> - <h1>CakePHP Rapid Development</h1> - </div> - <div id="content"> - <?php if ($session->check('Message.flash')) - { - $session->flash(); - } - echo $content_for_layout; - ?> - </div> - <div id="footer"> - - <a href="http://www.cakephp.org/" target="_new"> - <?php echo $html->image('cake.power.png', array('alt'=>"CakePHP(tm) : Rapid Development Framework", 'border'=>"0"));?> - </a> - </div> - </div> -</body> -</html>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/flash.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/flash.thtml deleted file mode 100644 index b1880c2..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/views/layouts/flash.thtml +++ /dev/null @@ -1,50 +0,0 @@ -<?php -/* SVN FILE: $Id: flash.thtml 6305 2008-01-02 02:33:56Z phpnut $ */ - -/** - * - * - * - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.libs.view.templates.layouts - * @since CakePHP(tm) v 0.10.0.1076 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> -<title><?php echo $page_title?></title> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<?php if (Configure::read() == 0) { ?> -<meta http-equiv="Refresh" content="<?php echo $pause?>;url=<?php echo $url?>"/> -<?php } ?> -<style><!-- -P { text-align:center; font:bold 1.1em sans-serif } -A { color:#444; text-decoration:none } -A:HOVER { text-decoration: underline; color:#44E } ---></style> -</head> - -<body> - -<p><a href="<?php echo $url?>"><?php echo $message?></a></p> - -</body> -</html>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/.htaccess b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/.htaccess deleted file mode 100644 index 8ca27c0..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/.htaccess +++ /dev/null @@ -1,6 +0,0 @@ -<IfModule mod_rewrite.c> - RewriteEngine On - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] -</IfModule>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/css.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/css.php deleted file mode 100644 index 23223a6..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/css.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php -/* SVN FILE: $Id: css.php 6305 2008-01-02 02:33:56Z phpnut $ */ -/** - * Short description for file. - * - * Long description for file - * - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.app.webroot - * @since CakePHP(tm) v 0.2.9 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -/** - * Enter description here... - */ - require(CONFIGS . 'paths.php'); - require(CAKE . 'basics.php'); - require(LIBS . 'folder.php'); - require(LIBS . 'file.php'); - require(LIBS . 'legacy.php'); -/** - * Enter description here... - * - * @param unknown_type $path - * @param unknown_type $name - * @return unknown - */ - function make_clean_css($path, $name) { - require(VENDORS . 'csspp' . DS . 'csspp.php'); - $data =file_get_contents($path); - $csspp =new csspp(); - $output=$csspp->compress($data); - $ratio =100 - (round(strlen($output) / strlen($data), 3) * 100); - $output=" /* file: $name, ratio: $ratio% */ " . $output; - return $output; - } -/** - * Enter description here... - * - * @param unknown_type $path - * @param unknown_type $content - * @return unknown - */ - function write_css_cache($path, $content) { - if (!is_dir(dirname($path))) { - mkdir(dirname($path)); - } - $cache=new File($path); - return $cache->write($content); - } - - if (preg_match('|\.\.|', $url) || !preg_match('|^ccss/(.+)$|i', $url, $regs)) { - die('Wrong file name.'); - } - - $filename = 'css/' . $regs[1]; - $filepath = CSS . $regs[1]; - $cachepath = CACHE . 'css' . DS . str_replace(array('/','\\'), '-', $regs[1]); - - if (!file_exists($filepath)) { - die('Wrong file name.'); - } - - if (file_exists($cachepath)) { - $templateModified=filemtime($filepath); - $cacheModified =filemtime($cachepath); - - if ($templateModified > $cacheModified) { - $output=make_clean_css($filepath, $filename); - write_css_cache($cachepath, $output); - } else { - $output = file_get_contents($cachepath); - } - } else { - $output=make_clean_css($filepath, $filename); - write_css_cache($cachepath, $output); - } - header("Date: " . date("D, j M Y G:i:s ", $templateModified) . 'GMT'); - header("Content-Type: text/css"); - header("Expires: " . gmdate("D, j M Y H:i:s", time() + DAY) . " GMT"); - header("Cache-Control: cache"); // HTTP/1.1 - header("Pragma: cache"); // HTTP/1.0 - print $output; -?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/css/cake.generic.css b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/css/cake.generic.css deleted file mode 100644 index 491dc7a..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/css/cake.generic.css +++ /dev/null @@ -1,251 +0,0 @@ -*{ -margin:0; -padding:0; -} - -body{ -font-family:"frutiger linotype","lucida grande",helvetica,arial,sans-serif; -text-align:center; -color:#333; -font-size: 76%; -} - -/* General Style Info */ -a{ -color:#003d4c; -text-decoration:underline; -} -a:hover{ -color:#003d4c; -text-decoration:none; -} - -a img{ -border:none; -} - -h1, h2, h3, h4{ -font-weight:normal; -} - -h1{ -color: #003d4c; -margin:0.3em 0; -font-size: 180%; -} - -h2{ -color:#c6c65b; -padding-top: 1em; -margin:0.3em 0; -font-size: 180%; -} - -h3{ -color:#c6c65b; -padding-top:2em; -font-size: 140%; -} - -h4{ -color:#c6c65b; -padding-top:0.5em; -font-weight:normal; -} - -em { -font-size: 12px; -} - -ul, li { -margin: 0 12px; -} - -/* Layout */ - -#container{ -text-align:left; -} - -#header{ -margin-top: 1em; -padding: 4px 20px; -} - -#content{ -clear:both; -padding: 0px 40px 10px 40px; -background-color: #fff; -color: #333; -} -#footer{ -clear:both; -padding: 6px 10px; -text-align: right; -} - -/* tables */ - -table { -width: 100%; -border-top: 1px solid #ccc; -border-left: 1px solid #ccc; -border-bottom: 1px solid #ccc; -color:#333; -background-color: #fff; -clear:both; -padding: 0; -margin: 0 0 2em 0; -white-space: normal; -} -th { -background-color: #e2e2e2; -border-top: 1px solid #fff; -border-left: 1px solid #fff; -border-right: 1px solid #003d4c; -border-bottom: 1px solid #003d4c; -text-align: center; -padding:1px 4px; -} -table tr td { -border-right: 1px solid #ddd; -padding:4px 4px; -vertical-align:top; -text-align: center; -} -table tr.altRow td { -background: #f4f4f4; -} -table td.actions { - white-space: nowrap; -} -#cakeSqlLog td { -text-align: left; -padding: 4px 8px; -background: #fff; -border-bottom: 2px solid #ccc; -} - -/* scaffold show */ - -div.related { -clear:both; -display:block; -} -dl { -line-height:2em; -margin:0em 1em; -float:left; -width: 400px; -} -dt { -font-weight: bold; -vertical-align:top; -} -dd { -margin-left:10em; -margin-top:-2em; -vertical-align:top; -} - -/* notices and errors */ - -#flashMessage, .error, .error_message { -color:#900; -font-size: 16px; -background-color: #fff; -margin: 8px 0px; -font-weight: bold; -} -.error_message { -clear: both; -} -.error em { -font-size: 18px; -color: #003d4c; -} -.notice { -color: #656565; -font-size: 14px; -background-color: #f4f4f4; -padding: 0.5em; -margin: 1em 0; -display:block; -} -.tip { -color: #656565; -background-color: #ddd; -} - -/* forms */ - -form { -margin-top: 2em; -} -form div{ -vertical-align: text-top; -margin-left: 1em; -margin-bottom:2em; -} -form div.date{ -margin-left: 0em; -} -label { -display: block; -float:left; -width: 140px; -font-size: 14px; -padding-right: 20px; -} -input[type=checkbox] { -float: left; -clear: left; -margin: 2px 6px 7px 2px; -} -input, textarea { -clear: both; -display:block; -font-size: 14px; -font-family: inherit; -} -select { -clear: both; -vertical-align: text-bottom; -font-size: 14px; -font-family: inherit; -} -option { -font-size: 14px; -font-family: inherit; -padding: 0 0.3em; -} -input[type=submit] { -display: inline; -vertical-align: bottom; -} -div.required { -clear: both; -color:#222; -font-weight:bold; -} -div.optional { -clear: both; -color:#555; -} -div.submit { -clear: both; -margin-top: 40px; -margin-left: 140px; -} -/* action links */ -ul.actions { -float: left; -margin-left:20px; -width: 200px; -} -ul.actions li { -margin-top: 4px; -} -pre { -padding: 1em; -}
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/favicon.ico b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/favicon.ico Binary files differdeleted file mode 100644 index 1bc32bd..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/favicon.ico +++ /dev/null diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/img/cake.power.png b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/img/cake.power.png Binary files differdeleted file mode 100644 index 699ef80..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/img/cake.power.png +++ /dev/null diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/index.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/index.php deleted file mode 100644 index 6874e2b..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/index.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php -/* SVN FILE: $Id: index.php 6305 2008-01-02 02:33:56Z phpnut $ */ -/** - * Short description for file. - * - * Long description for file - * - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.app.webroot - * @since CakePHP(tm) v 0.2.9 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -/** - * Do not change - */ - if (!defined('DS')) { - define('DS', DIRECTORY_SEPARATOR); - } -/** - * These defines should only be edited if you have cake installed in - * a directory layout other than the way it is distributed. - * Each define has a commented line of code that explains what you would change. - * - */ - if (!defined('ROOT')) { - //define('ROOT', 'FULL PATH TO DIRECTORY WHERE APP DIRECTORY IS LOCATED DO NOT ADD A TRAILING DIRECTORY SEPARATOR'; - //You should also use the DS define to seperate your directories - define('ROOT', dirname(dirname(dirname(__FILE__)))); - } - if (!defined('APP_DIR')) { - //define('APP_DIR', 'DIRECTORY NAME OF APPLICATION'; - define('APP_DIR', basename(dirname(dirname(__FILE__)))); - } -/** - * This only needs to be changed if the cake installed libs are located - * outside of the distributed directory structure. - */ - if (!defined('CAKE_CORE_INCLUDE_PATH')) { - //define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR'; - //You should also use the DS define to seperate your directories - define('CAKE_CORE_INCLUDE_PATH', ROOT); - } -/////////////////////////////// -//DO NOT EDIT BELOW THIS LINE// -/////////////////////////////// - if (!defined('WEBROOT_DIR')) { - define('WEBROOT_DIR', basename(dirname(__FILE__))); - } - if (!defined('WWW_ROOT')) { - define('WWW_ROOT', dirname(__FILE__) . DS); - } - if (!defined('CORE_PATH')) { - if (function_exists('ini_set')) { - ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS . PATH_SEPARATOR . ini_get('include_path')); - 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 CORE_PATH . 'cake' . DS . 'bootstrap.php'; - if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') { - } else { - $Dispatcher = new Dispatcher(); - $Dispatcher->dispatch($url); - } - if (Configure::read() > 0) { - echo "<!-- " . round(getMicrotime() - $TIME_START, 4) . "s -->"; - } -?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/js/vendors.php b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/js/vendors.php deleted file mode 100644 index 1075bfb..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/skel/webroot/js/vendors.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php -/* SVN FILE: $Id: vendors.php 6305 2008-01-02 02:33:56Z phpnut $ */ -/** - * Short description for file. - * - * This file includes js vendor-files from /vendor/ directory if they need to - * be accessible to the public. - * - * PHP versions 4 and 5 - * - * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> - * Copyright 2005-2008, 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 2005-2008, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.app.webroot.js - * @since CakePHP(tm) v 0.2.9 - * @version $Revision: 6305 $ - * @modifiedby $LastChangedBy: phpnut $ - * @lastmodified $Date: 2008-01-01 21:33:56 -0500 (Tue, 01 Jan 2008) $ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -/** - * Enter description here... - */ -$file = $_GET['file']; -$pos = strpos($file, '..'); -if ($pos === false) { - if (is_file('../../vendors/javascript/'.$file) && (preg_match('/(\/.+)\\.js/', $file))) - { - readfile('../../vendors/javascript/'.$file); - } -} else { - header('HTTP/1.1 404 Not Found'); -} -?>
\ No newline at end of file diff --git a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/views/home.thtml b/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/views/home.thtml deleted file mode 100644 index d107e55..0000000 --- a/poc/poc02-compiling-cake/src/vendor/cake_1.1.20.7692/cake/scripts/templates/views/home.thtml +++ /dev/null @@ -1,16 +0,0 @@ -<?php -$output = "<p class=\"notice\">Your database configuration file is <?php echo file_exists(CONFIGS.'database.php') ?' present.' . \$filePresent = ' ' : ' not present.'; ?></p>\n"; -$output .= "<?php if (!empty(\$filePresent)):?>\n"; -$output .= "<?php uses('model' . DS . 'connection_manager'); \$db = ConnectionManager::getInstance(); ?>\n"; -$output .= "<?php \$connected = \$db->getDataSource('default'); ?>\n"; -$output .= "<p class=\"notice\">Cake<?php echo \$connected->isConnected() ? ' is able to' : ' is not able to';?> connect to the database.</p>\n"; -$output .= "<br />\n"; -$output .= "<?php endif; ?>\n"; -$output .= "<h1>Sweet, \"".Inflector::humanize($app)."\" got Baked by CakePHP!</h1>\n"; -$output .= "<h2>Editing this Page</h2>\n"; -$output .= "<p>\n"; -$output .= "To change the content of this page, edit: ".$dir.DS."views".DS."pages".DS."home.thtml.<br />\n"; -$output .= "To change its layout, edit: ".$dir.DS."views".DS."layouts".DS."default.thtml.<br />\n"; -$output .= "You can also add some CSS styles for your pages at: ".$dir.DS."webroot/css/.\n"; -$output .= "</p>\n"; -?>
\ No newline at end of file |