euromark 12 年之前
父节点
当前提交
6ab0f74fbf

+ 0 - 1
View/Helper/HcardHelper.php

@@ -78,7 +78,6 @@ class HcardHelper extends AppHelper {
 		$text .= '<span class="country-name">' . $data['country'] . '</span> ';
 		$text .= '</div>';
 		return $text;
-
 	}
 
 	/**

+ 12 - 10
View/Helper/IcalHelper.php

@@ -1,10 +1,9 @@
 <?php
 App::uses('AppHelper', 'View/Helper');
-
-App::uses('Helper', 'View');
+App::uses('IcalLib', 'Tools.Lib');
 
 /**
- * uses ical lib
+ * Uses ical lib
  * tipps see http://labs.iamkoa.net/2007/09/07/create-downloadable-ical-events-via-cake/
  *
  * needs ical layout
@@ -14,27 +13,28 @@ App::uses('Helper', 'View');
  */
 class IcalHelper extends AppHelper {
 
-	public $helpers = array(); //'Html'
-
 	public $Ical;
 
 	protected $_data = array();
 
-
 	public function __construct($View = null, $settings = array()) {
 		parent::__construct($View, $settings);
 
-		App::uses('IcalLib', 'Tools.Lib');
 		$this->Ical = new IcalLib();
 	}
 
-
+	/**
+	 * IcalHelper::reset()
+	 *
+	 * @return void
+	 */
 	public function reset() {
 		$this->$_data = array();
 	}
 
 	/**
-	 * add a new ical record
+	 * Add a new ical record.
+	 *
 	 * @return boolean $success
 	 */
 	public function add($data = array()) {
@@ -45,7 +45,9 @@ class IcalHelper extends AppHelper {
 	}
 
 	/**
-	 * returns complete ical calender file content to output
+	 * Returns complete ical calender file content to output.
+	 *
+	 * @return string
 	 * 2011-10-10 ms
 	 */
 	public function generate($globalData = array(), $addStartAndEnd = true) {

+ 17 - 17
View/Helper/LoremHelper.php

@@ -8,16 +8,16 @@ class LoremHelper extends AppHelper {
 	public $words = array();
 
 	/**
-	* Return placeholder text. By default, a single html-formatted paragraph.
-	* For a brief history of "lorem ipsum", see http://en.wikipedia.org/wiki/Lorem_ipsum
-	* also, thanks http://www.lipsum.org for all the faithful placeholder
-	*
-	* @param integer $number depending on the
-	* @param string $type trigger used to switch between words only, paragraph(s), or lists (ol/ul)
-	* @param array $attributes Additional HTML attributes of the list (ol/ul) tag, or paragraph (when applicable)
-	* @param array $itemAttributes Additional HTML attributes of the list item (LI) tag (when applicable)
-	* @return string placeholder text
-	*/
+	 * Return placeholder text. By default, a single html-formatted paragraph.
+	 * For a brief history of "lorem ipsum", see http://en.wikipedia.org/wiki/Lorem_ipsum
+	 * also, thanks http://www.lipsum.org for all the faithful placeholder
+	 *
+	 * @param integer $number depending on the
+	 * @param string $type trigger used to switch between words only, paragraph(s), or lists (ol/ul)
+	 * @param array $attributes Additional HTML attributes of the list (ol/ul) tag, or paragraph (when applicable)
+	 * @param array $itemAttributes Additional HTML attributes of the list item (LI) tag (when applicable)
+	 * @return string placeholder text
+	 */
 	public function ipsum($number = 1, $type = 'p', $attributes = array(), $itemAttributes = array()) {
 		if (!$this->words) {
 			$this->words = explode(' ', 'lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum');
@@ -56,13 +56,13 @@ class LoremHelper extends AppHelper {
 	}
 
 	/**
-	* Internal function to return a greeked sentence
-	*
-	* @param integer $maxWords maximum number of words for this sentence
-	* @param integer $minWords minimum number of words for this sentence
-	* @param boolean $punctuation if false it will not append random commas and ending period
-	* @return string greeked sentence
-	*/
+	 * Internal function to return a greeked sentence
+	 *
+	 * @param integer $maxWords maximum number of words for this sentence
+	 * @param integer $minWords minimum number of words for this sentence
+	 * @param boolean $punctuation if false it will not append random commas and ending period
+	 * @return string greeked sentence
+	 */
 	protected function _sentence($maxWords = 10, $minWords = 4, $punctuation = true) {
 		$string = '';
 		$numWords = rand($minWords, $maxWords);

+ 14 - 20
View/Helper/MyHelper.php

@@ -35,7 +35,7 @@ class MyHelper extends Helper {
 				continue;
 			}
 			App::uses($helperName . 'Helper', $plugin . 'View/Helper');
-			$helperFullName = $helperName.'Helper';
+			$helperFullName = $helperName . 'Helper';
 			$this->{$helperName} = new $helperFullName($this->_View, (array)$config);
 
 			if ($callbacks) {
@@ -136,18 +136,12 @@ class MyHelper extends Helper {
 		return sprintf($this->tags['time'], $attributes, $content);
 	}
 
-	# for convienience function Html::defaultLink()
-	protected $linkDefaults = null;
-
-	/*
-	# only one prefix at a time
-	public function url($url, $full = false) {
-		if (is_array($url)) {
-			$url['lang'] = 'deu';
-		}
-		return parent::url($url, $full);
-	}
-	*/
+	/**
+	 * For convienience function Html::defaultLink().
+	 *
+	 * @var array
+	 */
+	protected $_linkDefaults = null;
 
 	/**
 	 * keep named and query params for pagination/filter after edit etc
@@ -186,22 +180,22 @@ class MyHelper extends Helper {
 	 * 2010-01-23 ms
 	 */
 	public function defaultLink($title, $url = null, $options = array(), $confirmMessage = false) {
-		if ($this->linkDefaults === null) {
+		if ($this->_linkDefaults === null) {
 			if (!class_exists('CommonComponent')) {
 				App::uses('CommonComponent', 'Tools.Controller/Component');
 			}
-			$this->linkDefaults = CommonComponent::defaultUrlParams();
+			$this->_linkDefaults = CommonComponent::defaultUrlParams();
 		}
 		if (!defined('PREFIX_ADMIN')) {
 			define('PREFIX_ADMIN', 'admin');
 		}
 		if ($url !== null && is_array($url)) {
-			$url = array_merge($this->linkDefaults, $url);
+			$url = array_merge($this->_linkDefaults, $url);
 			if (!empty($url[PREFIX_ADMIN])) {
 				$options['rel'] = 'nofollow';
 			}
 		} elseif (is_array($title)) {
-			$title = array_merge($this->linkDefaults, $title);
+			$title = array_merge($this->_linkDefaults, $title);
 			if (!empty($title[PREFIX_ADMIN])) {
 				$options['rel'] = 'nofollow';
 			}
@@ -217,14 +211,14 @@ class MyHelper extends Helper {
 	 * 2010-01-23 ms
 	 */
 	public function defaultUrl($url = null, $full = false) {
-		if ($this->linkDefaults === null) {
+		if ($this->_linkDefaults === null) {
 			if (!class_exists('CommonComponent')) {
 				App::uses('CommonComponent', 'Tools.Controller/Component');
 			}
-			$this->linkDefaults = CommonComponent::defaultUrlParams();
+			$this->_linkDefaults = CommonComponent::defaultUrlParams();
 		}
 		if ($url !== null && is_array($url)) {
-			$url = array_merge($this->linkDefaults, $url);
+			$url = array_merge($this->_linkDefaults, $url);
 		}
 		return $this->url($url, $full);
 	}

+ 32 - 26
View/Helper/QrCodeHelper.php

@@ -48,8 +48,9 @@ class QrCodeHelper extends AppHelper {
 	const SIZE_Q = 66;
 	const SIZE_H = 74;
 
-	protected $engine = 'google';
-	protected $url = 'http://chart.apis.google.com/chart?';
+	public $engine = 'google';
+
+	public $url = 'http://chart.apis.google.com/chart?';
 
 	/**
 	 * necessary
@@ -57,11 +58,11 @@ class QrCodeHelper extends AppHelper {
 	 * - choe: string $outputEncoding
 	 * - chs: size (...x...)
 	 */
-	protected $options = array('cht'=>'qr', 'chl'=>'', 'choe'=>'', 'chs'=>'');
+	public $options = array('cht' => 'qr', 'chl' => '', 'choe' => '', 'chs' => '');
 
-	protected $ecLevels = array('H', 'Q', 'M', 'L'); # 30%..7%
+	public $ecLevels = array('H', 'Q', 'M', 'L'); # 30%..7%
 
-	protected $formattingTypes = array('url'=>'http', 'tel'=>'tel', 'sms'=>'smsto', 'card'=>'mecard');
+	public $formattingTypes = array('url' => 'http', 'tel' => 'tel', 'sms' => 'smsto', 'card' => 'mecard');
 
 	public function __construct(View $View, $settings = array()) {
 		parent::__construct($View, $settings);
@@ -120,19 +121,19 @@ class QrCodeHelper extends AppHelper {
 				$text = $this->Html->url($text, true);
 				break;
 			case 'sms':
-				$text = 'smsto:'.implode(':', (array)$text);
+				$text = 'smsto:' . implode(':', (array)$text);
 				break;
 			case 'tel':
-				$text = 'tel:'.$text;
+				$text = 'tel:' . $text;
 				break;
 			case 'email':
-				$text = 'mailto:'.$text;
+				$text = 'mailto:' . $text;
 				break;
 			case 'geo':
-				$text = 'geo:'.implode(',', (array)$text); #like 77.1,11.8
+				$text = 'geo:' . implode(',', (array)$text); #like 77.1,11.8
 				break;
 			case 'market':
-				$text = 'market://search?q=pname:'.$text;
+				$text = 'market://search?q=pname:' . $text;
 		}
 		return $text;
 	}
@@ -153,70 +154,70 @@ class QrCodeHelper extends AppHelper {
 		foreach ($data as $key => $val) {
 			switch ($key) {
 				case 'name':
-					$res[] = 'N:'.$val; # //TODO: support array
+					$res[] = 'N:' . $val; # //TODO: support array
 					break;
 				case 'nickname':
-					$res[] = 'NICKNAME:'.$val;
+					$res[] = 'NICKNAME:' . $val;
 					break;
 				case 'sound':
-					$res[] = 'SOUND:'.$val;
+					$res[] = 'SOUND:' . $val;
 					break;
 				case 'note':
 					$val = str_replace(';', ',', $val);
-					$res[] = 'NOTE:'.$val; //TODO: remove other invalid characters
+					$res[] = 'NOTE:' . $val; //TODO: remove other invalid characters
 					break;
 				case 'birthday':
 					if (strlen($val) !== 8) {
-						$val = substr($val, 0, 4).substr($val, 6, 2).substr($val, 10, 2);
+						$val = substr($val, 0, 4) . substr($val, 6, 2) . substr($val, 10, 2);
 					}
-					$res[] = 'BDAY:'.$val;
+					$res[] = 'BDAY:' . $val;
 					break;
 				case 'tel':
 					$val = (array)$val;
 					foreach ($val as $v) {
-						$res[] = 'TEL:'.$v;
+						$res[] = 'TEL:' . $v;
 					}
 					break;
 				case 'video':
 					$val = (array)$val;
 					foreach ($val as $v) {
-						$res[] = 'TEL-AV:'.$v;
+						$res[] = 'TEL-AV:' . $v;
 					}
 					break;
 				case 'address':
 					$val = (array)$val;
 					foreach ($val as $v) {
-						$res[] = 'ADR:'.$v; //TODO: reformat (array etc)
+						$res[] = 'ADR:' . $v; //TODO: reformat (array etc)
 					}
 					break;
 				case 'org':
 					$val = (array)$val;
 					foreach ($val as $v) {
-						$res[] = 'ORG:'.$v;
+						$res[] = 'ORG:' . $v;
 					}
 					break;
 				case 'role':
 					$val = (array)$val;
 					foreach ($val as $v) {
-						$res[] = 'ROLE:'.$v;
+						$res[] = 'ROLE:' . $v;
 					}
 					break;
 				case 'email':
 					$val = (array)$val;
 					foreach ($val as $v) {
-						$res[] = 'EMAIL:'.$v;
+						$res[] = 'EMAIL:' . $v;
 					}
 					break;
 				case 'url':
 					$val = (array)$val;
 					foreach ($val as $v) {
-						$res[] = 'URL:'.$this->Html->url($v, true);
+						$res[] = 'URL:' . $this->Html->url($v, true);
 					}
 					break;
 			}
 		}
 
-		return 'MECARD:'.implode(';', $res).';';
+		return 'MECARD:' . implode(';', $res) . ';';
 	}
 
 	/**
@@ -257,7 +258,7 @@ class QrCodeHelper extends AppHelper {
 		}
 		$value = (int)$value;
 		if ($value >= self::MIN_SIZE && $value <= self::MAX_SIZE) {
-			$this->options['chs'] = $value.'x'.$value;
+			$this->options['chs'] = $value. 'x' . $value;
 			return true;
 		}
 		return false;
@@ -274,7 +275,7 @@ class QrCodeHelper extends AppHelper {
 			if ($margin === null) {
 				$margin = 4; # minimum
 			}
-			$this->options['chld'] = strtoupper($level).'|'.$margin;
+			$this->options['chld'] = strtoupper($level). '|' . $margin;
 			return true;
 		}
 		return false;
@@ -284,6 +285,11 @@ class QrCodeHelper extends AppHelper {
 		//TODO
 	}
 
+	/**
+	 * QrCodeHelper::reset()
+	 *
+	 * @return void
+	 */
 	public function reset() {
 		$this->setSize(self::DEFAULT_SIZE);
 		//$this->setLevel(QS_CODE_DEFAULT_LEVEL);

+ 121 - 121
View/Helper/TreeHelper.php

@@ -14,83 +14,83 @@
 App::uses('AppHelper', 'View/Helper');
 
 /**
- * TreeHelper class
+ * TreeHelper class.
  *
  * Helper to generate tree representations of MPTT or recursively nested data
  */
 class TreeHelper extends AppHelper {
 
-/**
- * Settings property
- *
- * @var array
- */
+	/**
+	 * Settings property
+	 *
+	 * @var array
+	 */
 	protected $_settings = array();
 
-/**
- * typeAttributes property
- *
- * @var array
- */
+	/**
+	 * typeAttributes property
+	 *
+	 * @var array
+	 */
 	protected $_typeAttributes = array();
 
-/**
- * typeAttributesNext property
- *
- * @var array
- */
+	/**
+	 * typeAttributesNext property
+	 *
+	 * @var array
+	 */
 	protected $_typeAttributesNext = array();
 
-/**
- * itemAttributes property
- *
- * @var array
- */
+	/**
+	 * itemAttributes property
+	 *
+	 * @var array
+	 */
 	protected $_itemAttributes = array();
 
-/**
- * Helpers variable
- *
- * @var array
- */
+	/**
+	 * Helpers variable
+	 *
+	 * @var array
+	 */
 	public $helpers = array('Html');
 
-/**
- * Tree generation method.
- *
- * Accepts the results of
- * 	find('all', array('fields' => array('lft', 'rght', 'whatever'), 'order' => 'lft ASC'));
- * 	children(); // if you have the tree behavior of course!
- * or 	find('threaded'); and generates a tree structure of the data.
- *
- * Settings (2nd parameter):
- *	'model' => name of the model (key) to look for in the data array. defaults to the first model for the current
- * controller. If set to false 2d arrays will be allowed/expected.
- *	'alias' => the array key to output for a simple ul (not used if element or callback is specified)
- *	'type' => type of output defaults to ul
- *	'itemType => type of item output default to li
- *	'id' => id for top level 'type'
- *	'class' => class for top level 'type'
- *	'element' => path to an element to render to get node contents.
- *	'callback' => callback to use to get node contents. e.g. array(&$anObject, 'methodName') or 'floatingMethod'
- *	'autoPath' => array($left, $right [$classToAdd = 'active']) if set any item in the path will have the class $classToAdd added. MPTT only.
- *  'hideUnrelated' => if unrelated (not children, not siblings) should be hidden, needs 'treePath', true/false or array/string for callback
- *  'treePath' => treePath to insert into callback/element
- *	'left' => name of the 'lft' field if not lft. only applies to MPTT data
- *	'right' => name of the 'rght' field if not rght. only applies to MPTT data
- *	'depth' => used internally when running recursively, can be used to override the depth in either mode.
- *  'maxDepth' => used to control the depth upto which to generate tree
- *	'firstChild' => used internally when running recursively.
- *	'splitDepth' => if multiple "parallel" types are required, instead of one big type, nominate the depth to do so here
- *		example: useful if you have 30 items to display, and you'd prefer they appeared in the source as 3 lists of 10 to be able to
- *		style/float them.
- *	'splitCount' => the number of "parallel" types. defaults to null (disabled) set the splitCount,
- *		and optionally set the splitDepth to get parallel lists
- *
- * @param array $data data to loop on
- * @param array $settings
- * @return string html representation of the passed data
- */
+	/**
+	 * Tree generation method.
+	 *
+	 * Accepts the results of
+	 * 	find('all', array('fields' => array('lft', 'rght', 'whatever'), 'order' => 'lft ASC'));
+	 * 	children(); // if you have the tree behavior of course!
+	 * or 	find('threaded'); and generates a tree structure of the data.
+	 *
+	 * Settings (2nd parameter):
+	 *	'model' => name of the model (key) to look for in the data array. defaults to the first model for the current
+	 * controller. If set to false 2d arrays will be allowed/expected.
+	 *	'alias' => the array key to output for a simple ul (not used if element or callback is specified)
+	 *	'type' => type of output defaults to ul
+	 *	'itemType => type of item output default to li
+	 *	'id' => id for top level 'type'
+	 *	'class' => class for top level 'type'
+	 *	'element' => path to an element to render to get node contents.
+	 *	'callback' => callback to use to get node contents. e.g. array(&$anObject, 'methodName') or 'floatingMethod'
+	 *	'autoPath' => array($left, $right [$classToAdd = 'active']) if set any item in the path will have the class $classToAdd added. MPTT only.
+	 *  'hideUnrelated' => if unrelated (not children, not siblings) should be hidden, needs 'treePath', true/false or array/string for callback
+	 *  'treePath' => treePath to insert into callback/element
+	 *	'left' => name of the 'lft' field if not lft. only applies to MPTT data
+	 *	'right' => name of the 'rght' field if not rght. only applies to MPTT data
+	 *	'depth' => used internally when running recursively, can be used to override the depth in either mode.
+	 *  'maxDepth' => used to control the depth upto which to generate tree
+	 *	'firstChild' => used internally when running recursively.
+	 *	'splitDepth' => if multiple "parallel" types are required, instead of one big type, nominate the depth to do so here
+	 *		example: useful if you have 30 items to display, and you'd prefer they appeared in the source as 3 lists of 10 to be able to
+	 *		style/float them.
+	 *	'splitCount' => the number of "parallel" types. defaults to null (disabled) set the splitCount,
+	 *		and optionally set the splitDepth to get parallel lists
+	 *
+	 * @param array $data data to loop on
+	 * @param array $settings
+	 * @return string html representation of the passed data
+	 */
 	public function generate($data, $settings = array()) {
 		if (!$data) {
 			return '';
@@ -328,17 +328,17 @@ class TreeHelper extends AppHelper {
 		return $return;
 	}
 
-/**
- * addItemAttribute function
- *
- * Called to modify the attributes of the next <item> to be processed
- * Note that the content of a 'node' is processed before generating its wrapping <item> tag
- *
- * @param string $id
- * @param string $key
- * @param mixed $value
- * @return void
- */
+	/**
+	 * addItemAttribute function
+	 *
+	 * Called to modify the attributes of the next <item> to be processed
+	 * Note that the content of a 'node' is processed before generating its wrapping <item> tag
+	 *
+	 * @param string $id
+	 * @param string $key
+	 * @param mixed $value
+	 * @return void
+	 */
 	public function addItemAttribute($id = '', $key = '', $value = null) {
 		if (!is_null($value)) {
 			$this->_itemAttributes[$id][$key] = $value;
@@ -347,33 +347,33 @@ class TreeHelper extends AppHelper {
 		}
 	}
 
-/**
- * addTypeAttribute function
- *
- * Called to modify the attributes of the next <type> to be processed
- * Note that the content of a 'node' is processed before generating its wrapping <type> tag (if appropriate)
- * An 'interesting' case is that of a first child with children. To generate the output
- * <ul> (1)
- *      <li>XYZ (3)
- *              <ul> (2)
- *                      <li>ABC...
- *                      ...
- *              </ul>
- *              ...
- * The processing order is indicated by the numbers in brackets.
- * attributes are allways applied to the next type (2) to be generated
- * to set properties of the holding type - pass 'previous' for the 4th param
- * i.e.
- * // Hide children (2)
- * $tree->addTypeAttribute('style', 'display', 'hidden');
- * // give top level type (1) a class
- * $tree->addTypeAttribute('class', 'hasHiddenGrandChildren', null, 'previous');
- *
- * @param string $id
- * @param string $key
- * @param mixed $value
- * @return void
- */
+	/**
+	 * addTypeAttribute function
+	 *
+	 * Called to modify the attributes of the next <type> to be processed
+	 * Note that the content of a 'node' is processed before generating its wrapping <type> tag (if appropriate)
+	 * An 'interesting' case is that of a first child with children. To generate the output
+	 * <ul> (1)
+	 *      <li>XYZ (3)
+	 *              <ul> (2)
+	 *                      <li>ABC...
+	 *                      ...
+	 *              </ul>
+	 *              ...
+	 * The processing order is indicated by the numbers in brackets.
+	 * attributes are allways applied to the next type (2) to be generated
+	 * to set properties of the holding type - pass 'previous' for the 4th param
+	 * i.e.
+	 * // Hide children (2)
+	 * $tree->addTypeAttribute('style', 'display', 'hidden');
+	 * // give top level type (1) a class
+	 * $tree->addTypeAttribute('class', 'hasHiddenGrandChildren', null, 'previous');
+	 *
+	 * @param string $id
+	 * @param string $key
+	 * @param mixed $value
+	 * @return void
+	 */
 	public function addTypeAttribute($id = '', $key = '', $value = null, $previousOrNext = 'next') {
 		$var = '_typeAttributes';
 		$firstChild = isset($this->_settings['firstChild']) ? $this->_settings['firstChild'] : true;
@@ -387,21 +387,21 @@ class TreeHelper extends AppHelper {
 		}
 	}
 
-/**
- * supressChildren method
- *
- * @return void
- */
+	/**
+	 * supressChildren method
+	 *
+	 * @return void
+	 */
 	public function supressChildren() {
 	}
 
-/**
- * suffix method
- *
- * Used to close and reopen a ul/ol to allow easier listings
- *
- * @return void
- */
+	/**
+	 * Suffix method.
+	 *
+	 * Used to close and reopen a ul/ol to allow easier listings
+	 *
+	 * @return void
+	 */
 	protected function _suffix($reset = false) {
 		static $_splitCount = 0;
 		static $_splitCounter = 0;
@@ -439,15 +439,15 @@ class TreeHelper extends AppHelper {
 		}
 	}
 
-/**
- * attributes function
- *
- * Logic to apply styles to tags.
- *
- * @param mixed $rType
- * @param array $elementData
- * @return void
- */
+	/**
+	 * Attributes function.
+	 *
+	 * Logic to apply styles to tags.
+	 *
+	 * @param mixed $rType
+	 * @param array $elementData
+	 * @return void
+	 */
 	protected function _attributes($rType, $elementData = array(), $clear = true) {
 		extract($this->_settings);
 		if ($rType == $type) {

+ 1 - 3
View/Helper/WeatherHelper.php

@@ -38,12 +38,10 @@ class WeatherHelper extends AppHelper {
 		}
 
 		$res .= '<table><tr>';
-
 		//$res .= '<td>'.[].'</td>';
-
 		$res .= '</tr></table>';
 
-		$res .= '<h1>'.$weather['city'].':</h1>';
+		$res .= '<h1>' . h($weather['city']) . ':</h1>';
 
 		return $res;
 	}