lightbox2.formatter.inc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <?php
  2. // $Id: lightbox2.formatter.inc,v 1.1.2.30 2010/09/22 10:47:15 snpower Exp $
  3. /**
  4. * @file
  5. * Lightbox2 formatter hooks and callbacks.
  6. */
  7. /**
  8. * Theme function for displaying the lightbox2 trigger image in an imagefield.
  9. *
  10. * @param $path
  11. * The path to the image to be displayed.
  12. * @param $alt
  13. * The image alternative text.
  14. * @param $title
  15. * The image title.
  16. * @param $attributes
  17. * An array of image attributes, e.g. class name.
  18. * @return
  19. * HTML output for displaying the image.
  20. */
  21. function theme_lightbox2_image($variables) {
  22. $path = $variables['path'];
  23. $item = $variables['item'];
  24. $image_style = $variables['image_style'];
  25. $node_id = $variables['node_id'];
  26. $field_name = $variables['field_name'];
  27. if (!$variables["lightbox_style"]) {
  28. $path['path'] = file_create_url($item['uri']);
  29. }
  30. else {
  31. $path['path'] = image_style_url($variables["lightbox_style"], $item['uri']);
  32. }
  33. // Lightbox type
  34. $rel = $variables['lightbox_type'];
  35. // Grouping
  36. $rel .= '[';
  37. $group = variable_get('lightbox2_image_group_node_id', 1);
  38. switch ($group) {
  39. // No groups
  40. case '0':
  41. break;
  42. // Group by field name
  43. case '1':
  44. $rel .= $field_name;
  45. break;
  46. // Group by node id
  47. case '2':
  48. $rel .= $node_id;
  49. break;
  50. // Group by field name and node id
  51. case '3':
  52. $rel .= $field_name . '_' . $node_id;
  53. break;
  54. // All nodes and fields in same group
  55. case '4':
  56. $rel .= 'group';
  57. break;
  58. }
  59. $rel .= ']';
  60. // Title Start
  61. $rel .= '[' . $item['title'];
  62. // Download Link
  63. if (user_access('download original image')) {
  64. $rel .= '<p><a href="' . file_create_url($item['uri']) . '">' . variable_get('lightbox2_download_link_text', 'Download Original') . '</a></p>';
  65. }
  66. // Title End
  67. $rel .= ']';
  68. $path['options']['attributes']['rel'] = $rel;
  69. $path['options']['attributes']['title'] = $item['title'];
  70. return theme('image_formatter', array( 'item' => $item, 'path' => $path, 'image_style' => $image_style ) );
  71. }
  72. /**
  73. * Handler for Lightbox2 display of imagecache + imagefield CCK fields.
  74. *
  75. * The compact view shows only the first image in a multiple imagefield but
  76. * shows all images in the lightbox.
  77. *
  78. * @param $element
  79. * The CCK field element.
  80. * @return
  81. * HTML output for displaying the image and link.
  82. */
  83. /*function theme_lightbox2_formatter_imagefield($variables) {
  84. $element = $variables['element'];
  85. if (!module_exists("image")) {
  86. return;
  87. }
  88. $field_name = $element['#field_name'];
  89. $item = $element['#item'];
  90. $formatter = $element['#formatter'];
  91. $node = node_load($element['#item']['nid']);
  92. if (strpos($formatter, '__lightbox2__') !== FALSE || strpos($formatter, '__lightshow2__') !== FALSE || strpos($formatter, '__lightframe2__') !== FALSE
  93. || strpos($formatter, '__lightbox2_compact__') !== FALSE || strpos($formatter, '__lightshow2_compact__') !== FALSE || strpos($formatter, '__lightframe2_compact__') !== FALSE) {
  94. list($tmp, $lightbox_type, $view_preset, $lightbox_preset) = explode('__', $formatter, 4);
  95. return lightbox2_imagefield_image_imagecache($field_name, $item, $formatter, $node, $view_preset, $lightbox_preset);
  96. }
  97. }*/
  98. /**
  99. * Function to set up the data needed for
  100. * theme_imagefield_image_imagecache_lightbox2().
  101. *
  102. * @param $field_name
  103. * The field name the action is being performed on.
  104. * @param $item
  105. * An array, keyed by column, of the data stored for this item in this field.
  106. * @param $formatter
  107. * The formatter to use for the field.
  108. * @param $node
  109. * The node object.
  110. * @param $view_preset
  111. * The imagecache preset to be displayed on the node or in the view.
  112. * @param $lightbox_preset
  113. * The imagecache preset to be displayed in the lightbox.
  114. * @return
  115. * The themed imagefield + imagecache image and link.
  116. */
  117. /*function lightbox2_imagefield_image_imagecache($variables) {
  118. $field_name = $variables['field_name'];
  119. $item = $variables['item'];
  120. $formatter = $variables['formatter'];
  121. $node = $variables['node'];
  122. $view_preset = $variables['view_preset'];
  123. $lightbox_preset = $variables['lightbox_preset'];
  124. // Load file data if missing
  125. if (!isset($item['filepath']) && !empty($item['fid'])) {
  126. $file = field_file_load($item['fid']);
  127. $item = array_merge($item, (array)$file);
  128. }
  129. elseif (!isset($item['filepath'])) {
  130. // No file in field, return.
  131. return '';
  132. }
  133. $args['lightbox_preset'] = $lightbox_preset;
  134. // Check view_preset for existence.
  135. $rules = array();
  136. if (function_exists('imagecache_presets')) {
  137. $presets = imagecache_presets();
  138. foreach ($presets as $preset_id => $preset_info) {
  139. $rules[$preset_id] = $preset_info['presetname'];
  140. }
  141. }
  142. else {
  143. $rules = _imagecache_get_presets();
  144. }
  145. if ($view_preset == 'link' || $view_preset == 'original' || in_array($view_preset, (array) $rules)) {
  146. $rel = 'lightbox';
  147. if (strpos($formatter, '__lightshow2__') !== FALSE) {
  148. $rel = 'lightshow';
  149. }
  150. elseif (strpos($formatter, '__lightshow2_compact__') !== FALSE) {
  151. $rel = 'lightshow';
  152. $args['compact'] = TRUE;
  153. }
  154. elseif (strpos($formatter, '__lightframe2__') !== FALSE) {
  155. $rel = 'lightframe';
  156. }
  157. // Check if this is a compact display.
  158. list($tmp, $lightbox_type, $tmp) = explode('__', $formatter, 3);
  159. if ($lightbox_type == 'lightbox2_compact') {
  160. $args['compact'] = TRUE;
  161. }
  162. return theme('imagefield_image_imagecache_lightbox2', array( 'view_preset' => $view_preset, 'field_name' => $field_name, 'item' => $item, 'node' => $node, 'rel' => $rel, 'args' => $args ) );
  163. }
  164. }
  165. /**
  166. * Generate the HTML output for imagefield + imagecache images so they can be
  167. * opened in a lightbox by clicking on the image on the node page or in a view.
  168. *
  169. * This actually also handles filefields + imagecache images too.
  170. *
  171. * @param $view_preset
  172. * The imagecache preset to be displayed on the node or in the view.
  173. * @param $field_name
  174. * The field name the action is being performed on.
  175. * @param $item
  176. * An array, keyed by column, of the data stored for this item in this field.
  177. * @param $node
  178. * The node object.
  179. * @param $rel
  180. * The type of lightbox to open: lightbox, lightshow or lightframe.
  181. * @param $args
  182. * Args may override internal processes: caption, rel_grouping.
  183. * @return
  184. * The themed imagefield + imagecache image and link.
  185. */
  186. /*function theme_imagefield_image_imagecache_lightbox2($variables) {
  187. $view_preset = $variables['view_preset'];
  188. $field_name = $variables['field_name'];
  189. $item = $variables['item'];
  190. $node = $variables['node'];
  191. $rel = $variables['rel'];
  192. $args = $variables['args'];
  193. if (!isset($args['lightbox_preset'])) {
  194. $args['lightbox_preset'] = 'original';
  195. }
  196. // Can't show current node page in a lightframe on the node page.
  197. // Switch instead to show it in a lightbox.
  198. $on_image_node = (arg(0) == 'node') && (arg(1) == $node->nid);
  199. if ($rel == 'lightframe' && $on_image_node) {
  200. $rel = 'lightbox';
  201. }
  202. $orig_rel = $rel;
  203. // Unserialize into original - if sourced by views.
  204. $item_data = $item['data'];
  205. if (is_string($item['data'])) {
  206. $item_data = unserialize($item['data']);
  207. }
  208. // Set up the title.
  209. $image_title = $item_data['description'];
  210. $image_title = (!empty($image_title) ? $image_title : $item_data['title']);
  211. $image_title = (!empty($image_title) ? $image_title : $item_data['alt']);
  212. if (empty($image_title) || variable_get('lightbox2_imagefield_use_node_title', FALSE)) {
  213. $node = node_load($node->nid);
  214. $image_title = $node->title;
  215. }
  216. $image_tag_title = '';
  217. if (!empty($item_data['title'])) {
  218. $image_tag_title = $item_data['title'];
  219. }
  220. // Enforce image alt.
  221. $image_tag_alt = '';
  222. if (!empty($item_data['alt'])) {
  223. $image_tag_alt = $item_data['alt'];
  224. }
  225. elseif (!empty($image_title)) {
  226. $image_tag_alt = $image_title;
  227. }
  228. // Set up the caption.
  229. $node_links = array();
  230. if (!empty($item['nid'])) {
  231. $attributes = array();
  232. $attributes['id'] = 'lightbox2-node-link-text';
  233. $target = variable_get('lightbox2_node_link_target', FALSE);
  234. if (!empty($target)) {
  235. $attributes['target'] = $target;
  236. }
  237. $node_link_text = variable_get('lightbox2_node_link_text', 'View Image Details');
  238. if (!$on_image_node && !empty($node_link_text)) {
  239. $node_links[] = l($node_link_text, 'node/'. $item['nid'], array('attributes' => $attributes));
  240. }
  241. $download_link_text = check_plain(variable_get('lightbox2_download_link_text', 'Download Original'));
  242. if (!empty($download_link_text) && user_access('download original image')) {
  243. $node_links[] = l($download_link_text, file_create_url($item['filepath']), array('attributes' => array('target' => '_blank', 'id' => 'lightbox2-download-link-text')));
  244. }
  245. }
  246. $caption = $image_title;
  247. if (count($node_links)) {
  248. $caption .= '<br /><br />'. implode(" - ", $node_links);
  249. }
  250. if (isset($args['caption'])) {
  251. $caption = $args['caption']; // Override caption.
  252. }
  253. if ($orig_rel == 'lightframe') {
  254. $frame_width = variable_get('lightbox2_default_frame_width', 600);
  255. $frame_height = variable_get('lightbox2_default_frame_height', 400);
  256. $frame_size = 'width:'. $frame_width .'px; height:'. $frame_height .'px;';
  257. $rel = preg_replace('/\]$/', "|$frame_size]", $rel);
  258. }
  259. // Set up the rel attribute.
  260. $full_rel = '';
  261. $imagefield_grouping = variable_get('lightbox2_imagefield_group_node_id', 1);
  262. if (isset($args['rel_grouping'])) {
  263. $full_rel = $rel .'['. $args['rel_grouping'] .']['. $caption .']';
  264. }
  265. elseif ($imagefield_grouping == 1) {
  266. $full_rel = $rel .'['. $field_name .']['. $caption .']';
  267. }
  268. elseif ($imagefield_grouping == 2 && !empty($item['nid'])) {
  269. $full_rel = $rel .'['. $item['nid'] .']['. $caption .']';
  270. }
  271. elseif ($imagefield_grouping == 3 && !empty($item['nid'])) {
  272. $full_rel = $rel .'['. $field_name .'_'. $item['nid'] .']['. $caption .']';
  273. }
  274. elseif ($imagefield_grouping == 4 ) {
  275. $full_rel = $rel .'[allnodes]['. $caption .']';
  276. }
  277. else {
  278. $full_rel = $rel .'[]['. $caption .']';
  279. }
  280. $class = '';
  281. if ($view_preset != 'original') {
  282. $class = 'imagecache imagecache-' . $field_name . ' imagecache-' . $view_preset . ' imagecache-' . $field_name . '-' . $view_preset;
  283. }
  284. $link_attributes = array(
  285. 'rel' => $full_rel,
  286. 'class' => 'imagefield imagefield-lightbox2 imagefield-lightbox2-' . $view_preset . ' imagefield-' . $field_name . ' ' . $class,
  287. );
  288. $attributes = array();
  289. if (isset($args['compact']) && $item['#delta']) {
  290. $image = '';
  291. }
  292. elseif ($view_preset == 'original') {
  293. $image = theme('lightbox2_image', array( 'path' => $item['filepath'], 'alt' => $image_tag_alt, 'title' => $image_tag_title, 'attributes' => $attributes ) );
  294. }
  295. elseif ($view_preset == 'link') {
  296. // Not actually an image, just a text link.
  297. $image = variable_get('lightbox2_view_image_text', 'View image');
  298. }
  299. else {
  300. $image = theme('imagecache', array( 'style_name' => $view_preset, 'path' => $item['filepath'], 'alt' => $image_tag_alt, 'title' => $image_tag_title, 'attributes' => $attributes ) );
  301. }
  302. if ($args['lightbox_preset'] == 'node') {
  303. $output = l($image, 'node/'. $node->nid .'/lightbox2', array('attributes' => $link_attributes, 'html' => TRUE));
  304. }
  305. elseif ($args['lightbox_preset'] == 'original') {
  306. $output = l($image, file_create_url($item['filepath']), array('attributes' => $link_attributes, 'html' => TRUE));
  307. }
  308. else {
  309. $output = l($image, imagecache_create_url($args['lightbox_preset'], $item['filepath']), array('attributes' => $link_attributes, 'html' => TRUE));
  310. }
  311. return $output;
  312. }*/
  313. /**
  314. * Theme function for the lightbox iframe filefield formatter.
  315. *
  316. * @param $element
  317. * The CCK field element.
  318. * @return
  319. * The themed link to the file, with lightframe support.
  320. */
  321. /*function theme_lightbox2_formatter_filefield_lightframe($variables) {
  322. $element = $variables['element'];
  323. $file = $element['#item'];
  324. $field = content_fields($element['#field_name']);
  325. if (!filefield_view_access($field['field_name']) || empty($file['list'])) {
  326. return '';
  327. }
  328. if (empty($file['fid']) || !is_file($file['filepath'])) {
  329. return '';
  330. }
  331. $file = (object)$file;
  332. if (!lightbox2_check_filefield_extension($file, $field)) {
  333. return '';
  334. }
  335. drupal_add_css(drupal_get_path('module', 'filefield') .'/filefield.css');
  336. return '<div class="filefield-item">'. theme('lightbox2_file_formatter_lightbox2_iframe', array( 'file' => $file, 'field' => $field, 'file_formatter_settings' => NULL ) ) .'</div>';
  337. }*/
  338. /**
  339. * Theme function for the lightbox iframe filefield formatter.
  340. *
  341. * @param $file
  342. * Filefield file object.
  343. * @param $field
  344. * The CCK field the action is being performed on.
  345. * @param $file_formatter_settings
  346. * File formatter settings; ignored.
  347. * @return
  348. * Themed link to filefield.
  349. */
  350. /*function theme_lightbox2_file_formatter_lightbox2_iframe($variables) {
  351. $file = $variables['file'];
  352. $field = $varbiables['field'];
  353. $file_formatter_settings = $variables['file_formatter_settings'];
  354. $path = $file->filepath;
  355. $url = file_create_url($path);
  356. $icon = theme('file_icon', array( 'file' => $file ) );
  357. $file_data = $file->data;
  358. if (is_string($file_data)) {
  359. $file_data = unserialize($file->data);
  360. }
  361. $description = $file_data['description'];
  362. if (empty($description)) {
  363. $description = $file->filename;
  364. }
  365. $attributes = array();
  366. $attributes['id'] = 'lightbox2-node-link-text';
  367. $target = variable_get('lightbox2_node_link_target', FALSE);
  368. if (!empty($target)) {
  369. $attributes['target'] = $target;
  370. }
  371. $node_link = '';
  372. $node_link_text = check_plain(variable_get('lightbox2_node_link_text', 'View Image Details'));
  373. if (!empty($node_link_text)) {
  374. $node_link .= '<br /><br />'. l($node_link_text, $url, array('attributes' => $attributes));
  375. }
  376. // Only files with supported extensions make it this far, so no need to check here.
  377. $link_attributes = array('rel' => 'lightframe[]['. $description . $node_link .']');
  378. return '<div class="filefield-formatter-lightbox2-iframe">'. $icon . l($description, $url, array('attributes' => $link_attributes)) .'</div>';
  379. }*/
  380. /**
  381. * Generate the HTML output to open embedded cck images in a lightbox.
  382. *
  383. * @param $element
  384. * The CCK field element.
  385. * @return
  386. * The themed link to the embedded image.
  387. */
  388. /*function theme_lightbox2_formatter_emimage($variables) {
  389. $element = $variables['element'];
  390. $field = content_fields($element['#field_name'], $element['#type_name']);
  391. $item = $element['#item'];
  392. $formatter = $element['#formatter'];
  393. $node = node_load($element['#node']->nid);
  394. list($tmp, $lightbox_type) = explode('_', $formatter, 2);
  395. $field['lightbox_type'] = $lightbox_type;
  396. $formatter = "emimage";
  397. return module_invoke('emfield', 'emfield_field_formatter', $field, $item, $formatter, $node, 'lightbox2');
  398. }*/
  399. /**
  400. * Generate the HTML output to open embedded cck images in a lightbox.
  401. *
  402. * @param $field
  403. * The CCK field the action is being performed on.
  404. * @param $item
  405. * An array, keyed by column, of the data stored for this item in this field.
  406. * @param $formatter
  407. * The formatter to use for the field.
  408. * @param $node
  409. * The node object.
  410. * @param $args
  411. * Args may override internal processes: caption, rel_grouping.
  412. * @return
  413. * Themed embedded media field image and link.
  414. */
  415. /*function theme_lightbox2_emimage($variables) {
  416. $field = $variables['field'];
  417. $item = $variables['item'];
  418. $formatter = $variables['formatter'];
  419. $node = $variables['node'];
  420. $args = $variables['args'];
  421. $lightbox_type = $field['lightbox_type'];
  422. if ($item['value'] && $item['provider']) {
  423. $rel = 'lightbox';
  424. if ($lightbox_type == 'lightshow2') {
  425. $rel = 'lightshow';
  426. }
  427. elseif ($lightbox_type == 'lightframe2') {
  428. $rel = 'lightframe';
  429. }
  430. if ($rel == 'lightframe' && arg(0) == 'node' && arg(1) == $node->nid) {
  431. $rel = 'lightbox';
  432. }
  433. $orig_rel = $rel;
  434. $code = $item['value'];
  435. $width = $field['widget']['thumbnail_width'] == '' ? variable_get('emimage_default_full_width', EMIMAGE_DEFAULT_FULL_WIDTH) : $field['widget']['thumbnail_width'];
  436. $height = $field['widget']['thumbnail_height'] == '' ? variable_get('emimage_default_full_height', EMIMAGE_DEFAULT_FULL_HEIGHT) : $field['widget']['thumbnail_height'];
  437. $link = $field['widget']['thumbnail_link'] ? $field['widget']['thumbnail_link'] : variable_get('emimage_default_thumbnail_link', EMIMAGE_DEFAULT_THUMBNAIL_LINK);
  438. if ($link == EMIMAGE_LINK_CONTENT) {
  439. $link = 'node/'. $node->nid;
  440. }
  441. elseif ($link == EMIMAGE_LINK_PROVIDER) {
  442. $link = module_invoke('emfield', 'include_invoke', 'emimage', $item['provider'], 'embedded_link', $code, $item['data']);
  443. }
  444. else {
  445. $link = NULL;
  446. }
  447. $attributes = array();
  448. $attributes['id'] = 'lightbox2-node-link-text';
  449. if ($width) {
  450. $attributes['width'] = $width;
  451. }
  452. if ($height) {
  453. $attributes['height'] = $height;
  454. }
  455. $target = variable_get('lightbox2_node_link_target', FALSE);
  456. if (!empty($target)) {
  457. $attributes['target'] = $target;
  458. }
  459. // Set up the title.
  460. $title = module_invoke('emfield', 'include_invoke', 'emimage', $item['provider'], 'image_title', $code, $item['data']);
  461. // Set up the caption.
  462. $node_link = '';
  463. $node_link_text = variable_get('lightbox2_node_link_text', 'View Image Details');
  464. if (!empty($node_link_text) && !empty($link)) {
  465. $node_link = '<br /><br />'. l($node_link_text, $link, array('attributes' => $attributes));
  466. }
  467. // @TODO original download link possible with emfield?
  468. $caption = $title . $node_link;
  469. if (isset($args['caption'])) {
  470. $caption = $args['caption']; // Override caption.
  471. }
  472. // Set up url and image.
  473. $url = module_invoke('emfield', 'include_invoke', 'emimage', $item['provider'], 'image_url', $code, $width, $height, "emimage", $field, $item, $node);
  474. $image = theme('image', array( 'path' => $url, 'alt' => $title, 'title' => $title, 'attributes' => $attributes, 'getsize' => FALSE ) );
  475. // Set up full rel attribute.
  476. $image_grouping = variable_get('lightbox2_emimage_group_node_id', 1);
  477. if ($image_grouping == 1) {
  478. $full_rel = $rel .'['. $field['field_name'] .']['. $caption .']';
  479. }
  480. elseif ($image_grouping == 2 && !empty($node->nid)) {
  481. $full_rel = $rel .'['. $node->nid .']['. $caption .']';
  482. }
  483. elseif ($image_grouping == 3 && !empty($node->nid)) {
  484. $full_rel = $rel .'['. $field['field_name'] .'_'. $node->nid .']['. $caption .']';
  485. }
  486. elseif (isset($args['rel_grouping'])) {
  487. $full_rel = $rel .'['. $args['rel_grouping'] .']['. $caption .']';
  488. }
  489. else {
  490. $rel = $full_rel .'[]['. $caption .']';
  491. }
  492. if ($orig_rel != 'lightframe') {
  493. $link_attributes = array('rel' => $full_rel);
  494. $full_width = $field['widget']['full_width'] == '' ? variable_get('emimage_default_full_width', EMIMAGE_DEFAULT_FULL_WIDTH) : $field['widget']['full_width'];
  495. $full_height = $field['widget']['full_height'] == '' ? variable_get('emimage_default_full_height', EMIMAGE_DEFAULT_FULL_HEIGHT) : $field['widget']['full_height'];
  496. $full_image_url = module_invoke('emfield', 'include_invoke', 'emimage', $item['provider'], 'image_url', $code, $full_width, $full_height, "emimage", $field, $item, $node);
  497. $output = l($image, $full_image_url, array('attributes' => $link_attributes, 'html' => TRUE));
  498. }
  499. else {
  500. $frame_width = variable_get('lightbox2_default_frame_width', 600);
  501. $frame_height = variable_get('lightbox2_default_frame_height', 400);
  502. $frame_size = 'width:'. $frame_width .'px; height:'. $frame_height .'px;';
  503. $full_rel = preg_replace('/\]\[/', "|$frame_size][", $full_rel);
  504. $link_attributes = array('rel' => $full_rel);
  505. $output = l($image, $link .'/lightbox2', array('attributes' => $link_attributes, 'html' => TRUE));
  506. }
  507. }
  508. return $output;
  509. }*/
  510. /**
  511. * Generate the HTML output to open embedded cck videos in a lightbox.
  512. *
  513. * @param $element
  514. * The CCK field element.
  515. * @return
  516. * HTML output for displaying the video and link.
  517. */
  518. /*function theme_lightbox2_formatter_emvideo_lightvideo($variables) {
  519. $element = $variables['element'];
  520. if (!variable_get('lightbox2_enable_video', FALSE)) {
  521. return;
  522. }
  523. $field = content_fields($element['#field_name'], $element['#type_name']);
  524. $item = $element['#item'];
  525. $formatter = "emvideo";
  526. $node = node_load($element['#node']->nid);
  527. return module_invoke('emfield', 'emfield_field_formatter', $field, $item, $formatter, $node, 'lightbox2');
  528. }*/
  529. /**
  530. * Generate the HTML output to open embedded cck videos in a lightbox.
  531. *
  532. * @param $field
  533. * The CCK field the action is being performed on.
  534. * @param $item
  535. * An array, keyed by column, of the data stored for this item in this field.
  536. * @param $formatter
  537. * The formatter to use for the field.
  538. * @param $node
  539. * The node object.
  540. * @param $options
  541. * Options array.
  542. * @return
  543. * Themed link to the embedded media field video.
  544. */
  545. /*function theme_lightbox2_emvideo($variables) {
  546. $field = $variables['field'];
  547. $item = $variables['item'];
  548. $formatter = $variables['formatter'];
  549. $node = $variables['node'];
  550. $thumbnail = isset($options['thumbnail']) ? $options['thumbnail'] : theme('emvideo_video_thumbnail', $field, $item, 'video_thumbnail', $node, TRUE, $options);
  551. // if options title set use that, otherwise use video title if set in node,
  552. // otherwise try node title, then widget thumbnail setting and fallback to
  553. // default string.
  554. $title = isset($options['title']) ? $options['title'] : (isset($item['data']['emthumb']['emthumb_title']) ? $item['data']['emthumb']['emthumb_title'] : (isset($node->title) ? $node->title : (isset($field['widget']['thumbnail_link_title']) ? $field['widget']['thumbnail_link_title'] : variable_get('emvideo_default_thumbnail_link_title', t('See video')))));
  555. $destination = 'video-cck/lightbox2/'. $node->nid .'/'. $field['widget']['video_width'] .'/'. $field['widget']['video_height'] .'/'. $field['field_name'] .'/'. $item['provider'] .'/'. $item['value'];
  556. $width = $field['widget']['video_width'] + 20;
  557. $height = $field['widget']['video_height'] + 20;
  558. if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)) {
  559. $width = $field['widget']['video_width'] + 40;
  560. $height = $field['widget']['video_height'] + 40;
  561. }
  562. $rel_full = 'lightframe['. $field['type_name'] . '|width:'. $width .'px; height:'. $height .'px; overflow:visible;]';
  563. $attributes = array(
  564. 'attributes' => array(
  565. 'title' => $title,
  566. 'class' => $field['type_name'],
  567. 'rel' => $rel_full,
  568. ),
  569. 'query' => NULL,
  570. 'fragment' => NULL,
  571. 'absolute' => FALSE,
  572. 'html' => TRUE,
  573. );
  574. $output = l($thumbnail, $destination, $attributes);
  575. return $output;
  576. }*/