35 $api_url = $js_api_asset->
getURL();
36 $nonce_token = get_unique_token();
57 function createRequest()
61 request =
new XMLHttpRequest();
62 }
catch (trymicrosoft) {
64 request =
new ActiveXObject(
"Msxml2.XMLHTTP");
65 }
catch (othermicrosoft) {
67 request =
new ActiveXObject(
"Microsoft.XMLHTTP");
75 alert(
'Your browser does not support Ajax');
93 if (typeof(obj) ==
'undefined' || obj == null) {
109 function jsonToObj(json)
113 var jsonObj = eval(
'(' + json +
')');
128 function success(ajaxRequest, dataCallback)
130 if (ajaxRequest.readyState == 4) {
131 if (ajaxRequest.status == 200) {
132 if (ajaxRequest.responseText !==
'' && ajaxRequest.responseText !==
'undefined' && ajaxRequest.responseText !== null) {
133 var response = jsonToObj(ajaxRequest.responseText);
135 dataCallback(response);
152 function setApiKey(api_key)
155 window.api_key = api_key;
169 function makeRequest(url, receive, dataCallback)
172 urlarray = url.split(
"?");
174 var ajaxRequest = createRequest();
176 ajaxRequest.open(
'POST', encodeURI(urlarray[0]),
true);
180 ajaxRequest.onreadystatechange =
function() {
181 success(ajaxRequest, dataCallback);
184 ajaxRequest.setRequestHeader(
"Content-type",
"application/x-www-form-urlencoded");
185 var postString = urlarray[1] +
'&nonce_token=<?php echo $nonce_token; ?>';
186 ajaxRequest.send(encodeURI(postString));
199 function dumpObj(obj, parent) {
203 var msg = parent +
'.' + i +
' => ' + obj[i] +
'<br />';
205 var msg = i +
" => " + obj[i] +
"<br>";
210 if (typeof obj[i] ==
'object') {
212 document.write(
'<div style="padding-left:20px;">');
214 dumpObj(obj[i], parent +
'.' + i);
219 document.write(
'</div>');
227 if ($js_api_asset->
attr(
'get_general')) {
239 function getGeneral(asset_id, get_attributes, dataCallback)
242 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
243 var get_attributes = isset(get_attributes) ? get_attributes : 0;
246 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getGeneral&id=' + asset_id +
'&get_attributes=' + get_attributes;
249 makeRequest(url,
true, dataCallback);
263 function getChildCount(asset_id, level, dataCallback)
266 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
268 var level = isset(level) ? level : 0;
271 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getChildCount&asset_id=' + asset_id +
'&levels=' + level;
274 makeRequest(url,
true, dataCallback);
281 if ($js_api_asset->
attr(
'get_attributes')) {
292 function getAttributes(asset_id, dataCallback)
295 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
298 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getAttributes&id=' + asset_id;
301 makeRequest(url,
true, dataCallback);
308 if ($js_api_asset->
attr(
'set_attribute')) {
321 function setAttribute(asset_id, attr_name, attr_val, dataCallback)
324 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
327 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=setAttribute&id=' + asset_id +
'&attr_name=' + attr_name +
'&attr_val=' + attr_val.replace(/#/g ,
"%23").replace(/&/g ,
"%26").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B");
330 makeRequest(url,
true, dataCallback);
344 function setMultipleAttributes(asset_id, field_info, dataCallback)
347 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
349 var field_names =
'';
351 for (var field_name in field_info) {
353 if (field_name ==
'')
continue;
354 field_names = field_names + field_name +
'\\,';
355 field_vals = field_vals + field_info[field_name].replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B") +
'\\,' ;
359 field_names = field_names.substring(0, field_names.length-2);
360 field_vals = field_vals.substring(0,field_vals.length-2);
363 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=setMultipleAttributes&id=' + asset_id +
'&attr_name=' + field_names +
'&attr_val=' + field_vals;
366 makeRequest(url,
true, dataCallback);
373 if ($js_api_asset->
attr(
'get_metadata')) {
384 function getMetadata(asset_id, dataCallback)
387 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
390 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getMetadata&id=' + asset_id;
393 makeRequest(url,
true, dataCallback);
400 if ($js_api_asset->
attr(
'set_metadata')) {
411 function setMetadata(asset_id, field_id, field_val, dataCallback)
414 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
417 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=setMetadata&id=' + asset_id +
'&field_id=' + field_id +
'&field_val=' + field_val.replace(/#/g ,
"%23").replace(/&/g ,
"%26").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B");
420 makeRequest(url,
true, dataCallback);
434 function setMetadataAllFields(asset_id, field_info, dataCallback)
437 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
441 for (var field_id in field_info) {
443 field_ids = field_ids + field_id +
'\\,';
444 field_vals = field_vals + field_info[field_id].replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B") +
'\\,' ;
448 field_ids = field_ids.substring(0, field_ids.length-2);
449 field_vals = field_vals.substring(0,field_vals.length-2);
452 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=setMetadata&id=' + asset_id +
'&field_id=' + field_ids +
'&field_val=' + field_vals;
455 makeRequest(url,
true, dataCallback);
462 if ($js_api_asset->
attr(
'trash_asset')) {
473 function trashAsset(asset_ids, dataCallback)
475 if (typeof(asset_ids) !=
'string') {
477 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
480 for (var index in asset_ids) {
482 ids = ids + asset_ids[index] +
'\\,';
486 ids = ids.substring(0, ids.length-2);
492 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=trashAsset&assetid=' + ids;
495 makeRequest(url,
true, dataCallback);
502 if ($js_api_asset->
attr(
'get_children')) {
524 function getChildren(asset_id, levels, type_codes, link_types, link_values, get_attributes, dataCallback)
527 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
529 if(isset(type_codes) && type_codes !=
'') {
530 if(typeof(type_codes) ==
'object' ) {
531 for (var idx in type_codes) {
532 type_code = type_code + type_codes[idx] +
'\\,';
534 type_code = type_code.substring(0, type_code.length-2);
536 type_code = type_codes;
541 if(isset(link_types) && link_types !=
'') {
542 if(typeof(link_types) ==
'object' ) {
543 for (var idx in link_types) {
544 link_type = link_type + link_types[idx] +
'\\,';
546 link_type = link_type.substring(0, link_type.length-2)
548 link_type = link_types;
553 if(isset(link_values) && link_values !=
'') {
554 if(typeof(link_values) ==
'object' ) {
555 for (var idx in link_values) {
556 link_value = link_value + link_values[idx] +
'\\,';
558 link_value = link_value.substring(0, link_value.length-2);
560 link_value = link_values;
565 var levels = typeof(levels) !=
'undefined' ? levels : 0;
566 var get_attributes = isset(get_attributes) ? get_attributes : 0;
569 var url =
'<?php echo $api_url; ?>' +
571 '&type=getChildren&id=' + asset_id +
572 '&levels=' + levels +
573 '&type_codes=' + type_code +
574 '&link_type=' + link_type +
575 '&link_value=' + link_value +
576 '&get_attributes=' + get_attributes;
579 makeRequest(url,
true, dataCallback);
586 if ($js_api_asset->
attr(
'get_parents')) {
608 function getParents(asset_id, levels, type_codes, link_types, link_values, get_attributes, dataCallback)
611 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
613 if(isset(type_codes) && type_codes !=
'') {
614 if(typeof(type_codes) ==
'object' ) {
615 for (var idx in type_codes) {
616 type_code = type_code + type_codes[idx] +
'\\,';
618 type_code = type_code.substring(0, type_code.length-2);
620 type_code = type_codes;
625 if(isset(link_types) && link_types !=
'') {
626 if(typeof(link_types) ==
'object' ) {
627 for (var idx in link_types) {
628 link_type = link_type + link_types[idx] +
'\\,';
630 link_type = link_type.substring(0, link_type.length-2);
632 link_type = link_types;
637 if(isset(link_values) && link_values !=
'') {
638 if(typeof(link_values) ==
'object' ) {
639 for (var idx in link_values) {
640 link_value = link_value + link_values[idx] +
'\\,';
642 link_value = link_value.substring(0, link_value.length-2);
644 link_value = link_values;
649 var levels = typeof(levels) !=
'undefined' ? levels : 0;
650 var get_attributes = isset(get_attributes) ? get_attributes : 0;
653 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
654 '&type=getParents&id=' + asset_id +
655 '&levels=' + levels +
656 '&type_codes=' + type_code +
657 '&link_type=' + link_type +
658 '&link_value=' + link_value +
659 '&get_attributes=' + get_attributes;
663 makeRequest(url,
true, dataCallback);
670 if ($js_api_asset->
attr(
'get_permissions')) {
682 function getPermissions(asset_id, level, dataCallback)
685 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
686 var level = (isset(level) && level !=
'') ? level : 1 ;
689 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getPermissions&id=' + asset_id +
'&level=' + level;
692 makeRequest(url,
true, dataCallback);
699 if ($js_api_asset->
attr(
'create_asset')) {
718 function createAsset(parent_id, type_code, asset_name, link_type, link_value, sort_order, is_dependant, is_exclusive, extra_attributes, attributes, dataCallback)
721 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
724 if (!isset(link_type)) link_type =
'';
725 if (!isset(link_value)) link_value =
'';
726 if (!isset(sort_order)) sort_order =
'';
727 if (!isset(is_dependant)) is_dependant =
'';
728 if (!isset(is_exclusive)) is_exclusive =
'';
729 if (!isset(extra_attributes)) extra_attributes =
'';
730 if (!isset(attributes)) attributes =
'';
733 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=createAsset' +
735 '&type_code=' + type_code +
736 '&asset_name=' + asset_name.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B") +
737 '&link_type=' + link_type +
738 '&link_value=' + link_value.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B") +
739 '&sort_order=' + sort_order +
740 '&is_dependant=' + is_dependant +
741 '&is_exclusive=' + is_exclusive +
742 '&extra_attributes=' + extra_attributes +
746 makeRequest(url,
true, dataCallback);
764 function createFileAsset(parentID, type_code, friendly_name, link_type, link_value, dataCallback)
767 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
768 var type_code = (isset(type_code) && type_code !=
'' ) ? type_code :
'file';
769 var friendly_name = isset(friendly_name) ? friendly_name :
'';
770 var link_type = (isset(link_type) && link_type !=
'') ? link_type : SQ_LINK_TYPE_1;
771 var link_value = isset(link_value) ? link_value :
'';
773 var url =
'<?php echo $api_url; ?>' +
775 '&type=createFileAsset&id=' + parentID +
776 '&type_code=' + type_code +
777 '&friendly_name=' + friendly_name +
778 '&link_type=' + link_type +
779 '&link_value=' + link_value;
782 makeRequest(url,
true, dataCallback);
790 if ($js_api_asset->
attr(
'get_asset_types')) {
800 function getAssetTypes(dataCallback)
803 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
806 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getAssetTypes&id=1';
809 makeRequest(url,
true, dataCallback);
816 if ($js_api_asset->
attr(
'get_locks_info')) {
828 function getLocksInfo(asset_id, screen_name, dataCallback)
831 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
834 if (!isset(screen_name) || screen_name ==
'') screen_name =
'all';
837 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getLocksInfo&id=' + asset_id +
'&screen=' + screen_name;
840 makeRequest(url,
true, dataCallback);
847 if ($js_api_asset->
attr(
'acquire_lock')) {
861 function acquireLock(asset_id, screen_name, dependants_only, force_acquire, dataCallback)
863 var dependants_only = isset(dependants_only) && ( dependants_only.toString().toLowerCase() !=
'null' && dependants_only !=
'' ) ? dependants_only : 1;
864 var force_acquire = isset(force_acquire) && ( force_acquire.toString().toLowerCase() !=
'null' && force_acquire !=
'' ) ? force_acquire : 0;
867 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
871 if (typeof(dependants_only) ==
'string') {
872 if (dependants_only.toLowerCase() ==
'false') {
874 }
else if (dependants_only.toLowerCase() ==
'true') {
879 if (typeof(force_acquire) ==
'string') {
880 if (force_acquire.toLowerCase() ==
'false') {
882 }
else if (force_acquire.toLowerCase() ==
'true') {
888 if (!isset(screen_name) || screen_name ==
'') screen_name =
'all';
891 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=acquireLock&id=' + asset_id +
'&screen=' + screen_name +
'&dependants_only=' + dependants_only +
'&force_acquire=' + force_acquire;
894 makeRequest(url,
true, dataCallback);
901 if ($js_api_asset->
attr(
'release_lock')) {
914 function releaseLock(asset_id, screen_name, dataCallback)
917 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
920 if (!isset(screen_name) || screen_name ==
'') screen_name =
'all';
923 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=releaseLock&id=' + asset_id +
'&screen=' + screen_name;
926 makeRequest(url,
true, dataCallback);
933 if ($js_api_asset->
attr(
'create_link')) {
949 function createLink(parent_id, child_id, link_type, link_value, sort_order, is_dependant, is_exclusive, dataCallback)
952 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
955 if (!isset(link_type)) link_type =
'1';
956 if (!isset(link_value)) link_value =
'';
957 if (!isset(sort_order)) sort_order =
'';
958 if (!isset(is_dependant)) is_dependant =
'';
959 if (!isset(is_exclusive)) is_exclusive =
'';
962 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=createLink' +
964 '&parent_id=' + parent_id +
965 '&link_type=' + link_type +
966 '&link_value=' + link_value +
967 '&sort_order=' + sort_order +
968 '&is_dependant=' + is_dependant +
969 '&is_exclusive=' + is_exclusive;
972 makeRequest(url,
true, dataCallback);
979 if ($js_api_asset->
attr(
'remove_link')) {
994 function removeLink(parent_id, child_id, link_type, link_value, dataCallback)
997 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
998 var link_type = (isset(link_type) && link_type !=
'' ) ? link_type.toUpperCase() :
'SQ_LINK_TYPE_1';
999 var link_value = isset(link_value) ? link_value :
'';
1002 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=removeLink&id=' + child_id +
'&parent_id=' + parent_id +
'&link_type=' + link_type +
'&link_value=' + link_value.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B");
1005 makeRequest(url,
true, dataCallback);
1047 function removeMultipleLinks(link_info, dataCallback)
1050 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1054 var link_value =
'';
1056 for (var x = 0; x < link_info.links.length; x++) {
1057 link_typ = isset(link_info.links[x].link_type) ? link_info.links[x].link_type.toUpperCase() :
'SQ_LINK_TYPE_1' ;
1058 link_val = isset(link_info.links[x].link_value) ? link_info.links[x].link_value :
'' ;
1060 parentid = parentid + link_info.links[x].parent +
'\\,';
1061 childid = childid + link_info.links[x].child +
'\\,';
1062 link_type = link_type + link_typ +
'\\,';
1063 link_value = link_value + link_val.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B") +
'\\,';
1067 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=removeMultipleLinks&parent_id=' + parentid.substring(0, parentid.length-2) +
1068 '&child_id=' + childid.substring(0, childid.length-2) +
1069 '&link_type=' + link_type.substring(0, link_type.length-2) +
1070 '&link_value=' + link_value.substring(0, link_value.length-2)
1073 makeRequest(url,
true, dataCallback);
1080 if ($js_api_asset->
attr(
'move_link')) {
1100 function moveLink(old_parent_id, child_id, old_link_type, old_link_value, new_parent_id, new_link_type, new_link_value, new_position, dataCallback)
1103 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1106 var old_link_type = (isset(old_link_type) && old_link_type !=
'' ) ? old_link_type.toUpperCase() :
'SQ_LINK_TYPE_1';
1107 var old_link_value = isset(old_link_value) ? old_link_value.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B") :
'';
1109 var new_link_type = (isset(new_link_type) && new_link_type !=
'' ) ? new_link_type.toUpperCase() :
'SQ_LINK_TYPE_1';
1110 var new_link_value = isset(new_link_value) ? new_link_value.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B") :
'';
1111 new_position = (isset(new_position) && new_position !=
'') ? new_position :
'0';
1114 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=moveLink' +
1116 '&old_parent_id=' + old_parent_id +
1117 '&old_link_type=' + old_link_type +
1118 '&old_link_value='+ old_link_value +
1119 '&new_parent_id=' + new_parent_id +
1120 '&new_link_type=' + new_link_type +
1121 '&new_link_value='+ new_link_value +
1122 '&new_position=' + new_position;
1125 makeRequest(url,
true, dataCallback);
1132 if ($js_api_asset->
attr(
'update_link')) {
1152 function updateLink(parent_id, child_id, existing_link_type, existing_link_value, link_type, link_value, sort_order, locked, dataCallback)
1155 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1158 existing_link_type = (isset(existing_link_type) && existing_link_type !=
'' ) ? existing_link_type.toUpperCase() :
'SQ_LINK_TYPE_1';
1159 existing_link_value= isset(existing_link_value) ? existing_link_value :
'';
1161 link_type = (isset(link_type) && link_type !=
'' ) ? link_type.toUpperCase() :
'SQ_LINK_TYPE_1';
1162 link_value= isset(link_value) ? link_value :
'';
1164 sort_order= isset(sort_order) ? sort_order :
'';
1165 locked = isset(locked) ? locked :
'';
1168 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=updateLink' +
1170 '&parent_id=' + parent_id +
1171 '&existing_link_type=' + existing_link_type +
1172 '&existing_link_value=' + existing_link_value.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B") +
1173 '&link_type=' + link_type +
1174 '&link_value=' + link_value.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B") +
1175 '&sort_order=' + sort_order +
1176 '&locked=' + locked;
1179 makeRequest(url,
true, dataCallback);
1240 function updateMultipleLinks(link_info, dataCallback)
1243 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1246 var existing_link_type =
'';
1247 var existing_link_value=
'';
1249 var link_value =
'';
1250 var sort_order =
'';
1253 for (var x = 0; x < link_info.links.length; x++) {
1254 existing_link_typ = (isset(link_info.links[x].existing_link_type) && link_info.links[x].existing_link_type !=
'' ) ? link_info.links[x].existing_link_type.toUpperCase() :
'SQ_LINK_TYPE_1' ;
1255 existing_link_val = isset(link_info.links[x].existing_link_value) ? link_info.links[x].existing_link_value :
'' ;
1256 link_typ = isset(link_info.links[x].link_type) ? link_info.links[x].link_type.toUpperCase() :
'SQ_LINK_TYPE_1' ;
1257 link_val = isset(link_info.links[x].link_value) ? link_info.links[x].link_value :
'' ;
1258 sort_ord = isset(link_info.links[x].sort_order) ? link_info.links[x].sort_order :
'' ;
1259 lock = isset(link_info.links[x].link_lock) ? link_info.links[x].link_lock :
'' ;
1261 parentid = parentid + link_info.links[x].parent +
'\\,';
1262 childid = childid + link_info.links[x].child +
'\\,';
1263 existing_link_type = existing_link_type + existing_link_typ +
'\\,';
1264 existing_link_value = existing_link_value + existing_link_val.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B") +
'\\,';
1265 link_type = link_type + link_typ +
'\\,';
1266 link_value = link_value + link_val.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B") +
'\\,';
1267 sort_order = sort_order + sort_ord +
'\\,';
1268 locked = locked + lock +
'\\,';
1272 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=updateMultipleLinks' +
1273 '&parent_id=' + parentid.substring(0, parentid.length-2) +
1274 '&child_id=' + childid.substring(0, childid.length-2) +
1275 '&existing_link_type=' + existing_link_type.substring(0, existing_link_type.length-2) +
1276 '&existing_link_value=' + existing_link_value.substring(0, existing_link_value.length-2) +
1277 '&link_type=' + link_type.substring(0, link_type.length-2) +
1278 '&link_value=' + link_value.substring(0, link_value.length-2) +
1279 '&sort_order=' + sort_order.substring(0, sort_order.length-2) +
1280 '&locked=' + locked.substring(0, locked.length-2);
1283 makeRequest(url,
true, dataCallback);
1290 if ($js_api_asset->
attr(
'get_link_id')) {
1306 function getLinkId(parent_id, child_id, link_type, link_value, all_info, dataCallback)
1309 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1310 var all_info = isset(all_info) ? all_info : 0;
1311 var link_type = (isset(link_type) && link_type !=
'' ) ? link_type.toUpperCase() :
'SQ_LINK_TYPE_1';
1312 var link_value = isset(link_value) ? link_value :
'';
1315 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getLinkId&id=' + child_id +
'&parent_id=' + parent_id +
'&all_info=' + all_info +
'&link_type=' + link_type +
'&link_value=' + link_value.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B");
1318 makeRequest(url,
true, dataCallback);
1325 if ($js_api_asset->
attr(
'get_asset_tree')) {
1337 function getAssetTree(asset_id, levels, dataCallback)
1340 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1343 var levels = typeof(levels) !=
'undefined' ? levels : 0;
1346 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getAssetTree&id=' + asset_id +
'&levels=' + levels;
1349 makeRequest(url,
true, dataCallback);
1356 if ($js_api_asset->
attr(
'get_keywords_replacements')) {
1367 function getKeywordsReplacements(asset_id, keywords_array, dataCallback)
1370 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1373 for (var keyword in keywords_array) {
1375 if (keywords_array[keyword] ==
'')
continue;
1376 keywords = keywords + keywords_array[keyword] +
'\\,';
1380 keywords = keywords.substring(0, keywords.length-2);
1383 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getKeywordsReplacements&id=' + asset_id +
'&keywords=' + keywords;
1386 makeRequest(url,
true, dataCallback);
1393 if ($js_api_asset->
attr(
'set_asset_status')) {
1407 function setAssetStatus(asset_id, status, cascade, workflow_stream, dataCallback)
1410 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1411 var workflow_stream = isset(workflow_stream) ? workflow_stream :
'';
1412 var cascade = isset(cascade) && ( cascade.toString().toLowerCase() !=
'null' && cascade !=
'' ) ? cascade : 0;
1416 if (typeof(cascade) ==
'string') {
1417 if (cascade.toLowerCase() ==
'false') {
1419 }
else if (cascade.toLowerCase() ==
'true') {
1425 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=setAssetStatus&id=' + asset_id +
'&status=' + status +
'&cascade=' + cascade +
'&workflow_stream=' + workflow_stream.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B");
1428 makeRequest(url,
true, dataCallback);
1435 if ($js_api_asset->
attr(
'get_web_path')) {
1446 function getWebPath(asset_id, dataCallback)
1449 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1452 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getWebPath&id=' + asset_id;
1455 makeRequest(url,
true, dataCallback);
1462 if ($js_api_asset->
attr(
'set_web_path')) {
1475 function setWebPath(asset_id, paths, auto_remap ,dataCallback)
1478 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1479 var auto_remap = isset(auto_remap) && ( auto_remap.toString().toLowerCase() !=
'null' && auto_remap !=
'' ) ? auto_remap : 1;
1483 if (typeof(auto_remap) ==
'string') {
1484 if (auto_remap.toLowerCase() ==
'false') {
1486 }
else if (auto_remap.toLowerCase() ==
'true') {
1492 for (var path in paths) {
1494 webpath = webpath + paths[path].replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B") +
'\\,';
1498 webpath = webpath.substring(0, webpath.length-2);
1502 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=setWebPath&id=' + asset_id +
'&webpath=' + webpath +
'&auto_remap=' + auto_remap ;
1505 makeRequest(url,
true, dataCallback);
1512 if ($js_api_asset->
attr(
'get_workflow_schema')) {
1526 function getWorkflowSchema(asset_id, granted, running, dataCallback)
1529 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1530 var granted = isset(granted) && ( granted.toString().toLowerCase() !=
'null' && granted !=
'' ) ? granted :
'';
1531 var running = isset(running) && ( running.toString().toLowerCase() !=
'null' && running !=
'' ) ? running : 0;
1535 if (typeof(granted) ==
'string') {
1536 if (granted.toLowerCase() ==
'false') {
1538 }
else if (granted.toLowerCase() ==
'true') {
1542 if (typeof(running) ==
'string') {
1543 if (running.toLowerCase() ==
'false') {
1545 }
else if (running.toLowerCase() ==
'true') {
1551 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getWorkflowSchema&id=' + asset_id +
'&granted=' + granted +
'&running=' + running;
1554 makeRequest(url,
true, dataCallback);
1561 if ($js_api_asset->
attr(
'set_file_content')) {
1575 function setContentOfEditableFileAsset(assetID, content, dataCallback)
1578 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1580 var content = isset(content) ? escape(content) :
'no_value_provided';
1582 var url =
'<?php echo $api_url; ?>' +
1584 '&type=setContentOfEditableFileAsset&id=' + assetID +
1585 '&content=' + content ;
1588 makeRequest(url,
true, dataCallback);
1596 if ($js_api_asset->
attr(
'import_assets')) {
1609 function importAssetsFromXML(assetID, filePath, dataCallback)
1612 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1614 var file = isset(file) ? content :
'no_file_provided';
1615 var url =
'<?php echo $api_url; ?>' +
1617 '&type=importAssetsFromXML&id=' + assetID +
1618 '&filePath=' + filePath;
1621 makeRequest(url,
true, dataCallback);
1628 if ($js_api_asset->
attr(
'get_roles')) {
1652 function getRoles(assetid, roleid, userid, include_assetid, include_globals, expand_groups, inc_dependants, include_parents, type_codes, strict_type_code, dataCallback)
1655 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1656 var assetid = isset(assetid) ? assetid :
'';
1657 var roleid = isset(roleid) ? roleid :
'';
1658 var userid = isset(userid) ? userid :
'';
1660 var include_assetid = isset(include_assetid) && ( include_assetid.toString().toLowerCase() !=
'null' && include_assetid !=
'' ) ? include_assetid : 0;
1661 var include_globals = isset(include_globals) && ( include_globals.toString().toLowerCase() !=
'null' && include_globals !=
'' ) ? include_globals : 0;
1662 var expand_groups = isset(expand_groups) && ( expand_groups.toString().toLowerCase() !=
'null' && expand_groups !=
'' ) ? expand_groups : 0;
1663 var inc_dependants = isset(inc_dependants) && ( inc_dependants.toString().toLowerCase() !=
'null') ? inc_dependants : 1;
1664 var include_parents = isset(include_parents) && ( include_parents.toString().toLowerCase() !=
'null' && include_parents !=
'' ) ? include_parents : 0;
1666 if(isset(type_codes) && type_codes !=
'') {
1667 if(typeof(type_codes) ==
'object' ) {
1668 for (var idx in type_codes) {
1669 type_code = type_code + type_codes[idx] +
'\\,';
1671 type_code = type_code.substring(0, type_code.length-2);
1673 type_code = type_codes;
1676 var strict_type_code = isset(strict_type_code) && ( strict_type_code.toString().toLowerCase() !=
'null' && strict_type_code !=
'' ) ? strict_type_code : 1;
1679 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getRoles&id=' + assetid
1680 +
'&roleid=' + roleid
1681 +
'&userid=' + userid
1682 +
'&include_assetid=' + include_assetid
1683 +
'&include_globals=' + include_globals
1684 +
'&expand_groups=' + expand_groups
1685 +
'&inc_dependants=' + inc_dependants
1686 +
'&include_parents=' + include_parents
1687 +
'&type_codes=' + type_code
1688 +
'&strict_type_code=' + strict_type_code;
1691 makeRequest(url,
true, dataCallback);
1698 if ($js_api_asset->
attr(
'execute_html_tidy')) {
1710 function executeHTMLTidy(content, dataCallback)
1713 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1714 var content = isset(content) ? content :
'';
1717 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=executeHTMLTidy&content=' + content.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B");
1720 makeRequest(url,
true, dataCallback);
1727 if ($js_api_asset->
attr(
'get_lineage')) {
1740 function getLineage(asset_url, significant_link_only, dataCallback)
1743 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1744 var asset_url = isset(asset_url) ? asset_url.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B") :
'';
1745 var significant_link_only = isset(significant_link_only) && (significant_link_only.toString().toLowerCase() !=
'null' && significant_link_only !=
'' ) ? significant_link_only : 1;
1749 if (typeof(significant_link_only) ==
'string') {
1750 if(significant_link_only.toLowerCase() ==
'false') {
1751 significant_link_only = 0;
1752 }
else if (significant_link_only.toLowerCase() ==
'true') {
1753 significant_link_only = 1;
1758 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getLineage&asset_url=' + asset_url +
'&significant_link_only=' + significant_link_only;
1761 makeRequest(url,
true, dataCallback);
1770 if ($js_api_asset->
attr(
'get_lineage_from_url')) {
1782 function getLineageFromUrl(asset_url, dataCallback)
1785 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1786 var asset_url = isset(asset_url) ? asset_url.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B") :
'';
1787 var significant_link_only = isset(significant_link_only) && (significant_link_only.toString().toLowerCase() !=
'null' && significant_link_only !=
'' ) ? significant_link_only : 1;
1791 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getLineageFromUrl&asset_url=' + asset_url;
1794 makeRequest(url,
true, dataCallback);
1803 if ($js_api_asset->
attr(
'get_url_from_lineage')) {
1817 function getUrlFromLineage(lineage, root_url, protocol, dataCallback)
1820 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1821 var root_url = isset(root_url) && ( root_url.toString().toLowerCase() !=
'null' && root_url !=
'' ) ? encodeURI(root_url) :
'';
1822 var protocol = isset(protocol) && ( protocol.toString().toLowerCase() !=
'null' && protocol !=
'' ) ? encodeURI(protocol) :
'';
1824 var lineageArray = [];
1825 for (var i = 0, l = lineage.length; i<l; i+=1) {
1826 if(lineage[i].hasOwnProperty(
"assetid")) {
1827 lineageArray.push(lineage[i][
"assetid"]);
1830 lineageArray.push(lineage[i]);
1835 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=getUrlFromLineage&lineage=' + lineageArray.join(
'\\,') +
'&root_url=' + root_url +
'&protocol=' + protocol;
1838 makeRequest(url,
true, dataCallback);
1847 if ($js_api_asset->
attr(
'batch_requests')) {
1859 function batchRequest(functions, dataCallback)
1862 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1865 for (var index in functions) {
1866 fnName = functions[index].function;
1868 if (!(window[fnName])) {
1869 throw "The function name " + functions[index].function +
" does not exist";
1874 var postData = JSON.stringify(functions);
1876 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
'&type=batchRequest&functions=' + postData.replace(/&/g ,
"%26").replace(/#/g ,
"%23").replace(/\?/g ,
"%3F").replace(/\+/g ,
"%2B");
1879 makeRequest(url,
true, dataCallback);
1886 if ($js_api_asset->
attr(
'clone_asset')) {
1904 function cloneAsset(assetid, new_parent, clone_num, new_position, link_type, link_value, dataCallback)
1907 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1909 var clone_num = (isset(clone_num) && clone_num !=
'') ? clone_num : 1
1910 var new_position = (isset(new_position) && new_position !=
'') ? new_position : -1;
1911 var link_type = (isset(link_type) && link_type !=
'') ? link_type :
'SQ_LINK_TYPE_1';
1912 var link_value = (isset(link_value)) ? link_value :
'';
1914 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key
1915 +
'&type=cloneAsset&id=' + assetid
1916 +
'&new_parent=' + new_parent
1917 +
'&clone_num=' + clone_num
1918 +
'&new_position=' + new_position
1919 +
'&link_value=' + link_value
1920 +
'&link_type=' + link_type;
1923 makeRequest(url,
true, dataCallback);
1930 if ($js_api_asset->
attr(
'show_diff')) {
1945 function showDifference(assetid_1, assetid_2, paint_layout_1, paint_layout_2, dataCallback)
1948 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1949 paint_layout_1 = (isset(paint_layout_1)) ? paint_layout_1 :
'';
1950 paint_layout_2 = (isset(paint_layout_2)) ? paint_layout_2 :
'';
1953 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key
1954 +
'&type=showDifference&id=' + assetid_1
1955 +
'&assetid_2=' + assetid_2
1956 +
'&paint_layout_1=' + paint_layout_1
1957 +
'&paint_layout_2=' + paint_layout_2;
1960 makeRequest(url,
true, dataCallback);
1967 if ($js_api_asset->
attr(
'get_context')) {
1981 function getAlternateContext(all_info, dataCallback)
1984 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
1986 var all_info = isset(all_info) && (all_info.toString().toLowerCase() !=
'null' && all_info.toString() !=
'' ) ? all_info : 0;
1988 if (typeof(all_info) ==
'string') {
1989 if(all_info.toLowerCase() ==
'false') {
1991 }
else if (all_info.toLowerCase() ==
'true') {
1997 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
1998 '&type=getAlternateContext' +
1999 '&all_info=' + all_info;
2002 makeRequest(url,
true, dataCallback);
2017 function getAllContexts(all_info, dataCallback)
2020 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
2022 var all_info = isset(all_info) && (all_info.toString().toLowerCase() !=
'null' && all_info.toString() !=
'' ) ? all_info : 0;
2024 if (typeof(all_info) ==
'string') {
2025 if(all_info.toLowerCase() ==
'false') {
2027 }
else if (all_info.toLowerCase() ==
'true') {
2033 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
2034 '&type=getAllContexts' +
2035 '&all_info=' + all_info;
2038 makeRequest(url,
true, dataCallback);
2053 function getCurrentContext(all_info, dataCallback)
2056 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
2058 var all_info = isset(all_info) && (all_info.toString().toLowerCase() !=
'null' && all_info.toString() !=
'' ) ? all_info : 0;
2060 if (typeof(all_info) ==
'string') {
2061 if(all_info.toLowerCase() ==
'false') {
2063 }
else if (all_info.toLowerCase() ==
'true') {
2069 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
2070 '&type=getCurrentContext' +
2071 '&all_info=' + all_info;
2074 makeRequest(url,
true, dataCallback);
2082 if ($js_api_asset->
attr(
'set_context')) {
2094 function setContext(context_id, dataCallback)
2097 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
2099 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
2100 '&type=setContext' +
2101 '&context_id=' + context_id;
2104 makeRequest(url,
true, dataCallback);
2118 function restoreContext(dataCallback)
2121 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
2123 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key +
2124 '&type=restoreContext';
2127 makeRequest(url,
true, dataCallback);
2134 if ($js_api_asset->
attr(
'get_metadata_schema')) {
2147 function getMetadataSchema(assetid, granted, cascades, dataCallback)
2150 var dataCallback = typeof(dataCallback) !=
'undefined' ? dataCallback :
function() {};
2152 granted = isset(granted) && (granted.toString().toLowerCase() !=
'null' && granted.toString() !=
'') ? granted.toString() :
'1';
2153 cascades = isset(cascades) && (cascades.toString().toLowerCase() !=
'null' && cascades.toString() !=
'') ? cascades.toString() :
'';
2156 if (granted.toLowerCase() ==
'false' || granted.toLowerCase() ==
'0') {
2162 var url =
'<?php echo $api_url; ?>' +
'?key=' + api_key
2163 +
'&type=getMetadataSchema&id=' + assetid
2164 +
'&granted=' + granted;
2165 if (cascades.toLowerCase() ==
'false' || cascades.toLowerCase() ==
'0') {
2166 url = url +
'&cascades=0';
2167 }
else if (cascades.toLowerCase() ==
'true' || cascades.toLowerCase() ==
'1') {
2168 url = url +
'&cascades=1';
2172 makeRequest(url,
true, dataCallback);