1Liferay.PortletURL = new Liferay.Class( 2 { 3 initialize: function(lifecycle, params) { 4 var instance = this; 5 6 instance.params = params || {}; 7 8 instance.options = { 9 copyCurrentRenderParameters: null, 10 doAsUserId: null, 11 encrypt: null, 12 escapeXML: null, 13 lifecycle: lifecycle, 14 name: null, 15 p_l_id: themeDisplay.getPlid(), 16 portletConfiguration: false, 17 portletId: null, 18 portletMode: null, 19 resourceId: null, 20 secure: null, 21 windowState: null 22 }; 23 24 instance._parameterMap = { 25 javaClass: 'java.util.HashMap', 26 map: {} 27 }; 28 }, 29 30 setCopyCurrentRenderParameters: function(copyCurrentRenderParameters) { 31 var instance = this; 32 33 instance.options.copyCurrentRenderParameters = copyCurrentRenderParameters; 34 35 return instance; 36 }, 37 38 setDoAsUserId: function(doAsUserId) { 39 var instance = this; 40 41 instance.options.doAsUserId = doAsUserId; 42 43 return instance; 44 }, 45 46 setEncrypt: function(encrypt) { 47 var instance = this; 48 49 instance.options.encrypt = encrypt; 50 51 return instance; 52 }, 53 54 setEscapeXML: function(escapeXML) { 55 var instance = this; 56 57 instance.options.escapeXML = escapeXML; 58 59 return instance; 60 }, 61 62 setLifecycle: function(lifecycle) { 63 var instance = this; 64 65 instance.options.lifecycle = lifecycle; 66 67 return instance; 68 }, 69 70 setName: function(name) { 71 var instance = this; 72 73 instance.options.name = name; 74 75 return instance; 76 }, 77 78 setParameter: function(key, value) { 79 var instance = this; 80 81 instance.params[key] = value; 82 83 return instance; 84 }, 85 86 setPlid: function(plid) { 87 var instance = this; 88 89 instance.options.p_l_id = plid; 90 91 return instance; 92 }, 93 94 setPortletConfiguration: function(portletConfiguration) { 95 var instance = this; 96 97 instance.options.portletConfiguration = portletConfiguration; 98 99 return instance; 100 }, 101 102 setPortletId: function(portletId) { 103 var instance = this; 104 105 instance.options.portletId = portletId; 106 107 return instance; 108 }, 109 110 setPortletMode: function(portletMode) { 111 var instance = this; 112 113 instance.options.portletMode = portletMode; 114 115 return instance; 116 }, 117 118 setResourceId: function(resourceId) { 119 var instance = this; 120 121 instance.options.resourceId = resourceId; 122 123 return instance; 124 }, 125 126 setSecure: function(secure) { 127 var instance = this; 128 129 instance.options.secure = secure; 130 131 return instance; 132 }, 133 134 setWindowState: function(windowState) { 135 var instance = this; 136 137 instance.options.windowState = windowState; 138 139 return instance; 140 }, 141 142 toString: function() { 143 var instance = this; 144 145 instance._forceStringValues(instance.params); 146 instance._forceStringValues(instance.options); 147 148 jQuery.extend( 149 instance._parameterMap.map, 150 instance.params 151 ); 152 153 var xHR = jQuery.ajax( 154 { 155 async: false, 156 data: instance._buildRequestData(), 157 type: 'GET', 158 url: themeDisplay.getPathContext() + '/c/portal/portlet_url' 159 } 160 ); 161 162 return xHR.responseText; 163 }, 164 165 _buildRequestData: function() { 166 var instance = this; 167 168 var data = {}; 169 170 jQuery.each( 171 instance.options, 172 function (key, value) { 173 if (value !== null) { 174 data[key] = [value].join(''); 175 } 176 } 177 ); 178 179 data.parameterMap = jQuery.toJSON(instance._parameterMap); 180 181 return data; 182 }, 183 184 _forceStringValues: function(obj) { 185 jQuery.each( 186 obj, 187 function (key, value) { 188 if (value !== null) { 189 obj[key] = [value].join(''); 190 } 191 } 192 ); 193 194 return obj; 195 } 196 } 197); 198 199jQuery.extend( 200 Liferay.PortletURL, 201 { 202 createActionURL: function() { 203 return new Liferay.PortletURL('ACTION_PHASE'); 204 }, 205 206 createPermissionURL: function(portletResource, modelResource, modelResourceDescription, resourcePrimKey) { 207 var redirect = location.href; 208 209 var portletURL = Liferay.PortletURL.createRenderURL(); 210 211 portletURL.setPortletId(86); 212 213 portletURL.setWindowState('MAXIMIZED'); 214 215 portletURL.setParameter('struts_action', '/portlet_configuration/edit_permissions'); 216 portletURL.setParameter('redirect', redirect); 217 218 if (!themeDisplay.isStateMaximized()) { 219 portletURL.setParameter('returnToFullPageURL', redirect); 220 } 221 222 portletURL.setParameter('portletResource', portletResource); 223 portletURL.setParameter('modelResource', modelResource); 224 portletURL.setParameter('modelResourceDescription', modelResourceDescription); 225 portletURL.setParameter('resourcePrimKey', resourcePrimKey); 226 227 return portletURL; 228 }, 229 230 createRenderURL: function() { 231 return new Liferay.PortletURL('RENDER_PHASE'); 232 }, 233 234 createResourceURL: function() { 235 return new Liferay.PortletURL('RESOURCE_PHASE'); 236 } 237 } 238);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.