Fix coding standard issues in View/

This commit is contained in:
mark_story 2012-03-03 17:10:12 -05:00
parent 0df239de2b
commit acccdcde1f
19 changed files with 103 additions and 129 deletions

View file

@ -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 @@ class Helper extends Object {
$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 @@ class Helper extends Object {
*/
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 @@ class Helper extends Object {
}
}
$this->_entityPath = $entity;
return;
}
/**
@ -899,4 +891,5 @@ class Helper extends Object {
} while ($oldstring != $this->_cleaned);
$this->_cleaned = str_replace(array("&amp;", "&lt;", "&gt;"), array("&amp;amp;", "&amp;lt;", "&amp;gt;"), $this->_cleaned);
}
}

View file

@ -317,4 +317,5 @@ class CacheHelper extends AppHelper {
$file .= $content;
return cache('views' . DS . $cache, $file, $timestamp);
}
}

View file

@ -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 @@ class FormHelper extends AppHelper {
}
$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 @@ class FormHelper extends AppHelper {
* @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 ($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 === '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;
}
}
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;
}
}
$this->fieldset[$model]['validates'] = $validates;
}
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;
}
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 @@ class FormHelper extends AppHelper {
$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 @@ class FormHelper extends AppHelper {
$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 @@ class FormHelper extends AppHelper {
$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 @@ class FormHelper extends AppHelper {
$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 @@ class FormHelper extends AppHelper {
'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 @@ class FormHelper extends AppHelper {
$this->_secure($secure, $fieldName);
return $result;
}
}

View file

@ -431,7 +431,7 @@ class HtmlHelper extends AppHelper {
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 @@ class HtmlHelper extends AppHelper {
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 @@ class HtmlHelper extends AppHelper {
return $data;
}
$out = array();
foreach ($data as $key=> $value) {
foreach ($data as $key => $value) {
$out[] = $key . ':' . $value . ';';
}
if ($oneline) {

View file

@ -38,6 +38,7 @@ App::uses('JsBaseEngineHelper', 'View/Helper');
* @package Cake.View.Helper
*/
class JqueryEngineHelper extends JsBaseEngineHelper {
/**
* Option mappings for jQuery
*
@ -149,7 +150,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
*/
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 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
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 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
}
$options = $this->_prepareCallbacks('request', $options);
$options = $this->_parseOptions($options, $callbacks);
return $this->jQueryObject . '.ajax({' . $options .'});';
return $this->jQueryObject . '.ajax({' . $options . '});';
}
/**
@ -356,4 +357,5 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
}
return $selector . $method;
}
}

View file

@ -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 @@ abstract class JsBaseEngineHelper extends AppHelper {
}
return $out;
}
}

View file

@ -430,4 +430,5 @@ class JsHelper extends AppHelper {
}
return array($options, $htmlOptions);
}
}

View file

@ -1,17 +1,5 @@
<?php
/**
* MooTools Engine Helper for JsHelper
*
* Provides MooTools specific Javascript for JsHelper.
* Assumes that you have the following MooTools packages
*
* - Remote, Remote.HTML, Remote.JSON
* - Fx, Fx.Tween, Fx.Morph
* - Selectors, DomReady,
* - Drag, Drag.Move
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@ -41,6 +29,7 @@ App::uses('JsBaseEngineHelper', 'View/Helper');
* @package Cake.View.Helper
*/
class MootoolsEngineHelper extends JsBaseEngineHelper {
/**
* Option mappings for MooTools
*
@ -133,7 +122,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
public function get($selector) {
$this->_multipleSelection = false;
if ($selector == 'window' || $selector == 'document') {
$this->selection = "$(" . $selector .")";
$this->selection = "$(" . $selector . ")";
return $this;
}
if (preg_match('/^#[^\s.]+$/', $selector)) {
@ -383,4 +372,5 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
}
return $selection . $method;
}
}

View file

@ -33,11 +33,15 @@ App::uses('AppHelper', 'View/Helper');
*/
class NumberHelper extends AppHelper {
/** CakeNumber instance
/**
* CakeNumber instance
*
* @var CakeNumber
*/
protected $_engine = null;
/* Default Constructor
/**
* Default Constructor
*
* ### Settings:
*
@ -46,6 +50,7 @@ class NumberHelper extends AppHelper {
*
* @param View $View The View this helper is being attached to.
* @param array $settings Configuration settings for the helper
* @throws CakeException When the engine class could not be found.
*/
public function __construct(View $View, $settings = array()) {
$settings = Set::merge(array('engine' => 'CakeNumber'), $settings);

View file

@ -690,7 +690,7 @@ class PaginatorHelper extends AppHelper {
$start = $params['page'] - ($modulus - ($end - $params['page']));
if ($start <= 1) {
$start = 1;
$end = $params['page'] + ($modulus - $params['page']) + 1;
$end = $params['page'] + ($modulus - $params['page']) + 1;
}
if ($first && $start > 1) {
@ -705,8 +705,7 @@ class PaginatorHelper extends AppHelper {
$out .= $before;
for ($i = $start; $i < $params['page']; $i++) {
$out .= $this->Html->tag($tag, $this->link($i, array('page' => $i), $options), compact('class'))
. $separator;
$out .= $this->Html->tag($tag, $this->link($i, array('page' => $i), $options), compact('class')) . $separator;
}
if ($class) {
@ -719,8 +718,7 @@ class PaginatorHelper extends AppHelper {
$start = $params['page'] + 1;
for ($i = $start; $i < $end; $i++) {
$out .= $this->Html->tag($tag, $this->link($i, array('page' => $i), $options), compact('class'))
. $separator;
$out .= $this->Html->tag($tag, $this->link($i, array('page' => $i), $options), compact('class')) . $separator;
}
if ($end != $params['page']) {
@ -823,8 +821,7 @@ class PaginatorHelper extends AppHelper {
$out .= $after;
} elseif ($params['page'] > 1 && is_string($first)) {
$options += array('rel' => 'first');
$out = $this->Html->tag($tag, $this->link($first, array('page' => 1), $options), compact('class'))
. $after;
$out = $this->Html->tag($tag, $this->link($first, array('page' => 1), $options), compact('class')) . $after;
}
return $out;
}
@ -897,4 +894,5 @@ class PaginatorHelper extends AppHelper {
}
return $out;
}
}

View file

@ -31,6 +31,7 @@ App::uses('JsBaseEngineHelper', 'View/Helper');
* @package Cake.View.Helper
*/
class PrototypeEngineHelper extends JsBaseEngineHelper {
/**
* Is the current selection a multiple selection? or is it just a single element.
*
@ -119,7 +120,7 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
public function get($selector) {
$this->_multiple = false;
if ($selector == 'window' || $selector == 'document') {
$this->selection = "$(" . $selector .")";
$this->selection = "$(" . $selector . ")";
return $this;
}
if (preg_match('/^#[^\s.]+$/', $selector)) {
@ -219,7 +220,7 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
case 'fadeIn':
case 'fadeOut':
$name = ($name == 'fadeIn') ? 'appear' : 'fade';
$effect = $this->selection . '.' . $name .'(' . substr($optionString, 2) . ');';
$effect = $this->selection . '.' . $name . '(' . substr($optionString, 2) . ');';
break;
}
return $effect;
@ -233,7 +234,7 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
* @return string The completed ajax call.
*/
public function request($url, $options = array()) {
$url = '"'. $this->url($url) . '"';
$url = '"' . $this->url($url) . '"';
$options = $this->_mapOptions('request', $options);
$type = '.Request';
$data = null;
@ -365,4 +366,5 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
}
return $selection . $method;
}
}

View file

@ -326,7 +326,7 @@ class RssHelper extends AppHelper {
if ($cdata && !empty($content)) {
$content = '<![CDATA[' . $content . ']]>';
}
$xml .= '>' . $content . '</' . $name. '>';
$xml .= '>' . $content . '</' . $name . '>';
$elem = Xml::build($xml, array('return' => 'domdocument'));
$nodes = $elem->getElementsByTagName($bareName);
foreach ($attrib as $key => $value) {
@ -341,4 +341,5 @@ class RssHelper extends AppHelper {
$xml = trim(substr($xml, strpos($xml, '?>') + 2));
return $xml;
}
}

View file

@ -159,4 +159,5 @@ class SessionHelper extends AppHelper {
public function valid() {
return CakeSession::valid();
}
}

View file

@ -63,6 +63,7 @@ class TextHelper extends AppHelper {
*
* @param View $View the view object the helper is attached to.
* @param array $settings Settings array Settings array
* @throws CakeException when the engine class could not be found.
*/
public function __construct(View $View, $settings = array()) {
$settings = Set::merge(array('engine' => 'String'), $settings);

View file

@ -47,6 +47,7 @@ class TimeHelper extends AppHelper {
*
* @param View $View the view object the helper is attached to.
* @param array $settings Settings array Settings array
* @throws CakeException When the engine class could not be found.
*/
public function __construct(View $View, $settings = array()) {
$settings = Set::merge(array('engine' => 'CakeTime'), $settings);

View file

@ -152,4 +152,5 @@ class HelperCollection extends ObjectCollection implements CakeEventListener {
}
return parent::trigger($callback, $params, $options);
}
}

View file

@ -58,6 +58,7 @@ App::uses('CakeRequest', 'Network');
* @package Cake.View
*/
class MediaView extends View {
/**
* Indicates whether response gzip compression was enabled for this class
*
@ -65,15 +66,6 @@ class MediaView extends View {
*/
protected $_compressionEnabled = false;
/**
* Constructor
*
* @param Controller $controller The controller with viewVars
*/
public function __construct(Controller $controller = null) {
parent::__construct($controller);
}
/**
* Display or download the given file
*
@ -242,4 +234,5 @@ class MediaView extends View {
@flush();
@ob_flush();
}
}

View file

@ -87,4 +87,5 @@ class ScaffoldView extends ThemeView {
throw new MissingViewException($paths[0] . $name . $this->ext);
}
}

View file

@ -154,4 +154,5 @@ class ViewBlock {
public function unclosed() {
return $this->_active;
}
}