Author: phpnut
Date: 8:13:45 PM, Friday, October 28, 2005
Message:
adding version text file

[1257]
Author: phpnut
Date: 8:03:24 PM, Friday, October 28, 2005
Message:
small typo in last commit

[1256]
Author: phpnut
Date: 7:16:50 PM, Friday, October 28, 2005
Message:
Added fix for a self join of 1 to 1 associations.
This is automatic and adds Child_ to the joined class for hasOne or belongsTo.
Scaffold is updated to work with this change.
You will have to consider the Child_ prefix when working with self joins.

[1253]
Author: phpnut
Date: 4:07:55 PM, Friday, October 28, 2005
Message:
Fixed problem with session cookies being set for each path in the URL.
Added char to switch in Controller::generateFieldNames() 

[1252]
Author: phpnut
Date: 1:59:49 PM, Friday, October 28, 2005
Message:
Updated routes.php.default with change to route case.
Removed debug code I had added to Model::findAll

[1251]
Author: phpnut
Date: 1:51:00 PM, Friday, October 28, 2005
Message:
Added a fix for class already defined error.
Updated core.php docblock with level 3 setting for DEBUG.
Change  instances of AppController to Controller for loading error messages.
Updated 404 errors to use default layout

[1250]
Author: phpnut
Date: 1:34:08 PM, Friday, October 28, 2005
Message:
renaming error or error404

[1249]
Author: phpnut
Date: 1:32:51 PM, Friday, October 28, 2005
Message:
moving error.thtml to errors directory


git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1259 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2005-10-29 01:21:47 +00:00
parent 051fe48685
commit bc6de8791d
12 changed files with 99 additions and 137 deletions

9
VERSION.txt Normal file
View file

@ -0,0 +1,9 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// +---------------------------------------------------------------------------------------------------+ //
// + $Id$
// + Last Modified: $Date$
// + Modified By: $LastChangedBy$
// +---------------------------------------------------------------------------------------------------+ //
///////////////////////////////////////////////////////////////////////////////////////////////////////////
0.10.2.1258_alpha

View file

@ -50,6 +50,7 @@
* - 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.

View file

@ -47,17 +47,17 @@
* and its action called 'display'. We pass a parameter to select the view file
* to use (in this case, /app/views/pages/home.thtml).
*/
$Route->connect ('/', array('controller'=>'Pages', 'action'=>'display', 'home'));
$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'));
$Route->connect ('/pages/*', array('controller'=>'pages', 'action'=>'display'));
/**
* Then we connect url '/test' to our test controller. This is helpful in
* development.
*/
$Route->connect ('/test', array('controller'=>'Tests', 'action'=>'test_all'));
$Route->connect ('/test', array('controller'=>'tests', 'action'=>'test_all'));
?>

View file

