
<?php
/**
* ImageBlock
* Gallery2 Image Block for MODx
*
* Shows randomImage, recentImage, viewedImage, randomAlbum, recentAlbum, viewedAlbum, dailyImage, weeklyImage, monthlyImage, dailyAlbum, weeklyAlbum, monthlyAlbum, specificItem.
*
* Depend on the gallery module
* Version: 1.1
*
* You have to call it uncached : [!ImageBlock!]
* or for example , add option [!ImageBlock? &pageid=`5`&blocks=`recentImage`&show=`title|date|views`!]
* default parameter is set to $pageid="-1" , $blocks="randomImage",$show="title|date"
* pageid is default set to "-1". it means link to gallery2 directly.
*
* Parameter (for the getImageBlock line 42):
* 'blocks': List composed with the following items : randomImage, recentImage, viewedImage, randomAlbum, recentAlbum, viewedAlbum, dailyImage, weeklyImage, monthlyImage, dailyAlbum, weeklyAlbum, monthlyAlbum, specificItem ; Separate items with pipes (|) (except specificItem); default value is randomImage
* 'show': List composed with the following items : title, date, views, owner, heading, fullSize ; Separate items with pipes (|) ; the value can be : none (in this case you'll just have the image showing)
* 'itemId': Limit the selection to a specific item ;
* 'maxSize': Max siez of the image (by default it shows thumbnails)
**/
# build mod path
$modpath = $modx->config["base_path"].($mpth ? $mpth:"assets/modules/gallery/");
# include main class
include_once $modpath."g2cms.base.class.inc.php";
$gb = new G2CMS_Base();
require_once($gb->g2Path.'embed.php');
//Parameter
//Gallery2 Embeded page id ( snipet)
$pageid = isset($pageid)? $pageid : '-1'; // if you want to link to gallery2 directly , must be set "-1".
//blocks
$blocks = isset($blocks)? $blocks : 'recentImage';
//show
$show = isset($show)? $show : 'title';
//itemId
$itemId = isset($itemId)? $itemId : null;
if ( $pageid == "-1"){
$uri=$gb->g2Uri; // link to gallery2 directly
}
else{
$uri=$modx->makeUrl($pageid); // link to embeded page
}
$ret = GalleryEmbed::init(array(
'embedUri' => $uri,
'g2Uri' => $gb->g2Uri,
'fullInit' => true
));
if ($ret) {
echo $ret->getAsHtml();
}
if($blocks =="specificItem"){
list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => "$blocks", 'show' => "$show",'itemId' => "$itemId"));
}
else{
list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => "$blocks", 'show' => "$show"));
}
if ($ret) {
echo $ret->getAsHtml();
}
list($title, $css, $javascript) = GalleryEmbed::parseHead($headHtml);
$header = '';
foreach($css as $c) $modx->regClientCSS($c);
foreach($javascript as $j) $modx->regClientStartupScript($j);
/* Shows the image block. */
print $bodyHtml;
?>Warning: G2CMS_Admin::require_once() [function.G2CMS-Admin-require-once]: open_basedir restriction in effect. File(/embed.php) is not within the allowed path(s): (/home/jackal/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/jackal/public_html/shtuck/assets/modules/gallery/g2cms.admin.class.inc.php on line 24 Warning: G2CMS_Admin::require_once(/embed.php) [function.G2CMS-Admin-require-once]: failed to open stream: Operation not permitted in /home/jackal/public_html/shtuck/assets/modules/gallery/g2cms.admin.class.inc.php on line 24 Fatal error: G2CMS_Admin::require_once() [function.require]: Failed opening required '/embed.php' (include_path='/home/jackal/public_html/shtuck/manager/includes/') in /home/jackal/public_html/shtuck/assets/modules/gallery/g2cms.admin.class.inc.php on line 24

Hi vega2000
Please show me your setting of gallery2 modules ..
.....
// if we have an item id, we set it
// either from Gallery Album drop down, or whatever else that might be passed.
// so if either is set, and if doesn't already have one. added by Brenton Bartel
if (isset($g2_itemId) && !GalleryUtilities::hasRequestVariable('itemId')) {
GalleryUtilities::putRequestVariable('itemId', $g2_itemId);
}
<?php
/**
* This is probably the ugliest work around, but this is the only way I could figure out to
* get it all to work.
* For the Template Variable, do something like this:
*
* @EVAL include_once('/abs_path/assets/modules/gallery/tv_albums.php'); return getAlbums
ForTemplateVariable();
*
* Where it's all on 1 line, and the include_once is absolute path to this file.
*/
function getAlbumsForTemplateVariable() {
GLOBAL $modx;
# build mod path
//$modpath = $modx->config["base_path"].($mpth ? $mpth:"assets/modules/gallery/");
$modpath = dirname(__FILE__);
# include main class
include_once $modpath."/g2cms.base.class.inc.php";
$gb = new G2CMS_Base();
$uname = $modx->getLoginUserName();
//require_once($gb->g2Path.'embed.php');
require_once('/abs_path/gallery2/embed.php');
$ret = GalleryEmbed::init(array(
'embedUri' => $gb->embedUri,
'g2Uri' => $gb->g2Uri,
'activeUserId' => $uname,
));
$albumIds = array();
/* Get ids of all all albums where we can add new album items */
list ($ret, $albumIds) = GalleryCoreApi::fetchAllItemIds('GalleryAlbumItem');
if ($ret) {
// return array($ret->wrap(__FILE__, __LINE__), null);
}
/* Load all the album entities */
list ($ret, $albums) = GalleryCoreApi::loadEntitiesById($albumIds);
if ($ret) {
// return array($ret->wrap(__FILE__, __LINE__), null);
}
$albumTree = GalleryUtilities::createAlbumTree($albums);
$ret_val = '';
$comma = '';
// have everything we need, now need to create the dropdown code.
foreach ($albumTree AS $album) {
$ret_val .= $comma .' ';
for ($d = 0; $d < $album['depth']; $d++) {
$ret_val .= '--';
}
if ($album['data']['title'] != '') {
$ret_val .= ' '. $album['data']['title'];
}
else {
$ret_val .= ' '. $album['data']['pathComponent'];
}
$ret_val .= '=='. $album['data']['id'];
$comma = '||';
}
return $ret_val;
}
?>
[[Gallery? &g2_itemId=`[*TV_Name*]`]]
Error (ERROR_MISSING_OBJECT) : admin GalleryUser
* in modules/core/classes/helpers/GalleryEntityHelper_simple.class at line 142 (GalleryCoreApi::error)
* in modules/core/classes/GalleryCoreApi.class at line 2424 (GalleryEntityHelper_simple::loadEntityByExternalId)
* in modules/core/classes/GalleryEmbed.class at line 227 (GalleryCoreApi::loadEntityByExternalId)
* in modules/core/classes/GalleryEmbed.class at line 131 (GalleryEmbed::checkActiveUser)
* in /home/voguebis/public_html/assets/modules/gallery/g2cms.admin.class.inc.php at line 33 (GalleryEmbed::init)
* in /home/voguebis/public_html/manager/processors/execute_module.processor.php(98) : eval()’d code at line 28 (G2CMS_Admin::execute)
* in /home/voguebis/public_html/manager/processors/execute_module.processor.php at line 98
* in /home/voguebis/public_html/manager/processors/execute_module.processor.php at line 85
* in /home/voguebis/public_html/manager/index.php at line 543
can this module work with gallery 2.2.1?
I get a error that he can’t find embed.php, I did try relative and absolute paths.
<?php
/**
* ImageBlock
* Gallery2 Image Block for MODx
*
* Shows randomImage, recentImage, viewedImage, randomAlbum, recentAlbum, viewedAlbum, dailyImage, weeklyImage, monthlyImage, dailyAlbum, weeklyAlbum, monthlyAlbum, specificItem.
*
* Depend on the gallery module
* Version: 1.1
*
* You have to call it uncached : [!ImageBlock!]
* or for example , add option [!ImageBlock? &pageid=`5`&blocks=`recentImage`&show=`title|date|views`!]
* default parameter is set to $pageid="-1" , $blocks="randomImage",$show="title|date"
* pageid is default set to "-1". it means link to gallery2 directly.
*
* Parameter (for the getImageBlock line 42):
* 'blocks': List composed with the following items : randomImage, recentImage, viewedImage, randomAlbum, recentAlbum, viewedAlbum, dailyImage, weeklyImage, monthlyImage, dailyAlbum, weeklyAlbum, monthlyAlbum, specificItem ; Separate items with pipes (|) (except specificItem); default value is randomImage
* 'show': List composed with the following items : title, date, views, owner, heading, fullSize ; Separate items with pipes (|) ; the value can be : none (in this case you'll just have the image showing)
* 'itemId': Limit the selection to a specific item ;
* 'maxSize': Max siez of the image (by default it shows thumbnails)
**/
# build mod path
$modpath = $modx->config["base_path"].($mpth ? $mpth:"assets/modules/gallery/");
# include main class
include_once $modpath."g2cms.base.class.inc.php";
$gb = new G2CMS_Base();
require_once($gb->g2Path.'embed.php');
//Parameter
//Gallery2 Embeded page id ( snipet)
$pageid = isset($pageid)? $pageid : '-1'; // if you want to link to gallery2 directly , must be set "-1".
//blocks
$blocks = isset($blocks)? $blocks : 'recentImage';
//show
$show = isset($show)? $show : 'title|date';
//itemId
$itemId = isset($itemId)? $itemId : null;
//maxSize
$maxSize = isset($maxSize)? $maxSize : 150;
if ( $pageid == "-1"){
$uri=$gb->g2Uri; // link to gallery2 directly
}
else{
$uri=$modx->makeUrl($pageid); // link to embeded page
}
$ret = GalleryEmbed::init(array(
'embedUri' => $uri,
'g2Uri' => $gb->g2Uri,
'fullInit' => true,
));
if ($ret) {
echo $ret->getAsHtml();
}
if($blocks == "specificItem"){
list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => "$blocks", 'show' => "$show",'itemId' => "$itemId", 'maxSize' => "$maxSize"));
}
else{
list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => "$blocks", 'show' => "$show", 'maxSize' => "$maxSize"));
}
if ($ret) {
echo $ret->getAsHtml();
}
list($title, $css, $javascript) = GalleryEmbed::parseHead($headHtml);
foreach($css as $c) $modx->regClientCSS($c);
foreach($javascript as $j) $modx->regClientStartupScript($j);
$ret = GalleryEmbed::done();
if ($ret) {
echo $ret->getAsHtml();
}
$bodyHtml=str_replace('<a href',$header.'<a target="_blank" href',$bodyHtml);
/* Shows the image block. */
print $bodyHtml;
?>[!ImageBlock? &pageid=`120` &maxSize=`90` &show=`none` &blocks=`recentImage|recentImage|recentImage|recentImage`!]