Inheritance: implements Gpf_Rpc_DataEncoder, implements Gpf_Rpc_DataDecoder
コード例 #1
0
ファイル: Task.class.php プロジェクト: AmineCherrai/rostanvo
    protected function execute() {
        $json = new Gpf_Rpc_Json();
        $processor = new Pap_Features_CompressedCommissionPlacementModel_Processor();
        if ($this->isPending('initAffiliatesList', $this->_('Initialization affiliates list'))) {
            $this->debug('initAffiliatesList');
            $this->userIds = $processor->initAffiliates();
            $this->setParams($json->encode($this->userIds));
            $this->setDone();
        }

        if ($this->isPending('initTransactionsList', $this->_('Initialization transactions list'))) {
            $this->debug('initTransactionsList');
            $this->userIds = $json->decode($this->getParams());
            $this->affectedTransactions = $processor->initTransactions($this->userIds);
            $this->setParams($json->encode($this->getTransactionIdsFromCollection($this->affectedTransactions)));
            $this->setDone();
        }
        $affectedTransactionIds = $this->getCollectionFromIds($json->decode($this->getParams()));
        $this->debug('process transactions');

        while ($affectedTransactionIds->getSize() > 0) {
            if ($this->isPending($this->getFirstElement($affectedTransactionIds)->getId(), $this->_('Compressed transaction: %s', $this->getFirstElement($affectedTransactionIds)->getId()))) {

                $processor->processFirstTransaction($affectedTransactionIds);
                $this->setDone();
            }
            else {
                $processor->removeByTransactionId($this->getFirstElement($affectedTransactionIds)->getId(), $affectedTransactionIds);
            }
        }
        $this->debug('finish task');
        $this->forceFinishTask();
    }
コード例 #2
0
 private function removeMapOverlayFromAffiliatePanel() {
     $affMenu = Gpf_Settings::get(Pap_Settings::AFFILIATE_MENU);
     $json = new Gpf_Rpc_Json();
     $affMenuDecoded = $json->decode($affMenu);
     try {
         $affMenuDecoded = $this->removeMenuItem($affMenuDecoded, $this->getMapOverlayScreenId());
         Gpf_Settings::set(Pap_Settings::AFFILIATE_MENU,$json->encode($affMenuDecoded));
     } catch (Gpf_DbEngine_NoRowException $e) {
     }
 }
コード例 #3
0
 protected function getRequestIdsIterator()
 {
     $json = new Gpf_Rpc_Json();
     $requestParams = new Gpf_Rpc_Params($json->decode($this->params->get(self::IDS_REQUEST)));
     $c = $requestParams->getClass();
     $gridService = new $c();
     if (!$gridService instanceof Gpf_View_GridService) {
         throw new Gpf_Exception(sprintf('%s is not Gpf_View_GridService class.', $requestParams->getClass()));
     }
     return $gridService->getIdsIterator($requestParams);
 }
コード例 #4
0
 public static function render()
 {
     $encoder = new Gpf_Rpc_Json();
     $out = '';
     $response = self::getInstance();
     foreach ($response->encodedResponses as $id => $value) {
         $out .= 'window["' . $id . '"]="' . $value . '";';
     }
     foreach ($response->responses as $id => $value) {
         $out .= 'window["' . $id . '"]="' . addcslashes($encoder->encodeResponse($value), '"\\') . '";';
     }
     return '<script type="text/javascript">' . $out . '</script>';
 }
コード例 #5
0
 public function execute() {
     $tree = Gpf_Settings::get(Pap_Settings::AFFILIATE_MENU);
     
     if (strpos($tree, '"data":{"code":')) {
         return;
     }
     
     $json = new Gpf_Rpc_Json();
     $tree = $json->decode($tree);
     
     $this->changeItem($tree);
     
     Gpf_Settings::set(Pap_Settings::AFFILIATE_MENU,$json->encode($tree));
 }
