]> git.parisson.com Git - telemeta.git/commitdiff
eztelemeta: simplifying...
authorolivier <>
Thu, 9 Apr 2009 10:09:49 +0000 (10:09 +0000)
committerolivier <>
Thu, 9 Apr 2009 10:09:49 +0000 (10:09 +0000)
tools/eztelemeta/autoload/autoload.php [deleted file]
tools/eztelemeta/datatypes/eztelemetaitem/eztelemetaitemtype.php [new file with mode: 0755]
tools/eztelemeta/settings/content.ini.append
tools/eztelemeta/src/exceptions.php [deleted file]
tools/eztelemeta/src/telemetaitem.php [deleted file]

diff --git a/tools/eztelemeta/autoload/autoload.php b/tools/eztelemeta/autoload/autoload.php
deleted file mode 100644 (file)
index edb70f4..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-return array(
-    "TelemetaItem"                  => "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 (executable)
index 0000000..6267a78
--- /dev/null
@@ -0,0 +1,85 @@
+<?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");
index 95000c21fce20b5b908d3398a825af7b3c0d603c..e40635db13ba4c456a48d51df07e81d6c577cc8c 100644 (file)
@@ -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 (file)
index d62b5a1..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<?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);
-    }
-}
-?>
diff --git a/tools/eztelemeta/src/telemetaitem.php b/tools/eztelemeta/src/telemetaitem.php
deleted file mode 100644 (file)
index 15c3e8e..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-<?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');
-    }
-}
-
-
-?>
-