From d5ebd2f4b77c712e0427a67a12211b3d8081d742 Mon Sep 17 00:00:00 2001 From: phpnut Date: Thu, 25 Aug 2005 16:40:50 +0000 Subject: [PATCH] merging changes from [692] [693] [697] [699] [701] [704] [706] [707] git-svn-id: https://svn.cakephp.org/repo/trunk/cake@709 3807eeeb-6ff5-0310-8944-8be069107fe0 --- libs/basics.php | 20 +- libs/controller.php | 5 +- .../templates/scaffolds/list.thtml | 3 +- libs/dbo/dbo_adodb.php | 18 +- libs/dbo/dbo_generic.php | 36 +- libs/dbo/dbo_sqlite.php | 2 +- libs/helpers/html.php | 4 +- libs/model.php | 63 ++-- libs/scaffold.php | 347 +++++++++--------- libs/template.php | 16 +- libs/time.php | 28 +- libs/view.php | 60 +-- 12 files changed, 317 insertions(+), 285 deletions(-) diff --git a/libs/basics.php b/libs/basics.php index 191d7a368..4f009ed00 100644 --- a/libs/basics.php +++ b/libs/basics.php @@ -2,9 +2,9 @@ /* SVN FILE: $Id$ */ /** - * Basic Cake functionalities. + * Basic Cake functionality. * - * Long description for file + * Core functions for including other source files, loading models and so forth. * * PHP versions 4 and 5 * @@ -84,8 +84,8 @@ function loadControllers () /** * Loads a controller and its helper libraries. * - * @param string $name - * @return boolean + * @param string $name Name of controller + * @return boolean Success */ function loadController ($name) { @@ -103,8 +103,8 @@ function loadController ($name) /** * Lists PHP files in given directory. * - * @param string $path - * @return array + * @param string $path Path to scan for files + * @return array List of files in directory */ function listClasses($path) { @@ -114,6 +114,8 @@ function listClasses($path) /** * Loads configuration files + * + * @return boolean True on success. */ function config () { @@ -157,6 +159,12 @@ function uses () } } +/** + * Require given files in the VENDORS directory. Function takes optional number of parameters. + * + * @param string $name Filename without the .php part. + * + */ function vendor($name) { $args = func_get_args(); diff --git a/libs/controller.php b/libs/controller.php index c44dae64f..6e699f57d 100644 --- a/libs/controller.php +++ b/libs/controller.php @@ -508,7 +508,7 @@ class Controller extends Object foreach ($tables as $tabl) { // set up the prompt - if( Model::isForeignKey($tabl['name']) ) + if( $objRegistryModel->isForeignKey($tabl['name']) ) { $niceName = substr( $tabl['name'], 0, strpos( $tabl['name'], "_id" ) ); $fieldNames[ $tabl['name'] ]['prompt'] = Inflector::humanize($niceName); @@ -619,6 +619,9 @@ class Controller extends Object } break; case "int": + case "smallint": + case "mediumint": + case "bigint": case "decimal": case "float": case "double": diff --git a/libs/controllers/templates/scaffolds/list.thtml b/libs/controllers/templates/scaffolds/list.thtml index 76a2d09be..b0a3f7e09 100644 --- a/libs/controllers/templates/scaffolds/list.thtml +++ b/libs/controllers/templates/scaffolds/list.thtml @@ -27,7 +27,8 @@ foreach( $fieldNames as $field=>$value ) { ?> _conn, SQLITE_ASSOC); + $cols = sqlite_fetch_column_types($table_name, $this->_conn); foreach ($cols as $column => $type) { diff --git a/libs/helpers/html.php b/libs/helpers/html.php index 7365432dc..95bf514ec 100644 --- a/libs/helpers/html.php +++ b/libs/helpers/html.php @@ -993,7 +993,7 @@ class HtmlHelper extends Helper * @param array $optionAttr Array of HTML options for the enclosed OPTION elements * @return string Formatted SELECT element */ - function selectTag($fieldName, $option_elements, $selected=null, $select_attr=null, $optionAttr=null, $show_empty=false) + function selectTag($fieldName, $option_elements, $selected=null, $select_attr=null, $optionAttr=null, $showEmpty=true) { $this->setFormTag($fieldName); @@ -1012,7 +1012,7 @@ class HtmlHelper extends Helper $select[] = sprintf($this->tags['selectstart'], $this->model, $this->field, $this->parseHtmlOptions($select_attr)); } - if($show_empty == true) + if($showEmpty == true) { $select[] = sprintf($this->tags['selectempty'], $this->parseHtmlOptions($optionAttr)); } diff --git a/libs/model.php b/libs/model.php index 68cc22803..b6f8f9495 100644 --- a/libs/model.php +++ b/libs/model.php @@ -1022,7 +1022,7 @@ class Model extends Object { if(!empty($joined)) { - $this->saveMulti($joined, $this->id); + $this->_saveMulti($joined, $this->id); } $this->data = false; return true; @@ -1049,7 +1049,7 @@ class Model extends Object { $this->id = $newID; } - $this->saveMulti($joined, $this->id); + $this->_saveMulti($joined, $this->id); } return true; } @@ -1071,9 +1071,10 @@ class Model extends Object * * @param array $joined Data to save. * @param string $id - * @return boolean success + * @return + * @access private */ - function saveMulti ($joined, $id) + function _saveMulti ($joined, $id) { $sql = array(); @@ -1085,27 +1086,27 @@ class Model extends Object $tableSort[1] = $name; sort($tableSort); $joinTable = $tableSort[0] . '_' . $tableSort[1]; - $key1 = Inflector::singularize($this->table) . '_id'; - $key2 = Inflector::singularize($name) . '_id'; + $mainKey = Inflector::singularize($this->table) . '_id'; + + $key[] = $mainKey; + $key[] = Inflector::singularize($name) . '_id'; + $fields = join(',', $key); + foreach ($value as $update) { - $fields1[] = $key1; - $values1[] = $this->db->prepare($id); - $fields1[] = $key2; - $values1[] = $this->db->prepare($update); + $values[] = $this->db->prepare($id); + $values[] = $this->db->prepare($update); + $values = join(',', $values); + $newValue[] = "({$values})"; + unset($values); - $fields1 = join(',', $fields1); - $values1 = join(',', $values1); - $joinedSql[] = "INSERT INTO {$joinTable} ({$fields1}) VALUES ({$values1})"; - - unset($fields1); - unset($values1); } - $this->db->query("DELETE FROM {$joinTable} WHERE $key1 = '{$id}'"); - } - foreach ($joinedSql as $insert){ - $this->db->query($insert); + $this->db->query("DELETE FROM {$joinTable} WHERE $mainKey = '{$id}'"); } + + $newValue = join(',', $newValue); + $this->db->query("INSERT INTO {$joinTable} ({$fields}) VALUES {$newValue}"); + } } @@ -1528,12 +1529,24 @@ class Model extends Object * This function determines whether or not a string is a foreign key * * @param string $field Returns true if the input string ends in "_id" - * @return True if the input string ends in "_id", else false. + * @return True if the field is a foreign key listed in the belongsTo array. */ - function isForeignKey( $field ) { - - // search for the string _id reveals that this string appears three characters from the end, then this is a foreign key. - if( substr($field, -3) === '_id' ) + function isForeignKey( $field ) + { + + $foreignKeys = array(); + + if(!empty($this->_belongsToOther)) + { + + foreach ($this->_belongsToOther as $rule) + { + list($table, $key, $value) = $rule; + $foreignKeys[$key] = $key; + } + } + + if( array_key_exists($field, $foreignKeys) ) { return true; } diff --git a/libs/scaffold.php b/libs/scaffold.php index 75348f221..f92edf5e2 100644 --- a/libs/scaffold.php +++ b/libs/scaffold.php @@ -37,274 +37,281 @@ uses('model', 'template', 'inflector', 'object'); /** - * Short description for class + * Scaffolding is a set of automatic views, forms and controllers for starting web development work faster. * - * Long description for class + * Scaffold inspects your database tables, and making educated guesses, sets up a + * number of pages for each of your Models. These pages have data forms that work, + * and afford the web developer an early look at the data, and the possibility to over-ride + * scaffolded actions with custom-made ones. * * @package cake * @subpackage cake.libs * @since Cake v 1.0.0.172 */ class Scaffold extends Object { - + /** - * Enter description here... + * Name of controller class * - * @var unknown_type + * @var string */ var $clazz = null; - + /** * Enter description here... * - * @var unknown_type + * @var string */ var $actionView = null; - + /** * Enter description here... * * @var unknown_type */ var $model = null; - + /** * Enter description here... * - * @var unknown_type + * @var Object */ var $controllerClass = null; - + /** - * Enter description here... + * Name of scaffolded Model * - * @var unknown_type + * @var string */ var $modelName = null; - + /** - * Enter description here... + * Title HTML element for current scaffolded view * - * @var unknown_type + * @var string */ var $scaffoldTitle = null; - -/** - * Enter description here... + + /** + * Base URL * - * @var unknown_type + * @var string */ var $base = false; - + /** - * Enter description here... + * Construct and set up given controller with given parameters. * - * @param unknown_type $controller_class - * @param unknown_type $params + * @param string $controller_class Name of controller + * @param array $params */ function __construct($controller_class, $params) { - $this->clazz = $controller_class; - $this->actionView = $params['action']; - - $r = null; - if (!preg_match('/(.*)Controller/i', $this->clazz, $r)) - { - die("Scaffold::__construct() : Can't get or parse class name."); - } - $this->model = strtolower(Inflector::singularize($r[1])); - $this->scaffoldTitle = $r[1]; + $this->clazz = $controller_class; + $this->actionView = $params['action']; + + $r = null; + if (!preg_match('/(.*)Controller/i', $this->clazz, $r)) + { + die("Scaffold::__construct() : Can't get or parse class name."); + } + $this->model = strtolower(Inflector::singularize($r[1])); + $this->scaffoldTitle = $r[1]; } - + /** - * Enter description here... + * Set up a new class with the given settings. * - * @param unknown_type $params + * @param array $params */ function constructClasses($params) { - $this->controllerClass = new $this->clazz(); - $this->controllerClass->base = $this->base; - $this->controllerClass->params = $params; - $this->controllerClass->contructClasses(); - $this->controllerClass->layout = 'scaffold'; - $this->controllerClass->pageTitle = $this->scaffoldTitle; + $this->controllerClass = new $this->clazz(); + $this->controllerClass->base = $this->base; + $this->controllerClass->params = $params; + $this->controllerClass->contructClasses(); + $this->controllerClass->layout = 'scaffold'; + $this->controllerClass->pageTitle = $this->scaffoldTitle; } - + /** - * Enter description here... + * Renders the List view as the default action (index). * - * @param unknown_type $params - * @return unknown + * @param array $params + * @return boolean Success */ function scaffoldIndex($params) { - return $this->scaffoldList($params); + return $this->scaffoldList($params); } - + /** - * Enter description here... + * Renders a Show view of scaffolded Model. * - * @param unknown_type $params + * @param array $params */ function scaffoldShow($params) { - $this->controllerClass->params['data'] = $this->controllerClass->models[$this->model]->read(); - $this->controllerClass->set('data', $this->controllerClass->params['data'] ); - $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames( $this->controllerClass->params['data'], false ) ); - $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'show.thtml'); + $this->controllerClass->params['data'] = $this->controllerClass->models[$this->model]->read(); + $this->controllerClass->set('data', $this->controllerClass->params['data'] ); + $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames( $this->controllerClass->params['data'], false ) ); + $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'show.thtml'); } - + /** - * Enter description here... + * Renders List view of scaffolded Model. * - * @param unknown_type $params + * @param array $params */ function scaffoldList($params) { - $model = $this->model; - $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames(null,false) ); + $model = $this->model; + $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames(null,false) ); $this->controllerClass->set('data', $this->controllerClass->models[$model]->findAll()); - $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'list.thtml'); + $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'list.thtml'); } - + /** - * Enter description here... + * Creates a new scaffold. * - * @param unknown_type $params + * @param array $params */ function scaffoldNew($params) { - $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() ); - $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml'); + $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() ); + $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml'); } - + /** - * Enter description here... + * Renders an Edit view for scaffolded Model. * - * @param unknown_type $params + * @param array $params */ function scaffoldEdit($params) { - $this->controllerClass->params['data'] = $this->controllerClass->models[$this->model]->read(); - // generate the field names. - $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames($this->controllerClass->params['data']) ); - $this->controllerClass->set('data', $this->controllerClass->params['data']); - $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml'); + $this->controllerClass->params['data'] = $this->controllerClass->models[$this->model]->read(); + // generate the field names. + $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames($this->controllerClass->params['data']) ); + $this->controllerClass->set('data', $this->controllerClass->params['data']); + $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml'); } - -/** - * Enter description here... - * - * @param unknown_type $params - */ + + /** + * Renders a "create new" view for scaffolded Model. + * + * @param array $params + */ function scaffoldCreate($params) { - $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() ); - $this->cleanUpFields(); - - if ($this->controllerClass->models[$this->model]->save($this->controllerClass->params['data'])) - { - $this->controllerClass->flash('Your '.$this->model.' has been saved.', '/'.$this->controllerClass->viewPath ); - } - else - { - $this->controllerClass->set('data', $this->controllerClass->params['data']); - $this->controllerClass->validateErrors($this->controllerClass->models[$this->model]); - $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml'); - } + $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() ); + $this->cleanUpFields(); + + if ($this->controllerClass->models[$this->model]->save($this->controllerClass->params['data'])) + { + $this->controllerClass->flash('Your '.$this->model.' has been saved.', '/'.$this->controllerClass->viewPath ); + } + else + { + $this->controllerClass->set('data', $this->controllerClass->params['data']); + $this->controllerClass->validateErrors($this->controllerClass->models[$this->model]); + $this->controllerClass->render($this->actionView, '', LIBS.'controllers'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml'); + } } - + /** - * Enter description here... + * Renders an update view for scaffolded Model. * - * @param unknown_type $params + * @param array $params */ function scaffoldUpdate($params=array()) { - // clean up the date fields - $this->cleanUpFields(); - - $this->controllerClass->models[$this->model]->set($this->controllerClass->params['data']); - if ( $this->controllerClass->models[$this->model]->save()) - { - $this->controllerClass->flash('The '.$this->model.' has been updated.','/'.$this->controllerClass->name); - } - else - { - $this->controllerClass->flash('There was an error updating the '.$this->model,'/'.$this->controllerClass->name); - } + // clean up the date fields + $this->cleanUpFields(); + + $this->controllerClass->models[$this->model]->set($this->controllerClass->params['data']); + if ( $this->controllerClass->models[$this->model]->save()) + { + $this->controllerClass->flash('The '.$this->model.' has been updated.','/'.$this->controllerClass->name); + } + else + { + $this->controllerClass->flash('There was an error updating the '.$this->model,'/'.$this->controllerClass->name); + } } - + /** - * Enter description here... + * Performs a delete on given scaffolded Model. * - * @param unknown_type $params + * @param array $params */ function scaffoldDestroy($params=array()) { - $id = $params['pass'][0]; - // figure out what model and table we are working with - $controllerName = $this->controllerClass->name; - $table = Inflector::singularize($controllerName); - if ($this->controllerClass->models[$table]->del($id)) - { - $this->controllerClass->flash('The '.$table.' with id: '.$id.' has been deleted.', '/'.$controllerName); - } - else - { - $this->controllerClass->flash('There was an error deleting the '.$table.' with the id '.$id, '/'.$controllerName); - } + $id = $params['pass'][0]; + // figure out what model and table we are working with + $controllerName = $this->controllerClass->name; + $table = Inflector::singularize($controllerName); + if ($this->controllerClass->models[$table]->del($id)) + { + $this->controllerClass->flash('The '.$table.' with id: '.$id.' has been deleted.', '/'.$controllerName); + } + else + { + $this->controllerClass->flash('There was an error deleting the '.$table.' with the id '.$id, '/'.$controllerName); + } } - - function cleanUpFields() + /** + * Cleans up the date fields of current Model. + * + * + */ + function cleanUpFields() { - // clean up the date fields - $objModel = $this->controllerClass->models[$this->model]; - foreach( $objModel->_table_info as $table ) - { - foreach ($table as $field) - { - if( 'date' == $field['type'] && isset($this->controllerClass->params['data'][$this->model][$field['name'].'_year'] ) ) - { - $newDate = mktime( 0,0,0, - $this->controllerClass->params['data'][$this->model][$field['name'].'_month'], - $this->controllerClass->params['data'][$this->model][$field['name'].'_day'], - $this->controllerClass->params['data'][$this->model][$field['name'].'_year'] ); - $newDate = date( 'Y-m-d', $newDate ); - $this->controllerClass->params['data'][$this->model][$field['name']] = $newDate; - } - else if( 'datetime' == $field['type'] && isset($this->controllerClass->params['data'][$this->model][$field['name'].'_year'] ) ) - { - $hour = $this->controllerClass->params['data'][$this->model][$field['name'].'_hour']; - if( $hour != 12 && 'pm' == $this->controllerClass->params['data'][$this->model][$field['name'].'_meridian'] ) - { - $hour = $hour + 12; - } - $newDate = mktime( $hour, - $this->controllerClass->params['data'][$this->model][$field['name'].'_min'], - 0, - $this->controllerClass->params['data'][$this->model][$field['name'].'_month'], - $this->controllerClass->params['data'][$this->model][$field['name'].'_day'], - $this->controllerClass->params['data'][$this->model][$field['name'].'_year'] ); - $newDate = date( 'Y-m-d', $newDate ); - $this->controllerClass->params['data'][$this->model][$field['name']] = $newDate; - } - else if( 'tinyint(1)' == $field['type'] ) - { - if( isset( $this->controllerClass->params['data'][$this->model][$field['name']]) && - "on" == $this->controllerClass->params['data'][$this->model][$field['name']] ) - { - $this->controllerClass->params['data'][$this->model][$field['name']] = true; - } - else - { - $this->controllerClass->params['data'][$this->model][$field['name']] = false; - } - } - } - } + // clean up the date fields + $objModel = $this->controllerClass->models[$this->model]; + foreach( $objModel->_table_info as $table ) + { + foreach ($table as $field) + { + if( 'date' == $field['type'] && isset($this->controllerClass->params['data'][$this->model][$field['name'].'_year'] ) ) + { + $newDate = mktime( 0,0,0, + $this->controllerClass->params['data'][$this->model][$field['name'].'_month'], + $this->controllerClass->params['data'][$this->model][$field['name'].'_day'], + $this->controllerClass->params['data'][$this->model][$field['name'].'_year'] ); + $newDate = date( 'Y-m-d', $newDate ); + $this->controllerClass->params['data'][$this->model][$field['name']] = $newDate; + } + else if( 'datetime' == $field['type'] && isset($this->controllerClass->params['data'][$this->model][$field['name'].'_year'] ) ) + { + $hour = $this->controllerClass->params['data'][$this->model][$field['name'].'_hour']; + if( $hour != 12 && 'pm' == $this->controllerClass->params['data'][$this->model][$field['name'].'_meridian'] ) + { + $hour = $hour + 12; + } + $newDate = mktime( $hour, + $this->controllerClass->params['data'][$this->model][$field['name'].'_min'], + 0, + $this->controllerClass->params['data'][$this->model][$field['name'].'_month'], + $this->controllerClass->params['data'][$this->model][$field['name'].'_day'], + $this->controllerClass->params['data'][$this->model][$field['name'].'_year'] ); + $newDate = date( 'Y-m-d', $newDate ); + $this->controllerClass->params['data'][$this->model][$field['name']] = $newDate; + } + else if( 'tinyint(1)' == $field['type'] ) + { + if( isset( $this->controllerClass->params['data'][$this->model][$field['name']]) && + "on" == $this->controllerClass->params['data'][$this->model][$field['name']] ) + { + $this->controllerClass->params['data'][$this->model][$field['name']] = true; + } + else + { + $this->controllerClass->params['data'][$this->model][$field['name']] = false; + } + } + } + } } } diff --git a/libs/template.php b/libs/template.php index 7670b8803..9dea15892 100644 --- a/libs/template.php +++ b/libs/template.php @@ -2,9 +2,9 @@ /* SVN FILE: $Id$ */ /** - * Short description for file. + * Templating for Controller class. Takes care of rendering views. * - * Long description for file + * Templating system for Cake. * * PHP versions 4 and 5 * @@ -49,15 +49,15 @@ class Template extends Object { /** - * Enter description here... + * Base URL part * - * @var unknown_type + * @var string * @access public */ var $base = null; /** - * Enter description here... + * Layout name * * @var string * @access public @@ -65,7 +65,7 @@ class Template extends Object var $layout = 'default'; /** - * Enter description here... + * Turns on or off Cake's conventional mode of rendering views. On by default. * * @var boolean * @access public @@ -73,7 +73,7 @@ class Template extends Object var $autoRender = true; /** - * Enter description here... + * Turns on or off Cake's conventional mode of finding layout files. On by default. * * @var boolean * @access public @@ -89,7 +89,7 @@ class Template extends Object var $_viewVars = array(); /** - * Enter description here... + * Title HTML element of current View. * * @var boolean * @access private diff --git a/libs/time.php b/libs/time.php index d2237c787..17dbb6bc4 100644 --- a/libs/time.php +++ b/libs/time.php @@ -2,9 +2,9 @@ /* SVN FILE: $Id$ */ /** - * Short description for file. + * Time library for Cake. * - * Long description for file + * Methods for handling and formatting date and time information. * * PHP versions 4 and 5 * @@ -37,9 +37,9 @@ uses ('object'); /** - * Time related functions, formatting for dates etc. + * Time-related functions, formatting for dates etc. * - * Long description for class + * The Time class handles and formats date and time information. * * @package cake * @subpackage cake.libs @@ -102,12 +102,12 @@ class Time extends Object } /** - * Enter description here... + * Returns SQL for selecting a date range between the datetime pair $begin and $end. * - * @param unknown_type $begin - * @param unknown_type $end - * @param unknown_type $field_name - * @return unknown + * @param string $begin Start of date range as a Datetime string + * @param string $end End of date range as a Datetime string + * @param string $field_name Name of database date field + * @return string SQL code for selecting the date range */ function daysAsSql ($begin, $end, $field_name) { @@ -118,11 +118,12 @@ class Time extends Object } /** - * Enter description here... + * Returns SQL for selecting a date range that includes the whole day of given datetime string. * - * @param unknown_type $date - * @param unknown_type $field_name - * @return unknown + * @param string $date Datetime string + * @param string $field_name Name of database date field + * @return SQL for selecting the date range of that full day + * @see Time::daysAsSql() */ function dayAsSql ($date, $field_name) { @@ -178,6 +179,7 @@ class Time extends Object * * @param datetime $date Datetime string * @return string Formatted date string + * @todo Is this for RSS 0.9.2 or RSS 2.0? */ function toRSS ($date) { diff --git a/libs/view.php b/libs/view.php index 7ef25ea33..7a321905e 100644 --- a/libs/view.php +++ b/libs/view.php @@ -37,9 +37,9 @@ uses('object'); /** - * Short description for class + * View, the V in the MVC triad. * - * Long description for class + * Class holding methods for displaying presentation data. * * @package cake * @subpackage cake.libs @@ -50,7 +50,7 @@ class View extends Object /** * Name of the controller. * - * @var unknown_type + * @var string Name of controller * @access public */ var $name = null; @@ -73,7 +73,7 @@ class View extends Object /** * Action to be performed. * - * @var string + * @var string Name of action * @access public */ var $action = null; @@ -95,9 +95,9 @@ class View extends Object var $helpers = array('html'); /** - * Enter description here... + * Path to View. * - * @var unknown_type + * @var string Path to View */ var $viewPath; @@ -110,7 +110,7 @@ class View extends Object var $_viewVars = array(); /** - * Enter description here... + * Title HTML element of this View. * * @var boolean * @access private @@ -125,17 +125,16 @@ class View extends Object */ var $models = array(); - /** - * Enter description here... + * Path parts for creating links in views. * - * @var unknown_type + * @var string Base URL * @access public */ var $base = null; /** - * Enter description here... + * Name of layout to use with this View. * * @var string * @access public @@ -143,7 +142,7 @@ class View extends Object var $layout = 'default'; /** - * Enter description here... + * Turns on or off Cake's conventional mode of rendering views. On by default. * * @var boolean * @access public @@ -151,7 +150,7 @@ class View extends Object var $autoRender = true; /** - * Enter description here... + * Turns on or off Cake's conventional mode of finding layout files. On by default. * * @var boolean * @access public @@ -159,27 +158,27 @@ class View extends Object var $autoLayout = true; /** - * Enter description here... + * Array of parameter data * - * @var unknown_type + * @var array Parameter data */ var $params; /** * Enter description here... * - * @var unknown_type + * @var boolean */ var $hasRendered = null; /** * Enter description here... * - * @var unknown_type + * @var boolean */ var $modelsLoaded = false; /** - * Enter description here... + * Constructor * * @return View */ @@ -203,7 +202,7 @@ class View extends Object /** - * Render view for given action and layout. If $file is given, that is used + * Renders view for given action and layout. If $file is given, that is used * for a view filename (e.g. customFunkyView.thtml). * * @param string $action Name of action to render for @@ -213,7 +212,6 @@ class View extends Object function render($action=null, $layout=null, $file=null) { - if ($this->modelsLoaded!==true) { foreach ($this->models as $modelName => $model) @@ -331,8 +329,12 @@ class View extends Object /** * Renders a piece of PHP with provided parameters and returns HTML, XML, or any other string. * - * @param string $name Name of template file - * @param array $params Array of data for rendered view + * This realizes the concept of Elements, (or "partial layouts") + * and the $params array is used to send data to be used in the + * Element. + * + * @param string $name Name of template file in the /app/views/elements/ folder + * @param array $params Array of data to be made available to the for rendered view (i.e. the Element) * @return string Rendered output */ function renderElement($name, $params=array()) @@ -349,8 +351,8 @@ class View extends Object /** * Renders a layout. Returns output from _render(). Returns false on error. * - * @param string $content_for_layout Content to render in a view - * @return string Rendered output + * @param string $content_for_layout Content to render in a view, wrapped by the surrounding layout. + * @return string Rendered output, or false on error */ function renderLayout($content_for_layout) { @@ -383,7 +385,7 @@ class View extends Object } /** - * Choose the layout to be used when rendering. + * Set layout to be used when rendering. * * @param string $layout */ @@ -397,7 +399,7 @@ class View extends Object * * @param int $code Error code (for instance: 404) * @param string $name Name of the error (for instance: Not Found) - * @param string $message Error message + * @param string $message Error message as a web page */ function error ($code, $name, $message) { @@ -407,7 +409,7 @@ class View extends Object /** - * Enter description here... + * Renders the Missing Controller web page. * */ function missingController() @@ -417,7 +419,7 @@ class View extends Object } /** - * Enter description here... + * Renders the Missing Action web page. * */ function missingAction() @@ -427,7 +429,7 @@ class View extends Object } /** - * Enter description here... + * Renders the Missing View web page. * */ function missingView()