update template docs, move deprecation to 5.0, capitalise Is

This commit is contained in:
Andrew Aitken-Fincham 2020-06-15 12:25:13 +01:00
parent 2e0e04f701
commit 7c95237e8d
2 changed files with 16 additions and 14 deletions

View File

@ -358,6 +358,8 @@ iteration.
* `$Even`, `$Odd`: Returns boolean, handy for zebra striping. * `$Even`, `$Odd`: Returns boolean, handy for zebra striping.
* `$EvenOdd`: Returns a string, either 'even' or 'odd'. Useful for CSS classes. * `$EvenOdd`: Returns a string, either 'even' or 'odd'. Useful for CSS classes.
* `$First`, `$Last`, `$Middle`: Booleans about the position in the list. * `$First`, `$Last`, `$Middle`: Booleans about the position in the list.
* Note: as of CMS 4.7.0 `$IsFirst` and `$IsLast` will be preferred. The original
syntax will continue to work, but will be deprecated in a future release.
* `$FirstLast`: Returns a string, "first", "last", "first last" (if both), or "". Useful for CSS classes. * `$FirstLast`: Returns a string, "first", "last", "first last" (if both), or "". Useful for CSS classes.
* `$Pos`: The current position in the list (integer). * `$Pos`: The current position in the list (integer).
Will start at 1, but can take a starting index as a parameter. Will start at 1, but can take a starting index as a parameter.

View File

@ -26,8 +26,8 @@ class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider
public static function get_template_iterator_variables() public static function get_template_iterator_variables()
{ {
return [ return [
'isFirst', 'IsFirst',
'isLast', 'IsLast',
'First', 'First',
'Last', 'Last',
'FirstLast', 'FirstLast',
@ -61,19 +61,19 @@ class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider
* *
* @return bool * @return bool
*/ */
public function isFirst() public function IsFirst()
{ {
return $this->iteratorPos == 0; return $this->iteratorPos == 0;
} }
/** /**
* @deprecated 4.7.0 Use isFirst() to avoid clashes with SS_Lists * @deprecated 5.0 Use IsFirst() to avoid clashes with SS_Lists
* @return bool * @return bool
*/ */
public function First() public function First()
{ {
Deprecation::notice('4.7.0', 'Use isFirst() to avoid clashes with SS_Lists'); Deprecation::notice('5.0', 'Use IsFirst() to avoid clashes with SS_Lists');
return $this->isFirst(); return $this->IsFirst();
} }
/** /**
@ -81,19 +81,19 @@ class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider
* *
* @return bool * @return bool
*/ */
public function isLast() public function IsLast()
{ {
return $this->iteratorPos == $this->iteratorTotalItems - 1; return $this->iteratorPos == $this->iteratorTotalItems - 1;
} }
/** /**
* @deprecated 4.7.0 Use isLast() to avoid clashes with SS_Lists * @deprecated 5.0 Use IsLast() to avoid clashes with SS_Lists
* @return bool * @return bool
*/ */
public function Last() public function Last()
{ {
Deprecation::notice('4.7.0', 'Use isLast() to avoid clashes with SS_Lists'); Deprecation::notice('5.0', 'Use IsLast() to avoid clashes with SS_Lists');
return $this->isLast(); return $this->IsLast();
} }
/** /**
@ -103,13 +103,13 @@ class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider
*/ */
public function FirstLast() public function FirstLast()
{ {
if ($this->isFirst() && $this->isLast()) { if ($this->IsFirst() && $this->IsLast()) {
return 'first last'; return 'first last';
} }
if ($this->isFirst()) { if ($this->IsFirst()) {
return 'first'; return 'first';
} }
if ($this->isLast()) { if ($this->IsLast()) {
return 'last'; return 'last';
} }
return null; return null;
@ -122,7 +122,7 @@ class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider
*/ */
public function Middle() public function Middle()
{ {
return !$this->isFirst() && !$this->isLast(); return !$this->IsFirst() && !$this->IsLast();
} }
/** /**