Пример #1
0
 public static function encode($param)
 {
     if (extension_loaded('JSON')) {
         return json_encode($param);
     } else {
         $temp = new TJSON();
         return $temp->encode($param);
     }
 }
Пример #2
0
 /**
  * Raises the callback event. This method is required by {@link
  * ICallbackEventHandler} interface. If {@link getCausesValidation
  * CausesValidation} is true, it will invoke the page's {@link TPage::
  * validate validate} method first. It will raise {@link onClick
  * OnClick} event first and then the {@link onCallback OnCallback} event. 
  * This method is mainly used by framework and control developers.
  * @param TCallbackEventParameter the event parameter
  */
 public function raiseCallbackEvent($param)
 {
     $json = new TJSON();
     $paramObj = $json->decode($param->getCallbackParameter());
     switch ($paramObj->eventType) {
         case "__BActiveGoogleMap_OnMoveEnd__":
             // raise the event
             $eventParam = new TCallbackEventParameter($this->getResponse(), $paramObj->clientSide);
             $this->onMoveEnd($eventParam);
             break;
         case "__BActiveGoogleMap_OnMarkerChanged__":
             // raise the event
             $eventParam = new TCallbackEventParameter($this->getResponse(), $paramObj->markerID);
             $this->onMarkerChanged($eventParam);
             break;
         case "__BActiveGoogleMap_OnMarkerDrag__":
             $eventParam = new TCallbackEventParameter($this->getResponse(), new BMarkerDragEventParameter($paramObj->markerID, $paramObj->clientSide, $paramObj->lat, $paramObj->lng));
             $this->onMarkerDrag($eventParam);
             $eventParam = new TCallbackEventParameter($this->getResponse(), $paramObj->clientSide);
             $this->onMoveEnd($eventParam);
             break;
         case "__BActiveGoogleMap_OnClick__":
             $eventParam = new TCallbackEventParameter($this->getResponse(), new BMapClickEventParameter($paramObj->clientSide, $paramObj->lat, $paramObj->lng));
             $this->onClick($eventParam);
             break;
     }
 }
 /**
  * Gets the data collected during the callback request. It contains
  * all the inputs for controls that implements IPostBackEventHandler.
  * @return array callback data.
  */
 public function getPostData()
 {
     if (isset($_POST['__data'])) {
         require_once dirname(__FILE__) . '/TJSON.php';
         $json = new TJSON();
         return $json->decode($_POST['__data']);
     }
     return array();
 }
 /**
  * Renders the response, send JSON encoded data, if any, in the header
  * X-JSON and renders the output.
  */
 public function render()
 {
     $data = $this->getData();
     if (!is_null($data)) {
         require_once dirname(__FILE__) . '/TJSON.php';
         $json = new TJSON();
         header('X-JSON: ' . $json->enc($data));
     }
     echo $this->getOutput();
 }