Advertisement
Guest User

unzend.com_290

a guest
Jul 4th, 2015
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 22.06 KB | None | 0 0
  1. <?php
  2. // Ioncube Decoder Unzend.Com Email unzend@gmail.com
  3. // http://www.unzend.com
  4. /**
  5.  * This file contains the foundation classes for component-based and event-driven programming.
  6.  *
  7.  * @author Qiang Xue <qiang.xue@gmail.com>
  8.  * @link http://www.yiiframework.com/
  9.  * @copyright 2008-2013 Yii Software LLC
  10.  * @license http://www.yiiframework.com/license/
  11.  */
  12.  
  13. /**
  14.  * CComponent is the base class for all components.
  15.  *
  16.  * CComponent implements the protocol of defining, using properties and events.
  17.  *
  18.  * A property is defined by a getter method, and/or a setter method.
  19.  * Properties can be accessed in the way like accessing normal object members.
  20.  * Reading or writing a property will cause the invocation of the corresponding
  21.  * getter or setter method, e.g
  22.  * <pre>
  23.  * $a=$component->text;     // equivalent to $a=$component->getText();
  24.  * $component->text='abc';  // equivalent to $component->setText('abc');
  25.  * </pre>
  26.  * The signatures of getter and setter methods are as follows,
  27.  * <pre>
  28.  * // getter, defines a readable property 'text'
  29.  * public function getText() { ... }
  30.  * // setter, defines a writable property 'text' with $value to be set to the property
  31.  * public function setText($value) { ... }
  32.  * </pre>
  33.  *
  34.  * An event is defined by the presence of a method whose name starts with 'on'.
  35.  * The event name is the method name. When an event is raised, functions
  36.  * (called event handlers) attached to the event will be invoked automatically.
  37.  *
  38.  * An event can be raised by calling {@link raiseEvent} method, upon which
  39.  * the attached event handlers will be invoked automatically in the order they
  40.  * are attached to the event. Event handlers must have the following signature,
  41.  * <pre>
  42.  * function eventHandler($event) { ... }
  43.  * </pre>
  44.  * where $event includes parameters associated with the event.
  45.  *
  46.  * To attach an event handler to an event, see {@link attachEventHandler}.
  47.  * You can also use the following syntax:
  48.  * <pre>
  49.  * $component->onClick=$callback;    // or $component->onClick->add($callback);
  50.  * </pre>
  51.  * where $callback refers to a valid PHP callback. Below we show some callback examples:
  52.  * <pre>
  53.  * 'handleOnClick'                   // handleOnClick() is a global function
  54.  * array($object,'handleOnClick')    // using $object->handleOnClick()
  55.  * array('Page','handleOnClick')     // using Page::handleOnClick()
  56.  * </pre>
  57.  *
  58.  * To raise an event, use {@link raiseEvent}. The on-method defining an event is
  59.  * commonly written like the following:
  60.  * <pre>
  61.  * public function onClick($event)
  62.  * {
  63.  *     $this->raiseEvent('onClick',$event);
  64.  * }
  65.  * </pre>
  66.  * where <code>$event</code> is an instance of {@link CEvent} or its child class.
  67.  * One can then raise the event by calling the on-method instead of {@link raiseEvent} directly.
  68.  *
  69.  * Both property names and event names are case-insensitive.
  70.  *
  71.  * CComponent supports behaviors. A behavior is an
  72.  * instance of {@link IBehavior} which is attached to a component. The methods of
  73.  * the behavior can be invoked as if they belong to the component. Multiple behaviors
  74.  * can be attached to the same component.
  75.  *
  76.  * To attach a behavior to a component, call {@link attachBehavior}; and to detach the behavior
  77.  * from the component, call {@link detachBehavior}.
  78.  *
  79.  * A behavior can be temporarily enabled or disabled by calling {@link enableBehavior}
  80.  * or {@link disableBehavior}, respectively. When disabled, the behavior methods cannot
  81.  * be invoked via the component.
  82.  *
  83.  * Starting from version 1.1.0, a behavior's properties (either its public member variables or
  84.  * its properties defined via getters and/or setters) can be accessed through the component it
  85.  * is attached to.
  86.  *
  87.  * @author Qiang Xue <qiang.xue@gmail.com>
  88.  * @package system.base
  89.  * @since 1.0
  90.  */
  91. class CComponent
  92. {
  93.     private $_e;
  94.     private $_m;
  95.  
  96.     /**
  97.      * Returns a property value, an event handler list or a behavior based on its name.
  98.      * Do not call this method. This is a PHP magic method that we override
  99.      * to allow using the following syntax to read a property or obtain event handlers:
  100.      * <pre>
  101.      * $value=$component->propertyName;
  102.      * $handlers=$component->eventName;
  103.      * </pre>
  104.      * @param string $name the property name or event name
  105.      * @return mixed the property value, event handlers attached to the event, or the named behavior
  106.      * @throws CException if the property or event is not defined
  107.      * @see __set
  108.      */
  109.     public function __get($name)
  110.     {
  111.         $getter='get'.$name;
  112.         if(method_exists($this,$getter))
  113.             return $this->$getter();
  114.         elseif(strncasecmp($name,'on',2)===0 && method_exists($this,$name))
  115.         {
  116.             // duplicating getEventHandlers() here for performance
  117.             $name=strtolower($name);
  118.             if(!isset($this->_e[$name]))
  119.                 $this->_e[$name]=new CList;
  120.             return $this->_e[$name];
  121.         }
  122.         elseif(isset($this->_m[$name]))
  123.             return $this->_m[$name];
  124.         elseif(is_array($this->_m))
  125.         {
  126.             foreach($this->_m as $object)
  127.             {
  128.                 if($object->getEnabled() && (property_exists($object,$name) || $object->canGetProperty($name)))
  129.                     return $object->$name;
  130.             }
  131.         }
  132.         throw new CException(Yii::t('yii','Property "{class}.{property}" is not defined.',
  133.             array('{class}'=>get_class($this), '{property}'=>$name)));
  134.     }
  135.  
  136.     /**
  137.      * Sets value of a component property.
  138.      * Do not call this method. This is a PHP magic method that we override
  139.      * to allow using the following syntax to set a property or attach an event handler
  140.      * <pre>
  141.      * $this->propertyName=$value;
  142.      * $this->eventName=$callback;
  143.      * </pre>
  144.      * @param string $name the property name or the event name
  145.      * @param mixed $value the property value or callback
  146.      * @return mixed
  147.      * @throws CException if the property/event is not defined or the property is read only.
  148.      * @see __get
  149.      */
  150.     public function __set($name,$value)
  151.     {
  152.         $setter='set'.$name;
  153.         if(method_exists($this,$setter))
  154.             return $this->$setter($value);
  155.         elseif(strncasecmp($name,'on',2)===0 && method_exists($this,$name))
  156.         {
  157.             // duplicating getEventHandlers() here for performance
  158.             $name=strtolower($name);
  159.             if(!isset($this->_e[$name]))
  160.                 $this->_e[$name]=new CList;
  161.             return $this->_e[$name]->add($value);
  162.         }
  163.         elseif(is_array($this->_m))
  164.         {
  165.             foreach($this->_m as $object)
  166.             {
  167.                 if($object->getEnabled() && (property_exists($object,$name) || $object->canSetProperty($name)))
  168.                     return $object->$name=$value;
  169.             }
  170.         }
  171.         if(method_exists($this,'get'.$name))
  172.             throw new CException(Yii::t('yii','Property "{class}.{property}" is read only.',
  173.                 array('{class}'=>get_class($this), '{property}'=>$name)));
  174.         else
  175.             throw new CException(Yii::t('yii','Property "{class}.{property}" is not defined.',
  176.                 array('{class}'=>get_class($this), '{property}'=>$name)));
  177.     }
  178.  
  179.     /**
  180.      * Checks if a property value is null.
  181.      * Do not call this method. This is a PHP magic method that we override
  182.      * to allow using isset() to detect if a component property is set or not.
  183.      * @param string $name the property name or the event name
  184.      * @return boolean
  185.      */
  186.     public function __isset($name)
  187.     {
  188.         $getter='get'.$name;
  189.         if(method_exists($this,$getter))
  190.             return $this->$getter()!==null;
  191.         elseif(strncasecmp($name,'on',2)===0 && method_exists($this,$name))
  192.         {
  193.             $name=strtolower($name);
  194.             return isset($this->_e[$name]) && $this->_e[$name]->getCount();
  195.         }
  196.         elseif(is_array($this->_m))
  197.         {
  198.             if(isset($this->_m[$name]))
  199.                 return true;
  200.             foreach($this->_m as $object)
  201.             {
  202.                 if($object->getEnabled() && (property_exists($object,$name) || $object->canGetProperty($name)))
  203.                     return $object->$name!==null;
  204.             }
  205.         }
  206.         return false;
  207.     }
  208.  
  209.     /**
  210.      * Sets a component property to be null.
  211.      * Do not call this method. This is a PHP magic method that we override
  212.      * to allow using unset() to set a component property to be null.
  213.      * @param string $name the property name or the event name
  214.      * @throws CException if the property is read only.
  215.      * @return mixed
  216.      */
  217.     public function __unset($name)
  218.     {
  219.         $setter='set'.$name;
  220.         if(method_exists($this,$setter))
  221.             $this->$setter(null);
  222.         elseif(strncasecmp($name,'on',2)===0 && method_exists($this,$name))
  223.             unset($this->_e[strtolower($name)]);
  224.         elseif(is_array($this->_m))
  225.         {
  226.             if(isset($this->_m[$name]))
  227.                 $this->detachBehavior($name);
  228.             else
  229.             {
  230.                 foreach($this->_m as $object)
  231.                 {
  232.                     if($object->getEnabled())
  233.                     {
  234.                         if(property_exists($object,$name))
  235.                             return $object->$name=null;
  236.                         elseif($object->canSetProperty($name))
  237.                             return $object->$setter(null);
  238.                     }
  239.                 }
  240.             }
  241.         }
  242.         elseif(method_exists($this,'get'.$name))
  243.             throw new CException(Yii::t('yii','Property "{class}.{property}" is read only.',
  244.                 array('{class}'=>get_class($this), '{property}'=>$name)));
  245.     }
  246.  
  247.     /**
  248.      * Calls the named method which is not a class method.
  249.      * Do not call this method. This is a PHP magic method that we override
  250.      * to implement the behavior feature.
  251.      * @param string $name the method name
  252.      * @param array $parameters method parameters
  253.      * @throws CException if current class and its behaviors do not have a method or closure with the given name
  254.      * @return mixed the method return value
  255.      */
  256.     public function __call($name,$parameters)
  257.     {
  258.         if($this->_m!==null)
  259.         {
  260.             foreach($this->_m as $object)
  261.             {
  262.                 if($object->getEnabled() && method_exists($object,$name))
  263.                     return call_user_func_array(array($object,$name),$parameters);
  264.             }
  265.         }
  266.         if(class_exists('Closure', false) && $this->canGetProperty($name) && $this->$name instanceof Closure)
  267.             return call_user_func_array($this->$name, $parameters);
  268.         throw new CException(Yii::t('yii','{class} and its behaviors do not have a method or closure named "{name}".',
  269.             array('{class}'=>get_class($this), '{name}'=>$name)));
  270.     }
  271.  
  272.     /**
  273.      * Returns the named behavior object.
  274.      * The name 'asa' stands for 'as a'.
  275.      * @param string $behavior the behavior name
  276.      * @return IBehavior the behavior object, or null if the behavior does not exist
  277.      */
  278.     public function asa($behavior)
  279.     {
  280.         return isset($this->_m[$behavior]) ? $this->_m[$behavior] : null;
  281.     }
  282.  
  283.     /**
  284.      * Attaches a list of behaviors to the component.
  285.      * Each behavior is indexed by its name and should be an instance of
  286.      * {@link IBehavior}, a string specifying the behavior class, or an
  287.      * array of the following structure:
  288.      * <pre>
  289.      * array(
  290.      *     'class'=>'path.to.BehaviorClass',
  291.      *     'property1'=>'value1',
  292.      *     'property2'=>'value2',
  293.      * )
  294.      * </pre>
  295.      * @param array $behaviors list of behaviors to be attached to the component
  296.      */
  297.     public function attachBehaviors($behaviors)
  298.     {
  299.         foreach($behaviors as $name=>$behavior)
  300.             $this->attachBehavior($name,$behavior);
  301.     }
  302.  
  303.     /**
  304.      * Detaches all behaviors from the component.
  305.      */
  306.     public function detachBehaviors()
  307.     {
  308.         if($this->_m!==null)
  309.         {
  310.             foreach($this->_m as $name=>$behavior)
  311.                 $this->detachBehavior($name);
  312.             $this->_m=null;
  313.         }
  314.     }
  315.  
  316.     /**
  317.      * Attaches a behavior to this component.
  318.      * This method will create the behavior object based on the given
  319.      * configuration. After that, the behavior object will be initialized
  320.      * by calling its {@link IBehavior::attach} method.
  321.      * @param string $name the behavior's name. It should uniquely identify this behavior.
  322.      * @param mixed $behavior the behavior configuration. This is passed as the first
  323.      * parameter to {@link YiiBase::createComponent} to create the behavior object.
  324.      * You can also pass an already created behavior instance (the new behavior will replace an already created
  325.      * behavior with the same name, if it exists).
  326.      * @return IBehavior the behavior object
  327.      */
  328.     public function attachBehavior($name,$behavior)
  329.     {
  330.         if(!($behavior instanceof IBehavior))
  331.             $behavior=Yii::createComponent($behavior);
  332.         $behavior->setEnabled(true);
  333.         $behavior->attach($this);
  334.         return $this->_m[$name]=$behavior;
  335.     }
  336.  
  337.     /**
  338.      * Detaches a behavior from the component.
  339.      * The behavior's {@link IBehavior::detach} method will be invoked.
  340.      * @param string $name the behavior's name. It uniquely identifies the behavior.
  341.      * @return IBehavior the detached behavior. Null if the behavior does not exist.
  342.      */
  343.     public function detachBehavior($name)
  344.     {
  345.         if(isset($this->_m[$name]))
  346.         {
  347.             $this->_m[$name]->detach($this);
  348.             $behavior=$this->_m[$name];
  349.             unset($this->_m[$name]);
  350.             return $behavior;
  351.         }
  352.     }
  353.  
  354.     /**
  355.      * Enables all behaviors attached to this component.
  356.      */
  357.     public function enableBehaviors()
  358.     {
  359.         if($this->_m!==null)
  360.         {
  361.             foreach($this->_m as $behavior)
  362.                 $behavior->setEnabled(true);
  363.         }
  364.     }
  365.  
  366.     /**
  367.      * Disables all behaviors attached to this component.
  368.      */
  369.     public function disableBehaviors()
  370.     {
  371.         if($this->_m!==null)
  372.         {
  373.             foreach($this->_m as $behavior)
  374.                 $behavior->setEnabled(false);
  375.         }
  376.     }
  377.  
  378.     /**
  379.      * Enables an attached behavior.
  380.      * A behavior is only effective when it is enabled.
  381.      * A behavior is enabled when first attached.
  382.      * @param string $name the behavior's name. It uniquely identifies the behavior.
  383.      */
  384.     public function enableBehavior($name)
  385.     {
  386.         if(isset($this->_m[$name]))
  387.             $this->_m[$name]->setEnabled(true);
  388.     }
  389.  
  390.     /**
  391.      * Disables an attached behavior.
  392.      * A behavior is only effective when it is enabled.
  393.      * @param string $name the behavior's name. It uniquely identifies the behavior.
  394.      */
  395.     public function disableBehavior($name)
  396.     {
  397.         if(isset($this->_m[$name]))
  398.             $this->_m[$name]->setEnabled(false);
  399.     }
  400.  
  401.     /**
  402.      * Determines whether a property is defined.
  403.      * A property is defined if there is a getter or setter method
  404.      * defined in the class. Note, property names are case-insensitive.
  405.      * @param string $name the property name
  406.      * @return boolean whether the property is defined
  407.      * @see canGetProperty
  408.      * @see canSetProperty
  409.      */
  410.     public function hasProperty($name)
  411.     {
  412.         return method_exists($this,'get'.$name) || method_exists($this,'set'.$name);
  413.     }
  414.  
  415.     /**
  416.      * Determines whether a property can be read.
  417.      * A property can be read if the class has a getter method
  418.      * for the property name. Note, property name is case-insensitive.
  419.      * @param string $name the property name
  420.      * @return boolean whether the property can be read
  421.      * @see canSetProperty
  422.      */
  423.     public function canGetProperty($name)
  424.     {
  425.         return method_exists($this,'get'.$name);
  426.     }
  427.  
  428.     /**
  429.      * Determines whether a property can be set.
  430.      * A property can be written if the class has a setter method
  431.      * for the property name. Note, property name is case-insensitive.
  432.      * @param string $name the property name
  433.      * @return boolean whether the property can be written
  434.      * @see canGetProperty
  435.      */
  436.     public function canSetProperty($name)
  437.     {
  438.         return method_exists($this,'set'.$name);
  439.     }
  440.  
  441.     /**
  442.      * Determines whether an event is defined.
  443.      * An event is defined if the class has a method named like 'onXXX'.
  444.      * Note, event name is case-insensitive.
  445.      * @param string $name the event name
  446.      * @return boolean whether an event is defined
  447.      */
  448.     public function hasEvent($name)
  449.     {
  450.         return !strncasecmp($name,'on',2) && method_exists($this,$name);
  451.     }
  452.  
  453.     /**
  454.      * Checks whether the named event has attached handlers.
  455.      * @param string $name the event name
  456.      * @return boolean whether an event has been attached one or several handlers
  457.      */
  458.     public function hasEventHandler($name)
  459.     {
  460.         $name=strtolower($name);
  461.         return isset($this->_e[$name]) && $this->_e[$name]->getCount()>0;
  462.     }
  463.  
  464.     /**
  465.      * Returns the list of attached event handlers for an event.
  466.      * @param string $name the event name
  467.      * @return CList list of attached event handlers for the event
  468.      * @throws CException if the event is not defined
  469.      */
  470.     public function getEventHandlers($name)
  471.     {
  472.         if($this->hasEvent($name))
  473.         {
  474.             $name=strtolower($name);
  475.             if(!isset($this->_e[$name]))
  476.                 $this->_e[$name]=new CList;
  477.             return $this->_e[$name];
  478.         }
  479.         else
  480.             throw new CException(Yii::t('yii','Event "{class}.{event}" is not defined.',
  481.                 array('{class}'=>get_class($this), '{event}'=>$name)));
  482.     }
  483.  
  484.     /**
  485.      * Attaches an event handler to an event.
  486.      *
  487.      * An event handler must be a valid PHP callback, i.e., a string referring to
  488.      * a global function name, or an array containing two elements with
  489.      * the first element being an object and the second element a method name
  490.      * of the object.
  491.      *
  492.      * An event handler must be defined with the following signature,
  493.      * <pre>
  494.      * function handlerName($event) {}
  495.      * </pre>
  496.      * where $event includes parameters associated with the event.
  497.      *
  498.      * This is a convenient method of attaching a handler to an event.
  499.      * It is equivalent to the following code:
  500.      * <pre>
  501.      * $component->getEventHandlers($eventName)->add($eventHandler);
  502.      * </pre>
  503.      *
  504.      * Using {@link getEventHandlers}, one can also specify the excution order
  505.      * of multiple handlers attaching to the same event. For example:
  506.      * <pre>
  507.      * $component->getEventHandlers($eventName)->insertAt(0,$eventHandler);
  508.      * </pre>
  509.      * makes the handler to be invoked first.
  510.      *
  511.      * @param string $name the event name
  512.      * @param callback $handler the event handler
  513.      * @throws CException if the event is not defined
  514.      * @see detachEventHandler
  515.      */
  516.     public function attachEventHandler($name,$handler)
  517.     {
  518.         $this->getEventHandlers($name)->add($handler);
  519.     }
  520.  
  521.     /**
  522.      * Detaches an existing event handler.
  523.      * This method is the opposite of {@link attachEventHandler}.
  524.      * @param string $name event name
  525.      * @param callback $handler the event handler to be removed
  526.      * @return boolean if the detachment process is successful
  527.      * @see attachEventHandler
  528.      */
  529.     public function detachEventHandler($name,$handler)
  530.     {
  531.         if($this->hasEventHandler($name))
  532.             return $this->getEventHandlers($name)->remove($handler)!==false;
  533.         else
  534.             return false;
  535.     }
  536.  
  537.     /**
  538.      * Raises an event.
  539.      * This method represents the happening of an event. It invokes
  540.      * all attached handlers for the event.
  541.      * @param string $name the event name
  542.      * @param CEvent $event the event parameter
  543.      * @throws CException if the event is undefined or an event handler is invalid.
  544.      */
  545.     public function raiseEvent($name,$event)
  546.     {
  547.         $name=strtolower($name);
  548.         if(isset($this->_e[$name]))
  549.         {
  550.             foreach($this->_e[$name] as $handler)
  551.             {
  552.                 if(is_string($handler))
  553.                     call_user_func($handler,$event);
  554.                 elseif(is_callable($handler,true))
  555.                 {
  556.                     if(is_array($handler))
  557.                     {
  558.                         // an array: 0 - object, 1 - method name
  559.                         list($object,$method)=$handler;
  560.                         if(is_string($object))  // static method call
  561.                             call_user_func($handler,$event);
  562.                         elseif(method_exists($object,$method))
  563.                             $object->$method($event);
  564.                         else
  565.                             throw new CException(Yii::t('yii','Event "{class}.{event}" is attached with an invalid handler "{handler}".',
  566.                                 array('{class}'=>get_class($this), '{event}'=>$name, '{handler}'=>$handler[1])));
  567.                     }
  568.                     else // PHP 5.3: anonymous function
  569.                         call_user_func($handler,$event);
  570.                 }
  571.                 else
  572.                     throw new CException(Yii::t('yii','Event "{class}.{event}" is attached with an invalid handler "{handler}".',
  573.                         array('{class}'=>get_class($this), '{event}'=>$name, '{handler}'=>gettype($handler))));
  574.                 // stop further handling if param.handled is set true
  575.                 if(($event instanceof CEvent) && $event->handled)
  576.                     return;
  577.             }
  578.         }
  579.         elseif(YII_DEBUG && !$this->hasEvent($name))
  580.             throw new CException(Yii::t('yii','Event "{class}.{event}" is not defined.',
  581.                 array('{class}'=>get_class($this), '{event}'=>$name)));
  582.     }
  583.  
  584.     /**
  585.      * Evaluates a PHP expression or callback under the context of this component.
  586.      *
  587.      * Valid PHP callback can be class method name in the form of
  588.      * array(ClassName/Object, MethodName), or anonymous function (only available in PHP 5.3.0 or above).
  589.      *
  590.      * If a PHP callback is used, the corresponding function/method signature should be
  591.      * <pre>
  592.      * function foo($param1, $param2, ..., $component) { ... }
  593.      * </pre>
  594.      * where the array elements in the second parameter to this method will be passed
  595.      * to the callback as $param1, $param2, ...; and the last parameter will be the component itself.
  596.      *
  597.      * If a PHP expression is used, the second parameter will be "extracted" into PHP variables
  598.      * that can be directly accessed in the expression. See {@link http://us.php.net/manual/en/function.extract.php PHP extract}
  599.      * for more details. In the expression, the component object can be accessed using $this.
  600.      *
  601.      * A PHP expression can be any PHP code that has a value. To learn more about what an expression is,
  602.      * please refer to the {@link http://www.php.net/manual/en/language.expressions.php php manual}.
  603.      *
  604.      * @param mixed $_expression_ a PHP expression or PHP callback to be evaluated.
  605.      * @param array $_data_ additional parameters to be passed to the above expression/callback.
  606.      * @return mixed the expression result
  607.      * @since 1.1.0
  608.      */
  609.     public function evaluateExpression($_expression_,$_data_=array())
  610.     {
  611.         if(is_string($_expression_))
  612.         {
  613.             extract($_data_);
  614.             return eval('return '.$_expression_.';');
  615.         }
  616.         else
  617.         {
  618.             $_data_[]=$this;
  619.             return call_user_func_array($_expression_, $_data_);
  620.         }
  621.     }
  622. }
  623.  
  624.  
  625. /**
  626.  * CEvent is the base class for all event classes.
  627.  *
  628.  * It encapsulates the parameters associated with an event.
  629.  * The {@link sender} property describes who raises the event.
  630.  * And the {@link handled} property indicates if the event is handled.
  631.  * If an event handler sets {@link handled} to true, those handlers
  632.  * that are not invoked yet will not be invoked anymore.
  633.  *
  634.  * @author Qiang Xue <qiang.xue@gmail.com>
  635.  * @package system.base
  636.  * @since 1.0
  637.  */
  638. class CEvent extends CComponent
  639. {
  640.     /**
  641.      * @var object the sender of this event
  642.      */
  643.     public $sender;
  644.     /**
  645.      * @var boolean whether the event is handled. Defaults to false.
  646.      * When a handler sets this true, the rest of the uninvoked event handlers will not be invoked anymore.
  647.      */
  648.     public $handled=false;
  649.     /**
  650.      * @var mixed additional event parameters.
  651.      * @since 1.1.7
  652.      */
  653.     public $params;
  654.  
  655.     /**
  656.      * Constructor.
  657.      * @param mixed $sender sender of the event
  658.      * @param mixed $params additional parameters for the event
  659.      */
  660.     public function __construct($sender=null,$params=null)
  661.     {
  662.         $this->sender=$sender;
  663.         $this->params=$params;
  664.     }
  665. }
  666.  
  667.  
  668. /**
  669.  * CEnumerable is the base class for all enumerable types.
  670.  *
  671.  * To define an enumerable type, extend CEnumberable and define string constants.
  672.  * Each constant represents an enumerable value.
  673.  * The constant name must be the same as the constant value.
  674.  * For example,
  675.  * <pre>
  676.  * class TextAlign extends CEnumerable
  677.  * {
  678.  *     const Left='Left';
  679.  *     const Right='Right';
  680.  * }
  681.  * </pre>
  682.  * Then, one can use the enumerable values such as TextAlign::Left and
  683.  * TextAlign::Right.
  684.  *
  685.  * @author Qiang Xue <qiang.xue@gmail.com>
  686.  * @package system.base
  687.  * @since 1.0
  688.  */
  689. class CEnumerable
  690. {
  691. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement