Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
js_api_standard_function_list.inc
1 <?php
31 {
32 
33  public static function paintJSFunctions(JS_Api $js_api_asset)
34  {
35  $api_url = $js_api_asset->getURL();
36  $nonce_token = get_unique_token();
37  ?>
38 
57 function createRequest()
58 {
59  var request;
60  try {
61  request = new XMLHttpRequest();
62  } catch (trymicrosoft) {
63  try {
64  request = new ActiveXObject("Msxml2.XMLHTTP");
65  } catch (othermicrosoft) {
66  try {
67  request = new ActiveXObject("Microsoft.XMLHTTP");
68  } catch (failed) {
69  request = false;
70  }//end catch
71  }//end catch
72  }//end catch
73 
74  if (!request) {
75  alert('Your browser does not support Ajax');
76  }
77 
78  return request;
79 
80 }//end createRequest
81 
82 
90 function isset(obj)
91 {
92  // Check to see if a variable or array item is set
93  if (typeof(obj) == 'undefined' || obj == null) {
94  return false;
95  } else {
96  return true;
97  }
98 
99 }//end isset
100 
101 
109 function jsonToObj(json)
110 {
111  // Make the conversion
112  // Don't worry, even the creator of JSON says eval is ok here
113  var jsonObj = eval('(' + json + ')');
114 
115  return jsonObj;
116 
117 }//end jsonToObj
118 
119 
128 function success(ajaxRequest, dataCallback)
129 {
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);
134  // Custom callback
135  dataCallback(response);
136  }//end if
137 
138  }//end if
139 
140  }//end if
141 
142 }//end success
143 
144 
152 function setApiKey(api_key)
153 {
154  // Make this into a global variable
155  window.api_key = api_key;
156 
157 }//end setApiKey
158 
159 
169 function makeRequest(url, receive, dataCallback)
170 {
171  //split url to url and parameters
172  urlarray = url.split("?");
173  // Create an instance of our ajax object
174  var ajaxRequest = createRequest();
175  // Open request
176  ajaxRequest.open('POST', encodeURI(urlarray[0]), true);
177  // Should we use a callback?
178  if (receive) {
179  // Custom callback
180  ajaxRequest.onreadystatechange = function() {
181  success(ajaxRequest, dataCallback);
182  };
183  }//end if
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));
187 
188 }//end makeRequest
189 
190 
199 function dumpObj(obj, parent) {
200  // Go through all the properties of the passed-in object
201  for (var i in obj) {
202  if (parent) {
203  var msg = parent + '.' + i + ' => ' + obj[i] + '<br />';
204  } else {
205  var msg = i + " => " + obj[i] + "<br>";
206  }
207  // Write it out
208  document.write(msg);
209  // Check if we need to go deeper
210  if (typeof obj[i] == 'object') {
211  // Write opening
212  document.write('<div style="padding-left:20px;">');
213  if (parent) {
214  dumpObj(obj[i], parent + '.' + i);
215  } else {
216  dumpObj(obj[i], i);
217  }
218  // Write closing
219  document.write('</div>');
220  }//end if
221 
222  }//end for
223 
224 }//end dumpObj
225 
226  <?php
227  if ($js_api_asset->attr('get_general')) {
228  ?>
229 
239 function getGeneral(asset_id, get_attributes, dataCallback)
240 {
241  // Create blank function
242  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
243  var get_attributes = isset(get_attributes) ? get_attributes : 0;
244 
245  // Build our string
246  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=getGeneral&id=' + asset_id + '&get_attributes=' + get_attributes;
247 
248  // Make our request
249  makeRequest(url, true, dataCallback);
250 
251 }//end getGeneral
252 
253 
263 function getChildCount(asset_id, level, dataCallback)
264 {
265  // Create blank function
266  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
267  // Check to see if we have set any levels
268  var level = isset(level) ? level : 0;
269 
270  // Build our string
271  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=getChildCount&asset_id=' + asset_id + '&levels=' + level;
272 
273  // Make our request
274  makeRequest(url, true, dataCallback);
275 
276 }//end getChildCount()
277 
278  <?php
279  }// end if(get_general)
280 
281  if ($js_api_asset->attr('get_attributes')) {
282  ?>
283 
292 function getAttributes(asset_id, dataCallback)
293 {
294  // Create blank function
295  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
296 
297  // Build our string
298  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=getAttributes&id=' + asset_id;
299 
300  // Make our request
301  makeRequest(url, true, dataCallback);
302 
303 }//end getAttributes
304 
305  <?php
306  }// end if(get_attributes)
307 
308  if ($js_api_asset->attr('set_attribute')) {
309  ?>
310 
321 function setAttribute(asset_id, attr_name, attr_val, dataCallback)
322 {
323  // Create blank function
324  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
325 
326  // Build our string
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");
328 
329  // Make our request
330  makeRequest(url, true, dataCallback);
331 
332 }//end setAttribute
333 
334 
344 function setMultipleAttributes(asset_id, field_info, dataCallback)
345 {
346  // Create blank function
347  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
348 
349  var field_names = '';
350  var field_vals = '';
351  for (var field_name in field_info) {
352  // construct our query strings to be passed
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") + '\\,' ;
356  }
357 
358  // remove the trailing "\,"
359  field_names = field_names.substring(0, field_names.length-2);
360  field_vals = field_vals.substring(0,field_vals.length-2);
361 
362  // Build our string
363  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=setMultipleAttributes&id=' + asset_id + '&attr_name=' + field_names + '&attr_val=' + field_vals;
364 
365  // Make our request
366  makeRequest(url, true, dataCallback);
367 
368 }//end setMultipleAttributes
369 
370  <?php
371  }// end if(set_attribute)
372 
373  if ($js_api_asset->attr('get_metadata')) {
374  ?>
375 
384 function getMetadata(asset_id, dataCallback)
385 {
386  // Create blank function
387  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
388 
389  // Build our string
390  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=getMetadata&id=' + asset_id;
391 
392  // Make our request
393  makeRequest(url, true, dataCallback);
394 
395 }//end getMetadata
396 
397  <?php
398  }// end if(get_metadata)
399 
400  if ($js_api_asset->attr('set_metadata')) {
401  ?>
402 
411 function setMetadata(asset_id, field_id, field_val, dataCallback)
412 {
413  // Create blank function
414  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
415 
416  // Build our string
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");
418 
419  // Make our request
420  makeRequest(url, true, dataCallback);
421 
422 }//end setMetadata
423 
424 
434 function setMetadataAllFields(asset_id, field_info, dataCallback)
435 {
436  // Create blank function
437  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
438 
439  var field_ids = '';
440  var field_vals = '';
441  for (var field_id in field_info) {
442  // construct our query strings to be passed
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") + '\\,' ;
445  }
446 
447  // remove the trailing "\,"
448  field_ids = field_ids.substring(0, field_ids.length-2);
449  field_vals = field_vals.substring(0,field_vals.length-2);
450 
451  // Build our string
452  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=setMetadata&id=' + asset_id + '&field_id=' + field_ids + '&field_val=' + field_vals;
453 
454  // Make our request
455  makeRequest(url, true, dataCallback);
456 
457 }//end setMetadataAllFields()
458 
459  <?php
460  }// end if(set_metadata)
461 
462  if ($js_api_asset->attr('trash_asset')) {
463  ?>
464 
473 function trashAsset(asset_ids, dataCallback)
474 {
475  if (typeof(asset_ids) != 'string') {
476  // Create blank function
477  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
478  var ids = '';
479 
480  for (var index in asset_ids) {
481  // construct our query strings to be passed
482  ids = ids + asset_ids[index] + '\\,';
483  }
484 
485  // remove the trailing "\,"
486  ids = ids.substring(0, ids.length-2);
487  } else {
488  ids = asset_ids;
489  }
490 
491  // Build our string
492  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=trashAsset&assetid=' + ids;
493 
494  // Make our request
495  makeRequest(url, true, dataCallback);
496 
497 }//end trashAsset
498 
499  <?php
500  }// end if (trash_asset)
501 
502  if ($js_api_asset->attr('get_children')) {
503  ?>
504 
524 function getChildren(asset_id, levels, type_codes, link_types, link_values, get_attributes, dataCallback)
525 {
526  // Create blank function
527  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
528  var type_code = '';
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] + '\\,';
533  }
534  type_code = type_code.substring(0, type_code.length-2);
535  } else {
536  type_code = type_codes;
537  }
538  }
539 
540  var link_type = '';
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] + '\\,';
545  }
546  link_type = link_type.substring(0, link_type.length-2)
547  } else {
548  link_type = link_types;
549  }
550  }
551 
552  var link_value = '';
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] + '\\,';
557  }
558  link_value = link_value.substring(0, link_value.length-2);
559  } else {
560  link_value = link_values;
561  }
562  }
563 
564  // Check to see if we have set any levels
565  var levels = typeof(levels) != 'undefined' ? levels : 0;
566  var get_attributes = isset(get_attributes) ? get_attributes : 0;
567 
568  // Build our string
569  var url = '<?php echo $api_url; ?>' +
570  '?key=' + api_key +
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;
577 
578  // Make our request
579  makeRequest(url, true, dataCallback);
580 
581 }//end getChildren
582 
583  <?php
584  }//end if (get_children)
585 
586  if ($js_api_asset->attr('get_parents')) {
587  ?>
588 
608 function getParents(asset_id, levels, type_codes, link_types, link_values, get_attributes, dataCallback)
609 {
610  // Create blank function
611  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
612  var type_code = '';
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] + '\\,';
617  }
618  type_code = type_code.substring(0, type_code.length-2);
619  } else {
620  type_code = type_codes;
621  }
622  }
623 
624  var link_type = '';
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] + '\\,';
629  }
630  link_type = link_type.substring(0, link_type.length-2);
631  } else {
632  link_type = link_types;
633  }
634  }
635 
636  var link_value = '';
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] + '\\,';
641  }
642  link_value = link_value.substring(0, link_value.length-2);
643  } else {
644  link_value = link_values;
645  }
646  }
647 
648  // Check to see if we have set any levels
649  var levels = typeof(levels) != 'undefined' ? levels : 0;
650  var get_attributes = isset(get_attributes) ? get_attributes : 0;
651 
652  // Build our string
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;
660 
661 
662  // Make our request
663  makeRequest(url, true, dataCallback);
664 
665 }//end getParents
666 
667  <?php
668  }// end if(get_parents)
669 
670  if ($js_api_asset->attr('get_permissions')) {
671  ?>
672 
682 function getPermissions(asset_id, level, dataCallback)
683 {
684  // Create blank function
685  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
686  var level = (isset(level) && level != '') ? level : 1 ;
687 
688  // Build our string
689  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=getPermissions&id=' + asset_id + '&level=' + level;
690 
691  // Make our request
692  makeRequest(url, true, dataCallback);
693 
694 }//end getPermissions
695 
696  <?php
697  }//
698 
699  if ($js_api_asset->attr('create_asset')) {
700  ?>
701 
718 function createAsset(parent_id, type_code, asset_name, link_type, link_value, sort_order, is_dependant, is_exclusive, extra_attributes, attributes, dataCallback)
719 {
720  // Create blank function
721  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
722 
723  // Check to see if we have set values
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 = '';
731 
732  // Build our string
733  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=createAsset' +
734  '&id=' + parent_id +
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 +
743  '&' + attributes;
744 
745  // Make our request
746  makeRequest(url, true, dataCallback);
747 
748 }//end createAsset
749 
750 
764 function createFileAsset(parentID, type_code, friendly_name, link_type, link_value, dataCallback)
765 {
766  // Create blank function
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 : '';
772 
773  var url = '<?php echo $api_url; ?>' +
774  '?key=' + api_key +
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;
780 
781  // Make our request
782  makeRequest(url, true, dataCallback);
783 
784 
785 }//end createFileAsset()
786 
787  <?php
788  }//end if(create_asset)
789 
790  if ($js_api_asset->attr('get_asset_types')) {
791  ?>
792 
800 function getAssetTypes(dataCallback)
801 {
802  // Create blank function
803  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
804 
805  // Build our string
806  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=getAssetTypes&id=1';
807 
808  // Make our request
809  makeRequest(url, true, dataCallback);
810 
811 }//end getAssetTypes
812 
813  <?php
814  }// end if(get_asset_types)
815 
816  if ($js_api_asset->attr('get_locks_info')) {
817  ?>
818 
828 function getLocksInfo(asset_id, screen_name, dataCallback)
829 {
830  // Create blank function
831  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
832 
833  // If the user does not set it, we get all locks
834  if (!isset(screen_name) || screen_name == '') screen_name = 'all';
835 
836  // Build our string
837  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=getLocksInfo&id=' + asset_id + '&screen=' + screen_name;
838 
839  // Make our request
840  makeRequest(url, true, dataCallback);
841 
842 }//end getLocksInfo()
843 
844  <?php
845  }//end if(get_locks_info)
846 
847  if ($js_api_asset->attr('acquire_lock')) {
848  ?>
861 function acquireLock(asset_id, screen_name, dependants_only, force_acquire, dataCallback)
862 {
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;
865 
866  // Create blank function
867  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
868 
869  // we cannot pass TRUE or FALSE as string so lets do our conversion
870  // but try conversion only if its a string still
871  if (typeof(dependants_only) == 'string') {
872  if (dependants_only.toLowerCase() == 'false') {
873  dependants_only = 0;
874  } else if (dependants_only.toLowerCase() == 'true') {
875  dependants_only = 1;
876  }
877  }
878 
879  if (typeof(force_acquire) == 'string') {
880  if (force_acquire.toLowerCase() == 'false') {
881  force_acquire = 0;
882  } else if (force_acquire.toLowerCase() == 'true') {
883  force_acquire = 1;
884  }
885  }
886 
887  // If the user does not set it, we get all locks
888  if (!isset(screen_name) || screen_name == '') screen_name = 'all';
889 
890  // Build our string
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;
892 
893  // Make our request
894  makeRequest(url, true, dataCallback);
895 
896 }//end acquireLock
897 
898  <?php
899  }//end if(acquire_locks)
900 
901  if ($js_api_asset->attr('release_lock')) {
902  ?>
903 
904 
914 function releaseLock(asset_id, screen_name, dataCallback)
915 {
916  // Create blank function
917  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
918 
919  // If the user does not set it, we get all locks
920  if (!isset(screen_name) || screen_name == '') screen_name = 'all';
921 
922  // Build our string
923  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=releaseLock&id=' + asset_id + '&screen=' + screen_name;
924 
925  // Make our request
926  makeRequest(url, true, dataCallback);
927 
928 }//end releaseLock
929 
930  <?php
931  }//end if(release_locks)
932 
933  if ($js_api_asset->attr('create_link')) {
934  ?>
935 
949 function createLink(parent_id, child_id, link_type, link_value, sort_order, is_dependant, is_exclusive, dataCallback)
950 {
951  // Create blank function
952  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
953 
954  // Check to see if we have set values
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 = '';
960 
961  // Build our string
962  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=createLink' +
963  '&id=' + child_id +
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;
970 
971  // Make our request
972  makeRequest(url, true, dataCallback);
973 
974 }//end createLink
975 
976  <?php
977  }//end if(create_link)
978 
979  if ($js_api_asset->attr('remove_link')) {
980  ?>
981 
994 function removeLink(parent_id, child_id, link_type, link_value, dataCallback)
995 {
996  // Create blank function
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 : '';
1000 
1001  // Build our string
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");
1003 
1004  // Make our request
1005  makeRequest(url, true, dataCallback);
1006 
1007 }//end removeLink
1008 
1009 
1047 function removeMultipleLinks(link_info, dataCallback)
1048 {
1049  // Create blank function
1050  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
1051  var parentid = '';
1052  var childid = '';
1053  var link_type = '';
1054  var link_value = '';
1055 
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 : '' ;
1059 
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") + '\\,';
1064  }
1065 
1066  // Build our string
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)
1071 
1072  // Make our request
1073  makeRequest(url, true, dataCallback);
1074 
1075 }//end removeMultipleLinks
1076 
1077  <?php
1078  }//end if(remove_links)
1079 
1080  if ($js_api_asset->attr('move_link')) {
1081  ?>
1082 
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)
1101 {
1102  // Create blank function
1103  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
1104 
1105  // Check to see if we have set values
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") : '';
1108 
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';
1112 
1113  // Build our string
1114  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=moveLink' +
1115  '&id=' + child_id +
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;
1123 
1124  // Make our request
1125  makeRequest(url, true, dataCallback);
1126 
1127 }//end moveLink
1128 
1129  <?php
1130  }//end if(move_link)
1131 
1132  if ($js_api_asset->attr('update_link')) {
1133  ?>
1134 
1152 function updateLink(parent_id, child_id, existing_link_type, existing_link_value, link_type, link_value, sort_order, locked, dataCallback)
1153 {
1154  // Create blank function
1155  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
1156 
1157  // Check to see if we have set values
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 : '';
1160 
1161  link_type = (isset(link_type) && link_type != '' ) ? link_type.toUpperCase() : 'SQ_LINK_TYPE_1';
1162  link_value= isset(link_value) ? link_value : '';
1163 
1164  sort_order= isset(sort_order) ? sort_order : '';
1165  locked = isset(locked) ? locked : '';
1166 
1167  // Build our string
1168  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=updateLink' +
1169  '&id=' + child_id +
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;
1177 
1178  // Make our request
1179  makeRequest(url, true, dataCallback);
1180 
1181 }//end updateLink
1182 
1183 
1240 function updateMultipleLinks(link_info, dataCallback)
1241 {
1242  // Create blank function
1243  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
1244  var parentid = '';
1245  var childid = '';
1246  var existing_link_type = '';
1247  var existing_link_value= '';
1248  var link_type = '';
1249  var link_value = '';
1250  var sort_order = '';
1251  var locked = '';
1252 
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 : '' ;
1260 
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 + '\\,';
1269  }
1270 
1271  // Build our string
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);
1281 
1282  // Make our request
1283  makeRequest(url, true, dataCallback);
1284 
1285 }//end updateMultipleLinks()
1286 
1287  <?php
1288  }//end if(update_link)
1289 
1290  if ($js_api_asset->attr('get_link_id')) {
1291  ?>
1292 
1306 function getLinkId(parent_id, child_id, link_type, link_value, all_info, dataCallback)
1307 {
1308  // Create blank function
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 : '';
1313 
1314  // Build our string
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");
1316 
1317  // Make our request
1318  makeRequest(url, true, dataCallback);
1319 
1320 }//end getLinkId
1321 
1322  <?php
1323  }//end if(get_link_id)
1324 
1325  if ($js_api_asset->attr('get_asset_tree')) {
1326  ?>
1327 
1337 function getAssetTree(asset_id, levels, dataCallback)
1338 {
1339  // Create blank function
1340  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
1341 
1342  // Check to see if we have set any levels
1343  var levels = typeof(levels) != 'undefined' ? levels : 0;
1344 
1345  // Build our string
1346  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=getAssetTree&id=' + asset_id + '&levels=' + levels;
1347 
1348  // Make our request
1349  makeRequest(url, true, dataCallback);
1350 
1351 }//end getAssetTree
1352 
1353  <?php
1354  }//end if(get_asset_tree)
1355 
1356  if ($js_api_asset->attr('get_keywords_replacements')) {
1357  ?>
1358 
1367 function getKeywordsReplacements(asset_id, keywords_array, dataCallback)
1368 {
1369  // Create blank function
1370  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
1371 
1372  var keywords = '';
1373  for (var keyword in keywords_array) {
1374  // construct our query strings to be passed
1375  if (keywords_array[keyword] == '') continue;
1376  keywords = keywords + keywords_array[keyword] + '\\,';
1377  }
1378 
1379  // remove the trailing "\,"
1380  keywords = keywords.substring(0, keywords.length-2);
1381 
1382  // Build our string
1383  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=getKeywordsReplacements&id=' + asset_id + '&keywords=' + keywords;
1384 
1385  // Make our request
1386  makeRequest(url, true, dataCallback);
1387 
1388 }//end getKeywordsReplacements()
1389 
1390  <?php
1391  }//end if(get_keywords_replacements)
1392 
1393  if ($js_api_asset->attr('set_asset_status')) {
1394  ?>
1395 
1407 function setAssetStatus(asset_id, status, cascade, workflow_stream, dataCallback)
1408 {
1409  // Create blank function
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;
1413 
1414  // we cannot pass TRUE or FALSE as string so lets do our conversion
1415  // but try conversion only if its a string still
1416  if (typeof(cascade) == 'string') {
1417  if (cascade.toLowerCase() == 'false') {
1418  cascade = 0;
1419  } else if (cascade.toLowerCase() == 'true') {
1420  cascade = 1;
1421  }
1422  }
1423 
1424  // Build our string
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");
1426 
1427  // Make our request
1428  makeRequest(url, true, dataCallback);
1429 
1430 }//end setAssetStatus()
1431 
1432  <?php
1433  }//end if(set_asset_status)
1434 
1435  if ($js_api_asset->attr('get_web_path')) {
1436  ?>
1437 
1446 function getWebPath(asset_id, dataCallback)
1447 {
1448  // Create blank function
1449  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
1450 
1451  // Build our string
1452  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=getWebPath&id=' + asset_id;
1453 
1454  // Make our request
1455  makeRequest(url, true, dataCallback);
1456 
1457 }//end getWebPath()
1458 
1459  <?php
1460  }//end if(get_web_path)
1461 
1462  if ($js_api_asset->attr('set_web_path')) {
1463  ?>
1464 
1475 function setWebPath(asset_id, paths, auto_remap ,dataCallback)
1476 {
1477  // Create blank function
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;
1480 
1481  // we cannot pass TRUE or FALSE as string so lets do our conversion
1482  // but try conversion only if its a string still
1483  if (typeof(auto_remap) == 'string') {
1484  if (auto_remap.toLowerCase() == 'false') {
1485  auto_remap = 0;
1486  } else if (auto_remap.toLowerCase() == 'true') {
1487  auto_remap = 1;
1488  }
1489  }
1490 
1491  var webpath = '';
1492  for (var path in paths) {
1493  // construct our query strings to be passed
1494  webpath = webpath + paths[path].replace(/&/g , "%26").replace(/#/g , "%23").replace(/\?/g , "%3F").replace(/\+/g , "%2B") + '\\,';
1495  }
1496 
1497  // remove the trailing "\,"
1498  webpath = webpath.substring(0, webpath.length-2);
1499 
1500 
1501  // Build our string
1502  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=setWebPath&id=' + asset_id + '&webpath=' + webpath + '&auto_remap=' + auto_remap ;
1503 
1504  // Make our request
1505  makeRequest(url, true, dataCallback);
1506 
1507 }//end setWebPath()
1508 
1509  <?php
1510  }//end if(set_web_path)
1511 
1512  if ($js_api_asset->attr('get_workflow_schema')) {
1513  ?>
1514 
1526 function getWorkflowSchema(asset_id, granted, running, dataCallback)
1527 {
1528  // Create blank function
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;
1532 
1533  // we cannot pass TRUE or FALSE as string so lets do our conversion
1534  // but try conversion only if its a string still
1535  if (typeof(granted) == 'string') {
1536  if (granted.toLowerCase() == 'false') {
1537  granted = 0;
1538  } else if (granted.toLowerCase() == 'true') {
1539  granted = 1;
1540  }
1541  }
1542  if (typeof(running) == 'string') {
1543  if (running.toLowerCase() == 'false') {
1544  running = 0;
1545  } else if (running.toLowerCase() == 'true') {
1546  running = 1;
1547  }
1548  }
1549 
1550  // Build our string
1551  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=getWorkflowSchema&id=' + asset_id + '&granted=' + granted + '&running=' + running;
1552 
1553  // Make our request
1554  makeRequest(url, true, dataCallback);
1555 
1556 }//end getWorkflowSchema()
1557 
1558  <?php
1559  }//end if(get_workflow_schema)
1560 
1561  if ($js_api_asset->attr('set_file_content')) {
1562  ?>
1563 
1575 function setContentOfEditableFileAsset(assetID, content, dataCallback)
1576 {
1577  // Create blank function
1578  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
1579 
1580  var content = isset(content) ? escape(content) : 'no_value_provided';
1581 
1582  var url = '<?php echo $api_url; ?>' +
1583  '?key=' + api_key +
1584  '&type=setContentOfEditableFileAsset&id=' + assetID +
1585  '&content=' + content ;
1586 
1587  // Make our request
1588  makeRequest(url, true, dataCallback);
1589 
1590 
1591 }// end setContentOfEditableFileAsset()
1592 
1593  <?php
1594  }//end if(set_file_content)
1595 
1596  if ($js_api_asset->attr('import_assets')) {
1597  ?>
1598 
1609 function importAssetsFromXML(assetID, filePath, dataCallback)
1610 {
1611  // Create blank function
1612  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
1613 
1614  var file = isset(file) ? content : 'no_file_provided';
1615  var url = '<?php echo $api_url; ?>' +
1616  '?key=' + api_key +
1617  '&type=importAssetsFromXML&id=' + assetID +
1618  '&filePath=' + filePath;
1619 
1620  // Make our request
1621  makeRequest(url, true, dataCallback);
1622 
1623 }// end importAssetsFromXML()
1624 
1625  <?php
1626  }//end if(import_assets)
1627 
1628  if ($js_api_asset->attr('get_roles')) {
1629  ?>
1630 
1652 function getRoles(assetid, roleid, userid, include_assetid, include_globals, expand_groups, inc_dependants, include_parents, type_codes, strict_type_code, dataCallback)
1653 {
1654  // Create blank function
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 : '';
1659 
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;
1665  var type_code = '';
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] + '\\,';
1670  }
1671  type_code = type_code.substring(0, type_code.length-2);
1672  } else {
1673  type_code = type_codes;
1674  }
1675  }
1676  var strict_type_code = isset(strict_type_code) && ( strict_type_code.toString().toLowerCase() != 'null' && strict_type_code != '' ) ? strict_type_code : 1;
1677 
1678  // Build our string
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;
1689 
1690  // Make our request
1691  makeRequest(url, true, dataCallback);
1692 
1693 }//end getRoles
1694 
1695  <?php
1696  }//end if(get_roles)
1697 
1698  if ($js_api_asset->attr('execute_html_tidy')) {
1699  ?>
1700 
1710 function executeHTMLTidy(content, dataCallback)
1711 {
1712  // Create blank function
1713  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
1714  var content = isset(content) ? content : '';
1715 
1716  // Build our string
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");
1718 
1719  // Make our request
1720  makeRequest(url, true, dataCallback);
1721 
1722 }//end executeHTMLTidy()
1723 
1724  <?php
1725  }//end if(execute_html_tidy)
1726 
1727  if ($js_api_asset->attr('get_lineage')) {
1728  ?>
1729 
1740 function getLineage(asset_url, significant_link_only, dataCallback)
1741 {
1742  // Create blank function
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;
1746 
1747  // we cannot pass TRUE or FALSE as string so lets do our conversion
1748  // but try conversion only if its a string still
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;
1754  }
1755  }
1756 
1757  // Build our string
1758  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=getLineage&asset_url=' + asset_url + '&significant_link_only=' + significant_link_only;
1759 
1760  // Make our request
1761  makeRequest(url, true, dataCallback);
1762 
1763 }//end getLineage()
1764 
1765 
1766  <?php
1767  }//end if(get_lineage)
1768 
1769 
1770  if ($js_api_asset->attr('get_lineage_from_url')) {
1771  ?>
1772 
1782 function getLineageFromUrl(asset_url, dataCallback)
1783 {
1784  // Create blank function
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;
1788 
1789 
1790  // Build our string
1791  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=getLineageFromUrl&asset_url=' + asset_url;
1792 
1793  // Make our request
1794  makeRequest(url, true, dataCallback);
1795 
1796 }//end getLineageFromUrl()
1797 
1798 
1799  <?php
1800  }//end if(get_lineage_from_url)
1801 
1802 
1803  if ($js_api_asset->attr('get_url_from_lineage')) {
1804  ?>
1805 
1817 function getUrlFromLineage(lineage, root_url, protocol, dataCallback)
1818 {
1819  // Create blank function
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) : '';
1823 
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"]);
1828  }
1829  else {
1830  lineageArray.push(lineage[i]);
1831  }
1832  }
1833 
1834  // Build our string
1835  var url = '<?php echo $api_url; ?>' + '?key=' + api_key + '&type=getUrlFromLineage&lineage=' + lineageArray.join('\\,') + '&root_url=' + root_url + '&protocol=' + protocol;
1836 
1837  // Make our request
1838  makeRequest(url, true, dataCallback);
1839 
1840 }//end getUrlFromLineage()
1841 
1842 
1843  <?php
1844  }//end if(get_url_from_lineage)
1845 
1846 
1847  if ($js_api_asset->attr('batch_requests')) {
1848  ?>
1849 
1859 function batchRequest(functions, dataCallback)
1860 {
1861  // Create blank function
1862  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
1863 
1864  // Loop through the functions to validate
1865  for (var index in functions) {
1866  fnName = functions[index].function;
1867  // Error check that the function name supplied is a valid function
1868  if (!(window[fnName])) {
1869  throw "The function name " + functions[index].function + " does not exist";
1870  }
1871  }
1872 
1873  // Package up the required function calls into string to POST
1874  var postData = JSON.stringify(functions);
1875 
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");
1877 
1878  // Make our request
1879  makeRequest(url, true, dataCallback);
1880 
1881 }//end batchRequest()
1882 
1883  <?php
1884  }//end if(batch_requests)
1885 
1886  if ($js_api_asset->attr('clone_asset')) {
1887  ?>
1888 
1904 function cloneAsset(assetid, new_parent, clone_num, new_position, link_type, link_value, dataCallback)
1905 {
1906  // Create blank function
1907  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
1908 
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 : '';
1913 
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;
1921 
1922  // Make our request
1923  makeRequest(url, true, dataCallback);
1924 
1925 }//end cloneAsset()
1926 
1927  <?php
1928  }//end if(clone_asset)
1929 
1930  if ($js_api_asset->attr('show_diff')) {
1931  ?>
1932 
1945 function showDifference(assetid_1, assetid_2, paint_layout_1, paint_layout_2, dataCallback)
1946 {
1947  // Create blank function
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 : '';
1951 
1952 
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;
1958 
1959  // Make our request
1960  makeRequest(url, true, dataCallback);
1961 
1962 }//end showDifference()
1963 
1964  <?php
1965  }//end if(show_diff)
1966 
1967  if ($js_api_asset->attr('get_context')) {
1968  ?>
1969 
1981 function getAlternateContext(all_info, dataCallback)
1982 {
1983  // Create blank function
1984  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
1985 
1986  var all_info = isset(all_info) && (all_info.toString().toLowerCase() != 'null' && all_info.toString() != '' ) ? all_info : 0;
1987 
1988  if (typeof(all_info) == 'string') {
1989  if(all_info.toLowerCase() == 'false') {
1990  all_info = 0;
1991  } else if (all_info.toLowerCase() == 'true') {
1992  all_info = 1;
1993  }
1994  }
1995 
1996 
1997  var url = '<?php echo $api_url; ?>' + '?key=' + api_key +
1998  '&type=getAlternateContext' +
1999  '&all_info=' + all_info;
2000 
2001  // Make our request
2002  makeRequest(url, true, dataCallback);
2003 
2004 }//end getAlternateContext()
2005 
2006 
2017 function getAllContexts(all_info, dataCallback)
2018 {
2019  // Create blank function
2020  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
2021 
2022  var all_info = isset(all_info) && (all_info.toString().toLowerCase() != 'null' && all_info.toString() != '' ) ? all_info : 0;
2023 
2024  if (typeof(all_info) == 'string') {
2025  if(all_info.toLowerCase() == 'false') {
2026  all_info = 0;
2027  } else if (all_info.toLowerCase() == 'true') {
2028  all_info = 1;
2029  }
2030  }
2031 
2032 
2033  var url = '<?php echo $api_url; ?>' + '?key=' + api_key +
2034  '&type=getAllContexts' +
2035  '&all_info=' + all_info;
2036 
2037  // Make our request
2038  makeRequest(url, true, dataCallback);
2039 
2040 }//end getAllContexts()
2041 
2042 
2053 function getCurrentContext(all_info, dataCallback)
2054 {
2055  // Create blank function
2056  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
2057 
2058  var all_info = isset(all_info) && (all_info.toString().toLowerCase() != 'null' && all_info.toString() != '' ) ? all_info : 0;
2059 
2060  if (typeof(all_info) == 'string') {
2061  if(all_info.toLowerCase() == 'false') {
2062  all_info = 0;
2063  } else if (all_info.toLowerCase() == 'true') {
2064  all_info = 1;
2065  }
2066  }
2067 
2068 
2069  var url = '<?php echo $api_url; ?>' + '?key=' + api_key +
2070  '&type=getCurrentContext' +
2071  '&all_info=' + all_info;
2072 
2073  // Make our request
2074  makeRequest(url, true, dataCallback);
2075 
2076 }//end getCurrentContext()
2077 
2078  <?php
2079  }//end if(get_context)
2080 
2081 
2082  if ($js_api_asset->attr('set_context')) {
2083  ?>
2084 
2094 function setContext(context_id, dataCallback)
2095 {
2096  // Create blank function
2097  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
2098 
2099  var url = '<?php echo $api_url; ?>' + '?key=' + api_key +
2100  '&type=setContext' +
2101  '&context_id=' + context_id;
2102 
2103  // Make our request
2104  makeRequest(url, true, dataCallback);
2105 
2106 }//end setContext()
2107 
2108 
2118 function restoreContext(dataCallback)
2119 {
2120  // Create blank function
2121  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
2122 
2123  var url = '<?php echo $api_url; ?>' + '?key=' + api_key +
2124  '&type=restoreContext';
2125 
2126  // Make our request
2127  makeRequest(url, true, dataCallback);
2128 
2129 }//end restoreContext()
2130 
2131  <?php
2132  }//end if(set_context)
2133 
2134  if ($js_api_asset->attr('get_metadata_schema')) {
2135  ?>
2136 /*
2137 * Get the info of the Metadata Schema applied to the asset
2138 *
2139 * @param string assetid the asset to get the info of the schemas applied to
2140 * @param boolean granted type of access : TRUE = applied, FALSE = denied
2141 * @param boolean cascades does this schema cascade to newly created assets?
2142 * @param function dataCallback custom callback function
2143 *
2144 * @return array
2145 * @access public
2146 */
2147 function getMetadataSchema(assetid, granted, cascades, dataCallback)
2148 {
2149  // Create blank function
2150  var dataCallback = typeof(dataCallback) != 'undefined' ? dataCallback : function() {};
2151 
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() : '';
2154 
2155  // we cannot pass TRUE or FALSE as string so lets do our conversion
2156  if (granted.toLowerCase() == 'false' || granted.toLowerCase() == '0') {
2157  granted = 0;
2158  } else {
2159  granted = 1;
2160  }
2161 
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';
2169  }
2170 
2171  // Make our request
2172  makeRequest(url, true, dataCallback);
2173 
2174 }//end getMetadataSchema()
2175 
2176  <?php
2177  }//end if(get_metadata_schema)
2178 
2179  }//end paintJSFunctions()
2180 
2181 }// end class
2182 
2183 ?>