Commit 030f6937 authored by profix898's avatar profix898
Browse files

- update D6 version (Oct-15, 2007)

parent dccc293a
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
function g2ic_open(field) { function g2ic_open(field) {
// Set some properties // Set some properties
var form = $('#'+field).parents('form').attr('id'); var form = $('#'+field).parents('form').attr('id');
var url = Drupal.settings.gallery2.g2image_uri+'g2image.php?g2ic_form='+form+'&g2ic_field='+field+'&g2ic_tinymce=0'; var url = Drupal.settings.gallery.g2image_uri+'g2image.php?g2ic_form='+form+'&g2ic_field='+field+'&g2ic_tinymce=0';
var name = 'g2image'; var name = 'g2image';
var w = 600; var w = 600;
var h = 600; var h = 600;
......
...@@ -37,8 +37,20 @@ function gallery_theme() { ...@@ -37,8 +37,20 @@ function gallery_theme() {
'gallery_severity_status_message' => array( 'gallery_severity_status_message' => array(
'arguments' => array('severity' => NULL, 'status' => NULL, 'full_msg' => FALSE, 'invert' => FALSE), 'arguments' => array('severity' => NULL, 'status' => NULL, 'full_msg' => FALSE, 'invert' => FALSE),
), ),
'gallery_g2image_textarea_link' => array(
'arguments' => array('element' => NULL, 'link' => NULL),
),
'gallery_report' => array( 'gallery_report' => array(
'arguments' => array('report' => FALSE), 'arguments' => array('report' => FALSE),
),
'gallery_block_image_block' => array(
'arguments' => array('content' => NULL, 'class' => NULL),
),
'gallery_block_grid_block' => array(
'arguments' => array('images' => NULL, 'num_cols' => NULL, 'class' => NULL),
),
'gallery_search_item' => array(
'arguments' => array('item' => NULL),
) )
); );
} }
...@@ -52,7 +64,7 @@ function gallery_init() { ...@@ -52,7 +64,7 @@ function gallery_init() {
drupal_add_css(drupal_get_path('module', 'gallery') .'/gallery.css'); drupal_add_css(drupal_get_path('module', 'gallery') .'/gallery.css');
drupal_add_css(drupal_get_path('module', 'gallery') .'/gallery_filter.css'); drupal_add_css(drupal_get_path('module', 'gallery') .'/gallery_filter.css');
// Switch theme for gallery pages // Switch theme for gallery pages
if (arg(0) == 'gallery' && (($theme = variable_get('gallery_page_theme', NULL)) != 'default')) { if (arg(0) == variable_get('gallery_base', 'gallery') && (($theme = variable_get('gallery_page_theme', NULL)) != 'default')) {
$custom_theme = $theme; $custom_theme = $theme;
init_theme(); init_theme();
} }
...@@ -65,7 +77,7 @@ function gallery_menu() { ...@@ -65,7 +77,7 @@ function gallery_menu() {
$items = array(); $items = array();
$gallery_valid = variable_get('gallery_valid', 0); $gallery_valid = variable_get('gallery_valid', 0);
if ($gallery_valid) { if ($gallery_valid) {
$items['gallery'] = array( $items[variable_get('gallery_base', 'gallery')] = array(
'title' => 'Gallery', 'title' => 'Gallery',
'description' => 'Visit your embedded Gallery2.', 'description' => 'Visit your embedded Gallery2.',
'access callback' => 'user_access', 'access callback' => 'user_access',
...@@ -373,7 +385,7 @@ function gallery_block($op = 'list', $delta = 0, $edit = array()) { ...@@ -373,7 +385,7 @@ function gallery_block($op = 'list', $delta = 0, $edit = array()) {
* (main gallery display page) * (main gallery display page)
*/ */
function gallery_page() { function gallery_page() {
if (!_gallery_init(FALSE)) { if (!_gallery_init()) {
return ''; return '';
} }
// Turn off sidebar // Turn off sidebar
...@@ -423,7 +435,7 @@ function gallery_page() { ...@@ -423,7 +435,7 @@ function gallery_page() {
} }
} }
// Store the sidebar info in a global variable for use in the gallery navigation block // Store the sidebar info in a global variable for use in the gallery navigation block
$GLOBALS['_gallery_sidebar_'] = $result['sidebarBlocksHtml']; $GLOBALS['gallery_sidebar'] = $result['sidebarBlocksHtml'];
return $result['bodyHtml']; return $result['bodyHtml'];
} }
......
...@@ -188,12 +188,10 @@ function gallery_get_image_frames() { ...@@ -188,12 +188,10 @@ function gallery_get_image_frames() {
* Function gallery_generate_url(). * Function gallery_generate_url().
*/ */
function gallery_generate_url($params, $html = TRUE, $full = TRUE) { function gallery_generate_url($params, $html = TRUE, $full = TRUE) {
if (!isset($GLOBALS['gallery'])) { if (!_gallery_init()) {
if (!_gallery_init()) { return '';
return '';
}
} }
// Get URL generator and generate the url
$url_generator =& $GLOBALS['gallery']->getUrlGenerator(); $url_generator =& $GLOBALS['gallery']->getUrlGenerator();
if (!$url_generator) { if (!$url_generator) {
gallery_error(t('Error: UrlGenerator not available')); gallery_error(t('Error: UrlGenerator not available'));
...@@ -215,7 +213,7 @@ function gallery_generate_url($params, $html = TRUE, $full = TRUE) { ...@@ -215,7 +213,7 @@ function gallery_generate_url($params, $html = TRUE, $full = TRUE) {
* Function gallery_album_tree(). * Function gallery_album_tree().
*/ */
function gallery_album_tree($root = NULL, $depth = NULL, $uid = NULL) { function gallery_album_tree($root = NULL, $depth = NULL, $uid = NULL) {
if (!_gallery_init()) { if (!_gallery_init(TRUE)) {
return array(); return array();
} }
// If this is called for the Drupal guest user, pass in G2 // If this is called for the Drupal guest user, pass in G2
...@@ -242,6 +240,9 @@ function gallery_album_tree($root = NULL, $depth = NULL, $uid = NULL) { ...@@ -242,6 +240,9 @@ function gallery_album_tree($root = NULL, $depth = NULL, $uid = NULL) {
*/ */
function gallery_item_details($id, $verbose = FALSE) { function gallery_item_details($id, $verbose = FALSE) {
$details = array(); $details = array();
if (!_gallery_init(TRUE)) {
return $details;
}
// Load entity // Load entity
list($ret, $entity) = GalleryCoreApi::loadEntitiesById($id); list($ret, $entity) = GalleryCoreApi::loadEntitiesById($id);
if ($ret) { if ($ret) {
...@@ -250,32 +251,50 @@ function gallery_item_details($id, $verbose = FALSE) { ...@@ -250,32 +251,50 @@ function gallery_item_details($id, $verbose = FALSE) {
return $details; return $details;
} }
// Extract details // Extract details
$details['g2id'] = $id;
$details['g2type'] = $entity->entityType; $details['g2type'] = $entity->entityType;
$details['g2owner'] = $entity->ownerId; $details['g2owner'] = $entity->ownerId;
$details['g2parent'] = $entity->parentId; $details['g2parent'] = $entity->parentId;
// Drupal node properties (no g2 prefix) // Drupal node properties (no g2 prefix)
$details['title'] = _gallery_htmlcharsdecode($entity->title); $details['title'] = _gallery_htmlcharsdecode($entity->title);
$details['created'] = $entity->creationTimestamp; $details['created'] = $entity->creationTimestamp;
$details['changed'] = $entity->modificationTimestamp;
if ($verbose) { if ($verbose) {
$details['g2description'] = _gallery_htmlcharsdecode($entity->description); $details['g2description'] = _gallery_htmlcharsdecode($entity->description);
$details['g2summary'] = _gallery_htmlcharsdecode($entity->summary); $details['g2summary'] = _gallery_htmlcharsdecode($entity->summary);
$details['g2keywords'] = $entity->keywords; $details['g2keywords'] = $entity->keywords;
$details['g2theme'] = $entity->theme; $details['g2theme'] = isset($entity->theme) ? $entity->theme : NULL;
} }
return $details; return $details;
} }
/**
* Function gallery_item_access().
*/
function gallery_item_access($id, $permission = 'core.view', $user = NULL) {
if (!_gallery_init(TRUE)) {
return FALSE;
}
// Check access permissions
list($ret, $access) = GalleryCoreApi::hasItemPermission($id, $permission, $user);
if ($ret) {
gallery_error(t('Error calling hasItemPermission()'), $ret);
return FALSE;
}
return $access;
}
/** /**
* Function gallery_db_query(). * Function gallery_db_query().
*/ */
function gallery_db_query($query, $data = NULL) { function gallery_db_query($query, $data = NULL) {
if (!isset($GLOBALS['gallery'])) { if (!_gallery_init(TRUE)) {
if (!_gallery_init()) { return FALSE;
return FALSE;
}
} }
// Perform query
list ($ret, $search) = $GLOBALS['gallery']->search($query, $data); list ($ret, $search) = $GLOBALS['gallery']->search($query, $data);
if ($ret) { if ($ret) {
return FALSE; return FALSE;
...@@ -292,11 +311,10 @@ function gallery_db_query($query, $data = NULL) { ...@@ -292,11 +311,10 @@ function gallery_db_query($query, $data = NULL) {
* Function gallery_flush_entity_cache(). * Function gallery_flush_entity_cache().
*/ */
function gallery_flush_entity_cache() { function gallery_flush_entity_cache() {
if (!isset($GLOBALS['gallery'])) { if (!_gallery_init()) {
if (!_gallery_init()) { return FALSE;
return FALSE;
}
} }
// Flush entity cache
$platform =& $GLOBALS['gallery']->getPlatform(); $platform =& $GLOBALS['gallery']->getPlatform();
$cache_basedir = $GLOBALS['gallery']->getConfig('data.gallery.cache'); $cache_basedir = $GLOBALS['gallery']->getConfig('data.gallery.cache');
$cache_dir = $cache_basedir .'entity'; $cache_dir = $cache_basedir .'entity';
...@@ -333,21 +351,27 @@ function gallery_set_css($css) { ...@@ -333,21 +351,27 @@ function gallery_set_css($css) {
if (count($css)) { if (count($css)) {
$css = preg_replace('/<link(.*?)href="([^"]*)"(.*?)\/>/i', '${2}', $css); $css = preg_replace('/<link(.*?)href="([^"]*)"(.*?)\/>/i', '${2}', $css);
$css = preg_replace(array('#^'. $base_url .'#', '#^'. base_path() .'#', '#^/#'), '', $css);
foreach ($css as $include) { foreach ($css as $include) {
if (!in_array(($md5 = md5($include)), $css_memory)) { if (!in_array(($md5 = md5($include)), $css_memory)) {
$css_memory[] = $md5; $css_memory[] = $md5;
if (substr($include, 0, 6) == '<style') { if (variable_get('gallery_outside', 0)) {
// drupal_add_css() does not support inline styles
drupal_set_html_head($include);
}
elseif (substr($include, 0, 4) == 'http' || variable_get('gallery_outside', 0)) {
// drupal_add_css() does not support external paths // drupal_add_css() does not support external paths
drupal_set_html_head('<link type="text/css" rel="stylesheet" media="all" href="'. $include .'" />'."\n"); drupal_set_html_head('<link type="text/css" rel="stylesheet" media="all" href="'. $include .'" />');
} }
else { else {
// Gallery's css must always be added first to allow overriding from the module(s) $include = preg_replace(array('#^'. $base_url .'#', '#^'. base_path() .'#', '#^/#'), '', $include);
drupal_add_css($include, 'module', 'all', FALSE); if (substr($include, 0, 6) == '<style') {
// drupal_add_css() does not support inline styles
drupal_set_html_head($include);
}
elseif (substr($include, 0, 4) == 'http') {
// drupal_add_css() does not support external paths
drupal_set_html_head('<link type="text/css" rel="stylesheet" media="all" href="'. $include .'" />');
}
else {
// Gallery's css must always be added first to allow overriding from the module(s)
drupal_add_css($include, 'module', 'all', FALSE);
}
} }
} }
} }
...@@ -370,22 +394,54 @@ function gallery_set_javascript($javascript) { ...@@ -370,22 +394,54 @@ function gallery_set_javascript($javascript) {
drupal_add_js(implode("\n", $inline), 'inline'); drupal_add_js(implode("\n", $inline), 'inline');
// Javascript files // Javascript files
$files = preg_replace('/<script(.*?)src="([^"]*)"([^>]*)>(.*?)<\/script>/i', '${2}', $files); $files = preg_replace('/<script(.*?)src="([^"]*)"([^>]*)>(.*?)<\/script>/i', '${2}', $files);
$files = preg_replace(array('#^'. $base_url .'#', '#^'. base_path() .'#', '#^/#'), '', $files);
foreach ($files as $include) { foreach ($files as $include) {
if (!in_array(($md5 = md5($include)), $js_memory)) { if (!in_array(($md5 = md5($include)), $js_memory)) {
$js_memory[] = $md5; $js_memory[] = $md5;
if (substr($include, 0, 4) == 'http' || variable_get('gallery_outside', 0)) { if (variable_get('gallery_outside', 0)) {
// drupal_add_js() does not support external paths // drupal_add_js() does not support external paths
drupal_set_html_head('<script type="text/javascript" src="'. $include .'"></script>'."\n"); drupal_set_html_head('<script type="text/javascript" src="'. $include .'"></script>');
} }
else { else {
drupal_add_js($include); $include = preg_replace(array('#^'. $base_url .'#', '#^'. base_path() .'#', '#^/#'), '', $include);
if (substr($include, 0, 4) == 'http') {
// drupal_add_js() does not support external paths
drupal_set_html_head('<script type="text/javascript" src="'. $include .'"></script>');
}
else {
drupal_add_js($include);
}
} }
} }
} }
} }
} }
/**
* Function gallery_get_block().
*
* This function allows developers to fetch an image or grid block with certain
* parameters from Gallery2.
*
* @param $params
* An array of parameters to be passed to getImageBlock().
* (http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryEmbed.html#methodgetImageBlock)
* If 'itemId' is set to 'user' (or 'user:uid') items are be taken from the
* current (or specified) user's useralbum.
* @param $num_cols
* If given a grid block with $num_cols columns is generated.
* Otherwise (default) a 'normal' image block is returned.
* @param $class
* Optional class to apply to the block (if customized css styles are required).
*/
function gallery_get_block($params, $num_cols = NULL, $class = NULL) {
if (!_gallery_init()) {
return array('content' => '');
}
// Include gallery_block.inc and call the private implementation
require_once(drupal_get_path('module', 'gallery') .'/gallery_block.inc');
return _gallery_block_get_block($params, $num_cols, $class);
}
/** /**
* Function _gallery_split_imageblock(). * Function _gallery_split_imageblock().
* (split an image block result into individual images) * (split an image block result into individual images)
...@@ -515,8 +571,7 @@ function gallery_plugin_status($plugin_names) { ...@@ -515,8 +571,7 @@ function gallery_plugin_status($plugin_names) {
static $all_plugins_status = array(); static $all_plugins_status = array();
$plugins_status = array(); $plugins_status = array();
if (!_gallery_init(FALSE)) { if (!_gallery_init()) {
gallery_error(t('Unable to initialize Gallery2.'), $ret);
foreach ($plugin_names as $plugin) { foreach ($plugin_names as $plugin) {
$plugins_status[$plugin] = GALLERY_PLUGIN_STATUS_UNKNOWN; $plugins_status[$plugin] = GALLERY_PLUGIN_STATUS_UNKNOWN;
} }
...@@ -598,10 +653,10 @@ function gallery_get_status() { ...@@ -598,10 +653,10 @@ function gallery_get_status() {
* Function gallery_version(). * Function gallery_version().
*/ */
function gallery_version() { function gallery_version() {
if (!_gallery_init(FALSE)) { if (!_gallery_init()) {
return array(); return array();
} }
// Get API version
list($core_major, $core_minor) = GalleryCoreApi::getApiVersion(); list($core_major, $core_minor) = GalleryCoreApi::getApiVersion();
list($embed_major, $embed_minor) = GalleryEmbed::getApiVersion(); list($embed_major, $embed_minor) = GalleryEmbed::getApiVersion();
$version = array( $version = array(
......
...@@ -17,21 +17,32 @@ function _gallery_block($op = 'list', $delta = 0, $edit = array()) { ...@@ -17,21 +17,32 @@ function _gallery_block($op = 'list', $delta = 0, $edit = array()) {
$type_map = $param_map = array(); $type_map = $param_map = array();
_gallery_block_options($type_map, $param_map); _gallery_block_options($type_map, $param_map);
list($type, $delta) = (stristr($delta, '-') !== FALSE) ? explode('-', $delta) : array('', 0); if ($delta == 'navigation') {
$type = $delta;
}
else {
list($type, $delta) = (stristr($delta, '-') !== FALSE) ? explode('-', $delta) : array('', 0);
}
switch ($op) { switch ($op) {
case 'list': case 'list':
// Navigation Block
$blocks['navigation']['info'] = t('Gallery Navigation'); $blocks['navigation']['info'] = t('Gallery Navigation');
$blocks['navigation']['cache'] = variable_get('gallery_block_navigation_cache', BLOCK_CACHE_PER_USER);
// Image Block
$imageblock_num = variable_get('gallery_block_image_num', 1); $imageblock_num = variable_get('gallery_block_image_num', 1);
for ($i=0; $i<$imageblock_num; $i++) { for ($i=0; $i<$imageblock_num; $i++) {
$id = variable_get('gallery_block_image_'. $i .'_blockid', ''); $id = variable_get('gallery_block_image_'. $i .'_blockid', '');
$blocks['image-'. $i]['info'] = t('Gallery Image Block @id', $blocks['image-'. $i]['info'] = t('Gallery Image Block @id',
array('@id' => ($imageblock_num > 1) ? ('['. ($id ? $id : $i+1) .']') : '')); array('@id' => ($imageblock_num > 1) ? ('['. ($id ? $id : $i+1) .']') : ''));
$blocks['image-'. $i]['cache'] = variable_get('gallery_block_image_'. $i .'_cache', BLOCK_CACHE_PER_USER);
} }
// Image Grid Block
$gridblock_num = variable_get('gallery_block_grid_num', 1); $gridblock_num = variable_get('gallery_block_grid_num', 1);
for ($i=0; $i<$gridblock_num; $i++) { for ($i=0; $i<$gridblock_num; $i++) {
$id = variable_get('gallery_block_grid_'. $i .'_blockid', ''); $id = variable_get('gallery_block_grid_'. $i .'_blockid', '');
$blocks['grid-'. $i]['info'] = t('Gallery Grid Block @id', $blocks['grid-'. $i]['info'] = t('Gallery Grid Block @id',
array('@id' => ($gridblock_num > 1) ? ('['. ($id ? $id : $i+1) .']') : '')); array('@id' => ($gridblock_num > 1) ? ('['. ($id ? $id : $i+1) .']') : ''));
$blocks['grid-'. $i]['cache'] = variable_get('gallery_block_grid_'. $i .'_cache', BLOCK_CACHE_PER_USER);
} }
return $blocks; return $blocks;
case 'view': case 'view':
...@@ -40,10 +51,9 @@ function _gallery_block($op = 'list', $delta = 0, $edit = array()) { ...@@ -40,10 +51,9 @@ function _gallery_block($op = 'list', $delta = 0, $edit = array()) {
} }
switch ($type) { switch ($type) {
case 'navigation': // Navigation Block case 'navigation': // Navigation Block
global $_gallery_sidebar_; if ((arg(0) == variable_get('gallery_base', 'gallery')) && !empty($GLOBALS['gallery_sidebar'])) {
if ((arg(0) == 'gallery') && !empty($_gallery_sidebar_)) {
$block['subject'] = t('Gallery Navigation'); $block['subject'] = t('Gallery Navigation');
$block['content'] = '<div id="gsSidebar" class="gcBorder1">'. implode('', $_gallery_sidebar_) .'</div>'; $block['content'] = '<div id="gsSidebar" class="gcBorder1">'. implode('', $GLOBALS['gallery_sidebar']) .'</div>';
} }
break; break;
case 'image': // Image Block case 'image': // Image Block
...@@ -58,6 +68,8 @@ function _gallery_block($op = 'list', $delta = 0, $edit = array()) { ...@@ -58,6 +68,8 @@ function _gallery_block($op = 'list', $delta = 0, $edit = array()) {
case 'configure': case 'configure':
require_once(drupal_get_path('module', 'gallery') .'/gallery_settings.inc'); require_once(drupal_get_path('module', 'gallery') .'/gallery_settings.inc');
switch ($type) { switch ($type) {
case 'navigation': // Navigation Block
return _gallery_settings_block_navigation();
case 'image': // Image Block case 'image': // Image Block
return _gallery_settings_block_image($delta); return _gallery_settings_block_image($delta);
case 'grid': // Image Grid Block case 'grid': // Image Grid Block
...@@ -101,16 +113,9 @@ function _gallery_block_options(&$type_map, &$param_map) { ...@@ -101,16 +113,9 @@ function _gallery_block_options(&$type_map, &$param_map) {
* Function _gallery_block_image_block(). * Function _gallery_block_image_block().
*/ */
function _gallery_block_image_block($delta, $type_map) { function _gallery_block_image_block($delta, $type_map) {
$param_blocks_array = variable_get('gallery_block_image_'. $delta .'_block_block', array('randomImage')); $param_blocks_array = array_filter(variable_get('gallery_block_image_'. $delta .'_block_block', array('randomImage')));
$params['blocks'] = is_array($param_blocks_array) ? implode('|', $param_blocks_array) : ''; $params['blocks'] = is_array($param_blocks_array) ? implode('|', $param_blocks_array) : '';
$param_itemid = variable_get('gallery_block_image_'. $delta .'_item_id', ''); $params['itemId'] = variable_get('gallery_block_image_'. $delta .'_item_id', '');
if (trim($param_itemid) == '%user') {
require_once(drupal_get_path('module', 'gallery') .'/gallery_user.inc');
$param_itemid = gallery_user_useralbum(NULL, FALSE);
}
if (!empty($param_itemid)) {
$params['itemId'] = $param_itemid;
}
$param_show_array = variable_get('gallery_block_image_'. $delta .'_block_show', array()); $param_show_array = variable_get('gallery_block_image_'. $delta .'_block_show', array());
$params['show'] = is_array($param_show_array) ? implode('|', $param_show_array) : ''; $params['show'] = is_array($param_show_array) ? implode('|', $param_show_array) : '';
if (variable_get('gallery_block_image_'. $delta .'_size_method', GALLERY_IMAGEBLOCK_SIZE_METHOD_DEFAULT) == 'maxsize') { if (variable_get('gallery_block_image_'. $delta .'_size_method', GALLERY_IMAGEBLOCK_SIZE_METHOD_DEFAULT) == 'maxsize') {
...@@ -123,37 +128,13 @@ function _gallery_block_image_block($delta, $type_map) { ...@@ -123,37 +128,13 @@ function _gallery_block_image_block($delta, $type_map) {
$params['itemFrame'] = variable_get('gallery_block_image_'. $delta .'_item_frame', 'none'); $params['itemFrame'] = variable_get('gallery_block_image_'. $delta .'_item_frame', 'none');
$params['linkTarget'] = variable_get('gallery_block_image_'. $delta .'_link_target', ''); $params['linkTarget'] = variable_get('gallery_block_image_'. $delta .'_link_target', '');
$params['link'] = variable_get('gallery_block_image_'. $delta .'_link', ''); $params['link'] = variable_get('gallery_block_image_'. $delta .'_link', '');
$block = array();
list($ret, $content, $head) = GalleryEmbed::getImageBlock($params);
if ($ret) {
gallery_error(t('Unable to get Gallery image block'), $ret);
return array();
}
if ($content) { $block = _gallery_block_get_block($params);
if (count($param_blocks_array) > 1) { $block['subject'] = (count($param_blocks_array) > 1) ? t('Gallery') : $type_map[$params['blocks']];
$block['subject'] = t('Gallery');
}
else {
$block['subject'] = $type_map[$params['blocks']];
}
$block['content'] = theme('gallery_block_image_block', $content);
}
if ($head) {
gallery_set_head($head);
}
return $block; return $block;
} }
/**
* Theme function : theme_gallery_block_image_block().
*/
function theme_gallery_block_image_block($content) {
return '<div class="g2image_centered">'. $content .'</div>';
}
/** /**
* Function _gallery_block_grid_block(). * Function _gallery_block_grid_block().
*/ */
...@@ -164,14 +145,7 @@ function _gallery_block_grid_block($delta, $type_map) { ...@@ -164,14 +145,7 @@ function _gallery_block_grid_block($delta, $type_map) {
$param_blocks_array = array_fill(0, $num_images, variable_get('gallery_block_grid_'. $delta .'_block_block', 'randomImage')); $param_blocks_array = array_fill(0, $num_images, variable_get('gallery_block_grid_'. $delta .'_block_block', 'randomImage'));
$params['blocks'] = is_array($param_blocks_array) ? implode('|', $param_blocks_array) : ''; $params['blocks'] = is_array($param_blocks_array) ? implode('|', $param_blocks_array) : '';
$param_itemid = variable_get('gallery_block_grid_'. $delta .'_item_id', ''); $params['itemId'] = variable_get('gallery_block_grid_'. $delta .'_item_id', '');
if (trim($param_itemid) == '%user') {
require_once(drupal_get_path('module', 'gallery') .'/gallery_user.inc');
$param_itemid = gallery_user_useralbum(NULL, FALSE);
}
if (!empty($param_itemid)) {
$params['itemId'] = $param_itemid;
}
$param_show_array = variable_get('gallery_block_grid_'. $delta .'_block_show', array()); $param_show_array = variable_get('gallery_block_grid_'. $delta .'_block_show', array());
$params['show'] = is_array($param_show_array) ? implode('|', $param_show_array) : ''; $params['show'] = is_array($param_show_array) ? implode('|', $param_show_array) : '';
if (variable_get('gallery_block_grid_'. $delta .'_size_method', GALLERY_GRID_SIZE_METHOD_DEFAULT) == 'maxsize') { if (variable_get('gallery_block_grid_'. $delta .'_size_method', GALLERY_GRID_SIZE_METHOD_DEFAULT) == 'maxsize') {
...@@ -185,29 +159,62 @@ function _gallery_block_grid_block($delta, $type_map) { ...@@ -185,29 +159,62 @@ function _gallery_block_grid_block($delta, $type_map) {
$params['linkTarget'] = variable_get('gallery_block_grid_'. $delta .'_link_target', ''); $params['linkTarget'] = variable_get('gallery_block_grid_'. $delta .'_link_target', '');
$params['link'] = variable_get('gallery_block_grid_'. $delta .'_link', ''); $params['link'] = variable_get('gallery_block_grid_'. $delta .'_link', '');
$block = array(); return _gallery_block_get_block($params, $num_cols);
}
/**
* Function _gallery_block_get_block().
*/
function _gallery_block_get_block($params, $num_cols = NULL, $class = NULL) {
// Handle useralbum feature
if (preg_match('/user(:([\d]+))?/i', $params['itemId'], $param_uid)) {
require_once(drupal_get_path('module', 'gallery') .'/gallery_user.inc');
$params['itemId'] = gallery_user_useralbum(isset($param_uid[2]) ? $param_uid[2] : NULL, FALSE);
}
if (empty($params['itemId']) || $params['itemId'] === FALSE) {
unset($params['itemId']);
}
// Get the image(s) from G2
list($ret, $content, $head) = GalleryEmbed::getImageBlock($params); list($ret, $content, $head) = GalleryEmbed::getImageBlock($params);
if ($ret) { if ($ret) {
gallery_error(t('Unable to get Gallery image block'), $ret); gallery_error(t('Unable to get Gallery image block'), $ret);
return array(); return array();
} }
// Format the block content
$block = array();
if ($content) { if ($content) {
$block['subject'] = t('Gallery'); $block['subject'] = t('Gallery');
$images = _gallery_split_imageblock($content); if (isset($num_cols)) {
$images = array_chunk($images, $num_cols); $class = isset($class) ? $class : 'gallery-grid-block';
$block['content'] = theme('gallery_block_grid_block', $images);