+++ /dev/null
-<?php
-return array(
- "TelemetaItem" => "src/telemetaitem.php",
- "TelemetaItemType" => "src/telemetaitemtype.php",
- "TelemetaInvalidParamsError" => "src/exceptions.php"
-);
-
-?>
--- /dev/null
+<?php
+/**
+ * Definition of the Telemeta Item datatype
+ *
+ * @package eztelemeta
+ * @author Olivier Guilyardi
+ * @copyright 2009 Samalyse
+ * @license CeCILL Free Software License Agreement
+ */
+
+
+/**
+ * Class definining the Telemeta Item datatype
+ *
+ * @package eztelemeta
+ * @author Olivier Guilyardi
+ * @copyright 2009 Samalyse
+ * @license CeCILL Free Software License Agreement
+ */
+class eZTelemetaItemType extends eZDataType
+{
+ const DATA_TYPE_STRING = 'eztelemetaitem';
+
+ public function __construct()
+ {
+ parent::__construct(self::DATA_TYPE_STRING, 'Telemeta Item');
+ }
+
+ function validateObjectAttributeHTTPInput($http, $base, $attribute)
+ {
+ $idvar = "{$base}_itemid_{$attribute->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");
[DataTypeSettings]
ExtensionDirectories[]=eztelemeta
-AvailableDataTypes[]=telemetaitem
+AvailableDataTypes[]=eztelemetaitem
+++ /dev/null
-<?php
-/**
- * Definition of the Telemeta invalid params error
- *
- * @package eztelemeta
- * @author Olivier Guilyardi
- * @copyright 2009 Samalyse
- * @license CeCILL Free Software License Agreement
- */
-
-
-/**
- * Class defining the Telemeta invalid params error
- *
- * @package eztelemeta
- * @author Olivier Guilyardi
- * @copyright 2009 Samalyse
- * @license CeCILL Free Software License Agreement
- */
-class TelemetaInvalidParamsError extends ezcBaseException
-{
- public function __construct($msg)
- {
- parent::__construct($msg);
- }
-}
-?>
+++ /dev/null
-<?php
-/**
- * Definition of the Telemeta Item datatype
- *
- * @package eztelemeta
- * @author Olivier Guilyardi
- * @copyright 2009 Samalyse
- * @license CeCILL Free Software License Agreement
- */
-
-
-/**
- * Class definining the Telemeta Item datatype
- *
- * @package eztelemeta
- * @author Olivier Guilyardi
- * @copyright 2009 Samalyse
- * @license CeCILL Free Software License Agreement
- */
-class TelemetaItem
-{
- private $cacheTimeout = 3600;
-
- private $properties = array(
- 'id' => 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');
- }
-}
-
-
-?>
-