コード例 #6
0
 /**
  * @param $request
  * @param $groupId
  * @param $validTo
  * @return string
  */
 public function __construct(Gpf_Rpc_Request $request, Gpf_DateTime $validTo = null)
 {
     parent::__construct();
     $json = new Gpf_Rpc_Json();
     if ($validTo === null) {
         $validTo = new Gpf_DateTime();
         $validTo->addDay(30);
     }
     $this->setAccountId(Gpf_Session::getInstance()->getAuthUser()->getAccountId());
     $this->setGroupId('');
     $this->setRequest($json->encode($request->toObject()));
     $this->setValidTo($validTo->toDateTime());
     $this->insert();
     return $this;
 }
コード例 #7
0
ファイル: Main.class.php プロジェクト: AmineCherrai/rostanvo
	public function execute(){
		$response = '';
		try {
			if(isset($_REQUEST['action'])){
				$action = @$_REQUEST['action'];
				$response = $this->createResponse($action);
			}else {
				$response = new Pap_Mobile_Response(false);
				$response->exception = Gpf_Lang::_('Unsupported action');
			}
		} catch (Gpf_Rpc_SessionExpiredException $e) {
			$response = new Pap_Mobile_Response(false);
			$response->exception = 'session_expired';
		} catch (Exception $e) {
			$response = new Pap_Mobile_Response(false);
			$response->exception = Gpf_Lang::_('Response failed on server: ').$e->getMessage();
			// 			$response->trace = $e->getTraceAsString();
		}
		$json = new Gpf_Rpc_Json();
		echo $json->encode($response);
	}
コード例 #8
0
 private function addField($caption, $code, $type, $status, $help = '', $values = array())
 {
     $record = $this->fieldsRecordset->createRecord();
     $record->set('id', '0');
     $record->set('code', $code);
     $record->set('name', $caption);
     $record->set('help', $help);
     $record->set('type', $type);
     $record->set('status', $status);
     if (count($values) > 0) {
         $valuesRecordSet = new Gpf_Data_RecordSet();
         $valuesRecordSet->setHeader(array("id", "value"));
         foreach ($values as $id => $value) {
             if ($id != '') {
                 $valuesRecordSet->add(array($id, $value));
             }
         }
         $json = new Gpf_Rpc_Json();
         $record->set('availablevalues', $json->encode($valuesRecordSet->toObject()));
     }
     $this->fieldsRecordset->addRecord($record);
 }
コード例 #9
0
 private function loadActions($actionsString) {
     if ($actionsString == '') {
         throw new Gpf_Exception($this->_('no actions in visit'));
     }
     $actionsArray = $this->json->decode($actionsString);
     if (!is_array($actionsArray)) {
         throw new Gpf_Exception($this->_('invalid action format (%s)', $actionsString));
     }
     $actions = array();
     foreach ($actionsArray as $actionObject) {
         $actions[] = new Pap_Tracking_Action_RequestActionObject($actionObject);
     }
     return $actions;
 }
コード例 #10
0
 public function send()
 {
     $request = new Gpf_Rpc_Request($this->serverClassName, Gpf_Rpc_Server::RUN_METHOD);
     if ($this->useNewStyleRequestsEncoding) {
         $request->addParam(Gpf_Rpc_Server::REQUESTS_SHORT, $this->requests);
     } else {
         $request->addParam(Gpf_Rpc_Server::REQUESTS, $this->requests);
     }
     if ($this->sessionId != null) {
         $request->addParam("S", $this->sessionId);
     }
     $requestBody = $this->json->encodeResponse($request);
     $responseText = $this->sendRequest($requestBody);
     if ($this->debugRequests) {
         echo "REQUEST: " . $requestBody . "<br/>";
         echo "RESPONSE: " . $responseText . "<br/><br/>";
     }
     $responseArray = $this->json->decode($responseText);
     if (!is_array($responseArray)) {
         throw new Gpf_Exception("Response decoding failed: not array. Received text: {$responseText}");
     }
     if (count($responseArray) != $this->requests->getCount()) {
         throw new Gpf_Exception("Response decoding failed: Number of responses is not same as number of requests");
     }
     $exception = false;
     foreach ($responseArray as $index => $response) {
         if (is_object($response) && isset($response->e)) {
             $exception = true;
             $this->requests->get($index)->setResponseError($response->e);
         } else {
             $this->requests->get($index)->setResponse($response);
         }
     }
     if ($exception) {
         $messages = '';
         foreach ($this->requests as $request) {
             $messages .= $request->getResponseError() . "|";
         }
     }
     $this->requests = new Gpf_Rpc_Array();
     if ($exception) {
         throw new Gpf_Rpc_ExecutionException($messages);
     }
 }
