36 $api_url = $js_api_asset->
getURL();
37 $nonce_token = get_unique_token();
58 function jsonToObj(json)
61 if (typeof(JSON) !==
'undefined') {
62 return JSON.parse(json);
66 return eval(
'(' + json +
')');
76 function getProperties(obj)
79 for (var propName in obj){
80 if (obj.hasOwnProperty(propName)){
81 properties.push(propName);
93 function convertToBoolean(variable)
96 if (variable !== null && typeof(variable) !==
"undefined") {
97 switch (typeof(variable)) {
99 ret = (variable === 1) ?
true :
false;
107 var testVar = variable.toLowerCase();
108 if (testVar ===
'true' || testVar ===
'1') {
110 }
else if (testVar ===
'false' || testVar ===
'0') {
126 gscope.Squiz_Matrix_API =
function(options)
130 if (!options.hasOwnProperty(
'key') || options.key ===
'') {
131 throw 'An API key is required';
134 self.key = options.key;
141 gscope.Squiz_Matrix_API.prototype = {
142 syncing_enabled : <?php echo $js_api_asset->
attr(
'sync_context'); ?>,
144 _http:
function(options)
149 function createRequest()
153 request =
new XMLHttpRequest();
154 }
catch (trymicrosoft) {
156 request =
new ActiveXObject(
"Msxml2.XMLHTTP");
157 }
catch (othermicrosoft) {
159 request =
new ActiveXObject(
"Microsoft.XMLHTTP");
167 throw 'Your browser does not support Ajax';
176 function data(params)
179 var dataArr = [
'key=' +
self.key];
181 for (var i = 0, l = params.length; i<l; i+=1) {
182 dataArr.push(params[i][0] +
'=' + params[i][1]);
184 return dataArr.join(
"&");
189 options =
self._options([
'params'],{
190 url:
'<?php echo $api_url; ?>',
193 contentType:
'application/x-www-form-urlencoded',
196 onSuccess:
function(){},
198 throw 'HTTPRequest call failed';
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);
211 options.onError.call(
this,http);
214 options.onError.call(
this,http);
219 http.setRequestHeader(
"Content-type", options.contentType);
223 http.send(encodeURI(data(options.params)));
231 _options:
function(required,defaults,options)
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';
241 for (var def in defaults) {
242 if (defaults.hasOwnProperty(def)){
243 defaults[def] = (options.hasOwnProperty(def)) ? options[def] : defaults[def];
247 if (defaults.hasOwnProperty(
'dataCallback') && typeof(defaults.dataCallback) !==
"function") {
248 throw 'Data callback must be a function';
261 _cleanUrlParam:
function(value)
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");
272 if ($js_api_asset->
attr(
'batch_requests')) {
285 batchRequest:
function(options)
287 var fnName =
'batchRequest';
288 if (arguments.length === 0) {
293 dataCallback:
function(){}
297 required: [
'functions']
303 var fnConfig =
this[fnName].call(
this);
304 options = this._options(fnConfig.required,fnConfig.defaults,options);
307 var postData = JSON.stringify(options.functions);
309 this._doPost(fnName,[
310 [
'functions', this._cleanUrlParam(postData)]
318 if ($js_api_asset->
attr(
'get_general')) {
332 getGeneral:
function(options)
334 var fnName =
'getGeneral';
335 if (arguments.length === 0) {
341 dataCallback:
function(){}
345 required: [
'asset_id']
351 var fnConfig =
this[fnName].call(
this);
352 options = this._options(fnConfig.required,fnConfig.defaults,options);
354 options.get_attributes = (convertToBoolean(options.get_attributes)) ? 1 : 0;
356 this._doPost(fnName,[
357 [
'id',options.asset_id],
358 [
'get_attributes',options.get_attributes]
375 getChildCount:
function(options)
377 var fnName =
'getChildCount';
378 if (arguments.length === 0) {
384 dataCallback:
function(){}
388 required: [
'asset_id',
'level']
394 var fnConfig =
this[fnName].call(
this);
395 options = this._options(fnConfig.required,fnConfig.defaults,options);
397 this._doPost(fnName,[
398 [
'asset_id', options.asset_id],
399 [
'levels',options.level]
407 if ($js_api_asset->
attr(
'get_lineage')) {
421 getLineage:
function(options)
423 var fnName =
'getLineage';
424 if (arguments.length === 0) {
429 significant_link_only: 1,
430 dataCallback:
function(){}
434 required: [
'asset_url']
440 var fnConfig =
this[fnName].call(
this);
441 options = this._options(fnConfig.required,fnConfig.defaults,options);
444 options.asset_url = encodeURI(options.asset_url);
446 options.significant_link_only = (convertToBoolean(options.significant_link_only)) ? 1 : 0;
448 this._doPost(fnName,[
449 [
'asset_url', options.asset_url],
450 [
'significant_link_only', options.significant_link_only]
459 if ($js_api_asset->
attr(
'get_lineage_from_url')) {
472 getLineageFromUrl:
function(options)
474 var fnName =
'getLineageFromUrl';
475 if (arguments.length === 0) {
480 dataCallback:
function(){}
484 required: [
'asset_url']
490 var fnConfig =
this[fnName].call(
this);
491 options = this._options(fnConfig.required,fnConfig.defaults,options);
494 options.asset_url = encodeURI(options.asset_url);
496 this._doPost(fnName,[
497 [
'asset_url', options.asset_url]
506 if ($js_api_asset->
attr(
'get_url_from_lineage')) {
519 getUrlFromLineage:
function(options)
521 var fnName =
'getUrlFromLineage';
522 if (arguments.length === 0) {
529 dataCallback:
function(){}
533 required: [
'lineage']
539 var fnConfig =
this[fnName].call(
this);
540 options = this._options(fnConfig.required,fnConfig.defaults,options);
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"]);
549 lineageArray.push(options.lineage[i]);
554 this._doPost(fnName,[
555 [
'lineage', lineageArray.join(
'\\,')],
556 [
'root_url', options.root_url],
557 [
'protocol', options.protocol]
567 if ($js_api_asset->
attr(
'get_attributes')) {
579 getAttributes:
function(options)
581 var fnName =
'getAttributes';
582 if (arguments.length === 0) {
587 dataCallback:
function(){}
591 required: [
'asset_id']
597 var fnConfig =
this[fnName].call(
this);
598 options = this._options(fnConfig.required,fnConfig.defaults,options);
600 this._doPost(fnName,[
601 [
'id',options.asset_id]
609 if ($js_api_asset->
attr(
'set_attribute')) {
623 setAttribute:
function(options)
625 var fnName =
'setAttribute';
626 if (arguments.length === 0) {
633 dataCallback:
function(){}
637 required: [
'asset_id',
'attr_name',
'attr_val']
643 var fnConfig =
this[fnName].call(
this);
644 options = this._options(fnConfig.required,fnConfig.defaults,options);
646 this._doPost(fnName,[
647 [
'id',options.asset_id],
648 [
'attr_name',options.attr_name],
649 [
'attr_val',
this._cleanUrlParam(options.attr_val)]
665 setMultipleAttributes:
function(options)
667 var fnName =
'setMultipleAttributes';
668 if (arguments.length === 0) {
674 dataCallback:
function(){}
678 required: [
'asset_id',
'field_info']
684 var fnConfig =
this[fnName].call(
this);
685 options = this._options(fnConfig.required,fnConfig.defaults,options);
687 var field_names = [];
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]));
696 this._doPost(fnName,[
697 [
'attr_name',field_names.join(
'\\,')],
698 [
'attr_val',field_vals.join(
'\\,')],
699 [
'id',options.asset_id]
707 if ($js_api_asset->
attr(
'get_metadata')) {
719 getMetadata:
function(options)
721 var fnName =
'getMetadata';
722 if (arguments.length === 0) {
727 dataCallback:
function(){}
731 required: [
'asset_id']
737 var fnConfig =
this[fnName].call(
this);
738 options = this._options(fnConfig.required,fnConfig.defaults,options);
740 this._doPost(fnName,[
741 [
'id',options.asset_id]
749 if ($js_api_asset->
attr(
'set_metadata')) {
763 setMetadata:
function(options)
765 var fnName =
'setMetadata';
766 if (arguments.length === 0) {
773 dataCallback:
function(){}
777 required: [
'asset_id',
'field_id',
'field_val']
783 var fnConfig =
this[fnName].call(
this);
784 options = this._options(fnConfig.required,fnConfig.defaults,options);
786 this._doPost(fnName,[
787 [
'id',options.asset_id],
788 [
'field_id',options.field_id],
789 [
'field_val',
this._cleanUrlParam(options.field_val)]
805 setMetadataAllFields:
function(options)
807 var fnName =
'setMetadataAllFields';
808 if (arguments.length === 0) {
814 dataCallback:
function(){}
818 required: [
'asset_id',
'field_info']
824 var fnConfig =
this[fnName].call(
this);
825 options = this._options(fnConfig.required,fnConfig.defaults,options);
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]));
836 this._doPost(fnName,[
837 [
'field_id',field_ids.join(
'\\,')],
838 [
'field_val',field_vals.join(
'\\,')],
839 [
'id',options.asset_id]
847 if ($js_api_asset->
attr(
'trash_asset')) {
859 trashAsset:
function(options)
861 var fnName =
'trashAsset';
862 if (arguments.length === 0) {
867 dataCallback:
function(){}
871 required: [
'asset_ids']
877 var fnConfig =
this[fnName].call(
this);
878 options = this._options(fnConfig.required,fnConfig.defaults,options);
882 if (options.asset_ids.constructor === String) {
883 options.asset_ids = [options.asset_ids];
886 this._doPost(fnName,[
887 [
'assetid', options.asset_ids.join(
'\\,')]
895 if ($js_api_asset->
attr(
'get_children')) {
913 getChildren:
function(options)
915 var fnName =
'getChildren';
916 if (arguments.length === 0) {
926 dataCallback:
function(){}
930 required: [
'asset_id']
936 var fnConfig =
this[fnName].call(
this);
937 options = this._options(fnConfig.required,fnConfig.defaults,options);
939 if (typeof(options.type_codes) ===
"string") {
940 options.type_codes = [options.type_codes];
943 if (typeof(options.link_values) ===
"string") {
944 options.link_values = [options.link_values];
947 if (typeof(options.link_types) ===
"string") {
948 options.link_types = [options.link_types];
951 options.get_attributes = (convertToBoolean(options.get_attributes)) ? 1 : 0;
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]
967 if ($js_api_asset->
attr(
'get_parents')) {
985 getParents:
function(options)
987 var fnName =
'getParents';
988 if (arguments.length === 0) {
998 dataCallback:
function(){}
1002 required: [
'asset_id']
1008 var fnConfig =
this[fnName].call(
this);
1009 options = this._options(fnConfig.required,fnConfig.defaults,options);
1011 if (typeof(options.type_codes) ===
"string") {
1012 options.type_codes = [options.type_codes];
1015 if (typeof(options.link_values) ===
"string") {
1016 options.link_values = [options.link_values];
1019 if (typeof(options.link_types) ===
"string") {
1020 options.link_types = [options.link_types];
1023 options.get_attributes = (convertToBoolean(options.get_attributes)) ? 1 : 0;
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]
1039 if ($js_api_asset->
attr(
'get_permissions')) {
1052 getPermissions:
function(options)
1054 var fnName =
'getPermissions';
1055 if (arguments.length === 0) {
1061 dataCallback:
function(){}
1065 required: [
'asset_id']
1071 var fnConfig =
this[fnName].call(
this);
1072 options = this._options(fnConfig.required,fnConfig.defaults,options);
1074 this._doPost(fnName,[
1075 [
'id', options.asset_id],
1076 [
'level', options.level]
1084 if ($js_api_asset->
attr(
'create_asset')) {
1105 createAsset:
function(options)
1107 var fnName =
'createAsset';
1108 if (arguments.length === 0) {
1120 extra_attributes: 0,
1122 dataCallback:
function(){}
1126 required: [
'parent_id',
'type_code',
'asset_name',
'link_type']
1132 var fnConfig =
this[fnName].call(
this);
1133 options = this._options(fnConfig.required,fnConfig.defaults,options);
1135 options.is_dependant = (convertToBoolean(options.is_dependant)) ? 1 : 0;
1136 options.is_exclusive = (convertToBoolean(options.is_exclusive)) ? 1 : 0;
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]
1166 createFileAsset:
function(options)
1168 var fnName =
'createFileAsset';
1169 if (arguments.length === 0) {
1176 link_type:
'SQ_LINK_TYPE_1',
1178 dataCallback:
function(){}
1182 required: [
'parentID',
'type_code']
1188 var fnConfig =
this[fnName].call(
this);
1189 options = this._options(fnConfig.required,fnConfig.defaults,options);
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)]
1204 if ($js_api_asset->
attr(
'get_asset_types')) {
1215 getAssetTypes:
function(options)
1217 var fnName =
'getAssetTypes';
1218 if (arguments.length === 0) {
1222 dataCallback:
function(){}
1232 var fnConfig =
this[fnName].call(
this);
1233 options = this._options(fnConfig.required,fnConfig.defaults,options);
1235 this._doPost(fnName,[
1244 if ($js_api_asset->
attr(
'get_locks_info')) {
1257 getLocksInfo:
function(options)
1259 var fnName =
'getLocksInfo';
1260 if (arguments.length === 0) {
1266 dataCallback:
function(){}
1270 required: [
'asset_id']
1276 var fnConfig =
this[fnName].call(
this);
1277 options = this._options(fnConfig.required,fnConfig.defaults,options);
1279 this._doPost(fnName,[
1280 [
'id',options.asset_id],
1281 [
'screen',options.screen_name]
1289 if ($js_api_asset->
attr(
'acquire_lock')) {
1305 acquireLock:
function(options)
1307 var fnName =
'acquireLock';
1308 if (arguments.length === 0) {
1316 dataCallback:
function(){}
1320 required: [
'asset_id']
1326 var fnConfig =
this[fnName].call(
this);
1327 options = this._options(fnConfig.required,fnConfig.defaults,options);
1329 options.dependants_only = (convertToBoolean(options.dependants_only)) ? 1 : 0;
1330 options.force_acquire = (convertToBoolean(options.force_acquire)) ? 1 : 0;
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]
1344 if ($js_api_asset->
attr(
'release_lock')) {
1357 releaseLock:
function(options)
1359 var fnName =
'releaseLock';
1360 if (arguments.length === 0) {
1366 dataCallback:
function(){}
1370 required: [
'asset_id']
1376 var fnConfig =
this[fnName].call(
this);
1377 options = this._options(fnConfig.required,fnConfig.defaults,options);
1379 this._doPost(fnName,[
1380 [
'id',options.asset_id],
1381 [
'screen',options.screen_name]
1389 if ($js_api_asset->
attr(
'create_link')) {
1407 createLink:
function(options)
1409 var fnName =
'createLink';
1410 if (arguments.length === 0) {
1421 dataCallback:
function(){}
1425 required: [
'parent_id',
'child_id',
'link_value',
'link_type']
1431 var fnConfig =
this[fnName].call(
this);
1432 options = this._options(fnConfig.required,fnConfig.defaults,options);
1434 options.is_dependant = (convertToBoolean(options.is_dependant)) ? 1 : 0;
1435 options.is_exclusive = (convertToBoolean(options.is_exclusive)) ? 1 : 0;
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]
1452 if ($js_api_asset->
attr(
'remove_link')) {
1468 removeLink:
function(options)
1470 var fnName =
'removeLink';
1471 if (arguments.length === 0) {
1477 link_type:
'SQ_LINK_TYPE_1',
1479 dataCallback:
function(){}
1483 required: [
'parent_id',
'child_id',
'link_value',
'link_type']
1489 var fnConfig =
this[fnName].call(
this);
1490 options = this._options(fnConfig.required,fnConfig.defaults,options);
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)]
1512 removeMultipleLinks:
function(options)
1514 var fnName =
'removeMultipleLinks';
1515 if (arguments.length === 0) {
1520 dataCallback:
function(){}
1524 required: [
'link_info']
1530 var fnConfig =
this[fnName].call(
this);
1531 options = this._options(fnConfig.required,fnConfig.defaults,options);
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';
1539 var parent_ids = [];
1540 var link_types = [];
1541 var link_values = [];
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));
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(
'\\,')]
1557 throw fnName +
' missing "links" property';
1565 if ($js_api_asset->
attr(
'move_link')) {
1586 moveLink:
function(options)
1588 var fnName =
'moveLink';
1589 if (arguments.length === 0) {
1593 old_parent_id: null,
1595 old_link_type:
'SQ_LINK_TYPE_1',
1597 new_parent_id: null,
1598 new_link_type:
'SQ_LINK_TYPE_1',
1601 dataCallback:
function(){}
1605 required: [
'old_parent_id',
'child_id',
'old_link_type',
'old_link_value',
'new_parent_id']
1611 var fnConfig =
this[fnName].call(
this);
1612 options = this._options(fnConfig.required,fnConfig.defaults,options);
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]
1630 if ($js_api_asset->
attr(
'update_link')) {
1651 updateLink:
function(options)
1653 var fnName =
'updateLink';
1654 if (arguments.length === 0) {
1660 existing_link_type:
'SQ_LINK_TYPE_1',
1661 existing_link_value:
'',
1662 link_type:
'SQ_LINK_TYPE_1',
1666 dataCallback:
function(){}
1670 required: [
'parent_id',
'child_id',
'existing_link_type',
'existing_link_value']
1676 var fnConfig =
this[fnName].call(
this);
1677 options = this._options(fnConfig.required,fnConfig.defaults,options);
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]
1703 updateMultipleLinks:
function(options)
1705 var fnName =
'updateMultipleLinks';
1706 if (arguments.length === 0) {
1711 dataCallback:
function(){}
1715 required: [
'link_info']
1721 var fnConfig =
this[fnName].call(
this);
1722 options = this._options(fnConfig.required,fnConfig.defaults,options);
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';
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 = [];
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);
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(
'\\,')]
1760 throw fnName +
' missing "links" property';
1768 if ($js_api_asset->
attr(
'get_link_id')) {
1785 getLinkId:
function(options)
1787 var fnName =
'getLinkId';
1788 if (arguments.length === 0) {
1794 link_type:
'SQ_LINK_TYPE_1',
1797 dataCallback:
function(){}
1801 required: [
'parent_id',
'child_id']
1807 var fnConfig =
this[fnName].call(
this);
1808 options = this._options(fnConfig.required,fnConfig.defaults,options);
1810 options.all_info = (convertToBoolean(options.all_info)) ? 1 : 0;
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]
1825 if ($js_api_asset->
attr(
'get_asset_tree')) {
1838 getAssetTree:
function(options)
1840 var fnName =
'getAssetTree';
1841 if (arguments.length === 0) {
1847 dataCallback:
function(){}
1851 required: [
'asset_id']
1857 var fnConfig =
this[fnName].call(
this);
1858 options = this._options(fnConfig.required,fnConfig.defaults,options);
1860 this._doPost(fnName,[
1861 [
'id', options.asset_id],
1862 [
'levels', options.levels]
1870 if ($js_api_asset->
attr(
'get_keywords_replacements')) {
1883 getKeywordsReplacements:
function(options)
1885 var fnName =
'getKeywordsReplacements';
1886 if (arguments.length === 0) {
1892 dataCallback:
function(){}
1896 required: [
'asset_id',
'keywords_array']
1902 var fnConfig =
this[fnName].call(
this);
1903 options = this._options(fnConfig.required,fnConfig.defaults,options);
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] +
'")';
1911 this._doPost(fnName,[
1912 [
'id', options.asset_id],
1913 [
'keywords', options.keywords_array.join(
'\\,')]
1921 if ($js_api_asset->
attr(
'set_asset_status')) {
1936 setAssetStatus:
function(options)
1938 var fnName =
'setAssetStatus';
1939 if (arguments.length === 0) {
1946 workflow_stream:
'',
1947 dataCallback:
function(){}
1951 required: [
'asset_id',
'status']
1957 var fnConfig =
this[fnName].call(
this);
1958 options = this._options(fnConfig.required,fnConfig.defaults,options);
1960 options.cascade = (convertToBoolean(options.cascade)) ? 1 : 0;
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]
1974 if ($js_api_asset->
attr(
'get_web_path')) {
1986 getWebPath:
function(options)
1988 var fnName =
'getWebPath';
1989 if (arguments.length === 0) {
1994 dataCallback:
function(){}
1998 required: [
'asset_id']
2004 var fnConfig =
this[fnName].call(
this);
2005 options = this._options(fnConfig.required,fnConfig.defaults,options);
2007 this._doPost(fnName,[
2008 [
'id', options.asset_id]
2016 if ($js_api_asset->
attr(
'set_web_path')) {
2030 setWebPath:
function(options)
2032 var fnName =
'setWebPath';
2033 if (arguments.length === 0) {
2040 dataCallback:
function(){}
2044 required: [
'asset_id']
2050 var fnConfig =
this[fnName].call(
this);
2051 options = this._options(fnConfig.required,fnConfig.defaults,options);
2053 options.auto_remap = (convertToBoolean(options.auto_remap)) ? 1 : 0;
2055 for (var path in options.paths) {
2056 if (options.paths[path] !==
'') {
2057 options.paths[path] = this._cleanUrlParam(options.paths[path]);
2061 this._doPost(fnName,[
2062 [
'id', options.asset_id],
2063 [
'webpath', options.paths.join(
'\\,')],
2064 [
'auto_remap',options.auto_remap]
2072 if ($js_api_asset->
attr(
'get_workflow_schema')) {
2087 getWorkflowSchema:
function(options)
2089 var fnName =
'getWorkflowSchema';
2090 if (arguments.length === 0) {
2097 dataCallback:
function(){}
2101 required: [
'asset_id']
2107 var fnConfig =
this[fnName].call(
this);
2108 options = this._options(fnConfig.required,fnConfig.defaults,options);
2110 options.running = (convertToBoolean(options.running)) ? 1 : 0;
2112 this._doPost(fnName,[
2113 [
'id', options.asset_id],
2114 [
'granted', options.granted],
2115 [
'running',options.running]
2123 if ($js_api_asset->
attr(
'set_file_content')) {
2138 setContentOfEditableFileAsset:
function(options)
2140 var fnName =
'setContentOfEditableFileAsset';
2141 if (arguments.length === 0) {
2146 content:
'no_value_provided',
2147 dataCallback:
function(){}
2151 required: [
'asset_id',
'content']
2157 var fnConfig =
this[fnName].call(
this);
2158 options = this._options(fnConfig.required,fnConfig.defaults,options);
2160 options.content = escape(options.content);
2162 this._doPost(fnName,[
2163 [
'id', options.asset_id],
2164 [
'content', options.content]
2172 if ($js_api_asset->
attr(
'import_assets')) {
2186 importAssetsFromXML:
function(options)
2188 var fnName =
'importAssetsFromXML';
2189 if (arguments.length === 0) {
2195 dataCallback:
function(){}
2199 required: [
'asset_id',
'filePath']
2205 var fnConfig =
this[fnName].call(
this);
2206 options = this._options(fnConfig.required,fnConfig.defaults,options);
2208 this._doPost(fnName,[
2209 [
'id', options.asset_id],
2210 [
'filePath', options.filePath]
2218 if ($js_api_asset->
attr(
'get_roles')) {
2242 getRoles:
function(options)
2244 var fnName =
'getRoles';
2245 if (arguments.length === 0) {
2258 strict_type_code: 1,
2259 dataCallback:
function(){}
2269 var fnConfig =
this[fnName].call(
this);
2270 options = this._options(fnConfig.required,fnConfig.defaults,options);
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;
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],
2297 if ($js_api_asset->
attr(
'execute_html_tidy')) {
2309 executeHTMLTidy:
function(options)
2311 var fnName =
'executeHTMLTidy';
2312 if (arguments.length === 0) {
2317 dataCallback:
function(){}
2321 required: [
'content']
2327 var fnConfig =
this[fnName].call(
this);
2328 options = this._options(fnConfig.required,fnConfig.defaults,options);
2330 this._doPost(fnName,[
2331 [
'content', options.content]
2340 if ($js_api_asset->
attr(
'clone_asset')) {
2358 cloneAsset:
function(options)
2360 var fnName =
'cloneAsset';
2361 if (arguments.length === 0) {
2369 link_type:
'SQ_LINK_TYPE_1',
2371 dataCallback:
function(){}
2375 required: [
'asset_id',
'new_parent']
2381 var fnConfig =
this[fnName].call(
this);
2382 options = this._options(fnConfig.required,fnConfig.defaults,options);
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]
2399 if ($js_api_asset->
attr(
'show_diff')) {
2415 showDifference:
function(options)
2417 var fnName =
'showDifference';
2418 if (arguments.length === 0) {
2426 dataCallback:
function(){}
2430 required: [
'assetid_1',
'assetid_2']
2436 var fnConfig =
this[fnName].call(
this);
2437 options = this._options(fnConfig.required,fnConfig.defaults,options);
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]
2452 if ($js_api_asset->
attr(
'get_context')) {
2466 getAlternateContext:
function(options)
2468 var fnName =
'getAlternateContext';
2469 if (arguments.length === 0) {
2474 dataCallback:
function(){}
2478 required: [
'all_info']
2484 var fnConfig =
this[fnName].call(
this);
2485 options = this._options(fnConfig.required,fnConfig.defaults,options);
2487 options.all_info = (convertToBoolean(options.all_info)) ? 1 : 0;
2489 this._doPost(fnName,[
2490 [
'all_info', options.all_info]
2506 getCurrentContext:
function(options)
2508 var fnName =
'getCurrentContext';
2509 if (arguments.length === 0) {
2514 dataCallback:
function(){}
2518 required: [
'all_info']
2524 var fnConfig =
this[fnName].call(
this);
2525 options = this._options(fnConfig.required,fnConfig.defaults,options);
2527 options.all_info = (convertToBoolean(options.all_info)) ? 1 : 0;
2529 this._doPost(fnName,[
2530 [
'all_info', options.all_info]
2546 getAllContexts:
function(options)
2548 var fnName =
'getAllContexts';
2549 if (arguments.length === 0) {
2554 dataCallback:
function(){}
2558 required: [
'all_info']
2564 var fnConfig =
this[fnName].call(
this);
2565 options = this._options(fnConfig.required,fnConfig.defaults,options);
2567 options.all_info = (convertToBoolean(options.all_info)) ? 1 : 0;
2569 this._doPost(fnName,[
2570 [
'all_info', options.all_info]
2578 if ($js_api_asset->
attr(
'set_context')) {
2590 setContext :
function(options)
2592 var fnName =
'setContext';
2593 if (arguments.length === 0) {
2598 dataCallback:
function(){}
2602 required: [
'context_id']
2608 var fnConfig =
this[fnName].call(
this);
2609 options = this._options(fnConfig.required,fnConfig.defaults,options);
2611 this._doPost(fnName,[
2612 [
'context_id', options.context_id]
2627 restoreContext :
function(options)
2629 var fnName =
'restoreContext';
2630 if (arguments.length === 0) {
2634 dataCallback:
function(){}
2644 var fnConfig =
this[fnName].call(
this);
2645 options = this._options(fnConfig.required,fnConfig.defaults,options);
2647 this._doPost(fnName,[],options);
2654 if ($js_api_asset->
attr(
'get_metadata_schema')) {
2669 getMetadataSchema:
function(options)
2671 var fnName =
'getMetadataSchema';
2672 if (arguments.length === 0) {
2679 dataCallback:
function(){}
2683 required: [
'assetid']
2689 var fnConfig =
this[fnName].call(
this);
2690 options = this._options(fnConfig.required,fnConfig.defaults,options);
2692 options.granted = (convertToBoolean(options.granted)) ? 1 : 0;
2694 this._doPost(fnName,[
2695 [
'id', options.assetid],
2696 [
'granted', options.granted],
2697 [
'cascades', options.cascades]
2710 _doPost:
function(fnName,data,options)
2715 data.push([
'type',fnName]);
2717 data.push([
'nonce_token',
'<?php echo ($nonce_token);?>']);
2720 onSuccess:
function(json) {
2722 if (options.hasOwnProperty(
'dataCallback')) {
2723 options.dataCallback.call(
this,json);