mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge remote branch 'origin/1.3' into 2.0
Conflicts: cake/console/libs/shell.php cake/libs/controller/components/acl.php cake/libs/controller/components/auth.php cake/libs/controller/components/email.php cake/libs/controller/components/security.php cake/libs/controller/components/session.php cake/libs/view/helper.php cake/libs/view/helpers/form.php cake/libs/view/helpers/html.php cake/libs/view/helpers/number.php cake/libs/view/helpers/session.php cake/libs/view/helpers/text.php cake/libs/view/helpers/time.php cake/libs/view/helpers/xml.php
This commit is contained in:
commit
e4d292bfa4
27 changed files with 358 additions and 16 deletions
|
@ -607,7 +607,7 @@ class Shell extends Object {
|
|||
* @return string Plural human name
|
||||
*/
|
||||
protected function _pluralHumanName($name) {
|
||||
return Inflector::humanize(Inflector::underscore(Inflector::pluralize($name)));
|
||||
return Inflector::humanize(Inflector::underscore($name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.controller.components
|
||||
* @link http://book.cakephp.org/view/1242/Access-Control-Lists
|
||||
*/
|
||||
class AclComponent extends Object {
|
||||
|
||||
|
@ -245,6 +246,7 @@ class DbAcl extends AclBase {
|
|||
* @param string $aco ACO The controlled object identifier.
|
||||
* @param string $action Action (defaults to *)
|
||||
* @return boolean Success (true if ARO has access to action in ACO, false otherwise)
|
||||
* @link http://book.cakephp.org/view/1249/Checking-Permissions-The-ACL-Component
|
||||
*/
|
||||
public function check($aro, $aco, $action = "*") {
|
||||
if ($aro == null || $aco == null) {
|
||||
|
@ -335,6 +337,7 @@ class DbAcl extends AclBase {
|
|||
* @param string $actions Action (defaults to *)
|
||||
* @param integer $value Value to indicate access type (1 to give access, -1 to deny, 0 to inherit)
|
||||
* @return boolean Success
|
||||
* @link http://book.cakephp.org/view/1248/Assigning-Permissions
|
||||
*/
|
||||
public function allow($aro, $aco, $actions = "*", $value = 1) {
|
||||
$perms = $this->getAclLink($aro, $aco);
|
||||
|
@ -385,6 +388,7 @@ class DbAcl extends AclBase {
|
|||
* @param string $aco ACO The controlled object identifier.
|
||||
* @param string $actions Action (defaults to *)
|
||||
* @return boolean Success
|
||||
* @link http://book.cakephp.org/view/1248/Assigning-Permissions
|
||||
*/
|
||||
public function deny($aro, $aco, $action = "*") {
|
||||
return $this->allow($aro, $aco, $action, -1);
|
||||
|
|
|
@ -29,6 +29,7 @@ App::import('Core', array('Router', 'Security'), false);
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.controller.components
|
||||
* @link http://book.cakephp.org/view/1250/Authentication
|
||||
*/
|
||||
class AuthComponent extends Object {
|
||||
|
||||
|
@ -53,6 +54,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @var object
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1278/authenticate
|
||||
*/
|
||||
public $authenticate = null;
|
||||
|
||||
|
@ -66,6 +68,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @var mixed
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1275/authorize
|
||||
*/
|
||||
public $authorize = false;
|
||||
|
||||
|
@ -75,6 +78,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @var string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1277/ajaxLogin
|
||||
*/
|
||||
public $ajaxLogin = null;
|
||||
|
||||
|
@ -91,6 +95,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @var string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1266/userModel
|
||||
*/
|
||||
public $userModel = 'User';
|
||||
|
||||
|
@ -100,6 +105,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @var array
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1268/userScope
|
||||
*/
|
||||
public $userScope = array();
|
||||
|
||||
|
@ -109,6 +115,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @var array
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1267/fields
|
||||
*/
|
||||
public $fields = array('username' => 'username', 'password' => 'password');
|
||||
|
||||
|
@ -118,6 +125,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @var string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1276/sessionKey
|
||||
*/
|
||||
public $sessionKey = null;
|
||||
|
||||
|
@ -129,6 +137,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @var string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1279/actionPath
|
||||
*/
|
||||
public $actionPath = null;
|
||||
|
||||
|
@ -138,6 +147,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @var mixed
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1269/loginAction
|
||||
*/
|
||||
public $loginAction = null;
|
||||
|
||||
|
@ -149,6 +159,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @var mixed
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1270/loginRedirect
|
||||
*/
|
||||
public $loginRedirect = null;
|
||||
|
||||
|
@ -161,6 +172,7 @@ class AuthComponent extends Object {
|
|||
* @access public
|
||||
* @see AuthComponent::$loginAction
|
||||
* @see AuthComponent::logout()
|
||||
* @link http://book.cakephp.org/view/1271/logoutRedirect
|
||||
*/
|
||||
public $logoutRedirect = null;
|
||||
|
||||
|
@ -178,6 +190,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @var string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1272/loginError
|
||||
*/
|
||||
public $loginError = null;
|
||||
|
||||
|
@ -187,6 +200,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @var string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1273/authError
|
||||
*/
|
||||
public $authError = null;
|
||||
|
||||
|
@ -195,6 +209,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @var boolean
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1274/autoRedirect
|
||||
*/
|
||||
public $autoRedirect = true;
|
||||
|
||||
|
@ -204,6 +219,7 @@ class AuthComponent extends Object {
|
|||
* @var array
|
||||
* @access public
|
||||
* @see AuthComponent::allow()
|
||||
* @link http://book.cakephp.org/view/1251/Setting-Auth-Component-Variables
|
||||
*/
|
||||
public $allowedActions = array();
|
||||
|
||||
|
@ -586,6 +602,7 @@ class AuthComponent extends Object {
|
|||
* @param string $action Controller action name
|
||||
* @param string ... etc.
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/view/1257/allow
|
||||
*/
|
||||
public function allow() {
|
||||
$args = func_get_args();
|
||||
|
@ -607,6 +624,7 @@ class AuthComponent extends Object {
|
|||
* @param string ... etc.
|
||||
* @return void
|
||||
* @see AuthComponent::allow()
|
||||
* @link http://book.cakephp.org/view/1258/deny
|
||||
*/
|
||||
public function deny() {
|
||||
$args = func_get_args();
|
||||
|
@ -627,6 +645,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @param array $map Actions to map
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/view/1260/mapActions
|
||||
*/
|
||||
public function mapActions($map = array()) {
|
||||
$crud = array('create', 'read', 'update', 'delete');
|
||||
|
@ -651,6 +670,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @param mixed $data User object
|
||||
* @return boolean True on login success, false on failure
|
||||
* @link http://book.cakephp.org/view/1261/login
|
||||
*/
|
||||
public function login($data = null) {
|
||||
$this->__setDefaults();
|
||||
|
@ -673,6 +693,7 @@ class AuthComponent extends Object {
|
|||
* @param mixed $url Optional URL to redirect the user to after logout
|
||||
* @return string AuthComponent::$loginAction
|
||||
* @see AuthComponent::$loginAction
|
||||
* @link http://book.cakephp.org/view/1262/logout
|
||||
*/
|
||||
public function logout() {
|
||||
$this->__setDefaults();
|
||||
|
@ -687,6 +708,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @param string $key field to retrive. Leave null to get entire User record
|
||||
* @return mixed User record. or null if no user is logged in.
|
||||
* @link http://book.cakephp.org/view/1264/user
|
||||
*/
|
||||
public function user($key = null) {
|
||||
$this->__setDefaults();
|
||||
|
@ -758,6 +780,7 @@ class AuthComponent extends Object {
|
|||
* user against. The current request action is used if
|
||||
* none is specified.
|
||||
* @return boolean ACO node path
|
||||
* @link http://book.cakephp.org/view/1256/action
|
||||
*/
|
||||
public function action($action = ':plugin/:controller/:action') {
|
||||
$plugin = empty($this->params['plugin']) ? null : Inflector::camelize($this->params['plugin']) . '/';
|
||||
|
@ -877,6 +900,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @param array $data Set of data to look for passwords
|
||||
* @return array Data with passwords hashed
|
||||
* @link http://book.cakephp.org/view/1259/hashPasswords
|
||||
*/
|
||||
public function hashPasswords($data) {
|
||||
if (is_object($this->authenticate) && method_exists($this->authenticate, 'hashPasswords')) {
|
||||
|
@ -897,6 +921,7 @@ class AuthComponent extends Object {
|
|||
*
|
||||
* @param string $password Password to hash
|
||||
* @return string Hashed password
|
||||
* @link http://book.cakephp.org/view/1263/password
|
||||
*/
|
||||
public function password($password) {
|
||||
return Security::hash($password, null, true);
|
||||
|
|
|
@ -30,6 +30,7 @@ App::import('Core', 'Security');
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.controller.components
|
||||
* @link http://book.cakephp.org/view/1280/Cookies
|
||||
*
|
||||
*/
|
||||
class CookieComponent extends Object {
|
||||
|
|
|
@ -27,6 +27,7 @@ App::import('Core', 'Multibyte');
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.controller.components
|
||||
* @link http://book.cakephp.org/view/1283/Email
|
||||
*
|
||||
*/
|
||||
class EmailComponent extends Object{
|
||||
|
@ -225,6 +226,7 @@ class EmailComponent extends Object{
|
|||
*
|
||||
* @var array
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1290/Sending-A-Message-Using-SMTP
|
||||
*/
|
||||
public $smtpOptions = array(
|
||||
'port'=> 25, 'host' => 'localhost', 'timeout' => 30
|
||||
|
@ -386,6 +388,7 @@ class EmailComponent extends Object{
|
|||
/**
|
||||
* Reset all EmailComponent internal variables to be able to send out a new email.
|
||||
*
|
||||
* @link http://book.cakephp.org/view/1285/Sending-Multiple-Emails-in-a-loop
|
||||
*/
|
||||
public function reset() {
|
||||
$this->template = null;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.controller.components
|
||||
* @link http://book.cakephp.org/view/1291/Request-Handling
|
||||
*
|
||||
*/
|
||||
class RequestHandlerComponent extends Object {
|
||||
|
|
|
@ -23,6 +23,7 @@ App::import('Core', array('String', 'Security'));
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.controller.components
|
||||
* @link http://book.cakephp.org/view/1296/Security-Component
|
||||
*/
|
||||
class SecurityComponent extends Object {
|
||||
|
||||
|
@ -212,6 +213,7 @@ class SecurityComponent extends Object {
|
|||
* Sets the actions that require a POST request, or empty for all actions
|
||||
*
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/view/1299/requirePost
|
||||
*/
|
||||
public function requirePost() {
|
||||
$args = func_get_args();
|
||||
|
@ -252,6 +254,7 @@ class SecurityComponent extends Object {
|
|||
* Sets the actions that require a request that is SSL-secured, or empty for all actions
|
||||
*
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/view/1300/requireSecure
|
||||
*/
|
||||
public function requireSecure() {
|
||||
$args = func_get_args();
|
||||
|
@ -262,6 +265,7 @@ class SecurityComponent extends Object {
|
|||
* Sets the actions that require an authenticated request, or empty for all actions
|
||||
*
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/view/1301/requireAuth
|
||||
*/
|
||||
public function requireAuth() {
|
||||
$args = func_get_args();
|
||||
|
@ -272,6 +276,7 @@ class SecurityComponent extends Object {
|
|||
* Sets the actions that require an HTTP-authenticated request, or empty for all actions
|
||||
*
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/view/1302/requireLogin
|
||||
*/
|
||||
public function requireLogin() {
|
||||
$args = func_get_args();
|
||||
|
@ -296,6 +301,7 @@ class SecurityComponent extends Object {
|
|||
*
|
||||
* @param string $type Either 'basic', 'digest', or null. If null/empty, will try both.
|
||||
* @return mixed If successful, returns an array with login name and password, otherwise null.
|
||||
* @link http://book.cakephp.org/view/1303/loginCredentials-string-type
|
||||
*/
|
||||
public function loginCredentials($type = null) {
|
||||
switch (strtolower($type)) {
|
||||
|
@ -334,6 +340,7 @@ class SecurityComponent extends Object {
|
|||
*
|
||||
* @param array $options Set of options for header
|
||||
* @return string HTTP-authentication request header
|
||||
* @link http://book.cakephp.org/view/1304/loginRequest-array-options
|
||||
*/
|
||||
public function loginRequest($options = array()) {
|
||||
$options = array_merge($this->loginOptions, $options);
|
||||
|
@ -355,6 +362,7 @@ class SecurityComponent extends Object {
|
|||
*
|
||||
* @param string $digest Digest authentication response
|
||||
* @return array Digest authentication parameters
|
||||
* @link http://book.cakephp.org/view/1305/parseDigestAuthData-string-digest
|
||||
*/
|
||||
public function parseDigestAuthData($digest) {
|
||||
if (substr($digest, 0, 7) == 'Digest ') {
|
||||
|
@ -383,6 +391,7 @@ class SecurityComponent extends Object {
|
|||
* @return string Digest authentication hash
|
||||
* @access public
|
||||
* @see SecurityComponent::parseDigestAuthData()
|
||||
* @link http://book.cakephp.org/view/1306/generateDigestResponseHash-array-data
|
||||
*/
|
||||
function generateDigestResponseHash($data) {
|
||||
return md5(
|
||||
|
@ -401,6 +410,7 @@ class SecurityComponent extends Object {
|
|||
* @return mixed If specified, controller blackHoleCallback's response, or no return otherwise
|
||||
* @access public
|
||||
* @see SecurityComponent::$blackHoleCallback
|
||||
* @link http://book.cakephp.org/view/1307/blackHole-object-controller-string-error
|
||||
*/
|
||||
function blackHole(&$controller, $error = '') {
|
||||
if ($this->blackHoleCallback == null) {
|
||||
|
|
|
@ -28,6 +28,7 @@ if (!class_exists('cakesession')) {
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.controller.components
|
||||
* @link http://book.cakephp.org/view/1310/Sessions
|
||||
*
|
||||
*/
|
||||
class SessionComponent extends CakeSession {
|
||||
|
@ -96,6 +97,7 @@ class SessionComponent extends CakeSession {
|
|||
* This should be in a Controller.key format for better organizing
|
||||
* @param string $value The value you want to store in a session.
|
||||
* @return boolean Success
|
||||
* @link http://book.cakephp.org/view/1312/write
|
||||
*/
|
||||
public function write($name, $value = null) {
|
||||
if ($this->__active === true) {
|
||||
|
@ -124,6 +126,7 @@ class SessionComponent extends CakeSession {
|
|||
*
|
||||
* @param string $name the name of the session key you want to read
|
||||
* @return mixed value from the session vars
|
||||
* @link http://book.cakephp.org/view/1314/read
|
||||
*/
|
||||
public function read($name = null) {
|
||||
if ($this->__active === true) {
|
||||
|
@ -140,6 +143,7 @@ class SessionComponent extends CakeSession {
|
|||
*
|
||||
* @param string $name the name of the session key you want to delete
|
||||
* @return boolean true is session variable is set and can be deleted, false is variable was not set.
|
||||
* @link http://book.cakephp.org/view/1316/delete
|
||||
*/
|
||||
public function delete($name) {
|
||||
if ($this->__active === true) {
|
||||
|
@ -156,6 +160,7 @@ class SessionComponent extends CakeSession {
|
|||
*
|
||||
* @param string $name the name of the session key you want to check
|
||||
* @return boolean true is session variable is set, false if not
|
||||
* @link http://book.cakephp.org/view/1315/check
|
||||
*/
|
||||
public function check($name) {
|
||||
if ($this->__active === true) {
|
||||
|
@ -171,6 +176,7 @@ class SessionComponent extends CakeSession {
|
|||
* In your controller: $this->Session->error();
|
||||
*
|
||||
* @return string Last session error
|
||||
* @link http://book.cakephp.org/view/1318/error
|
||||
*/
|
||||
public function error() {
|
||||
if ($this->__active === true) {
|
||||
|
@ -191,6 +197,7 @@ class SessionComponent extends CakeSession {
|
|||
* @param string $element Element 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'
|
||||
* @link http://book.cakephp.org/view/1313/setFlash
|
||||
*/
|
||||
public function setFlash($message, $element = 'default', $params = array(), $key = 'flash') {
|
||||
if ($this->__active === true) {
|
||||
|
@ -234,6 +241,7 @@ class SessionComponent extends CakeSession {
|
|||
* In your controller: $this->Session->destroy();
|
||||
*
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/view/1317/destroy
|
||||
*/
|
||||
public function destroy() {
|
||||
if ($this->__active === true) {
|
||||
|
|
|
@ -181,11 +181,13 @@ class ContainableBehavior extends ModelBehavior {
|
|||
}
|
||||
|
||||
$query['fields'] = (array)$query['fields'];
|
||||
if (!empty($Model->belongsTo)) {
|
||||
foreach ($Model->belongsTo as $assoc => $data) {
|
||||
if (!empty($data['fields'])) {
|
||||
foreach ((array) $data['fields'] as $field) {
|
||||
$query['fields'][] = (strpos($field, '.') === false ? $assoc . '.' : '') . $field;
|
||||
foreach (array('hasOne', 'belongsTo') as $type) {
|
||||
if (!empty($Model->{$type})) {
|
||||
foreach ($Model->{$type} as $assoc => $data) {
|
||||
if (!empty($data['fields'])) {
|
||||
foreach ((array) $data['fields'] as $field) {
|
||||
$query['fields'][] = (strpos($field, '.') === false ? $assoc . '.' : '') . $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1906,6 +1906,7 @@ class DboSource extends DataSource {
|
|||
$fields = String::tokenize($fields);
|
||||
}
|
||||
$fields = array_values(array_filter($fields));
|
||||
$allFields = $allFields || in_array('*', $fields) || in_array($model->alias . '.*', $fields);
|
||||
|
||||
$virtual = array();
|
||||
$virtualFields = $model->getVirtualField();
|
||||
|
|
|
@ -180,6 +180,7 @@ class Helper {
|
|||
* the reverse routing features of CakePHP.
|
||||
* @param boolean $full If true, the full base URL will be prepended to the result
|
||||
* @return string Full translated URL with base path.
|
||||
* @link http://book.cakephp.org/view/1448/url
|
||||
*/
|
||||
public function url($url = null, $full = false) {
|
||||
return h(Router::url($url, $full));
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @link http://book.cakephp.org/view/1358/AJAX
|
||||
*/
|
||||
class AjaxHelper extends AppHelper {
|
||||
|
||||
|
@ -207,6 +208,7 @@ class AjaxHelper extends AppHelper {
|
|||
* @param string $confirm Confirmation message. Calls up a JavaScript confirm() message.
|
||||
*
|
||||
* @return string HTML code for link to remote action
|
||||
* @link http://book.cakephp.org/view/1363/link
|
||||
*/
|
||||
function link($title, $url = null, $options = array(), $confirm = null) {
|
||||
if (!isset($url)) {
|
||||
|
@ -250,6 +252,7 @@ class AjaxHelper extends AppHelper {
|
|||
* @param array $options options for javascript
|
||||
* @return string html code for link to remote action
|
||||
* @see AjaxHelper::link() for docs on options parameter.
|
||||
* @link http://book.cakephp.org/view/1364/remoteFunction
|
||||
*/
|
||||
function remoteFunction($options) {
|
||||
if (isset($options['update'])) {
|
||||
|
@ -307,6 +310,7 @@ class AjaxHelper extends AppHelper {
|
|||
* @param array $options Callback options
|
||||
* @return string Javascript code
|
||||
* @see AjaxHelper::link()
|
||||
* @link http://book.cakephp.org/view/1365/remoteTimer
|
||||
*/
|
||||
function remoteTimer($options = null) {
|
||||
$frequency = (isset($options['frequency'])) ? $options['frequency'] : 10;
|
||||
|
@ -333,6 +337,7 @@ class AjaxHelper extends AppHelper {
|
|||
* @param array $options Callback/HTML options
|
||||
* @return string JavaScript/HTML code
|
||||
* @see AjaxHelper::link()
|
||||
* @link http://book.cakephp.org/view/1366/form
|
||||
*/
|
||||
function form($params = null, $type = 'post', $options = array()) {
|
||||
$model = false;
|
||||
|
@ -372,6 +377,7 @@ class AjaxHelper extends AppHelper {
|
|||
* @param array $options Callback options
|
||||
* @return string Ajaxed input button
|
||||
* @see AjaxHelper::form()
|
||||
* @link http://book.cakephp.org/view/1367/submit
|
||||
*/
|
||||
function submit($title = 'Submit', $options = array()) {
|
||||
$htmlOptions = $this->__getHtmlOptions($options);
|
||||
|
@ -419,6 +425,7 @@ class AjaxHelper extends AppHelper {
|
|||
* @param string $field DOM ID of field to observe
|
||||
* @param array $options ajax options
|
||||
* @return string ajax script
|
||||
* @link http://book.cakephp.org/view/1368/observeField
|
||||
*/
|
||||
function observeField($field, $options = array()) {
|
||||
if (!isset($options['with'])) {
|
||||
|
@ -444,6 +451,7 @@ class AjaxHelper extends AppHelper {
|
|||
* @param string $form DOM ID of form to observe
|
||||
* @param array $options ajax options
|
||||
* @return string ajax script
|
||||
* @link http://book.cakephp.org/view/1369/observeForm
|
||||
*/
|
||||
function observeForm($form, $options = array()) {
|
||||
if (!isset($options['with'])) {
|
||||
|
@ -470,6 +478,7 @@ class AjaxHelper extends AppHelper {
|
|||
* @param string $url URL for the autocomplete action
|
||||
* @param array $options Ajax options
|
||||
* @return string Ajax script
|
||||
* @link http://book.cakephp.org/view/1370/autoComplete
|
||||
*/
|
||||
function autoComplete($field, $url = "", $options = array()) {
|
||||
$var = '';
|
||||
|
@ -562,6 +571,7 @@ class AjaxHelper extends AppHelper {
|
|||
* Detects Ajax requests
|
||||
*
|
||||
* @return boolean True if the current request is a Prototype Ajax update call
|
||||
* @link http://book.cakephp.org/view/1371/isAjax
|
||||
*/
|
||||
function isAjax() {
|
||||
return (isset($this->params['isAjax']) && $this->params['isAjax'] === true);
|
||||
|
@ -574,6 +584,7 @@ class AjaxHelper extends AppHelper {
|
|||
* @param unknown_type $id
|
||||
* @param array $options
|
||||
* @return unknown
|
||||
* @link http://book.cakephp.org/view/1372/drag-drop
|
||||
*/
|
||||
function drag($id, $options = array()) {
|
||||
$var = '';
|
||||
|
@ -594,6 +605,7 @@ class AjaxHelper extends AppHelper {
|
|||
* @param unknown_type $id
|
||||
* @param array $options
|
||||
* @return string
|
||||
* @link http://book.cakephp.org/view/1372/drag-drop
|
||||
*/
|
||||
function drop($id, $options = array()) {
|
||||
$optionsString = array('overlap', 'hoverclass');
|
||||
|
@ -645,6 +657,7 @@ class AjaxHelper extends AppHelper {
|
|||
* @param string $trackId DOM ID of slider track
|
||||
* @param array $options Array of options to control the slider
|
||||
* @link http://github.com/madrobby/scriptaculous/wikis/slider
|
||||
* @link http://book.cakephp.org/view/1373/slider
|
||||
*/
|
||||
function slider($id, $trackId, $options = array()) {
|
||||
if (isset($options['var'])) {
|
||||
|
@ -683,6 +696,7 @@ class AjaxHelper extends AppHelper {
|
|||
* @param string $url Postback URL of saved data
|
||||
* @param array $options Array of options to control the editor, including ajaxOptions (see link).
|
||||
* @link http://github.com/madrobby/scriptaculous/wikis/ajax-inplaceeditor
|
||||
* @link http://book.cakephp.org/view/1374/editor
|
||||
*/
|
||||
function editor($id, $url, $options = array()) {
|
||||
$url = $this->url($url);
|
||||
|
@ -726,6 +740,7 @@ class AjaxHelper extends AppHelper {
|
|||
* @param string $id DOM ID of parent
|
||||
* @param array $options Array of options to control sort.
|
||||
* @link http://github.com/madrobby/scriptaculous/wikis/sortable
|
||||
* @link http://book.cakephp.org/view/1375/sortable
|
||||
*/
|
||||
function sortable($id, $options = array()) {
|
||||
if (!empty($options['url'])) {
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @link http://book.cakephp.org/view/1376/Cache
|
||||
*/
|
||||
class CacheHelper extends AppHelper {
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @link http://book.cakephp.org/view/1383/Form
|
||||
*/
|
||||
class FormHelper extends AppHelper {
|
||||
|
||||
|
@ -182,6 +183,7 @@ class FormHelper extends AppHelper {
|
|||
* @param string $model The model object which the form is being defined for
|
||||
* @param array $options An array of html attributes and options.
|
||||
* @return string An formatted opening FORM tag.
|
||||
* @link http://book.cakephp.org/view/1384/Creating-Forms
|
||||
*/
|
||||
function create($model = null, $options = array()) {
|
||||
$created = $id = false;
|
||||
|
@ -334,6 +336,8 @@ class FormHelper extends AppHelper {
|
|||
*
|
||||
* @param mixed $options as a string will use $options as the value of button,
|
||||
* @return string a closing FORM tag optional submit button.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1389/Closing-the-Form
|
||||
*/
|
||||
public function end($options = null) {
|
||||
if (!empty($this->params['models'])) {
|
||||
|
@ -443,6 +447,8 @@ class FormHelper extends AppHelper {
|
|||
*
|
||||
* @param string $field This should be "Modelname.fieldname"
|
||||
* @return boolean If there are errors this method returns true, else false.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1426/isFieldError
|
||||
*/
|
||||
public function isFieldError($field) {
|
||||
$this->setEntity($field);
|
||||
|
@ -463,6 +469,8 @@ class FormHelper extends AppHelper {
|
|||
* @param mixed $text Error message or array of $options
|
||||
* @param array $options Rendering options for <div /> wrapper tag
|
||||
* @return string If there are errors this method returns an error message, otherwise null.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1423/error
|
||||
*/
|
||||
public function error($field, $text = null, $options = array()) {
|
||||
$defaults = array('wrap' => true, 'class' => 'error-message', 'escape' => true);
|
||||
|
@ -517,6 +525,7 @@ class FormHelper extends AppHelper {
|
|||
* @param string $text Text that will appear in the label field.
|
||||
* @param mixed $options An array of HTML attributes, or a string, to be used as a class name.
|
||||
* @return string The formatted LABEL element
|
||||
* @link http://book.cakephp.org/view/1427/label
|
||||
*/
|
||||
function label($fieldName = null, $text = null, $options = array()) {
|
||||
if (empty($fieldName)) {
|
||||
|
@ -673,6 +682,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $fieldName This should be "Modelname.fieldname"
|
||||
* @param array $options Each type of input takes different options.
|
||||
* @return string Completed form widget.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1390/Automagic-Form-Elements
|
||||
*/
|
||||
public function input($fieldName, $options = array()) {
|
||||
$this->setEntity($fieldName);
|
||||
|
@ -963,6 +974,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $fieldName Name of a field, like this "Modelname.fieldname"
|
||||
* @param array $options Array of HTML attributes.
|
||||
* @return string An HTML text input element.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1414/checkbox
|
||||
*/
|
||||
public function checkbox($fieldName, $options = array()) {
|
||||
$options = $this->_initInputField($fieldName, $options) + array('hiddenField' => true);
|
||||
|
@ -1010,6 +1023,8 @@ class FormHelper extends AppHelper {
|
|||
* @param array $options Radio button options array.
|
||||
* @param array $attributes Array of HTML attributes, and special attributes above.
|
||||
* @return string Completed radio widget set.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1429/radio
|
||||
*/
|
||||
public function radio($fieldName, $options = array(), $attributes = array()) {
|
||||
$attributes = $this->_initInputField($fieldName, $attributes);
|
||||
|
@ -1092,6 +1107,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $fieldName Name of a field, in the form "Modelname.fieldname"
|
||||
* @param array $options Array of HTML attributes.
|
||||
* @return string A generated HTML text input element
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1432/text
|
||||
*/
|
||||
public function text($fieldName, $options = array()) {
|
||||
$options = $this->_initInputField($fieldName, array_merge(
|
||||
|
@ -1110,6 +1127,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $fieldName Name of a field, like in the form "Modelname.fieldname"
|
||||
* @param array $options Array of HTML attributes.
|
||||
* @return string A generated password input.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1428/password
|
||||
*/
|
||||
public function password($fieldName, $options = array()) {
|
||||
$options = $this->_initInputField($fieldName, $options);
|
||||
|
@ -1130,6 +1149,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $fieldName Name of a field, in the form "Modelname.fieldname"
|
||||
* @param array $options Array of HTML attributes, and special options above.
|
||||
* @return string A generated HTML text input element
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1433/textarea
|
||||
*/
|
||||
public function textarea($fieldName, $options = array()) {
|
||||
$options = $this->_initInputField($fieldName, $options);
|
||||
|
@ -1156,6 +1177,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $fieldName Name of a field, in the form of "Modelname.fieldname"
|
||||
* @param array $options Array of HTML attributes.
|
||||
* @return string A generated hidden input
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1425/hidden
|
||||
*/
|
||||
public function hidden($fieldName, $options = array()) {
|
||||
$secure = true;
|
||||
|
@ -1186,6 +1209,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $fieldName Name of a field, in the form "Modelname.fieldname"
|
||||
* @param array $options Array of HTML attributes.
|
||||
* @return string A generated file input.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1424/file
|
||||
*/
|
||||
public function file($fieldName, $options = array()) {
|
||||
$options = array_merge($options, array('secure' => false));
|
||||
|
@ -1212,6 +1237,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $title The button's caption. Not automatically HTML encoded
|
||||
* @param array $options Array of options and HTML attributes.
|
||||
* @return string A HTML button tag.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1415/button
|
||||
*/
|
||||
public function button($title, $options = array()) {
|
||||
$options += array('type' => 'submit', 'escape' => false);
|
||||
|
@ -1252,6 +1279,8 @@ class FormHelper extends AppHelper {
|
|||
* OR if the first character is not /, image is relative to webroot/img.
|
||||
* @param array $options Array of options. See above.
|
||||
* @return string A HTML submit button
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1431/submit
|
||||
*/
|
||||
public function submit($caption = null, $options = array()) {
|
||||
if (!$caption) {
|
||||
|
@ -1362,6 +1391,8 @@ class FormHelper extends AppHelper {
|
|||
* from POST data will be used when available.
|
||||
* @param array $attributes The HTML attributes of the select element.
|
||||
* @return string Formatted SELECT element
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1430/select
|
||||
*/
|
||||
public function select($fieldName, $options = array(), $selected = null, $attributes = array()) {
|
||||
$select = array();
|
||||
|
@ -1459,6 +1490,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $selected Option which is selected.
|
||||
* @param array $attributes HTML attributes for the select element
|
||||
* @return string A generated day select box.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1419/day
|
||||
*/
|
||||
public function day($fieldName, $selected = null, $attributes = array()) {
|
||||
$attributes += array('empty' => true);
|
||||
|
@ -1488,6 +1521,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $selected Option which is selected.
|
||||
* @param array $attributes Attribute array for the select elements.
|
||||
* @return string Completed year select input
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1416/year
|
||||
*/
|
||||
public function year($fieldName, $minYear = null, $maxYear = null, $selected = null, $attributes = array()) {
|
||||
$attributes += array('empty' => true);
|
||||
|
@ -1539,6 +1574,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $selected Option which is selected.
|
||||
* @param array $attributes Attributes for the select element
|
||||
* @return string A generated month select dropdown.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1417/month
|
||||
*/
|
||||
public function month($fieldName, $selected = null, $attributes = array()) {
|
||||
$attributes += array('empty' => true);
|
||||
|
@ -1574,6 +1611,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $selected Option which is selected.
|
||||
* @param array $attributes List of HTML attributes
|
||||
* @return string Completed hour select input
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1420/hour
|
||||
*/
|
||||
public function hour($fieldName, $format24Hours = false, $selected = null, $attributes = array()) {
|
||||
$attributes += array('empty' => true);
|
||||
|
@ -1607,6 +1646,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $selected Option which is selected.
|
||||
* @param string $attributes Array of Attributes
|
||||
* @return string Completed minute select input.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1421/minute
|
||||
*/
|
||||
public function minute($fieldName, $selected = null, $attributes = array()) {
|
||||
$attributes += array('empty' => true);
|
||||
|
@ -1669,6 +1710,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $attributes Array of Attributes
|
||||
* @param bool $showEmpty Show/Hide an empty option
|
||||
* @return string Completed meridian select input
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1422/meridian
|
||||
*/
|
||||
public function meridian($fieldName, $selected = null, $attributes = array()) {
|
||||
$attributes += array('empty' => true);
|
||||
|
@ -1716,6 +1759,8 @@ class FormHelper extends AppHelper {
|
|||
* @param string $selected Option which is selected.
|
||||
* @param string $attributes array of Attributes
|
||||
* @return string Generated set of select boxes for the date and time formats chosen.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1418/dateTime
|
||||
*/
|
||||
public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $selected = null, $attributes = array()) {
|
||||
$attributes += array('empty' => true);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @link http://book.cakephp.org/view/1434/HTML
|
||||
*/
|
||||
class HtmlHelper extends AppHelper {
|
||||
/**
|
||||
|
@ -157,6 +158,8 @@ class HtmlHelper extends AppHelper {
|
|||
*
|
||||
* @param string $type Doctype to use.
|
||||
* @return string Doctype string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1439/docType
|
||||
*/
|
||||
public function docType($type = 'xhtml-strict') {
|
||||
if (isset($this->__docTypes[$type])) {
|
||||
|
@ -177,6 +180,8 @@ class HtmlHelper extends AppHelper {
|
|||
* @param array $options Other attributes for the generated tag. If the type attribute is html,
|
||||
* rss, atom, or icon, the mime-type is returned.
|
||||
* @return string A completed `<link />` element.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1438/meta
|
||||
*/
|
||||
public function meta($type, $url = null, $options = array()) {
|
||||
$inline = isset($options['inline']) ? $options['inline'] : true;
|
||||
|
@ -241,6 +246,8 @@ class HtmlHelper extends AppHelper {
|
|||
* @param string $charset The character set to be used in the meta tag. If empty,
|
||||
* The App.encoding value will be used. Example: "utf-8".
|
||||
* @return string A meta tag containing the specified character set.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1436/charset
|
||||
*/
|
||||
public function charset($charset = null) {
|
||||
if (empty($charset)) {
|
||||
|
@ -267,6 +274,8 @@ class HtmlHelper extends AppHelper {
|
|||
* @param array $options Array of HTML attributes.
|
||||
* @param string $confirmMessage JavaScript confirmation message.
|
||||
* @return string An `<a />` element.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1442/link
|
||||
*/
|
||||
public function link($title, $url = null, $options = array(), $confirmMessage = false) {
|
||||
$escapeTitle = true;
|
||||
|
@ -320,6 +329,8 @@ class HtmlHelper extends AppHelper {
|
|||
* @param string $rel Rel attribute. Defaults to "stylesheet". If equal to 'import' the stylesheet will be imported.
|
||||
* @param array $options Array of HTML attributes.
|
||||
* @return string CSS <link /> or <style /> tag, depending on the type of link.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1437/css
|
||||
*/
|
||||
public function css($path, $rel = null, $options = array()) {
|
||||
$options += array('inline' => true);
|
||||
|
@ -391,6 +402,8 @@ class HtmlHelper extends AppHelper {
|
|||
* @param mixed $options Array of options, and html attributes see above. If boolean sets $options['inline'] = value
|
||||
* @return mixed String of `<script />` tags or null if $inline is false or if $once is true and the file has been
|
||||
* included before.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1589/script
|
||||
*/
|
||||
public function script($url, $options = array()) {
|
||||
if (is_bool($options)) {
|
||||
|
@ -448,6 +461,8 @@ class HtmlHelper extends AppHelper {
|
|||
* @param string $script The script to wrap
|
||||
* @param array $options The options to use.
|
||||
* @return mixed string or null depending on the value of `$options['inline']`
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1604/scriptBlock
|
||||
*/
|
||||
public function scriptBlock($script, $options = array()) {
|
||||
$options += array('safe' => true, 'inline' => true);
|
||||
|
@ -478,6 +493,8 @@ class HtmlHelper extends AppHelper {
|
|||
*
|
||||
* @param array $options Options for the code block.
|
||||
* @return void
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1605/scriptStart
|
||||
*/
|
||||
public function scriptStart($options = array()) {
|
||||
$options += array('safe' => true, 'inline' => true);
|
||||
|
@ -492,6 +509,8 @@ class HtmlHelper extends AppHelper {
|
|||
* used when the scriptBlock was started
|
||||
*
|
||||
* @return mixed depending on the settings of scriptStart() either a script tag or null
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1606/scriptEnd
|
||||
*/
|
||||
public function scriptEnd() {
|
||||
$buffer = ob_get_clean();
|
||||
|
@ -515,6 +534,8 @@ class HtmlHelper extends AppHelper {
|
|||
* @param array $data Style data array, keys will be used as property names, values as property values.
|
||||
* @param boolean $oneline Whether or not the style block should be displayed on one line.
|
||||
* @return string CSS styling data
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1440/style
|
||||
*/
|
||||
public function style($data, $oneline = true) {
|
||||
if (!is_array($data)) {
|
||||
|
@ -575,6 +596,8 @@ class HtmlHelper extends AppHelper {
|
|||
* @param string $path Path to the image file, relative to the app/webroot/img/ directory.
|
||||
* @param array $options Array of HTML attributes.
|
||||
* @return string completed img tag
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1441/image
|
||||
*/
|
||||
public function image($path, $options = array()) {
|
||||
if (is_array($path)) {
|
||||
|
@ -611,6 +634,8 @@ class HtmlHelper extends AppHelper {
|
|||
* @param array $trOptions HTML options for TR elements.
|
||||
* @param array $thOptions HTML options for TH elements.
|
||||
* @return string Completed table headers
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1446/tableHeaders
|
||||
*/
|
||||
public function tableHeaders($names, $trOptions = null, $thOptions = null) {
|
||||
$out = array();
|
||||
|
@ -630,6 +655,8 @@ class HtmlHelper extends AppHelper {
|
|||
* @param bool $continueOddEven If false, will use a non-static $count variable,
|
||||
* so that the odd/even count is reset to zero just for that call.
|
||||
* @return string Formatted HTML
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1447/tableCells
|
||||
*/
|
||||
public function tableCells($data, $oddTrOptions = null, $evenTrOptions = null, $useCount = false, $continueOddEven = true) {
|
||||
if (empty($data[0]) || !is_array($data[0])) {
|
||||
|
@ -685,6 +712,8 @@ class HtmlHelper extends AppHelper {
|
|||
* If null, only a start tag will be printed
|
||||
* @param array $options Additional HTML attributes of the DIV tag, see above.
|
||||
* @return string The formatted tag element
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1443/tag
|
||||
*/
|
||||
public function tag($name, $text = null, $options = array()) {
|
||||
if (is_array($options) && isset($options['escape']) && $options['escape']) {
|
||||
|
@ -714,6 +743,8 @@ class HtmlHelper extends AppHelper {
|
|||
* If null, only a start tag will be printed
|
||||
* @param array $options Additional HTML attributes of the DIV tag
|
||||
* @return string The formatted DIV element
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1444/div
|
||||
*/
|
||||
public function div($class = null, $text = null, $options = array()) {
|
||||
if (!empty($class)) {
|
||||
|
@ -733,6 +764,8 @@ class HtmlHelper extends AppHelper {
|
|||
* @param string $text String content that will appear inside the p element.
|
||||
* @param array $options Additional HTML attributes of the P tag
|
||||
* @return string The formatted P element
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1445/para
|
||||
*/
|
||||
public function para($class, $text, $options = array()) {
|
||||
if (isset($options['escape'])) {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @link http://book.cakephp.org/view/1450/Javascript
|
||||
*/
|
||||
class JavascriptHelper extends AppHelper {
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @link http://book.cakephp.org/view/1452/Number
|
||||
*/
|
||||
class NumberHelper extends AppHelper {
|
||||
|
||||
|
@ -69,6 +70,8 @@ class NumberHelper extends AppHelper {
|
|||
* @param float $number A floating point number.
|
||||
* @param integer $precision The precision of the returned number.
|
||||
* @return float Enter description here...
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1454/precision
|
||||
*/
|
||||
public function precision($number, $precision = 3) {
|
||||
return sprintf("%01.{$precision}f", $number);
|
||||
|
@ -79,6 +82,8 @@ class NumberHelper extends AppHelper {
|
|||
*
|
||||
* @param integer $length Size in bytes
|
||||
* @return string Human readable size
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1456/toReadableSize
|
||||
*/
|
||||
public function toReadableSize($size) {
|
||||
switch (true) {
|
||||
|
@ -101,6 +106,8 @@ class NumberHelper extends AppHelper {
|
|||
* @param float $number A floating point number
|
||||
* @param integer $precision The precision of the returned number
|
||||
* @return string Percentage string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1455/toPercentage
|
||||
*/
|
||||
public function toPercentage($number, $precision = 2) {
|
||||
return $this->precision($number, $precision) . '%';
|
||||
|
@ -113,6 +120,8 @@ class NumberHelper extends AppHelper {
|
|||
* @param integer $options if int then places, if string then before, if (,.-) then use it
|
||||
* or array with places and before keys
|
||||
* @return string formatted number
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1457/format
|
||||
*/
|
||||
public function format($number, $options = false) {
|
||||
$places = 0;
|
||||
|
@ -169,6 +178,8 @@ class NumberHelper extends AppHelper {
|
|||
* set at least 'before' and 'after' options.
|
||||
* @param array $options
|
||||
* @return string Number formatted as a currency.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1453/currency
|
||||
*/
|
||||
public function currency($number, $currency = 'USD', $options = array()) {
|
||||
$default = $this->_currencyDefaults;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @link http://book.cakephp.org/view/1458/Paginator
|
||||
*/
|
||||
class PaginatorHelper extends AppHelper {
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ App::import('Helper', 'Xml');
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @link http://book.cakephp.org/view/1460/RSS
|
||||
*/
|
||||
class RssHelper extends XmlHelper {
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ if (!class_exists('cakesession')) {
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @link http://book.cakephp.org/view/1465/Session
|
||||
*/
|
||||
class SessionHelper extends CakeSession {
|
||||
|
||||
|
@ -76,6 +77,8 @@ class SessionHelper extends CakeSession {
|
|||
*
|
||||
* @param string $name the name of the session key you want to read
|
||||
* @return values from the session vars
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1466/Methods
|
||||
*/
|
||||
public function read($name = null) {
|
||||
if ($this->__active === true && $this->__start()) {
|
||||
|
@ -91,6 +94,8 @@ class SessionHelper extends CakeSession {
|
|||
*
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1466/Methods
|
||||
*/
|
||||
public function check($name) {
|
||||
if ($this->__active === true && $this->__start()) {
|
||||
|
@ -105,6 +110,8 @@ class SessionHelper extends CakeSession {
|
|||
* In your view: `$session->error();`
|
||||
*
|
||||
* @return string last error
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1466/Methods
|
||||
*/
|
||||
public function error() {
|
||||
if ($this->__active === true && $this->__start()) {
|
||||
|
@ -121,6 +128,9 @@ class SessionHelper extends CakeSession {
|
|||
*
|
||||
* @param string $key The [Message.]key you are rendering in the view.
|
||||
* @return boolean|string Will return the value if $key is set, or false if not set.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1466/Methods
|
||||
* @link http://book.cakephp.org/view/1467/flash
|
||||
*/
|
||||
public function flash($key = 'flash') {
|
||||
$out = false;
|
||||
|
|
|
@ -38,6 +38,7 @@ if (!class_exists('Multibyte')) {
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @link http://book.cakephp.org/view/1469/Text
|
||||
*/
|
||||
class TextHelper extends AppHelper {
|
||||
|
||||
|
@ -54,6 +55,8 @@ class TextHelper extends AppHelper {
|
|||
* @param string $phrase The phrase that will be searched
|
||||
* @param array $options An array of html attributes and options.
|
||||
* @return string The highlighted text
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1469/Text#highlight-1622
|
||||
*/
|
||||
public function highlight($text, $phrase, $options = array()) {
|
||||
if (empty($phrase)) {
|
||||
|
@ -97,6 +100,8 @@ class TextHelper extends AppHelper {
|
|||
*
|
||||
* @param string $text Text
|
||||
* @return string The text without links
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1469/Text#stripLinks-1623
|
||||
*/
|
||||
public function stripLinks($text) {
|
||||
return preg_replace('|<a\s+[^>]+>|im', '', preg_replace('|<\/a>|im', '', $text));
|
||||
|
@ -109,6 +114,8 @@ class TextHelper extends AppHelper {
|
|||
* @param string $text Text to add links to
|
||||
* @param array $options Array of HTML options.
|
||||
* @return string The text with links
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1469/Text#autoLinkUrls-1619
|
||||
*/
|
||||
public function autoLinkUrls($text, $options = array()) {
|
||||
$linkOptions = 'array(';
|
||||
|
@ -131,6 +138,8 @@ class TextHelper extends AppHelper {
|
|||
* @param string $text Text
|
||||
* @param array $options Array of HTML options.
|
||||
* @return string The text with links
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1469/Text#autoLinkEmails-1618
|
||||
*/
|
||||
public function autoLinkEmails($text, $options = array()) {
|
||||
$linkOptions = 'array(';
|
||||
|
@ -150,6 +159,8 @@ class TextHelper extends AppHelper {
|
|||
* @param string $text Text
|
||||
* @param array $options Array of HTML options.
|
||||
* @return string The text with links
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1469/Text#autoLink-1620
|
||||
*/
|
||||
public function autoLink($text, $options = array()) {
|
||||
return $this->autoLinkEmails($this->autoLinkUrls($text, $options), $options);
|
||||
|
@ -171,6 +182,8 @@ class TextHelper extends AppHelper {
|
|||
* @param integer $length Length of returned string, including ellipsis.
|
||||
* @param array $options An array of html attributes and options.
|
||||
* @return string Trimmed string.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1469/Text#truncate-1625
|
||||
*/
|
||||
public function truncate($text, $length = 100, $options = array()) {
|
||||
$default = array(
|
||||
|
@ -270,6 +283,8 @@ class TextHelper extends AppHelper {
|
|||
* @param integer $radius The amount of characters that will be returned on each side of the founded phrase
|
||||
* @param string $ending Ending that will be appended
|
||||
* @return string Modified string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1469/Text#excerpt-1621
|
||||
*/
|
||||
public function excerpt($text, $phrase, $radius = 100, $ending = '...') {
|
||||
if (empty($text) or empty($phrase)) {
|
||||
|
@ -314,6 +329,8 @@ class TextHelper extends AppHelper {
|
|||
* @param string $and The word used to join the last and second last items together with. Defaults to 'and'
|
||||
* @param string $separator The separator used to join all othe other items together. Defaults to ', '
|
||||
* @return string The glued together string.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1469/Text#toList-1624
|
||||
*/
|
||||
public function toList($list, $and = 'and', $separator = ', ') {
|
||||
if (count($list) > 1) {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @link http://book.cakephp.org/view/1470/Time
|
||||
*/
|
||||
class TimeHelper extends AppHelper {
|
||||
|
||||
|
@ -163,6 +164,8 @@ class TimeHelper extends AppHelper {
|
|||
* @param string $dateString Datetime string
|
||||
* @param int $userOffset User's offset from GMT (in hours)
|
||||
* @return string Parsed timestamp
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1471/Formatting
|
||||
*/
|
||||
public function fromString($dateString, $userOffset = null) {
|
||||
if (empty($dateString)) {
|
||||
|
@ -188,6 +191,8 @@ class TimeHelper extends AppHelper {
|
|||
* @param string $dateString Datetime string or Unix timestamp
|
||||
* @param int $userOffset User's offset from GMT (in hours)
|
||||
* @return string Formatted date string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1471/Formatting
|
||||
*/
|
||||
public function nice($dateString = null, $userOffset = null) {
|
||||
if ($dateString != null) {
|
||||
|
@ -210,6 +215,8 @@ class TimeHelper extends AppHelper {
|
|||
* @param string $dateString Datetime string or Unix timestamp
|
||||
* @param int $userOffset User's offset from GMT (in hours)
|
||||
* @return string Described, relative date string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1471/Formatting
|
||||
*/
|
||||
public function niceShort($dateString = null, $userOffset = null) {
|
||||
$date = $dateString ? $this->fromString($dateString, $userOffset) : time();
|
||||
|
@ -236,6 +243,8 @@ class TimeHelper extends AppHelper {
|
|||
* @param string $fieldName Name of database field to compare with
|
||||
* @param int $userOffset User's offset from GMT (in hours)
|
||||
* @return string Partial SQL string.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1471/Formatting
|
||||
*/
|
||||
public function daysAsSql($begin, $end, $fieldName, $userOffset = null) {
|
||||
$begin = $this->fromString($begin, $userOffset);
|
||||
|
@ -254,6 +263,8 @@ class TimeHelper extends AppHelper {
|
|||
* @param string $fieldName Name of database field to compare with
|
||||
* @param int $userOffset User's offset from GMT (in hours)
|
||||
* @return string Partial SQL string.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1471/Formatting
|
||||
*/
|
||||
public function dayAsSql($dateString, $fieldName, $userOffset = null) {
|
||||
$date = $this->fromString($dateString, $userOffset);
|
||||
|
@ -277,6 +288,8 @@ class TimeHelper extends AppHelper {
|
|||
* @param string $dateString
|
||||
* @param int $userOffset User's offset from GMT (in hours)
|
||||
* @return boolean True if datetime string is within current week
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1472/Testing-Time
|
||||
*/
|
||||
public function isThisWeek($dateString, $userOffset = null) {
|
||||
$date = $this->fromString($dateString, $userOffset);
|
||||
|
@ -288,6 +301,8 @@ class TimeHelper extends AppHelper {
|
|||
* @param string $dateString
|
||||
* @param int $userOffset User's offset from GMT (in hours)
|
||||
* @return boolean True if datetime string is within current month
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1472/Testing-Time
|
||||
*/
|
||||
public function isThisMonth($dateString, $userOffset = null) {
|
||||
$date = $this->fromString($dateString);
|
||||
|
@ -299,6 +314,8 @@ class TimeHelper extends AppHelper {
|
|||
*
|
||||
* @param string $dateString Datetime string or Unix timestamp
|
||||
* @return boolean True if datetime string is within current year
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1472/Testing-Time
|
||||
*/
|
||||
public function isThisYear($dateString, $userOffset = null) {
|
||||
$date = $this->fromString($dateString, $userOffset);
|
||||
|
@ -311,6 +328,9 @@ class TimeHelper extends AppHelper {
|
|||
* @param string $dateString Datetime string or Unix timestamp
|
||||
* @param int $userOffset User's offset from GMT (in hours)
|
||||
* @return boolean True if datetime string was yesterday
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1472/Testing-Time
|
||||
*
|
||||
*/
|
||||
public function wasYesterday($dateString, $userOffset = null) {
|
||||
$date = $this->fromString($dateString, $userOffset);
|
||||
|
@ -323,6 +343,8 @@ class TimeHelper extends AppHelper {
|
|||
* @param string $dateString Datetime string or Unix timestamp
|
||||
* @param int $userOffset User's offset from GMT (in hours)
|
||||
* @return boolean True if datetime string was yesterday
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1472/Testing-Time
|
||||
*/
|
||||
public function isTomorrow($dateString, $userOffset = null) {
|
||||
$date = $this->fromString($dateString, $userOffset);
|
||||
|
@ -335,6 +357,8 @@ class TimeHelper extends AppHelper {
|
|||
* @param string $dateString
|
||||
* @param boolean $range if true returns a range in Y-m-d format
|
||||
* @return boolean True if datetime string is within current week
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1471/Formatting
|
||||
*/
|
||||
public function toQuarter($dateString, $range = false) {
|
||||
$time = $this->fromString($dateString);
|
||||
|
@ -371,6 +395,8 @@ class TimeHelper extends AppHelper {
|
|||
* @param string $dateString Datetime string to be represented as a Unix timestamp
|
||||
* @param int $userOffset User's offset from GMT (in hours)
|
||||
* @return integer Unix timestamp
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1471/Formatting
|
||||
*/
|
||||
public function toUnix($dateString, $userOffset = null) {
|
||||
return $this->fromString($dateString, $userOffset);
|
||||
|
@ -382,6 +408,8 @@ class TimeHelper extends AppHelper {
|
|||
* @param string $dateString Datetime string or Unix timestamp
|
||||
* @param int $userOffset User's offset from GMT (in hours)
|
||||
* @return string Formatted date string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1471/Formatting
|
||||
*/
|
||||
public function toAtom($dateString, $userOffset = null) {
|
||||
$date = $this->fromString($dateString, $userOffset);
|
||||
|
@ -394,6 +422,8 @@ class TimeHelper extends AppHelper {
|
|||
* @param string $dateString Datetime string or Unix timestamp
|
||||
* @param int $userOffset User's offset from GMT (in hours)
|
||||
* @return string Formatted date string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1471/Formatting
|
||||
*/
|
||||
public function toRSS($dateString, $userOffset = null) {
|
||||
$date = $this->fromString($dateString, $userOffset);
|
||||
|
@ -423,6 +453,8 @@ class TimeHelper extends AppHelper {
|
|||
* @param string $dateString Datetime string or Unix timestamp
|
||||
* @param array $options Default format if timestamp is used in $dateString
|
||||
* @return string Relative time string.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1471/Formatting
|
||||
*/
|
||||
public function timeAgoInWords($dateTime, $options = array()) {
|
||||
$userOffset = null;
|
||||
|
@ -590,6 +622,7 @@ class TimeHelper extends AppHelper {
|
|||
* @see TimeHelper::timeAgoInWords
|
||||
* @access public
|
||||
* @deprecated This method alias will be removed in future versions.
|
||||
* @link http://book.cakephp.org/view/1471/Formatting
|
||||
*/
|
||||
function relativeTime($dateTime, $options = array()) {
|
||||
return $this->timeAgoInWords($dateTime, $options);
|
||||
|
@ -603,6 +636,8 @@ class TimeHelper extends AppHelper {
|
|||
* @param mixed $dateString the datestring or unix timestamp to compare
|
||||
* @param int $userOffset User's offset from GMT (in hours)
|
||||
* @return bool
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1472/Testing-Time
|
||||
*/
|
||||
public function wasWithinLast($timeInterval, $dateString, $userOffset = null) {
|
||||
$tmp = str_replace(' ', '', $timeInterval);
|
||||
|
@ -625,6 +660,8 @@ class TimeHelper extends AppHelper {
|
|||
*
|
||||
* @param string $dateString Datetime string
|
||||
* @return string Formatted date string
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1471/Formatting
|
||||
*/
|
||||
public function gmt($string = null) {
|
||||
if ($string != null) {
|
||||
|
|
|
@ -26,6 +26,7 @@ App::import('Core', array('Xml', 'Set'));
|
|||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @link http://book.cakephp.org/view/1473/XML
|
||||
*/
|
||||
class XmlHelper extends AppHelper {
|
||||
|
||||
|
@ -53,6 +54,8 @@ class XmlHelper extends AppHelper {
|
|||
*
|
||||
* @param array $attrib Header tag attributes
|
||||
* @return string XML header
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1476/header
|
||||
*/
|
||||
public function header($attrib = array()) {
|
||||
if (Configure::read('App.encoding') !== null) {
|
||||
|
@ -102,6 +105,8 @@ class XmlHelper extends AppHelper {
|
|||
* @param mixed $content XML element content
|
||||
* @param boolean $endTag Whether the end tag of the element should be printed
|
||||
* @return string XML
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1475/elem
|
||||
*/
|
||||
public function elem($name, $attrib = array(), $content = null, $endTag = true) {
|
||||
$namespace = null;
|
||||
|
@ -156,6 +161,8 @@ class XmlHelper extends AppHelper {
|
|||
* XmlNode::__construct().
|
||||
* @return string A copy of $data in XML format
|
||||
* @see XmlNode
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1474/serialize
|
||||
*/
|
||||
public function serialize($data, $options = array()) {
|
||||
$options += array('attributes' => false, 'format' => 'attributes');
|
||||
|
|
|
@ -137,7 +137,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
'My link',
|
||||
'/a'
|
||||
);
|
||||
$this->assertTrue($this->Case->assertTags($input, $pattern));
|
||||
$this->assertTrue($this->Case->assertTags($input, $pattern), 'Attributes in wrong order. %s');
|
||||
|
||||
$input = "<a href=\"/test.html\"\t\n\tclass=\"active\"\tid=\"primary\">\t<span>My link</span></a>";
|
||||
$pattern = array(
|
||||
|
@ -147,7 +147,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
'/span',
|
||||
'/a'
|
||||
);
|
||||
$this->assertTrue($this->Case->assertTags($input, $pattern));
|
||||
$this->assertTrue($this->Case->assertTags($input, $pattern), 'Whitespace consumption %s');
|
||||
|
||||
$input = '<p class="info"><a href="/test.html" class="active"><strong onClick="alert(\'hey\');">My link</strong></a></p>';
|
||||
$pattern = array(
|
||||
|
@ -162,6 +162,37 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
$this->assertTrue($this->Case->assertTags($input, $pattern));
|
||||
}
|
||||
|
||||
/**
|
||||
* test that assertTags knows how to handle correct quoting.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testAssertTagsQuotes() {
|
||||
$input = '<a href="/test.html" class="active">My link</a>';
|
||||
$pattern = array(
|
||||
'a' => array('href' => '/test.html', 'class' => 'active'),
|
||||
'My link',
|
||||
'/a'
|
||||
);
|
||||
$this->assertTrue($this->Case->assertTags($input, $pattern), 'Double quoted attributes %s');
|
||||
|
||||
$input = "<a href='/test.html' class='active'>My link</a>";
|
||||
$pattern = array(
|
||||
'a' => array('href' => '/test.html', 'class' => 'active'),
|
||||
'My link',
|
||||
'/a'
|
||||
);
|
||||
$this->assertTrue($this->Case->assertTags($input, $pattern), 'Single quoted attributes %s');
|
||||
|
||||
$input = "<a href='/test.html' class='active'>My link</a>";
|
||||
$pattern = array(
|
||||
'a' => array('href' => 'preg:/.*\.html/', 'class' => 'active'),
|
||||
'My link',
|
||||
'/a'
|
||||
);
|
||||
$this->assertTrue($this->Case->assertTags($input, $pattern), 'Single quoted attributes %s');
|
||||
}
|
||||
|
||||
/**
|
||||
* testNumericValuesInExpectationForAssertTags
|
||||
*
|
||||
|
|
|
@ -2881,7 +2881,10 @@ class ContainableBehaviorTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testEmbeddedFindFields() {
|
||||
$result = $this->Article->find('all', array('contain' => array('User(user)'), 'fields' => array('title')));
|
||||
$result = $this->Article->find('all', array(
|
||||
'contain' => array('User(user)'),
|
||||
'fields' => array('title')
|
||||
));
|
||||
$expected = array(
|
||||
array('Article' => array('title' => 'First Article'), 'User' => array('user' => 'mariano', 'id' => 1)),
|
||||
array('Article' => array('title' => 'Second Article'), 'User' => array('user' => 'larry', 'id' => 3)),
|
||||
|
@ -2889,7 +2892,10 @@ class ContainableBehaviorTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Article->find('all', array('contain' => array('User(id, user)'), 'fields' => array('title')));
|
||||
$result = $this->Article->find('all', array(
|
||||
'contain' => array('User(id, user)'),
|
||||
'fields' => array('title')
|
||||
));
|
||||
$expected = array(
|
||||
array('Article' => array('title' => 'First Article'), 'User' => array('user' => 'mariano', 'id' => 1)),
|
||||
array('Article' => array('title' => 'Second Article'), 'User' => array('user' => 'larry', 'id' => 3)),
|
||||
|
@ -2897,7 +2903,12 @@ class ContainableBehaviorTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Article->find('all', array('contain' => array('Comment(comment, published)' => 'Attachment(attachment)', 'User(user)'), 'fields' => array('title')));
|
||||
$result = $this->Article->find('all', array(
|
||||
'contain' => array(
|
||||
'Comment(comment, published)' => 'Attachment(attachment)', 'User(user)'
|
||||
),
|
||||
'fields' => array('title')
|
||||
));
|
||||
if (!empty($result)) {
|
||||
foreach($result as $i=>$article) {
|
||||
foreach($article['Comment'] as $j=>$comment) {
|
||||
|
@ -2935,6 +2946,38 @@ class ContainableBehaviorTest extends CakeTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that hasOne and belongsTo fields act the same in a contain array.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testHasOneFieldsInContain() {
|
||||
$this->Article->unbindModel(array(
|
||||
'hasMany' => array('Comment')
|
||||
), true);
|
||||
unset($this->Article->Comment);
|
||||
$this->Article->bindModel(array(
|
||||
'hasOne' => array('Comment')
|
||||
));
|
||||
|
||||
$result = $this->Article->find('all', array(
|
||||
'fields' => array('title', 'body'),
|
||||
'contain' => array(
|
||||
'Comment' => array(
|
||||
'fields' => array('comment')
|
||||
),
|
||||
'User' => array(
|
||||
'fields' => array('user')
|
||||
)
|
||||
)
|
||||
));
|
||||
$this->assertTrue(isset($result[0]['Article']['title']), 'title missing %s');
|
||||
$this->assertTrue(isset($result[0]['Article']['body']), 'body missing %s');
|
||||
$this->assertTrue(isset($result[0]['Comment']['comment']), 'comment missing %s');
|
||||
$this->assertTrue(isset($result[0]['User']['user']), 'body missing %s');
|
||||
$this->assertFalse(isset($result[0]['Comment']['published']), 'published found %s');
|
||||
$this->assertFalse(isset($result[0]['User']['password']), 'password found %s');
|
||||
}
|
||||
/**
|
||||
* testFindConditionalBinding method
|
||||
*
|
||||
|
@ -2942,7 +2985,13 @@ class ContainableBehaviorTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testFindConditionalBinding() {
|
||||
$this->Article->contain(array('User(user)', 'Tag' => array('fields' => array('tag', 'created'), 'conditions' => array('created >=' => '2007-03-18 12:24'))));
|
||||
$this->Article->contain(array(
|
||||
'User(user)',
|
||||
'Tag' => array(
|
||||
'fields' => array('tag', 'created'),
|
||||
'conditions' => array('created >=' => '2007-03-18 12:24')
|
||||
)
|
||||
));
|
||||
$result = $this->Article->find('all', array('fields' => array('title')));
|
||||
$expected = array(
|
||||
array(
|
||||
|
@ -3019,7 +3068,13 @@ class ContainableBehaviorTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Article->contain(array('User(id,user)', 'Tag' => array('fields' => array('tag', 'created'), 'conditions' => array('created >=' => '2007-03-18 12:24'))));
|
||||
$this->Article->contain(array(
|
||||
'User(id,user)',
|
||||
'Tag' => array(
|
||||
'fields' => array('tag', 'created'),
|
||||
'conditions' => array('created >=' => '2007-03-18 12:24')
|
||||
)
|
||||
));
|
||||
$result = $this->Article->find('all', array('fields' => array('title')));
|
||||
$expected = array(
|
||||
array(
|
||||
|
|
|
@ -4266,6 +4266,24 @@ class DboSourceTest extends CakeTestCase {
|
|||
'(NOW()) AS `Article__this_moment`',
|
||||
);
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $this->db->fields($Article, null, array('Article.*'));
|
||||
$expected = array(
|
||||
'`Article`.*',
|
||||
'(NOW()) AS `Article__this_moment`',
|
||||
'(1 + 1) AS `Article__two`',
|
||||
'(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) AS `Article__comment_count`'
|
||||
);
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $this->db->fields($Article, null, array('*'));
|
||||
$expected = array(
|
||||
'*',
|
||||
'(NOW()) AS `Article__this_moment`',
|
||||
'(1 + 1) AS `Article__two`',
|
||||
'(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) AS `Article__comment_count`'
|
||||
);
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -614,30 +614,33 @@ class CakeTestCase extends UnitTestCase {
|
|||
}
|
||||
$attrs = array();
|
||||
$explanations = array();
|
||||
$i = 1;
|
||||
foreach ($attributes as $attr => $val) {
|
||||
if (is_numeric($attr) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
|
||||
$attrs[] = $matches[1];
|
||||
$explanations[] = sprintf('Regex "%s" matches', $matches[1]);
|
||||
continue;
|
||||
} else {
|
||||
$quotes = '"';
|
||||
$quotes = '["\']';
|
||||
if (is_numeric($attr)) {
|
||||
$attr = $val;
|
||||
$val = '.+?';
|
||||
$explanations[] = sprintf('Attribute "%s" present', $attr);
|
||||
} elseif (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
|
||||
$quotes = '"?';
|
||||
$quotes = '["\']?';
|
||||
$val = $matches[1];
|
||||
$explanations[] = sprintf('Attribute "%s" matches "%s"', $attr, $val);
|
||||
} else {
|
||||
$explanations[] = sprintf('Attribute "%s" == "%s"', $attr, $val);
|
||||
$val = preg_quote($val, '/');
|
||||
}
|
||||
$attrs[] = '[\s]+'.preg_quote($attr, '/').'='.$quotes.$val.$quotes;
|
||||
$attrs[] = '[\s]+' . preg_quote($attr, '/') . '=' . $quotes . $val . $quotes;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
if ($attrs) {
|
||||
$permutations = $this->__array_permute($attrs);
|
||||
|
||||
$permutationTokens = array();
|
||||
foreach ($permutations as $permutation) {
|
||||
$permutationTokens[] = implode('', $permutation);
|
||||
|
|
Loading…
Reference in a new issue