Class: GalleryEmbed
Source Location: /modules/core/classes/GalleryEmbed.class
Class GalleryEmbed
Class Overview
Access point for external application in which Gallery is embedded.
See http://codex.gallery2.org/index.php/Gallery2:Embedding for more information on embedding / integration. Three interaction modes: - 1. GalleryEmbed::init(array(..)) followed by GalleryEmbed::handleRequest()
- 2. GalleryEmbed::init(array(.., 'fullInit' => true)) followed by other
GalleryEmbed/G2 calls, end with GalleryEmbed::done() <-- REQUIRED
- 3. Single GalleryEmbed::logout(array(..)) call
All of these methods should be accessed in a static sense, ie: GalleryEmbed::handleRequest();
Located in /modules/core/classes/GalleryEmbed.class [line 58]
|
Methods
|
Method Summary
array |
getApiVersion() |
Return the major and minor version of the Embedding API. |
array |
getExternalIdMap() |
Get the complete externalId<->entityId map (for users and groups). |
string |
getSessionId() |
Retrieve G2 session id. This method can be called after init() or handleRequest(). |
GalleryStatus |
init() |
Initialize Gallery; must be called before most GalleryEmbed methods can be used. |
array |
parseHead() |
Parse html (headHtml) for css links, javascript, meta tags and page title |
array |
search() |
Search specific module. |
array |
searchScan() |
Perform a search across all available searchable modules. |
Methods
static void getEmbedPathByHttpRequest(
)
|
|
Simplify finding the path to embed.php by sending it as a HTTP header
Idea: In your integration setup you need to find out - the filesystem path for embed.php
- the g2Uri and the embedUri.
You can get the embed.php path with your g2Uri by fetching http://example.com/gallery2/embed.php?getEmbedPath=1 via fsockopen.
GalleryStatus addExternalIdMapEntry(
string
$externalId, int
$entityId, string
$entityType
)
|
|
Add an externalId<->entityId map entry for existing G2/emApp users/groups Example:
Parameters:
string |
$externalId: |
the user/group id in the embedded application |
int |
$entityId: |
the entityId of the user/group in G2 |
string |
$entityType: |
'GalleryUser' for user mapping, 'GalleryGroup' for group mapping |
GalleryStatus addUserToGroup(
string
$extUserId, string
$extGroupId
)
|
|
Add a user to a G2 group.
Parameters:
string |
$extUserId: |
external user id |
string |
$extGroupId: |
external group id |
API Tags:
Ensure G2 session has same active user as CMS session.
No need to call directly if activeUserId is passed to init().
Parameters:
string |
$activeUserId: |
external user id of active user (null or empty for anonymous/guest user) |
API Tags:
Return: | a status object |
Access: | private |
Information Tags:
Todo: | Ensure that the active user ($gallery->getActiveUser) is changed as well |
GalleryStatus createGroup(
string
$extGroupId, string
$groupName
)
|
|
Create a G2 group.
Parameters:
string |
$extGroupId: |
external group id |
string |
$groupName: |
group name |
API Tags:
Create a G2 user.
Parameters:
string |
$extUserId: |
external user id |
array |
$args: |
user data (username required; others optional) ['username' => string, 'email' => string, 'fullname' => string, 'language' => string, 'password' => string, 'hashedpassword' => string, 'hashmethod' => string, 'creationtimestamp' => integer] |
API Tags:
Delete a G2 group.
Parameters:
string |
$extGroupId: |
external group id |
API Tags:
Delete a G2 user.
Parameters:
string |
$extUserId: |
external user id |
API Tags:
Complete the G2 transaction.
API Tags:
Return the major and minor version of the Embedding API.
Make sure to specify the 'apiVersion' parameter in the GalleryEmbed::init call!
API Tags:
Return: | major number, minor number |
See: | GalleryCoreApi::getApiVersion, the same rules and notes apply to the Embedding API |
array getBlock(
string
$moduleId, string
$blockName, [array
$params = array()]
)
|
|
Get a module block
Parameters:
string |
$moduleId: |
A Gallery module id |
string |
$blockName: |
The name of the requested block |
array |
$params: |
(optional) Block parameters |
API Tags:
Return: | GalleryStatus A status code, string HTML content: the block HTML, string head HTML to be inserted into the <head> section |
Information Tags:
array getExternalIdMap(
string
$key
)
|
|
Get the complete externalId<->entityId map (for users and groups).
The return array is organized by externalId or by entityId.
Parameters:
string |
$key: |
'externalId' or 'entityId', array is organized by this key |
API Tags:
Return: | GalleryStatus, array(externalId|entityId => array(externalId => int/string, entityId => int, entityType => string)) |
array getImageBlock(
array
$params
)
|
|
Get HTML for an image block
Example: list ($ret, $html, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => 'randomImage', 'show' => 'title|date'));
Parameters:
array |
$params: |
('blocks' => string, 'show' => string, (optional)'itemId' => int, (optional)'maxSize' => int, (optional)'exactSize' => int, (optional)'itemFrame' => frameId, (optional)'albumFrame' => frameId) - 'blocks' is a pipe (|) separated list, of one or more possible blocks which are:
randomImage|recentImage|viewedImage|randomAlbum|recentAlbum|viewedAlbum|specificItem
dailyImage|weeklyImage|monthlyImage|dailyAlbum|weeklyAlbum|monthlyAlbum
- 'show' is a pipe (|) separated list of one or more possible choices which are:
title|date|views|owner|heading|fullSize or just 'none'
- If you choose 'blocks' => 'specificItem', you must specify 'itemId' too.<li>
- itemFrame/albumFrame may require CSS to be displayed.
- See Image Block Site Admin page for info on optional parameters.
|
API Tags:
Return: | GalleryStatus, string html content, string head content or null if none required |
Deprecated: | Use getBlock() instead |
Retrieve G2 session id. This method can be called after init() or handleRequest().
API Tags:
void handleEvent(
$event
)
|
|
Parameters:
API Tags:
See: | GalleryEventListener::handleRequest |
Process the G2 request.
Return value contains 'isDone'=>true if output has already been sent (redirect, or output from G2 immediate view like core.DownloadItem) and CMS should not send any additional output. If isDone is false then check headHtml and bodyHtml keys for content to display via CMS. Include activeUserName parameter if integration is not calling GalleryEmbed::login() at CMS login time. themeData is set if isDone is false and populated with the corresponding template variable.
API Tags:
Return: | ('isDone' => boolean, [optional: 'headHtml' => string, 'bodyHtml' => string, 'sidebarBlocksHtml' => array('blockHtml', 'blockHtml'), 'themeData' => mixed theme data] |
Initialize Gallery; must be called before most GalleryEmbed methods can be used.
This method should only be called once during the lifetime of the request.
Parameters:
array |
$initParams: |
(optional--required before calling handleRequest) ( 'embedUri' => URI to access G2 via CMS application (example: /portal/index.php?module=gallery2) 'g2Uri' = URL path to G2 (example: /gallery2/, see extended docs for special character '|') 'loginRedirect' => (optional) URI for redirect to CMS login view (example: /cms/index.php) 'embedSessionString' => (optional) To support cookieless browsing, pass in key=value for CMS session key and session id value to be added as query parameter in urls 'gallerySessionId' => (optional) To support cookieless browsing, pass in G2 session id (when cookies not in use, CMS must track this value between requests) 'activeUserId' => (optional) external user id of active user (empty string for anonymous/guest user) 'activeLanguage' => (optional) language code in use for this session 'fullInit' => (optional) call GalleryInitSecondPass (only use when not calling handleRequest) 'apiVersion' => (optional) array int major, int minor (check if your integration is compatible) ) |
API Tags:
boolean isCompatibleWithEmbedApi(
array
$apiVersion
)
|
|
Return whether the supplied Embedding API version is compatible or not
Parameters:
array |
$apiVersion: |
int major, int minor |
GalleryStatus isExternalIdMapped(
string
$externalId, string
$entityType
)
|
|
Check if externalId is mapped to a G2 user/group.
- If GalleryStatus is a success, the externalId is mapped. Else, check for the status code.
- ERROR_MISSING_OBJECT -> externalId is not mapped to a G2 entity.
- other error codes -> unexpected behavior / bug.
Parameters:
string |
$externalId: |
the user/group id in the embedded application |
string |
$entityType: |
'GalleryUser' for user mapping, 'GalleryGroup' for group mapping |
Login the specified user in the G2 session.
This method is not usually needed (passing activeUserId to init() or calling checkActiveUser will login the user as needed); this method included for completeness.
Parameters:
string |
$extUserId: |
external user id |
API Tags:
Reset the G2 session. Do not call init() before this method.
Specify embedUri (the same embedUri as the one from ::init())
Parameters:
array |
$params: |
('embedUri' => string the embedUri (e.g. /cms/index.php)) |
API Tags:
array parseHead(
string
$headhtml
)
|
|
Parse html (headHtml) for css links, javascript, meta tags and page title
Note: meta are parsed for since Embed API version 1.4
Parameters:
API Tags:
Return: | string title, array (string css1, string css2, ...), array (string javascript1, string javascript2, ...), array (string meta1, string meta2, ...) |
GalleryStatus removeUserFromGroup(
string
$extUserId, string
$extGroupId
)
|
|
Remove a user from a G2 group.
Parameters:
string |
$extUserId: |
external user id |
string |
$extGroupId: |
external group id |
API Tags:
array search(
string
$searchString, string
$moduleId, int
$offset, int
$count
)
|
|
Search specific module.
Parameters:
string |
$searchString: |
search criteria |
string |
$moduleId: |
id of module to search |
int |
$offset: |
start index |
int |
$count: |
number of results to retrieve |
API Tags:
Return: | GalleryStatus a status object results array plus 'name' key with module name |
See: | GallerySearchInterface_1_0::search for contents of results array |
array searchScan(
string
$searchString, [int
$resultsPerModule = 3]
)
|
|
Perform a search across all available searchable modules.
Parameters:
string |
$searchString: |
search criteria |
int |
$resultsPerModule: |
(optional) max number of results to return from each module, defaults to 3 |
API Tags:
Return: | GalleryStatus a status object, array of {module_id} => results array plus 'name' key with module name> |
See: | GallerySearchInterface_1_0::search for contents of results arrays |
GalleryStatus setThemeForRequest(
string
$themeId, [array
$themeParams = null]
)
|
|
Override the theme for this request.
If the specified theme is unavailable, incompatible or inactive, it is ignored.
Parameters:
string |
$themeId: |
A GalleryTheme id |
array |
$themeParams: |
(optional) Theme parameters to be used. |
Update a G2 Group.
Parameters:
string |
$extGroupId: |
external group id |
array |
$args: |
group data ['groupname' => string] |
API Tags:
Update a G2 user.
Parameters:
string |
$extUserId: |
external user id |
array |
$args: |
user data ['username' => string, 'email' => string, 'fullname' => string, 'language' => string, 'password' => string, 'hashedpassword' => string, 'hashmethod' => string, 'creationtimestamp' => integer] |
API Tags:
Set values in user object based on given args.
Parameters:
GalleryUser |
$user: |
|
array |
$args: |
additional user data |
bool |
$create: |
(optional) Whether to use creation mode (applying default values). Default false. |
|
&$user: |
|
API Tags:
Return: | a status object |
Access: | private |
|
|