sterzycom/kirby/core/field.php

56 lines
1.1 KiB
PHP
Raw Normal View History

<?php
/**
* Field
*
* @package Kirby CMS
* @author Bastian Allgeier <bastian@getkirby.com>
* @link http://getkirby.com
* @copyright Bastian Allgeier
* @license http://getkirby.com/license
*/
abstract class FieldAbstract {
static public $methods = array();
public $page;
public $key;
public $value;
public function __construct($page, $key, $value = '') {
$this->page = $page;
$this->key = $key;
$this->value = $value;
}
public function page() {
return $this->page;
}
public function exists() {
return $this->page->content()->has($this->key);
}
public function key() {
return $this->key;
}
public function value() {
return $this->value;
}
public function isTranslated($lang = null) {
return true;
}
public function __toString() {
return (string)$this->value;
}
public function toString() {
return $this->value;
}
public function __call($method, $arguments = array()) {
if(isset(static::$methods[$method])) {
array_unshift($arguments, clone $this);
return call(static::$methods[$method], $arguments);
} else {
return $this;
}
}
}