phpDocumentor GalleryCore
Classes
[ class tree: GalleryCore ] [ index: GalleryCore ] [ all elements ]

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

[ Top ]
Method Summary
static void   getEmbedPathByHttpRequest()   Simplify finding the path to embed.php by sending it as a HTTP header
GalleryStatus   addExternalIdMapEntry()   Add an externalId<->entityId map entry for existing G2/emApp users/groups Example:
  1. GalleryEmbed::addExternalIdMapEntry($uid$g2user->getId()'GalleryUser');
GalleryStatus   addUserToGroup()   Add a user to a G2 group.
GalleryStatus   checkActiveUser()   Ensure G2 session has same active user as CMS session.
GalleryStatus   createGroup()   Create a G2 group.
GalleryStatus   createUser()   Create a G2 user.
GalleryStatus   deleteGroup()   Delete a G2 group.
GalleryStatus   deleteUser()   Delete a G2 user.
GalleryStatus   done()   Complete the G2 transaction.
array   getApiVersion()   Return the major and minor version of the Embedding API.
array   getBlock()   Get a module block
array   getExternalIdMap()   Get the complete externalId<->entityId map (for users and groups).
array   getImageBlock()   Get HTML for an image block
string   getSessionId()   Retrieve G2 session id. This method can be called after init() or handleRequest().
void   handleEvent()  
array   handleRequest()   Process the G2 request.
GalleryStatus   init()   Initialize Gallery; must be called before most GalleryEmbed methods can be used.
boolean   isCompatibleWithEmbedApi()   Return whether the supplied Embedding API version is compatible or not
GalleryStatus   isExternalIdMapped()   Check if externalId is mapped to a G2 user/group.
GalleryStatus   login()   Login the specified user in the G2 session.
GalleryStatus   logout()   Reset the G2 session. Do not call init() before this method.
array   parseHead()   Parse html (headHtml) for css links, javascript, meta tags and page title
GalleryStatus   removeUserFromGroup()   Remove a user from a G2 group.
array   search()   Search specific module.
array   searchScan()   Perform a search across all available searchable modules.
GalleryStatus   setThemeForRequest()   Override the theme for this request.
GalleryStatus   updateGroup()   Update a G2 Group.
GalleryStatus   updateUser()   Update a G2 user.
GalleryStatus   _setUserData()   Set values in user object based on given args.

[ Top ]
Methods
static method getEmbedPathByHttpRequest  [line 1100]

  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.



[ Top ]
addExternalIdMapEntry  [line 882]

  GalleryStatus addExternalIdMapEntry( string $externalId, int $entityId, string $entityType  )

Add an externalId<->entityId map entry for existing G2/emApp users/groups Example:

  1. GalleryEmbed::addExternalIdMapEntry($uid$g2user->getId()'GalleryUser');

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


[ Top ]
addUserToGroup  [line 644]

  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:
Return:  a status object


[ Top ]
checkActiveUser  [line 225]

  GalleryStatus checkActiveUser( string $activeUserId  )

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

[ Top ]
createGroup  [line 551]

  GalleryStatus createGroup( string $extGroupId, string $groupName  )

Create a G2 group.

Parameters:
string   $extGroupId:  external group id
string   $groupName:  group name

API Tags:
Return:  a status object


[ Top ]
createUser  [line 405]

  GalleryStatus createUser( string $extUserId, array $args  )

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:
Return:  a status object


[ Top ]
deleteGroup  [line 587]

  GalleryStatus deleteGroup( string $extGroupId  )

Delete a G2 group.

Parameters:
string   $extGroupId:  external group id

API Tags:
Return:  a status object


[ Top ]
deleteUser  [line 526]

  GalleryStatus deleteUser( string $extUserId  )

Delete a G2 user.

Parameters:
string   $extUserId:  external user id

API Tags:
Return:  a status object


[ Top ]
done  [line 162]

  GalleryStatus done( )

Complete the G2 transaction.


API Tags:
Return:  a status object


[ Top ]
getApiVersion  [line 67]

  array getApiVersion( )

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


[ Top ]
getBlock  [line 995]

  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:
Since:  1.4

[ Top ]
getExternalIdMap  [line 903]

  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))


[ Top ]
getImageBlock  [line 868]

  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


[ Top ]
getSessionId  [line 388]

  string getSessionId( )

Retrieve G2 session id. This method can be called after init() or handleRequest().


API Tags:
Return:  session id


[ Top ]
handleEvent  [line 972]

  void handleEvent( $event  )

Parameters:
   $event: 

API Tags:
See:  GalleryEventListener::handleRequest


[ Top ]
handleRequest  [line 204]

  array 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]


[ Top ]
init  [line 105]

  GalleryStatus init( [array $initParams = array()]  )

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:
Return:  a status object


[ Top ]
isCompatibleWithEmbedApi  [line 77]

  boolean isCompatibleWithEmbedApi( array $apiVersion  )

Return whether the supplied Embedding API version is compatible or not

Parameters:
array   $apiVersion:  int major, int minor


[ Top ]
isExternalIdMapped  [line 937]

  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


[ Top ]
login  [line 309]

  GalleryStatus login( string $extUserId  )

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:
Return:  a status object


[ Top ]
logout  [line 346]

  GalleryStatus logout( [array $params = array()]  )

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:
Return:  a status object


[ Top ]
parseHead  [line 810]

  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:
string   $headhtml: 

API Tags:
Return:  string title, array (string css1, string css2, ...), array (string javascript1, string javascript2, ...), array (string meta1, string meta2, ...)


[ Top ]
removeUserFromGroup  [line 675]

  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:
Return:  a status object


[ Top ]
search  [line 760]

  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


[ Top ]
searchScan  [line 701]

  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


[ Top ]
setThemeForRequest  [line 959]

  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.


[ Top ]
updateGroup  [line 612]

  GalleryStatus updateGroup( string $extGroupId, array $args  )

Update a G2 Group.

Parameters:
string   $extGroupId:  external group id
array   $args:  group data ['groupname' => string]

API Tags:
Return:  a status object


[ Top ]
updateUser  [line 450]

  GalleryStatus updateUser( string $extUserId, array $args  )

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:
Return:  a status object


[ Top ]
_setUserData  [line 487]

  GalleryStatus _setUserData( &$user, array $args, [bool $create = false], GalleryUser $user  )

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


[ Top ]

Documentation generated on Fri, 08 Oct 2010 04:58:21 -0700 by phpDocumentor 1.3.0RC6