-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage.js
44 lines (43 loc) · 1.45 KB
/
page.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Create the resource object & check for resource namespace
* @hide
*/
if ( !GENTICS.Aloha.Repositories ) GENTICS.Aloha.Repositories = {};
GENTICS.Aloha.Repositories.Page = new GENTICS.Aloha.Repository('com.gentics.aloha.GCN.Page');
/**
* Searches a resource for resource items matching query if objectTypes.
* If none found it returns null.
*/
GENTICS.Aloha.Repositories.Page.query = function( p, callback) {
// check whether a magiclinkconstruct exists. If not, just do nothing, since setting GCN links is not supported
if (!GENTICS.Aloha.GCN.settings.magiclinkconstruct) {
callback.call(that);
}
var that = this;
var params = {
'query' : p.queryString,
'links' : GENTICS.Aloha.GCN.settings.links
};
if (p.maxItems) {
params['maxItems'] = p.maxItems;
}
// TODO handle errors
GENTICS.Aloha.GCN.performRESTRequest({
'url' : GENTICS.Aloha.GCN.settings.stag_prefix + GENTICS.Aloha.GCN.restUrl + '/folder/findPages',
'params' : params,
'success' : function(data) {
// TODO let the portal render <plink>s
jQuery.each(data.pages, function(index, page) {
page.id = "10007." + page.id;
page.displayName = page.name;
page.objectType = "website";
// TODO make this more efficient (don't make a single call for every url)
if (page.url && GENTICS.Aloha.GCN.settings.renderBlockContentURL) {
page.url = GENTICS.Aloha.GCN.renderBlockContent(page.url);
}
});
callback.call(that, data.pages);
},
'type' : 'GET'
});
};