mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Merging fixes and enhancements into trunk.
Revision: [2151] Merging changes made to model_php5.php into model_php4.php. Revision: [2150] Cleaning up code, removing in line comments Revision: [2149] Fixed wrong params passed to SessionComponent::setFlash() in Scaffold class. Changed View::_render() to only suppress errors in the view when DEBUG is set to 0. Revision: [2148] Adding suggestion from Ticket #446. Revision: [2147] Added fix for Ticket #443 Revision: [2146] Added fix for Ticket #444. Added table.field in the CakeSession class database methods Revision: [2145] Renamed _new to _blank in default.thtml. Starting to refactor changes that broke self joined associations. Revision: [2144] Adding fix for Ticket #202 Revision: [2143] Adding support for nested array-based conditions Revision: [2141] Updating View for Session flash changes Revision: [2140] Adding Session flash enhancements for a ticket that I took but can't find because someone else closed it git-svn-id: https://svn.cakephp.org/repo/trunk/cake@2152 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
f37dfb6302
commit
6cc1cf8b80
13 changed files with 223 additions and 133 deletions
|
@ -6,4 +6,4 @@
|
|||
// +---------------------------------------------------------------------------------------------------+ //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
0.10.8.2134
|
||||
0.10.8.2152
|
|
@ -132,41 +132,52 @@ class SessionComponent extends Object
|
|||
*
|
||||
* Use like this. $this->Session->setFlash('This has been saved');
|
||||
*
|
||||
* @param string $flashMessage Message to be flashed
|
||||
* @param string $layout Layout to wrap flash message in
|
||||
* @param array $params Parameters to be sent to layout as view variables
|
||||
* @param string $key Message key, default is 'flash'
|
||||
* @return string Last session error
|
||||
*/
|
||||
function setFlash($flashMessage)
|
||||
function setFlash($flashMessage, $layout = 'default', $params = array(), $key = 'flash')
|
||||
{
|
||||
$this->write('Message.flash', $flashMessage);
|
||||
if ($layout == 'default' || $layout == null)
|
||||
{
|
||||
$out = '<div class="message">'.$flashMessage.'</div>';
|
||||
}
|
||||
else if($layout == '')
|
||||
{
|
||||
$out = $flashMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ctrl = null;
|
||||
$view = new View($ctrl);
|
||||
$view->layout = $layout;
|
||||
$view->pageTitle = '';
|
||||
$view->_viewVars = $params;
|
||||
$out = $view->renderLayout($flashMessage);
|
||||
}
|
||||
$this->write('Message.'.$key, $out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to output or return the value of the Message flash.
|
||||
* Use like this. $this->Session->flash();
|
||||
*
|
||||
* @param string $css css class used in the div tag
|
||||
* @param boolean $return setting to true return the value of the flash message instead of displaying
|
||||
* @return message output
|
||||
* */
|
||||
function flash($css = 'message', $return = false)
|
||||
* @param string $key Optional message key
|
||||
* @return null
|
||||
*/
|
||||
function flash($key = 'flash')
|
||||
{
|
||||
if($this->check('Message.flash'))
|
||||
if($this->check('Message.'.$key))
|
||||
{
|
||||
if($return === false)
|
||||
{
|
||||
echo '<div class="'.$css.'">'.$this->read('Message.flash').'</div>';
|
||||
$this->del('Message.flash');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$return = $this->read('Message.flash');
|
||||
$this->del('Message.flash');
|
||||
return $return;
|
||||
}
|
||||
e($this->read('Message.'.$key));
|
||||
$this->del('Message.'.$key);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -265,7 +265,7 @@ class Scaffold extends Object {
|
|||
{
|
||||
if(is_object($this->controllerClass->Session))
|
||||
{
|
||||
$this->controllerClass->Session->setFlash('The '.Inflector::humanize($this->modelKey).' has been '.$success.'.', '/');
|
||||
$this->controllerClass->Session->setFlash('The '.Inflector::humanize($this->modelKey).' has been '.$success.'.');
|
||||
$this->controllerClass->redirect(Inflector::underscore($this->controllerClass->viewPath));
|
||||
}
|
||||
else
|
||||
|
@ -278,7 +278,7 @@ class Scaffold extends Object {
|
|||
{
|
||||
if(is_object($this->controllerClass->Session))
|
||||
{
|
||||
$this->controllerClass->Session->setFlash('Please correct errors below');
|
||||
$this->controllerClass->Session->setFlash('Please correct errors below.');
|
||||
}
|
||||
$this->controllerClass->set('data', $this->controllerClass->params['data']);
|
||||
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames($this->__rebuild($this->controllerClass->params['data'])));
|
||||
|
@ -320,7 +320,7 @@ class Scaffold extends Object {
|
|||
{
|
||||
if(is_object($this->controllerClass->Session))
|
||||
{
|
||||
$this->controllerClass->Session->setFlash('The '.Inflector::humanize($this->modelKey).' with id: '.$id.' has been deleted.', '/');
|
||||
$this->controllerClass->Session->setFlash('The '.Inflector::humanize($this->modelKey).' with id: '.$id.' has been deleted.');
|
||||
$this->controllerClass->redirect(Inflector::underscore($this->controllerClass->viewPath));
|
||||
}
|
||||
else
|
||||
|
@ -333,7 +333,7 @@ class Scaffold extends Object {
|
|||
{
|
||||
if(is_object($this->controllerClass->Session))
|
||||
{
|
||||
$this->controllerClass->Session->setFlash('There was an error deleting the '.Inflector::humanize($this->modelKey).' with the id '.$id, '/');
|
||||
$this->controllerClass->Session->setFlash('There was an error deleting the '.Inflector::humanize($this->modelKey).' with the id '.$id);
|
||||
$this->controllerClass->redirect(Inflector::underscore($this->controllerClass->viewPath));
|
||||
}
|
||||
else
|
||||
|
|
|
@ -398,6 +398,25 @@ class DataSource extends Object
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats column data from definition in DBO's $columns array
|
||||
*
|
||||
* @param string $data
|
||||
* @param unknown_type $fields
|
||||
* @return mixed Data formatted to column specifications
|
||||
* @access protected
|
||||
*/
|
||||
function __formatColumnData($data, $format, $formatter)
|
||||
{
|
||||
switch($formatter)
|
||||
{
|
||||
case 'date':
|
||||
return date($format, strtotime($data));
|
||||
case 'sprintf':
|
||||
return sprintf($format, $data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
|
|
|
@ -566,6 +566,10 @@ class DboSource extends DataSource
|
|||
return true;
|
||||
}
|
||||
}
|
||||
elseif (isset($linkModel))
|
||||
{
|
||||
return $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isset($this->__assocJoins))
|
||||
|
@ -670,7 +674,7 @@ class DboSource extends DataSource
|
|||
$sql .= $this->limit($queryData['limit']);
|
||||
return $sql;
|
||||
}
|
||||
else if($joinedOnSelf != true)
|
||||
else
|
||||
{
|
||||
if(!isset($assocData['fields']))
|
||||
{
|
||||
|
@ -737,7 +741,7 @@ class DboSource extends DataSource
|
|||
}
|
||||
return $sql;
|
||||
}
|
||||
else if($joinedOnSelf != true)
|
||||
else
|
||||
{
|
||||
if(!isset($assocData['fields']))
|
||||
{
|
||||
|
@ -1060,15 +1064,25 @@ class DboSource extends DataSource
|
|||
else
|
||||
{
|
||||
$clause = 'WHERE ';
|
||||
$out = array();
|
||||
$count = 0;
|
||||
$operator = null;
|
||||
foreach ($conditions as $key => $value)
|
||||
$out = $this->conditionKeysToString($conditions);
|
||||
return $clause . ' ('.join(') AND (', $out).')';
|
||||
}
|
||||
}
|
||||
|
||||
function conditionKeysToString($conditions)
|
||||
{
|
||||
$out = array();
|
||||
$operator = null;
|
||||
$bool = array('and', 'or', 'and not', 'or not');
|
||||
|
||||
foreach ($conditions as $key => $value)
|
||||
{
|
||||
if (in_array(low($key), $bool))
|
||||
{
|
||||
$out[] = '('.join(') '.$key.' (', $this->conditionKeysToString($value)).')';
|
||||
}
|
||||
else
|
||||
{
|
||||
if($count > 0)
|
||||
{
|
||||
$operator = ' AND ';
|
||||
}
|
||||
if (is_array($value))
|
||||
{
|
||||
$data = $key . ' IN (';
|
||||
|
@ -1093,7 +1107,6 @@ class DboSource extends DataSource
|
|||
{
|
||||
$match['operator'] = ' = ';
|
||||
}
|
||||
|
||||
if (strpos($match['value'], '-!') === 0)
|
||||
{
|
||||
$match['value'] = str_replace('-!', '', $match['value']);
|
||||
|
@ -1108,13 +1121,13 @@ class DboSource extends DataSource
|
|||
$data = $this->name($key) . ' '.$match['operator'].' '. $match['value'];
|
||||
}
|
||||
}
|
||||
$count++;
|
||||
$out[] = $operator.$data;
|
||||
}
|
||||
return $clause . join('', $out);
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To be overridden in subclasses.
|
||||
*
|
||||
|
@ -1178,12 +1191,13 @@ class DboSource extends DataSource
|
|||
{
|
||||
$direction = $match['direction'];
|
||||
$keys = preg_replace('/'.$match['direction'].'/', '', $keys);
|
||||
return ' ORDER BY '.$keys.$direction;
|
||||
}
|
||||
else
|
||||
{
|
||||
$direction = ' '.$direction;
|
||||
}
|
||||
return ' ORDER BY '.$this->name($keys).$direction;
|
||||
return ' ORDER BY '.$keys.$direction;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,11 +87,11 @@ class DboMysql extends DboSource
|
|||
'string' => array('name' => 'varchar', 'limit' => '255'),
|
||||
'text' => array('name' => 'text'),
|
||||
'integer' => array('name' => 'int', 'limit' => '11'),
|
||||
'float' => array('name' => 'float'),
|
||||
'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d h:i:s'),
|
||||
'timestamp' => array('name' => 'datetime', 'format' => 'Y-m-d h:i:s'),
|
||||
'time' => array('name' => 'time', 'format' => 'h:i:s'),
|
||||
'date' => array('name' => 'date', 'format' => 'Y-m-d'),
|
||||
'float' => array('name' => 'float'),
|
||||
'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d h:i:s', 'formatter' => 'date'),
|
||||
'timestamp' => array('name' => 'datetime', 'format' => 'Y-m-d h:i:s', 'formatter' => 'date'),
|
||||
'time' => array('name' => 'time', 'format' => 'h:i:s', 'formatter' => 'date'),
|
||||
'date' => array('name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'),
|
||||
'binary' => array('name' => 'blob'),
|
||||
'boolean' => array('name' => 'tinyint', 'limit' => '1'));
|
||||
|
||||
|
@ -503,6 +503,16 @@ class DboMysql extends DboSource
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @param string $real Real database-layer column type (i.e. "varchar(255)")
|
||||
*/
|
||||
function column($real)
|
||||
{
|
||||
return $real;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
|
|
|
@ -640,7 +640,7 @@ class Model extends Object
|
|||
|
||||
$cols = array();
|
||||
foreach($columns as $col) {
|
||||
$cols[$col['name']] = $col['type'];
|
||||
$cols[$col['name']] = $this->db->column($col['type']);
|
||||
}
|
||||
return $cols;
|
||||
}
|
||||
|
@ -888,7 +888,7 @@ class Model extends Object
|
|||
}
|
||||
else
|
||||
{
|
||||
return $this->hasAny($this->escapeField($this->primaryKey).' = '.$this->db->value($this->id));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1095,7 +1095,6 @@ class Model extends Object
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if a record with set id exists.
|
||||
*
|
||||
|
@ -1455,7 +1454,12 @@ class Model extends Object
|
|||
*/
|
||||
function generateList ($conditions = null, $order = null, $limit = null, $keyPath = null, $valuePath = null)
|
||||
{
|
||||
$fields = array($this->primaryKey, $this->displayField);
|
||||
if ($keyPath == null && $valuePath == null)
|
||||
{
|
||||
$fields = array($this->primaryKey, $this->displayField);
|
||||
} else {
|
||||
$fields = '*';
|
||||
}
|
||||
$result = $this->findAll($conditions, $fields, $order, $limit, 1, 0);
|
||||
|
||||
if ($keyPath == null)
|
||||
|
|
|
@ -636,7 +636,7 @@ class Model extends Object
|
|||
|
||||
$cols = array();
|
||||
foreach($columns as $col) {
|
||||
$cols[$col['name']] = $col['type'];
|
||||
$cols[$col['name']] = $this->db->column($col['type']);
|
||||
}
|
||||
return $cols;
|
||||
}
|
||||
|
@ -884,7 +884,7 @@ class Model extends Object
|
|||
}
|
||||
else
|
||||
{
|
||||
return $this->hasAny($this->escapeField($this->primaryKey).' = '.$this->db->value($this->id));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1087,7 +1087,7 @@ class Model extends Object
|
|||
{
|
||||
foreach ($this->hasAndBelongsToMany as $assoc => $data)
|
||||
{
|
||||
$this->db->execute("DELETE FROM {$this->db->name($data['joinTable'])} WHERE {$this->db->name($data['foreignKey'])} = '{$id}'");
|
||||
$this->db->execute("DELETE FROM ".$this->db->name($data['joinTable'])." WHERE ".$this->db->name($data['foreignKey'])." = '{$id}'");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1450,7 +1450,12 @@ class Model extends Object
|
|||
*/
|
||||
function generateList ($conditions = null, $order = null, $limit = null, $keyPath = null, $valuePath = null)
|
||||
{
|
||||
$fields = array($this->primaryKey, $this->displayField);
|
||||
if ($keyPath == null && $valuePath == null)
|
||||
{
|
||||
$fields = array($this->primaryKey, $this->displayField);
|
||||
} else {
|
||||
$fields = '*';
|
||||
}
|
||||
$result = $this->findAll($conditions, $fields, $order, $limit, 1, 0);
|
||||
|
||||
if ($keyPath == null)
|
||||
|
|
|
@ -133,17 +133,26 @@ class Object
|
|||
{
|
||||
uses('cake_log');
|
||||
}
|
||||
if (is_null($this->_log))
|
||||
{
|
||||
$this->_log = new CakeLog();
|
||||
}
|
||||
if (is_null($this->_log))
|
||||
{
|
||||
$this->_log = new CakeLog();
|
||||
}
|
||||
if (!is_string($msg))
|
||||
{
|
||||
ob_start();
|
||||
print_r($msg);
|
||||
$msg = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case LOG_DEBUG:
|
||||
return $this->_log->write('debug', $msg);
|
||||
default:
|
||||
return $this->_log->write('error', $msg);
|
||||
switch ($type)
|
||||
{
|
||||
case LOG_DEBUG:
|
||||
return $this->_log->write('debug', $msg);
|
||||
break;
|
||||
default:
|
||||
return $this->_log->write('error', $msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ class CakeSession extends Object
|
|||
function __destroy($key)
|
||||
{
|
||||
$db =& ConnectionManager::getDataSource('default');
|
||||
$db->execute("DELETE FROM ".$db->name('cake_sessions')." WHERE ".$db->name('id')." = ".$db->value($key));
|
||||
$db->execute("DELETE FROM ".$db->name('cake_sessions')." WHERE ".$db->name('cake_sessions.id')." = ".$db->value($key));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -332,7 +332,7 @@ class CakeSession extends Object
|
|||
function __gc($expires)
|
||||
{
|
||||
$db =& ConnectionManager::getDataSource('default');
|
||||
$db->execute("DELETE FROM ".$db->name('cake_sessions')." WHERE ".$db->name('expires')." < " . $db->value(time()));
|
||||
$db->execute("DELETE FROM ".$db->name('cake_sessions')." WHERE ".$db->name('cake_sessions.expires')." < " . $db->value(time()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -501,7 +501,7 @@ class CakeSession extends Object
|
|||
{
|
||||
$db =& ConnectionManager::getDataSource('default');
|
||||
|
||||
$row = $db->query("SELECT ".$db->name('data')." FROM ".$db->name('cake_sessions')." WHERE ".$db->name('id')." = ".$db->value($key));
|
||||
$row = $db->query("SELECT ".$db->name('cake_sessions.data')." FROM ".$db->name('cake_sessions')." WHERE ".$db->name('cake_sessions.id')." = ".$db->value($key));
|
||||
|
||||
if ($row && $row[0]['cake_sessions']['data'])
|
||||
{
|
||||
|
@ -634,15 +634,15 @@ class CakeSession extends Object
|
|||
|
||||
$expires = time() + CAKE_SESSION_TIMEOUT * $factor;
|
||||
|
||||
$row = $db->query("SELECT COUNT(*) AS count FROM ".$db->name('cake_sessions')." WHERE ".$db->name('id')." = ".$db->value($key));
|
||||
$row = $db->query("SELECT COUNT(id) AS count FROM ".$db->name('cake_sessions')." WHERE ".$db->name('cake_sessions.id')." = ".$db->value($key));
|
||||
|
||||
if($row[0][0]['count'] > 0)
|
||||
{
|
||||
$db->execute("UPDATE ".$db->name('cake_sessions')." SET ".$db->name('data')." = ".$db->value($value).", ".$db->name('expires')." = ".$db->value($expires)." WHERE ".$db->name('id')." = ".$db->value($key));
|
||||
$db->execute("UPDATE ".$db->name('cake_sessions')." SET ".$db->name('cake_sessions.data')." = ".$db->value($value).", ".$db->name('cake_sessions.expires')." = ".$db->value($expires)." WHERE ".$db->name('cake_sessions.id')." = ".$db->value($key));
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->execute("INSERT INTO ".$db->name('cake_sessions')." (".$db->name('data').",".$db->name('expires').",".$db->name('id').") VALUES (".$db->value($value).", ".$db->value($expires).", ".$db->value($key).")");
|
||||
$db->execute("INSERT INTO ".$db->name('cake_sessions')." (".$db->name('cake_sessions.data').",".$db->name('cake_sessions.expires').",".$db->name('cake_sessions.id').") VALUES (".$db->value($value).", ".$db->value($expires).", ".$db->value($key).")");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class AjaxHelper extends Helper
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
var $ajaxOptions = array('type', 'confirm', 'condition', 'before', 'after', 'fallback', 'update', 'loading', 'loaded', 'interactive', 'complete', 'with', 'url', 'method', 'position', 'form', 'parameters', 'evalScripts', 'asynchronous', 'onComplete', 'onUninitialized', 'onLoading', 'onLoaded', 'onInteractive');
|
||||
var $ajaxOptions = array('type', 'confirm', 'condition', 'before', 'after', 'fallback', 'update', 'loading', 'loaded', 'interactive', 'complete', 'with', 'url', 'method', 'position', 'form', 'parameters', 'evalScripts', 'asynchronous', 'onComplete', 'onUninitialized', 'onLoading', 'onLoaded', 'onInteractive', 'insertion');
|
||||
|
||||
/**
|
||||
* Options for draggable.
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
<br />
|
||||
<p>
|
||||
<!--PLEASE USE ONE OF THE POWERED BY CAKEPHP LOGO-->
|
||||
<a href="http://www.cakephp.org/" target="_new">
|
||||
<a href="http://www.cakephp.org/" target="_blank">
|
||||
<?php echo $html->image('cake.power.png', array('alt'=>'CakePHP : Rapid Development Framework',
|
||||
'height' => "15",
|
||||
'width' => "80"))?>
|
||||
|
|
|
@ -216,26 +216,29 @@ class View extends Object
|
|||
*/
|
||||
function __construct (&$controller)
|
||||
{
|
||||
$this->controller =& $controller;
|
||||
$this->_viewVars =& $this->controller->_viewVars;
|
||||
$this->action =& $this->controller->action;
|
||||
$this->autoLayout =& $this->controller->autoLayout;
|
||||
$this->autoRender =& $this->controller->autoRender;
|
||||
$this->base =& $this->controller->base;
|
||||
$this->webroot =& $this->controller->webroot;
|
||||
$this->helpers =& $this->controller->helpers;
|
||||
$this->here =& $this->controller->here;
|
||||
$this->layout =& $this->controller->layout;
|
||||
$this->modelNames =& $this->controller->modelNames;
|
||||
$this->name =& $this->controller->name;
|
||||
$this->pageTitle =& $this->controller->pageTitle;
|
||||
$this->parent =& $this->controller->parent;
|
||||
$this->viewPath =& $this->controller->viewPath;
|
||||
$this->params =& $this->controller->params;
|
||||
$this->data =& $this->controller->data;
|
||||
$this->displayFields =& $this->controller->displayFields;
|
||||
$this->webservices =& $this->controller->webservices;
|
||||
$this->plugin =& $this->controller->plugin;
|
||||
if ($controller != null)
|
||||
{
|
||||
$this->controller =& $controller;
|
||||
$this->_viewVars =& $this->controller->_viewVars;
|
||||
$this->action =& $this->controller->action;
|
||||
$this->autoLayout =& $this->controller->autoLayout;
|
||||
$this->autoRender =& $this->controller->autoRender;
|
||||
$this->base =& $this->controller->base;
|
||||
$this->webroot =& $this->controller->webroot;
|
||||
$this->helpers =& $this->controller->helpers;
|
||||
$this->here =& $this->controller->here;
|
||||
$this->layout =& $this->controller->layout;
|
||||
$this->modelNames =& $this->controller->modelNames;
|
||||
$this->name =& $this->controller->name;
|
||||
$this->pageTitle =& $this->controller->pageTitle;
|
||||
$this->parent =& $this->controller->parent;
|
||||
$this->viewPath =& $this->controller->viewPath;
|
||||
$this->params =& $this->controller->params;
|
||||
$this->data =& $this->controller->data;
|
||||
$this->displayFields =& $this->controller->displayFields;
|
||||
$this->webservices =& $this->controller->webservices;
|
||||
$this->plugin =& $this->controller->plugin;
|
||||
}
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
@ -353,11 +356,11 @@ class View extends Object
|
|||
{
|
||||
if(substr($viewFileName, -5) === 'thtml')
|
||||
{
|
||||
$out = View::_render($viewFileName, $this->_viewVars, 0);
|
||||
$out = View::_render($viewFileName, $this->_viewVars);
|
||||
}
|
||||
else
|
||||
{
|
||||
$out = $this->_render($viewFileName, $this->_viewVars, 0);
|
||||
$out = $this->_render($viewFileName, $this->_viewVars);
|
||||
}
|
||||
if ($out !== false)
|
||||
{
|
||||
|
@ -370,7 +373,7 @@ class View extends Object
|
|||
}
|
||||
else
|
||||
{
|
||||
$out = $this->_render($viewFileName, $this->_viewVars, false);
|
||||
$out = $this->_render($viewFileName, $this->_viewVars);
|
||||
trigger_error(sprintf(__("Error in view %s, got: <blockquote>%s</blockquote>"), $viewFileName, $out), E_USER_ERROR);
|
||||
}
|
||||
return true;
|
||||
|
@ -399,7 +402,7 @@ class View extends Object
|
|||
{
|
||||
$fn = APP.'plugins'.DS.$this->plugin.'views'.DS.'elements'.DS.$name.$this->ext;
|
||||
$params = array_merge_recursive($params, $this->loaded);
|
||||
return $this->_render($fn, array_merge($this->_viewVars, $params), true, false);
|
||||
return $this->_render($fn, array_merge($this->_viewVars, $params), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -409,7 +412,12 @@ class View extends Object
|
|||
}
|
||||
|
||||
$params = array_merge_recursive($params, $this->loaded);
|
||||
return $this->_render($fn, array_merge($this->_viewVars, $params), true, false);
|
||||
return $this->_render($fn, array_merge($this->_viewVars, $params), false);
|
||||
}
|
||||
|
||||
function element($name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -422,35 +430,44 @@ class View extends Object
|
|||
{
|
||||
$layout_fn = $this->_getLayoutFileName();
|
||||
|
||||
if(DEBUG > 2)
|
||||
if(DEBUG > 2 && $this->controller != null)
|
||||
{
|
||||
$debug = View::_render(LIBS.'view'.DS.'templates'.DS.'elements'.DS.'dump.thtml', array('controller' => $this->controller), true, false);
|
||||
$debug = View::_render(LIBS.'view'.DS.'templates'.DS.'elements'.DS.'dump.thtml', array('controller' => $this->controller), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
$debug = '';
|
||||
}
|
||||
$data_for_layout = array_merge($this->_viewVars, array(
|
||||
'title_for_layout'=>$this->pageTitle !== false? $this->pageTitle: Inflector::humanize($this->viewPath),
|
||||
'content_for_layout'=>$content_for_layout,
|
||||
'cakeDebug' => $debug));
|
||||
|
||||
if ($this->pageTitle !== false)
|
||||
{
|
||||
$pageTitle = $this->pageTitle;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pageTitle = Inflector::humanize($this->viewPath);
|
||||
}
|
||||
|
||||
$data_for_layout = array_merge($this->_viewVars, array('title_for_layout' => $pageTitle,
|
||||
'content_for_layout'=> $content_for_layout,
|
||||
'cakeDebug' => $debug));
|
||||
|
||||
if (is_file($layout_fn))
|
||||
{
|
||||
$data_for_layout = array_merge($data_for_layout,$this->loaded); # load all view variables)
|
||||
$data_for_layout = array_merge($data_for_layout, $this->loaded);
|
||||
|
||||
if(substr($layout_fn, -5) === 'thtml')
|
||||
{
|
||||
$out = View::_render($layout_fn, $data_for_layout, true, false);
|
||||
$out = View::_render($layout_fn, $data_for_layout, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
$out = $this->_render($layout_fn, $data_for_layout, true, false);
|
||||
$out = $this->_render($layout_fn, $data_for_layout, false);
|
||||
}
|
||||
|
||||
if ($out === false)
|
||||
{
|
||||
$out = $this->_render($layout_fn, $data_for_layout, false);
|
||||
$out = $this->_render($layout_fn, $data_for_layout);
|
||||
trigger_error(sprintf(__("Error in layout %s, got: <blockquote>%s</blockquote>"), $layout_fn, $out), E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
@ -550,7 +567,7 @@ class View extends Object
|
|||
*/
|
||||
function _getLayoutFileName()
|
||||
{
|
||||
if(!is_null($this->webservices))
|
||||
if(isset($this->webservices) && !is_null($this->webservices))
|
||||
{
|
||||
$type = strtolower($this->webservices).DS;
|
||||
}
|
||||
|
@ -559,7 +576,7 @@ class View extends Object
|
|||
$type = null;
|
||||
}
|
||||
|
||||
if(!is_null($this->plugin))
|
||||
if(isset($this->plugin) && !is_null($this->plugin))
|
||||
{
|
||||
if(file_exists(APP.'plugins'.DS.$this->plugin.'views'.DS.'layouts'.DS.$this->layout.$this->ext))
|
||||
{
|
||||
|
@ -586,11 +603,10 @@ class View extends Object
|
|||
*
|
||||
* @param string $___viewFn Filename of the view
|
||||
* @param array $___dataForView Data to include in rendered view
|
||||
* @param boolean $___playSafe If set to false, the include() of the $__viewFn is done without suppressing output of errors
|
||||
* @return string Rendered output
|
||||
* @access private
|
||||
*/
|
||||
function _render($___viewFn, $___dataForView, $___playSafe = true, $loadHelpers = true)
|
||||
function _render($___viewFn, $___dataForView, $loadHelpers = true)
|
||||
{
|
||||
if ($this->helpers != false && $loadHelpers === true)
|
||||
{
|
||||
|
@ -615,27 +631,22 @@ class View extends Object
|
|||
}
|
||||
}
|
||||
|
||||
extract($___dataForView, EXTR_SKIP); # load all view variables
|
||||
/**
|
||||
* Local template variables.
|
||||
*/
|
||||
$BASE = $this->base;
|
||||
$params = &$this->params;
|
||||
$page_title = $this->pageTitle;
|
||||
extract($___dataForView, EXTR_SKIP);
|
||||
$BASE = $this->base;
|
||||
$params = &$this->params;
|
||||
$page_title = $this->pageTitle;
|
||||
|
||||
/**
|
||||
* Start caching output (eval outputs directly so we need to cache).
|
||||
*/
|
||||
ob_start();
|
||||
|
||||
/**
|
||||
* Include the template.
|
||||
*/
|
||||
$___playSafe? @include($___viewFn): include($___viewFn);
|
||||
|
||||
$out = ob_get_clean();
|
||||
|
||||
return $out;
|
||||
ob_start();
|
||||
if(DEBUG)
|
||||
{
|
||||
include($___viewFn);
|
||||
}
|
||||
else
|
||||
{
|
||||
@include($___viewFn);
|
||||
}
|
||||
$out = ob_get_clean();
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -693,12 +704,12 @@ class View extends Object
|
|||
|
||||
if(class_exists($helperCn))
|
||||
{
|
||||
${$camelBackedHelper} =& new $helperCn;
|
||||
${$camelBackedHelper} =& new $helperCn;
|
||||
${$camelBackedHelper}->base = $this->base;
|
||||
${$camelBackedHelper}->webroot = $this->webroot;
|
||||
${$camelBackedHelper}->here = $this->here;
|
||||
${$camelBackedHelper}->params = $this->params;
|
||||
${$camelBackedHelper}->action = $this->action;
|
||||
${$camelBackedHelper}->params = $this->params;
|
||||
${$camelBackedHelper}->action = $this->action;
|
||||
${$camelBackedHelper}->data = $this->data;
|
||||
${$camelBackedHelper}->themeWeb = $this->themeWeb;
|
||||
${$camelBackedHelper}->tags = $tags;
|
||||
|
@ -724,6 +735,13 @@ class View extends Object
|
|||
return $loaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @param unknown_type $action
|
||||
* @param unknown_type $layout
|
||||
* @return unknown
|
||||
*/
|
||||
function pluginView($action, $layout)
|
||||
{
|
||||
$viewFileName = APP.'plugins'.DS.$this->plugin.'views'.DS.$this->viewPath.DS.$action.$this->ext;
|
||||
|
|
Loading…
Add table
Reference in a new issue