| 1 |
<?php
|
| 2 |
// $Id: node_gallery.module,v 1.16 2009/05/06 01:57:01 kmonty Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Node gallery module file.
|
| 7 |
*/
|
| 8 |
|
| 9 |
define("NODE_GALLERY_PERM_ADMIN_GALLERY", 'administer node gallery');
|
| 10 |
define("NODE_GALLERY_PERM_VIEW_GALLERY", 'view node gallery');
|
| 11 |
if (module_exists('token')) {
|
| 12 |
module_load_include('inc', 'node_gallery', 'node_gallery.token');
|
| 13 |
}
|
| 14 |
|
| 15 |
module_load_include('inc', 'node_gallery', 'node_gallery.model');
|
| 16 |
|
| 17 |
/**
|
| 18 |
* Implementation of hook_init().
|
| 19 |
* Add our CSS file.
|
| 20 |
*/
|
| 21 |
function node_gallery_init() {
|
| 22 |
drupal_add_css(drupal_get_path('module', 'node_gallery') ."/node_gallery.css");
|
| 23 |
}
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Implementation of hook_perm().
|
| 27 |
*/
|
| 28 |
function node_gallery_perm() {
|
| 29 |
return array(NODE_GALLERY_PERM_ADMIN_GALLERY, NODE_GALLERY_PERM_VIEW_GALLERY);
|
| 30 |
}
|
| 31 |
|
| 32 |
/**
|
| 33 |
* Implementation of hook_menu()
|
| 34 |
*/
|
| 35 |
function node_gallery_menu() {
|
| 36 |
$items = array();
|
| 37 |
|
| 38 |
$items['admin/build/node_gallery'] = array(
|
| 39 |
'title' => 'Node Gallery',
|
| 40 |
'description' => t('Create and manage your Node Gallery relationships.'),
|
| 41 |
'page callback' => 'node_gallery_config_list',
|
| 42 |
'access arguments' => array(NODE_GALLERY_PERM_ADMIN_GALLERY),
|
| 43 |
'file' => 'node_gallery.admin.inc',
|
| 44 |
'type' => MENU_NORMAL_ITEM,
|
| 45 |
);
|
| 46 |
$items['admin/build/node_gallery/list'] = array(
|
| 47 |
'title' => 'List',
|
| 48 |
'type' => MENU_DEFAULT_LOCAL_TASK,
|
| 49 |
'weight' => -10,
|
| 50 |
);
|
| 51 |
$items['admin/build/node_gallery/add'] = array(
|
| 52 |
'title' => 'Add a Gallery Relationship',
|
| 53 |
'page callback' => 'drupal_get_form',
|
| 54 |
'page arguments' => array('node_gallery_config_form'),
|
| 55 |
'access arguments' => array(NODE_GALLERY_PERM_ADMIN_GALLERY),
|
| 56 |
'file' => 'node_gallery.admin.inc',
|
| 57 |
'type' => MENU_LOCAL_TASK,
|
| 58 |
);
|
| 59 |
$items['admin/build/node_gallery/edit/%node_gallery_config'] = array(
|
| 60 |
'title' => 'Node Gallery Config Edit',
|
| 61 |
'page callback' => 'drupal_get_form',
|
| 62 |
'page arguments' => array('node_gallery_config_form', 4),
|
| 63 |
'access arguments' => array(NODE_GALLERY_PERM_ADMIN_GALLERY),
|
| 64 |
'file' => 'node_gallery.admin.inc',
|
| 65 |
'type' => MENU_CALLBACK,
|
| 66 |
);
|
| 67 |
$items['admin/build/node_gallery/delete/%node_gallery_config'] = array(
|
| 68 |
'title' => 'Node Gallery Config Delete',
|
| 69 |
'page callback' => 'drupal_get_form',
|
| 70 |
'page arguments' => array('node_gallery_config_delete_form', 4),
|
| 71 |
'access arguments' => array(NODE_GALLERY_PERM_ADMIN_GALLERY),
|
| 72 |
'file' => 'node_gallery.admin.inc',
|
| 73 |
'type' => MENU_CALLBACK,
|
| 74 |
);
|
| 75 |
|
| 76 |
$items['galleries'] = array(
|
| 77 |
'title' => 'Galleries List',
|
| 78 |
'page callback' => 'node_gallery_list',
|
| 79 |
'access arguments' => array(NODE_GALLERY_PERM_VIEW_GALLERY),
|
| 80 |
'file' => 'node_gallery.pages.inc',
|
| 81 |
'type' => MENU_NORMAL_ITEM,
|
| 82 |
);
|
| 83 |
$items['galleries/%user'] = array(
|
| 84 |
'title' => 'My Galleries',
|
| 85 |
'title callback' => 'galleries_title',
|
| 86 |
'title arguments' => array(1),
|
| 87 |
'page callback' => 'node_gallery_list',
|
| 88 |
'page arguments' => array(1),
|
| 89 |
'access arguments' => array(NODE_GALLERY_PERM_VIEW_GALLERY),
|
| 90 |
'file' => 'node_gallery.pages.inc',
|
| 91 |
'type' => MENU_NORMAL_ITEM,
|
| 92 |
);
|
| 93 |
$items['node/%node_gallery_gallery/upload'] = array(
|
| 94 |
'title' => 'Upload Images',
|
| 95 |
'page callback' => 'drupal_get_form',
|
| 96 |
'page arguments' => array('node_gallery_upload_form', 1),
|
| 97 |
'access callback' => 'node_gallery_user_access',
|
| 98 |
'access arguments' => array('upload', 1),
|
| 99 |
'file' => 'node_gallery.pages.inc'
|
| 100 |
);
|
| 101 |
$items['node/%node_gallery_gallery/edit/images'] = array(
|
| 102 |
'title' => 'Edit Images',
|
| 103 |
'page callback' => 'drupal_get_form',
|
| 104 |
'page arguments' => array('node_gallery_edit_images_form', 1),
|
| 105 |
'access callback' => 'node_gallery_user_access',
|
| 106 |
'access arguments' => array('edit image', 1),
|
| 107 |
'file' => 'node_gallery.pages.inc',
|
| 108 |
);
|
| 109 |
|
| 110 |
$items['node_gallery/upload/js'] = array(
|
| 111 |
'title' => 'Gallery Image Upload',
|
| 112 |
'page callback' => 'node_gallery_upload_js',
|
| 113 |
'access callback' => TRUE,
|
| 114 |
'file' => 'node_gallery.pages.inc',
|
| 115 |
'type' => MENU_CALLBACK,
|
| 116 |
);
|
| 117 |
|
| 118 |
return $items;
|
| 119 |
}
|
| 120 |
|
| 121 |
/**
|
| 122 |
* Implementation of hook_menu_alter()
|
| 123 |
*/
|
| 124 |
function node_gallery_menu_alter(&$items) {
|
| 125 |
// Disable all Node Gallery image types from showing up on node/add
|
| 126 |
$types = gallery_config_gateway::get_types();
|
| 127 |
|
| 128 |
//Only do the foreach if there is a type
|
| 129 |
if ($types) {
|
| 130 |
foreach ($types as $type) {
|
| 131 |
$items['node/add/'. $type->image_type]['access callback'] = FALSE;
|
| 132 |
$items['node/add/'. str_replace('_', '-', $type->image_type)]['access callback'] = FALSE;
|
| 133 |
}
|
| 134 |
}
|
| 135 |
} //node_gallery_menu_alter()
|
| 136 |
|
| 137 |
/**
|
| 138 |
* Implementation of hook_theme()
|
| 139 |
*/
|
| 140 |
function node_gallery_theme() {
|
| 141 |
return array(
|
| 142 |
'image_view' => array(
|
| 143 |
'arguments' => array('imagecache' => NULL, 'image' => NULL),
|
| 144 |
'file' => 'node_gallery.themes.inc',
|
| 145 |
),
|
| 146 |
'gallery_cover_view' => array(
|
| 147 |
'template' => 'gallery_cover_view',
|
| 148 |
'arguments' => array('gallery' => NULL, 'config' => NULL),
|
| 149 |
'file' => 'node_gallery.themes.inc',
|
| 150 |
),
|
| 151 |
'gallery_list' => array(
|
| 152 |
'arguments' => array('items' => NULL, 'account' => NULL),
|
| 153 |
'file' => 'node_gallery.themes.inc',
|
| 154 |
),
|
| 155 |
'gallery_edit_images_form' => array(
|
| 156 |
'file' => 'node_gallery.themes.inc',
|
| 157 |
'arguments' => array('form' => NULL),
|
| 158 |
),
|
| 159 |
'gallery_images_list' => array(
|
| 160 |
'arguments' => array('gallery' => NULL, 'config' => NULL),
|
| 161 |
'file' => 'node_gallery.themes.inc',
|
| 162 |
),
|
| 163 |
'gallery_image_navigator' => array(
|
| 164 |
'arguments' => array('navigator' => NULL, 'image' => NULL),
|
| 165 |
'file' => 'node_gallery.themes.inc',
|
| 166 |
),
|
| 167 |
'gallery_image_thumbnail' => array(
|
| 168 |
'arguments' => array('image' => NULL, 'config' => NULL),
|
| 169 |
'file' => 'node_gallery.themes.inc',
|
| 170 |
),
|
| 171 |
'gallery_image_lightbox2' => array(
|
| 172 |
'arguments' => array('image' => NULL, 'config' => NULL, 'gallery' => NULL),
|
| 173 |
'file' => 'node_gallery.themes.inc',
|
| 174 |
),
|
| 175 |
'gallery_teaser' => array(
|
| 176 |
'arguments' => array('gallery' => NULL, 'config' => NULL),
|
| 177 |
'file' => 'node_gallery.themes.inc',
|
| 178 |
),
|
| 179 |
'gallery_meta' => array(
|
| 180 |
'arguments' => array('gallery' => NULL),
|
| 181 |
'file' => 'node_gallery.themes.inc',
|
| 182 |
),
|
| 183 |
'node_gallery_image' => array(
|
| 184 |
'arguments' => array('config' => NULL, 'node' => NULL),
|
| 185 |
'file' => 'node_gallery.themes.inc',
|
| 186 |
),
|
| 187 |
'node_gallery_teaser' => array(
|
| 188 |
'arguments' => array('config' => NULL, 'node' => NULL),
|
| 189 |
'file' => 'node_gallery.themes.inc',
|
| 190 |
),
|
| 191 |
);
|
| 192 |
}
|
| 193 |
|
| 194 |
/**
|
| 195 |
* Implementation of hook_nodeapi().
|
| 196 |
*/
|
| 197 |
function node_gallery_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
|
| 198 |
$function = '_node_gallery_'. $op;
|
| 199 |
if (function_exists($function)) {
|
| 200 |
call_user_func($function, $node, $a3, $a4);
|
| 201 |
}
|
| 202 |
}
|
| 203 |
|
| 204 |
/**
|
| 205 |
* Implementation of hook_nodeapi(op='load').
|
| 206 |
*/
|
| 207 |
function _node_gallery_load(&$node) {
|
| 208 |
if (gallery_config_gateway::get_types('gallery', $node->type)) {
|
| 209 |
$node->images = gallery_gateway::get_images($node->nid);
|
| 210 |
$node->image_count = count($node->images);
|
| 211 |
}
|
| 212 |
if (gallery_config_gateway::get_types('image', $node->type)) {
|
| 213 |
$image = ImageGateway::get_file($node->nid);
|
| 214 |
if (!empty($image)) {
|
| 215 |
foreach (get_object_vars($image) as $k => $v) {
|
| 216 |
$node->$k = $v;
|
| 217 |
}
|
| 218 |
}
|
| 219 |
}
|
| 220 |
}
|
| 221 |
|
| 222 |
/**
|
| 223 |
* Implementation of hook_nodeapi(op='view').
|
| 224 |
*/
|
| 225 |
function _node_gallery_view(&$node, $teaser, $page) {
|
| 226 |
if (gallery_config_gateway::get_types('image', $node->type)) {
|
| 227 |
$config = gallery_config_gateway::get_by($node->gid, 'id');
|
| 228 |
$gallery = new Gallery(array('nid' => $node->gid));
|
| 229 |
if ($config->content_display == 'gallery') {
|
| 230 |
$node->content['body']['#value'] = $gallery->get_content($teaser);
|
| 231 |
$tmp = $node->content['body'];
|
| 232 |
unset($node->content);
|
| 233 |
$node->content['body'] = $tmp;
|
| 234 |
}
|
| 235 |
}
|
| 236 |
}
|
| 237 |
|
| 238 |
/**
|
| 239 |
* Implementation of hook_nodeapi(op='alter').
|
| 240 |
*/
|
| 241 |
function _node_gallery_alter(&$node) {
|
| 242 |
if (gallery_config_gateway::get_types('image', $node->type)) {
|
| 243 |
$config = gallery_config_gateway::get_by($node->gid, 'id');
|
| 244 |
if ($config->content_display == 'gallery') {
|
| 245 |
//we'll display gallery's comments, not image's;
|
| 246 |
$node->old_comment = $node->comment;
|
| 247 |
$node->comment = 0;
|
| 248 |
}
|
| 249 |
}
|
| 250 |
}
|
| 251 |
|
| 252 |
/**
|
| 253 |
* Implementation of hook_nodeapi(op='delete').
|
| 254 |
*/
|
| 255 |
function _node_gallery_delete(&$node) {
|
| 256 |
global $user;
|
| 257 |
|
| 258 |
if (gallery_config_gateway::get_types('gallery', $node->type)) {
|
| 259 |
gallery_gateway::delete($node->nid);
|
| 260 |
if (!empty($node->images)) {
|
| 261 |
foreach ($node->images as $image) {
|
| 262 |
$operations[] = array('images_delete_process', array($image));
|
| 263 |
}
|
| 264 |
$batch = array(
|
| 265 |
'operations' => $operations,
|
| 266 |
'finished' => 'images_process_finished',
|
| 267 |
'title' => t('Processing Gallery Delete.'),
|
| 268 |
'init_message' => t('Gallery Delete is starting.'),
|
| 269 |
'progress_message' => t('Processed @current out of @total.'),
|
| 270 |
'error_message' => t('Gallery Delete has encountered an error.'),
|
| 271 |
);
|
| 272 |
|
| 273 |
batch_set($batch);
|
| 274 |
batch_process('galleries/'. $user->uid);
|
| 275 |
}
|
| 276 |
}
|
| 277 |
if (gallery_config_gateway::get_types('image', $node->type)) {
|
| 278 |
ImageGateway::delete($node);
|
| 279 |
}
|
| 280 |
}
|
| 281 |
|
| 282 |
function node_gallery_config_load($type) {
|
| 283 |
return gallery_config_gateway::get_by($type);
|
| 284 |
}
|
| 285 |
|
| 286 |
function node_gallery_gallery_load($nid) {
|
| 287 |
static $galleries;
|
| 288 |
|
| 289 |
if (empty($galleries[$nid])) {
|
| 290 |
if (gallery_config_gateway::get_by($nid, 'id')) {
|
| 291 |
$galleries[$nid] = new Gallery(node_load($nid));
|
| 292 |
}
|
| 293 |
}
|
| 294 |
return $galleries[$nid];
|
| 295 |
}
|
| 296 |
|
| 297 |
function galleries_title($user) {
|
| 298 |
return t('!user\'s Galleries', array('!user' => $user->name));
|
| 299 |
}
|
| 300 |
|
| 301 |
function node_gallery_user_access($op, $gallery = NULL) {
|
| 302 |
global $user;
|
| 303 |
$gallery_config = gallery_config_gateway::get_by($gallery->type);
|
| 304 |
|
| 305 |
switch ($op) {
|
| 306 |
case 'view':
|
| 307 |
return user_access(NODE_GALLERY_PERM_VIEW_GALLERY);
|
| 308 |
break;
|
| 309 |
case 'upload':
|
| 310 |
if ($user->uid == $gallery->uid || $user->uid == 1) {
|
| 311 |
return user_access('create '. $gallery_config->image_type .' content');
|
| 312 |
}
|
| 313 |
else {
|
| 314 |
return user_access('edit any '. $gallery->type .' content');
|
| 315 |
}
|
| 316 |
break;
|
| 317 |
case 'edit':
|
| 318 |
if ($user->uid == $gallery->uid) {
|
| 319 |
return user_access('edit own '. $gallery->type .' content') || user_access('edit any '. $gallery->type .' content');
|
| 320 |
}
|
| 321 |
else {
|
| 322 |
return user_access('edit any '. $gallery->type .' content');
|
| 323 |
}
|
| 324 |
break;
|
| 325 |
case 'edit image':
|
| 326 |
if ($user->uid == $gallery->uid) {
|
| 327 |
return user_access('edit own '. $gallery_config->image_type .' content') || user_access('edit any '. $gallery_config->image_type .' content');
|
| 328 |
}
|
| 329 |
else {
|
| 330 |
return user_access('edit any '. $gallery_config->image_type .' content');
|
| 331 |
}
|
| 332 |
break;
|
| 333 |
case 'delete':
|
| 334 |
if ($user->uid == $gallery->uid) {
|
| 335 |
return user_access('delete own '. $gallery_config->image_type .' content') || user_access('delete any '. $gallery_config->image_type .' content');
|
| 336 |
}
|
| 337 |
else {
|
| 338 |
return user_access('delete any '. $gallery_config->image_type .' content');
|
| 339 |
}
|
| 340 |
break;
|
| 341 |
case 'create':
|
| 342 |
return user_access('create '. $gallery->type .' content');
|
| 343 |
break;
|
| 344 |
}
|
| 345 |
}
|
| 346 |
|
| 347 |
function node_gallery_image_user_access($op, $image = NULL) {
|
| 348 |
global $user;
|
| 349 |
|
| 350 |
switch ($op) {
|
| 351 |
case 'edit':
|
| 352 |
if ($user->uid == $image->uid) {
|
| 353 |
return user_access("edit own $image->type content") || user_access("edit any $image->type content");
|
| 354 |
}
|
| 355 |
if ($user->uid != $image->uid) {
|
| 356 |
return user_access("edit any $image->type content");
|
| 357 |
}
|
| 358 |
break;
|
| 359 |
}
|
| 360 |
}
|
| 361 |
|
| 362 |
function node_gallery_operations($type, $a2 = NULL) {
|
| 363 |
global $user;
|
| 364 |
$items = array();
|
| 365 |
|
| 366 |
switch ($type) {
|
| 367 |
case 'list':
|
| 368 |
$account = $a2;
|
| 369 |
//all gallery list or current user's gallery list;
|
| 370 |
if ($account->uid == $user->uid) {
|
| 371 |
$node_types = node_get_types();
|
| 372 |
$types = gallery_config_gateway::get_types();
|
| 373 |
foreach (array_keys($types) as $type) {
|
| 374 |
if (user_access("create $type content", $user)) {
|
| 375 |
$items[] = array('title' => t('Create !type', array('!type' => $node_types[$type]->name)),
|
| 376 |
'href' => 'node/add/'. $type);
|
| 377 |
}
|
| 378 |
}
|
| 379 |
}
|
| 380 |
break;
|
| 381 |
case 'cover':
|
| 382 |
$gallery = $a2;
|
| 383 |
if (node_gallery_user_access('edit', $gallery)) {
|
| 384 |
$items[] = array('title' => t('Edit gallery'), 'href' => "node/$gallery->nid/edit", 'query' => array('destination' => "galleries/$gallery->uid"));
|
| 385 |
}
|
| 386 |
if (node_gallery_user_access('upload', $gallery)) {
|
| 387 |
$items[] = array('title' => t('Upload images'), 'href' => "node/$gallery->nid/upload");
|
| 388 |
}
|
| 389 |
if (node_gallery_user_access('delete', $gallery)) {
|
| 390 |
$items[] = array('title' => t('Delete gallery'), 'href' => "node/$gallery->nid/delete",
|
| 391 |
'query' => array('destination' => "galleries/$gallery->uid"));
|
| 392 |
}
|
| 393 |
break;
|
| 394 |
case 'gallery':
|
| 395 |
$gallery = $a2;
|
| 396 |
if (node_gallery_user_access('edit', $gallery)) {
|
| 397 |
$items[] = array('title' => t('Edit gallery'), 'href' => "node/$gallery->nid/edit",
|
| 398 |
'query' => array('destination' => "node/$gallery->nid"));
|
| 399 |
}
|
| 400 |
if (node_gallery_user_access('upload', $gallery)) {
|
| 401 |
$items[] = array('title' => t('Upload images'), 'href' => "node/$gallery->nid/upload",
|
| 402 |
'query' => array('destination' => "node/$gallery->nid"));
|
| 403 |
}
|
| 404 |
if (node_gallery_user_access('edit image', $gallery) && $gallery->image_count) {
|
| 405 |
$items[] = array('title' => t('Edit images'), 'href' => "node/$gallery->nid/edit/images",
|
| 406 |
'query' => array('destination' => "node/$gallery->nid"));
|
| 407 |
}
|
| 408 |
if (node_gallery_user_access('delete', $gallery)) {
|
| 409 |
$items[] = array('title' => t('Delete gallery'), 'href' => "node/$gallery->nid/delete",
|
| 410 |
'query' => array('destination' => "galleries/$gallery->uid"));
|
| 411 |
}
|
| 412 |
$items[] = array('title' => t('Back to !name\'s gallery list', array('!name' => $gallery->name)), 'href' => 'galleries/'. $gallery->uid);
|
| 413 |
break;
|
| 414 |
case 'image':
|
| 415 |
$image = $a2;
|
| 416 |
if (node_gallery_image_user_access('edit', $image)) {
|
| 417 |
$items[] = array('title' => t('Edit image'), 'href' => 'node/'. $image->nid ."/edit");
|
| 418 |
}
|
| 419 |
$items[] = array('title' => t('Back to gallery'), 'href' => 'node/'. $image->gid);
|
| 420 |
break;
|
| 421 |
}
|
| 422 |
return theme('links', $items, array('class' => 'gallery-operations'));
|
| 423 |
}
|
| 424 |
|
| 425 |
/**
|
| 426 |
* We can't put this function to node_gallery.pages.inc
|
| 427 |
* because the batch was started after reboot.
|
| 428 |
*
|
| 429 |
* @param unknown_type $file
|
| 430 |
* @param unknown_type $fid
|
| 431 |
* @param unknown_type $num
|
| 432 |
* @param unknown_type $context
|
| 433 |
*/
|
| 434 |
function images_upload_process($form, $image, &$context) {
|
| 435 |
|
| 436 |
$image->save($form);
|
| 437 |
|
| 438 |
$context['results'][] = $image_form_state['values']['title'];
|
| 439 |
$context['message'] = t('Now uploading %node', array('%node' => $image_form_state['values']['title']));
|
| 440 |
}
|
| 441 |
|
| 442 |
function images_delete_process($image, &$context) {
|
| 443 |
$image->delete();
|
| 444 |
|
| 445 |
$context['results'][] = $image->title;
|
| 446 |
$context['message'] = t('Now deleting %node', array('%node' => $image->title));
|
| 447 |
}
|
| 448 |
|
| 449 |
function images_process_finished($success, $results, $operations) {
|
| 450 |
if ($success) {
|
| 451 |
// Here we do something meaningful with the results.
|
| 452 |
//$message .= theme('item_list', $results);
|
| 453 |
}
|
| 454 |
else {
|
| 455 |
// An error occurred.
|
| 456 |
// $operations contains the operations that remained unprocessed.
|
| 457 |
$error_operation = reset($operations);
|
| 458 |
$message = 'An error occurred while processing '. $error_operation[0] .' with arguments :'. print_r($error_operation[0], TRUE);
|
| 459 |
}
|
| 460 |
drupal_set_message($message);
|
| 461 |
}
|
| 462 |
|
| 463 |
/**
|
| 464 |
* Implementation of hook_link_alter().
|
| 465 |
*/
|
| 466 |
function node_gallery_link_alter(&$links, $node) {
|
| 467 |
if (gallery_config_gateway::get_types('image', $node->type)) {
|
| 468 |
$conf = gallery_config_gateway::get_by($node->gid, 'id');
|
| 469 |
if ($conf->content_display == 'gallery') {
|
| 470 |
foreach ($links as $k => $link) {
|
| 471 |
if (strpos($k, 'comment') !== FALSE && is_array($link)) {
|
| 472 |
foreach ($link as $k2 => $v) {
|
| 473 |
if ($k2 == 'href') {
|
| 474 |
$links[$k][$k2] = preg_replace('/(\w+)\/(\d+)/i', "\$1/". $node->gid, $v);
|
| 475 |
}
|
| 476 |
if ($k2 == 'query') {
|
| 477 |
$links[$k][$k2] = is_array($v) ? array_merge($v, array('destination' => 'node/'. $node->nid)) : $v ."&destinatioin=$node->nid";
|
| 478 |
}
|
| 479 |
}
|
| 480 |
}
|
| 481 |
}
|
| 482 |
}
|
| 483 |
}
|
| 484 |
}
|
| 485 |
|
| 486 |
/**
|
| 487 |
* Implementation of hook_theme_registry_alter().
|
| 488 |
*/
|
| 489 |
function node_gallery_theme_registry_alter(&$theme_registry) {
|
| 490 |
$theme_registry['node']['theme paths'][] = drupal_get_path('module', 'node_gallery');
|
| 491 |
}
|
| 492 |
|
| 493 |
function node_gallery_preprocess_node(&$vars) {
|
| 494 |
$node = $vars['node'];
|
| 495 |
$page = $vars['page'];
|
| 496 |
|
| 497 |
if (gallery_config_gateway::get_types('gallery', $node->type)) {
|
| 498 |
$config = gallery_config_gateway::get_by($node->type);
|
| 499 |
|
| 500 |
if ($page) {
|
| 501 |
$vars['gallery_operations'] = node_gallery_operations('gallery', $node);
|
| 502 |
$vars['gallery'] = theme('gallery_images_list', $node, $config);
|
| 503 |
}
|
| 504 |
else {
|
| 505 |
$vars['gallery'] = theme('gallery_teaser', $node, $config);
|
| 506 |
}
|
| 507 |
|
| 508 |
array_pop($vars['template_files']);
|
| 509 |
$vars['template_files'][] = "node-gallery-default";
|
| 510 |
$vars['template_files'][] = "node-" . $node->type;
|
| 511 |
}
|
| 512 |
elseif (gallery_config_gateway::get_types('image', $node->type)) {
|
| 513 |
$config = gallery_config_gateway::get_by($node->gid, 'id');
|
| 514 |
$gallery = new Gallery(array('nid' => $node->gid));
|
| 515 |
if ($page) {
|
| 516 |
$vars['image_navigator'] = theme('gallery_image_navigator', $gallery->get_image_navigator($node->nid), $node);
|
| 517 |
|
| 518 |
$vars['image'] = theme('node_gallery_image', $config, $node);
|
| 519 |
|
| 520 |
if ($config->content_display == 'gallery' && function_exists('comment_render')) {
|
| 521 |
$gallery_node = node_load($node->gid);
|
| 522 |
if ($gallery_node->comment) {
|
| 523 |
$vars['comments'] = comment_render($gallery_node);
|
| 524 |
}
|
| 525 |
}
|
| 526 |
elseif ($config->content_display == 'image' && function_exists('comment_render') && $node->old_comment) {
|
| 527 |
$vars['comments'] = comment_render($node);
|
| 528 |
}
|
| 529 |
}
|
| 530 |
else {
|
| 531 |
$vars['image'] = theme('node_gallery_image', $config, $node);
|
| 532 |
}
|
| 533 |
|
| 534 |
|
| 535 |
array_pop($vars['template_files']);
|
| 536 |
$vars['template_files'][] = "node-image-default";
|
| 537 |
$vars['template_files'][] = "node-" . $node->type;
|
| 538 |
}
|
| 539 |
}
|