mGallery 0.2 - Postnuke bridge module

Johnny Birchett

Version .2-1

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation, with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the license can be obtained from the Free Software foundation

Abstract

This manual documents how the the menalto Gallery2 bridge for PostNuke works. mGallery2 is a utility module that embeds the Gallery2 web application into Postnuke


Table of Contents

1. Installation
Requirements
Install Gallery2
Gallery2 2.2.1 (Double-Double) Notes
Installing mGallery2
Install the module
Configuring the module
Adding mGallery2 to your Postnuke menu
User and Group Synchronization
2. mGallery2 Blocks
Random Block
Specific Block
Sidebar Block
3. The Transform Hook
Activating the transform hook
Postnuke HTML Options
General tag syntax
Transform Hook Options
itemID - The album or image id
show - How to show the image
maxsize - Maximum size of a full-sized image
type - The type of imageblock to show
aframe - Album Frame
iframe - Image Frame
frame - Image and Album Frame
class - CSS class
n - Number of images
itemId and block types
Escaping mg2 tags
4. Using g2Image with mGallery2 and Scribite
Requirements
Install and configure g2image files
g2Image and OpenBasedir
Updating Scribite
5. Support

List of Figures

1.1. Main Module Configuration

Chapter 1. Installation

Requirements

To install mGallery2 version .02, you must be running the following:

  • PostNuke .764 - Download it at http://www.postnuke.com/

  • Gallery2 2.1.2 (or higher) installed and working - Download at http://gallery.menalto.com

  • Image Block module installed and activated in Gallery2

  • Image Frame module installed and activated in Gallery2

You may find that it works with earlier versions but if you want support it will be difficult for me to debug. We are currently working on updates to make it compatible with Postnuke .8

Install Gallery2

Use the gallery documentation to install Gallery2 standalone on your web site. Gallery can be installed anywhere on your website. Just make a note of the base directory - the physical location of the gallery files - and the URI of the Gallery2 web site - it's path from the web root.

For instance, on a UNIX system, if your web site's root is located at /home/apache/htdocs and you install the Gallery2 files in /home/apache/htdocs/gallery2, your base directory would be /home/apache/htdocs/gallery2 and your Gallery2 URI would be /gallery2. The same applies on a Windows system. If your web root is located at d:\webroot\ and you install Gallery2 files in d:\webroot\gallery2, your base directory is d:\webroot\gallery2 and your Gallery2 URI is /gallery2.

Once Gallery2 is installed, go into the site administration and click on the modules link in the sidebar. Look in the Blocks section of the modules admin and make sure the Image Block plugin is installed and active. Look in the Display section of the modules admin and make sure the ImageFrame module is installed and active.

Gallery2 2.2.1 (Double-Double) Notes

Gallery 2.2.1 incorporates the Smarty templating engine and has several places in the code where it explicitly calls its own plugins. This causes some problems with Postnuke's own Smarty engine, so running Gallery 2.2.1 will require some code editing.

albumselect module

To correct the album select module's Smarty overlap, do the following:

  1. In your Gallery2 installation folder, navigate to the modules/albumselect folder

  2. Open the Callbacks.inc file in an editor. Save a copy of the file for safety

  3. Go to line 136, which should read:

    GalleryCoreApi::requireOnce('lib/smarty/plugins/modifier.escape.php');
  4. Add a line before this line that reads:

    if(!function_exists("smarty_modifier_escape")) {
  5. Add a line after 136 that reads:

    }
  6. Save and exit the file

GalleryTemplateAdapter

