From cf6da48b2b0942dc2cdad20370fd9b028f527086 Mon Sep 17 00:00:00 2001 From: olivier <> Date: Thu, 9 Apr 2009 10:09:49 +0000 Subject: [PATCH] eztelemeta: simplifying... --- tools/eztelemeta/autoload/autoload.php | 8 -- .../eztelemetaitem/eztelemetaitemtype.php | 85 ++++++++++++++ tools/eztelemeta/settings/content.ini.append | 2 +- tools/eztelemeta/src/exceptions.php | 27 ----- tools/eztelemeta/src/telemetaitem.php | 109 ------------------ 5 files changed, 86 insertions(+), 145 deletions(-) delete mode 100644 tools/eztelemeta/autoload/autoload.php create mode 100755 tools/eztelemeta/datatypes/eztelemetaitem/eztelemetaitemtype.php delete mode 100644 tools/eztelemeta/src/exceptions.php delete mode 100644 tools/eztelemeta/src/telemetaitem.php diff --git a/tools/eztelemeta/autoload/autoload.php b/tools/eztelemeta/autoload/autoload.php deleted file mode 100644 index edb70f47..00000000 --- a/tools/eztelemeta/autoload/autoload.php +++ /dev/null @@ -1,8 +0,0 @@ - "src/telemetaitem.php", - "TelemetaItemType" => "src/telemetaitemtype.php", - "TelemetaInvalidParamsError" => "src/exceptions.php" -); - -?> diff --git a/tools/eztelemeta/datatypes/eztelemetaitem/eztelemetaitemtype.php b/tools/eztelemeta/datatypes/eztelemetaitem/eztelemetaitemtype.php new file mode 100755 index 00000000..6267a78d --- /dev/null +++ b/tools/eztelemeta/datatypes/eztelemetaitem/eztelemetaitemtype.php @@ -0,0 +1,85 @@ +id}"; + if ($http->hasPostVariable($idvar)) { + $itemId = $http->postVariable($idvar); + $classAttribute = $attribute->contentClassAttribute(); + if ($classAttribute->attribute("is_required")) { + if (!$itemId) { + $attribute->setValidationError(ezi18n('content/datatypes', + "A valid Telemeta Item identifier is required", + __CLASS__)); + return eZInputValidator::STATE_INVALID; + } + } + if ($itemId != 1000) { + $attribute->setValidationError(ezi18n('content/datatypes', + "Invalid Telemeta Item identifier", + __CLASS__)); + return eZInputValidator::STATE_INVALID; + } + } + return eZInputValidator::STATE_ACCEPTED; + } + + function fetchObjectAttributeHTTPInput($http, $base, $attribute) + { + $idvar = "{$base}_itemid_{$attribute->id}"; + if ($http->hasPostVariable($idvar)) { + $itemId = $http->postVariable($idvar); + $attribute->setAttribute("itemid", $itemId); + } + return true; + } + + function objectAttributeContent($attribute) + { + return $attribute->attribute("itemid"); + } + + function metaData($attribute) + { + return $attribute->attribute("itemid"); + } + + function title($attribute, $name = null) + { + return "Telemeta Item id " . $attribute->attribute("itemid"); + } + + function isIndexable() + { + return true; + } + +} + +eZDataType::register(eZTelemetaItemType::DATA_TYPE_STRING, "eztelemetaitemtype"); diff --git a/tools/eztelemeta/settings/content.ini.append b/tools/eztelemeta/settings/content.ini.append index 95000c21..e40635db 100644 --- a/tools/eztelemeta/settings/content.ini.append +++ b/tools/eztelemeta/settings/content.ini.append @@ -1,4 +1,4 @@ [DataTypeSettings] ExtensionDirectories[]=eztelemeta -AvailableDataTypes[]=telemetaitem +AvailableDataTypes[]=eztelemetaitem diff --git a/tools/eztelemeta/src/exceptions.php b/tools/eztelemeta/src/exceptions.php deleted file mode 100644 index d62b5a15..00000000 --- a/tools/eztelemeta/src/exceptions.php +++ /dev/null @@ -1,27 +0,0 @@ - diff --git a/tools/eztelemeta/src/telemetaitem.php b/tools/eztelemeta/src/telemetaitem.php deleted file mode 100644 index 15c3e8e2..00000000 --- a/tools/eztelemeta/src/telemetaitem.php +++ /dev/null @@ -1,109 +0,0 @@ - null, - 'title' => null, - 'description' => null, - 'rights' => null, - 'duration' => null, - 'creator' => null, - 'timeFetched' => null - ); - - - /** - * Constructs a new Telemeta item data type - * - * @param string $data Serialized data - * @throws telemetaDatatypeInvalidParamsError - */ - public function __construct($data = null) - { - if ($data) { - $data = unserialize($data); - if (!$data) { - throw new telemetaInvalidParamsError("Couldn't unserialize Telemeta Item data"); - } - $this->properties = array_merge($this->properties, $data); - } - } - - private function fetch($itemId) - { - if ($itemId == 1000) { - $this->properties['id'] = 1000; - $this->properties['title'] = "Pulp Fiction"; - $this->properties['description'] = "A crazy movie"; - $this->properties['rights'] = "Copyright Holywood"; - $this->properties['duration'] = 3600 + 1800; - $this->properties['creator'] = "Quentin Tarantino"; - $this->properties['timeFetched'] = time(); - return true; - } - return false; - } - - public function __toString() - { - return serialize($this->properties); - } - - public static function createFromString($str) - { - return new self($str); - } - - public function attribute($name) - { - return $this->__get($name); - } - - public function hasAttribute($name) - { - return $this->__isset($name); - } - - public function __get($name) - { - if ($this->__isset($name)) { - return $this->properties[$name]; - } else { - throw new ezcBasePropertyNotFoundException($name); - } - } - - public function __isset($name) - { - return (array_key_exists($name, $this->properties) and !is_null($this->properties[$name])); - } - - public function hasContent() - { - return $this->__isset('id'); - } -} - - -?> - -- 2.39.5