コード例 #1
0
 public function service($serviceName, $param, $response)
 {
     $this->serviceName = $serviceName;
     $this->param = $param;
     $this->response = $response;
     $this->digest = null;
     if (com_wiris_plugin_impl_TextServiceImpl::hasCache($serviceName)) {
         $this->digest = $this->plugin->newRender()->computeDigest(null, $param);
         $store = $this->plugin->getStorageAndCache();
         $ext = com_wiris_plugin_impl_TextServiceImpl::getDigestExtension($serviceName, $param);
         $s = $store->retreiveData($this->digest, $ext);
         if ($s !== null) {
             $response->returnString(com_wiris_system_Utf8::fromBytes($s));
             return;
         }
     }
     $url = $this->plugin->getImageServiceURL($serviceName, true);
     $h = new com_wiris_plugin_impl_HttpImpl($url, $this);
     $this->plugin->addReferer($h);
     $this->plugin->addProxy($h);
     if ($param !== null) {
         $ha = com_wiris_system_PropertiesTools::fromProperties($param);
         $iter = $ha->keys();
         while ($iter->hasNext()) {
             $k = $iter->next();
             $h->setParameter($k, $ha->get($k));
             unset($k);
         }
     }
     $h->request(true);
 }
コード例 #2
0
 public function service($serviceName, $param)
 {
     $digest = null;
     if (com_wiris_plugin_impl_TextServiceImpl::hasCache($serviceName)) {
         $digest = $this->plugin->newRender()->computeDigest(null, $param);
         $store = $this->plugin->getStorageAndCache();
         $ext = com_wiris_plugin_impl_TextServiceImpl::getDigestExtension($serviceName, $param);
         $s = $store->retreiveData($digest, $ext);
         if ($s !== null) {
             return com_wiris_system_Utf8::fromBytes($s);
         }
     }
     $result = $this->serviceText($serviceName, $param);
     if ($digest !== null) {
         $store = $this->plugin->getStorageAndCache();
         $ext = com_wiris_plugin_impl_TextServiceImpl::getDigestExtension($serviceName, $param);
         $store->storeData($digest, $ext, com_wiris_system_Utf8::toBytes($result));
     }
     return $result;
 }
コード例 #3
0
ファイル: RenderImpl.class.php プロジェクト: komcdo/winnow
 public function showImageJson($digest, $lang)
 {
     $store = $this->plugin->getStorageAndCache();
     $bs = null;
     $bs = $store->retreiveData($digest, $this->plugin->getConfiguration()->getProperty("wirisimageformat", "png"));
     $jsonOutput = new Hash();
     if ($bs !== null) {
         $jsonOutput->set("status", "ok");
         $jsonResult = new Hash();
         $by = haxe_io_Bytes::ofData($bs);
         $b64 = _hx_deref(new com_wiris_system_Base64())->encodeBytes($by);
         $metrics = array();
         $this->getMetricsFromBytes($bs, $metrics);
         if ($lang === null) {
             $lang = "en";
         }
         $s = $store->retreiveData($digest, $lang);
         $hashMetrics = com_wiris_system_PropertiesTools::fromProperties($metrics);
         $keys = $hashMetrics->keys();
         while ($keys->hasNext()) {
             $currentKey = $keys->next();
             $jsonResult->set($currentKey, $hashMetrics->get($currentKey));
             unset($currentKey);
         }
         if ($s !== null) {
             $jsonResult->set("alt", com_wiris_system_Utf8::fromBytes($s));
         }
         $jsonResult->set("pngBase64", $b64->toString());
         $jsonOutput->set("result", $jsonResult);
     } else {
         $jsonOutput->set("status", "warning");
     }
     return com_wiris_util_json_JSon::encode($jsonOutput);
 }