コード例 #11
0
 /**
  * array-walking function for use in generating JSON-formatted name-value pairs
  *
  * @param    string  $name   name of key to use
  * @param    mixed   $value  reference to an array element to be encoded
  *
  * @return   string  JSON-formatted name-value pair, like '"name":value'
  * @access   private
  */
 function name_value($name, $value)
 {
     $encoded_value = $this->encode($value);
     if (Gpf_Rpc_Json::isError($encoded_value)) {
         return $encoded_value;
     }
     return $this->encode(strval($name)) . ':' . $encoded_value;
 }
コード例 #12
0
ファイル: OFC_Chart.php プロジェクト: AmineCherrai/rostanvo
	function toString()
	{
		$json = new Gpf_Rpc_Json();
		return $json->encode( $this );
	}
コード例 #13
0
 public function __construct($request)
 {
     $json = new Gpf_Rpc_Json();
     $this->params = new Gpf_Rpc_Params($json->decode($request));
     parent::__construct($this->params);
 }
コード例 #14
0
 public function addAvailableValue($value, $label)
 {
     $record = $this->availableValues->createRecord();
     $record->set('id', $value);
     $record->set('name', $label);
     $this->availableValues->addRecord($record);
     $json = new Gpf_Rpc_Json();
     $this->setAvailableValues($json->encodeResponse($this->availableValues));
 }
コード例 #15
0
 public function encode()
 {
     $json = new Gpf_Rpc_Json();
     return $json->encode($this);
 }
コード例 #16
0
 protected function loadFromTask() {
     parent::loadFromTask();
     $json = new Gpf_Rpc_Json();
     $values = $json->decode($this->getParams());
     $this->paramsArray['papUserIds'] = $values->papUserIds;
 }
コード例 #17
0
 private function addPostParams(Gpf_Rpc_Params $params) {        
     if ($params->exists('fields')) {
     	$json = new Gpf_Rpc_Json();
         foreach ($params->get('fields') as $field) {
             if (!$params->exists($field[0])) {
                 $decodedItem = $json->decode($field[1]);
                 if ($decodedItem !== null || $decodedItem != '') {
                     $params->add($field[0], $decodedItem);
                 } else {
                     $params->add($field[0], $field[1]);
                 }
             }
         }
     }
 }
コード例 #18
0
 private function exportClientCacheFile($dirName)
 {
     $file = new Gpf_Io_File($this->getCacheFileName($dirName, false));
     $file->setFileMode('w');
     if (!$file->isExists()) {
         $file->setFilePermissions(0777);
     }
     $recordSet = new Gpf_Data_RecordSet();
     $recordSet->setHeader(array('source', 'translation'));
     foreach ($this->translations as $translation) {
         if ($translation->getType() == Gpf_Lang_Parser_Translation::TYPE_CLIENT || $translation->getType() == Gpf_Lang_Parser_Translation::TYPE_BOTH) {
             if ($translation->getStatus() != 'D') {
                 $recordSet->add(array($translation->getSourceMessage(), $translation->getDestinationMessage()));
             }
         }
     }
     $recordSet->add(array("_dateFormat", $this->getMetaValue(self::LANG_DATE_FORMAT)));
     $recordSet->add(array("_timeFormat", $this->getMetaValue(self::LANG_TIME_FORMAT)));
     $recordSet->add(array("_thousandsSeparator", $this->getMetaValue(self::LANG_THOUSANDS_SEPARATOR)));
     $recordSet->add(array("_decimalSeparator", $this->getMetaValue(self::LANG_DECIMAL_SEPARATOR)));
     $encoder = new Gpf_Rpc_Json();
     $file->write(addcslashes($encoder->encodeResponse($recordSet), '"\\'));
     $file->close();
 }