To correct the album select module's Smarty overlap, do the following:

  1. In your Gallery2 installation folder, navigate to the modules/core/classes folder

  2. Open the GalleryTemplateAdapter.class file in an editor. Save a copy of the file for safety.

  3. Go to line 241, which should read:

    GalleryCoreApi::requireOnce('lib/smarty/plugins/modifier.escape.php');
  4. Add a line before this line that reads:

    if(!function_exists("smarty_modifier_escape")) {
  5. Add a line after 241 that reads:

    }
  6. Go to line 726, which should read:

    GalleryCoreApi::requireOnce('lib/smarty/plugins/function.debug.php');
  7. Add a line before this line that reads:

    if(!function_exists("smarty_function_debug")) {
  8. Add a line after 726 that reads:

    }
  9. Go to line 1014, which should read:

    GalleryCoreApi::requireOnce('lib/smarty/plugins/modifier.escape.php');
  10. Add a line after this line that reads:

    if(!function_exists("smarty_modifier_escape")) {
  11. Add a line after 1014 that reads:

    }
  12. Save and exit the file

Validate Changes

Open your Gallery to make sure it still works. If it doesn't restore the two files and try again. If it still doesn't work, ask around on the mGallery2 forums.

Installing mGallery2

This section will describe how to install the module into your Postnuke site. It will also cover adding the module to the standard Postnuke menu and how to set up user and Group synchronization.

Install the module

The mGallery2 package consists of the module files, located in the mGallery2 folder, and two core Postnuke files for PN764, one located in the User/ folder and the other in the Groups/ folder. To perform the mGallery2 install:

  1. Copy the mGallery2 folder into your Postnuke modules/ folder

  2. Go to your Postnuke Administration Panel

  3. Click on the system tab

  4. Click on modules

  5. Make sure All is selected in the drop-down list beside the alphabetical filter menu links

  6. Click on the Regenerate link in the administration links

  7. After Postnuke regenerates the modules, find mGallery2 in the list

    Tip

    Click on the M link above the modules table to make it easier to find. It should have a status of Uninitialized)

  8. Click on Initialize in the module's actions

  9. The status of the module should now be Inactive

  10. Click on Activate in the module's actions

The module should now be installed.

Configuring the module

Now that the module is installed, it will need to be configured in order to access your installed Gallery2. This is where you will use the Base Directory and Gallery2 URI that you noted during Gallery2 installation. To configure the module, click on the Admin link in the module's actions or click on the 3rd Party tab in your Postnuke Admin Panel and click the mGallery2 icon.

There are two sections in the module's administration panel. The first section, Main Module Configuration, sets up the parameters for communicating with Gallery2. The screenshot below shows this section. You will notice that there are two lines in red. Before the module is configured, they will say that modules are disabled in the Gallery2 core, but they ar inaccurate until the module is set up properly. Here is the screenshot:

Figure 1.1. Main Module Configuration

Main Module Configuration

The first field is Base Directory, which is the physical path to the Gallery2 installation files. This is the path from the root of the filesystem. On a UNIX machine, it might be something like /webroot/htdocs/gallery2. On a Windows machine, it might be something like d:\webroot\gallery2.The second field is Gallery2 URI, which is the path from the web root to the Gallery2 files. Here's an example. The web root is where your web server looks for documents. Let's say you installed Postnuke into a folder called c:\web\postnuke or /web/postnuke and you set your web root to this folder in apache. You access your Postnuke site at this URI: /. Now, let's say you install gallery2 into a folder called c:\web\postnuke\g2\ or /web/postnuke/g2/ within the Postnuke folder. The URI for Gallery2 would be /g2. Let's say, on the other hand, that you installed Gallery2 into a different folder altogether, like d:\gallery2 or /apps/gallery2. In apache, you set this folder up to map to /Gallery2. Now your URI is /Gallery2.

Once you have these two fields set up correctly, click on the Update button at the bottom of the screen. If you have set Gallery up correctly, when the screen refreshes, the module status lines should both be in green as in the screenshot below:

If these lines are still red, it means you have either forgotten to install and activate the modules in Gallery2 or you have an incorrect Base directory, Gallery URI, or both. The mGallery2 module will still work without the two Gallery2 modules, but frames will not be available. mGallery2 will not work without a correct Base Directory and Gallery URI. The second section in the main module administration is the default parameters for the transform hook. The settings look like this.

