Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
js_api_enhanced_function_list.inc
1 <?php
32 {
33 
34  public static function paintJSFunctions(JS_Api $js_api_asset)
35  {
36  $api_url = $js_api_asset->getURL();
37  $nonce_token = get_unique_token();
38 ?>
52 (function(gscope){
53 
54 
58  function jsonToObj(json)
59  {
60  // Make the conversion
61  if (typeof(JSON) !== 'undefined') {
62  return JSON.parse(json);
63  }// end if
64 
65  // Don't worry, even the creator of JSON says eval is ok here
66  return eval('(' + json + ')');
67 
68  }// end jsonToObj
69 
70 
76  function getProperties(obj)
77  {
78  var properties = [];
79  for (var propName in obj){
80  if (obj.hasOwnProperty(propName)){
81  properties.push(propName);
82  }// end if
83  }// end for
84 
85  return properties;
86 
87  }// end getProperties
88 
89 
93  function convertToBoolean(variable)
94  {
95  var ret = false;
96  if (variable !== null && typeof(variable) !== "undefined") {
97  switch (typeof(variable)) {
98  case 'number':
99  ret = (variable === 1) ? true : false;
100  break;
101 
102  case 'boolean':
103  ret = variable;
104  break;
105 
106  case 'string':
107  var testVar = variable.toLowerCase();
108  if (testVar === 'true' || testVar === '1') {
109  ret = true;
110  } else if (testVar === 'false' || testVar === '0') {
111  ret = false;
112  }// end if
113  break;
114  }// end switch
115 
116  }// end if
117 
118  return ret;
119 
120  }// end convertToBoolean
121 
122 
126  gscope.Squiz_Matrix_API = function(options)
127  {
128  var self = this;
129 
130  if (!options.hasOwnProperty('key') || options.key === '') {
131  throw 'An API key is required';
132  }// end if
133 
134  self.key = options.key;
135  };// end construct
136 
137 
141  gscope.Squiz_Matrix_API.prototype = {
142  syncing_enabled : <?php echo $js_api_asset->attr('sync_context'); ?>,
143 
144  _http: function(options)
145  {
146  var self = this;
147 
148  // Create the HTTPRequest object
149  function createRequest()
150  {
151  var request;
152  try {
153  request = new XMLHttpRequest();
154  } catch (trymicrosoft) {
155  try {
156  request = new ActiveXObject("Msxml2.XMLHTTP");
157  } catch (othermicrosoft) {
158  try {
159  request = new ActiveXObject("Microsoft.XMLHTTP");
160  } catch(nosupport) {
161  request = false;
162  }// end try
163  }// end try
164  }// end try
165 
166  if (!request) {
167  throw 'Your browser does not support Ajax';
168  }// end if
169 
170  return request;
171 
172  }// end createRequest
173 
174 
175  // Process parameters into a data array
176  function data(params)
177  {
178  // Automatically append 'key' to every request
179  var dataArr = ['key=' + self.key];
180 
181  for (var i = 0, l = params.length; i<l; i+=1) {
182  dataArr.push(params[i][0] + '=' + params[i][1]);
183  }// end for
184  return dataArr.join("&");
185 
186  }// end data
187 
188  // Set some defaults for the HTTP Request
189  options = self._options(['params'],{
190  url: '<?php echo $api_url; ?>',
191  query: null,
192  method: 'POST',
193  contentType: 'application/x-www-form-urlencoded',
194  params: [],
195  async: true,
196  onSuccess: function(){},
197  onError: function(){
198  throw 'HTTPRequest call failed';
199  }
200  },options);
201 
202  var http = createRequest();
203  http.open(options.method,encodeURI(options.url),options.async);
204  http.onreadystatechange = function() {
205  if (http.readyState === 4) {
206  if (http.status === 200) {
207  if (typeof(http.responseText) !== 'undefined' || http.responseText !== '' || http.responseText !== null) {
208  var response = jsonToObj(http.responseText);
209  options.onSuccess.call(this,response);
210  } else {
211  options.onError.call(this,http);
212  }// end if
213  } else {
214  options.onError.call(this,http);
215  }// end if
216  }// end if
217  };// end onreadstatechange
218 
219  http.setRequestHeader("Content-type", options.contentType);
220 
221 
222  // Send the request
223  http.send(encodeURI(data(options.params)));
224 
225  },// end _ajax
226 
227 
231  _options: function(required,defaults,options)
232  {
233  // Required data
234  for (var i = 0, l = required.length; i<l; i+=1) {
235  if (!options.hasOwnProperty(required[i])) {
236  throw 'Required argument "' + required[i] + '" missing';
237  }// end if
238  }// end for
239 
240  // Merge options and defaults
241  for (var def in defaults) {
242  if (defaults.hasOwnProperty(def)){
243  defaults[def] = (options.hasOwnProperty(def)) ? options[def] : defaults[def];
244  }//end if
245  }// end for
246 
247  if (defaults.hasOwnProperty('dataCallback') && typeof(defaults.dataCallback) !== "function") {
248  throw 'Data callback must be a function';
249  }// end if
250 
251  return defaults;
252 
253  },// end _options
254 
255 
261  _cleanUrlParam: function(value)
262  {
263  if (typeof(value) !== 'undefined' && value !== null && value.constructor === String && value !== '') {
264  return value.replace(/#/g , "%23").replace(/&/g , "%26").replace(/\?/g , "%3F").replace(/\+/g , "%2B");
265  }// end if
266 
267  return value;
268 
269  },// end _cleanUrlParam
270 
271  <?php
272  if ($js_api_asset->attr('batch_requests')) {
273  ?>
274 
285  batchRequest: function(options)
286  {
287  var fnName = 'batchRequest';
288  if (arguments.length === 0) {
289  return {
290  // Set the default values
291  defaults: {
292  functions: null,
293  dataCallback: function(){}
294  },
295 
296  // Set the required arguments
297  required: ['functions']
298  };
299  }// end if
300 
301  // Extract some configuration and use it to build
302  // parameters for the post call
303  var fnConfig = this[fnName].call(this);
304  options = this._options(fnConfig.required,fnConfig.defaults,options);
305 
306  // Package up the required function calls into string to POST
307  var postData = JSON.stringify(options.functions);
308 
309  this._doPost(fnName,[
310  ['functions', this._cleanUrlParam(postData)]
311  ],options);
312 
313  },// end batchRequest
314 
315  <?php
316  }// end if(batch_request)
317 
318  if ($js_api_asset->attr('get_general')) {
319  ?>
320 
332  getGeneral: function(options)
333  {
334  var fnName = 'getGeneral';
335  if (arguments.length === 0) {
336  return {
337  // Set the default values
338  defaults: {
339  asset_id: null,
340  get_attributes: 0,
341  dataCallback: function(){}
342  },
343 
344  // Set the required arguments
345  required: ['asset_id']
346  };
347  }// end if
348 
349  // Extract some configuration and use it to build
350  // parameters for the post call
351  var fnConfig = this[fnName].call(this);
352  options = this._options(fnConfig.required,fnConfig.defaults,options);
353 
354  options.get_attributes = (convertToBoolean(options.get_attributes)) ? 1 : 0;
355 
356  this._doPost(fnName,[
357  ['id',options.asset_id],
358  ['get_attributes',options.get_attributes]
359  ],options);
360 
361  },// end getGeneral
362 
363 
375  getChildCount: function(options)
376  {
377  var fnName = 'getChildCount';
378  if (arguments.length === 0) {
379  return {
380  // Set the default values
381  defaults: {
382  asset_id: null,
383  level: 0,
384  dataCallback: function(){}
385  },
386 
387  // Set the required arguments
388  required: ['asset_id','level']
389  };
390  }// end if
391 
392  // Extract some configuration and use it to build
393  // parameters for the post call
394  var fnConfig = this[fnName].call(this);
395  options = this._options(fnConfig.required,fnConfig.defaults,options);
396 
397  this._doPost(fnName,[
398  ['asset_id', options.asset_id],
399  ['levels',options.level]
400  ],options);
401 
402  },// end getChildCount
403 
404  <?php
405  }// end if(get_general)
406 
407  if ($js_api_asset->attr('get_lineage')) {
408  ?>
409 
421  getLineage: function(options)
422  {
423  var fnName = 'getLineage';
424  if (arguments.length === 0) {
425  return {
426  // Set the default values
427  defaults: {
428  asset_url: '',
429  significant_link_only: 1,
430  dataCallback: function(){}
431  },
432 
433  // Set the required arguments
434  required: ['asset_url']
435  };
436  }// end if
437 
438  // Extract some configuration and use it to build
439  // parameters for the post call
440  var fnConfig = this[fnName].call(this);
441  options = this._options(fnConfig.required,fnConfig.defaults,options);
442 
443  // Encode the url
444  options.asset_url = encodeURI(options.asset_url);
445 
446  options.significant_link_only = (convertToBoolean(options.significant_link_only)) ? 1 : 0;
447 
448  this._doPost(fnName,[
449  ['asset_url', options.asset_url],
450  ['significant_link_only', options.significant_link_only]
451  ],options);
452 
453  },// end getLineage
454 
455  <?php
456  }// end if(get_lineage)
457 
458 
459  if ($js_api_asset->attr('get_lineage_from_url')) {
460  ?>
461 
472  getLineageFromUrl: function(options)
473  {
474  var fnName = 'getLineageFromUrl';
475  if (arguments.length === 0) {
476  return {
477  // Set the default values
478  defaults: {
479  asset_url: '',
480  dataCallback: function(){}
481  },
482 
483  // Set the required arguments
484  required: ['asset_url']
485  };
486  }// end if
487 
488  // Extract some configuration and use it to build
489  // parameters for the post call
490  var fnConfig = this[fnName].call(this);
491  options = this._options(fnConfig.required,fnConfig.defaults,options);
492 
493  // Encode the url
494  options.asset_url = encodeURI(options.asset_url);
495 
496  this._doPost(fnName,[
497  ['asset_url', options.asset_url]
498  ],options);
499 
500  },// end getLineageFromUrl
501 
502  <?php
503  }// end if(get_lineage_from_url)
504 
505 
506  if ($js_api_asset->attr('get_url_from_lineage')) {
507  ?>
508 
519  getUrlFromLineage: function(options)
520  {
521  var fnName = 'getUrlFromLineage';
522  if (arguments.length === 0) {
523  return {
524  // Set the default values
525  defaults: {
526  lineage: [],
527  root_url: '',
528  protocol: '',
529  dataCallback: function(){}
530  },
531 
532  // Set the required arguments
533  required: ['lineage']
534  };
535  }// end if
536 
537  // Extract some configuration and use it to build
538  // parameters for the post call
539  var fnConfig = this[fnName].call(this);
540  options = this._options(fnConfig.required,fnConfig.defaults,options);
541 
542  // Encode the lineage
543  var lineageArray = [];
544  for (var i = 0, l = options.lineage.length; i<l; i+=1) {
545  if (options.lineage[i].hasOwnProperty("assetid")) {
546  lineageArray.push(options.lineage[i]["assetid"]);
547  }
548  else {
549  lineageArray.push(options.lineage[i]);
550  }
551  }
552 
553 
554  this._doPost(fnName,[
555  ['lineage', lineageArray.join('\\,')],
556  ['root_url', options.root_url],
557  ['protocol', options.protocol]
558  ],options);
559 
560  },// end getUrlFromLineage
561 
562  <?php
563  }// end if(get_url_from_lineage)
564 
565 
566 
567  if ($js_api_asset->attr('get_attributes')) {
568  ?>
569 
579  getAttributes: function(options)
580  {
581  var fnName = 'getAttributes';
582  if (arguments.length === 0) {
583  return {
584  // Set the default values
585  defaults: {
586  asset_id: null,
587  dataCallback: function(){}
588  },
589 
590  // Set the required arguments
591  required: ['asset_id']
592  };
593  }// end if
594 
595  // Extract some configuration and use it to build
596  // parameters for the post call
597  var fnConfig = this[fnName].call(this);
598  options = this._options(fnConfig.required,fnConfig.defaults,options);
599 
600  this._doPost(fnName,[
601  ['id',options.asset_id]
602  ],options);
603 
604  },// end getAttribute
605 
606  <?php
607  }// end if(get_attributes)
608 
609  if ($js_api_asset->attr('set_attribute')) {
610  ?>
611 
623  setAttribute: function(options)
624  {
625  var fnName = 'setAttribute';
626  if (arguments.length === 0) {
627  return {
628  // Set the default values
629  defaults: {
630  asset_id: null,
631  attr_name: '',
632  attr_val: '',
633  dataCallback: function(){}
634  },
635 
636  // Set the required arguments
637  required: ['asset_id','attr_name','attr_val']
638  };
639  }// end if
640 
641  // Extract some configuration and use it to build
642  // parameters for the post call
643  var fnConfig = this[fnName].call(this);
644  options = this._options(fnConfig.required,fnConfig.defaults,options);
645 
646  this._doPost(fnName,[
647  ['id',options.asset_id],
648  ['attr_name',options.attr_name],
649  ['attr_val',this._cleanUrlParam(options.attr_val)]
650  ],options);
651 
652  },// end setAttribute
653 
654 
665  setMultipleAttributes: function(options)
666  {
667  var fnName = 'setMultipleAttributes';
668  if (arguments.length === 0) {
669  return {
670  // Set the default values
671  defaults: {
672  asset_id: null,
673  field_info: {},
674  dataCallback: function(){}
675  },
676 
677  // Set the required arguments
678  required: ['asset_id','field_info']
679  };
680  }// end if
681 
682  // Extract some configuration and use it to build
683  // parameters for the post call
684  var fnConfig = this[fnName].call(this);
685  options = this._options(fnConfig.required,fnConfig.defaults,options);
686 
687  var field_names = [];
688  var field_vals = [];
689  for (var field_name in options.field_info) {
690  if (options.field_info.hasOwnProperty(field_name)){
691  field_names.push(field_name);
692  field_vals.push(this._cleanUrlParam(options.field_info[field_name]));
693  }// end if
694  }// end of
695 
696  this._doPost(fnName,[
697  ['attr_name',field_names.join('\\,')],
698  ['attr_val',field_vals.join('\\,')],
699  ['id',options.asset_id]
700  ],options);
701 
702  },// end setMultipleAttributes
703 
704  <?php
705  }// end if(set_attribute)
706 
707  if ($js_api_asset->attr('get_metadata')) {
708  ?>
709 
719  getMetadata: function(options)
720  {
721  var fnName = 'getMetadata';
722  if (arguments.length === 0) {
723  return {
724  // Set the default values
725  defaults: {
726  asset_id: null,
727  dataCallback: function(){}
728  },
729 
730  // Set the required arguments
731  required: ['asset_id']
732  };
733  }// end if
734 
735  // Extract some configuration and use it to build
736  // parameters for the post call
737  var fnConfig = this[fnName].call(this);
738  options = this._options(fnConfig.required,fnConfig.defaults,options);
739 
740  this._doPost(fnName,[
741  ['id',options.asset_id]
742  ],options);
743 
744  },// end getMetadata
745 
746  <?php
747  }// end if(get_metadata)
748 
749  if ($js_api_asset->attr('set_metadata')) {
750  ?>
751 
763  setMetadata: function(options)
764  {
765  var fnName = 'setMetadata';
766  if (arguments.length === 0) {
767  return {
768  // Set the default values
769  defaults: {
770  asset_id: null,
771  field_id: '',
772  field_val: '',
773  dataCallback: function(){}
774  },
775 
776  // Set the required arguments
777  required: ['asset_id','field_id','field_val']
778  };
779  }// end if
780 
781  // Extract some configuration and use it to build
782  // parameters for the post call
783  var fnConfig = this[fnName].call(this);
784  options = this._options(fnConfig.required,fnConfig.defaults,options);
785 
786  this._doPost(fnName,[
787  ['id',options.asset_id],
788  ['field_id',options.field_id],
789  ['field_val',this._cleanUrlParam(options.field_val)]
790  ],options);
791 
792  },// end setMetadata
793 
794 
805  setMetadataAllFields: function(options)
806  {
807  var fnName = 'setMetadataAllFields';
808  if (arguments.length === 0) {
809  return {
810  // Set the default values
811  defaults: {
812  asset_id: null,
813  field_info: null,
814  dataCallback: function(){}
815  },
816 
817  // Set the required arguments
818  required: ['asset_id','field_info']
819  };
820  }// end if
821 
822  // Extract some configuration and use it to build
823  // parameters for the post call
824  var fnConfig = this[fnName].call(this);
825  options = this._options(fnConfig.required,fnConfig.defaults,options);
826 
827  var field_ids = [];
828  var field_vals = [];
829  for (var field_id in options.field_info) {
830  if (options.field_info.hasOwnProperty(field_id)){
831  field_ids.push(field_id);
832  field_vals.push(this._cleanUrlParam(options.field_info[field_id]));
833  }// end if
834  }// end of
835 
836  this._doPost(fnName,[
837  ['field_id',field_ids.join('\\,')],
838  ['field_val',field_vals.join('\\,')],
839  ['id',options.asset_id]
840  ],options);
841 
842  },// end setMetadataAllFields
843 
844  <?php
845  }// end if(set_metadata)
846 
847  if ($js_api_asset->attr('trash_asset')) {
848  ?>
849 
859  trashAsset: function(options)
860  {
861  var fnName = 'trashAsset';
862  if (arguments.length === 0) {
863  return {
864  // Set the default values
865  defaults: {
866  asset_ids: [],
867  dataCallback: function(){}
868  },
869 
870  // Set the required arguments
871  required: ['asset_ids']
872  };
873  }// end if
874 
875  // Extract some configuration and use it to build
876  // parameters for the post call
877  var fnConfig = this[fnName].call(this);
878  options = this._options(fnConfig.required,fnConfig.defaults,options);
879 
880  // If a string has been supplied (only 1 asset), then convert it to
881  // an array
882  if (options.asset_ids.constructor === String) {
883  options.asset_ids = [options.asset_ids];
884  }// end if
885 
886  this._doPost(fnName,[
887  ['assetid', options.asset_ids.join('\\,')]
888  ],options);
889 
890  },// end trashAsset
891 
892  <?php
893  }// end if (trash_asset)
894 
895  if ($js_api_asset->attr('get_children')) {
896  ?>
897 
913  getChildren: function(options)
914  {
915  var fnName = 'getChildren';
916  if (arguments.length === 0) {
917  return {
918  // Set the default values
919  defaults: {
920  asset_id: null,
921  levels: 0,
922  type_codes: [],
923  link_types: [],
924  link_values: [],
925  get_attributes: 0,
926  dataCallback: function(){}
927  },
928 
929  // Set the required arguments
930  required: ['asset_id']
931  };
932  }// end if
933 
934  // Extract some configuration and use it to build
935  // parameters for the post call
936  var fnConfig = this[fnName].call(this);
937  options = this._options(fnConfig.required,fnConfig.defaults,options);
938 
939  if (typeof(options.type_codes) === "string") {
940  options.type_codes = [options.type_codes];
941  }// end if
942 
943  if (typeof(options.link_values) === "string") {
944  options.link_values = [options.link_values];
945  }// end if
946 
947  if (typeof(options.link_types) === "string") {
948  options.link_types = [options.link_types];
949  }// end if
950 
951  options.get_attributes = (convertToBoolean(options.get_attributes)) ? 1 : 0;
952 
953  this._doPost(fnName,[
954  ['id', options.asset_id],
955  ['levels', options.levels],
956  ['type_codes', options.type_codes.join('\\,')],
957  ['link_type', options.link_types.join('\\,')],
958  ['link_value', options.link_values.join('\\,')],
959  ['get_attributes', options.get_attributes]
960  ],options);
961 
962  },// end getChildren
963 
964  <?php
965  }//end if (get_children)
966 
967  if ($js_api_asset->attr('get_parents')) {
968  ?>
969 
985  getParents: function(options)
986  {
987  var fnName = 'getParents';
988  if (arguments.length === 0) {
989  return {
990  // Set the default values
991  defaults: {
992  asset_id: null,
993  levels: 0,
994  type_codes: [],
995  link_types: [],
996  link_values: [],
997  get_attributes: 0,
998  dataCallback: function(){}
999  },
1000 
1001  // Set the required arguments
1002  required: ['asset_id']
1003  };
1004  }// end if
1005 
1006  // Extract some configuration and use it to build
1007  // parameters for the post call
1008  var fnConfig = this[fnName].call(this);
1009  options = this._options(fnConfig.required,fnConfig.defaults,options);
1010 
1011  if (typeof(options.type_codes) === "string") {
1012  options.type_codes = [options.type_codes];
1013  }// end if
1014 
1015  if (typeof(options.link_values) === "string") {
1016  options.link_values = [options.link_values];
1017  }// end if
1018 
1019  if (typeof(options.link_types) === "string") {
1020  options.link_types = [options.link_types];
1021  }// end if
1022 
1023  options.get_attributes = (convertToBoolean(options.get_attributes)) ? 1 : 0;
1024 
1025  this._doPost(fnName,[
1026  ['id', options.asset_id],
1027  ['levels', options.levels],
1028  ['type_codes', options.type_codes.join('\\,')],
1029  ['link_type', options.link_types.join('\\,')],
1030  ['link_value', options.link_values.join('\\,')],
1031  ['get_attributes', options.get_attributes]
1032  ],options);
1033 
1034  },// end getParents
1035 
1036  <?php
1037  }// end if(get_parents)
1038 
1039  if ($js_api_asset->attr('get_permissions')) {
1040  ?>
1041 
1052  getPermissions: function(options)
1053  {
1054  var fnName = 'getPermissions';
1055  if (arguments.length === 0) {
1056  return {
1057  // Set the default values
1058  defaults: {
1059  asset_id: null,
1060  level: 1,
1061  dataCallback: function(){}
1062  },
1063 
1064  // Set the required arguments
1065  required: ['asset_id']
1066  };
1067  }// end if
1068 
1069  // Extract some configuration and use it to build
1070  // parameters for the post call
1071  var fnConfig = this[fnName].call(this);
1072  options = this._options(fnConfig.required,fnConfig.defaults,options);
1073 
1074  this._doPost(fnName,[
1075  ['id', options.asset_id],
1076  ['level', options.level]
1077  ],options);
1078 
1079  },// end getPermissions
1080 
1081  <?php
1082  }//
1083 
1084  if ($js_api_asset->attr('create_asset')) {
1085  ?>
1086 
1105  createAsset: function(options)
1106  {
1107  var fnName = 'createAsset';
1108  if (arguments.length === 0) {
1109  return {
1110  // Set the default values
1111  defaults: {
1112  parent_id: null,
1113  type_code: '',
1114  asset_name: '',
1115  link_type: '',
1116  link_value: '',
1117  sort_order: -1,
1118  is_dependant: 0,
1119  is_exclusive: 0,
1120  extra_attributes: 0,
1121  attributes: '',
1122  dataCallback: function(){}
1123  },
1124 
1125  // Set the required arguments
1126  required: ['parent_id','type_code','asset_name','link_type']
1127  };
1128  }// end if
1129 
1130  // Extract some configuration and use it to build
1131  // parameters for the post call
1132  var fnConfig = this[fnName].call(this);
1133  options = this._options(fnConfig.required,fnConfig.defaults,options);
1134 
1135  options.is_dependant = (convertToBoolean(options.is_dependant)) ? 1 : 0;
1136  options.is_exclusive = (convertToBoolean(options.is_exclusive)) ? 1 : 0;
1137 
1138  this._doPost(fnName,[
1139  ['id', options.parent_id],
1140  ['type_code', options.type_code],
1141  ['asset_name', this._cleanUrlParam(options.asset_name)],
1142  ['link_type', options.link_type],
1143  ['link_value',this._cleanUrlParam(options.link_value)],
1144  ['sort_order', options.sort_order],
1145  ['is_dependant', options.is_dependant],
1146  ['is_exclusive', options.is_exclusive],
1147  ['extra_attributes', options.extra_attributes + '&' + options.attributes]
1148  ],options);
1149 
1150  },// end createAsset
1151 
1152 
1166  createFileAsset: function(options)
1167  {
1168  var fnName = 'createFileAsset';
1169  if (arguments.length === 0) {
1170  return {
1171  // Set the default values
1172  defaults: {
1173  parentID: null,
1174  type_code: 'file',
1175  friendly_name: '',
1176  link_type: 'SQ_LINK_TYPE_1',
1177  link_value: '',
1178  dataCallback: function(){}
1179  },
1180 
1181  // Set the required arguments
1182  required: ['parentID','type_code']
1183  };
1184  }// end if
1185 
1186  // Extract some configuration and use it to build
1187  // parameters for the post call
1188  var fnConfig = this[fnName].call(this);
1189  options = this._options(fnConfig.required,fnConfig.defaults,options);
1190 
1191  this._doPost(fnName,[
1192  ['id', options.parentID],
1193  ['type_code', options.type_code],
1194  ['friendly_name',options.friendly_name],
1195  ['link_type', options.link_type],
1196  ['link_value', this._cleanUrlParam(options.link_value)]
1197  ],options);
1198 
1199  },// end createFileAsset
1200 
1201  <?php
1202  }//end if(create_asset)
1203 
1204  if ($js_api_asset->attr('get_asset_types')) {
1205  ?>
1206 
1215  getAssetTypes: function(options)
1216  {
1217  var fnName = 'getAssetTypes';
1218  if (arguments.length === 0) {
1219  return {
1220  // Set the default values
1221  defaults: {
1222  dataCallback: function(){}
1223  },
1224 
1225  // Set the required arguments
1226  required: []
1227  };
1228  }// end if
1229 
1230  // Extract some configuration and use it to build
1231  // parameters for the post call
1232  var fnConfig = this[fnName].call(this);
1233  options = this._options(fnConfig.required,fnConfig.defaults,options);
1234 
1235  this._doPost(fnName,[
1236  ['id','1']
1237  ],options);
1238 
1239  },// end getAssetTypes
1240 
1241  <?php
1242  }// end if(get_asset_types)
1243 
1244  if ($js_api_asset->attr('get_locks_info')) {
1245  ?>
1246 
1257  getLocksInfo: function(options)
1258  {
1259  var fnName = 'getLocksInfo';
1260  if (arguments.length === 0) {
1261  return {
1262  // Set the default values
1263  defaults: {
1264  asset_id: null,
1265  screen_name: 'all',
1266  dataCallback: function(){}
1267  },
1268 
1269  // Set the required arguments
1270  required: ['asset_id']
1271  };
1272  }// end if
1273 
1274  // Extract some configuration and use it to build
1275  // parameters for the post call
1276  var fnConfig = this[fnName].call(this);
1277  options = this._options(fnConfig.required,fnConfig.defaults,options);
1278 
1279  this._doPost(fnName,[
1280  ['id',options.asset_id],
1281  ['screen',options.screen_name]
1282  ],options);
1283 
1284  },// end getLocksInfo
1285 
1286  <?php
1287  }//end if(get_locks_info)
1288 
1289  if ($js_api_asset->attr('acquire_lock')) {
1290  ?>
1291 
1305  acquireLock: function(options)
1306  {
1307  var fnName = 'acquireLock';
1308  if (arguments.length === 0) {
1309  return {
1310  // Set the default values
1311  defaults: {
1312  asset_id: null,
1313  screen_name: 'all',
1314  dependants_only: 1,
1315  force_acquire: 0,
1316  dataCallback: function(){}
1317  },
1318 
1319  // Set the required arguments
1320  required: ['asset_id']
1321  };
1322  }// end if
1323 
1324  // Extract some configuration and use it to build
1325  // parameters for the post call
1326  var fnConfig = this[fnName].call(this);
1327  options = this._options(fnConfig.required,fnConfig.defaults,options);
1328 
1329  options.dependants_only = (convertToBoolean(options.dependants_only)) ? 1 : 0;
1330  options.force_acquire = (convertToBoolean(options.force_acquire)) ? 1 : 0;
1331 
1332  this._doPost(fnName,[
1333  ['id', options.asset_id],
1334  ['screen', options.screen_name],
1335  ['dependants_only', options.dependants_only],
1336  ['force_acquire', options.force_acquire]
1337  ],options);
1338 
1339  },// end acquireLock
1340 
1341  <?php
1342  }//end if(acquire_locks)
1343 
1344  if ($js_api_asset->attr('release_lock')) {
1345  ?>
1346 
1357  releaseLock: function(options)
1358  {
1359  var fnName = 'releaseLock';
1360  if (arguments.length === 0) {
1361  return {
1362  // Set the default values
1363  defaults: {
1364  asset_id: null,
1365  screen_name: 'all',
1366  dataCallback: function(){}
1367  },
1368 
1369  // Set the required arguments
1370  required: ['asset_id']
1371  };
1372  }// end if
1373 
1374  // Extract some configuration and use it to build
1375  // parameters for the post call
1376  var fnConfig = this[fnName].call(this);
1377  options = this._options(fnConfig.required,fnConfig.defaults,options);
1378 
1379  this._doPost(fnName,[
1380  ['id',options.asset_id],
1381  ['screen',options.screen_name]
1382  ],options);
1383 
1384  },// end releaseLock
1385 
1386  <?php
1387  }//end if(release_locks)
1388 
1389  if ($js_api_asset->attr('create_link')) {
1390  ?>
1391 
1407  createLink: function(options)
1408  {
1409  var fnName = 'createLink';
1410  if (arguments.length === 0) {
1411  return {
1412  // Set the default values
1413  defaults: {
1414  parent_id: null,
1415  child_id: null,
1416  link_type: '',
1417  link_value: '',
1418  sort_order: -1,
1419  is_dependant: 0,
1420  is_exclusive: 0,
1421  dataCallback: function(){}
1422  },
1423 
1424  // Set the required arguments
1425  required: ['parent_id','child_id','link_value','link_type']
1426  };
1427  }// end if
1428 
1429  // Extract some configuration and use it to build
1430  // parameters for the post call
1431  var fnConfig = this[fnName].call(this);
1432  options = this._options(fnConfig.required,fnConfig.defaults,options);
1433 
1434  options.is_dependant = (convertToBoolean(options.is_dependant)) ? 1 : 0;
1435  options.is_exclusive = (convertToBoolean(options.is_exclusive)) ? 1 : 0;
1436 
1437  this._doPost(fnName,[
1438  ['id', options.child_id],
1439  ['parent_id', options.parent_id],
1440  ['link_type', options.link_type],
1441  ['link_value',options.link_value],
1442  ['sort_order', options.sort_order],
1443  ['is_dependant', options.is_dependant],
1444  ['is_exclusive', options.is_exclusive]
1445  ],options);
1446 
1447  },// end createLink
1448 
1449  <?php
1450  }//end if(create_link)
1451 
1452  if ($js_api_asset->attr('remove_link')) {
1453  ?>
1454 
1468  removeLink: function(options)
1469  {
1470  var fnName = 'removeLink';
1471  if (arguments.length === 0) {
1472  return {
1473  // Set the default values
1474  defaults: {
1475  parent_id: null,
1476  child_id: null,
1477  link_type: 'SQ_LINK_TYPE_1',
1478  link_value: '',
1479  dataCallback: function(){}
1480  },
1481 
1482  // Set the required arguments
1483  required: ['parent_id','child_id','link_value','link_type']
1484  };
1485  }// end if
1486 
1487  // Extract some configuration and use it to build
1488  // parameters for the post call
1489  var fnConfig = this[fnName].call(this);
1490  options = this._options(fnConfig.required,fnConfig.defaults,options);
1491 
1492  this._doPost(fnName,[
1493  ['id', options.child_id],
1494  ['parent_id', options.parent_id],
1495  ['link_type', options.link_type],
1496  ['link_value',this._cleanUrlParam(options.link_value)]
1497  ],options);
1498 
1499  },// end removeLink
1500 
1501 
1512  removeMultipleLinks: function(options)
1513  {
1514  var fnName = 'removeMultipleLinks';
1515  if (arguments.length === 0) {
1516  return {
1517  // Set the default values
1518  defaults: {
1519  link_info: {},
1520  dataCallback: function(){}
1521  },
1522 
1523  // Set the required arguments
1524  required: ['link_info']
1525  };
1526  }// end if
1527 
1528  // Extract some configuration and use it to build
1529  // parameters for the post call
1530  var fnConfig = this[fnName].call(this);
1531  options = this._options(fnConfig.required,fnConfig.defaults,options);
1532 
1533  if (options.link_info.hasOwnProperty('links')){
1534  if (options.link_info.links.constructor !== Array) {
1535  throw '"links" property for function ' + fnName + ' must be an Array';
1536  }// end if
1537 
1538  var child_ids = [];
1539  var parent_ids = [];
1540  var link_types = [];
1541  var link_values = [];
1542 
1543  for (var i = 0, l = options.link_info.links.length; i<l; i+=1) {
1544  child_ids.push(options.link_info.links[i].child);
1545  parent_ids.push(options.link_info.links[i].parent);
1546  link_types.push(options.link_info.links[i].link_type);
1547  link_values.push(this._cleanUrlParam(options.link_info.links[i].link_value));
1548  }// end for
1549 
1550  this._doPost(fnName,[
1551  ['child_id', child_ids.join('\\,')],
1552  ['parent_id', parent_ids.join('\\,')],
1553  ['link_type', link_types.join('\\,')],
1554  ['link_value',link_values.join('\\,')]
1555  ],options);
1556  } else {
1557  throw fnName + ' missing "links" property';
1558  }// end if
1559 
1560  },// end removeMultipleLinks
1561 
1562  <?php
1563  }//end if(remove_links)
1564 
1565  if ($js_api_asset->attr('move_link')) {
1566  ?>
1567 
1586  moveLink: function(options)
1587  {
1588  var fnName = 'moveLink';
1589  if (arguments.length === 0) {
1590  return {
1591  // Set the default values
1592  defaults: {
1593  old_parent_id: null,
1594  child_id: null,
1595  old_link_type: 'SQ_LINK_TYPE_1',
1596  old_link_value: '',
1597  new_parent_id: null,
1598  new_link_type: 'SQ_LINK_TYPE_1',
1599  new_link_value: '',
1600  new_position: -1,
1601  dataCallback: function(){}
1602  },
1603 
1604  // Set the required arguments
1605  required: ['old_parent_id','child_id','old_link_type','old_link_value','new_parent_id']
1606  };
1607  }// end if
1608 
1609  // Extract some configuration and use it to build
1610  // parameters for the post call
1611  var fnConfig = this[fnName].call(this);
1612  options = this._options(fnConfig.required,fnConfig.defaults,options);
1613 
1614  this._doPost(fnName,[
1615  ['id', options.child_id],
1616  ['old_parent_id', options.old_parent_id],
1617  ['old_link_type', options.old_link_type],
1618  ['old_link_value', this._cleanUrlParam(options.old_link_value)],
1619  ['new_parent_id',options.new_parent_id],
1620  ['new_link_type', options.new_link_type],
1621  ['new_link_value', this._cleanUrlParam(options.new_link_value)],
1622  ['new_position', options.new_position]
1623  ],options);
1624 
1625  },// end moveLink
1626 
1627  <?php
1628  }//end if(move_link)
1629 
1630  if ($js_api_asset->attr('update_link')) {
1631  ?>
1632 
1651  updateLink: function(options)
1652  {
1653  var fnName = 'updateLink';
1654  if (arguments.length === 0) {
1655  return {
1656  // Set the default values
1657  defaults: {
1658  parent_id: null,
1659  child_id: null,
1660  existing_link_type: 'SQ_LINK_TYPE_1',
1661  existing_link_value:'',
1662  link_type: 'SQ_LINK_TYPE_1',
1663  link_value: '',
1664  sort_order: -1,
1665  locked: '',
1666  dataCallback: function(){}
1667  },
1668 
1669  // Set the required arguments
1670  required: ['parent_id','child_id','existing_link_type','existing_link_value']
1671  };
1672  }// end if
1673 
1674  // Extract some configuration and use it to build
1675  // parameters for the post call
1676  var fnConfig = this[fnName].call(this);
1677  options = this._options(fnConfig.required,fnConfig.defaults,options);
1678 
1679  this._doPost(fnName,[
1680  ['id', options.child_id],
1681  ['parent_id', options.parent_id],
1682  ['existing_link_type', options.existing_link_type],
1683  ['existing_link_value', this._cleanUrlParam(options.existing_link_value)],
1684  ['link_type',options.link_type],
1685  ['link_value', this._cleanUrlParam(options.link_value)],
1686  ['sort_order', options.sort_order],
1687  ['locked', options.locked]
1688  ],options);
1689 
1690  },// end updateLink
1691 
1692 
1703  updateMultipleLinks: function(options)
1704  {
1705  var fnName = 'updateMultipleLinks';
1706  if (arguments.length === 0) {
1707  return {
1708  // Set the default values
1709  defaults: {
1710  link_info: {},
1711  dataCallback: function(){}
1712  },
1713 
1714  // Set the required arguments
1715  required: ['link_info']
1716  };
1717  }// end if
1718 
1719  // Extract some configuration and use it to build
1720  // parameters for the post call
1721  var fnConfig = this[fnName].call(this);
1722  options = this._options(fnConfig.required,fnConfig.defaults,options);
1723 
1724  if (options.link_info.hasOwnProperty('links')){
1725  if (options.link_info.links.constructor !== Array) {
1726  throw '"links" property for function ' + fnName + ' must be an Array';
1727  }// end if
1728 
1729  var child_ids = [];
1730  var parent_ids = [];
1731  var link_types = [];
1732  var link_values = [];
1733  var existing_link_types = [];
1734  var existing_link_values = [];
1735  var sort_orders = [];
1736  var link_locks = [];
1737 
1738  for (var i = 0, l = options.link_info.links.length; i<l; i+=1) {
1739  child_ids.push(options.link_info.links[i].child);
1740  parent_ids.push(options.link_info.links[i].parent);
1741  link_types.push(options.link_info.links[i].link_type);
1742  link_values.push(this._cleanUrlParam(options.link_info.links[i].link_value));
1743  existing_link_types.push(options.link_info.links[i].existing_link_type);
1744  existing_link_values.push(this._cleanUrlParam(options.link_info.links[i].existing_link_value));
1745  sort_orders.push(options.link_info.links[i].sort_order);
1746  link_locks.push(options.link_info.links[i].link_lock);
1747  }// end for
1748 
1749  this._doPost(fnName,[
1750  ['child_id', child_ids.join('\\,')],
1751  ['parent_id', parent_ids.join('\\,')],
1752  ['link_type', link_types.join('\\,')],
1753  ['link_value',link_values.join('\\,')],
1754  ['existing_link_type',existing_link_types.join('\\,')],
1755  ['existing_link_value',existing_link_values.join('\\,')],
1756  ['sort_order',sort_orders.join('\\,')],
1757  ['locked',link_locks.join('\\,')]
1758  ],options);
1759  } else {
1760  throw fnName + ' missing "links" property';
1761  }// end if
1762 
1763  },// end updateMultipleLinks
1764 
1765  <?php
1766  }//end if(update_link)
1767 
1768  if ($js_api_asset->attr('get_link_id')) {
1769  ?>
1770 
1785  getLinkId: function(options)
1786  {
1787  var fnName = 'getLinkId';
1788  if (arguments.length === 0) {
1789  return {
1790  // Set the default values
1791  defaults: {
1792  parent_id: null,
1793  child_id: null,
1794  link_type: 'SQ_LINK_TYPE_1',
1795  link_value: '',
1796  all_info: 0,
1797  dataCallback: function(){}
1798  },
1799 
1800  // Set the required arguments
1801  required: ['parent_id','child_id']
1802  };
1803  }// end if
1804 
1805  // Extract some configuration and use it to build
1806  // parameters for the post call
1807  var fnConfig = this[fnName].call(this);
1808  options = this._options(fnConfig.required,fnConfig.defaults,options);
1809 
1810  options.all_info = (convertToBoolean(options.all_info)) ? 1 : 0;
1811 
1812  this._doPost(fnName,[
1813  ['id', options.child_id],
1814  ['parent_id', options.parent_id],
1815  ['link_type',options.link_type],
1816  ['link_value', this._cleanUrlParam(options.link_value)],
1817  ['all_info',options.all_info]
1818  ],options);
1819 
1820  },// end getLinkId
1821 
1822  <?php
1823  }//end if(get_link_id)
1824 
1825  if ($js_api_asset->attr('get_asset_tree')) {
1826  ?>
1827 
1838  getAssetTree: function(options)
1839  {
1840  var fnName = 'getAssetTree';
1841  if (arguments.length === 0) {
1842  return {
1843  // Set the default values
1844  defaults: {
1845  asset_id: null,
1846  levels: 0,
1847  dataCallback: function(){}
1848  },
1849 
1850  // Set the required arguments
1851  required: ['asset_id']
1852  };
1853  }// end if
1854 
1855  // Extract some configuration and use it to build
1856  // parameters for the post call
1857  var fnConfig = this[fnName].call(this);
1858  options = this._options(fnConfig.required,fnConfig.defaults,options);
1859 
1860  this._doPost(fnName,[
1861  ['id', options.asset_id],
1862  ['levels', options.levels]
1863  ],options);
1864 
1865  },// end getAssetTree
1866 
1867  <?php
1868  }//end if(get_asset_tree)
1869 
1870  if ($js_api_asset->attr('get_keywords_replacements')) {
1871  ?>
1872 
1883  getKeywordsReplacements: function(options)
1884  {
1885  var fnName = 'getKeywordsReplacements';
1886  if (arguments.length === 0) {
1887  return {
1888  // Set the default values
1889  defaults: {
1890  asset_id: null,
1891  keywords_array: [],
1892  dataCallback: function(){}
1893  },
1894 
1895  // Set the required arguments
1896  required: ['asset_id','keywords_array']
1897  };
1898  }// end if
1899 
1900  // Extract some configuration and use it to build
1901  // parameters for the post call
1902  var fnConfig = this[fnName].call(this);
1903  options = this._options(fnConfig.required,fnConfig.defaults,options);
1904 
1905  for (var i = 0, l = options.keywords_array.length; i<l; i+=1) {
1906  if (options.keywords_array[i] === '' || /^%(.*)%$/.test(options.keywords_array[i]) === false) {
1907  throw 'Incorrect keyword format passed to ' + fnName + ' ("' + options.keywords_array[i] + '")';
1908  }
1909  }// end for
1910 
1911  this._doPost(fnName,[
1912  ['id', options.asset_id],
1913  ['keywords', options.keywords_array.join('\\,')]
1914  ],options);
1915 
1916  },// end getKeywordsReplacements
1917 
1918  <?php
1919  }//end if(get_keywords_replacements)
1920 
1921  if ($js_api_asset->attr('set_asset_status')) {
1922  ?>
1923 
1936  setAssetStatus: function(options)
1937  {
1938  var fnName = 'setAssetStatus';
1939  if (arguments.length === 0) {
1940  return {
1941  // Set the default values
1942  defaults: {
1943  asset_id: null,
1944  status: '',
1945  cascade: 0,
1946  workflow_stream: '',
1947  dataCallback: function(){}
1948  },
1949 
1950  // Set the required arguments
1951  required: ['asset_id','status']
1952  };
1953  }// end if
1954 
1955  // Extract some configuration and use it to build
1956  // parameters for the post call
1957  var fnConfig = this[fnName].call(this);
1958  options = this._options(fnConfig.required,fnConfig.defaults,options);
1959 
1960  options.cascade = (convertToBoolean(options.cascade)) ? 1 : 0;
1961 
1962  this._doPost(fnName,[
1963  ['id', options.asset_id],
1964  ['workflow_stream', this._cleanUrlParam(options.workflow_stream)],
1965  ['status',options.status],
1966  ['cascade',options.cascade]
1967  ],options);
1968 
1969  },// end setAssetStatus
1970 
1971  <?php
1972  }//end if(set_asset_status)
1973 
1974  if ($js_api_asset->attr('get_web_path')) {
1975  ?>
1976 
1986  getWebPath: function(options)
1987  {
1988  var fnName = 'getWebPath';
1989  if (arguments.length === 0) {
1990  return {
1991  // Set the default values
1992  defaults: {
1993  asset_id: null,
1994  dataCallback: function(){}
1995  },
1996 
1997  // Set the required arguments
1998  required: ['asset_id']
1999  };
2000  }// end if
2001 
2002  // Extract some configuration and use it to build
2003  // parameters for the post call
2004  var fnConfig = this[fnName].call(this);
2005  options = this._options(fnConfig.required,fnConfig.defaults,options);
2006 
2007  this._doPost(fnName,[
2008  ['id', options.asset_id]
2009  ],options);
2010 
2011  },// end getWebPath
2012 
2013  <?php
2014  }//end if(get_web_path)
2015 
2016  if ($js_api_asset->attr('set_web_path')) {
2017  ?>
2018 
2030  setWebPath: function(options)
2031  {
2032  var fnName = 'setWebPath';
2033  if (arguments.length === 0) {
2034  return {
2035  // Set the default values
2036  defaults: {
2037  asset_id: null,
2038  paths: [],
2039  auto_remap: 1,
2040  dataCallback: function(){}
2041  },
2042 
2043  // Set the required arguments
2044  required: ['asset_id']
2045  };
2046  }// end if
2047 
2048  // Extract some configuration and use it to build
2049  // parameters for the post call
2050  var fnConfig = this[fnName].call(this);
2051  options = this._options(fnConfig.required,fnConfig.defaults,options);
2052 
2053  options.auto_remap = (convertToBoolean(options.auto_remap)) ? 1 : 0;
2054 
2055  for (var path in options.paths) {
2056  if (options.paths[path] !== '') {
2057  options.paths[path] = this._cleanUrlParam(options.paths[path]);
2058  }// end if
2059  }// end for
2060 
2061  this._doPost(fnName,[
2062  ['id', options.asset_id],
2063  ['webpath', options.paths.join('\\,')],
2064  ['auto_remap',options.auto_remap]
2065  ],options);
2066 
2067  },// end setWebPath
2068 
2069  <?php
2070  }//end if(set_web_path)
2071 
2072  if ($js_api_asset->attr('get_workflow_schema')) {
2073  ?>
2074 
2087  getWorkflowSchema: function(options)
2088  {
2089  var fnName = 'getWorkflowSchema';
2090  if (arguments.length === 0) {
2091  return {
2092  // Set the default values
2093  defaults: {
2094  asset_id: null,
2095  granted: '',
2096  running: 0,
2097  dataCallback: function(){}
2098  },
2099 
2100  // Set the required arguments
2101  required: ['asset_id']
2102  };
2103  }// end if
2104 
2105  // Extract some configuration and use it to build
2106  // parameters for the post call
2107  var fnConfig = this[fnName].call(this);
2108  options = this._options(fnConfig.required,fnConfig.defaults,options);
2109 
2110  options.running = (convertToBoolean(options.running)) ? 1 : 0;
2111 
2112  this._doPost(fnName,[
2113  ['id', options.asset_id],
2114  ['granted', options.granted],
2115  ['running',options.running]
2116  ],options);
2117 
2118  },// end getWorkflowSchema
2119 
2120  <?php
2121  }//end if(get_workflow_schema)
2122 
2123  if ($js_api_asset->attr('set_file_content')) {
2124  ?>
2125 
2138  setContentOfEditableFileAsset: function(options)
2139  {
2140  var fnName = 'setContentOfEditableFileAsset';
2141  if (arguments.length === 0) {
2142  return {
2143  // Set the default values
2144  defaults: {
2145  asset_id: null,
2146  content: 'no_value_provided',
2147  dataCallback: function(){}
2148  },
2149 
2150  // Set the required arguments
2151  required: ['asset_id','content']
2152  };
2153  }// end if
2154 
2155  // Extract some configuration and use it to build
2156  // parameters for the post call
2157  var fnConfig = this[fnName].call(this);
2158  options = this._options(fnConfig.required,fnConfig.defaults,options);
2159 
2160  options.content = escape(options.content);
2161 
2162  this._doPost(fnName,[
2163  ['id', options.asset_id],
2164  ['content', options.content]
2165  ],options);
2166 
2167  },// end setContentOfEditableFileAsset
2168 
2169  <?php
2170  }//end if(set_file_content)
2171 
2172  if ($js_api_asset->attr('import_assets')) {
2173  ?>
2174 
2186  importAssetsFromXML: function(options)
2187  {
2188  var fnName = 'importAssetsFromXML';
2189  if (arguments.length === 0) {
2190  return {
2191  // Set the default values
2192  defaults: {
2193  asset_id: null,
2194  filePath: '',
2195  dataCallback: function(){}
2196  },
2197 
2198  // Set the required arguments
2199  required: ['asset_id','filePath']
2200  };
2201  }// end if
2202 
2203  // Extract some configuration and use it to build
2204  // parameters for the post call
2205  var fnConfig = this[fnName].call(this);
2206  options = this._options(fnConfig.required,fnConfig.defaults,options);
2207 
2208  this._doPost(fnName,[
2209  ['id', options.asset_id],
2210  ['filePath', options.filePath]
2211  ],options);
2212 
2213  },// end importAssetsFromXML
2214 
2215  <?php
2216  }//end if(import_assets)
2217 
2218  if ($js_api_asset->attr('get_roles')) {
2219  ?>
2220 
2242  getRoles: function(options)
2243  {
2244  var fnName = 'getRoles';
2245  if (arguments.length === 0) {
2246  return {
2247  // Set the default values
2248  defaults: {
2249  asset_id: '',
2250  role_id: '',
2251  user_id: '',
2252  include_assetid: 0,
2253  include_globals: 0,
2254  expand_groups: 0,
2255  inc_dependants: 0,
2256  include_parents: 0,
2257  type_codes: [],
2258  strict_type_code: 1,
2259  dataCallback: function(){}
2260  },
2261 
2262  // Set the required arguments
2263  required: []
2264  };
2265  }// end if
2266 
2267  // Extract some configuration and use it to build
2268  // parameters for the post call
2269  var fnConfig = this[fnName].call(this);
2270  options = this._options(fnConfig.required,fnConfig.defaults,options);
2271 
2272  options.include_assetid = (convertToBoolean(options.include_assetid)) ? 1 : 0;
2273  options.include_globals = (convertToBoolean(options.include_globals)) ? 1 : 0;
2274  options.expand_groups = (convertToBoolean(options.expand_groups)) ? 1 : 0;
2275  options.inc_dependants = (convertToBoolean(options.inc_dependants)) ? 1 : 0;
2276  options.include_parents = (convertToBoolean(options.include_parents)) ? 1 : 0;
2277  options.strict_type_code = (convertToBoolean(options.strict_type_code)) ? 1 : 0;
2278 
2279  this._doPost(fnName,[
2280  ['id', options.asset_id],
2281  ['roleid', options.role_id],
2282  ['userid', options.user_id],
2283  ['include_assetid', options.include_assetid],
2284  ['include_globals', options.include_globals],
2285  ['expand_groups', options.expand_groups],
2286  ['inc_dependants', options.inc_dependants],
2287  ['include_parents', options.include_parents],
2288  ['type_codes', options.type_codes],
2289  ['strict_type_code', options.strict_type_code],
2290  ],options);
2291 
2292  },// end getRoles
2293 
2294  <?php
2295  }//end if(get_roles)
2296 
2297  if ($js_api_asset->attr('execute_html_tidy')) {
2298  ?>
2299 
2309  executeHTMLTidy: function(options)
2310  {
2311  var fnName = 'executeHTMLTidy';
2312  if (arguments.length === 0) {
2313  return {
2314  // Set the default values
2315  defaults: {
2316  content: '',
2317  dataCallback: function(){}
2318  },
2319 
2320  // Set the required arguments
2321  required: ['content']
2322  };
2323  }// end if
2324 
2325  // Extract some configuration and use it to build
2326  // parameters for the post call
2327  var fnConfig = this[fnName].call(this);
2328  options = this._options(fnConfig.required,fnConfig.defaults,options);
2329 
2330  this._doPost(fnName,[
2331  ['content', options.content]
2332  ],options);
2333 
2334  },// end executeHTMLTidy
2335 
2336  <?php
2337  }//end if(execute_html_tidy)
2338 
2339 
2340  if ($js_api_asset->attr('clone_asset')) {
2341  ?>
2342 
2358  cloneAsset: function(options)
2359  {
2360  var fnName = 'cloneAsset';
2361  if (arguments.length === 0) {
2362  return {
2363  // Set the default values
2364  defaults: {
2365  asset_id: null,
2366  new_parent: null,
2367  clone_num: 1,
2368  new_position: -1,
2369  link_type: 'SQ_LINK_TYPE_1',
2370  link_value: '',
2371  dataCallback: function(){}
2372  },
2373 
2374  // Set the required arguments
2375  required: ['asset_id', 'new_parent']
2376  };
2377  }// end if
2378 
2379  // Extract some configuration and use it to build
2380  // parameters for the post call
2381  var fnConfig = this[fnName].call(this);
2382  options = this._options(fnConfig.required,fnConfig.defaults,options);
2383 
2384  this._doPost(fnName,[
2385  ['id', options.asset_id],
2386  ['new_parent', options.new_parent],
2387  ['clone_num', options.clone_num],
2388  ['new_position', options.new_position],
2389  ['link_type', options.link_type],
2390  ['link_value', options.link_value]
2391  ],options);
2392 
2393  },// end cloneAsset
2394 
2395  <?php
2396  }//end if(clone_asset)
2397 
2398 
2399  if ($js_api_asset->attr('show_diff')) {
2400  ?>
2401 
2415  showDifference: function(options)
2416  {
2417  var fnName = 'showDifference';
2418  if (arguments.length === 0) {
2419  return {
2420  // Set the default values
2421  defaults: {
2422  assetid_1: null,
2423  assetid_2: null,
2424  paint_layout_1: '',
2425  paint_layout_2: '',
2426  dataCallback: function(){}
2427  },
2428 
2429  // Set the required arguments
2430  required: ['assetid_1', 'assetid_2']
2431  };
2432  }// end if
2433 
2434  // Extract some configuration and use it to build
2435  // parameters for the post call
2436  var fnConfig = this[fnName].call(this);
2437  options = this._options(fnConfig.required,fnConfig.defaults,options);
2438 
2439  this._doPost(fnName,[
2440  ['id', options.assetid_1],
2441  ['assetid_2', options.assetid_2],
2442  ['paint_layout_1', options.paint_layout_1],
2443  ['paint_layout_2', options.paint_layout_2]
2444  ],options);
2445 
2446  },// end showDifference
2447 
2448  <?php
2449  }//end if(show_diff)
2450 
2451 
2452  if ($js_api_asset->attr('get_context')) {
2453  ?>
2454 
2466  getAlternateContext: function(options)
2467  {
2468  var fnName = 'getAlternateContext';
2469  if (arguments.length === 0) {
2470  return {
2471  // Set the default values
2472  defaults: {
2473  all_info: 0,
2474  dataCallback: function(){}
2475  },
2476 
2477  // Set the required arguments
2478  required: ['all_info']
2479  };
2480  }// end if
2481 
2482  // Extract some configuration and use it to build
2483  // parameters for the post call
2484  var fnConfig = this[fnName].call(this);
2485  options = this._options(fnConfig.required,fnConfig.defaults,options);
2486 
2487  options.all_info = (convertToBoolean(options.all_info)) ? 1 : 0;
2488 
2489  this._doPost(fnName,[
2490  ['all_info', options.all_info]
2491  ],options);
2492 
2493  },// end getAlternateContext
2494 
2495 
2506  getCurrentContext: function(options)
2507  {
2508  var fnName = 'getCurrentContext';
2509  if (arguments.length === 0) {
2510  return {
2511  // Set the default values
2512  defaults: {
2513  all_info: 0,
2514  dataCallback: function(){}
2515  },
2516 
2517  // Set the required arguments
2518  required: ['all_info']
2519  };
2520  }// end if
2521 
2522  // Extract some configuration and use it to build
2523  // parameters for the post call
2524  var fnConfig = this[fnName].call(this);
2525  options = this._options(fnConfig.required,fnConfig.defaults,options);
2526 
2527  options.all_info = (convertToBoolean(options.all_info)) ? 1 : 0;
2528 
2529  this._doPost(fnName,[
2530  ['all_info', options.all_info]
2531  ],options);
2532 
2533  },// end getCurrentContext
2534 
2535 
2546  getAllContexts: function(options)
2547  {
2548  var fnName = 'getAllContexts';
2549  if (arguments.length === 0) {
2550  return {
2551  // Set the default values
2552  defaults: {
2553  all_info: 0,
2554  dataCallback: function(){}
2555  },
2556 
2557  // Set the required arguments
2558  required: ['all_info']
2559  };
2560  }// end if
2561 
2562  // Extract some configuration and use it to build
2563  // parameters for the post call
2564  var fnConfig = this[fnName].call(this);
2565  options = this._options(fnConfig.required,fnConfig.defaults,options);
2566 
2567  options.all_info = (convertToBoolean(options.all_info)) ? 1 : 0;
2568 
2569  this._doPost(fnName,[
2570  ['all_info', options.all_info]
2571  ],options);
2572 
2573  },// end getAllContexts
2574 
2575  <?php
2576  }//end if(get_context)
2577 
2578  if ($js_api_asset->attr('set_context')) {
2579  ?>
2580 
2590  setContext : function(options)
2591  {
2592  var fnName = 'setContext';
2593  if (arguments.length === 0) {
2594  return {
2595  // Set the default values
2596  defaults: {
2597  context_id: null,
2598  dataCallback: function(){}
2599  },
2600 
2601  // Set the required arguments
2602  required: ['context_id']
2603  };
2604  }// end if
2605 
2606  // Extract some configuration and use it to build
2607  // parameters for the post call
2608  var fnConfig = this[fnName].call(this);
2609  options = this._options(fnConfig.required,fnConfig.defaults,options);
2610 
2611  this._doPost(fnName,[
2612  ['context_id', options.context_id]
2613  ],options);
2614 
2615  },//end setContext
2616 
2617 
2627  restoreContext : function(options)
2628  {
2629  var fnName = 'restoreContext';
2630  if (arguments.length === 0) {
2631  return {
2632  // Set the default values
2633  defaults: {
2634  dataCallback: function(){}
2635  },
2636 
2637  // Set the required arguments
2638  required: []
2639  };
2640  }// end if
2641 
2642  // Extract some configuration and use it to build
2643  // parameters for the post call
2644  var fnConfig = this[fnName].call(this);
2645  options = this._options(fnConfig.required,fnConfig.defaults,options);
2646 
2647  this._doPost(fnName,[],options);
2648 
2649  },//end restoreContext
2650 
2651  <?php
2652  }//end if(set_context)
2653 
2654  if ($js_api_asset->attr('get_metadata_schema')) {
2655  ?>
2656 
2669  getMetadataSchema: function(options)
2670  {
2671  var fnName = 'getMetadataSchema';
2672  if (arguments.length === 0) {
2673  return {
2674  // Set the default values
2675  defaults: {
2676  assetid: null,
2677  granted: 1,
2678  cascades: null,
2679  dataCallback: function(){}
2680  },
2681 
2682  // Set the required arguments
2683  required: ['assetid']
2684  };
2685  }// end if
2686 
2687  // Extract some configuration and use it to build
2688  // parameters for the post call
2689  var fnConfig = this[fnName].call(this);
2690  options = this._options(fnConfig.required,fnConfig.defaults,options);
2691 
2692  options.granted = (convertToBoolean(options.granted)) ? 1 : 0;
2693 
2694  this._doPost(fnName,[
2695  ['id', options.assetid],
2696  ['granted', options.granted],
2697  ['cascades', options.cascades]
2698  ],options);
2699 
2700  },// end getMetadataSchema
2701 
2702  <?php
2703  }//end if(get_metadata_schema)
2704 
2705  ?>
2706 
2710  _doPost: function(fnName,data,options)
2711  {
2712  var self = this;
2713 
2714  // Add the 'type' parameter for as the calling function name
2715  data.push(['type',fnName]);
2716  // Add nonce token
2717  data.push(['nonce_token','<?php echo ($nonce_token);?>']);
2718  self._http({
2719  params: data,
2720  onSuccess: function(json) {
2721  // Every function should have a dataCallback argument
2722  if (options.hasOwnProperty('dataCallback')) {
2723  options.dataCallback.call(this,json);
2724  }// end if
2725  }
2726  });
2727 
2728  }// end _doPost
2729 
2730 
2731  };// end Squiz_Matrix_API methods
2732 
2733 
2734 })(window);
2735 
2736  <?php
2737 
2738  }//end paintJSFunctions()
2739 
2740 
2741 }// end class
2742 
2743 ?>