示例#1
0
文件: WRuler.php 项目: point/cassea
 function handleEvent(WidgetEvent $event)
 {
     if ($event->getName() == "ruler_settotal") {
         $this->setTotalCount($event->getParam('total_count'));
         $this->calc();
         Controller::getInstance()->getDispatcher()->notify(new WidgetEvent("roll_setlimits", $this->getId(), $event->getSrc(), array('from' => ($this->current_page - 1) * $this->res_per_page, "limit" => ($_r = $this->total_count - $this->current_page * $this->res_per_page) < 0 ? $this->res_per_page + $_r : $this->res_per_page)));
     } elseif ($event->getName() == "ruler_has_another_instance") {
         $this->setUseGET(1);
         $controller = Controller::getInstance();
         $controller->getDisplayModeParams()->predicted_from = $controller->getDisplayModeParams()->prdicted_limit = null;
     }
     parent::handleEvent($event);
 }
示例#2
0
 /**
  * Sends message to the all subscribed widgets.
  * Name of the event is stored int the $event_obj object 
  * and should be specified.
  *
  * Additionally, destination widget id will be checked.
  * 
  * @param WidgetEvent object to be send.
  * @return null
  */
 function notify(WidgetEvent $event_obj)
 {
     $controller = Controller::getInstance();
     $event = $event_obj->getName();
     if (!isset($this->events[$event])) {
         return;
     }
     if (!empty($this->subscribers[$event])) {
         for ($i = 0, $c = count($this->subscribers[$event]); $i < $c; $i++) {
             $id = $this->subscribers[$event][$i];
             if (!isset($id)) {
                 continue;
             }
             if (!$event_obj->inDst($id) || ($src_id = $event_obj->getSrc()) && $src_id == $id) {
                 continue;
             }
             $controller->getWidget($id)->handleEvent($event_obj);
         }
     }
 }