These settings will take affect when no options are used in a transform hook tag. You can choose to show the title of the photo, the owner of the photo, the date of the photo (from EXIF data), or the number of views from within Gallery2. You can also choose to show the default full-sized image instead of a thumbnail and you can set the maximum size of the full-sized image or the thumbnail. The two dropdown boxes determine what frame will be used by default on albums and images. The link underneath the settings navigates to a contact sheet with all of the available frames displayed on a photo. All of these options are explained in more detail in the section The Transform Hook.

Adding mGallery2 to your Postnuke menu

The standard Postnuke installation comes with a side block menu. It can be accessed in the Postnuke administration panel under Blocks/Main Menu. It's easy to add a link to your gallery in the Postnuke menu block. Follow these steps to do it:

  1. Go to your Postnuke Administration Panel

  2. Click on the System tab if you're not there already

  3. Click on the Blocks icon

  4. Look for the Main Menu block and click on its Edit option

  5. In the Content section, look for or create an empty line

    Tip

    If you want it to appear after a specific item, check the "Insert blank after" check box for that item. Click the Update button. Edit the Main Menu again. You should see a new blank line where you wanted it.

  6. Type anything you want in the Title and Description fields

  7. In the URL field, type {mGallery2}

    Note

    This tells Postnuke to create a URL to the mGallery2 module

  8. Click the Update button

  9. You should now see your gallery link in the menu. Click it to test.

If you want to create links to specific albums, just go to your gallery and click on the album. When you have the desired album in the browser, copy the URL from the browser's navigation bar and paste it into the menu item's URL field instead of {mGallery2}.

User and Group Synchronization

mGallery2 can synchronize users and groups between Postnuke and Gallery2 in several ways. The first time a logged-in user clicks on your Gallery2 link, a new user will be created in Gallery2 and mapped to that Postnuke userid. If you want all of your users to have Gallery2 userid mappings, you can do it manually through the module's administration menu or you can set up automatic user and group synchronization. If you want to get user automatic synchronization working, you must modify two core Postnuke files to enable the mGallery hooks to work correctly. To do so:

  1. Make a copy of the core file modules/User/admin.php

  2. Copy User/admin.php into modules/User

  3. Make a copy of the core file modules/Groups/pnadminapi.php

  4. Copy Groups/pnadminapi.php into modules/Groups

  5. Go to your Postnuke Administration Panel

  6. Click on the system tab if you're not there already

  7. Click on the Modules icon

  8. Find the User module

    Tip

    Click on the U link above the modules table to make it easier to find

  9. Click on the Hooks action for the module

  10. Check the checkbox next to Activate mgallery2 for this module

  11. Click the Update button

  12. Find the Groups module

    Tip

    Click on the G link above the modules table to make it easier to find

  13. Click on the Hooks action for the module

  14. Check the checkbox next to Activate mgallery2 for this module

  15. Click the Update button

For small sites, automatic synchronization isn't necessary as users will be created when they enter the gallery, but for large or high-traffic sites, on-the-fly creation could cause some overhead. Automatic synchronization creates and deletes the user or group using hooks on the appropriate module, so the changes happen in Gallery2 at the same time the changes happen in Postnuke.

Note

From thaughbear - The user/group synchronization uses PostNuke as the master and G2 as the slave. It works exactly as I want it to work. My PostNuke and Gallery2 users are both called Admin and these are the only admin users. If you want it to work any other way submit a feature request which I may or may not implement.

Chapter 2. mGallery2 Blocks

There are three types of blocks in mGallery2. Two of them are used to display images and one is used to move the Gallery2 sidebar out of the embedded gallery and into Postnuke's block system. The block names are:

  • mGallery2/Random - Show a random image

  • mGallery2/Specific - Show a specific image

  • mGallery2/Sidebar - Show the Gallery2 sidebar

