Browse Source

cs, more tests and todo for readme

euromark 12 years ago
parent
commit
3e8dac89fe

+ 1 - 1
Controller/Component/CalendarComponent.php

@@ -136,7 +136,7 @@ class CalendarComponent extends Component {
 	 * 1 => 01, 12 => 12
 	 */
 	public function asString($number, $digits = 2) {
-		$number = (string )$number;
+		$number = (string)$number;
 		$count = mb_strlen($number);
 		while ($count < $digits) {
 			$number = '0' . $number;

+ 1 - 1
Lib/HttpSocketLib.php

@@ -97,7 +97,7 @@ class HttpSocketLib {
 		# cached?
 		if ($options['cache']) {
 			$cacheName = md5($url);
-			$cacheConfig = $options['cache'] === true ? null: $options['cache'];
+			$cacheConfig = $options['cache'] === true ? null : $options['cache'];
 			$cacheConfig = !Cache::isInitialized($cacheConfig) ? null : $cacheConfig;
 
 			if ($options['clearCache']) {

+ 2 - 2
Lib/ImapLib.php

@@ -386,7 +386,7 @@ class ImapLib {
 
 	/** testing only **/
 	public function delete($emails, $delete = false) {
-		$emails = (array )$emails;
+		$emails = (array)$emails;
 		foreach ($emails as $email) {
 			if ($delete) {
 				imap_delete($this->stream, (int)$email);
@@ -404,7 +404,7 @@ class ImapLib {
 		if (!$this->stream) {
 			return false;
 		}
-		$emails = (array )$emails;
+		$emails = (array)$emails;
 		foreach ($emails as $key => $val) {
 			$emails[$key] = (int)$val;
 		}

+ 1 - 1
Lib/RandomLib.php

@@ -297,7 +297,7 @@ class RandomLib {
 				$pool = '2345679ACDEFHJKLMNPRSTUVWXYZ';
 				break;
 			default:
-				$pool = (string )$type;
+				$pool = (string)$type;
 				//$utf8 = ! UTF8::is_ascii($pool);
 				break;
 		}

+ 3 - 3
Lib/Utility/NumberLib.php

@@ -307,9 +307,9 @@ class NumberLib extends CakeNumber {
 	/**
 	 * Returns the English ordinal suffix (th, st, nd, etc) of a number.
 	 *
-	 * echo Num::ordinal(2); // "2nd"
-	 * echo Num::ordinal(10); // "10th"
-	 * echo Num::ordinal(33); // "33rd"
+	 * echo NumberLib::ordinal(2); // "nd"
+	 * echo NumberLib::ordinal(10); // "th"
+	 * echo NumberLib::ordinal(33); // "rd"
 	 *
 	 * @param integer $number
 	 * @return string

+ 2 - 2
Lib/Utility/Utility.php

@@ -344,13 +344,13 @@ class Utility {
 				$value = (double)$value;
 				break;
 			case 'array':
-				$value = (array )$value;
+				$value = (array)$value;
 				break;
 			case 'bool':
 				$value = (bool)$value;
 				break;
 			case 'string':
-				$value = (string )$value;
+				$value = (string)$value;
 				break;
 			default:
 				return null;

+ 5 - 0
README.md

@@ -124,6 +124,11 @@ For details on how to contribute please read the [CONTRIBUTING page](CONTRIBUTIN
 Licensed under [The MIT License](http://www.opensource.org/licenses/mit-license.php)
 unless specified otherwise (in the classes).
 
+### TODOs
+
+* Better test coverage (once it's >= 75% I will declare the plugin stable 1.0)
+* Use __d() and https://www.transifex.com/projects/p/tools/resources/ for translations
+
 ### Recent changes (possibly BC breaking)
 
 * 2013-02 Removed PasswordChangeBehavior in favor of its new name Passwordable.

+ 17 - 1
Test/Case/View/Helper/TextExtHelperTest.php

@@ -25,7 +25,7 @@ class TextExtHelperTest extends MyCakeTestCase {
 
 		$text = 'Text with a url euro@euro.de and more';
 		$expected = 'Text with a url <script language=javascript><!--
-	document.write(\'<a\'+ \' hre\'+ \'f="ma\'+ \'ilto:\'+ \'eu\'+ \'ro@\'+ \'euro\'+ \'.d\'+ \'e"\'+ \' t\'+ \'itle\'+ \'="\'+ \'Für \'+ \'den\'+ \' G\'+ \'ebra\'+ \'uch\'+ \' eines\'+ \' exte\'+ \'rn\'+ \'en E-\'+ \'Mail-P\'+ \'rogra\'+ \'mms"\'+ \' cl\'+ \'ass="e\'+ \'mail"\'+ \'>\');
+	document.write(\'<a\'+ \' hre\'+ \'f="ma\'+ \'ilto:\'+ \'eu\'+ \'ro@\'+ \'euro\'+ \'.d\'+ \'e"\'+ \' t\'+ \'itle\'+ \'="\'+ \'Für \'+ \'den\'+ \' G\'+ \'ebra\'+ \'uch\'+ \' eines\'+ \' exte\'+ \'rn\'+ \'en E-\'+ \'Mail-P\'+ \'rogra\'+ \'mms"\'+ \' cl\'+ \'ass="e\'+ \'mail"\'+ \'>\');
 	//--></script>
 		e&#117;&#x72;o<span>@</span>e&#x75;&#x72;&#111;&#x2e;&#x64;&#x65;
 
@@ -128,6 +128,13 @@ class TextExtHelperTest extends MyCakeTestCase {
 		$result = $this->Text->autoLink($text);
 		//pr(h($text));
 		$this->assertEquals($expected, $result);
+
+		// With umlauts
+		$text = 'Text <i>with a url</i> www.äöü.ag?id=2&sub=3 link';
+		$expected = 'Text &lt;i&gt;with a url&lt;/i&gt; <a href="http://www.äöü.ag?id=2&amp;sub=3">www.äöü.ag?id=2&amp;sub=3</a> link';
+		$result = $this->Text->autoLink($text);
+		//pr(h($text));
+		$this->assertEquals($expected, $result);
 	}
 
 /* from cake */
@@ -222,4 +229,13 @@ class TextExtHelperTest extends MyCakeTestCase {
 	public function testShortenText() {
 	}
 
+	public function testO() {
+		$result = $this->Text->ordinalNumber(1);
+		$this->assertSame('1st', $result);
+
+		$result = $this->Text->ordinalNumber(1, true);
+		//debug($result);
+		$this->assertSame('1<sup>st</sup>', $result);
+	}
+
 }

+ 41 - 4
View/Helper/FormExtHelper.php

@@ -436,6 +436,7 @@ class FormExtHelper extends FormHelper {
 	 * - `required` - manually set if the field is required.
 	 *   If not set, it depends on Configure::read('Validation.browserAutoRequire').
 	 *
+	 * @return string
 	 */
 	public function input($fieldName, $options = array()) {
 		$this->setEntity($fieldName);
@@ -514,6 +515,8 @@ class FormExtHelper extends FormHelper {
 
 	/**
 	 * quicklinks: clear, today, ...
+	 *
+	 * @return void
 	 */
 	public function dateScripts($scripts = array(), $quicklinks = false) {
 		foreach ($scripts as $script) {
@@ -566,7 +569,7 @@ class FormExtHelper extends FormHelper {
 	 *
 	 * @param mixed $field
 	 * @param mixed $options
-	 * @return
+	 * @return string
 	 */
 	public function dateTimeExt($field, $options = array()) {
 		$res = array();
@@ -823,6 +826,13 @@ class FormExtHelper extends FormHelper {
 		return $this->timeExt($field, $options);
 	}
 
+	/**
+	 * FormExtHelper::timeExt()
+	 *
+	 * @param string $field
+	 * @param array $options
+	 * @return string
+	 */
 	public function timeExt($field, $options = array()) {
 		$return = false;
 		if (isset($options['return'])) {
@@ -1014,6 +1024,11 @@ jQuery(\'' . $selector . '\').maxlength(' . $this->Js->object($settings, array('
 });';
 	}
 
+	/**
+	 * FormExtHelper::autoCompleteScripts()
+	 *
+	 * @return void
+	 */
 	public function autoCompleteScripts() {
 		if (!$this->scriptsAdded['autoComplete']) {
 			$this->Html->script('jquery/autocomplete/jquery.autocomplete', false);
@@ -1026,6 +1041,7 @@ jQuery(\'' . $selector . '\').maxlength(' . $this->Js->object($settings, array('
 	 * //TODO
 	 * @param jquery: defaults to null = no jquery markup
 	 * - url, data, object (one is necessary), options
+	 * @return string
 	 */
 	public function autoComplete($field = null, $options = array(), $jquery = null) {
 		$this->autoCompleteScripts();
@@ -1046,6 +1062,13 @@ jQuery(\'' . $selector . '\').maxlength(' . $this->Js->object($settings, array('
 		return $res;
 	}
 
+	/**
+	 * FormExtHelper::_autoCompleteJs()
+	 *
+	 * @param mixed $id
+	 * @param array $jquery
+	 * @return string
+	 */
 	protected function _autoCompleteJs($id, $jquery = array()) {
 		if (!empty($jquery['url'])) {
 			$var = '"' . $this->Html->url($jquery['url']) . '"';
@@ -1068,8 +1091,11 @@ jQuery(\'' . $selector . '\').maxlength(' . $this->Js->object($settings, array('
 		return $this->Html->scriptBlock($js);
 	}
 
-/** checkboxes **/
-
+	/**
+	 * FormExtHelper::checkboxScripts()
+	 *
+	 * @return void
+	 */
 	public function checkboxScripts() {
 		if (!$this->scriptsAdded['checkbox']) {
 			$this->Html->script('jquery/checkboxes/jquery.checkboxes', false);
@@ -1079,6 +1105,8 @@ jQuery(\'' . $selector . '\').maxlength(' . $this->Js->object($settings, array('
 
 	/**
 	 * Returns script + elements "all", "none" etc
+	 *
+	 * @return string
 	 */
 	public function checkboxScript($id) {
 		$this->checkboxScripts();
@@ -1090,6 +1118,12 @@ jQuery(\'' . $selector . '\').maxlength(' . $this->Js->object($settings, array('
 		return $this->Html->scriptBlock($js);
 	}
 
+	/**
+	 * FormExtHelper::checkboxButtons()
+	 *
+	 * @param bool $buttonsOnly
+	 * @return string
+	 */
 	public function checkboxButtons($buttonsOnly = false) {
 		$res = '<div>';
 		$res .= __('Selection') . ': ';
@@ -1107,8 +1141,11 @@ jQuery(\'' . $selector . '\').maxlength(' . $this->Js->object($settings, array('
 
 	/**
 	 * Displays a single checkbox - called for each
+	 * //FIXME
+	 *
+	 * @return string
 	 */
-	public function _checkbox($id, $group = null, $options = array()) {
+	protected function _checkbox($id, $group = null, $options = array()) {
 		$defaults = array(
 			'class' => 'checkboxToggle'
 		);