Skip to content
Permalink
Browse files

Fix coding standard issues in View/

  • Loading branch information...
markstory committed Mar 3, 2012
1 parent 0df239d commit acccdcde1f8818378c12459139e9cda6b46c705d
@@ -1,11 +1,5 @@
<?php
/**
* Backend for helpers.
*
* Internal methods for the Helpers.
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@@ -146,7 +140,6 @@ class Helper extends Object {
'autoplay', 'controls', 'loop', 'muted'
);
/**
* Default Constructor
*
@@ -255,11 +248,11 @@ public function webroot($file) {
$file = str_replace('/', '\\', $file);
}
if (file_exists(Configure::read('App.www_root') . 'theme' . DS . $this->theme . DS . $file)) {
if (file_exists(Configure::read('App.www_root') . 'theme' . DS . $this->theme . DS . $file)) {
$webPath = "{$this->request->webroot}theme/" . $theme . $asset[0];
} else {
$themePath = App::themePath($this->theme);
$path = $themePath . 'webroot' . DS . $file;
$path = $themePath . 'webroot' . DS . $file;
if (file_exists($path)) {
$webPath = "{$this->request->webroot}theme/" . $theme . $asset[0];
}
@@ -414,13 +407,13 @@ public function clean($output) {
*/
protected function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
if (!is_string($options)) {
$options = (array) $options + array('escape' => true);
$options = (array)$options + array('escape' => true);
if (!is_array($exclude)) {
$exclude = array();
}
$exclude = array('escape' => true) + array_flip($exclude);
$exclude = array('escape' => true) + array_flip($exclude);
$escape = $options['escape'];
$attributes = array();
@@ -532,7 +525,6 @@ public function setEntity($entity, $setScope = false) {
}
}
$this->_entityPath = $entity;
return;
}
/**
@@ -899,4 +891,5 @@ protected function _clean() {
} while ($oldstring != $this->_cleaned);
$this->_cleaned = str_replace(array("&amp;", "&lt;", "&gt;"), array("&amp;amp;", "&amp;lt;", "&amp;gt;"), $this->_cleaned);
}
}
@@ -317,4 +317,5 @@ protected function _writeFile($content, $timestamp, $useCallbacks = false) {
$file .= $content;
return cache('views' . DS . $cache, $file, $timestamp);
}
}
@@ -1,11 +1,5 @@
<?php
/**
* Automatic generation of HTML FORMs from given data.
*
* Used for scaffolding.
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@@ -154,11 +148,11 @@ protected function _getModel($model) {
}
$this->_models[$model] = $object;
if (!$object) {;
if (!$object) {
return null;
}
$this->fieldset[$model] = array('fields' => null, 'key' => $object->primaryKey, 'validates' => null);
$this->fieldset[$model] = array('fields' => null, 'key' => $object->primaryKey, 'validates' => null);
return $object;
}
@@ -183,58 +177,58 @@ protected function _getModel($model) {
* @return mixed information extracted for the special key and field in a model
*/
protected function _introspectModel($model, $key, $field = null) {
$object = $this->_getModel($model);
if (!$object) {
return;
}
$object = $this->_getModel($model);
if (!$object) {
return;
}
if ($key === 'key') {
return $this->fieldset[$model]['key'] = $object->primaryKey;
}
if ($key === 'key') {
return $this->fieldset[$model]['key'] = $object->primaryKey;
}
if ($key === 'fields') {
if (!isset($this->fieldset[$model]['fields'])) {
$fields = $this->fieldset[$model]['fields'] = $object->schema();
foreach ($object->hasAndBelongsToMany as $alias => $assocData) {
$this->fieldset[$object->alias]['fields'][$alias] = array('type' => 'multiple');
}
}
if (empty($field)) {
return $this->fieldset[$model]['fields'];
} elseif (isset($this->fieldset[$model]['fields'][$field])) {
return $this->fieldset[$model]['fields'][$field];
} else {
return isset($object->hasAndBelongsToMany[$field]) ? array('type' => 'multiple') : null;
if ($key === 'fields') {
if (!isset($this->fieldset[$model]['fields'])) {
$fields = $this->fieldset[$model]['fields'] = $object->schema();
foreach ($object->hasAndBelongsToMany as $alias => $assocData) {
$this->fieldset[$object->alias]['fields'][$alias] = array('type' => 'multiple');
}
}
if ($key === 'errors' && !isset($this->validationErrors[$model])) {
$this->validationErrors[$model] =& $object->validationErrors;
return $this->validationErrors[$model];
} elseif ($key === 'errors' && isset($this->validationErrors[$model])) {
return $this->validationErrors[$model];
if (empty($field)) {
return $this->fieldset[$model]['fields'];
} elseif (isset($this->fieldset[$model]['fields'][$field])) {
return $this->fieldset[$model]['fields'][$field];
} else {
return isset($object->hasAndBelongsToMany[$field]) ? array('type' => 'multiple') : null;
}
}
if ($key === 'validates' && !isset($this->fieldset[$model]['validates'])) {
$validates = array();
if (!empty($object->validate)) {
foreach ($object->validate as $validateField => $validateProperties) {
if ($this->_isRequiredField($validateProperties)) {
$validates[$validateField] = true;
}
if ($key === 'errors' && !isset($this->validationErrors[$model])) {
$this->validationErrors[$model] =& $object->validationErrors;
return $this->validationErrors[$model];
} elseif ($key === 'errors' && isset($this->validationErrors[$model])) {
return $this->validationErrors[$model];
}
if ($key === 'validates' && !isset($this->fieldset[$model]['validates'])) {
$validates = array();
if (!empty($object->validate)) {
foreach ($object->validate as $validateField => $validateProperties) {
if ($this->_isRequiredField($validateProperties)) {
$validates[$validateField] = true;
}
}
$this->fieldset[$model]['validates'] = $validates;
}
$this->fieldset[$model]['validates'] = $validates;
}
if ($key === 'validates') {
if (empty($field)) {
return $this->fieldset[$model]['validates'];
} else {
return isset($this->fieldset[$model]['validates'][$field]) ?
$this->fieldset[$model]['validates'] : null;
}
if ($key === 'validates') {
if (empty($field)) {
return $this->fieldset[$model]['validates'];
} else {
return isset($this->fieldset[$model]['validates'][$field]) ?
$this->fieldset[$model]['validates'] : null;
}
}
}
/**
@@ -675,9 +669,9 @@ public function error($field, $text = null, $options = array()) {
$tmp = array();
foreach ($error as &$e) {
if (isset($text[$e])) {
$tmp []= $text[$e];
$tmp[] = $text[$e];
} else {
$tmp []= $e;
$tmp[] = $e;
}
}
$text = $tmp;
@@ -702,16 +696,16 @@ public function error($field, $text = null, $options = array()) {
$listParams = array();
if (isset($options['listOptions'])) {
if (is_string($options['listOptions'])) {
$listParams []= $options['listOptions'];
$listParams[] = $options['listOptions'];
} else {
if (isset($options['listOptions']['itemOptions'])) {
$listParams []= $options['listOptions']['itemOptions'];
$listParams[] = $options['listOptions']['itemOptions'];
unset($options['listOptions']['itemOptions']);
} else {
$listParams []= array();
$listParams[] = array();
}
if (isset($options['listOptions']['tag'])) {
$listParams []= $options['listOptions']['tag'];
$listParams[] = $options['listOptions']['tag'];
unset($options['listOptions']['tag']);
}
array_unshift($listParams, $options['listOptions']);
@@ -1028,7 +1022,7 @@ public function input($fieldName, $options = array()) {
$options['maxlength'] = $fieldDef['length'];
}
if ($autoLength && $fieldDef['type'] == 'float') {
$options['maxlength'] = array_sum(explode(',', $fieldDef['length']))+1;
$options['maxlength'] = array_sum(explode(',', $fieldDef['length'])) + 1;
}
$divOptions = array();
@@ -1999,7 +1993,7 @@ public function month($fieldName, $attributes = array()) {
$attributes['value'] = null;
}
$defaults = array('monthNames' => true);
$attributes = array_merge($defaults, (array) $attributes);
$attributes = array_merge($defaults, (array)$attributes);
$monthNames = $attributes['monthNames'];
unset($attributes['monthNames']);
@@ -2229,7 +2223,7 @@ public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $a
'minYear' => null, 'maxYear' => null, 'separator' => '-',
'interval' => 1, 'monthNames' => true
);
$attributes = array_merge($defaults, (array) $attributes);
$attributes = array_merge($defaults, (array)$attributes);
if (isset($attributes['minuteInterval'])) {
$attributes['interval'] = $attributes['minuteInterval'];
unset($attributes['minuteInterval']);
@@ -2592,4 +2586,5 @@ protected function _initInputField($field, $options = array()) {
$this->_secure($secure, $fieldName);
return $result;
}
}
@@ -431,7 +431,7 @@ public function css($path, $rel = null, $options = array()) {
foreach ($path as $i) {
$out .= "\n\t" . $this->css($i, $rel, $options);
}
if (empty($options['block'])) {
if (empty($options['block'])) {
return $out . "\n";
}
return;
@@ -523,7 +523,7 @@ public function script($url, $options = array()) {
foreach ($url as $i) {
$out .= "\n\t" . $this->script($i, $options);
}
if (empty($options['block'])) {
if (empty($options['block'])) {
return $out . "\n";
}
return null;
@@ -645,7 +645,7 @@ public function style($data, $oneline = true) {
return $data;
}
$out = array();
foreach ($data as $key=> $value) {
foreach ($data as $key => $value) {
$out[] = $key . ':' . $value . ';';
}
if ($oneline) {
@@ -38,6 +38,7 @@
* @package Cake.View.Helper
*/
class JqueryEngineHelper extends JsBaseEngineHelper {
/**
* Option mappings for jQuery
*
@@ -149,7 +150,7 @@ protected function _methodTemplate($method, $template, $options, $extraSafeKeys
*/
public function get($selector) {
if ($selector == 'window' || $selector == 'document') {
$this->selection = $this->jQueryObject . '(' . $selector .')';
$this->selection = $this->jQueryObject . '(' . $selector . ')';
} else {
$this->selection = $this->jQueryObject . '("' . $selector . '")';
}
@@ -258,7 +259,7 @@ public function request($url, $options = array()) {
if (isset($options['update'])) {
$wrapCallbacks = isset($options['wrapCallbacks']) ? $options['wrapCallbacks'] : true;
$success = '';
if (isset($options['success']) AND !empty($options['success'])) {
if (isset($options['success']) && !empty($options['success'])) {
$success .= $options['success'];
}
$success .= $this->jQueryObject . '("' . $options['update'] . '").html(data);';
@@ -276,7 +277,7 @@ public function request($url, $options = array()) {
}
$options = $this->_prepareCallbacks('request', $options);
$options = $this->_parseOptions($options, $callbacks);
return $this->jQueryObject . '.ajax({' . $options .'});';
return $this->jQueryObject . '.ajax({' . $options . '});';
}
/**
@@ -356,4 +357,5 @@ public function serializeForm($options = array()) {
}
return $selector . $method;
}
}
@@ -1,9 +1,5 @@
<?php
/**
* JsEngineBaseClass
*
* PHP 5
*
* CakePHP : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc.
*
@@ -59,16 +55,6 @@ abstract class JsBaseEngineHelper extends AppHelper {
*/
protected $_callbackArguments = array();
/**
* Constructor.
*
* @param View $View
* @param array $settings
*/
public function __construct($View, $settings = array()) {
parent::__construct($View, $settings);
}
/**
* Create an `alert()` message in Javascript
*
@@ -602,4 +588,5 @@ protected function _toQuerystring($parameters) {
}
return $out;
}
}
@@ -430,4 +430,5 @@ protected function _getHtmlOptions($options, $additional = array()) {
}
return array($options, $htmlOptions);
}
}
Oops, something went wrong.

0 comments on commit acccdcd

Please sign in to comment.
You can’t perform that action at this time.