18 require_once SQ_PACKAGES_PATH.
'/web_services/api/soap_api/soap_api.inc';
43 parent::__construct($assetid);
60 'GetFileInformation' =>
'1',
61 'GetImageInformation' =>
'1',
82 $request_info = (Array) $request;
83 $file_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($request_info[
'AssetID']);
84 $type_ancestors = $file_asset->getTypeAncestors(FALSE);
85 if (in_array(
'file', $type_ancestors) || $file_asset->type() ==
'file') {
87 $file_info = $file_asset->getExistingFile();
88 $file_path = $file_info[
'path'];
89 $file_content = file_get_contents($file_path);
90 $file_content_base64 = base64_encode($file_content);
92 $file_name = $file_info[
'filename'];
93 $file_type = get_file_type($file_name);
94 $file_size = $file_info[
'size'];
95 $file_modified = $file_info[
'modified'];
98 'FileName' => $file_name,
99 'FileType' => $file_type,
100 'FileSize' => $file_size,
101 'LastModified' => date(
'd-m-Y H:i:s', $file_modified),
102 'FileContentBase64' => $file_content_base64,
105 throw new SoapFault(
'Server',
'The Asset ID Provided Is Not Of A File Asset');
108 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($link_info[
'type_code']);
109 $object_name = str_replace(
' ',
'_', ucwords(str_replace(
'_',
' ', $link_info[
'type_code'])));
110 $asset =
new $object_name();
111 $asset->setAttrValue(
'name', $link_info[
'name']);
113 $link_info[
'asset'] = $parent_asset;
114 $linkid = $asset->create($link_info);
117 'CreateMessage' => Array (
118 'message' =>
'Asset was created successfully. Link id #'.$linkid,
120 'AssetObject' => Array (
121 'object_xml' =>
'walao xml',
144 $request_info = (Array) $request;
145 $file_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($request_info[
'AssetID']);
146 $type_ancestors = $file_asset->getTypeAncestors(FALSE);
147 if (in_array(
'file', $type_ancestors) || $file_asset->type() ==
'file') {
148 $file_info = $file_asset->getExistingFile();
150 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
151 $file_name = $file_info[
'filename'];
152 $file_type = get_file_type($file_name);
153 $file_size = $file_info[
'size'];
154 $file_modified = $file_info[
'modified'];
157 'FileName' => $file_name,
158 'FileType' => $file_type,
159 'FileSize' => $file_size,
160 'LastModified' => date(
'd-m-Y H:i:s', $file_modified),
163 throw new SoapFault(
'Server',
'The Asset ID Provided Is Not Of A File Asset');
184 $request_info = (Array) $request;
186 $file_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($request_info[
'AssetID']);
187 if ($file_asset->type() ===
'image') {
188 $fileInfo = $file_asset->getExistingFile();
189 $image_info = getimagesize($fileInfo[
'path']);
190 $mime_info = $image_info[
'mime'];
193 'FileName' => $file_asset->vars[
'name'][
'value'],
194 'FileTitle' => $file_asset->vars[
'title'][
'value'],
195 'FileType' => $file_asset->type(),
196 'FileSize' => $file_asset->vars[
'size'][
'value'],
197 'MimeType' => $mime_info,
198 'ImageWidth' => $file_asset->vars[
'width'][
'value'],
199 'ImageHeight' => $file_asset->vars[
'height'][
'value'],
200 'LastModified' => date(
'd-m-Y H:i:s', $file_modified),
203 throw new SoapFault(
'Server',
'The Asset ID provided is not of a file asset');
225 $request_info = (Array) $request;
226 $file_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($request_info[
'AssetID']);
227 $file_content = array_get_index($request_info,
'FileContentBase64',
'');
228 $file_name = array_get_index($request_info,
'FileName',
'');
229 $type_ancestors = $file_asset->getTypeAncestors(FALSE);
230 if (in_array(
'file', $type_ancestors) || $file_asset->type() ==
'file') {
232 $edit_fns = $file_asset->getEditFns();
233 if (!empty($file_content)) {
235 $tmp_file_name = self::getRandomFilename($file_name);
237 $destination_file = SQ_DATA_PATH.
'/temp/'.$tmp_file_name;
238 while (file_exists($destination_file)) {
240 $tmp_file_name = self::getRandomFilename($file_name);
242 file_put_contents($destination_file, base64_decode($file_content));
246 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
247 $file_type = get_file_type($file_name);
249 'name' => $file_name,
250 'type' => $file_type,
251 'tmp_name' => $destination_file,
252 'non_uploaded_file' => TRUE,
254 'size' => filesize($destination_file),
258 $prefix = $file_asset->type().
'_'.$file_asset->id;
259 require_once SQ_INCLUDE_PATH.
'/backend_outputter.inc';
261 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($file_asset->id,
'attributes');
263 $result = $edit_fns->processFileUpload($file_asset, $o, $prefix, $info);
264 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($file_asset->id,
'attributes');
267 if (file_exists($destination_file)) {
268 unlink($destination_file);
271 'UploadResult' => (
string) $result,
274 throw new SoapFault(
'Server',
'The Asset ID Provided Is Not Of A File Asset');
290 $hash_file_name = hash(
'md5', $file_name.time());
291 $rand_position = rand(0, strlen($hash_file_name)-6);
292 $tmp_file_name = substr($hash_file_name, $rand_position, 6);
294 return $tmp_file_name;
307 $obj_optional = self::getArgType(
'AssetObject', 0, 1);
309 $complex_types = Array (
310 'Download' => Array (
311 'Download' => Array (
312 'AssetID' => self::$string_non_optional,
314 'DownloadResponse' => Array (
315 'FileName' => self::$string_optional,
316 'FileType' => self::$string_optional,
317 'FileSize' => self::$string_optional,
318 'LastModified' => self::$string_optional,
319 'FileContentBase64' => self::$string_optional,
322 'GetFileInformation' => Array (
323 'GetFileInformation' => Array (
324 'AssetID' => self::$string_non_optional,
326 'GetFileInformationResponse' => Array (
327 'FileName' => self::$string_optional,
328 'FileType' => self::$string_optional,
329 'FileSize' => self::$string_optional,
330 'LastModified' => self::$string_optional,
333 'GetImageInformation' => Array (
334 'GetImageInformation' => Array (
335 'AssetID' => self::$string_non_optional,
337 'GetImageInformationResponse' => Array (
338 'FileName' => self::$string_optional,
339 'FileTitle' => self::$string_optional,
340 'FileType' => self::$string_optional,
341 'FileSize' => self::$string_optional,
342 'MimeType' => self::$string_optional,
343 'ImageWidth' => self::$string_optional,
344 'ImageHeight' => self::$string_optional,
345 'LastModified' => self::$string_optional,
350 'AssetID' => self::$string_non_optional,
351 'FileName' => self::$string_non_optional,
352 'FileContentBase64' => self::$string_non_optional,
354 'UploadResponse' => Array (
355 'UploadResult' => self::$string_optional,
362 $complex_types_available = parent::getComplexElements($complex_types);
364 return $complex_types_available;