The Random and specific blocks are both used to show an image (or images) in a block. In future versions, these blocks will be combined into one block that can perform both functions, as well as many others (recent images, most viewed image, etc.

Random Block

The random block is a sidebar (or center) block that has the ability to display an image or several images in your theme's block content. It is a standard Postnuke block that can be added through the Blocks administration menu. To add a block:

  1. Go to your Postnuke administration panel

  2. Click on the system tab if you're not already there

  3. Click on the Bocks icon

  4. Click on the New Block link in the Blocks Administration link menu

  5. The standard block options configuration screen will appear

  6. In the Title field, name the block anything you want - e.g. - Random Image

  7. Select mGallery2/Random from the Block dropdown field

  8. Select whichever position you want from the Position dropdown

    Note

    Your theme must support blocks for whichever position you select. If the theme doesn't have right blocks and you select the right position, the block will not display unless you edit your theme to support the right block or choose a supported position.

  9. Select whether or not you want the Block to be Collapsible. If the theme template supports it, this will show a clickable icon in the corner of the block that will allow the user to collapse the block. This defaults to Yes.

  10. Select the Default State for the block

  11. Select the Language of the block. The current translations are en-US and deu

  12. Click the Update button

  13. Now you will see specific options for the mGallery2/Random block

  14. Show Title will display the title of the image in the block, if selected.

  15. Show Owner will display the owner of the image in the block, if selected

  16. Show Views will show the number of views in the block, if selected

  17. Show Date will show the EXIF date of the image in the block, if selected

  18. The Number of Images field determines how many images will be displayed in the block. There is no maximum, so put something sane in the field.

  19. The Maximum Image Size (width) field will determine the maximum size, in pixels, of the image in the block

  20. Select a frame for album objects in the Album Frame dropdown box

  21. Select a frame for image objects in the Image Frame dropdown box

  22. The last option is another standard Postnuke block option that really isn't relevant to the mGallery2. Just leave the Refresh time for block setting at its default One hour setting

  23. Once again, click the Update button

The block is now available. If you put it in a position that can be seen from the administration template, you should see it now. Otherwise, go to home page or another page with block support for the position you chose. You should now see your block.

Note

Using the Maximum Size parameter and square frames (Gallery 2.2.1+) you can create a grid of images in your block. Set the number of images to four and experiment with the Maximum size parameter until two images fit on a row. The square frame is necesary to keep the width uniform.

Specific Block

The specific block is a holdover from the original mGallery2 source and has not been touched since it was written. It allows you to show a specific image in a block, but no options are enabled for it. The block is hard-coded to display the title and the date of the image. This block uses the image path instead of the image id when specifying an image. The best way to find the image path is to go the image within Gallery2 and click Edit Photo. The path will be displayed on the General tab under the Name section. To add a specific image block:

  1. Go to your Postnuke administration panel

  2. Click on the system tab if you're not already there

  3. Click on the Bocks icon

  4. Click on the New Block link in the Blocks Administration link menu

  5. The standard block options configuration screen will appear

  6. In the Title field, name the block anything you want - e.g. - Dragon

  7. Select mGallery2/Specific from the Block dropdown field

  8. Select whichever position you want from the Position dropdown

    Note

    Your theme must support blocks for whichever position you select. If the theme doesn't have right blocks and you select the right position, the block will not display unless you edit your theme to support the right block or choose a supported position.

  9. Select whether or not you want the Block to be Collapsible. If the theme template supports it, this will show a clickable icon in the corner of the block that will allow the user to collapse the block. This defaults to Yes.

  10. Select the Default State for the block

  11. Select the Language of the block. The current translations are en-US and deu

  12. Click the Update button

  13. Now you will see specific options for the mGallery2/Specific block

  14. Type in the image's path in the Image path field, for instance /album1/dragon.jpg

  15. The last option is another standard Postnuke block option that really isn't relevant to the mGallery2. Just leave the Refresh time for block setting at its default One hour setting

  16. Once again, click the Update button

The block is now available. If you put it in a position that can be seen from the administration template, you should see it now. Otherwise, go to the home page or another page with block support for the position you chose. You should now see your block.

This block and the Random block will evenually be integrated into a multi-block that can generate different types of blocks with all of the options enabled.

Sidebar Block

The Sidebar block, unlike the Random and Specific block, does not display images on your site. Instead, it is designed to take the embedded Gallery2 sidebar out of the modules's image display area and embed it into a block. The Gallery2 sidebar is a collection of links that allow administrators to manage images and albums and also lets regular users search the gallery, print photos to online printing companies, and view slideshows, among other things. The sidebar will only show when the mGallery2 module is active and it will only have content if the Sidebar Block setting is selected in mGallery2's administrative settings. If this setting is not selected, the title bar will show, but the block will be empty and the sidebar will be display within the embedded gallery page. To install:

  1. Go to your Postnuke administration panel

  2. Click on the system tab if you're not already there

  3. Click on the Bocks icon

  4. Click on the New Block link in the Blocks Administration link menu

  5. The standard block options configuration screen will appear

  6. In the Title field, name the block anything you want - e.g. - G2 Sidebar

  7. Select mGallery2/Sidebar from the Block dropdown field

  8. Select whichever position you want from the Position dropdown

    Note

    Your theme must support blocks for whichever position you select. If the theme doesn't have right blocks and you select the right position, the block will not display unless you edit your theme to support the right block or choose a supported position.

  9. Select whether or not you want the Block to be Collapsible. If the theme template supports it, this will show a clickable icon in the corner of the block that will allow the user to collapse the block. This defaults to Yes.

  10. Select the Default State for the block

  11. Select the Language of the block. The current translations are en-US and deu

  12. Click the Update button

  13. There are no specific options for the mGallery2/Sidebar block

  14. The last option is another standard Postnuke block option that really isn't relevant to the mGallery2. Just leave the Refresh time for block setting at its default One hour setting

  15. Once again, click the Update button.

The block is now available. If you put it in a position that can be seen from the administration template, you should see it now. Otherwise, go to the home page or another page with block support for the position you chose. You should now see your block.

Hopefully. I'll have some time to experiment with styling the block in the future. The contents of the block can be customized within the Gallery2 Site Admin. Just edit the G2 theme and pick the items you want in the sidebar.

Chapter 3. The Transform Hook

The mGallery2 transform hook is a tag-based transform hook similar to pn_bbcode. It uses tags that begin with [mg2 to insert gallery images into your site. When the transform hook encounters a tag, it replaces it inline with the HTML of an image block. The tag can be very simple, pointing to a single image, or complex, rendering multiple random images from a specific gallery.

Activating the transform hook

The transform hook can be activated for any module. Since the hook inserts html that will display an image, you should only activate this hook for modules that display something, such as News. To activate the hook for a module, follow these steps:

  1. Go to your Postnuke Administration Panel

  2. Click on the system tab if you're not there already

  3. Click on the Modules icon

  4. Find the module you would like to hook

    Tip

    Use the alphabet links above the modules table to make it easier to find your module

  5. Click on the Hooks action for the module

  6. Check the checkbox next to Activate mgallery2 for this module

  7. Click the Update button

To test the hook, go to the module you've hooked and add some content with an mGallery2 trasform hook tag. See the next sections below for more information on the syntax and options.

Postnuke HTML Options

In order for the images to display correctly within the News module, or any other module, you will need to edit your HTML Options in Postnuke's general site settings. The following HTML options must be Allowed with attributes.

  • <div>

  • <h4> - this is used by the image title caption

  • <p> - this is used by the owner and date captions

General tag syntax

The mGallery2 transform hook tag, in its most basic form is the prefix mg2, followed by a colon, followed by an image or album id. The tag is enclosed in brackets like so:

[mg2:imageId]

This example inserts a block of HTML that is returned from the Gallery2 Image Block module and inserts it inline into your content. There are many options in the Image Block module and the transform hook tries to take advantage of them all. the next section will discuss the options and give examples of their use

Transform Hook Options

The hook supports the following imageblock options:

itemID - The album or image id

This parameter is not specified in the tag. It follows the prefix (mg2:) and consists of an integer that is a valid image or album id in Gallery2.

[mg2:21]

This example will show the image with the gallery image id of 21. If it is an album, it will show the album highlight. Without arguments, this will show the image using the defaults defined in the mGallery2

show - How to show the image

This parameter takes a pipe-delimited list of options that determine what will be shown with the image. Options include title, owner, date, views, and fullSize. None of these options is required. The options will be described below after the example.

[mg2:41 show=owner|date]

This example will show the image with owner and date information pulled from Gallery2

title - The title of the image

This show option adds a caption to the image. The caption cannot be specified. It will read the title from Gallery2.

[mg2:11 show=title]

owner - The owner of the image

This show option adds a caption to the image with the image owner's name.

[mg2:10 show=owner]

date - The date information from the image

This show option adds a caption to the image with the image's date information.

[mg:22 show=date]

fullSize - Show the image fullSize

Normally, the imageblock plugin, which the transform hook utilizes, returns the thumbnail for an image, but this show option tells Gallery2 to return a full-sized image. The size of the image can be controlled with the maxSize option.

[mg2:2 show=fullSize]

views - Show the number of views

This show option adds a caption to the image with the number of views the image has set. This number is determined by Gallery2.

[mg2:445 show=views]

maxsize - Maximum size of a full-sized image

This parameter sets the maximum size in pixels of the longest side of the image. If it is used in conjunction with show=fullSize it will limit the size of the full-sized images returned. Without the show=fullSize option, it will limit the size of thumbnails.

[mg2:37 show=fullSize|views|owner|title maxSize=800]

This example renders a full-sized image with a maximum height or width of 800 pixels. It also includes captions with owner, title, and views.

[mg2:22 maxSize=50]

This example limits the height or width of the thumbnail image to 50 pixels.

type - The type of imageblock to show

This parameter determines the type of imageblock to show. The possible options are specificImage, randomImage, dailyImage, weeklyImage, monthlyImage, dailyAlbum, weeklyAlbum, monthlyAlbum, viewedImage, randomAlbum, recentAlbum, viewedAlbum. Only one option is permitted.

specificImage - Show a specific image

This block type shows a specific image by image id. This is the default block type.

[mg2:22 type=specificImage]

This example shows the image with an id of 22.

[mg2:22]

Since specificImage is the default option, this also shows the image with an id of 22.

randomImage - Show a random image

This block type will show a random image from the album specified in the album id. To choose an image from the entire gallery, specify the root gallery or an d of 0.

[mg2:47 type=randomImage]

This example will show a random image from the album with an id of 47.

[mg2:0 type=randomImage]

This example will show a random image from the entire gallery

dailyImage - Show the daily image

This block type will show the daily image that is determined by Gallery2. This image changes daily. Use an itemId of 0 for this type.

[mg2:0 type=dailyImage]

weeklyImage - Show the weekly image

This block type will show the weekly image that is determined by Gallery2. This image changes weekly. Use an itemId of 0 for this type.

[mg2:0 type=weeklyImage]

monthlyImage - Show the monthly image

This block type will show the monthly image that is determined by Gallery2. This image changes monthly. Use an itemId of 0 for this type.

[mg2:0 type=monthlyImage]

dailyAlbum - Show the daily album

This block type will show the highlighted photo of the daily album that is determined by Gallery2. This album changes daily.

[mg2:0 type=dailyAlbum]

weeklyAlbum - Show the weekly album

This block type will show the highlighted photo of the weekly album that is determined by Gallery2. This album changes weekly.

[mg2:0 type=weeklyAlbum]

monthlyAlbum - Show the monthly album

This block type will show the highlighted photo of the monthly album that is determined by Gallery2. This album changes monthly.

[mg2:0 type=monthlyAlbum]

viewedImage - Show the most viewed image

This block type will show the most viewed image from an album identified by itemId. An itemID of 0 will choose from the entire gallery.

[mg2:24 type=viewdImage]

This example will show the most viewed image from the album with an id of 24

[mg2:0 type-viewedImage]

This example will show the most viewed image in the gallery.

randomAlbum - Show a random album

This block type will show the highlighted photo from a random album from the gallery.

[mg2:0 type=randomAlbum]

recentAlbum - Show the most recent album

This block type will show the highlighted photo from the most recent album in the gallery.

[mg2:0 type=recentAlbum]

viewedAlbum - Show the most viewed album

This block type will show the highlighted photo from the most viewed album in the gallery.

[mg2:0 type=viewedAlbum]

aframe - Album Frame

This parameter selects a frame from the imageframe module that will be displayed around albums.

[mg2:22 aframe=dots]

This example will display the dots frame around the highlighted photo from the album with an id of 22. If 22 is an image, it will use the default item frame from the module's settings. To view the different frames, click on the frame samples page in mGallery2's module settings.

iframe - Image Frame

This parameter selects a frame from the imageframe module that will be displayed around images.

[mg2:4 iframe=shadow]

This example will display the shadow frame around the image with an id of 4. If 22 is an abum, it will use the default album frame from the module's settings. To view the different frames, click on the frame samples page in mGallery2's module settings.

frame - Image and Album Frame

This parameter can be used in place of the iframe and aframe parameters to specify thhttpe frame for albums and images.

[mg2:0 frame=gold type=randomAlbum]

This example will display the gold frame around the random album chosen by Gallery2 from the entire gallery.

[mg2:0 frame=flicking type=viewedImage]

This example will display the flicking frame around the most viewed image in the gallery.

class - CSS class

This parameter selects the class that will be applied to the imageblock's div. The options for this parameter are a list of predefined divs:

  • left - float left

  • right - float right

  • center/centre - center the image

  • normal - no styling

[mg2:44 class=left show=owner|date|title]

This example will display the image with an id of 44 and float the block left. The block will have owner, date, and title captions.

n - Number of images

This parameter specifies the number of images to display. There is no sanity checking on this parameter, so if you specify 100 images, you will get 100 images. Be warned! f you specify the n parameter for a specificImage type, only one instance of the image will be displayed.

[mg2:12 type=randomImage n=3 class=center]

This example will display three random images from the album with an id of 12 and center the images. Without captions, the images will display inline.

[mg2:12 type=randomImage n=3 class=center show=title]

This example will display three random images from the album with an id of 12 and center the images. Since this example includes a title caption, the images will display vertically.

itemId and block types

All mg2 tags must specify an itemId. This itemId can refer to an image ID or an album ID. Image IDs are only used when the specificImage block type is selected. All other blocks use an album ID. If you try to use an image id with an album-type image block, mGallery2 will return an error instead of an image.

Escaping mg2 tags

If you want to put mg2 tags somewhere in your site without having them processed (e.g. - a tutorial) just begin the tag with a doble bracket.

[[mg2:12 type=randomImage]

Chapter 4. Using g2Image with mGallery2 and Scribite

G2Image is a TimyMCE plugin that adds an icon to the TinyMCE toolbar. The plugin allows a user to choose an image from a Gallery2 installation by browsing thumbnails. In this document, it will be set up to insert tags which will be transformed by the mGallery2 transform hook into image blocks. This chapter describes the steps that need to be taken to get g2Image working with TinyMCE within Scribite.

Requirements

To get this combination working, you will need several components installed and working:

You can find documentation to install each of these components at their respective web sites or within the downloaded archive. The installaton and configuration of G2Image will be described below.

Install and configure g2image files

The G2Image download archive contains two folders. The first is tinymce_plugin, which is the one we're interested in. The second is wordpress_plugin, which we will ignore. Inside the tinymce_plugin folder is another folder, g2image. This is the folder we will be working with. To install:

  1. Copy the g2image folder into your modules/scribite/pnincludes/tiny_mce/plugins folder

  2. Open the g2image folder

  3. Open the config.php file

  4. Go to line 56, which should read:

    $g2ic_default_alignment = 'none';
  5. Change the word none to left

  6. Go to line 63. There should be four lines here defining custom classes. All of them should be set to unused, like the one below:

    $g2ic_custom_class_1 = 'not_used';
  7. Edit each of the four lines to define the following custom classes:

    $g2ic_custom_class_1 = 'left';
    $g2ic_custom_class_2 = 'right';
    $g2ic_custom_class_3 = 'center';
    $g2ic_custom_class_4 = 'centre';
  8. Go to line 98, which should read:

    $g2ic_default_action = 'thumbnail_image';
  9. Edit the line to read:

    $g2ic_default_action = 'drupal_g2_filter';
  10. Go to line 121, which should read:

    $g2ic_embedded_mode = FALSE;
  11. Change the value to TRUE

  12. Go to line 143, which should read:

    $g2ic_gallery2_uri = 'http://www.domain.com/gallery2/main.php';
  13. Change the value to your your Gallery2 URI, including the main.php at the end

  14. Go to line 159, which should read:

    $g2ic_drupal_g2_filter = FALSE;
  15. Change the value to TRUE

  16. Go to line 163, which should read:

    $g2ic_drupal_g2_filter_prefix = G2;
  17. Change the value from G2 to mg2

  18. Save the file

Because the Scribite module includes a version of TinyMCE with a version number greater than 2.03, you need to copy the files in the g2image/TinyMCE_version_2.0.3_files folder up to the g2image folder, overwriting the ones that are there.

g2Image and OpenBasedir

If you or your provider have activated the open_basedir restriction in PHP, G2Image will work, but you will see lots of errors. The G2Image code, as downloaded, tries to figure out if it is in a WordPress installation by searching for wp-config.php somewhere in the directory tree from its current location. As it climbs up the tree, it eventually tries to leave the web root and generates these errors. You can get rid of this functionality by editing the file modules/scribite/pnincludes/tiny_mce/plugins/g2image/init.php. There is a section in the code labeled WPG2 Validation. This section needs to be removed. simply delete lines 23 through 137 in the file.

Updating Scribite

Before enabling the plugin in Scribite, Scribite needs to know where to add the plugin's icon to the TinyMCE toolbar. This requires more editing:

  1. Open the file modules/scribite/pntemplates/tinymce_editorheader.htm

  2. Go to line 44, which should read:

    theme_advanced_buttons3_add : "emotions,iespell,media,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
  3. Add g2image at the end of the list, like this:

    theme_advanced_buttons3_add : "emotions,iespell,media,advhr,separator,print,separator,ltr,rtl,separator,fullscreen,g2image",
  4. Save the file

Now that scribite knows how to add the icon to the plugin, you must enable the plgin within Scribite. To do so:

  1. Go to your Postnuke Administration Panel

  2. Click on the 3rd party tab

  3. Click on the Scribite icon

  4. Click on the tiny_mce settings tab

  5. Find g2image in the tiny_mce Plugins section

  6. Check the checkbox for g2image

  7. Click Save Configuration

To test, add a story in your News module. You should see the g2image icon on the right side of the lowest toolbar in TinyMCE. The screenshot below shows TinyMCE with the G2image icon.

Chapter 5. Support

mGallery2 is registered as a project in the NOC. Please use the NOC for all support requests.