Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix coding standard issues in View/

  • Loading branch information...
commit acccdcde1f8818378c12459139e9cda6b46c705d 1 parent 0df239d
Mark Story markstory authored
17 lib/Cake/View/Helper.php
View
@@ -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);
}
+
}
1  lib/Cake/View/Helper/CacheHelper.php
View
@@ -317,4 +317,5 @@ protected function _writeFile($content, $timestamp, $useCallbacks = false) {
$file .= $content;
return cache('views' . DS . $cache, $file, $timestamp);
}
+
}
111 lib/Cake/View/Helper/FormHelper.php
View
@@ -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;
}
+
}
6 lib/Cake/View/Helper/HtmlHelper.php
View
@@ -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) {
8 lib/Cake/View/Helper/JqueryEngineHelper.php
View
@@ -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;
}
+
}
15 lib/Cake/View/Helper/JsBaseEngineHelper.php
View
@@ -1,9 +1,5 @@
<?php
/**
- * JsEngineBaseClass
- *
- * PHP 5
- *
* CakePHP : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc.
*
@@ -60,16 +56,6 @@
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
*
* @param string $message Message you want to alter.
@@ -602,4 +588,5 @@ protected function _toQuerystring($parameters) {
}
return $out;
}
+
}
1  lib/Cake/View/Helper/JsHelper.php
View
@@ -430,4 +430,5 @@ protected function _getHtmlOptions($options, $additional = array()) {
}
return array($options, $htmlOptions);
}
+
}
16 lib/Cake/View/Helper/MootoolsEngineHelper.php
View
@@ -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 @@
* @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 @@ public function serializeForm($options = array()) {
}
return $selection . $method;
}
+
}
9 lib/Cake/View/Helper/NumberHelper.php
View
@@ -33,11 +33,15 @@
*/
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);
12 lib/Cake/View/Helper/PaginatorHelper.php
View
@@ -690,7 +690,7 @@ public function numbers($options = array()) {
$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 @@ public function numbers($options = array()) {
$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 @@ public function numbers($options = array()) {
$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 @@ public function first($first = '<< first', $options = array()) {
$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 @@ public function last($last = 'last >>', $options = array()) {
}
return $out;
}
+
}
8 lib/Cake/View/Helper/PrototypeEngineHelper.php
View
@@ -31,6 +31,7 @@
* @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 @@ public function effect($name, $options = array()) {
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 @@ public function effect($name, $options = array()) {
* @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 @@ public function serializeForm($options = array()) {
}
return $selection . $method;
}
+
}
3  lib/Cake/View/Helper/RssHelper.php
View
@@ -326,7 +326,7 @@ public function elem($name, $attrib = array(), $content = null, $endTag = true)
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 @@ public function elem($name, $attrib = array(), $content = null, $endTag = true)
$xml = trim(substr($xml, strpos($xml, '?>') + 2));
return $xml;
}
+
}
1  lib/Cake/View/Helper/SessionHelper.php
View
@@ -159,4 +159,5 @@ public function flash($key = 'flash', $attrs = array()) {
public function valid() {
return CakeSession::valid();
}
+
}
1  lib/Cake/View/Helper/TextHelper.php
View
@@ -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);
1  lib/Cake/View/Helper/TimeHelper.php
View
@@ -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);
1  lib/Cake/View/HelperCollection.php
View
@@ -152,4 +152,5 @@ public function trigger($callback, $params = array(), $options = array()) {
}
return parent::trigger($callback, $params, $options);
}
+
}
11 lib/Cake/View/MediaView.php
View
@@ -58,6 +58,7 @@
* @package Cake.View
*/
class MediaView extends View {
+
/**
* Indicates whether response gzip compression was enabled for this class
*
@@ -66,15 +67,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
*
* @param string $view Not used
@@ -242,4 +234,5 @@ protected function _flushBuffer() {
@flush();
@ob_flush();
}
+
}
1  lib/Cake/View/ScaffoldView.php
View
@@ -87,4 +87,5 @@ protected function _getViewFileName($name = null) {
throw new MissingViewException($paths[0] . $name . $this->ext);
}
+
}
1  lib/Cake/View/ViewBlock.php
View
@@ -154,4 +154,5 @@ public function active() {
public function unclosed() {
return $this->_active;
}
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.