mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Replaced all instances of ife() in /cake
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7387 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
565163303c
commit
b6e9888753
19 changed files with 133 additions and 97 deletions
|
@ -380,7 +380,7 @@ class SecurityComponent extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __requireMethod($method, $actions = array()) {
|
||||
$this->{'require' . $method} = ife(empty($actions), array('*'), $actions);
|
||||
$this->{'require' . $method} = (empty($actions)) ? array('*'): $actions;
|
||||
}
|
||||
/**
|
||||
* Check if HTTP methods are required
|
||||
|
|
|
@ -505,53 +505,58 @@ class Controller extends Object {
|
|||
|
||||
if (!empty($status)) {
|
||||
$codes = array(
|
||||
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"
|
||||
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'
|
||||
);
|
||||
if (is_string($status)) {
|
||||
$codes = array_combine(array_values($codes), array_keys($codes));
|
||||
}
|
||||
|
||||
if (isset($codes[$status])) {
|
||||
$code = ife(is_numeric($status), $status, $codes[$status]);
|
||||
$msg = ife(is_string($status), $status, $codes[$status]);
|
||||
$code = $status = $codes[$status];
|
||||
if (is_numeric($status)) {
|
||||
$code = $status;
|
||||
}
|
||||
if (is_string($status)) {
|
||||
$msg = $status;
|
||||
}
|
||||
$status = "HTTP/1.1 {$code} {$msg}";
|
||||
} else {
|
||||
$status = null;
|
||||
|
|
|
@ -349,7 +349,7 @@ class Debugger extends Object {
|
|||
$_this = Debugger::getInstance();
|
||||
switch(strtolower(gettype($var))) {
|
||||
case 'boolean':
|
||||
return ife($var, 'true', 'false');
|
||||
return ($var) ? 'true' : 'false';
|
||||
break;
|
||||
case 'integer':
|
||||
case 'double':
|
||||
|
|
|
@ -741,7 +741,10 @@ class Folder extends Object{
|
|||
}
|
||||
$parts = explode(DS, $path);
|
||||
$newparts = array();
|
||||
$newpath = ife($path[0] == DS, DS, '');
|
||||
$newpath = '';
|
||||
if ($path[0] == DS) {
|
||||
$newpath = DS;
|
||||
}
|
||||
|
||||
while (($part = array_shift($parts)) !== NULL) {
|
||||
if ($part == '.' || $part == '') {
|
||||
|
|
|
@ -70,7 +70,10 @@ class ContainableBehavior extends ModelBehavior {
|
|||
if (!isset($this->settings[$Model->alias])) {
|
||||
$this->settings[$Model->alias] = array('recursive' => true, 'notices' => true, 'autoFields' => true);
|
||||
}
|
||||
$this->settings[$Model->alias] = array_merge($this->settings[$Model->alias], ife(is_array($settings), $settings, array()));
|
||||
if (!is_array($settings)) {
|
||||
$settings = array();
|
||||
}
|
||||
$this->settings[$Model->alias] = array_merge($this->settings[$Model->alias], $settings);
|
||||
}
|
||||
/**
|
||||
* Runs before a find() operation. Used to allow 'contain' setting
|
||||
|
|
|
@ -121,7 +121,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$addFields = array();
|
||||
if (is_array($query['fields'])) {
|
||||
foreach ($fields as $key => $value) {
|
||||
$field = ife(is_numeric($key), $value, $key);
|
||||
$field = (is_numeric($key)) ? $value : $key;
|
||||
|
||||
if (in_array($model->alias.'.*', $query['fields']) || $autoFields || in_array($model->alias.'.'.$field, $query['fields']) || in_array($field, $query['fields'])) {
|
||||
$addFields[] = $field;
|
||||
|
@ -194,7 +194,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$beforeFind = $this->runtime[$model->alias]['beforeFind'];
|
||||
|
||||
foreach ($results as $key => $row) {
|
||||
$results[$key][$model->alias]['locale'] = ife(is_array($locale), @$locale[0], $locale);
|
||||
$results[$key][$model->alias]['locale'] = (is_array($locale)) ? @$locale[0] : $locale;
|
||||
|
||||
foreach ($beforeFind as $field) {
|
||||
if (is_array($locale)) {
|
||||
|
@ -209,7 +209,10 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$results[$key][$model->alias][$field] = '';
|
||||
}
|
||||
} else {
|
||||
$value = ife(empty($results[$key]['I18n__'.$field]['content']), '', $results[$key]['I18n__'.$field]['content']);
|
||||
$value = '';
|
||||
if (!empty($results[$key]['I18n__'.$field]['content'])) {
|
||||
$value = $results[$key]['I18n__'.$field]['content'];
|
||||
}
|
||||
$results[$key][$model->alias][$field] = $value;
|
||||
unset($results[$key]['I18n__'.$field]);
|
||||
}
|
||||
|
@ -229,7 +232,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$tempData = array();
|
||||
|
||||
foreach ($fields as $key => $value) {
|
||||
$field = ife(is_numeric($key), $value, $key);
|
||||
$field = (is_numeric($key)) ? $value : $key;
|
||||
|
||||
if (isset($model->data[$model->alias][$field])) {
|
||||
$tempData[$field] = $model->data[$model->alias][$field];
|
||||
|
|
|
@ -886,7 +886,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
'fields' => $db->calculate($model, 'max', array($right)),
|
||||
'recursive' => $recursive
|
||||
)));
|
||||
return ife(empty ($edge[$right]), 0, $edge[$right]);
|
||||
return (empty($edge[$right])) ? 0 : $edge[$right];
|
||||
}
|
||||
/**
|
||||
* get the minimum index value in the table.
|
||||
|
@ -904,7 +904,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
'fields' => $db->calculate($model, 'min', array($left)),
|
||||
'recursive' => $recursive
|
||||
)));
|
||||
return ife(empty($edge[$left]), 0, $edge[$left]);
|
||||
return (empty($edge[$left])) ? 0 : $edge[$left];
|
||||
}
|
||||
/**
|
||||
* Table sync method.
|
||||
|
|
|
@ -514,7 +514,7 @@ class DboMysql extends DboSource {
|
|||
foreach ($keys as $i => $key) {
|
||||
if(!isset($index[$key['Key_name']])) {
|
||||
$index[$key['Key_name']]['column'] = $key['Column_name'];
|
||||
$index[$key['Key_name']]['unique'] = ife($key['Non_unique'] == 0, 1, 0);
|
||||
$index[$key['Key_name']]['unique'] = intval($key['Non_unique'] == 0);
|
||||
} else {
|
||||
if(!is_array($index[$key['Key_name']]['column'])) {
|
||||
$col[] = $index[$key['Key_name']]['column'];
|
||||
|
|
|
@ -343,7 +343,7 @@ class DboOracle extends DboSource {
|
|||
$this->_setError($this->_statementId);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$this->_setError(null, true);
|
||||
|
||||
switch(ocistatementtype($this->_statementId)) {
|
||||
|
@ -395,7 +395,7 @@ class DboOracle extends DboSource {
|
|||
$this->_currentRow++;
|
||||
return $resultRow;
|
||||
}
|
||||
|
||||
|
||||
function fetchResult() {
|
||||
return $this->fetchRow();
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ class DboOracle extends DboSource {
|
|||
$this->_sequenceMap[$model->table] = $model->sequence;
|
||||
} elseif (!empty($model->table)) {
|
||||
$this->_sequenceMap[$model->table] = $model->table . '_seq';
|
||||
}
|
||||
}
|
||||
|
||||
$cache = parent::describe($model);
|
||||
|
||||
|
@ -650,7 +650,7 @@ class DboOracle extends DboSource {
|
|||
}
|
||||
if(!isset($index[$key])) {
|
||||
$index[$key]['column'] = strtolower($idx['cc']['column_name']);
|
||||
$index[$key]['unique'] = ife($idx['i']['uniqueness'] == 'UNIQUE', 1, 0);
|
||||
$index[$key]['unique'] = intval($idx['i']['uniqueness'] == 'UNIQUE');
|
||||
} else {
|
||||
if(!is_array($index[$key]['column'])) {
|
||||
$col[] = $index[$key]['column'];
|
||||
|
|
|
@ -292,7 +292,7 @@ class Multibyte extends Object {
|
|||
|
||||
} else {
|
||||
if (count($values) == 0) {
|
||||
$find = ife($value < 224, 2, 3);
|
||||
$find = ($value < 224) ? 2 : 3;
|
||||
}
|
||||
$values[] = $value;
|
||||
|
||||
|
@ -639,8 +639,7 @@ class Multibyte extends Object {
|
|||
}
|
||||
$position++;
|
||||
}
|
||||
$return = ife($found, $position, false);
|
||||
return $return;
|
||||
return ($found) ? $position : false;
|
||||
}
|
||||
return strripos($haystack, $needle, $offset);
|
||||
}
|
||||
|
@ -689,8 +688,7 @@ class Multibyte extends Object {
|
|||
}
|
||||
$position++;
|
||||
}
|
||||
$return = ife($found, $position, false);
|
||||
return $return;
|
||||
return ($found) ? $position : false;
|
||||
}
|
||||
return strrpos($haystack, $needle, $offset);
|
||||
}
|
||||
|
|
|
@ -298,10 +298,11 @@ class Router extends Object {
|
|||
|
||||
foreach ($_this->__resourceMap as $params) {
|
||||
extract($params);
|
||||
$id = ife($id, '/:id', '');
|
||||
|
||||
Router::connect(
|
||||
"{$prefix}{$urlName}{$id}",
|
||||
$url = $prefix . $urlName;
|
||||
if ($id) {
|
||||
$url .= '/:id';
|
||||
}
|
||||
Router::connect($url,
|
||||
array('controller' => $urlName, 'action' => $action, '[method]' => $params['method']),
|
||||
array('id' => $options['id'], 'pass' => array('id'))
|
||||
);
|
||||
|
|
|
@ -297,7 +297,10 @@ class Helper extends Overloadable {
|
|||
$attribute = sprintf($attributeFormat, $key, $key);
|
||||
}
|
||||
} else {
|
||||
$attribute = sprintf($attributeFormat, $key, ife($escape, h($value), $value));
|
||||
if ($escape) {
|
||||
$value = htmlspecialchars($value);
|
||||
}
|
||||
$attribute = sprintf($attributeFormat, $key, $value);
|
||||
}
|
||||
return $attribute;
|
||||
}
|
||||
|
|
|
@ -682,10 +682,10 @@ class AjaxHelper extends AppHelper {
|
|||
foreach ($options as $key => $value) {
|
||||
switch($key) {
|
||||
case 'type':
|
||||
$jsOptions['asynchronous'] = ife(($value == 'synchronous'), 'false', 'true');
|
||||
$jsOptions['asynchronous'] = ($value == 'synchronous') ? 'false' : 'true';
|
||||
break;
|
||||
case 'evalScripts':
|
||||
$jsOptions['evalScripts'] = ife($value, 'true', 'false');
|
||||
$jsOptions['evalScripts'] = ($value) ? 'true' : 'false';
|
||||
break;
|
||||
case 'position':
|
||||
$jsOptions['insertion'] = "Insertion." . Inflector::camelize($options['position']);
|
||||
|
|
|
@ -171,7 +171,7 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
}
|
||||
if (empty($options['action'])) {
|
||||
$options['action'] = ife($created, 'edit', 'add');
|
||||
$options['action'] = ($created) ? 'edit' : 'add';
|
||||
}
|
||||
|
||||
$actionDefaults = array(
|
||||
|
@ -195,7 +195,7 @@ class FormHelper extends AppHelper {
|
|||
break;
|
||||
case 'file':
|
||||
$htmlAttributes['enctype'] = 'multipart/form-data';
|
||||
$options['type'] = ife($created, 'put', 'post');
|
||||
$options['type'] = ($created) ? 'put' : 'post';
|
||||
case 'post':
|
||||
case 'put':
|
||||
case 'delete':
|
||||
|
@ -1579,7 +1579,9 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
|
||||
if ($showParents || (!in_array($title, $parents))) {
|
||||
$title = ife($attributes['escape'], h($title), $title);
|
||||
if ($attributes['escape']) {
|
||||
$title = htmlspecialchars($title);
|
||||
}
|
||||
|
||||
if ($attributes['style'] === 'checkbox') {
|
||||
$htmlOptions['value'] = $name;
|
||||
|
|
|
@ -196,8 +196,10 @@ class JavascriptHelper extends AppHelper {
|
|||
if ($options['inline']) {
|
||||
if ($block) {
|
||||
return sprintf($this->tags['javascriptblock'], $script);
|
||||
} elseif ($safe) {
|
||||
return $this->tags['javascriptstart'] . "\n" . '//<![CDATA[' . "\n";
|
||||
} else {
|
||||
return sprintf($this->tags['javascriptstart']).ife($safe, "\n" . '//<![CDATA[' . "\n", '');
|
||||
return $this->tags['javascriptstart'];
|
||||
}
|
||||
} elseif ($block) {
|
||||
$view =& ClassRegistry::getObject('view');
|
||||
|
@ -230,7 +232,10 @@ class JavascriptHelper extends AppHelper {
|
|||
$this->_cachedEvents[] = $script;
|
||||
return null;
|
||||
}
|
||||
return ife($safe, "\n" . '//]]>' . "\n", '').$this->tags['javascriptend'];
|
||||
if ($safe) {
|
||||
return "\n" . '//]]>' . "\n" . $this->tags['javascriptend'];
|
||||
}
|
||||
return $this->tags['javascriptend'];
|
||||
}
|
||||
/**
|
||||
* Returns a JavaScript include tag (SCRIPT element). If the filename is prefixed with "/",
|
||||
|
@ -549,7 +554,7 @@ class JavascriptHelper extends AppHelper {
|
|||
$val = 'null';
|
||||
break;
|
||||
case (is_bool($val)):
|
||||
$val = ife($val, 'true', 'false');
|
||||
$val = ($val) ? 'true' : 'false';
|
||||
break;
|
||||
case (is_int($val)):
|
||||
$val = $val;
|
||||
|
|
|
@ -408,10 +408,17 @@ class PaginatorHelper extends AppHelper {
|
|||
$options);
|
||||
|
||||
$paging = $this->params($options['model']);
|
||||
$paging['pageCount'] = ife($paging['pageCount'] == 0, 1, $paging['pageCount']);
|
||||
|
||||
$start = ife($paging['count'] >= 1, ($paging['page'] - 1) * ($paging['options']['limit']) + 1, '0');
|
||||
$end = ife(($paging['count'] < ($start + $paging['options']['limit'] - 1)), $paging['count'], ($start + $paging['options']['limit'] - 1));
|
||||
if ($paging['pageCount'] == 0) {
|
||||
$paging['pageCount'] = 1;
|
||||
}
|
||||
$start = 0;
|
||||
if ($paging['count'] >= 1) {
|
||||
$start = (($paging['page'] - 1) * $paging['options']['limit']) + 1;
|
||||
}
|
||||
$end = $start + $paging['options']['limit'] - 1;
|
||||
if ($paging['count'] < $end) {
|
||||
$end = $paging['count'];
|
||||
}
|
||||
|
||||
switch ($options['format']) {
|
||||
case 'range':
|
||||
|
|
|
@ -77,14 +77,14 @@ class TextHelper extends AppHelper {
|
|||
$replace[] = '|' . $key . '|iu';
|
||||
$with[] = empty($value) ? $highlighter : $value;
|
||||
}
|
||||
|
||||
|
||||
return preg_replace($replace, $with, $text);
|
||||
} else {
|
||||
$phrase = '(' . $phrase . ')';
|
||||
if ($considerHtml) {
|
||||
$phrase = '(?![^<]+>)' . $phrase . '(?![^<]+>)';
|
||||
}
|
||||
|
||||
|
||||
return preg_replace('|'.$phrase.'|iu', $highlighter, $text);
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ class TextHelper extends AppHelper {
|
|||
preg_match_all('/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER);
|
||||
foreach ($tags as $tag) {
|
||||
if (preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/s', $tag[2])) {
|
||||
|
||||
|
||||
} else if (preg_match('/<[\w]+[^>]*>/s', $tag[0])) {
|
||||
array_unshift($openTags, $tag[2]);
|
||||
} else if (preg_match('/<\/([\w]+)[^>]*>/s', $tag[0], $closeTag)) {
|
||||
|
@ -202,7 +202,7 @@ class TextHelper extends AppHelper {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$truncate .= substr($tag[3], 0 , $left + $entitiesLength);
|
||||
break;
|
||||
|
@ -236,13 +236,13 @@ class TextHelper extends AppHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
$truncate = substr($truncate, 0, $spacepos);
|
||||
$truncate = substr($truncate, 0, $spacepos);
|
||||
}
|
||||
}
|
||||
|
||||
$truncate .= $ending;
|
||||
|
||||
if ($considerHtml) {
|
||||
|
||||
if ($considerHtml) {
|
||||
foreach ($openTags as $tag) {
|
||||
$truncate .= '</'.$tag.'>';
|
||||
}
|
||||
|
@ -275,21 +275,29 @@ class TextHelper extends AppHelper {
|
|||
return $this->truncate($text, $radius * 2, $ending);
|
||||
}
|
||||
|
||||
if ($radius < strlen($phrase)) {
|
||||
$radius = strlen($phrase);
|
||||
$phraseLen = strlen($phrase);
|
||||
if ($radius < $phraseLen) {
|
||||
$radius = $phraseLen;
|
||||
}
|
||||
|
||||
$pos = strpos(strtolower($text), strtolower($phrase));
|
||||
$startPos = ife($pos <= $radius, 0, $pos - $radius);
|
||||
$endPos = ife($pos + strlen($phrase) + $radius >= strlen($text), strlen($text), $pos + strlen($phrase) + $radius);
|
||||
$startPos = 0;
|
||||
if ($pos > $radius) {
|
||||
$startPos = $pos - $radius;
|
||||
}
|
||||
$textLen = strlen($text);
|
||||
$endPos = $pos + $phraseLen + $radius;
|
||||
if ($endPos >= $textLen) {
|
||||
$endPos = $textLen;
|
||||
}
|
||||
$excerpt = substr($text, $startPos, $endPos - $startPos);
|
||||
|
||||
if ($startPos != 0) {
|
||||
$excerpt = substr_replace($excerpt, $ending, 0, strlen($phrase));
|
||||
$excerpt = substr_replace($excerpt, $ending, 0, $phraseLen);
|
||||
}
|
||||
|
||||
if ($endPos != strlen($text)) {
|
||||
$excerpt = substr_replace($excerpt, $ending, -strlen($phrase));
|
||||
if ($endPos != $textLen) {
|
||||
$excerpt = substr_replace($excerpt, $ending, -$phraseLen);
|
||||
}
|
||||
|
||||
return $excerpt;
|
||||
|
|
|
@ -91,7 +91,7 @@ class TimeHelper extends AppHelper {
|
|||
$date = time();
|
||||
}
|
||||
|
||||
$ret = date("D, M jS Y, H:i", $date);
|
||||
$ret = i18n::strftime('%A, %B %e %Y, H:i', $date);
|
||||
return $this->output($ret);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -557,10 +557,8 @@ class View extends Object {
|
|||
* @return array An array containing the identity elements of an entity
|
||||
*/
|
||||
function entity() {
|
||||
return array_values(Set::filter(array(
|
||||
ife($this->association, $this->association, $this->model),
|
||||
$this->modelId, $this->field, $this->fieldSuffix
|
||||
)));
|
||||
$assoc = ($this->association) ? $this->association : $this->model;
|
||||
return array_values(Set::filter(array($assoc, $this->modelId, $this->field, $this->fieldSuffix)));
|
||||
}
|
||||
/**
|
||||
* Allows a template or element to set a variable that will be available in
|
||||
|
|
Loading…
Reference in a new issue