@ -135,8 +135,7 @@ class Dispatcher extends Object
if ($missingController)
{
require_once(CAKE.'app_controller.php');
$controller =& new AppController();
$controller =& new Controller();
$params['action'] = 'missingController';
if (empty($params['controller']))
{
@ -205,7 +204,7 @@ class Dispatcher extends Object
if(!defined('AUTO_SESSION') || AUTO_SESSION == true)
{
session_write_close();
$session =& CakeSession::getInstance();
$session =& CakeSession::getInstance($this->base);
}
return $this->_invoke($controller, $params );
}
@ -364,9 +363,10 @@ class Dispatcher extends Object
{
$controller =& new Controller ($this);
$controller->base = $this->base;
$controller->autoLayout = false;
$controller->autoLayout = true;
$controller->set(array('code'=>$code, 'name'=>$name, 'message'=>$message));
return $controller->render('layouts/error');
$controller->pageTitle = $code.' '. $name;
return $controller->render('errors/error404');
}

View file

@ -592,6 +592,7 @@ class Controller extends Object
{
foreach ($tables as $tabl)
{
$alias = null;
// set up the prompt
if( $objRegistryModel->isForeignKey($tabl['name']) )
{
@ -599,10 +600,16 @@ class Controller extends Object
$fieldNames[ $tabl['name'] ]['prompt'] = Inflector::humanize($niceName);
// this is a foreign key, also set up the other controller
$fieldNames[ $tabl['name'] ]['table'] = Inflector::pluralize($niceName);
$fieldNames[ $tabl['name'] ]['model'] = $this->{$model}->tableToModel[$fieldNames[ $tabl['name'] ]['table']];
if($this->{$model}->tableToModel[$fieldNames[ $tabl['name'] ]['table']] == $model)
{
$alias = 'Child_';
}
$fieldNames[ $tabl['name'] ]['prompt'] = Inflector::humanize($alias.$niceName);
$fieldNames[ $tabl['name'] ]['model'] = $alias.$this->{$model}->tableToModel[$fieldNames[ $tabl['name'] ]['table']];
$fieldNames[ $tabl['name'] ]['modelKey'] = $this->{$model}->tableToModel[$fieldNames[ $tabl['name'] ]['table']];
$fieldNames[ $tabl['name'] ]['controller'] = Inflector::pluralize($this->{$model}->tableToModel[Inflector::pluralize($niceName)]);
$fieldNames[ $tabl['name'] ]['foreignKey'] = true;
}
}
else if( 'created' != $tabl['name'] && 'updated' != $tabl['name'] )
{
$fieldNames[$tabl['name']]['prompt'] = Inflector::humanize($tabl['name']);
@ -658,6 +665,7 @@ class Controller extends Object
}
break;
case "varchar":
case "char":
{
if( isset( $fieldNames[ $tabl['name']]['foreignKey'] ) )
{
@ -667,8 +675,7 @@ class Controller extends Object
// get the list of options from the other model.
$registry = ClassRegistry::getInstance();
$otherModel = $registry->getObject(Inflector::underscore($fieldNames[$tabl['name']]['model']));
$otherModel = $registry->getObject(Inflector::underscore($fieldNames[$tabl['name']]['modelKey']));
if( is_object($otherModel) )
{
@ -679,7 +686,7 @@ class Controller extends Object
{
foreach( $pass as $key=>$value )
{
if( $key == $fieldNames[ $tabl['name']]['model'] && isset( $value['id'] ) && isset( $value[$otherDisplayField] ) )
if( $alias.$key == $fieldNames[ $tabl['name']]['model'] && isset( $value['id'] ) && isset( $value[$otherDisplayField] ) )
{
$fieldNames[ $tabl['name']]['options'][$value['id']] = $value[$otherDisplayField];
}
@ -730,9 +737,8 @@ class Controller extends Object
// get the list of options from the other model.
$registry = ClassRegistry::getInstance();
$otherModel = $registry->getObject(Inflector::underscore($fieldNames[$tabl['name']]['model']));
$otherModel = $registry->getObject(Inflector::underscore($fieldNames[$tabl['name']]['modelKey']));
if( is_object($otherModel) )
{
if( $doCreateOptions )
@ -742,7 +748,7 @@ class Controller extends Object
{
foreach( $pass as $key=>$value )
{
if( $key == $fieldNames[ $tabl['name']]['model'] && isset( $value['id'] ) && isset( $value[$otherDisplayField] ) )
if( $alias.$key == $fieldNames[ $tabl['name']]['model'] && isset( $value['id'] ) && isset( $value[$otherDisplayField] ) )
{
$fieldNames[ $tabl['name']]['options'][$value['id']] = $value[$otherDisplayField];
}

View file

@ -64,7 +64,7 @@
{
// this is a foreign key, figure out what the display field should be for this model.
$otherModelKey = Inflector::underscore($value['model']);
$otherModelKey = Inflector::underscore($value['modelKey']);
$otherControllerName = $value['controller'];
$registry = ClassRegistry::getInstance();
$otherModelObject = $registry->getObject( $otherModelKey );

View file

@ -94,6 +94,14 @@ class Model extends Object
*/
var $table = false;
/**
* Table name for this Model.
*
* @var string
* @access public
*/
var $tableId = null;
/**
* Table metadata
*
@ -195,6 +203,11 @@ class Model extends Object
$this->name = get_class($this);
}
if($this->tableId === null)
{
$this->tableId = 'id';
}
$this->currentModel = Inflector::underscore($this->name);
if($db != null)
@ -655,11 +668,11 @@ class Model extends Object
$this->validationErrors = null;
if(is_array($this->id))
{
return $this->id? $this->find("$this->table.id = '{$this->id[0]}'", $fields): false;
return $this->id? $this->find("$this->name.$this->tableId = '{$this->id[0]}'", $fields): false;
}
else
{
return $this->id? $this->find("$this->table.id = '{$this->id}'", $fields): false;
return $this->id? $this->find("$this->name.$this->tableId = '{$this->id}'", $fields): false;
}
}
@ -995,7 +1008,7 @@ class Model extends Object
function findAll ($conditions = null, $fields = null, $order = null, $limit=50, $page=1)
{
$conditions = $this->parseConditions($conditions);
$alias = null;
if (is_array($fields))
{
$f = $fields;
@ -1018,11 +1031,19 @@ class Model extends Object
list($model, $value) = $rule;
if(!empty($this->{$model}->{$this->currentModel.'_foreignkey'}))
{
if($this->name == $this->{$model}->name)
{
$alias = 'Child_'.$this->{$model}->name;
}
else
{
$alias = $this->{$model}->name;
}
$oneToOneConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'});
$oneToOneOrder = $this->{$model}->{$this->currentModel.'_order'};
$joins[] = "LEFT JOIN {$this->{$model}->table} ON
{$this->{$model}->table}.{$this->{$model}->{$this->currentModel.'_foreignkey'}} = {$this->table}.id"
$joins[] = "LEFT JOIN {$this->{$model}->table} AS $alias ON
$alias.{$this->{$model}->{$this->currentModel.'_foreignkey'}} = {$this->name}.id"
.($oneToOneConditions? " WHERE {$oneToOneConditions}":null)
.($oneToOneOrder? " ORDER BY {$oneToOneOrder}": null);
}
@ -1033,14 +1054,22 @@ class Model extends Object
{
foreach ($this->_belongsToOther as $rule)
{
list($model, $value) = $rule;
list($model, $value) = $rule;
if(!empty($this->{$model}->{$this->currentModel.'_foreignkey'}))
{
if($this->name == $this->{$model}->name)
{
$alias = 'Child_'.$this->{$model}->name;
}
else
{
$alias = $this->{$model}->name;
}
$belongsToOtherConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'});
$belongsToOtherOrder = $this->{$model}->{$this->currentModel.'_order'};
$joins[] = "LEFT JOIN {$this->{$model}->table} ON
{$this->table}.{$this->{$model}->{$this->currentModel.'_foreignkey'}} = {$this->{$model}->table}.id"
$joins[] = "LEFT JOIN {$this->{$model}->table} AS $alias ON {$this->name}.{$this->{$model}->{$this->currentModel.'_foreignkey'}} = $alias.id"
.($belongsToOtherConditions? " WHERE {$belongsToOtherConditions}":null)
.($belongsToOtherOrder? " ORDER BY {$belongsToOtherOrder}": null);
}
@ -1058,7 +1087,7 @@ class Model extends Object
: '';
$sql = "SELECT " .join(', ', $f)
." FROM {$this->table} {$joins}"
." FROM {$this->table} AS {$this->name} {$joins}"
.($conditions? " WHERE {$conditions}":null)
.($order? " ORDER BY {$order}": null)
.$limit_str;
@ -1083,6 +1112,7 @@ class Model extends Object
}
}
foreach ($data as $key => $value)
{
foreach ($this->tableToModel as $key1 => $value1)
@ -1093,8 +1123,10 @@ class Model extends Object
}
}
}
if (!empty($newData))
{
$merged = array_merge_recursive($data,$newData);
return $newData;
}
else
@ -1122,7 +1154,7 @@ class Model extends Object
{
foreach ($value1 as $key2 => $value2)
{
if($key2 === Inflector::singularize($this->table))
if($key2 === $this->name)
{
if($this->{$model}->{$this->currentModel.'_findersql'})
{
@ -1133,24 +1165,24 @@ class Model extends Object
$oneToManyConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'});
$oneToManyOrder = $this->{$model}->{$this->currentModel.'_order'};
$tmpSQL = "SELECT {$this->{$model}->{$this->currentModel.'_fields'}} FROM {$this->{$model}->table}
$tmpSQL = "SELECT {$this->{$model}->{$this->currentModel.'_fields'}} FROM {$this->{$model}->table} AS {$this->{$model}->name}
WHERE ({$this->{$model}->{$this->currentModel.'_foreignkey'}}) = '{$value2['id']}'"
.($oneToManyConditions? " WHERE {$oneToManyConditions}":null)
.($oneToManyOrder? " ORDER BY {$oneToManyOrder}": null);
}
$oneToManySelect[$this->{$model}->table] = $this->db->all($tmpSQL);
$oneToManySelect[$this->{$model}->name] = $this->db->all($tmpSQL);
if( !empty($oneToManySelect[$this->{$model}->table]) && is_array($oneToManySelect[$this->{$model}->table]))
if( !empty($oneToManySelect[$this->{$model}->name]) && is_array($oneToManySelect[$this->{$model}->name]))
{
$newKey = Inflector::singularize($this->{$model}->table);
foreach ($oneToManySelect[$this->{$model}->table] as $key => $value)
$newKey = $this->{$model}->name;
foreach ($oneToManySelect[$this->{$model}->name] as $key => $value)
{
$oneToManySelect1[$newKey][$key] = $value[$newKey];
}
$merged = array_merge_recursive($data[$count],$oneToManySelect1);
$newdata[$count] = $merged;
unset( $oneToManySelect[$this->{$model}->table], $oneToManySelect1);
unset( $oneToManySelect[$this->{$model}->name], $oneToManySelect1);
}
if(!empty($newdata[$count]))
{
@ -1506,7 +1538,7 @@ class Model extends Object
*/
function _throwMissingTable($tableName)
{
$error =& new AppController();
$error =& new Controller();
$error->missingTable = $this->table;
call_user_func_array(array(&$error, 'missingTable'), $tableName);
exit;
@ -1518,7 +1550,7 @@ class Model extends Object
*/
function _throwMissingConnection()
{
$error =& new AppController();
$error =& new Controller();
$error->missingConnection = $this->name;
call_user_func_array(array(&$error, 'missingConnection'), null);
exit;

View file

@ -88,7 +88,7 @@ class CakeSession extends Object
*
* @return unknown
*/
function &getInstance()
function &getInstance($base = null)
{
static $instance = array();
@ -100,11 +100,14 @@ class CakeSession extends Object
{
$instance[0]->host = substr($instance[0]->host,0, strpos($instance[0]->host, ':'));
}
$instance[0]->path = setUri();
$instance[0]->path = $base;
if (empty($instance[0]->path))
{
$instance[0]->path = '/';
}
$instance[0]->ip = $_SERVER['REMOTE_ADDR'];
$instance[0]->userAgent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";

View file

@ -0,0 +1,2 @@
<h1><?php echo $name; ?></h1>
<p><?php echo $message; ?></p>

View file

@ -19,11 +19,8 @@
<div id="headerNav">
<?php
echo $html->link('API', 'http://api.cakephp.org/');
echo $html->link('Wiki', 'http://wiki.cakephp.org');
echo $html->link('CakeForge', 'http://cakeforge.org');
echo $html->link('Trac', 'https://trac.cakephp.org');
?>
@ -31,20 +28,15 @@
</div>
<div id="pageNav">
<?php
$css_class = ($title_for_layout == 'Home') ? 'active' : '';
echo $html->link('Home', 'http://cakephp.org/',array('class'=>$css_class));
echo $html->link('Home', 'http://cakephp.org/',array('class'=>'active'));
echo '&nbsp;';
$css_class = ($title_for_layout == 'Blogs') ? 'active' : '';
echo $html->link('Blog', 'http://cakephp.org/blogs',array('class'=>$css_class));
echo $html->link('Blog', 'http://cakephp.org/blogs',array('class'=>''));
echo '&nbsp;';
$css_class = ($title_for_layout == 'Downloads') ? 'active' : '';
echo $html->link('Downloads', 'http://cakephp.org/downloads/',array('class'=>$css_class));
echo $html->link('Downloads', 'http://cakephp.org/downloads/',array('class'=>''));
echo '&nbsp;';
$css_class = ($title_for_layout == 'Support') ? 'active' : '';
echo $html->link('Support', 'http://cakephp.org/pages/support/',array('class'=>$css_class));
echo $html->link('Support', 'http://cakephp.org/pages/support/',array('class'=>''));
echo '&nbsp;';
$css_class = ($title_for_layout == 'Pastes') ? 'active' : '';
echo $html->link('CakeBin', 'http://cakephp.org/pastes/',array('class'=>$css_class));
echo $html->link('CakeBin', 'http://cakephp.org/pastes/',array('class'=>''));
?>
</div>
<div id="content">
@ -53,7 +45,7 @@
<div id="pb-cake">
&copy; 2005 CakePHP ::
<a href="https://trac.cakephp.org/wiki/Authors">CakePHP Developers and Authors</a>
<p>CakePHP version 0.10.0.1217_alpha</p>
<p>CakePHP version 0.10.1.1248_alpha</p>
<a href="http://www.cakephp.org/" target="_new" class="simple">
<?php echo $html->image('cake.power.png', array('alt'=>"CakePHP : Rapid Development Framework", 'border'=>"0"))?>
</a>

View file

@ -1,83 +0,0 @@
<?php
/* SVN FILE: $Id$ */
/**
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.view.templates.layouts
* @since CakePHP v 0.10.0.1076
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @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 $code; ?> <?php echo $name; ?></title>
<link REL="SHORTCUT ICON" HREF="img/favicon.ico" type="image/x-icon">
<?php echo $html->charsetTag('UTF-8')?>
<?php echo $html->cssTag('cake.default')?>
</head>
<body>
<div id="main">
<div id="header">
<div id="headerLogo"><?php echo $html->image('cake.logo.png',array('alt'=>"CakePHP :: A Rapid Development Framework")); ?></div>
<div id="headerNav">
<?
echo $html->link('Home', 'http://cakephp.org',array('class'=>''));
echo $html->link('Documentation', 'http://cakephp.org/pages/documentation',array('class'=>''));
echo $html->link('Downloads', 'http://cakephp.org/downloads/',array('class'=>''));
echo $html->link('Support', 'http://cakephp.org/pages/support/',array('class'=>''));
echo $html->link('Development', 'https://trac.cakephp.org',array('class'=>''));
?>
</div>
<div id="headerSubNav">
<?
echo $html->link('Blog', '/',array('class'=>''));
echo $html->link('Wiki Community', 'http://wiki.cakephp.org',array('class'=>''));
echo $html->link('Apps & Plugins', 'http://cakeforge.org',array('class'=>''));
echo $html->link('Cakebin', 'http://cakephp.org/pastes/',array('class'=>''));
?>
</div>
</div>
<div id="content">
<h1><?php echo $name; ?></h1>
<p><?php echo $message; ?></p>
</div>
</div>
<div id="footer" align="center">
&copy; 2005 CakePHP ::
<a href="https://trac.cakephp.org/wiki/Authors">CakePHP Developers and Authors</a>
<p>CakePHP v 0.10.0.1076_dev</p>
</div>
<!---PLEASE LEAVE THE POWERED BY CAKE LOGO------->
<div id="pb-cake">
<a href="http://www.cakephp.org/" target="_new" class="simple">
<?php echo $html->image('pbcake.gif',array('width'=>"120",'height'=>"28",'alt'=>"CakePHP :: A Rapid Development Framework", 'border'=>"0"))?>
</a>
</div>
</body>
</html>

View file

@ -617,7 +617,7 @@ class View extends Object
}
else
{
$error =& new AppController();
$error =& new Controller();
$error->autoLayout = true;
$error->base = $this->base;
call_user_func_array(array(&$error, 'missingHelperClass'), $helper);
@ -626,7 +626,7 @@ class View extends Object
}
else
{
$error =& new AppController();
$error =& new Controller();
$error->autoLayout = true;
$error->base = $this->base;
call_user_func_array(array(&$error, 'missingHelperFile'), Inflector::underscore($helper));