2005-07-04 01:07:14 +00:00
|
|
|
<?php
|
2005-08-21 06:49:02 +00:00
|
|
|
/* SVN FILE: $Id$ */
|
2005-06-19 23:30:36 +00:00
|
|
|
/**
|
2005-08-25 03:45:14 +00:00
|
|
|
* Base controller class.
|
2005-06-19 23:30:36 +00:00
|
|
|
*
|
2005-08-21 06:49:02 +00:00
|
|
|
* PHP versions 4 and 5
|
2005-06-19 23:30:36 +00:00
|
|
|
*
|
2005-08-21 06:49:02 +00:00
|
|
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
2006-05-26 05:29:17 +00:00
|
|
|
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
2005-07-10 05:08:19 +00:00
|
|
|
*
|
2005-12-23 21:57:26 +00:00
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
2005-07-10 05:08:19 +00:00
|
|
|
*
|
2005-08-25 03:45:14 +00:00
|
|
|
* @filesource
|
2006-05-26 05:29:17 +00:00
|
|
|
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
|
|
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.cake.libs.controller
|
|
|
|
* @since CakePHP v 0.2.9
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
2005-07-10 05:08:19 +00:00
|
|
|
*/
|
|
|
|
/**
|
2005-08-25 03:45:14 +00:00
|
|
|
* Include files
|
2005-07-10 05:08:19 +00:00
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
uses(DS . 'controller' . DS . 'component', DS . 'view' . DS . 'view');
|
2005-07-10 05:08:19 +00:00
|
|
|
/**
|
2005-08-21 06:49:02 +00:00
|
|
|
* Controller
|
2005-07-10 05:08:19 +00:00
|
|
|
*
|
2005-08-25 03:45:14 +00:00
|
|
|
* Application controller (controllers are where you put all the actual code)
|
2005-08-21 06:49:02 +00:00
|
|
|
* Provides basic functionality, such as rendering views (aka displaying templates).
|
2005-08-25 03:45:14 +00:00
|
|
|
* Automatically selects model name from on singularized object class name
|
2005-08-21 06:49:02 +00:00
|
|
|
* and creates the model object if proper class exists.
|
2005-07-10 05:08:19 +00:00
|
|
|
*
|
2006-05-26 05:29:17 +00:00
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.cake.libs.controller
|
2005-07-10 05:08:19 +00:00
|
|
|
*
|
|
|
|
*/
|
2006-08-18 07:53:45 +00:00
|
|
|
class Controller extends Object {
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* Name of the controller.
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $name = null;
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* Stores the current URL (for links etc.)
|
|
|
|
*
|
|
|
|
* @var string Current URL
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $here = null;
|
2006-06-14 18:02:37 +00:00
|
|
|
/**
|
|
|
|
* The webroot of the application
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
var $webroot = null;
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* Action to be performed.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $action = null;
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* An array of names of models the particular controller wants to use.
|
|
|
|
*
|
|
|
|
* @var mixed A single name as a string or a list of names as an array.
|
|
|
|
* @access protected
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $uses = false;
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* An array of names of built-in helpers to include.
|
|
|
|
*
|
|
|
|
* @var mixed A single name as a string or a list of names as an array.
|
|
|
|
* @access protected
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $helpers = array('Html');
|
2006-06-14 18:02:37 +00:00
|
|
|
/**
|
|
|
|
* Parameters received in the current request, i.e. GET and POST data
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
var $params = array();
|
|
|
|
/**
|
|
|
|
* POST'ed model data
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
var $data = array();
|
2006-10-16 20:02:34 +00:00
|
|
|
/**
|
2006-11-08 03:28:24 +00:00
|
|
|
* Pagination defaults
|
2006-10-16 20:02:34 +00:00
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-11-08 03:28:24 +00:00
|
|
|
var $paginate = array('limit' => 20, 'page' => 1);
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
2006-08-18 07:53:45 +00:00
|
|
|
* Sub-path for view files
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
*
|
2006-08-18 07:53:45 +00:00
|
|
|
* @var string
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $viewPath = null;
|
2006-08-18 07:53:45 +00:00
|
|
|
/**
|
|
|
|
* Sub-path for layout files
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2006-11-01 07:15:44 +00:00
|
|
|
var $layoutPath = null;
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* Variables for the view
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $_viewVars = array();
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* Web page title
|
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
* @access private
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $pageTitle = false;
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* An array of model objects.
|
|
|
|
*
|
|
|
|
* @var array Array of model objects.
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $modelNames = array();
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $base = null;
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* Layout file to use (see /app/views/layouts/default.thtml)
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $layout = 'default';
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* Automatically render the view (the dispatcher checks for this variable before running render())
|
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $autoRender = true;
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $autoLayout = true;
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $beforeFilter = null;
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $components = array();
|
2006-01-01 02:05:01 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $view = 'View';
|
2006-08-18 07:53:45 +00:00
|
|
|
/**
|
|
|
|
* File extension for view templates. Defaults to Cake's conventional ".thtml".
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
var $ext = '.thtml';
|
2006-01-01 02:05:01 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $_viewClass = null;
|
2006-02-02 11:48:29 +00:00
|
|
|
/**
|
|
|
|
* The output of the requested action. Contains either a variable
|
|
|
|
* returned from the action, or the data of the rendered view;
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $output = null;
|
2006-02-02 11:48:29 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $plugin = null;
|
2006-03-12 00:11:40 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $cacheAction = false;
|
2006-03-19 03:26:43 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
var $persistModel = false;
|
2006-07-07 02:46:16 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var unknown_type
|
|
|
|
*/
|
|
|
|
var $webservices = null;
|
2006-06-15 15:51:34 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var mixed
|
|
|
|
*/
|
|
|
|
var $namedArgs = false;
|
2006-07-23 16:13:05 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
var $argSeparator = ':';
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function __construct() {
|
|
|
|
if ($this->name === null) {
|
2006-06-14 18:02:37 +00:00
|
|
|
$r = null;
|
2006-05-26 05:29:17 +00:00
|
|
|
|
2006-06-14 18:02:37 +00:00
|
|
|
if (!preg_match('/(.*)Controller/i', get_class($this), $r)) {
|
|
|
|
die ("Controller::__construct() : Can't get or parse my own class name, exiting.");
|
|
|
|
}
|
|
|
|
$this->name = $r[1];
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->viewPath == null) {
|
2006-06-14 18:02:37 +00:00
|
|
|
$this->viewPath = Inflector::underscore($this->name);
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
2006-03-08 03:13:32 +00:00
|
|
|
|
2006-06-14 18:02:37 +00:00
|
|
|
$this->modelClass = ucwords(Inflector::singularize($this->name));
|
|
|
|
$this->modelKey = Inflector::underscore($this->modelClass);
|
2006-03-08 03:13:32 +00:00
|
|
|
|
2006-05-26 05:29:17 +00:00
|
|
|
if (!defined('AUTO_SESSION') || AUTO_SESSION == true) {
|
2006-06-14 18:02:37 +00:00
|
|
|
$this->components[] = 'Session';
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
2006-02-23 08:24:23 +00:00
|
|
|
|
2006-05-26 05:29:17 +00:00
|
|
|
if (is_subclass_of($this, 'AppController')) {
|
2006-06-14 18:02:37 +00:00
|
|
|
$appVars = get_class_vars('AppController');
|
|
|
|
|
|
|
|
foreach(array('components', 'helpers', 'uses') as $var) {
|
|
|
|
if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
|
|
|
|
$diff = array_diff($appVars[$var], $this->{$var});
|
|
|
|
$this->{$var} = array_merge($this->{$var}, $diff);
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
2006-06-14 18:02:37 +00:00
|
|
|
}
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
2006-07-29 17:08:23 +00:00
|
|
|
parent::__construct();
|
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
|
2006-07-29 17:08:23 +00:00
|
|
|
function _initComponents(){
|
2006-05-26 05:29:17 +00:00
|
|
|
if (!empty($this->components)) {
|
2006-06-15 09:58:45 +00:00
|
|
|
$component = new Component();
|
|
|
|
$component->init($this);
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-29 17:08:23 +00:00
|
|
|
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
/**
|
2006-02-23 08:24:23 +00:00
|
|
|
* Loads and instantiates classes required by this controller,
|
|
|
|
* including components and models
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
*
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function constructClasses() {
|
2006-11-12 00:12:34 +00:00
|
|
|
if (empty($this->passedArgs) || !isset($this->passedArgs['0'])) {
|
2006-05-26 05:29:17 +00:00
|
|
|
$id = false;
|
|
|
|
} else {
|
2006-11-12 00:12:34 +00:00
|
|
|
$id = $this->passedArgs['0'];
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
$cached = false;
|
|
|
|
$object = null;
|
|
|
|
|
2006-11-21 21:48:05 +00:00
|
|
|
if ($this->persistModel === true){
|
|
|
|
loadModels();
|
2006-11-22 20:08:53 +00:00
|
|
|
uses('neat_array');
|
2006-11-21 21:48:05 +00:00
|
|
|
} elseif($this->uses === false) {
|
2006-11-22 20:33:21 +00:00
|
|
|
if(!class_exists($this->modelClass)){
|
|
|
|
loadModel($this->modelClass);
|
|
|
|
}
|
2006-11-21 21:48:05 +00:00
|
|
|
}
|
|
|
|
|
2006-05-26 05:29:17 +00:00
|
|
|
if (class_exists($this->modelClass) && ($this->uses === false)) {
|
|
|
|
if ($this->persistModel === true) {
|
|
|
|
$cached = $this->_persist($this->modelClass, null, $object);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (($cached === false)) {
|
|
|
|
$model =& new $this->modelClass($id);
|
|
|
|
$this->modelNames[] = $this->modelClass;
|
|
|
|
$this->{$this->modelClass} =& $model;
|
|
|
|
|
|
|
|
if ($this->persistModel === true) {
|
|
|
|
$this->_persist($this->modelClass, true, $model);
|
|
|
|
$registry = ClassRegistry::getInstance();
|
|
|
|
$this->_persist($this->modelClass . 'registry', true, $registry->_objects, 'registry');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$this->_persist($this->modelClass . 'registry', true, $object, 'registry');
|
|
|
|
$this->_persist($this->modelClass, true, $object);
|
2006-06-14 18:02:37 +00:00
|
|
|
$this->modelNames[] = $this->modelClass;
|
2006-05-26 05:29:17 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} elseif ($this->uses === false) {
|
|
|
|
return $this->cakeError('missingModel', array(array('className' => $this->modelClass, 'webroot' => '', 'base' => $this->base)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->uses) {
|
|
|
|
$uses = is_array($this->uses) ? $this->uses : array($this->uses);
|
|
|
|
|
|
|
|
foreach($uses as $modelClass) {
|
2006-07-29 17:52:12 +00:00
|
|
|
$id = false;
|
2006-05-26 05:29:17 +00:00
|
|
|
$cached = false;
|
|
|
|
$object = null;
|
|
|
|
$modelKey = Inflector::underscore($modelClass);
|
2006-11-22 20:08:53 +00:00
|
|
|
|
|
|
|
if(!class_exists($modelClass)){
|
|
|
|
loadModel($modelClass);
|
|
|
|
}
|
2006-05-26 05:29:17 +00:00
|
|
|
|
|
|
|
if (class_exists($modelClass)) {
|
|
|
|
if ($this->persistModel === true) {
|
|
|
|
$cached = $this->_persist($modelClass, null, $object);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (($cached === false)) {
|
|
|
|
$model =& new $modelClass($id);
|
|
|
|
$this->modelNames[] = $modelClass;
|
|
|
|
$this->{$modelClass} =& $model;
|
|
|
|
|
|
|
|
if ($this->persistModel === true) {
|
|
|
|
$this->_persist($modelClass, true, $model);
|
|
|
|
$registry = ClassRegistry::getInstance();
|
|
|
|
$this->_persist($modelClass . 'registry', true, $registry->_objects, 'registry');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$this->_persist($modelClass . 'registry', true, $object, 'registry');
|
|
|
|
$this->_persist($modelClass, true, $object);
|
|
|
|
$this->modelNames[] = $modelClass;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return $this->cakeError('missingModel', array(array('className' => $modelClass, 'webroot' => '', 'base' => $this->base)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
/**
|
2006-09-14 21:59:51 +00:00
|
|
|
* Redirects to given $url, after turning off $this->autoRender. Please notice that the script execution is not stopped
|
2006-08-29 07:05:43 +00:00
|
|
|
* after the redirect.
|
2005-12-22 01:07:28 +00:00
|
|
|
*
|
2006-02-01 13:26:23 +00:00
|
|
|
* @param string $url
|
|
|
|
* @param integer $status
|
2005-12-22 01:07:28 +00:00
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function redirect($url, $status = null) {
|
|
|
|
$this->autoRender = false;
|
|
|
|
|
|
|
|
if (function_exists('session_write_close')) {
|
|
|
|
session_write_close();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($status != null) {
|
2006-06-14 18:02:37 +00:00
|
|
|
$codes = array(
|
2006-10-20 17:24:37 +00:00
|
|
|
100 => "Continue",
|
|
|
|
101 => "Switching Protocols",
|
|
|
|
200 => "OK",
|
|
|
|
201 => "Created",
|
|
|
|
202 => "Accepted",
|
|
|
|
203 => "Non-Authoritative Information",
|
|
|
|
204 => "No Content",
|
|
|
|
205 => "Reset Content",
|
|
|
|
206 => "Partial Content",
|
|
|
|
300 => "Multiple Choices",
|
|
|
|
301 => "Moved Permanently",
|
|
|
|
302 => "Found",
|
|
|
|
303 => "See Other",
|
|
|
|
304 => "Not Modified",
|
|
|
|
305 => "Use Proxy",
|
|
|
|
307 => "Temporary Redirect",
|
|
|
|
400 => "Bad Request",
|
|
|
|
401 => "Unauthorized",
|
|
|
|
402 => "Payment Required",
|
|
|
|
403 => "Forbidden",
|
|
|
|
404 => "Not Found",
|
|
|
|
405 => "Method Not Allowed",
|
|
|
|
406 => "Not Acceptable",
|
|
|
|
407 => "Proxy Authentication Required",
|
|
|
|
408 => "Request Time-out",
|
|
|
|
409 => "Conflict",
|
|
|
|
410 => "Gone",
|
|
|
|
411 => "Length Required",
|
|
|
|
412 => "Precondition Failed",
|
|
|
|
413 => "Request Entity Too Large",
|
|
|
|
414 => "Request-URI Too Large",
|
|
|
|
415 => "Unsupported Media Type",
|
|
|
|
416 => "Requested range not satisfiable",
|
|
|
|
417 => "Expectation Failed",
|
|
|
|
500 => "Internal Server Error",
|
|
|
|
501 => "Not Implemented",
|
|
|
|
502 => "Bad Gateway",
|
|
|
|
503 => "Service Unavailable",
|
|
|
|
504 => "Gateway Time-out"
|
2006-06-14 18:02:37 +00:00
|
|
|
);
|
2006-05-26 05:29:17 +00:00
|
|
|
|
|
|
|
if (isset($codes[$status])) {
|
2006-10-20 17:24:37 +00:00
|
|
|
header("HTTP/1.1 {$status} " . $codes[$status]);
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
}
|
2006-11-08 03:28:24 +00:00
|
|
|
if ($url !== null) {
|
|
|
|
header('Location: ' . Router::url($url, defined('SERVER_IIS')));
|
|
|
|
}
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
/**
|
|
|
|
* Saves a variable to use inside a template.
|
|
|
|
*
|
|
|
|
* @param mixed $one A string or an array of data.
|
2006-08-12 13:06:21 +00:00
|
|
|
* @param mixed $two Value in case $one is a string (which then works as the key).
|
|
|
|
* Unused if $one is an associative array, otherwise serves as the values to $one's keys.
|
2006-08-18 07:58:10 +00:00
|
|
|
* @return void
|
2005-12-22 01:07:28 +00:00
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function set($one, $two = null) {
|
2006-08-18 07:58:10 +00:00
|
|
|
$data = array();
|
|
|
|
|
2006-05-26 05:29:17 +00:00
|
|
|
if (is_array($one)) {
|
|
|
|
if (is_array($two)) {
|
2006-08-18 07:58:10 +00:00
|
|
|
$data = array_combine($one, $two);
|
2006-05-26 05:29:17 +00:00
|
|
|
} else {
|
2006-08-18 07:58:10 +00:00
|
|
|
$data = $one;
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
} else {
|
2006-08-18 07:58:10 +00:00
|
|
|
$data = array($one => $two);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach($data as $name => $value) {
|
|
|
|
if ($name == 'title') {
|
|
|
|
$this->pageTitle = $value;
|
|
|
|
} else {
|
|
|
|
$this->_viewVars[$name] = $value;
|
|
|
|
}
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
/**
|
2006-08-18 07:58:10 +00:00
|
|
|
* Internally redirects one action to another
|
2005-12-22 01:07:28 +00:00
|
|
|
*
|
2006-08-18 07:58:10 +00:00
|
|
|
* @param string $action The new action to be redirected to
|
|
|
|
* @param mixed Any other parameters passed to this method will be passed as
|
|
|
|
* parameters to the new action.
|
2005-12-22 01:07:28 +00:00
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function setAction($action) {
|
|
|
|
$this->action = $action;
|
|
|
|
$args = func_get_args();
|
|
|
|
unset($args[0]);
|
|
|
|
call_user_func_array(array(&$this, $action), $args);
|
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
/**
|
|
|
|
* Returns number of errors in a submitted FORM.
|
|
|
|
*
|
|
|
|
* @return int Number of errors
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function validate() {
|
|
|
|
$args = func_get_args();
|
|
|
|
$errors = call_user_func_array(array(&$this, 'validateErrors'), $args);
|
2005-08-21 06:49:02 +00:00
|
|
|
|
2006-05-26 05:29:17 +00:00
|
|
|
if ($errors === false) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return count($errors);
|
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
/**
|
|
|
|
* Validates a FORM according to the rules set up in the Model.
|
|
|
|
*
|
|
|
|
* @return int Number of errors
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function validateErrors() {
|
|
|
|
$objects = func_get_args();
|
|
|
|
if (!count($objects)) {
|
|
|
|
return false;
|
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
|
2006-05-26 05:29:17 +00:00
|
|
|
$errors = array();
|
|
|
|
foreach($objects as $object) {
|
|
|
|
$errors = array_merge($errors, $this->{$object->name}->invalidFields($object->data));
|
|
|
|
}
|
|
|
|
return $this->validationErrors = (count($errors) ? $errors : false);
|
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
/**
|
|
|
|
* Gets an instance of the view object & prepares it for rendering the output, then
|
|
|
|
* asks the view to actualy do the job.
|
|
|
|
*
|
|
|
|
* @param unknown_type $action
|
|
|
|
* @param unknown_type $layout
|
|
|
|
* @param unknown_type $file
|
|
|
|
* @return unknown
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function render($action = null, $layout = null, $file = null) {
|
2006-06-14 18:02:37 +00:00
|
|
|
$viewClass = $this->view;
|
2006-05-26 05:29:17 +00:00
|
|
|
if ($this->view != 'View') {
|
|
|
|
$viewClass = $this->view . 'View';
|
2006-06-14 18:02:37 +00:00
|
|
|
loadView($this->view);
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
$this->beforeRender();
|
|
|
|
$this->_viewClass =& new $viewClass($this);
|
|
|
|
|
|
|
|
if (!empty($this->modelNames)) {
|
|
|
|
foreach($this->modelNames as $model) {
|
|
|
|
if (!empty($this->{$model}->validationErrors)) {
|
|
|
|
$this->_viewClass->validationErrors[$model] = &$this->{$model}->validationErrors;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-06-14 18:02:37 +00:00
|
|
|
$this->autoRender = false;
|
2006-05-26 05:29:17 +00:00
|
|
|
return $this->_viewClass->render($action, $layout, $file);
|
|
|
|
}
|
2006-01-25 22:40:17 +00:00
|
|
|
/**
|
|
|
|
* Gets the referring URL of this request
|
|
|
|
*
|
|
|
|
* @param string $default Default URL to use if HTTP_REFERER cannot be read from headers
|
|
|
|
* @param boolean $local If true, restrict referring URLs to local server
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function referer($default = null, $local = false) {
|
|
|
|
$ref = env('HTTP_REFERER');
|
|
|
|
$base = FULL_BASE_URL . $this->webroot;
|
2006-06-14 18:02:37 +00:00
|
|
|
|
2006-05-26 05:29:17 +00:00
|
|
|
if ($ref != null && (defined(FULL_BASE_URL) || FULL_BASE_URL)) {
|
|
|
|
if (strpos($ref, $base) === 0) {
|
|
|
|
return substr($ref, strlen($base) - 1);
|
|
|
|
} elseif(!$local) {
|
|
|
|
return $ref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($default != null) {
|
|
|
|
return $default;
|
|
|
|
} else {
|
|
|
|
return '/';
|
|
|
|
}
|
|
|
|
}
|
2006-08-29 19:09:35 +00:00
|
|
|
/**
|
|
|
|
* Tells the browser not to cache the results of the current request
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
function disableCache() {
|
|
|
|
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
|
|
|
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
|
|
|
header("Cache-Control: no-store, no-cache, must-revalidate");
|
|
|
|
header("Cache-Control: post-check=0, pre-check=0", false);
|
|
|
|
header("Pragma: no-cache");
|
|
|
|
}
|
2005-09-17 12:37:05 +00:00
|
|
|
/**
|
2006-08-18 07:58:10 +00:00
|
|
|
* @deprecated
|
2006-11-08 03:28:24 +00:00
|
|
|
* @see Controller::set
|
2005-12-22 01:07:28 +00:00
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function _setTitle($pageTitle) {
|
2006-11-08 03:28:24 +00:00
|
|
|
trigger_error('Deprecated: Use Controller::set("title", "...") instead', E_USER_WARNING);
|
2006-05-26 05:29:17 +00:00
|
|
|
$this->pageTitle = $pageTitle;
|
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
/**
|
|
|
|
* Shows a message to the user $time seconds, then redirects to $url
|
|
|
|
* Uses flash.thtml as a layout for the messages
|
|
|
|
*
|
|
|
|
* @param string $message Message to display to the user
|
|
|
|
* @param string $url Relative URL to redirect to after the time expires
|
|
|
|
* @param int $time Time to show the message
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function flash($message, $url, $pause = 1) {
|
|
|
|
$this->autoRender = false;
|
|
|
|
$this->autoLayout = false;
|
|
|
|
$this->set('url', $this->base . $url);
|
|
|
|
$this->set('message', $message);
|
|
|
|
$this->set('pause', $pause);
|
|
|
|
$this->set('page_title', $message);
|
|
|
|
|
|
|
|
if (file_exists(VIEWS . 'layouts' . DS . 'flash.thtml')) {
|
|
|
|
$flash = VIEWS . 'layouts' . DS . 'flash.thtml';
|
|
|
|
} elseif ($flash = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . "layouts" . DS . 'flash.thtml')) {
|
|
|
|
}
|
|
|
|
$this->render(null, false, $flash);
|
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
/**
|
|
|
|
* Shows a message to the user $time seconds, then redirects to $url
|
|
|
|
* Uses flash.thtml as a layout for the messages
|
|
|
|
*
|
|
|
|
* @param string $message Message to display to the user
|
|
|
|
* @param string $url URL to redirect to after the time expires
|
|
|
|
* @param int $time Time to show the message
|
|
|
|
*
|
|
|
|
* @param unknown_type $message
|
|
|
|
* @param unknown_type $url
|
|
|
|
* @param unknown_type $time
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function flashOut($message, $url, $pause = 1) {
|
2006-06-14 18:02:37 +00:00
|
|
|
$this->autoRender = false;
|
|
|
|
$this->autoLayout = false;
|
2006-05-26 05:29:17 +00:00
|
|
|
$this->set('url', $url);
|
|
|
|
$this->set('message', $message);
|
|
|
|
$this->set('pause', $pause);
|
|
|
|
$this->set('page_title', $message);
|
|
|
|
|
|
|
|
if (file_exists(VIEWS . 'layouts' . DS . 'flash.thtml')) {
|
2006-06-14 18:02:37 +00:00
|
|
|
$flash = VIEWS . 'layouts' . DS . 'flash.thtml';
|
2006-05-26 05:29:17 +00:00
|
|
|
} elseif($flash = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . "layouts" . DS . 'flash.thtml')) {
|
|
|
|
}
|
|
|
|
$this->render(null, false, $flash);
|
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
/**
|
|
|
|
* This function creates a $fieldNames array for the view to use.
|
|
|
|
* @todo Map more database field types to html form fields.
|
|
|
|
* @todo View the database field types from all the supported databases.
|
|
|
|
*
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function generateFieldNames($data = null, $doCreateOptions = true) {
|
|
|
|
$fieldNames = array();
|
|
|
|
$model = $this->modelClass;
|
|
|
|
$modelKey = $this->modelKey;
|
|
|
|
$table = $this->{$model}->table;
|
|
|
|
$objRegistryModel =& ClassRegistry::getObject($modelKey);
|
|
|
|
|
|
|
|
foreach($objRegistryModel->_tableInfo as $tables) {
|
|
|
|
foreach($tables as $tabl) {
|
|
|
|
|
|
|
|
if ($objRegistryModel->isForeignKey($tabl['name'])) {
|
|
|
|
if(false !== strpos($tabl['name'], "_id")) {
|
|
|
|
$niceName = substr($tabl['name'], 0, strpos($tabl['name'], "_id" ));
|
|
|
|
} else {
|
|
|
|
$niceName = $niceName = $tabl['name'];
|
|
|
|
}
|
|
|
|
$fkNames = $this->{$model}->keyToTable[$tabl['name']];
|
|
|
|
$fieldNames[$tabl['name']]['table'] = $fkNames[0];
|
|
|
|
$fieldNames[$tabl['name']]['prompt'] = Inflector::humanize($niceName);
|
|
|
|
$fieldNames[$tabl['name']]['model'] = $fkNames[1];
|
|
|
|
$fieldNames[$tabl['name']]['modelKey'] = $this->{$model}->tableToModel[$fieldNames[$tabl['name']]['table']];
|
2006-06-14 18:02:37 +00:00
|
|
|
$fieldNames[$tabl['name']]['controller'] = Inflector::pluralize($this->{$model}->tableToModel[$fkNames[0]]);
|
2006-05-26 05:29:17 +00:00
|
|
|
$fieldNames[$tabl['name']]['foreignKey'] = true;
|
|
|
|
|
|
|
|
} else if('created' != $tabl['name'] && 'updated' != $tabl['name']) {
|
|
|
|
$fieldNames[$tabl['name']]['prompt'] = Inflector::humanize($tabl['name']);
|
|
|
|
} else if('created' == $tabl['name']) {
|
|
|
|
$fieldNames[$tabl['name']]['prompt'] = 'Created';
|
|
|
|
} else if('updated' == $tabl['name']) {
|
|
|
|
$fieldNames[$tabl['name']]['prompt'] = 'Modified';
|
|
|
|
}
|
2006-06-14 18:02:37 +00:00
|
|
|
$fieldNames[$tabl['name']]['tagName'] = $model . '/' . $tabl['name'];
|
|
|
|
$validationFields = $objRegistryModel->validate;
|
2006-05-26 05:29:17 +00:00
|
|
|
|
|
|
|
if (isset($validationFields[$tabl['name']])) {
|
|
|
|
if (VALID_NOT_EMPTY == $validationFields[$tabl['name']]) {
|
|
|
|
$fieldNames[$tabl['name']]['required'] = true;
|
|
|
|
$fieldNames[$tabl['name']]['errorMsg'] = "Required Field";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$lParenPos = strpos($tabl['type'], '(');
|
|
|
|
$rParenPos = strpos($tabl['type'], ')');
|
|
|
|
|
|
|
|
if (false != $lParenPos) {
|
|
|
|
$type = substr($tabl['type'], 0, $lParenPos);
|
|
|
|
$fieldLength = substr($tabl['type'], $lParenPos + 1, $rParenPos - $lParenPos - 1);
|
|
|
|
} else {
|
|
|
|
$type = $tabl['type'];
|
|
|
|
}
|
|
|
|
|
|
|
|
switch($type) {
|
|
|
|
case "text":
|
2006-06-14 18:02:37 +00:00
|
|
|
$fieldNames[$tabl['name']]['type'] = 'area';
|
2006-05-26 05:29:17 +00:00
|
|
|
break;
|
|
|
|
case "string":
|
|
|
|
if (isset($fieldNames[$tabl['name']]['foreignKey'])) {
|
|
|
|
$fieldNames[$tabl['name']]['type'] = 'select';
|
|
|
|
$fieldNames[$tabl['name']]['options'] = array();
|
|
|
|
$otherModel =& ClassRegistry::getObject(Inflector::underscore($fieldNames[$tabl['name']]['modelKey']));
|
|
|
|
|
|
|
|
if (is_object($otherModel)) {
|
|
|
|
|
|
|
|
if ($doCreateOptions) {
|
|
|
|
$otherDisplayField = $otherModel->getDisplayField();
|
|
|
|
$otherModel->recursive = 0;
|
|
|
|
$rec = $otherModel->findAll();
|
|
|
|
|
|
|
|
foreach($rec as $pass) {
|
|
|
|
foreach($pass as $key => $value) {
|
2006-07-29 17:28:13 +00:00
|
|
|
if ($key == $this->{$model}->tableToModel[$fieldNames[$tabl['name']]['table']] && isset($value[$otherModel->primaryKey]) && isset($value[$otherDisplayField])) {
|
|
|
|
$fieldNames[$tabl['name']]['options'][$value[$otherModel->primaryKey]] = $value[$otherDisplayField];
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-09-14 21:59:51 +00:00
|
|
|
$fieldNames[$tabl['name']]['selected'] = $data[$model][$tabl['name']];
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$fieldNames[$tabl['name']]['type'] = 'input';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "boolean":
|
|
|
|
$fieldNames[$tabl['name']]['type'] = 'checkbox';
|
|
|
|
break;
|
|
|
|
case "integer":
|
|
|
|
case "float":
|
|
|
|
if (strcmp($tabl['name'], $this->$model->primaryKey) == 0) {
|
|
|
|
$fieldNames[$tabl['name']]['type'] = 'hidden';
|
|
|
|
} else if(isset($fieldNames[$tabl['name']]['foreignKey'])) {
|
|
|
|
$fieldNames[$tabl['name']]['type'] = 'select';
|
|
|
|
$fieldNames[$tabl['name']]['options'] = array();
|
|
|
|
$otherModel =& ClassRegistry::getObject(Inflector::underscore($fieldNames[$tabl['name']]['modelKey']));
|
|
|
|
|
|
|
|
if (is_object($otherModel)) {
|
|
|
|
if ($doCreateOptions) {
|
|
|
|
$otherDisplayField = $otherModel->getDisplayField();
|
|
|
|
$otherModel->recursive = 0;
|
|
|
|
$rec = $otherModel->findAll();
|
|
|
|
|
2006-10-18 12:55:19 +00:00
|
|
|
foreach($rec as $pass) {
|
|
|
|
foreach($pass as $key => $value) {
|
|
|
|
if ($key == $this->{$model}->tableToModel[$fieldNames[$tabl['name']]['table']] && isset($value[$otherModel->primaryKey]) && isset($value[$otherDisplayField])) {
|
|
|
|
$fieldNames[$tabl['name']]['options'][$value[$otherModel->primaryKey]] = $value[$otherDisplayField];
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-06-14 18:02:37 +00:00
|
|
|
$fieldNames[$tabl['name']]['selected'] = $data[$model][$tabl['name']];
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$fieldNames[$tabl['name']]['type'] = 'input';
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case "enum":
|
2006-06-14 18:02:37 +00:00
|
|
|
$fieldNames[$tabl['name']]['type'] = 'select';
|
2006-05-26 05:29:17 +00:00
|
|
|
$fieldNames[$tabl['name']]['options'] = array();
|
|
|
|
$enumValues = split(',', $fieldLength);
|
|
|
|
|
|
|
|
foreach($enumValues as $enum) {
|
|
|
|
$enum = trim($enum, "'");
|
|
|
|
$fieldNames[$tabl['name']]['options'][$enum] = $enum;
|
|
|
|
}
|
|
|
|
|
|
|
|
$fieldNames[$tabl['name']]['selected'] = $data[$model][$tabl['name']];
|
|
|
|
break;
|
|
|
|
case "date":
|
|
|
|
case "datetime":
|
2006-07-29 17:28:13 +00:00
|
|
|
case "time":
|
2006-11-01 07:15:44 +00:00
|
|
|
case "year":
|
2006-05-26 05:29:17 +00:00
|
|
|
if (0 != strncmp("created", $tabl['name'], 7) && 0 != strncmp("modified", $tabl['name'], 8)) {
|
|
|
|
$fieldNames[$tabl['name']]['type'] = $type;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($data[$model][$tabl['name']])) {
|
|
|
|
$fieldNames[$tabl['name']]['selected'] = $data[$model][$tabl['name']];
|
|
|
|
} else {
|
|
|
|
$fieldNames[$tabl['name']]['selected'] = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach($objRegistryModel->hasAndBelongsToMany as $relation => $relData) {
|
|
|
|
$modelName = $relData['className'];
|
|
|
|
$manyAssociation = $relation;
|
|
|
|
$modelKeyM = Inflector::underscore($modelName);
|
|
|
|
$modelObject =& new $modelName();
|
|
|
|
|
|
|
|
if ($doCreateOptions) {
|
|
|
|
$otherDisplayField = $modelObject->getDisplayField();
|
|
|
|
$fieldNames[$modelKeyM]['model'] = $modelName;
|
|
|
|
$fieldNames[$modelKeyM]['prompt'] = "Related " . Inflector::humanize(Inflector::pluralize($modelName));
|
|
|
|
$fieldNames[$modelKeyM]['type'] = "selectMultiple";
|
|
|
|
$fieldNames[$modelKeyM]['tagName'] = $manyAssociation . '/' . $manyAssociation;
|
|
|
|
$modelObject->recursive = 0;
|
|
|
|
$rec = $modelObject->findAll();
|
|
|
|
|
|
|
|
foreach($rec as $pass) {
|
|
|
|
foreach($pass as $key => $value) {
|
|
|
|
if ($key == $modelName && isset($value[$modelObject->primaryKey]) && isset($value[$otherDisplayField])) {
|
|
|
|
$fieldNames[$modelKeyM]['options'][$value[$modelObject->primaryKey]] = $value[$otherDisplayField];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($data[$manyAssociation])) {
|
|
|
|
foreach($data[$manyAssociation] as $key => $row) {
|
|
|
|
$fieldNames[$modelKeyM]['selected'][$row[$modelObject->primaryKey]] = $row[$modelObject->primaryKey];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $fieldNames;
|
|
|
|
}
|
2006-03-14 02:26:08 +00:00
|
|
|
/**
|
|
|
|
* Converts POST'ed model data to a model conditions array, suitable for a find
|
|
|
|
* or findAll Model query
|
|
|
|
*
|
|
|
|
* @param array $data POST'ed data organized by model and field
|
2006-06-17 14:10:01 +00:00
|
|
|
* @param mixed $op A string containing an SQL comparison operator, or an array matching operators to fields
|
|
|
|
* @param string $bool SQL boolean operator: AND, OR, XOR, etc.
|
|
|
|
* @param boolean $exclusive If true, and $op is an array, fields not included in $op will not be included in the returned conditions
|
2006-03-14 02:26:08 +00:00
|
|
|
* @return array An array of model conditions
|
|
|
|
*/
|
2006-09-10 17:08:53 +00:00
|
|
|
function postConditions($data = array(), $op = null, $bool = 'AND', $exclusive = false) {
|
2006-08-18 07:53:45 +00:00
|
|
|
if ((!is_array($data) || empty($data)) && empty($this->data)) {
|
2006-05-26 05:29:17 +00:00
|
|
|
return null;
|
2006-08-18 07:53:45 +00:00
|
|
|
} elseif ((!is_array($data) || empty($data)) && !empty($this->data)) {
|
|
|
|
$data = $this->data;
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
2006-08-18 07:53:45 +00:00
|
|
|
|
2006-06-17 14:10:01 +00:00
|
|
|
$cond = array();
|
2006-09-10 17:08:53 +00:00
|
|
|
if ($op === null) {
|
|
|
|
$op = '';
|
|
|
|
}
|
2006-03-14 02:26:08 +00:00
|
|
|
|
2006-05-26 05:29:17 +00:00
|
|
|
foreach($data as $model => $fields) {
|
|
|
|
foreach($fields as $field => $value) {
|
2006-06-17 14:10:01 +00:00
|
|
|
$key = $model . '.' . $field;
|
|
|
|
if (is_string($op)) {
|
|
|
|
$cond[$key] = $this->__postConditionMatch($op, $value);
|
|
|
|
} elseif (is_array($op)) {
|
|
|
|
$opFields = array_keys($op);
|
|
|
|
if (in_array($key, $opFields) || in_array($field, $opFields)) {
|
|
|
|
if (in_array($key, $opFields)) {
|
|
|
|
$cond[$key] = $this->__postConditionMatch($op[$key], $value);
|
|
|
|
} else {
|
|
|
|
$cond[$key] = $this->__postConditionMatch($op[$field], $value);
|
|
|
|
}
|
|
|
|
} elseif (!$exclusive) {
|
|
|
|
$cond[$key] = $this->__postConditionMatch(null, $value);
|
|
|
|
}
|
|
|
|
}
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
}
|
2006-06-17 14:10:01 +00:00
|
|
|
if ($bool != null && up($bool) != 'AND') {
|
|
|
|
$cond = array($bool => $cond);
|
|
|
|
}
|
|
|
|
return $cond;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Private method used by postConditions
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function __postConditionMatch($op, $value) {
|
|
|
|
|
|
|
|
if (is_string($op)) {
|
|
|
|
$op = up(trim($op));
|
|
|
|
}
|
|
|
|
|
|
|
|
switch($op) {
|
|
|
|
case '':
|
|
|
|
case '=':
|
|
|
|
case null:
|
|
|
|
return $value;
|
|
|
|
break;
|
|
|
|
case 'LIKE':
|
|
|
|
return 'LIKE %' . $value . '%';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return $op . ' ' . $value;
|
|
|
|
break;
|
|
|
|
}
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
2006-02-23 11:40:52 +00:00
|
|
|
/**
|
|
|
|
* Cleans up the date fields of current Model.
|
|
|
|
*
|
|
|
|
*/
|
2006-09-20 04:43:28 +00:00
|
|
|
function cleanUpFields($modelClass = null) {
|
|
|
|
if ($modelClass == null) {
|
|
|
|
$modelClass = $this->modelClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach($this->{$modelClass}->_tableInfo as $table) {
|
2006-05-26 05:29:17 +00:00
|
|
|
foreach($table as $field) {
|
|
|
|
|
2006-11-12 00:12:34 +00:00
|
|
|
if ('date' == $field['type'] && isset($this->data[$modelClass][$field['name'] . '_year'])) {
|
|
|
|
$newDate = $this->data[$modelClass][$field['name'] . '_year'] . '-';
|
|
|
|
$newDate .= $this->data[$modelClass][$field['name'] . '_month'] . '-';
|
|
|
|
$newDate .= $this->data[$modelClass][$field['name'] . '_day'];
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_year']);
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_month']);
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_day']);
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_hour']);
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_min']);
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_meridian']);
|
|
|
|
$this->data[$modelClass][$field['name']] = $newDate;
|
2006-09-20 04:43:28 +00:00
|
|
|
$this->data[$modelClass][$field['name']] = $newDate;
|
|
|
|
|
2006-11-12 00:12:34 +00:00
|
|
|
} elseif('datetime' == $field['type'] && isset($this->data[$modelClass][$field['name'] . '_year'])) {
|
|
|
|
$hour = $this->data[$modelClass][$field['name'] . '_hour'];
|
2006-09-20 04:43:28 +00:00
|
|
|
|
2006-11-12 00:12:34 +00:00
|
|
|
if ($hour != 12 && (isset($this->data[$modelClass][$field['name'] . '_meridian']) && 'pm' == $this->data[$modelClass][$field['name'] . '_meridian'])) {
|
2006-05-26 05:29:17 +00:00
|
|
|
$hour = $hour + 12;
|
|
|
|
}
|
|
|
|
|
2006-11-12 00:12:34 +00:00
|
|
|
$newDate = $this->data[$modelClass][$field['name'] . '_year'] . '-';
|
|
|
|
$newDate .= $this->data[$modelClass][$field['name'] . '_month'] . '-';
|
|
|
|
$newDate .= $this->data[$modelClass][$field['name'] . '_day'] . ' ';
|
|
|
|
$newDate .= $hour . ':' . $this->data[$modelClass][$field['name'] . '_min'] . ':00';
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_year']);
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_month']);
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_day']);
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_hour']);
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_min']);
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_meridian']);
|
|
|
|
$this->data[$modelClass][$field['name']] = $newDate;
|
2006-09-20 04:43:28 +00:00
|
|
|
$this->data[$modelClass][$field['name']] = $newDate;
|
|
|
|
|
2006-11-12 00:12:34 +00:00
|
|
|
} elseif('time' == $field['type'] && isset($this->data[$modelClass][$field['name'] . '_hour'])) {
|
|
|
|
$hour = $this->data[$modelClass][$field['name'] . '_hour'];
|
2006-09-20 04:43:28 +00:00
|
|
|
|
2006-11-12 00:12:34 +00:00
|
|
|
if ($hour != 12 && (isset($this->data[$modelClass][$field['name'] . '_meridian']) && 'pm' == $this->data[$modelClass][$field['name'] . '_meridian'])) {
|
2006-07-29 17:28:13 +00:00
|
|
|
$hour = $hour + 12;
|
|
|
|
}
|
|
|
|
|
2006-11-12 00:12:34 +00:00
|
|
|
$newDate = $hour . ':' . $this->data[$modelClass][$field['name'] . '_min'] . ':00';
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_hour']);
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_min']);
|
|
|
|
unset($this->data[$modelClass][$field['name'] . '_meridian']);
|
|
|
|
$this->data[$modelClass][$field['name']] = $newDate;
|
2006-09-20 04:43:28 +00:00
|
|
|
$this->data[$modelClass][$field['name']] = $newDate;
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-08-08 17:33:57 +00:00
|
|
|
/**
|
|
|
|
* Handles automatic pagination of model records
|
|
|
|
*
|
|
|
|
* @param mixed $object
|
2006-09-28 20:29:04 +00:00
|
|
|
* @param mixed $scope
|
2006-08-08 17:33:57 +00:00
|
|
|
* @param array $whitelist
|
|
|
|
* @return array Model query results
|
|
|
|
*/
|
2006-09-28 20:29:04 +00:00
|
|
|
function paginate($object = null, $scope = array(), $whitelist = array()) {
|
2006-08-08 17:33:57 +00:00
|
|
|
|
2006-09-28 20:29:04 +00:00
|
|
|
if (is_array($object)) {
|
|
|
|
$whitelist = $scope;
|
|
|
|
$scope = $object;
|
|
|
|
$object = null;
|
2006-08-08 17:33:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_string($object)) {
|
2006-09-28 20:29:04 +00:00
|
|
|
if (isset($this->{$object})) {
|
2006-08-08 17:33:57 +00:00
|
|
|
$object = $this->{$object};
|
2006-09-28 20:29:04 +00:00
|
|
|
} elseif (isset($this->{$this->modelClass}) && isset($this->{$this->modelClass}->{$object})) {
|
2006-08-08 17:33:57 +00:00
|
|
|
$object = $this->{$this->modelClass}->{$object};
|
|
|
|
} elseif (!empty($this->uses)) {
|
|
|
|
for ($i = 0; $i < count($this->uses); $i++) {
|
|
|
|
$model = $this->uses[$i];
|
2006-09-28 20:29:04 +00:00
|
|
|
if (isset($this->{$model}->{$object})) {
|
2006-08-08 17:33:57 +00:00
|
|
|
$object = $this->{$model}->{$object};
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} elseif (empty($object) || $object == null) {
|
2006-09-28 20:29:04 +00:00
|
|
|
if (isset($this->{$this->modelClass})) {
|
2006-08-08 17:33:57 +00:00
|
|
|
$object = $this->{$this->modelClass};
|
2006-09-28 20:29:04 +00:00
|
|
|
} else {
|
|
|
|
$object = $this->{$this->uses[0]};
|
2006-08-08 17:33:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-28 20:29:04 +00:00
|
|
|
if (!is_object($object)) {
|
|
|
|
// Error: can't find object
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2006-09-29 01:30:09 +00:00
|
|
|
$options = am($this->params, $this->params['url'], $this->passedArgs);
|
2006-09-28 20:29:04 +00:00
|
|
|
if (isset($this->pagination[$object->name])) {
|
2006-08-08 17:33:57 +00:00
|
|
|
$defaults = $this->paginate[$object->name];
|
|
|
|
} else {
|
|
|
|
$defaults = $this->paginate;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($options['show'])) {
|
|
|
|
$options['limit'] = $options['show'];
|
|
|
|
}
|
2006-09-28 20:29:04 +00:00
|
|
|
|
2006-08-10 03:55:51 +00:00
|
|
|
if (isset($options['sort']) && isset($options['direction'])) {
|
|
|
|
$options['order'] = array($options['sort'] => $options['direction']);
|
2006-08-08 17:33:57 +00:00
|
|
|
} elseif (isset($options['sort'])) {
|
|
|
|
$options['order'] = $options['sort'];
|
|
|
|
}
|
|
|
|
|
2006-09-28 20:29:04 +00:00
|
|
|
$vars = array('fields', 'order', 'limit', 'page', 'recursive');
|
2006-08-08 17:33:57 +00:00
|
|
|
$keys = array_keys($options);
|
|
|
|
$count = count($keys);
|
2006-09-28 20:29:04 +00:00
|
|
|
|
2006-08-08 17:33:57 +00:00
|
|
|
for($i = 0; $i < $count; $i++) {
|
|
|
|
if (!in_array($keys[$i], $vars)) {
|
|
|
|
unset($options[$keys[$i]]);
|
|
|
|
}
|
2006-09-28 20:29:04 +00:00
|
|
|
if (empty($whitelist) && ($keys[$i] == 'fields' || $keys[$i] == 'recursive')) {
|
|
|
|
unset($options[$keys[$i]]);
|
|
|
|
} elseif (!empty($whitelist) && !in_array($keys[$i], $whitelist)) {
|
|
|
|
unset($options[$keys[$i]]);
|
2006-08-08 17:33:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$conditions = $fields = $order = $limit = $page = $recursive = null;
|
|
|
|
$options = am($defaults, $options);
|
2006-09-28 20:29:04 +00:00
|
|
|
if (isset($this->paginate[$object->name])) {
|
|
|
|
$defaults = $this->paginate[$object->name];
|
|
|
|
} else {
|
|
|
|
$defaults = $this->paginate;
|
|
|
|
}
|
|
|
|
if (!isset($defaults['conditions'])) {
|
|
|
|
$defaults['conditions'] = array();
|
2006-08-10 03:55:51 +00:00
|
|
|
}
|
|
|
|
|
2006-11-08 03:28:24 +00:00
|
|
|
extract(am(array('page' => 1, 'limit' => 20), $defaults, $options));
|
2006-09-28 20:29:04 +00:00
|
|
|
if ((is_array($scope) || is_string($scope)) && !empty($scope)) {
|
|
|
|
$conditions = array($conditions, $scope);
|
|
|
|
}
|
2006-08-08 17:33:57 +00:00
|
|
|
$results = $object->findAll($conditions, $fields, $order, $limit, $page, $recursive);
|
2006-09-28 20:29:04 +00:00
|
|
|
|
|
|
|
$count = $object->findCount($conditions);
|
|
|
|
$paging = array(
|
|
|
|
'current' => count($results),
|
|
|
|
'count' => $count,
|
|
|
|
'prevPage' => ($page > 1),
|
|
|
|
'nextPage' => ($count > ($page * $limit)),
|
|
|
|
'pageCount' => ceil($count / $limit),
|
|
|
|
'defaults' => $defaults,
|
|
|
|
'options' => $options
|
|
|
|
);
|
|
|
|
$this->params['paging'][$object->name] = $paging;
|
|
|
|
|
|
|
|
if (!in_array('Paginator', $this->helpers)) {
|
|
|
|
$this->helpers[] = 'Paginator';
|
|
|
|
}
|
2006-08-08 17:33:57 +00:00
|
|
|
|
|
|
|
return $results;
|
|
|
|
}
|
2006-02-02 11:48:29 +00:00
|
|
|
/**
|
|
|
|
* Called before the controller action. Overridden in subclasses.
|
|
|
|
*
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function beforeFilter() {
|
|
|
|
}
|
2006-02-02 11:48:29 +00:00
|
|
|
/**
|
|
|
|
* Called after the controller action is run, but before the view is rendered. Overridden in subclasses.
|
|
|
|
*
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function beforeRender() {
|
|
|
|
}
|
2006-02-02 11:48:29 +00:00
|
|
|
/**
|
|
|
|
* Called after the controller action is run and rendered. Overridden in subclasses.
|
|
|
|
*
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function afterFilter() {
|
|
|
|
}
|
2006-02-23 11:40:52 +00:00
|
|
|
/**
|
|
|
|
* This method should be overridden in child classes.
|
|
|
|
*
|
|
|
|
* @param string $method name of method called example index, edit, etc.
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function _beforeScaffold($method) {
|
|
|
|
return true;
|
|
|
|
}
|
2006-03-01 19:13:48 +00:00
|
|
|
/**
|
|
|
|
* This method should be overridden in child classes.
|
|
|
|
*
|
|
|
|
* @param string $method name of method called either edit or update.
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function _afterScaffoldSave($method) {
|
|
|
|
return true;
|
|
|
|
}
|
2006-03-01 19:13:48 +00:00
|
|
|
/**
|
|
|
|
* This method should be overridden in child classes.
|
|
|
|
*
|
|
|
|
* @param string $method name of method called either edit or update.
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function _afterScaffoldSaveError($method) {
|
|
|
|
return true;
|
|
|
|
}
|
2006-02-23 11:40:52 +00:00
|
|
|
/**
|
|
|
|
* This method should be overridden in child classes.
|
|
|
|
* If not it will render a scaffold error.
|
|
|
|
* Method MUST return true in child classes
|
|
|
|
*
|
|
|
|
* @param string $method name of method called example index, edit, etc.
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function _scaffoldError($method) {
|
|
|
|
return false;
|
|
|
|
}
|
2006-10-26 03:08:53 +00:00
|
|
|
/**
|
|
|
|
* Enter description here...
|
|
|
|
*
|
|
|
|
* @param unknown_type $data
|
|
|
|
* @param unknown_type $key
|
|
|
|
* @return unknown
|
|
|
|
*/
|
|
|
|
function _selectedArray($data, $key = 'id') {
|
|
|
|
$array = array();
|
|
|
|
if(!empty($data)) {
|
|
|
|
foreach($data as $var) {
|
|
|
|
$array[$var[$key]] = $var[$key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $array;
|
|
|
|
}
|
2006-01-12 02:10:47 +00:00
|
|
|
}
|
2006-06-14 18:02:37 +00:00
|
|
|
|
2006-05-26 05:29:17 +00:00
|
|
|
?>
|