コード例 #19
0
 protected function updateTask()
 {
     if ($this->doneProgress !== null) {
         $json = new Gpf_Rpc_Json();
         $this->task->setParams($json->encode($this->paramsArray));
         $this->task->setProgress($this->doneProgress);
         $this->task->setProgressMessage($this->getProgressMessage());
         $this->task->updateTask();
     }
 }
コード例 #20
0
 /**
  * @return string  string representation of input var or an error if a problem occurs
  */
 public function encodeResponse(Gpf_Rpc_Serializable $response)
 {
     return '<html><script type="text/javascript">
     window.name="' . addcslashes(parent::encodeResponse($response), '"\\') . '";</script></html>';
 }
コード例 #21
0
	private function saveParams($params) {
		$json = new Gpf_Rpc_Json();
		$encoded = $json->encode($params);
		$this->setParams($encoded);
	}
コード例 #22
0
 protected function getSaleParams()
 {
     if (count($this->sales) == 0) {
         return '';
     }
     $json = new Gpf_Rpc_Json();
     return $json->encode($this->sales);
 }
コード例 #23
0
 public function getJSONString($withRoot = true, $states = null)
 {
     if ($this->mpttArray == null) {
         throw new Gpf_Exception('No tree Records were set! There are no data to create JSON string');
     }
     $levels = array();
     $stack = 0;
     $oldDepth = -1;
     $headers = $this->getHeaders($this->mpttArray->getHeader());
     $oldStates = array();
     foreach ($this->mpttArray as $row) {
         $depth = $row->get('depth');
         // code, depth   //name,visible
         if ($depth == $oldDepth) {
             //no level change
             if (count($oldStates) > 0) {
                 array_pop($oldStates);
             }
             array_push($oldStates, $row->get('state'));
             if ($this->checkPrevioursStatesAreCorrect($oldStates, $states)) {
                 $levels[$depth][] = $this->createObject($row, $headers);
             }
         }
         if ($depth > $oldDepth) {
             //level raised
             array_push($oldStates, $row->get('state'));
             if ($this->checkPrevioursStatesAreCorrect($oldStates, $states)) {
                 $levels[$depth][] = $this->createObject($row, $headers);
             }
             $stack = $depth;
         }
         if ($depth < $oldDepth) {
             //level drop
             while ($stack > $depth) {
                 $stack--;
                 array_pop($oldStates);
                 if ($this->checkPrevioursStatesAreCorrect($oldStates, $states)) {
                     $array = $this->cloneArray($levels[$stack + 1]);
                     $levels[$stack][count($levels[$stack]) - 1]->items = $array;
                     unset($levels[$stack + 1]);
                 }
             }
             array_pop($oldStates);
             array_push($oldStates, $row->get('state'));
             if ($this->checkPrevioursStatesAreCorrect($oldStates, $states)) {
                 $levels[$depth][] = $this->createObject($row, $headers);
             }
         }
         $oldDepth = $depth;
     }
     while ($stack > 0) {
         $stack--;
         array_pop($oldStates);
         if ($this->checkPrevioursStatesAreCorrect($oldStates, $states)) {
             if (array_key_exists($stack + 1, $levels)) {
                 $levels[$stack][count($levels[$stack]) - 1]->items = $this->cloneArray($levels[$stack + 1]);
                 unset($levels[$stack + 1]);
             }
         }
     }
     $json = new Gpf_Rpc_Json();
     if ($withRoot) {
         return $json->encode($levels[0]);
     }
     if (array_key_exists(0, $levels)) {
         return $json->encode($levels[0][0]->items);
     }
     return 'null';
 }