| @@ 6-31 (lines=26) @@ | ||
| 3 | /** |
|
| 4 | * @author Mohamed Alsharaf <[email protected]> |
|
| 5 | */ |
|
| 6 | class EditableFieldCountryDropdownExtension extends DataExtension |
|
| 7 | { |
|
| 8 | /** |
|
| 9 | * Get field value that is suitable for the view template file. |
|
| 10 | * |
|
| 11 | * @return CountryField |
|
| 12 | */ |
|
| 13 | public function getViewValue() |
|
| 14 | { |
|
| 15 | $value = Object::create('CountryField'); |
|
| 16 | ||
| 17 | return $value->setValue($this->owner->Value); |
|
| 18 | } |
|
| 19 | ||
| 20 | /** |
|
| 21 | * Get string value of a field. |
|
| 22 | * |
|
| 23 | * @return null|string |
|
| 24 | */ |
|
| 25 | public function getValueAsString() |
|
| 26 | { |
|
| 27 | $country = $this->getViewValue(); |
|
| 28 | ||
| 29 | return $country ? $country->Name() : ''; |
|
| 30 | } |
|
| 31 | } |
|
| 32 | ||
| @@ 6-32 (lines=27) @@ | ||
| 3 | /** |
|
| 4 | * @author Mohamed Alsharaf <[email protected]> |
|
| 5 | */ |
|
| 6 | class EditableFieldDateExtension extends DataExtension |
|
| 7 | { |
|
| 8 | /** |
|
| 9 | * Get field value that is suitable for the view template file. |
|
| 10 | * |
|
| 11 | * @return Date |
|
| 12 | */ |
|
| 13 | public function getViewValue() |
|
| 14 | { |
|
| 15 | $value = Object::create('Date'); |
|
| 16 | $value->setValue($this->owner->Value); |
|
| 17 | ||
| 18 | return $value; |
|
| 19 | } |
|
| 20 | ||
| 21 | /** |
|
| 22 | * Get string value of a field. |
|
| 23 | * |
|
| 24 | * @return null|string |
|
| 25 | */ |
|
| 26 | public function getValueAsString() |
|
| 27 | { |
|
| 28 | $date = $this->getViewValue(); |
|
| 29 | ||
| 30 | return $date ? $date->Nice() : ''; |
|
| 31 | } |
|
| 32 | } |
|
| 33 | ||
| @@ 6-29 (lines=24) @@ | ||
| 3 | /** |
|
| 4 | * @author Mohamed Alsharaf <[email protected]> |
|
| 5 | */ |
|
| 6 | class EditableFieldMemberListExtension extends DataExtension |
|
| 7 | { |
|
| 8 | /** |
|
| 9 | * Get field value that is suitable for the view template file. |
|
| 10 | * |
|
| 11 | * @return Member |
|
| 12 | */ |
|
| 13 | public function getViewValue() |
|
| 14 | { |
|
| 15 | return Member::get()->byID((int) $this->owner->Value); |
|
| 16 | } |
|
| 17 | ||
| 18 | /** |
|
| 19 | * Get string value of a field. |
|
| 20 | * |
|
| 21 | * @return null|string |
|
| 22 | */ |
|
| 23 | public function getValueAsString() |
|
| 24 | { |
|
| 25 | $member = $this->getViewValue(); |
|
| 26 | ||
| 27 | return $member ? $member->getName() : ''; |
|
| 28 | } |
|
| 29 | } |
|
| 30 | ||
| @@ 6-29 (lines=24) @@ | ||
| 3 | /** |
|
| 4 | * @author Mohamed Alsharaf <[email protected]> |
|
| 5 | */ |
|
| 6 | class EditableFieldPageTypeListExtension extends DataExtension |
|
| 7 | { |
|
| 8 | /** |
|
| 9 | * Get field value that is suitable for the view template file. |
|
| 10 | * |
|
| 11 | * @return Page |
|
| 12 | */ |
|
| 13 | public function getViewValue() |
|
| 14 | { |
|
| 15 | return Page::get()->byID((int) $this->owner->Value); |
|
| 16 | } |
|
| 17 | ||
| 18 | /** |
|
| 19 | * Get string value of a field. |
|
| 20 | * |
|
| 21 | * @return null|string |
|
| 22 | */ |
|
| 23 | public function getValueAsString() |
|
| 24 | { |
|
| 25 | $page = $this->getViewValue(); |
|
| 26 | ||
| 27 | return $page ? $page->Title : ''; |
|
| 28 | } |
|
| 29 | } |
|
| 30 | ||