Commit e6eb5e28 authored by profix898's avatar profix898

- major update: basically all features ported to D6 now :)

(requires G2.3/svn and is still volatile, for early testing only)
parent 030f6937
......@@ -4,20 +4,18 @@
* Drupal embeded Gallery2 css overrides.
* These do not make a perfect theme, but are not bad as a first step.
*/
/* Increase font size */
/* Increase font size */
#gallery {
font-size: 100%;
}
/*#siteAdminForm {
font-size: 140%;
}*/
/* Remove the header */
#gsHeader {
display: none;
}
/* Removes the Gallery Title (as Drupal displays it)*/
/* Removes the Gallery Title (as Drupal displays it) */
#gallery .gbBlock table h2 {
display: none;
}
......@@ -58,7 +56,6 @@ table.ImageFrame_wood, table.ImageFrame_wood td {
padding: 0px;
}
/* Brings h2 back for siteAdmin pages */
#siteAdminForm .gbBlock h2 {
display: block;
......@@ -83,6 +80,19 @@ table.ImageFrame_wood, table.ImageFrame_wood td {
overflow: hidden;
}
/* Flatten left margin for SiteAdminLinks if moved to Drupal sidebar */
.block-gallery #gsSidebar ul#gbSiteAdminLinks,
.block-gallery #gsSidebar ul#gbSiteAdminLinks li,
.block-gallery #gsSidebar ul#gbSiteAdminLinks li ul,
.block-gallery #gsSidebar ul#gbSiteAdminLinks li ul li {
margin-left: 2px;
}
/* Remove bold font from SiteAdminLinks if moved to Drupal sidebar */
.block-gallery #gsSidebar #gbSiteAdminLinks a {
font-weight: normal;
}
.block-gallery div.block-core-ItemLinks {
margin: 0;
border-bottom: 1px solid #aaa;
......@@ -97,8 +107,9 @@ table.ImageFrame_wood, table.ImageFrame_wood td {
border-top: none;
}
/* Garland adds padding which needs to be removed */
.block-gallery td, th {
padding: 0; /* Garland adds padding which needs to be removed */
padding: 0;
}
/* Navigation Tree */
......@@ -106,7 +117,7 @@ table.ImageFrame_wood, table.ImageFrame_wood td {
font-size: 1em;
}
/* For g2ic_plugin */
/* For G2Image */
img.g2image_float_left, div.g2image_float_left {
float: left;
margin: 0px 4px 4px 0px;
......@@ -124,7 +135,7 @@ img.g2image_centered, div.g2image_centered {
text-align: center;
}
/* Neeed to centre images with frames */
/* Need to center images with frames */
.g2image_centered table {
margin: auto;
}
......@@ -204,10 +215,11 @@ td.gallery-grid-block {
margin: auto;
}*/
/* Garland adds padding which needs to be removed */
.gallery-grid-block table,
.gallery-grid-block .one-image td,
.gallery-grid-block .one-image table {
padding: 0; /* Garland adds padding which needs to be removed */
padding: 0;
margin: auto;
}
......
......@@ -15,22 +15,11 @@ function gallery_install() {
/**
* Implementation of hook_update_N().
* (migrate settings from the 5.x-1.x to 5.x-2.x (or 6.x-1.x) series)
* (migrate settings from the 5.x-1.x to 5.x-2.x series)
*/
function gallery_update_1() {
$ret = array();
$variables = array();
// Fetch all gallery-related variables
$result = db_query("SELECT * FROM {variable} WHERE name LIKE 'gallery_%'");
while ($var = db_fetch_object($result)) {
$variables[$var->name] = $var->value;
}
// Remove old variables
db_query("DELETE FROM {variable} WHERE name LIKE 'gallery_%'");
// Array containing 'old name' => 'new name' map
$variable_map = array(
$migrate = array(
// Image block settings
'gallery_album_frame' => 'gallery_block_image_0_album_frame',
'gallery_block_block' => 'gallery_block_image_0_block_block',
......@@ -59,17 +48,129 @@ function gallery_update_1() {
'gallery_use_full_name' => 'gallery_use_fullname',
'gallery_profile_full_name_field' => 'gallery_profile_fullname_field'
);
// Array containing obsolete variables
$obsolete = array('gallery_search_max_items', 'gallery_autodetect_dir', 'gallery_uri', 'gallery_dir');
// Update variables
$ret = gallery_update_variables($migrate, $obsolete);
// Update the blocks
$ret[] = update_sql("UPDATE {blocks} SET delta = 'image-0' WHERE module = 'gallery' AND delta = 0");
$ret[] = update_sql("UPDATE {blocks} SET delta = 'navigation' WHERE module = 'gallery' AND delta = 1");
$ret[] = update_sql("UPDATE {blocks} SET delta = 'grid-0' WHERE module = 'gallery' AND delta = 2");
// Mark gallery configuration invalid. This does NOT reset the configuration, but
// forces the user to run the install wizard to (re)set and verify critical settings.
variable_set('gallery_valid', FALSE);
drupal_set_message('You were updating from gallery module 5.x-1.x (or earlier) to the 6.x-1.x
series of the module. All your settings were migrated automatically (see below),
but you will need to re-configure some basic options. Please visit the
Gallery settings page (admin/settings/gallery) to complete the update.',
'error');
cache_clear_all('variables', 'cache');
menu_rebuild();
return $ret;
}
/**
* Implementation of hook_update_N().
* (initial update to Drupal 6)
*/
function gallery_update_6001() {
$delta = 0;
$new = $migrate = array();
// Image block settings
$imageblock_num = variable_get('gallery_block_image_num', 1);
for ($i=0; $i<$imageblock_num; $i++) {
$delta++;
$new += array(
'gallery_block_'. $delta .'_type' => 'imageblock',
'gallery_block_'. $delta .'_imageblock_num_cols' => 1,
);
$migrate += array(
'gallery_block_image_'. $i .'_blockid' => 'gallery_block_'. $delta .'_blockid',
'gallery_block_image_'. $i .'_num_images' => 'gallery_block_'. $delta .'_imageblock_num_rows',
'gallery_block_image_'. $i .'_block_block' => 'gallery_block_'. $delta .'_imageblock_block_block',
'gallery_block_image_'. $i .'_item_id' => 'gallery_block_'. $delta .'_imageblock_item_id',
'gallery_block_image_'. $i .'_block_show' => 'gallery_block_'. $delta .'_imageblock_block_show',
'gallery_block_image_'. $i .'_size_method' => 'gallery_block_'. $delta .'_imageblock_size_method',
'gallery_block_image_'. $i .'_size' => 'gallery_block_'. $delta .'_imageblock_size',
'gallery_block_image_'. $i .'_album_frame' => 'gallery_block_'. $delta .'_imageblock_album_frame',
'gallery_block_image_'. $i .'_item_frame' => 'gallery_block_'. $delta .'_imageblock_item_frame',
'gallery_block_image_'. $i .'_link_target' => 'gallery_block_'. $delta .'_imageblock_link_target',
'gallery_block_image_'. $i .'_link' => 'gallery_block_'. $delta .'_imageblock_link',
);
}
// Grid block settings
$gridblock_num = variable_get('gallery_block_grid_num', 1);
for ($i=0; $i<$gridblock_num; $i++) {
$delta++;
$new['gallery_block_'. $delta .'_type'] = 'imageblock';
$migrate += array(
'gallery_block_grid_'. $i .'_blockid' => 'gallery_block_'. $delta .'_blockid',
'gallery_block_grid_'. $i .'_num_cols' => 'gallery_block_'. $delta .'_imageblock_num_cols',
'gallery_block_grid_'. $i .'_num_rows' => 'gallery_block_'. $delta .'_imageblock_num_rows',
'gallery_block_grid_'. $i .'_block_block' => 'gallery_block_'. $delta .'_imageblock_block_block',
'gallery_block_grid_'. $i .'_item_id' => 'gallery_block_'. $delta .'_imageblock_item_id',
'gallery_block_grid_'. $i .'_block_show' => 'gallery_block_'. $delta .'_imageblock_block_show',
'gallery_block_grid_'. $i .'_size_method' => 'gallery_block_'. $delta .'_imageblock_size_method',
'gallery_block_grid_'. $i .'_size' => 'gallery_block_'. $delta .'_imageblock_size',
'gallery_block_grid_'. $i .'_album_frame' => 'gallery_block_'. $delta .'_imageblock_album_frame',
'gallery_block_grid_'. $i .'_item_frame' => 'gallery_block_'. $delta .'_imageblock_item_frame',
'gallery_block_grid_'. $i .'_link_target' => 'gallery_block_'. $delta .'_imageblock_link_target',
'gallery_block_grid_'. $i .'_link' => 'gallery_block_'. $delta .'_imageblock_link',
);
}
$new['gallery_block_num'] = $delta;
// Array containing obsolete variables
$obsolete = array('gallery_page_callback', 'gallery_block_image_num', 'gallery_block_grid_num');
// Add new variables
foreach ($new as $name => $value) {
db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, $value);
}
// Update variables
$ret = gallery_update_variables($migrate, $obsolete);
// Update the blocks
$ret[] = update_sql("UPDATE {blocks} SET delta = 'image-0' WHERE module = 'gallery' AND delta = 0");
$ret[] = update_sql("UPDATE {blocks} SET delta = 'navigation' WHERE module = 'gallery' AND delta = 1");
$ret[] = update_sql("UPDATE {blocks} SET delta = 'grid-0' WHERE module = 'gallery' AND delta = 2");
cache_clear_all('variables', 'cache');
menu_rebuild();
return $ret;
}
/**
* Function gallery_update_variables().
*/
function gallery_update_variables($migrate, $obsolete) {
$ret = array();
$variables = array();
// Fetch all gallery-related variables
$result = db_query("SELECT * FROM {variable} WHERE name LIKE 'gallery_%'");
while ($var = db_fetch_object($result)) {
$variables[$var->name] = $var->value;
}
// Remove old variables
db_query("DELETE FROM {variable} WHERE name LIKE 'gallery_%'");
// Migrate old variables
foreach ($variable_map as $old => $new) {
foreach ($migrate as $old => $new) {
if (isset($variables[$old])) {
$variables[$new] = $variables[$old];
unset($variables[$old]);
$ret[] = array('success' => TRUE, 'query' => 'Migrating variable ['. $old .' => '. $new .']');
}
}
// Unset obsolete variables
$obsolete = array('gallery_search_max_items', 'gallery_autodetect_dir', 'gallery_uri', 'gallery_dir');
foreach ($obsolete as $var) {
if (isset($variables[$var])) {
unset($variables[$var]);
......@@ -77,14 +178,6 @@ function gallery_update_1() {
}
}
// Mark gallery configuration invalid. This does NOT reset the configuration, but
// forces the user to run the install wizard to (re)set and verify critical settings.
$variables['gallery_valid'] = FALSE;
drupal_set_message('You were updating from gallery module 5.x-1.x (or earlier) to the 6.x-1.x
of the module. All your settings were migrated automatically (see below),
but you will need to re-configure some basic options. Please visit the
Gallery settings page (admin/settings/gallery) to complete the update.',
'error');
// Save resulting variables array
// (all variables not migrated or unset are taken over directly)
foreach ($variables as $name => $value) {
......@@ -92,20 +185,6 @@ function gallery_update_1() {
// (i.e. unserialize => serialize and cache_clear_all() for each variable)
db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, $value);
}
cache_clear_all('variables', 'cache');
menu_rebuild();
return $ret;
}
/**
* Implementation of hook_update_N().
* (initial update to Drupal 6)
*/
function gallery_update_6001() {
$ret = array();
$ret[] = array('success' => TRUE, 'query' => 'Removing variable [gallery_page_callback]');
variable_del('gallery_page_callback');
return $ret;
}
......
// $Id$
function g2ic_open(field) {
function g2image_open(field) {
// Set some properties
var form = $('#'+field).parents('form').attr('id');
var url = Drupal.settings.gallery.g2image_uri+'g2image.php?g2ic_form='+form+'&g2ic_field='+field+'&g2ic_tinymce=0';
......@@ -14,3 +14,10 @@ function g2ic_open(field) {
// Open the G2Image window
window.open(url, name, features);
}
// BUEditor
function g2bueditor_open() {
if (editor.active) {
g2image_open(editor.active.textArea.id);
}
}
......@@ -262,22 +262,21 @@ function gallery_auth_validate($form, &$form_state) {
*/
function gallery_user($op, &$edit, &$user, $category = NULL) {
require_once(drupal_get_path('module', 'gallery') .'/gallery_user.inc');
switch ($op) {
case 'login':
gallery_login();
break;
case 'logout':
gallery_logout();
break;
case 'view':
return gallery_user_view($user);
case 'insert':
return gallery_user_insert($edit, drupal_clone($user));
case 'update':
return gallery_user_update($edit, drupal_clone($user));
case 'delete':
return gallery_user_delete($user);
case 'login':
gallery_login();
break;
case 'logout':
gallery_logout();
break;
case 'view':
return gallery_user_view($user);
case 'insert':
return gallery_user_insert($edit, drupal_clone($user));
case 'update':
return gallery_user_update($edit, drupal_clone($user));
case 'delete':
return gallery_user_delete($user);
}
}
......@@ -308,12 +307,12 @@ function gallery_form_alter(&$form, $form_state, $form_id) {
$form['#submit'][] = '_gallery_groups_submit';
}
// Add a custom search form
if ($form_id == 'search_form' && arg(1) == 'gallery' && variable_get('gallery_search_advanced', 1) && user_access('access gallery')) {
else if ($form_id == 'search_form' && arg(1) == 'gallery' && variable_get('gallery_search_advanced', 1) && user_access('access gallery')) {
require_once(drupal_get_path('module', 'gallery') .'/gallery_search.inc');
_gallery_search_form($form);
}
// Add _validate() handler for external authentication
if ($form_id == 'user_login_block' || $form_id == 'user_login') {
else if ($form_id == 'user_login_block' || $form_id == 'user_login') {
$form['#validate'][] = 'gallery_auth_validate';
}
}
......@@ -395,7 +394,7 @@ function gallery_page() {
$result = gallery_handle_request();
if ($result && !$result['isDone']) {
// Allow modules to alter the page
drupal_alter('gallery_page', $result);
drupal_alter('gallery_page', $result, array());
// Add css/js for this page
gallery_set_head($result['headHtml'], TRUE);
// Add pathbar. See http://gallery.menalto.com/node/33447
......@@ -444,40 +443,35 @@ function gallery_page() {
}
/**
* Function gallery_gsitemap().
* Implementation of hook_xmlsitemap_links().
* (define additional links to add to the site map)
*
* This hook allows modules to add additional links to the site map. Links
* may be associated with nodes, terms, or users, as shown in the example.
*
* @param $type
* If given, the type of link to associate additional links with.
* @param $excludes
* If given, an array of criteria for excluding links.
* @return
* An array of links or an empty array.
*/
function gallery_gsitemap($type = NULL, $excludes = array()) {
function gallery_xmlsitemap_links($type = NULL, $excludes = array()) {
if (($type != 'xml') || !variable_get('gallery_enable_sitemap', 1) || !_gallery_init(TRUE)) {
return array();
return;
}
list($ret, $view) = GalleryView::loadView('sitemap.Sitemap');
if ($ret) {
gallery_error(t('Error loading the Gallery2 Google Sitemap. Make sure the \'Google Sitemap\' plugin is enabled in Gallery2.'), $ret);
return array();
gallery_error(t('Error loading the Gallery2 Sitemap. Make sure the \'Sitemap\' plugin is enabled in Gallery2.'), $ret);
return;
}
list($ret, $root_id) = GalleryCoreApi::getDefaultAlbumId();
list($ret, $root) = GalleryCoreApi::getDefaultAlbumId();
if ($ret) {
gallery_error(t('Error loading the Gallery2 Default Album Id.'), $ret);
return array();
gallery_error(t('Error calling getDefaultAlbumId()'), $ret);
return;
}
// Get the sitemap from Gallery2
ob_start();
$ret = $view->renderSitemap($root_id);
$ret = $view->renderSitemap($root);
$g2_sitemap = ob_get_contents();
ob_end_clean();
if ($ret) {
gallery_error(t('Error getting sitemap from Gallery2.'), $ret);
return;
}
return $g2_sitemap;
}
......@@ -78,16 +78,37 @@ function _gallery_init($full = FALSE, $vars = NULL, $report_error = TRUE) {
return FALSE;
}
include_once($embed_path);
// Language-prefix url rewrite
$language = gallery_get_language($user);
if (module_exists('i18n')) { // TODO
$embed_uri = preg_replace('/index.php\?q=/', i18n_path('index.php?q=', $language), $embed_uri);
}
// Prepare array with init parameters
$params = array('embedUri' => $embed_uri,
'g2Uri' => $g2_uri,
'loginRedirect' => url('user/login', array('query' => drupal_get_destination(), 'absolute' => TRUE)),
'activeUserId' => $uid,
'activeLanguage' => gallery_get_language($user),
'activeLanguage' => $language,
'fullInit' => $full,
'apiVersion' => array(1, 2));
'apiVersion' => array(1, 3));
// Add theme to init parameters
if (($g2_theme = variable_get('gallery_embed_theme', 'default')) != 'default') {
$params['themeId'] = $g2_theme;
}
// Add root album to init parameters (but only for the gallery pages)
$g2_root = variable_get('gallery_root_album', 'default');
if ($g2_root != 'default' && arg(0) == variable_get('gallery_base', 'gallery')) {
$params['defaultAlbumId'] = $params['breadcrumbRootId'] = $g2_root;
}
// Allow modules to alter the init parameters
drupal_alter('gallery_init', $params);
// Initialize Gallery2
include_once($embed_path);
$ret = GalleryEmbed::init($params);
if ($ret) {
if ($ret->getErrorCode() & ERROR_PLUGIN_VERSION_MISMATCH) {
......@@ -104,6 +125,7 @@ function _gallery_init($full = FALSE, $vars = NULL, $report_error = TRUE) {
}
}
// Check if initialization was successful
if (!class_exists('GalleryEmbed') || !class_exists('GalleryCoreApi')) {
if ($report_error) {
gallery_error(t('Classes \'GalleryEmbed\' and/or \'GalleryCoreApi\' are not available,
......@@ -112,6 +134,28 @@ function _gallery_init($full = FALSE, $vars = NULL, $report_error = TRUE) {
return FALSE;
}
// Multiroot: 'Virtual Root' (or 'Alternate guest user') view requested
if (isset($params['defaultAlbumId'])) {
$GLOBALS['gallery']->setConfig('defaultAlbumId', $params['defaultAlbumId']);
}
if (isset($params['breadcrumbRootId'])) {
$GLOBALS['gallery']->setConfig('breadcrumbRootId', $params['breadcrumbRootId']);
}
if (isset($params['anonymousUserId'])) {
$GLOBALS['gallery']->setConfig('anonymousUserId', $params['anonymousUserId']);
}
// Set theme for embedded gallery
if ((!$full || !$ready['half']) && isset($params['themeId'])) {
// TODO: G2.3
/*$ret = GalleryEmbed::setThemeForRequest($g2_theme);
if ($ret && $report_error) {
gallery_error(t('Error settings embedded theme (%theme).', array('%theme' => $g2_theme)));
}*/
}
// Allow other modules to perform post-init tasks
module_invoke_all('gallery_init', $full);
$ready['half'] = $full ? ($ready['full'] = TRUE) : TRUE;
return TRUE;
......@@ -122,6 +166,12 @@ function _gallery_init($full = FALSE, $vars = NULL, $report_error = TRUE) {
* (handleRequest extension with error handling)
*/
function gallery_handle_request() {
// Remove the language-prefix for G2
if (!empty($_GET['g2_path']) && module_exists('i18n')) {
i18n_get_lang_prefix($_GET['g2_path'], TRUE);
}
// Handle the request
ob_start();
$result = GalleryEmbed::handleRequest();
$output = ob_get_contents();
......@@ -135,17 +185,25 @@ function gallery_handle_request() {
}
else {
// Otherwise (on regular pages) $output means that an error occured
preg_match('%<div id="giStackTrace" [^>]*>(.*?)</div>%is', $output, $matches);
if (variable_get('gallery_error_redirect', 0) && user_access('search content')) {
drupal_set_message('The requested Gallery URL does not exist. The item may have been
moved or deleted. You can search for it below.', 'notice');
drupal_goto('search/gallery');
}
preg_match('%<div id="giStackTrace" [^>]*>(.*?)</div>%is', $output, $matches);
gallery_error(t('Error handling request (invalid request)<br />or the requested Gallery URL does not exist.'), $matches[1], TRUE);
return NULL;
}
}
// Include theme-specific css overrides (gallery-themeid.css)
if (isset($result['themeData']['themeId'])) {
$stylesheet = drupal_get_path('module', 'gallery') .'/gallery-'. $result['themeData']['themeId'] .'.css';
if (file_exists($stylesheet)) {
drupal_add_css($stylesheet);
}
}
return $result;
}
......@@ -163,6 +221,39 @@ function gallery_get_language($user) {
return $language->language;
}
/**
* Function gallery_get_themes().
* (retrieve all (active) themes from Gallery2)
*/
function gallery_get_themes() {
if (!_gallery_init()) {
return array();
}
// List of themes
list($ret, $g2_themes) = GalleryCoreApi::fetchPluginStatus('theme', TRUE);
if ($ret) {
gallery_error(t('Error retrieving theme list'), $ret);
return array();
}
$themes = array();
foreach (array_keys($g2_themes) as $themeid) {
// Only active themes
if (!empty($g2_themes[$themeid]['active'])) {
// Get theme details
list($ret, $theme) = GalleryCoreApi::loadPlugin('theme', $themeid, TRUE);
if ($ret) {
gallery_error(t('Error getting theme (:themeid) details',
array(':themeid' => $themeid)), $ret);
return array();
}
$themes[$themeid] = $theme->getName();
}
}
return $themes;
}
/**
* Function gallery_get_image_frames().
* (retrieve all image frames from Gallery2)
......@@ -188,7 +279,7 @@ function gallery_get_image_frames() {
* Function gallery_generate_url().
*/
function gallery_generate_url($params, $html = TRUE, $full = TRUE) {
if (!_gallery_init()) {
if (!_gallery_init(TRUE)) {
return '';
}
// Get URL generator and generate the url
......@@ -246,7 +337,7 @@ function gallery_item_details($id, $verbose = FALSE) {
// Load entity
list($ret, $entity) = GalleryCoreApi::loadEntitiesById($id);
if ($ret) {
gallery_error(t('Error fetching album details (entityId: :id)',
gallery_error(t('Error fetching item details (entityId: :id)',
array(':id' => $id)), $ret);
return $details;
}
......@@ -416,6 +507,32 @@ function gallery_set_javascript($javascript) {
}
}
/**
* Function gallery_get_blocks().
*/
function gallery_get_blocks($plugin_names = NULL) {
if (!_gallery_init()) {
return array();
}
// List of available blocks
list($ret, $g2_blocks) = GalleryCoreApi::loadAvailableBlocks();
if ($ret) {
gallery_error(t('Error retrieving available blocks list'), $ret);
return array();
}
// Filter plugins
if (isset($plugin_names)) {
$plugin_names = is_array($plugin_names) ? $plugin_names : array($plugin_names);
foreach ($g2_blocks as $plugin => $blocks) {
if (!in_array($plugin, $plugin_names)) {
unset($g2_blocks[$plugin]);
}
}
}
return $g2_blocks;
}
/**
* Function gallery_get_block().
*
......@@ -427,19 +544,25 @@ function gallery_set_javascript($javascript) {
* (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).
* @param $block
* Name of the block to get from Gallery2 (e.g. 'ImageBlock', etc.)
* @param $extra
* $extra['class']:
* Optional class to apply to the block (if customized css styles are required).
* $extra['num_colums']:
* If given for a 'ImageBlock' a grid block with 'num_cols' columns is generated.
* Otherwise (default) a 'normal' image block is returned.
*/
function gallery_get_block($params, $num_cols = NULL, $class = NULL) {
if (!_gallery_init()) {
function gallery_get_block($params, $block = 'ImageBlock', $extra = array()) {
require_once(drupal_get_path('module', 'gallery') .'/gallery_block.inc');
if (!_gallery_init(TRUE)) {
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);
$block_map = _gallery_block_map();
$plugin = $block_map[strtolower($block)]['plugin'];
$plugin_block = $block_map[strtolower($block)]['block'];
return _gallery_block_get_block($plugin, $plugin_block, $params, $extra);
}
/**
......@@ -452,9 +575,9 @@ function _gallery_split_imageblock($html) {
$pattern = '/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/';
$html_array = preg_split($pattern, trim($html), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$ndx = 0;
$images = array();
$image_html = '';
$ndx = $open_divs = 0;
// Iterate through this array and combine again, but on a per-image basis
foreach ($html_array as $value) {
$value = trim($value);
......@@ -599,7 +722,7 @@ function gallery_plugin_status($plugin_names) {
elseif (!isset($plugins_status_cache[$plugin]['active']) && $plugins_status_cache[$plugin]['available']) {
$plugins_status[$plugin] = GALLERY_PLUGIN_NOT_INSTALLED;
}
elseif (($plugins_status_cache[$plugin]['active'] == 0) && $plugins_status_cache[$plugin]['available']) {
elseif (($plugins_status_cache[$plugin]['active'] == FALSE) && $plugins_status_cache[$plugin]['available']) {
$plugins_status[$plugin] = GALLERY_PLUGIN_NOT_ACTIVE;
}
else {
......
This diff is collapsed.
This diff is collapsed.
......@@ -20,7 +20,7 @@ function gallery_filter_process($text) {
return $text;
}
$default['n'] = variable_get('gallery_filter_n_images', 1);
$default['type'] = implode('|', array_fill(0, $default['n'], variable_get('gallery_filter_default_block_type', 'recentImage')));
$default['type'] = variable_get('gallery_filter_default_block_type', 'recentImage');
$default['maxsize'] = variable_get('gallery_filter_default_maxsize', GALLERY_FILTER_MAXSIZE_DEFAULT);
$default['exactsize'] = variable_get('gallery_filter_default_exactsize', GALLERY_FILTER_EXACTSIZE_DEFAULT);
$default['class'] = variable_get('gallery_filter_default_div_class', 'nowrap');
......@@ -39,18 +39,25 @@ function gallery_filter_process($text) {
foreach ($matches as $match) {
// First argument is numeric => valid G2 filter tag
if (is_numeric($match[1])) {
$params = array('type' => 'specificItem');
$params['itemId'] = intval($match[1]);
$args = array_filter(preg_split('/[\s,]+/', $match[2]));
$params = array('itemId' => intval($match[1]));
// If this item is not an album (e.g. photo, movie, ...) set block type to 'specificItem'
$details = gallery_item_details($params['itemId']);
if (isset($details['g2type']) && $details['g2type'] != 'GalleryAlbumItem') {
$params['n'] = 1;
$params['type'] = 'specificItem';
}
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);
}
$args = array_filter(preg_split('/[\s,]+/', $match[2]));
// Loop over all (optional) arguments
foreach ($args as $arg) {
list($key, $value) = array_filter(explode('=', $arg));
$key = preg_replace('/\W/', '', $key);
$params[$key] = _gallery_filter_sanitize($key, $value);
if (!empty($value)) {
$key = preg_replace('/\W/', '', $key);
$params[$key] = _gallery_filter_sanitize($key, $value);
}
}
// Treat 'maxsize' and 'size' as the same
if (isset($params['size'])) {
......@@ -108,20 +115,21 @@ function gallery_filter_process($text) {
$params['item_frame'],
$params['target']
);
// Fetch the images and format output
list($ret, $content, $head) = GalleryEmbed::getImageBlock($params);
gallery_debug($params, t('Filter parameters'));
// Fetch the images and format output
list($ret, $content, $head) = GalleryEmbed::getBlock('imageblock', 'ImageBlock', $params);
if ($ret) {
gallery_error(t('Unable to get Gallery image block'), $ret);
gallery_error(t('Error trying to get image block.'), $ret);
continue;
}
if ($content) {
// Allow modules to alter the filter output
drupal_alter('gallery_filter', $content);
// Replace G2 filter tag with image block html
$params['class'] = 'giImageBlock'. ($params['class'] ? ' '. $params['class'] : '');