Commit 9fe08b6a authored by walkah's avatar walkah
Browse files

first pass at an update for CVS HEAD. please note, this version will no

longer work with 4.6.x .
parent 99f6d489
......@@ -32,15 +32,27 @@ function gallery_menu($may_cache) {
* Implementation of hook_settings
*/
function gallery_settings() {
$output = '';
$output.= form_textfield(t('Location of Gallery2'), 'gallery_dir', variable_get('gallery_dir', 'gallery2/'), 64, 64, t('Path to your gallery2 directory, relative to the root directory of your drupal installation. Please include a trailing slash ("/").'));
$output.= form_textfield(t('Location of Drupal'), 'gallery_drupal_dir', variable_get('gallery_drupal_dir', '/'), 64, 64, t('Path to your drupal directory, relative to the root of your website. Please include a trailing slash ("/").'));
$output .= form_checkboxes(t('Error logging'), 'gallery_error_mode',
variable_get('gallery_error_mode', array(1)),
array(1 => t('Watchdog'),
2 => t('Output to the browser')),
t('Choose where errors are displayed'));
return $output;
$form['gallery_dir'] = array(
'#type' => 'textfield',
'#title' => t('Location of Gallery2'),
'#default_value' => variable_get('gallery_dir', 'gallery2/'),
'#description' => t('Path to your gallery2 directory, relative to the root directory of your drupal installation. Please include a trailing slash ("/").'),
);
$form['gallery_drupal_dir'] = array(
'#type' => 'textfield',
'#title' => t('Location of Drupal'),
'#default_value' => variable_get('gallery_drupal_dir', '/'),
'#description' => t('Path to your drupal directory, relative to the root of your website. Please include a trailing slash ("/").'),
);
$form['gallery_error_mode'] = array(
'#type' => 'checkboxes',
'#title' => t('Error logging'),
'#default_value' => variable_get('gallery_error_mode', array(1)),
'#options' => array(1 => t('Watchdog'), 2 => t('Output to the browser')),
'#description' => t('Choose where errors are displayed'),
);
return $form;
}
/**
......@@ -140,78 +152,75 @@ function gallery_user($op, &$edit, &$user, $category = NULL) {
*/
function gallery_block($op = 'list', $delta = 0, $edit = array()) {
$typeMap = array('randomImage' => t('Random image'),
'recentImage' => t('Recent image'),
'viewedImage' => t('Viewed image'),
'randomAlbum' => t('Random album'),
'recentAlbum' => t('Recent album'),
'viewedAlbum' => t('Viewed album'),
'dailyImage' => t('Daily image'),
'weeklyImage' => t('Weekly image'),
'monthlyImage' => t('Monthly image'),
'dailyAlbum' => t('Daily album'),
'weeklyAlbum' => t('Weekly album'),
'monthlyAlbum' => t('Monthly album'));
'recentImage' => t('Recent image'),
'viewedImage' => t('Viewed image'),
'randomAlbum' => t('Random album'),
'recentAlbum' => t('Recent album'),
'viewedAlbum' => t('Viewed album'),
'dailyImage' => t('Daily image'),
'weeklyImage' => t('Weekly image'),
'monthlyImage' => t('Monthly image'),
'dailyAlbum' => t('Daily album'),
'weeklyAlbum' => t('Weekly album'),
'monthlyAlbum' => t('Monthly album'));
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Gallery Block');
return $blocks;
case 'configure':
$output = form_select(t('Image type'),
'gallery_block_block_' . $delta,
variable_get('gallery_block_block_' . $delta, 'randomImage'),
$typeMap,
t('Pick the type of image you\'d like to see'));
$output .= form_checkboxes(
t('Image data'),
'gallery_block_show_' . $delta,
variable_get('gallery_block_show_' . $delta, array('title', 'heading')),
array('title' => 'Title',
'date' => 'Date',
'views' => 'View Count',
'owner' => 'Item owner',
'heading' => 'Heading',
'fullSize' => 'Full Size'),
t('Choose the item metadata you\'d like to display'));
return $output;
case 'save':
variable_set('gallery_block_block_' . $delta, $edit['gallery_block_block_' . $delta]);
variable_set('gallery_block_show_' . $delta, $edit['gallery_block_show_' . $delta]);
break;
case 'view':
list ($success, $ret) = _gallery_init(true);
if (!$success) {
gallery_error(t('Unable to initialize embedded Gallery'), $ret);
return;
}
$params['block'] = variable_get('gallery_block_block_' . $delta, 'randomImage');
$params['show'] = implode('|', variable_get('gallery_block_show_' . $delta, array()));
// TODO: parameterize this
$params['maxSize'] = 160;
$block = array();
list($ret, $content) = GalleryEmbed::getImageBlock($params);
if ($ret->isError()) {
gallery_error(t('Unable to get Gallery image block'), $ret);
return;
} else {
if ($content) {
$block['subject'] = $typeMap[$params['block']];
$block['content'] = '<center>' . $content . '</center>';
case 'list':
$blocks[0]['info'] = t('Gallery Block');
return $blocks;
case 'configure':
$form['gallery_block_block_'. $delta] = array(
'#type' => 'select',
'#title' => t('Image type'),
'#default_value' => variable_get('gallery_block_block_' . $delta, 'randomImage'),
'#options' => $typeMap,
'#description' => t("Pick the type of image you'd like to see"),
);
$form['gallery_block_show_'. $delta] = array(
'#type' => 'checkboxes',
'#title' => t('Image data'),
'#default_value' => variable_get('gallery_block_show_' . $delta, array('title', 'heading')),
'#options' => array('title' => 'Title', 'date' => 'Date', 'views' => 'View Count', 'owner' => 'Item owner', 'heading' => 'Heading', 'fullSize' => 'Full Size'),
'#description' => t("Choose the item metadata you'd like to display")
);
return $form;
case 'save':
variable_set('gallery_block_block_' . $delta, $edit['gallery_block_block_' . $delta]);
variable_set('gallery_block_show_' . $delta, $edit['gallery_block_show_' . $delta]);
break;
case 'view':
list ($success, $ret) = _gallery_init(true);
if (!$success) {
gallery_error(t('Unable to initialize embedded Gallery'), $ret);
return;
}
}
$ret = GalleryEmbed::done();
if ($ret->isError()) {
gallery_error(t('Unable to complete Gallery request'), $ret);
return;
}
return $block;
$params['blocks'] = variable_get('gallery_block_block_' . $delta, 'randomImage');
$params['show'] = implode('|', array_keys(variable_get('gallery_block_show_' . $delta, array())));
// TODO: parameterize this
$params['maxSize'] = 160;
$block = array();
list($ret, $content) = GalleryEmbed::getImageBlock($params);
if ($ret->isError()) {
gallery_error(t('Unable to get Gallery image block'), $ret);
return;
} else {
if ($content) {
$block['subject'] = $typeMap[$params['blocks']];
$block['content'] = '<center>' . $content . '</center>';
}
}
$ret = GalleryEmbed::done();
if ($ret->isError()) {
gallery_error(t('Unable to complete Gallery request'), $ret);
return;
}
return $block;
}
}
......@@ -220,42 +229,42 @@ function gallery_block($op = 'list', $delta = 0, $edit = array()) {
*/
function gallery_search($op = 'search', $keys = null) {
switch ($op) {
case 'name':
return t('gallery');
case 'search':
$find = array();
list ($success, $ret) = _gallery_init(true);
if (!$success) {
gallery_error(t('Unable to initialize embedded Gallery'), $ret);
return;
}
list ($ret, $results) = GalleryEmbed::searchScan($keys, 20);
if (!$ret->isError()) {
$urlGenerator =& $GLOBALS['gallery']->getUrlGenerator();
foreach ($results as $name => $module) {
if (count($module['results']) > 0) {
foreach ($module['results'] as $result) {
$excerpt = array();
foreach ($result['fields'] as $field) {
$words = search_keywords_split($keys);
foreach ($words as $word) {
if (preg_match("/$word/", $field['value'])) {
$excerpt[] = $field['key'] .': '.search_excerpt($keys, $field['value']);
}
}
}
$link = str_replace('&amp;', '&', $urlGenerator->generateUrl(array('itemId' => $result['itemId'])));
$find[] = array('title' => $result['fields'][0]['value'],
'link' => $link,
'type' => $module['name'],
'snippet' => implode('<br />', $excerpt));
}
}
case 'name':
return t('gallery');
case 'search':
$find = array();
list ($success, $ret) = _gallery_init(true);
if (!$success) {
gallery_error(t('Unable to initialize embedded Gallery'), $ret);
return;
}
}
return $find;
list ($ret, $results) = GalleryEmbed::searchScan($keys, 20);
if (!$ret->isError()) {
$urlGenerator =& $GLOBALS['gallery']->getUrlGenerator();
foreach ($results as $name => $module) {
if (count($module['results']) > 0) {
foreach ($module['results'] as $result) {
$excerpt = array();
$words = search_index_split($keys);
foreach ($result['fields'] as $field) {
foreach ($words as $word) {
if (preg_match("/$word/i", $field['value'])) {
$excerpt[] = $field['key'] .': '.search_excerpt($words, $field['value']);
}
}
}
$link = str_replace('&amp;', '&', $urlGenerator->generateUrl(array('itemId' => $result['itemId'])));
$find[] = array('title' => $result['fields'][0]['value'],
'link' => $link,
'type' => $module['name'],
'snippet' => implode('<br />', $excerpt));
}
}
}
}
return $find;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment