function photos_block in Album Photos 6.2
File
- ./
photos.module, line 675
Code
function photos_block($op = 'list', $delta = 0, $edit = array()) {
global $user;
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Latest images');
$blocks[1]['info'] = t('User\'s images');
$blocks[2]['info'] = t('Photo information');
$blocks[3]['info'] = t('Random images');
return $blocks;
case 'configure':
switch ($delta) {
case '2':
$form['photos_block_num_2'] = array(
'#type' => 'radios',
'#title' => t('Show sub-album info'),
'#default_value' => variable_get('photos_block_num_2', 1),
'#options' => array(
t('Disabled'),
t('Enabled'),
),
);
break;
default:
$num = drupal_map_assoc(array(
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
15,
20,
25,
30,
40,
));
$form['photos_block_num_' . $delta] = array(
'#type' => 'select',
'#title' => t('Show several images'),
'#default_value' => variable_get('photos_block_num_' . $delta, 10),
'#options' => $num,
);
break;
}
return $form;
case 'save':
variable_set('photos_block_num_' . $delta, $edit['photos_block_num_' . $delta]);
break;
case 'view':
$block = array();
$count = variable_get('photos_block_num_' . $delta, 10);
switch ($delta) {
case '0':
if (user_access('view photo') && ($content = _photos_block_image('latest', $count, 'photos/image'))) {
$block['subject'] = t('Latest images');
$block['content'] = $content;
}
return $block;
case '1':
if (arg(0) == 'photos') {
switch (arg(1)) {
case 'image':
$uid = db_result(db_query('SELECT uid FROM {files} WHERE fid = %d', arg(2)));
break;
case 'user':
$uid = arg(2);
}
}
if (arg(0) == 'node' && is_numeric(arg(1))) {
$uid = db_result(db_query('SELECT uid FROM {node} WHERE nid = %d', arg(1)));
}
if ($uid && ($content = _photos_block_image('user', $count, "photos/user/{$uid}/image", $uid))) {
$block['subject'] = t('%name\'s images', array(
'%name' => $content[1],
));
$block['content'] = $content[0];
}
return $block;
case '2':
if (arg(0) == 'photos' && arg(1) == 'image' && is_numeric(arg(2))) {
if ($image = db_fetch_array(db_query(db_rewrite_sql('SELECT n.nid, n.title, f.timestamp, f.filemime, f.fid, u.name, u.picture, u.uid, p.count, p.comcount, p.exif, p.des FROM {x_image} p INNER JOIN {files} f ON p.fid = f.fid INNER JOIN {node} n ON p.pid = n.nid INNER JOIN {users} u ON f.uid = u.uid WHERE p.fid = %d'), arg(2)))) {
$image['pager'] = photos_image_pager($image['fid'], $image['nid']);
$item[] = l(t('Copy image to share code'), "photos/zoom/{$image['fid']}");
if ($image['exif'] && variable_get('photos_exif', 0)) {
$item[] = l(t('View image Exif information'), "photos/zoom/{$image['fid']}/exif");
}
if (variable_get('photos_slide', 0)) {
$image['slide_url'] = url('photos/album/' . $image['nid'] . '/slide');
}
$image['links'] = theme('item_list', $item);
if (variable_get('photos_block_num_2', 0)) {
$result = db_query_range('SELECT n.nid, n.title, u.uid, u.name FROM {node} n INNER JOIN {x_node} a ON n.nid = a.nid INNER JOIN {users} u ON n.uid = u.uid WHERE a.fid = %d ORDER BY n.nid DESC', $image['fid'], 0, 10);
while ($node = db_fetch_array($result)) {
$image['sub_album'][$node['nid']] = $node;
$image['sub_album'][$node['nid']]['geturl'] = url('photos/data/sub_album/' . $node['nid'] . '/block_new/json.json');
$image['sub_album'][$node['nid']]['url'] = url('photos/sub_album/' . $node['nid']);
$image['sub_album'][$node['nid']]['user'] = theme('username', (object) $node);
$image['sub_album'][$node['nid']]['info'] = t('!name in !time to create', array(
'!name' => $node['name'],
'!time' => format_date($image['timestamp'], 'small'),
));
}
}
$block['subject'] = t('Photo information');
$block['content'] = theme('photos_imageblock', $image);
}
}
return $block;
case '3':
if (user_access('view photo') && ($content = _photos_block_image('rand', $count))) {
$block['subject'] = t('Random images');
$block['content'] = $content;
}
return $block;
}
}
}