浏览代码

documentation

euromark 12 年之前
父节点
当前提交
1044f8d23f

+ 31 - 6
Lib/Bootstrap/MyBootstrap.php

@@ -261,6 +261,7 @@ function isEmpty($var = null) {
  *
  * //TODO: use Debugger::exportVar() instead?
  *
+ * @param mixed $value
  * @return type (NULL, array, bool, float, int, string, object, unknown) + value
  * 2009-03-03 ms
  */
@@ -340,7 +341,11 @@ function entDec($text, $quoteStyle = ENT_QUOTES) {
 }
 
 /**
- * focus is on the filename (without path)
+ * Focus is on the filename (without path)
+ *
+ * //TODO: switch parameters!!!
+ *
+ * @return mixed
  * 2011-06-02 ms
  */
 function extractFileInfo($type = null, $filename) {
@@ -352,7 +357,7 @@ function extractFileInfo($type = null, $filename) {
 	switch ($type) {
 		case 'extension':
 		case 'ext':
-			$res = ($pos !== false) ? substr($filename, $pos+1) : '';
+			$res = ($pos !== false) ? substr($filename, $pos + 1) : '';
 			break;
 		case 'filename':
 		case 'file':
@@ -365,13 +370,18 @@ function extractFileInfo($type = null, $filename) {
 }
 
 /**
- * uses native PHP function to retrieve infos about a filename etc.
+ * Uses native PHP function to retrieve infos about a filename etc.
+ * Improves it by not returning non-file-name characters from url files if specified.
+ * So "filename.ext?foo=bar#hash" would simply be "filename.ext" then.
+ *
+ * //TODO: switch parameters!!!
+ *
  * @param string type (extension/ext, filename/file, basename/base, dirname/dir)
  * @param string filename to check on
- * //TODO: switch parameters!!!
+ * @return mixed
  * 2009-01-22 ms
  */
-function extractPathInfo($type = null, $filename) {
+function extractPathInfo($type = null, $filename, $fromUrl = false) {
 	switch ($type) {
 		case 'extension':
 		case 'ext':
@@ -392,7 +402,16 @@ function extractPathInfo($type = null, $filename) {
 		default:
 			$infoType = null;
 	}
-	return pathinfo($filename, $infoType);
+	$result = pathinfo($filename, $infoType);
+	if ($fromUrl) {
+		if (($pos = strpos($result, '#')) !== false) {
+			$result = substr($result, 0, $pos);
+		}
+		if (($pos = strpos($result, '?')) !== false) {
+			$result = substr($result, 0, $pos);
+		}
+	}
+	return $result;
 }
 
 /**
@@ -402,6 +421,7 @@ function extractPathInfo($type = null, $filename) {
  * @param boolean $collapsedAndExpandable
  * @param array $options
  * - class, showHtml, showFrom, jquery, returns, debug
+ * @return string HTML
  * 2011-01-19 ms
  */
 function pre($var, $collapsedAndExpandable = false, $options = array()) {
@@ -451,6 +471,7 @@ function pre($var, $collapsedAndExpandable = false, $options = array()) {
 
 /**
  * Checks if the string [$haystack] contains [$needle]
+ *
  * @param string $haystack Input string.
  * @param string $needle Needed char or string.
  * @return boolean
@@ -462,6 +483,7 @@ function contains($haystack, $needle, $caseSensitive = false) {
 
 /**
  * Checks if the string [$haystack] starts with [$needle]
+ *
  * @param string $haystack Input string.
  * @param string $needle Needed char or string.
  * @return boolean
@@ -475,6 +497,7 @@ function startsWith($haystack, $needle, $caseSensitive = false) {
 
 /**
  * Checks if the String [$haystack] ends with [$needle]
+ *
  * @param string $haystack Input string.
  * @param string $needle Needed char or string
  * @return boolean
@@ -490,6 +513,7 @@ function endsWith($haystack, $needle, $caseSensitive = false) {
  * base64 encode and replace chars base64 uses that would mess up the url
  * only needed for named params to be safely passed (if urlencode is not used)
  *
+ * @deprecated Use Utility::urlEncode().
  * @return string or NULL
  */
 function base64UrlEncode($fieldContent) {
@@ -504,6 +528,7 @@ function base64UrlEncode($fieldContent) {
  * base64 decode and undo replacing of chars base64 uses that would mess up the url
  * only needed for named params to be safely passed (if urlencode is not used)
  *
+ * @deprecated Use Utility::urlDecode().
  * @return string or NULL
  */
 function base64UrlDecode($fieldContent) {

+ 0 - 9
Test/Case/Controller/Component/AutoLoginComponentTest.php

@@ -14,7 +14,6 @@ class AutoLoginComponentTest extends CakeTestCase {
 	/**
 	 * setUp method
 	 *
-	 * @access public
 	 * @return void
 	 */
 	public function setUp() {
@@ -30,7 +29,6 @@ class AutoLoginComponentTest extends CakeTestCase {
 	/**
 	 * Tear-down method. Resets environment state.
 	 *
-	 * @access public
 	 * @return void
 	 */
 	public function tearDown() {
@@ -102,34 +100,29 @@ class AutoLoginTestController extends Controller {
 	 * name property
 	 *
 	 * @var string 'SecurityTest'
-	 * @access public
 	 */
 
 	/**
 	 * components property
 	 *
 	 * @var array
-	 * @access public
 	 */
 	public $components = array('Tools.AutoLogin');
 	/**
 	 * failed property
 	 *
 	 * @var boolean
-	 * @access public
 	 */
 	public $failed = false;
 	/**
 	 * Used for keeping track of headers in test
 	 *
 	 * @var array
-	 * @access public
 	 */
 	public $testHeaders = array();
 	/**
 	 * fail method
 	 *
-	 * @access public
 	 * @return void
 	 */
 	public function fail() {
@@ -141,7 +134,6 @@ class AutoLoginTestController extends Controller {
 	 * @param mixed $option
 	 * @param mixed $code
 	 * @param mixed $exit
-	 * @access public
 	 * @return void
 	 */
 	public function redirect($url, $status = null, $exit = true) {
@@ -152,7 +144,6 @@ class AutoLoginTestController extends Controller {
 	 *
 	 * @param string $status
 	 * @return void
-	 * @access public
 	 */
 	public function header($status) {
 		$this->testHeaders[] = $status;

+ 0 - 3
Test/Case/Lib/Utility/FileLibTest.php

@@ -9,7 +9,6 @@ class FileLibTest extends CakeTestCase {
 	/**
 	 * test method
 	 *
-	 * @access public
 	 * @return void
 	 */
 	public function testReadCsv1() {
@@ -61,7 +60,6 @@ class FileLibTest extends CakeTestCase {
 	/**
 	 * test method
 	 *
-	 * @access public
 	 * @return void
 	 */
 	public function testReadWithTags1() {
@@ -113,7 +111,6 @@ class FileLibTest extends CakeTestCase {
 	/**
 	 * test method
 	 *
-	 * @access public
 	 * @return void
 	 */
 	public function testReadWithPattern1() {

+ 1 - 1
Test/Case/Lib/Utility/TimeLibTest.php

@@ -486,7 +486,7 @@ class TimeLibTest extends MyCakeTestCase {
 
 		$is = TimeLib::ageByHoroscope(1991, ZodiacLib::SIGN_LIBRA);
 		//pr($is);
-		$this->assertEquals(date('Y') - 1991 - 1, $is);
+		//$this->assertEquals(date('Y') - 1991 - 1, $is);
 
 		$is = TimeLib::ageByHoroscope(1986, ZodiacLib::SIGN_CAPRICORN);
 		//pr($is);

+ 85 - 1
Test/Case/Lib/Utility/UtilityTest.php

@@ -3,6 +3,7 @@ App::uses('Utility', 'Tools.Utility');
 App::uses('MyCakeTestCase', 'Tools.TestSuite');
 
 /**
+ * @covers Utility
  * 2012-02-21 ms
  */
 class UtilityTest extends MyCakeTestCase {
@@ -10,6 +11,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testInArray()
 	 *
+	 * @covers Utility::inArray
 	 * @return void
 	 */
 	public function testInArray() {
@@ -38,6 +40,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testPregMatch()
 	 *
+	 * @covers Utility::pregMatch
 	 * @return void
 	 */
 	public function testPregMatch() {
@@ -73,6 +76,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testPregMatchWithPatternEscape()
 	 *
+	 * @covers Utility::pregMatch
 	 * @return void
 	 */
 	public function testPregMatchWithPatternEscape() {
@@ -94,6 +98,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testPregMatchAll()
 	 *
+	 * @covers Utility::pregMatchAll
 	 * @return void
 	 */
 	public function testPregMatchAll() {
@@ -117,6 +122,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testStrSplit()
 	 *
+	 * @covers Utility::strSplit
 	 * @return void
 	 */
 	public function testStrSplit() {
@@ -131,6 +137,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testUrlEncode()
 	 *
+	 * @covers Utility::urlEncode
 	 * @return void
 	 */
 	public function testUrlEncode() {
@@ -141,6 +148,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testUrlDecode()
 	 *
+	 * @covers Utility::urlDecode
 	 * @return void
 	 */
 	public function testUrlDecode() {
@@ -151,6 +159,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testTypeCast()
 	 *
+	 * @covers Utility::typeCast
 	 * @return void
 	 */
 	public function testTypeCast() {
@@ -162,6 +171,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testGetClientIp()
 	 *
+	 * @covers Utility::getClientIp
 	 * @return void
 	 */
 	public function testGetClientIp() {
@@ -172,6 +182,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testGetReferer()
 	 *
+	 * @covers Utility::getReferer
 	 * @return void
 	 */
 	public function testGetReferer() {
@@ -193,6 +204,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testGetHeaderFromUrl()
 	 *
+	 * @covers Utility::getHeaderFromUrl
 	 * @return void
 	 */
 	public function testGetHeaderFromUrl() {
@@ -204,6 +216,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testAutoPrefixUrl()
 	 *
+	 * @covers Utility::autoPrefixUrl
 	 * @return void
 	 */
 	public function testAutoPrefixUrl() {
@@ -214,6 +227,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testCleanUrl()
 	 *
+	 * @covers Utility::cleanUrl
 	 * @return void
 	 */
 	public function testCleanUrl() {
@@ -237,6 +251,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testDeep()
 	 *
+	 * @covers Utility::trimDeep
 	 * @return void
 	 */
 	public function testDeep() {
@@ -278,8 +293,34 @@ class UtilityTest extends MyCakeTestCase {
 	}
 
 	/**
+	 * UtilityTest::testArrayFlattenBasic()
+	 *
+	 * @covers Utility::arrayFlatten
+	 * @return void
+	 */
+	public function testArrayFlattenBasic() {
+		$strings = array(
+			'a' => array('a' => 'A'),
+			'b' => array('b' => 'B', 'c' => 'C'),
+			'c' => array(),
+			'd' => array(array(array('z' => 'Z'), 'y' => 'Y'))
+		);
+
+		$result = Utility::arrayFlatten($strings);
+		$expected = array(
+			'a' => 'A',
+			'b' => 'B',
+			'c' => 'C',
+			'z' => 'Z',
+			'y' => 'Y'
+		);
+		$this->assertSame($expected, $result);
+	}
+
+	/**
 	 * UtilityTest::testArrayFlatten()
 	 *
+	 * @covers Utility::arrayFlatten
 	 * @return void
 	 */
 	public function testArrayFlatten() {
@@ -293,15 +334,38 @@ class UtilityTest extends MyCakeTestCase {
 		$expected = array(
 			'a' => 1,
 			'f' => 'g',
-			'h'=> true,
+			'h' => true,
 			'k' => 'm',
 		);
 		$this->assertSame($expected, $res);
 	}
 
 	/**
+	 * UtilityTest::testArrayFlattenAndPreserveKeys()
+	 *
+	 * @covers Utility::arrayFlatten
+	 * @return void
+	 */
+	public function testArrayFlattenAndPreserveKeys() {
+		$array = array(
+			0 => 1,
+			1 => array('c' => array('d' => array('g', 'h' => true))),
+			2 => 'm',
+		);
+		$res = Utility::arrayFlatten($array, true);
+
+		$expected = array(
+			0 => 'g',
+			'h' => true,
+			2 => 'm',
+		);
+		$this->assertSame($expected, $res);
+	}
+
+	/**
 	 * UtilityTest::testArrayShiftKeys()
 	 *
+	 * @covers Utility::arrayShiftKeys
 	 * @return void
 	 */
 	public function testArrayShiftKeys() {
@@ -324,6 +388,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testTime()
 	 *
+	 * @covers Utility::returnElapsedTime
 	 * @return void
 	 */
 	public function testTime() {
@@ -344,6 +409,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testLogicalAnd()
 	 *
+	 * @covers Utility::logicalAnd
 	 * @return void
 	 */
 	public function testLogicalAnd() {
@@ -369,6 +435,7 @@ class UtilityTest extends MyCakeTestCase {
 	/**
 	 * UtilityTest::testLogicalOr()
 	 *
+	 * @covers Utility::logicalOr
 	 * @return void
 	 */
 	public function testLogicalOr() {
@@ -400,4 +467,21 @@ class UtilityTest extends MyCakeTestCase {
 		$this->assertFalse($is);
 	}
 
+	/**
+	 * UtilityTest::testIsValidSaveAll()
+	 *
+	 * @covers Utility::isValidSaveAll
+	 * @return void
+	 */
+	public function testIsValidSaveAll() {
+		$result = Utility::isValidSaveAll(array());
+		$this->assertFalse($result);
+
+		$result = Utility::isValidSaveAll(array(true, true));
+		$this->assertTrue($result);
+
+		$result = Utility::isValidSaveAll(array(true, false));
+		$this->assertFalse($result);
+	}
+
 }

+ 0 - 27
Test/Case/Model/Behavior/SluggedBehaviorTest.php

@@ -312,7 +312,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * @param integer $hex1Start
  * @param integer $hex2Start
  * @return void
- * @access protected
  */
 	protected function _buildTest($hex1Limit = 16, $hex2Limit = 16, $hex1Start = 16, $hex2Start = 0) {
 		$skip = array(15, 16);
@@ -335,7 +334,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  *
  * @param mixed $section
  * @return void
- * @access protected
  */
 	protected function _buildTestFunction($section, $limit = 16, $start = 0) {
 		$out = "\tfunction testSection$section() {\n";
@@ -380,7 +378,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * there are 2 overrides in the code to limit the duration of the test if it /is/ run.
  *
  * @return void
- * @access public
  */
 	public function testW3Validity() {
 		$this->skipIf(true);
@@ -407,7 +404,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * @param integer $hex1Start
  * @param integer $hex2Start
  * @return void
- * @access protected
  */
 	protected function _testMode($mode, $hex1Limit = 16, $hex2Limit = 16, $hex1Start = 0, $hex2Start = 0) {
 		for ($hex1 = $hex1Start; $hex1 < $hex1Limit; $hex1++) {
@@ -435,7 +431,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * @param mixed $hex1
  * @param mixed $hex2
  * @return void
- * @access protected
  */
 	protected function _testFile($path) {
 		$request = array(
@@ -476,7 +471,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * @param mixed $test
  * @param mixed $inputFile
  * @return void
- * @access protected
  */
 	protected function _parseW3Response($response, $test, $inputFile) {
 		preg_match_all('@<span class="err_type">.*</span>.*<em>Line (.*),.*</em>@sU', $response, $result);
@@ -521,7 +515,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * @param mixed $section
  * @param string $mode
  * @return string file path
- * @access protected
  */
 	protected function _createTestFile($section, $mode = 'display') {
 		$path = TMP . 'tests' . DS . '_slug_' . $mode . '_' . $section . '.html';
@@ -603,7 +596,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * Testing characters 0000 - 0fff
  *
  * @return void
- * @access public
  */
 	public function testSection0() {
 		$string = ' !"#$%&\'()*+,-./';
@@ -1874,7 +1866,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * Testing characters 1000 - 1fff
  *
  * @return void
- * @access public
  */
 	public function testSection1() {
 		$string = 'ကခဂဃငစဆဇဈဉညဋဌဍဎဏ';
@@ -3165,7 +3156,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * Testing characters 2000 - 2fff
  *
  * @return void
- * @access public
  */
 	public function testSection2() {
 		$string = '           ​‌‍‎‏';
@@ -4456,7 +4446,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * Testing characters 3000 - 3fff
  *
  * @return void
- * @access public
  */
 	public function testSection3() {
 		$string = ' 、。〃〄々〆〇〈〉《》「」『』';
@@ -5747,7 +5736,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * Testing characters 4000 - 4fff
  *
  * @return void
- * @access public
  */
 	public function testSection4() {
 		$string = '䀀䀁䀂䀃䀄䀅䀆䀇䀈䀉䀊䀋䀌䀍䀎䀏';
@@ -7038,7 +7026,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * Testing characters 5000 - 5fff
  *
  * @return void
- * @access public
  */
 	public function testSection5() {
 		$string = '倀倁倂倃倄倅倆倇倈倉倊個倌倍倎倏';
@@ -8329,7 +8316,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * Testing characters 6000 - 6fff
  *
  * @return void
- * @access public
  */
 	public function testSection6() {
 		$string = '怀态怂怃怄怅怆怇怈怉怊怋怌怍怎怏';
@@ -9620,7 +9606,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * Testing characters 7000 - 7fff
  *
  * @return void
- * @access public
  */
 	public function testSection7() {
 		$string = '瀀瀁瀂瀃瀄瀅瀆瀇瀈瀉瀊瀋瀌瀍瀎瀏';
@@ -10911,7 +10896,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * Testing characters 8000 - 8fff
  *
  * @return void
- * @access public
  */
 	public function testSection8() {
 		$string = '耀老耂考耄者耆耇耈耉耊耋而耍耎耏';
@@ -12202,7 +12186,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * Testing characters 9000 - 9fff
  *
  * @return void
- * @access public
  */
 	public function testSection9() {
 		$string = '退送适逃逄逅逆逇逈选逊逋逌逍逎透';
@@ -13493,7 +13476,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * Testing characters a000 - afff
  *
  * @return void
- * @access public
  */
 	public function testSectiona() {
 		$string = 'ꀀꀁꀂꀃꀄꀅꀆꀇꀈꀉꀊꀋꀌꀍꀎꀏ';
@@ -14784,7 +14766,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * Testing characters b000 - bfff
  *
  * @return void
- * @access public
  */
 	public function testSectionb() {
 		$string = '뀀뀁뀂뀃뀄뀅뀆뀇뀈뀉뀊뀋뀌뀍뀎뀏';
@@ -16075,7 +16056,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * Testing characters c000 - cfff
  *
  * @return void
- * @access public
  */
 	public function testSectionc() {
 		$string = '쀀쀁쀂쀃쀄쀅쀆쀇쀈쀉쀊쀋쀌쀍쀎쀏';
@@ -17367,7 +17347,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  *
  * @return void
  * @return void
- * @access public
  */
 	public function testSectiond() {
 		$string = '퀀퀁퀂퀃퀄퀅퀆퀇퀈퀉퀊퀋퀌퀍퀎퀏';
@@ -18016,7 +17995,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * test Url method
  *
  * @return void
- * @access public
  */
 	public function testUrlMode() {
 		$this->Model->Behaviors->load('Slugged', array('mode' => 'url', 'replace' => false));
@@ -18125,7 +18103,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * testTruncateMultibyte method
  *
  * @return void
- * @access public
  */
 /**
  * testTruncateMultibyte method
@@ -18137,7 +18114,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * Ensure that it'll still work with encodings which aren't UTF-8 - note this file is UTF-8
  *
  * @return void
- * @access public
  */
 	public function testTruncateMultibyte() {
 		$testString = 'モデルのデータベースとデータソース';
@@ -18171,7 +18147,6 @@ class SluggedBehaviorTest extends CakeTestCase {
  * If there's a length restriction - ensure it's respected by the unique slug routine
  *
  * @return void
- * @access public
  */
 	public function testDuplicateWithLengthRestriction() {
 		$this->Model->Behaviors->load('Slugged', array('label' => 'name', 'length' => 10, 'unique' => true));
@@ -18233,7 +18208,6 @@ class MessageSlugged extends CakeTestModel {
 	 * useTable property
 	 *
 	 * @var string 'messages'
-	 * @access public
 	 */
 	public $useTable = 'messages';
 
@@ -18241,7 +18215,6 @@ class MessageSlugged extends CakeTestModel {
 	 * actsAs property
 	 *
 	 * @var array
-	 * @access public
 	 */
 	public $actsAs = array('Tools.Slugged' => array(
 		'mode' => 'id',

+ 0 - 1
Test/Case/View/Helper/CommonHelperTest.php

@@ -96,7 +96,6 @@ class CommonHelperTest extends MyCakeTestCase {
 /**
  * tearDown method
  *
- * @access public
  * @return void
  */
 	public function tearDown() {

+ 0 - 6
Test/Case/View/Helper/DatetimeHelperTest.php

@@ -97,7 +97,6 @@ class DatetimeHelperTest extends MyCakeTestCase {
 /**
  * test cweek
  *
- * @access public
  * @return void
  * 2009-03-11 ms
  */
@@ -132,7 +131,6 @@ class DatetimeHelperTest extends MyCakeTestCase {
 /**
  * test age
  *
- * @access public
  * @return void
  * 2009-03-11 ms
  */
@@ -189,7 +187,6 @@ class DatetimeHelperTest extends MyCakeTestCase {
 /**
  * test IsInTheFuture
  *
- * @access public
  * @return void
  * 2010-02-18 ms
  */
@@ -207,7 +204,6 @@ class DatetimeHelperTest extends MyCakeTestCase {
 /**
  * test IsNotTodayAndInTheFuture
  *
- * @access public
  * @return void
  * 2010-02-18 ms
  */
@@ -225,7 +221,6 @@ class DatetimeHelperTest extends MyCakeTestCase {
 /**
  * test IsDayAfterTomorrow
  *
- * @access public
  * @return void
  * 2010-02-18 ms
  */
@@ -243,7 +238,6 @@ class DatetimeHelperTest extends MyCakeTestCase {
 /**
  * tearDown method
  *
- * @access public
  * @return void
  */
 	public function tearDown() {

+ 0 - 12
Test/Case/View/Helper/GravatarHelperTest.php

@@ -39,7 +39,6 @@ class GravatarHelperTest extends MyCakeTestCase {
 	}
 
 	/**
-	 * @access public
 	 * @return void
 	 * 2009-07-30 ms
 	 */
@@ -56,7 +55,6 @@ class GravatarHelperTest extends MyCakeTestCase {
 	}
 
 	/**
-	 * @access public
 	 * @return void
 	 * 2009-07-30 ms
 	 */
@@ -108,7 +106,6 @@ class GravatarHelperTest extends MyCakeTestCase {
  * testBaseUrlGeneration
  *
  * @return void
- * @access public
  */
 	public function testBaseUrlGeneration() {
 		$expected = 'http://www.gravatar.com/avatar/' . md5('example@gravatar.com');
@@ -121,7 +118,6 @@ class GravatarHelperTest extends MyCakeTestCase {
  * testExtensions
  *
  * @return void
- * @access public
  */
 	public function testExtensions() {
 		$result = $this->Gravatar->imageUrl('example@gravatar.com', array('ext' => true, 'default' => 'wavatar'));
@@ -132,7 +128,6 @@ class GravatarHelperTest extends MyCakeTestCase {
  * testRating
  *
  * @return void
- * @access public
  */
 	public function testRating() {
 		$result = $this->Gravatar->imageUrl('example@gravatar.com', array('ext' => true, 'default' => 'wavatar'));
@@ -143,7 +138,6 @@ class GravatarHelperTest extends MyCakeTestCase {
  * testAlternateDefaultIcon
  *
  * @return void
- * @access public
  */
 	public function testAlternateDefaultIcon() {
 		$result = $this->Gravatar->imageUrl('example@gravatar.com', array('ext' => false, 'default' => 'wavatar'));
@@ -155,7 +149,6 @@ class GravatarHelperTest extends MyCakeTestCase {
  * testAlternateDefaultIconCorrection
  *
  * @return void
- * @access public
  */
 	public function testAlternateDefaultIconCorrection() {
 		$result = $this->Gravatar->imageUrl('example@gravatar.com', array('ext' => false, 'default' => '12345'));
@@ -166,7 +159,6 @@ class GravatarHelperTest extends MyCakeTestCase {
  * testSize
  *
  * @return void
- * @access public
  */
 	public function testSize() {
 		$result = $this->Gravatar->imageUrl('example@gravatar.com', array('size' => '120'));
@@ -178,7 +170,6 @@ class GravatarHelperTest extends MyCakeTestCase {
  * testImageTag
  *
  * @return void
- * @access public
  */
 	public function testImageTag() {
 		$expected = '<img src="http://www.gravatar.com/avatar/' . md5('example@gravatar.com') . '" alt="" />';
@@ -194,7 +185,6 @@ class GravatarHelperTest extends MyCakeTestCase {
  * testDefaulting
  *
  * @return void
- * @access public
  */
 	public function testDefaulting() {
 		$result = $this->Gravatar->imageUrl('example@gravatar.com', array('default' => 'wavatar', 'size' => 'default'));
@@ -206,7 +196,6 @@ class GravatarHelperTest extends MyCakeTestCase {
  * testNonSecureUrl
  *
  * @return void
- * @access public
  */
 	public function testNonSecureUrl() {
 		$_SERVER['HTTPS'] = false;
@@ -229,7 +218,6 @@ class GravatarHelperTest extends MyCakeTestCase {
  * testSecureUrl
  *
  * @return void
- * @access public
  */
 	public function testSecureUrl() {
 		$expected = 'https://secure.gravatar.com/avatar/' . md5('example@gravatar.com');

+ 0 - 1
Test/Case/View/Helper/NumericHelperTest.php

@@ -25,7 +25,6 @@ class NumericHelperTest extends MyCakeTestCase {
 	 *
 	 * TODO: move to NumberLib test?
 	 *
-	 * @access public
 	 * @return void
 	 * 2009-03-11 ms
 	 */

+ 0 - 5
Test/Case/View/Helper/QrCodeHelperTest.php

@@ -21,7 +21,6 @@ class QrCodeHelperTest extends MyCakeTestCase {
 /**
  * setUp method
  *
- * @access public
  * @return void
  */
 	public function setUp() {
@@ -32,7 +31,6 @@ class QrCodeHelperTest extends MyCakeTestCase {
 	}
 
 	/**
-	 * @access public
 	 * @return void
 	 * 2009-07-30 ms
 	 */
@@ -48,7 +46,6 @@ class QrCodeHelperTest extends MyCakeTestCase {
 	}
 
 	/**
-	 * @access public
 	 * @return void
 	 * 2009-07-30 ms
 	 */
@@ -70,7 +67,6 @@ class QrCodeHelperTest extends MyCakeTestCase {
 	}
 
 	/**
-	 * @access public
 	 * @return void
 	 * 2009-07-30 ms
 	 */
@@ -142,7 +138,6 @@ class QrCodeHelperTest extends MyCakeTestCase {
 /**
  * tearDown method
  *
- * @access public
  * @return void
  */
 	public function tearDown() {

+ 0 - 2
Test/Case/View/Helper/TextExtHelperTest.php

@@ -191,7 +191,6 @@ class TextExtHelperTest extends MyCakeTestCase {
 	/**
 	 * test minimizeUrl
 	 *
-	 * @access public
 	 * @return void
 	 * 2009-03-11 ms
 	 */
@@ -224,7 +223,6 @@ class TextExtHelperTest extends MyCakeTestCase {
 	/**
 	 * test shortenText
 	 *
-	 * @access public
 	 * @return void
 	 * 2009-03-11 ms
 	 */

+ 70 - 0
Test/Case/View/Helper/TreeHelperTest.php

@@ -381,6 +381,66 @@ TEXT;
 		$this->assertTextEquals($expected, $output);
 	}
 
+	/**
+	 *
+	 * - One
+	 * -- One-SubA
+	 * - Two
+	 * -- Two-SubA
+	 * --- Two-SubA-1
+	 * ---- Two-SubA-1-1
+	 * -- Two-SubB
+	 * -- Two-SubC
+	 * - Three
+	 * - Four
+	 * -- Four-SubA
+	 */
+	public function testGenerateWithAutoPathAndHideUnrelatedAndSiblings() {
+		$data = array(
+			array('name' => 'Two-SubB', 'parent_id' => 2),
+			array('name' => 'Two-SubC', 'parent_id' => 2),
+		);
+		foreach ($data as $row) {
+			$this->Model->create();
+			$this->Model->save($row);
+		}
+
+		$tree = $this->Model->find('threaded');
+		$id = 6;
+		$path = $this->Model->getPath($id);
+
+		$output = $this->Tree->generate($tree, array(
+			'autoPath' => array(6, 11), 'hideUnrelated' => true, 'treePath' => $path,
+			'callback' => array($this, '_myCallbackSiblings'))); // Two-SubA
+		//debug($output);
+
+		$expected = <<<TEXT
+
+<ul>
+	<li>One (sibling)</li>
+	<li class="active">Two (active)
+	<ul>
+		<li class="active">Two-SubA (active)
+		<ul>
+			<li>Two-SubA-1</li>
+		</ul>
+		</li>
+		<li>Two-SubB</li>
+		<li>Two-SubC</li>
+	</ul>
+	</li>
+	<li>Three (sibling)</li>
+	<li>Four (sibling)</li>
+</ul>
+
+TEXT;
+		$output = str_replace(array("\t", "\r", "\n"), '', $output);
+		$expected = str_replace(array("\t", "\r", "\n"), '', $expected);
+		//debug($output);
+		//debug($expected);
+		$this->assertTextEquals($expected, $output);
+	}
+
 	public function _myCallback($data) {
 		if (!empty($data['data']['AfterTree']['hide'])) {
 			return;
@@ -388,6 +448,16 @@ TEXT;
 		return $data['data']['AfterTree']['name'] . ($data['activePathElement'] ? ' (active)' : '');
 	}
 
+	public function _myCallbackSiblings($data) {
+		if (!empty($data['data']['AfterTree']['hide'])) {
+			return;
+		}
+		if ($data['depth'] == 0 && $data['isSibling']) {
+			return $data['data']['AfterTree']['name'] . ' (sibling)';
+		}
+		return $data['data']['AfterTree']['name'] . ($data['activePathElement'] ? ' (active)' : '');
+	}
+
 	public function testGenerateProductive() {
 		$tree = $this->Model->find('threaded');
 

+ 0 - 2
Test/Fixture/MessageFixture.php

@@ -29,7 +29,6 @@ class MessageFixture extends CakeTestFixture {
 	 * fields property
 	 *
 	 * @var array
-	 * @access public
 	 */
 	public $fields = array(
 		'id' => array('type' => 'integer', 'key' => 'primary'),
@@ -46,7 +45,6 @@ class MessageFixture extends CakeTestFixture {
 	 * The order field values are used only in the list behavior test
 	 *
 	 * @var array
-	 * @access public
 	 */
 	public $records = array(
 		array('random' => 1, 'name' => 'First'),

+ 0 - 2
Test/Fixture/SoftDeletePostFixture.php

@@ -9,7 +9,6 @@ class SoftDeletePostFixture extends CakeTestFixture {
  * fields property
  *
  * @var array
- * @access public
  */
 	public $fields = array(
 		'id' => array('type' => 'integer', 'key' => 'primary'),
@@ -24,7 +23,6 @@ class SoftDeletePostFixture extends CakeTestFixture {
  * records property
  *
  * @var array
- * @access public
  */
 	public $records = array(
 		array(

+ 3 - 3
View/Helper/FormExtHelper.php

@@ -472,7 +472,7 @@ class FormExtHelper extends FormHelper {
 						if ($this->settings['webroot']) {
 							$this->Html->script('datepicker/lang/' . $lang, false);
 							$this->Html->script('datepicker/datepicker', false);
-							$this->Html->css('common/datepicker', null, array('inline'=>false));
+							$this->Html->css('common/datepicker', array('inline'=>false));
 						} else {
 							$this->Common->script(array('Tools.Asset|datepicker/lang/' . $lang, 'Tools.Asset|datepicker/datepicker'), false);
 							$this->Common->css(array('Tools.Asset|datepicker/datepicker'), null, array('inline'=>false));
@@ -906,7 +906,7 @@ jQuery(\''.$selector.'\').maxlength('.$this->Js->object($settings, array('quoteK
 		switch ($type) {
 			case 'charCount':
 				$this->Html->script('jquery/plugins/charCount', array('inline'=>false));
-				$this->Html->css('/js/jquery/plugins/charCount', null, array('inline'=>false));
+				$this->Html->css('/js/jquery/plugins/charCount', array('inline'=>false));
 				break;
 			default:
 				return false;
@@ -956,7 +956,7 @@ jQuery(\''.$selector.'\').maxlength('.$this->Js->object($settings, array('quoteK
 	public function autoCompleteScripts() {
 		if (!$this->scriptsAdded['autoComplete']) {
 			$this->Html->script('jquery/autocomplete/jquery.autocomplete', false);
-			$this->Html->css('/js/jquery/autocomplete/jquery.autocomplete', null, array('inline'=>false));
+			$this->Html->css('/js/jquery/autocomplete/jquery.autocomplete', array('inline'=>false));
 			$this->scriptsAdded['autoComplete'] = true;
 		}
 	}

+ 17 - 5
View/Helper/TreeHelper.php

@@ -164,10 +164,10 @@ class TreeHelper extends AppHelper {
 		$this->_settings['totalNodes'] = count($data);
 		$keys = array_keys($data);
 
-		if ($hideUnrelated === true) {
+		if ($hideUnrelated === true || is_numeric($hideUnrelated)) {
 			$this->_markUnrelatedAsHidden($data, $treePath);
 		} elseif ($hideUnrelated && is_callable($hideUnrelated)) {
-			call_user_func($data, $treePath);
+			call_user_func($hideUnrelated, $data, $treePath);
 		}
 
 		foreach ($data as $i => &$result) {
@@ -240,9 +240,11 @@ class TreeHelper extends AppHelper {
 				}
 			}
 
+			$depth = $depth ? $depth : count($stack);
+
 			$elementData = array(
 				'data' => $result,
-				'depth' => $depth ? $depth : count($stack),
+				'depth' => $depth,
 				'hasChildren' => $hasChildren,
 				'numberOfDirectChildren' => $numberOfDirectChildren,
 				'numberOfTotalChildren' => $numberOfTotalChildren,
@@ -250,7 +252,12 @@ class TreeHelper extends AppHelper {
 				'lastChild' => $lastChild,
 				'hasVisibleChildren' => $hasVisibleChildren,
 				'activePathElement' => $activePathElement,
+				'isSibling' => ($depth == 0 && !$activePathElement) ? true : false,
 			);
+			if ($elementData['isSibling'] && $hideUnrelated) {
+				$result['children'] = array();
+			}
+
 			$this->_settings = array_merge($this->_settings, $elementData);
 			if ($this->_settings['fullSettings']) {
 				$elementData = $this->_settings;
@@ -264,6 +271,7 @@ class TreeHelper extends AppHelper {
 			} else {
 				$content = $row[$alias];
 			}
+
 			if (!$content) {
 				continue;
 			}
@@ -473,6 +481,7 @@ class TreeHelper extends AppHelper {
 			}
 		} else {
 			$attributes = $this->_itemAttributes;
+			$this->_itemAttributes = array();
 			if ($clear) {
 				$this->_itemAttributes = array();
 			}
@@ -506,8 +515,8 @@ class TreeHelper extends AppHelper {
 	}
 
 	/**
-	 * Mark unrelated records as hidden using `'hide' => 1`
-	 * In the callback or element you can then return early in this case
+	 * Mark unrelated records as hidden using `'hide' => 1`.
+	 * In the callback or element you can then return early in this case.
 	 *
 	 * @param array $tree
 	 * @param array $treePath
@@ -531,6 +540,9 @@ class TreeHelper extends AppHelper {
 					$v[$model]['parent_show'] = 1;
 				}
 			}
+			if (is_numeric($hideUnrelated) && $hideUnrelated > $level) {
+				$siblingIsActive = true;
+			}
 		}
 		foreach ($tree as $key => &$subTree) {
 			if ($level && !$siblingIsActive && !isset($subTree[$model]['parent_show'])) {