Author: Frederik Holljen
Date: 2006-08-28 14:20:45 +0200 (Mon, 28 Aug 2006)
New Revision: 3409

Log:
- update to follow property system (part deux)

Modified:
   experimental/Widget/src/application.php
   experimental/Widget/src/widgets/form_field_element.php

Modified: experimental/Widget/src/application.php
===================================================================
--- experimental/Widget/src/application.php     2006-08-28 11:07:01 UTC (rev 
3408)
+++ experimental/Widget/src/application.php     2006-08-28 12:20:45 UTC (rev 
3409)
@@ -49,14 +49,11 @@
 class ezcWgApplication
 {
     static private $instance = null;
+    private $properties = array();
 
-    private $mainWidget;
-    private $pageMainUrl; // base URL for this page, used by widgets to sent 
events back to themselves
-    protected $eventCreator = null;
-    protected $pageSelector = null;
-
     private function __construct()
     {
+        $this->mainWidget = null;
     }
 
     public static function getInstance()
@@ -68,19 +65,54 @@
         return self::$instance;
     }
 
-    public function setMainWidget( ezcWgWidget $w )
+    /**
+     * Sets the property $name to $value.
+     *
+     * @throws ezcBasePropertyNotFoundException if the property does not exist.
+     * @param string $name
+     * @param mixed $value
+     * @ignore
+     */
+    public function __set( $name, $value )
     {
-        $this->mainWidget = $w;
+        switch ( $name )
+        {
+            case 'mainWidget':
+            case 'pageMainUrl':
+            case 'eventCreator':
+            case 'pageSelector':
+                $this->properties[$name] = $value;
+                break;
+            default:
+                throw new ezcBasePropertyNotFoundException( $name );
+                break;
+        }
+
     }
 
-    public function setPageMainUrl( $url )
+    /**
+     * Returns the property $name.
+     *
+     * @throws ezcBasePropertyNotFoundException if the property does not exist.
+     * @param string $name
+     * @return mixed
+     * @ignore
+     */
+    public function __get( $name )
     {
-        $this->pageMainUrl = $url;
-    }
+        switch ( $name )
+        {
+            case 'mainWidget':
+            case 'pageMainUrl':
+            case 'eventCreator':
+            case 'pageSelector':
+                return isset( $this->properties[$name] ) ? 
$this->properties[$name] : null;
+                break;
 
-    public function getPageMainUrl( )
-    {
-        return $this->pageMainUrl;
+            default:
+                throw new ezcBasePropertyNotFoundException( $name );
+                break;
+        }
     }
 
     public function setEventCreator( ezcWgEventCreator $creator )

Modified: experimental/Widget/src/widgets/form_field_element.php
===================================================================
--- experimental/Widget/src/widgets/form_field_element.php      2006-08-28 
11:07:01 UTC (rev 3408)
+++ experimental/Widget/src/widgets/form_field_element.php      2006-08-28 
12:20:45 UTC (rev 3409)
@@ -16,8 +16,8 @@
 abstract class ezcWgFormFieldElement extends ezcWgFormElement
 {
     private $baseName;
-    protected $name;
     private $isArrayElement = false;
+    private $properties = array();
 
     public function __construct( ezcWgWidget $parent, ezcWgFormWidget $form, 
$baseName, $isArrayElement = false )
     {
@@ -29,18 +29,57 @@
         $form->registerElement( $this );
     }
 
-    public function getName()
+    /**
+     * Sets the property $name to $value.
+     *
+     * @throws ezcBasePropertyNotFoundException if the property does not exist.
+     * @param string $name
+     * @param mixed $value
+     * @ignore
+     */
+    public function __set( $name, $value )
     {
-        return $this->name;
+        switch ( $name )
+        {
+            case 'name':
+                throw new ezcBasePropertyPermissionException( $name, 
ezcBasePropertyPermissionException::READ );
+                break;
+            default:
+                throw new ezcBasePropertyNotFoundException( $name );
+                break;
+        }
+
     }
 
+    /**
+     * Returns the property $name.
+     *
+     * @throws ezcBasePropertyNotFoundException if the property does not exist.
+     * @param string $name
+     * @return mixed
+     * @ignore
+     */
+    public function __get( $name )
+    {
+        switch ( $name )
+        {
+            case 'name':
+                return isset( $this->properties[$name] ) ? 
$this->properties[$name] : null;
+                break;
+
+            default:
+                throw new ezcBasePropertyNotFoundException( $name );
+                break;
+        }
+    }
+
     public function setId( $id )
     {
-        $this->name = "{$this->baseName}_{$id}";
+        $this->properties['name'] = "{$this->baseName}_{$id}";
 
         if( $this->isArrayElement == true )
         {
-            $this->name .= "[]";
+            $this->properties['name'] .= "[]";
         }
     }
 

-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to