/** * Return the WebService object. * @return WebService */ public static function WS() { if (self::$_instance_virgo == null) { self::$_instance_virgo = new WebServiceVirgo(); } return self::$_instance_virgo; }
/** * Return path to SWF file, if file not exist, download it. * @param OfferPhoto $photo * @return string */ public static function GetSWF(OfferPhoto $photo) { $path = getcwd() . "/photos"; if (!file_exists($path)) { mkdir($path); chmod($path, 0775); } $suf = $photo->GetOfferId() < 100 ? $photo->GetOfferId() : substr($photo->GetOfferId(), 0, 2); $path = getcwd() . "/photos/ofs_" . $suf; if (!file_exists($path)) { mkdir($path); chmod($path, 0775); } $path = getcwd() . "/photos/ofs_{$suf}/offer_" . $photo->GetOfferId(); if ($photo->GetInvestmentId() > 0) { $path = getcwd() . "/photos/investment_" . $photo->GetInvestmentId(); } if (!file_exists($path)) { mkdir($path); chmod($path, 0775); } $fileName = "/" . $photo->GetFilename(); $path .= $fileName; if (!file_exists($path)) { //get image from server WebServiceVirgo::WS()->LoginEx(true); $buf = WebServiceVirgo::WS()->GetSWF($photo->GetId()); if ($buf != null) { $file = fopen($path, "wb"); fwrite($file, $buf); fclose($file); } } $path = Config::$AppPath . "/photos/ofs_{$suf}/offer_" . $photo->GetOfferId() . $fileName; if ($photo->GetInvestmentId() > 0) { $path = Config::$AppPath . "/photos/investment_" . $photo->GetInvestmentId() . $fileName; } return $path; }
/** * Import locations * @param int $type. Type of returned locations. Acceptable values 1,2,3,4. Default false. * @return string */ public function GetLocationsAll($type = false) { try { WebServiceVirgo::WS()->LoginEx(); $ret = WebServiceVirgo::WS()->GetLocationsAll($type); WebServiceVirgo::WS()->Logout(); return $ret; } catch (Exception $ex) { Errors::LogError("VirgoAPI:GetLocationsAll", $ex->getMessage()); return "ERROR"; } }