nggManageAlbum

The NextGEN Gallery nggManageAlbum class.

Defined (1)

The class is defined in the following location(s).

/products/photocrati_nextgen/modules/ngglegacy/admin/album.php  
  1. class nggManageAlbum { 
  2.  
  3. /** 
  4. * The selected album ID 
  5. * @since 1.3.0 
  6. * @access privat 
  7. * @var int 
  8. */ 
  9. var $currentID = 0; 
  10.  
  11. /** 
  12. * The array for the galleries 
  13. * @since 1.3.0 
  14. * @access privat 
  15. * @var array 
  16. */ 
  17. var $galleries = false; 
  18.  
  19. /** 
  20. * The array for the albums 
  21. * @since 1.3.0 
  22. * @access privat 
  23. * @var array 
  24. */ 
  25. var $albums = false; 
  26.  
  27. /** 
  28. * The amount of all galleries 
  29. * @since 1.4.0 
  30. * @access privat 
  31. * @var int 
  32. */ 
  33. var $num_galleries = false; 
  34.  
  35. /** 
  36. * The amount of all albums 
  37. * @since 1.4.0 
  38. * @access privat 
  39. * @var int 
  40. */ 
  41. var $num_albums = false; 
  42.  
  43. /** 
  44. * Gets the Pope component registry 
  45. * @return C_Component_Registry 
  46. */ 
  47. function get_registry() 
  48. if (!isset($this->_registry)) { 
  49. $this->_registry = C_Component_Registry::get_instance(); 
  50.  
  51. return $this->_registry; 
  52.  
  53. /** 
  54. * Init the album output 
  55. */ 
  56. function __construct() { 
  57. return true; 
  58.  
  59. function controller() { 
  60.  
  61. if (isset ($_POST['update']) || isset( $_POST['delete'] ) || isset( $_POST['add'] ) ) 
  62. $this->processor(); 
  63.  
  64. if (isset ($_POST['update_album']) ) 
  65. $this->update_album(); 
  66.  
  67. // get first all galleries & albums 
  68. $this->albums = array(); 
  69. foreach (C_Album_Mapper::get_instance()->find_all() as $album) { 
  70. $this->albums[$album->{$album->id_field}] = $album; 
  71.  
  72. $this->galleries = array(); 
  73. foreach (C_Gallery_Mapper::get_instance()->find_all() as $gallery) { 
  74. $this->galleries[$gallery->{$gallery->id_field}] = $gallery; 
  75.  
  76. if (apply_filters('ngg_manage_albums_items_order', 'ASC') == 'DESC') 
  77. $this->albums = array_reverse($this->albums, TRUE); 
  78. $this->galleries = array_reverse($this->galleries, TRUE); 
  79.  
  80. $this->num_albums = count( $this->albums ); 
  81. $this->num_galleries = count( $this->galleries ); 
  82.  
  83. $this->output(); 
  84.  
  85. function _get_album($id) 
  86. $retval = NULL; 
  87.  
  88. if (isset($this->albums[$id])) { 
  89. $retval = $this->albums[$id]; 
  90. else $retval = C_Album_Mapper::get_instance()->find($id); 
  91.  
  92. return $retval; 
  93.  
  94. function _get_gallery($id) 
  95. $retval = NULL; 
  96.  
  97. if (isset($this->galleries[$id])) { 
  98. $retval = $this->galleries[$id]; 
  99. else $retval = C_Gallery_Mapper::get_instance()->find($id); 
  100.  
  101. return $retval; 
  102.  
  103. /** 
  104. * Finds a suitable preview pic for the album if one hasn't been set 
  105. * already 
  106. * @param stdClass|C_Album $album 
  107. * @return stdClass|C_Album 
  108. */ 
  109. function _set_album_preview_pic($album) 
  110. $sortorder = array_merge($album->sortorder); 
  111.  
  112. while(!$album->previewpic) { 
  113. // If the album is missing a preview pic, set one! 
  114. if (($first_entity = array_pop($sortorder))) { 
  115.  
  116. // Is the first entity a gallery or album 
  117. if (substr($first_entity, 0, 1) == 'a') { 
  118. $subalbum = $this->_get_album(substr($first_entity, 1)); 
  119. if ($subalbum->previewpic) { 
  120. $album->previewpic = $subalbum->previewpic; 
  121. else { 
  122. $gallery = $this->_get_gallery($first_entity); 
  123. if ($gallery && $gallery->previewpic) { 
  124. $album->previewpic = $gallery->previewpic; 
  125. else break; 
  126.  
  127. return $album; 
  128.  
  129. function processor() { 
  130. global $wpdb; 
  131.  
  132. check_admin_referer('ngg_album'); 
  133.  
  134. // Create album 
  135. if ( isset($_POST['add']) && isset ($_POST['newalbum']) ) { 
  136.  
  137. if (!nggGallery::current_user_can( 'NextGEN Add/Delete album' )) 
  138. wp_die(__('Cheatin’ uh?')); 
  139.  
  140. $album = new stdClass(); 
  141. $album->name = $_POST['newalbum']; 
  142. if (C_Album_Mapper::get_instance()->save($album)) { 
  143. $this->currentID = $_REQUEST['act_album'] = $album->{$album->id_field}; 
  144. $this->albums[$this->currentID] = $album; 
  145. do_action('ngg_add_album', $this->currentID); 
  146. nggGallery::show_message(__('Update Successfully', 'nggallery')); 
  147. else { 
  148. $this->currentID = $_REQUEST['act_album'] = 0; 
  149.  
  150. else if ( isset($_POST['update']) && isset($_REQUEST['act_album']) && $this->currentID = intval($_REQUEST['act_album']) ) { 
  151.  
  152. $gid = array(); 
  153.  
  154. // Get the current album being updated 
  155. $album = $this->_get_album($this->currentID); 
  156.  
  157. // Get the list of galleries/sub-albums to be added to this album 
  158. parse_str($_REQUEST['sortorder']); 
  159.  
  160. // Set the new sortorder 
  161. $album->sortorder = $gid; 
  162.  
  163. // Ensure that a preview pic has been sent 
  164. $this->_set_album_preview_pic($album); 
  165.  
  166. // Save the changes 
  167. C_Album_Mapper::get_instance()->save($album); 
  168.  
  169. //hook for other plugins 
  170. do_action('ngg_update_album_sortorder', $this->currentID); 
  171.  
  172. nggGallery::show_message(__('Update Successfully', 'nggallery')); 
  173.  
  174.  
  175. if ( isset($_POST['delete']) ) { 
  176.  
  177. if (!nggGallery::current_user_can( 'NextGEN Add/Delete album' )) 
  178. wp_die(__('Cheatin’ uh?')); 
  179.  
  180. $this->currentID = $_REQUEST['act_album']; 
  181.  
  182. if (C_Album_Mapper::get_instance()->destroy($this->currentID)) { 
  183. //hook for other plugins 
  184. do_action('ngg_delete_album', $this->currentID); 
  185.  
  186. // jump back to main selection 
  187. $this->currentID = $_REQUEST['act_album'] = 0; 
  188.  
  189. nggGallery::show_message(__('Album deleted', 'nggallery')); 
  190.  
  191.  
  192.  
  193. function update_album() { 
  194.  
  195. check_admin_referer('ngg_thickbox_form'); 
  196.  
  197. if (!nggGallery::current_user_can( 'NextGEN Edit album settings' )) 
  198. wp_die(__('Cheatin’ uh?')); 
  199.  
  200. $this->currentID = $_REQUEST['act_album']; 
  201. $album = $this->_get_album($this->currentID); 
  202. $album->name = stripslashes($_POST['album_name']); 
  203. $album->albumdesc = stripslashes($_POST['album_desc']); 
  204. $album->previewpic = (int)$_POST['previewpic']; 
  205. $album->pageid = (int)$_POST['pageid']; 
  206. $result = C_Album_Mapper::get_instance()->save($album); 
  207.  
  208. //hook for other plugin to update the fields 
  209. do_action('ngg_update_album', $this->currentID, $_POST); 
  210.  
  211. if ($result) 
  212. nggGallery::show_message(__('Update Successfully', 'nggallery')); 
  213.  
  214. function get_available_preview_images($album) 
  215. $retval = array(); 
  216.  
  217. if ($album && isset($album->sortorder) && $album->sortorder) { 
  218. $galleries = array(); 
  219. $albums = array(); 
  220. foreach ($album->sortorder as $item) { 
  221. if (is_numeric($item)) $galleries[] = $item; 
  222. else $albums[] = $item; 
  223.  
  224. $image_mapper = C_Image_Mapper::get_instance(); 
  225. $retval += $image_mapper->select('DISTINCT *')->where(array("galleryid IN %s", $galleries))->where('exclude != 1')->run_query(); 
  226. foreach ($albums as $subalbum) $retval += $this->get_available_preview_images($subalbum); 
  227. else { 
  228. // enforce a reasonable limit on how many images to offer 
  229. $retval = C_Image_Mapper::get_instance() 
  230. ->select() 
  231. ->where_and(array()) 
  232. ->limit(intval(C_NextGen_Settings::get_instance()->get('maximum_entity_count', 500))) 
  233. ->run_query(); 
  234.  
  235. return $retval; 
  236.  
  237. function output() { 
  238.  
  239. global $wpdb, $nggdb; 
  240.  
  241. if (isset($_REQUEST['act_album'])) $this->currentID = intval($_REQUEST['act_album']); 
  242.  
  243. $album = $this->_get_album($this->currentID); 
  244.  
  245. // Generate JSON for autocomplete of preview images 
  246. $preview_images = $this->get_available_preview_images($album); 
  247.  
  248.  
  249. //TODO:Code MUST be optimized, how to flag a used gallery better ? 
  250. $used_list = $this->get_used_galleries(); 
  251.  
  252.  
  253. ?> 
  254. <style type="text/css"> 
  255. .select2-container {max-width: 580px; } 
  256. .select2-drop { max-width: 580px; } 
  257. .select2-choice { max-width: 580;} 
  258. </style> 
  259.  
  260. <script type="text/javascript"> 
  261.  
  262. jQuery(document).ready( 
  263. function($) 
  264. if ($(this).data('ready')) return; 
  265.  
  266. if (window.Frame_Event_Publisher) { 
  267.  
  268. // Refresh when a new gallery has been added 
  269. Frame_Event_Publisher.listen_for('attach_to_post:manage_galleries attach_to_post:new_gallery', function() { 
  270. window.location.href = window.location.href; 
  271. }); 
  272.  
  273. // Updates the thumbnail image when a previewpic has been modified 
  274. Frame_Event_Publisher.listen_for('attach_to_post:thumbnail_modified', function(data) { 
  275. var image_id = data.image[data.image.id_field]; 
  276. var $image = $('img[rel="'+image_id+'"]'); 
  277. if ($image.length > 0) { 
  278. $image.attr('src', data.image.thumb_url); 
  279. }); 
  280.  
  281. $("#previewpic").select2({ 
  282. width: '100%' 
  283. }); 
  284.  
  285. jQuery('#selectContainer').sortable( { 
  286. items: '.groupItem',  
  287. placeholder: 'sort_placeholder',  
  288. opacity: 0.7,  
  289. tolerance: 'intersect',  
  290. distance: 2,  
  291. forcePlaceholderSize: true ,  
  292. connectWith: ['#galleryContainer'] 
  293. } ); 
  294.  
  295. jQuery('#galleryContainer').sortable( { 
  296. items: '.groupItem',  
  297. placeholder: 'sort_placeholder',  
  298. opacity: 0.7,  
  299. tolerance: 'intersect',  
  300. distance: 2,  
  301. forcePlaceholderSize: true ,  
  302. connectWith: ['#selectContainer', '#albumContainer'] 
  303. } ); 
  304.  
  305. jQuery('#albumContainer').sortable( { 
  306. items: '.groupItem',  
  307. placeholder: 'sort_placeholder',  
  308. opacity: 0.7,  
  309. tolerance: 'intersect',  
  310. distance: 2,  
  311. forcePlaceholderSize: true ,  
  312. connectWith: ['#galleryContainer'] 
  313. } ); 
  314.  
  315. jQuery('a.min').on('click', toggleContent); 
  316.  
  317. // Hide used galleries 
  318. jQuery('a#toggle_used').click(function() 
  319. jQuery('#selectContainer div.inUse').toggle(); 
  320. return false; 
  321. ); 
  322.  
  323. // Maximize All Portlets (whole site, no differentiation) 
  324. jQuery('a#all_max').click(function() 
  325. jQuery('div.itemContent:hidden').show(); 
  326. return false; 
  327. ); 
  328.  
  329. // Minimize All Portlets (whole site, no differentiation) 
  330. jQuery('a#all_min').click(function() 
  331. jQuery('div.itemContent:visible').hide(); 
  332. return false; 
  333. ); 
  334. // Auto Minimize if more than 4 (whole site, no differentiation) 
  335. if(jQuery('a.min').length > 4) 
  336. jQuery('a.min').html('[+]'); 
  337. jQuery('div.itemContent:visible').hide(); 
  338. jQuery('#selectContainer div.inUse').toggle(); 
  339. }; 
  340.  
  341. $(this).data('ready', true); 
  342. ); 
  343.  
  344. var toggleContent = function(e) 
  345. var targetContent = jQuery('div.itemContent', this.parentNode.parentNode); 
  346. if (targetContent.css('display') == 'none') { 
  347. targetContent.slideDown(300); 
  348. jQuery(this).html('[-]'); 
  349. } else { 
  350. targetContent.slideUp(300); 
  351. jQuery(this).html('[+]'); 
  352. return false; 
  353. }; 
  354.  
  355. function ngg_serialize(s) 
  356. //serial = jQuery.SortSerialize(s); 
  357. serial = jQuery('#galleryContainer').sortable('serialize'); 
  358. jQuery('input[name=sortorder]').val(serial); 
  359. return serial; 
  360.  
  361. function showDialog() { 
  362. jQuery( "#editalbum").dialog({ 
  363. width: 640,  
  364. resizable : false,  
  365. modal: true,  
  366. title: '<?php echo esc_js( __('Edit Album', 'nggallery') ); ?>',  
  367. position: { 
  368. my: 'center',  
  369. at: 'center',  
  370. of: window.parent 
  371. }); 
  372. jQuery('#editalbum .dialog-cancel').click(function() { jQuery( "#editalbum" ).dialog("close"); }); 
  373.  
  374. </script> 
  375.  
  376. <div class="wrap album" id="wrap" > 
  377. <?php screen_icon( 'nextgen-gallery' ); ?> 
  378. <h2><?php esc_html_e('Manage Albums', 'nggallery') ?></h2> 
  379. <form id="selectalbum" method="POST" onsubmit="ngg_serialize()" accept-charset="utf-8"> 
  380. <?php wp_nonce_field('ngg_album') ?> 
  381. <input name="sortorder" type="hidden" /> 
  382. <div class="albumnav tablenav"> 
  383. <div class="alignleft actions"> 
  384. <?php esc_html_e('Select album', 'nggallery') ?> 
  385. <select id="act_album" name="act_album" onchange="this.form.submit();"> 
  386. <option value="0" ><?php esc_html_e('No album selected', 'nggallery') ?></option> 
  387. <?php 
  388. if( is_array($this->albums) ) { 
  389. foreach($this->albums as $a) { 
  390. $selected = ($this->currentID == $a->id) ? 'selected="selected" ' : ''; 
  391. echo '<option value="' . $a->id . '" ' . $selected . '>' . $a->id . ' - ' . esc_attr( $a->name ) . '</option>'."\n"; 
  392. ?> 
  393. </select> 
  394. <?php if ($album && $this->currentID) { ?> 
  395. <input class="button-primary" type="submit" name="update" value="<?php esc_attr_e('Update', 'nggallery'); ?>"/> 
  396. <?php if(nggGallery::current_user_can( 'NextGEN Edit album settings' )) { ?> 
  397. <input class="button-secondary" type="submit" name="showThickbox" value="<?php esc_attr_e( 'Edit Album', 'nggallery'); ?>" onclick="showDialog(); return false;" /> 
  398. <?php } ?> 
  399. <?php if(nggGallery::current_user_can( 'NextGEN Add/Delete album' )) { ?> 
  400. <input class="button-secondary action "type="submit" name="delete" value="<?php esc_attr_e('Delete', 'nggallery'); ?>" onclick="javascript:check=confirm('<?php echo esc_js('Delete album ?', 'nggallery'); ?>');if(check==false) return false;"/> 
  401. <?php } ?> 
  402. <?php } else { ?> 
  403. <?php if(nggGallery::current_user_can( 'NextGEN Add/Delete album' )) { ?> 
  404. <span><?php esc_html_e('Add new album', 'nggallery'); ?> </span> 
  405. <input class="search-input" id="newalbum" name="newalbum" type="text" value="" /> 
  406. <input class="button-secondary action" type="submit" name="add" value="<?php esc_attr_e('Add', 'nggallery'); ?>"/> 
  407. <?php } ?> 
  408. <?php } ?> 
  409. </div> 
  410. </div> 
  411. </form> 
  412.  
  413. <br class="clear"/> 
  414.  
  415. <div> 
  416. <div style="float:right;"> 
  417. <a href="#" title="<?php esc_attr_e('Show / hide used galleries', 'nggallery'); ?>" id="toggle_used"><?php esc_html_e('[Show all]', 'nggallery'); ?></a> 
  418. | <a href="#" title="<?php esc_attr_e('Maximize the widget content', 'nggallery'); ?>" id="all_max"><?php esc_html_e('[Maximize]', 'nggallery'); ?></a> 
  419. | <a href="#" title="<?php esc_attr_e('Minimize the widget content', 'nggallery'); ?>" id="all_min"><?php esc_html_e('[Minimize]', 'nggallery'); ?></a> 
  420. </div> 
  421. <?php esc_html_e('After you create and select a album, you can drag and drop a gallery or another album into your new album below', 'nggallery'); ?> 
  422. </div> 
  423.  
  424. <br class="clear" /> 
  425.  
  426. <div class="container"> 
  427.  
  428. <!-- /#album container --> 
  429. <div class="widget widget-right"> 
  430. <div class="widget-top"> 
  431. <h3><?php esc_html_e('Select album', 'nggallery'); ?></h3> 
  432. </div> 
  433. <div id="albumContainer" class="widget-holder"> 
  434. <?php 
  435. if( is_array( $this->albums ) ) { 
  436. foreach($this->albums as $a) { 
  437. $this->get_container('a' . $a->id); 
  438. ?> 
  439. </div> 
  440. </div> 
  441.  
  442. <!-- /#select container --> 
  443. <div class="widget widget-right"> 
  444. <div class="widget-top"> 
  445. <h3><?php esc_html_e('Select gallery', 'nggallery'); ?></h3> 
  446. </div> 
  447. <div id="selectContainer" class="widget-holder"> 
  448. <?php 
  449.  
  450. if( is_array( $this->galleries ) ) { 
  451. //get the array of galleries 
  452. $sort_array = $album ? $album->sortorder : array(); 
  453. foreach($this->galleries as $gallery) { 
  454. if (!in_array($gallery->gid, $sort_array)) { 
  455. if (in_array($gallery->gid, $used_list)) 
  456. $this->get_container($gallery->gid, true); 
  457. else 
  458. $this->get_container($gallery->gid, false); 
  459. ?> 
  460. </div> 
  461. </div> 
  462.  
  463. <!-- /#target-album --> 
  464. <div class="widget target-album widget-left"> 
  465. <?php if ($album && $this->currentID) { ?> 
  466. <div class="widget-top"> 
  467. <h3><?php esc_html_e('Album ID', 'nggallery'); ?> <?php echo $album->id . ' : ' . esc_html( $album->name ); ?> </h3> 
  468. </div> 
  469. <div id="galleryContainer" class="widget-holder target"> 
  470. <?php 
  471. $sort_array = $album->sortorder; 
  472. foreach($sort_array as $galleryid) { 
  473. $this->get_container($galleryid, false); 
  474. else 
  475. ?> 
  476. <div class="widget-top"> 
  477. <h3><?php esc_html_e('No album selected!', 'nggallery'); ?></h3> 
  478. </div> 
  479. <div class="widget-holder target"> 
  480. <?php 
  481. ?> 
  482. </div> 
  483. </div><!-- /#target-album --> 
  484.  
  485. </div><!-- /#container --> 
  486. </div><!-- /#wrap --> 
  487.  
  488. <?php if ($album && $this->currentID): ?> 
  489. <!-- #editalbum --> 
  490. <div id="editalbum" style="display: none;" > 
  491. <form id="form-edit-album" method="POST" accept-charset="utf-8"> 
  492. <?php wp_nonce_field('ngg_thickbox_form') ?> 
  493. <input type="hidden" id="current_album" name="act_album" value="<?php esc_attr_e($this->currentID); ?>" /> 
  494. <table width="100%" border="0" cellspacing="3" cellpadding="3" > 
  495. <tr> 
  496. <th> 
  497. <?php esc_html_e('Album name:', 'nggallery'); ?><br /> 
  498. <input class="search-input" id="album_name" name="album_name" type="text" value="<?php echo esc_attr( $album->name ); ?>" style="width:95%" /> 
  499. </th> 
  500. </tr> 
  501. <tr> 
  502. <th> 
  503. <?php esc_html_e('Album description:', 'nggallery'); ?><br /> 
  504. <textarea class="search-input" id="album_desc" name="album_desc" cols="50" rows="2" style="width:95%" ><?php echo esc_attr( $album->albumdesc ); ?></textarea> 
  505. </th> 
  506. </tr> 
  507. <tr> 
  508. <th> 
  509. <?php esc_html_e('Select a preview image:', 'nggallery'); ?><br /> 
  510. <select id="previewpic" name="previewpic" data-placeholder="<?php esc_attr_e(__('No picture', 'nggallery'))?>"> 
  511. <?php foreach ($preview_images as $image): ?> 
  512. <option value="<?php esc_attr_e($image->pid)?>" <?php selected($album->previewpic, $image->pid) ?>> 
  513. <?php $label = $image->alttext ? $image->alttext : $image->filename; ?> 
  514. <?php esc_html_e($image->pid)?> - <?php esc_html_e($label)?> 
  515. </option> 
  516. <?php endforeach ?> 
  517. </select> 
  518. </th> 
  519. </tr> 
  520. <tr> 
  521. <th> 
  522. <?php esc_html_e('Page Link to', 'nggallery')?><br /> 
  523. <?php 
  524. if (!isset($album->pageid)) 
  525. $album->pageid = 0; 
  526.  
  527. ob_start(); 
  528. wp_dropdown_pages(array( 
  529. 'echo' => TRUE,  
  530. 'name' => 'pageid',  
  531. 'selected' => $album->pageid,  
  532. 'show_option_none' => esc_html('Not linked', 'nggallery'),  
  533. 'option_none_value' => 0 
  534. )); 
  535. $dropdown = ob_get_contents(); 
  536. ob_end_clean(); 
  537. if (!empty($dropdown)) 
  538. echo $dropdown; 
  539. else { 
  540. echo '<input type="hidden" id="pageid" name="pageid" value="0"/>'; 
  541. esc_html_e('There are no pages to link to', 'nggallery'); 
  542. ?> 
  543. </th> 
  544. </tr> 
  545.  
  546. <?php do_action('ngg_edit_album_settings', $this->currentID); ?> 
  547.  
  548. <tr align="right"> 
  549. <td class="submit"> 
  550. <input type="submit" class="button-primary" name="update_album" value="<?php esc_attr_e('OK', 'nggallery'); ?>" /> 
  551.   
  552. <input class="button-secondary dialog-cancel" type="reset" value="<?php esc_attr_e('Cancel', 'nggallery'); ?>"/> 
  553. </td> 
  554. </tr> 
  555. </table> 
  556. </form> 
  557. </div> 
  558. <!-- /#editalbum --> 
  559. <?php endif; ?> 
  560.  
  561. <?php 
  562.  
  563.  
  564. /** 
  565. * Create the album or gallery container 
  566. * @param integer $id (the prefix 'a' indidcates that you look for a album 
  567. * @param bool $used (object will be hidden) 
  568. * @return $output 
  569. */ 
  570. function get_container($id = 0, $used = false) { 
  571. global $wpdb, $nggdb; 
  572.  
  573. $obj = array(); 
  574. $preview_image = ''; 
  575. $class = ''; 
  576.  
  577. // if the id started with a 'a', then it's a sub album 
  578. if (substr( $id, 0, 1) == 'a') { 
  579.  
  580. if ( !$album = $this->_get_album(substr( $id, 1))) 
  581. return; 
  582.  
  583. $obj['id'] = $album->id; 
  584. $obj['name'] = $obj['title'] = $album->name; 
  585. $obj['type'] = 'album'; 
  586. $class = 'album_obj'; 
  587.  
  588. // get the post name 
  589. $post = get_post($album->pageid); 
  590. $obj['pagenname'] = ($post == null) ? '---' : $post->post_title; 
  591.  
  592. // for speed reason we limit it to 50 
  593. if ( $this->num_albums < 50 ) { 
  594. $thumbURL = ""; 
  595. if ($album->previewpic) { 
  596. $image = $nggdb->find_image( $album->previewpic ); 
  597. if ($image) $thumbURL = @add_query_arg('timestamp', time(), $image->thumbURL); 
  598. $preview_image = $thumbURL ? '<div class="inlinepicture"><img rel="'.$album->previewpic.'" src="' . nextgen_esc_url( $thumbURL ). '" /></div>' : ''; 
  599.  
  600. // this indicates that we have a album container 
  601. $prefix = 'a'; 
  602.  
  603. } else { 
  604. if ( !$gallery = $nggdb->find_gallery( $id ) ) 
  605. return; 
  606.  
  607. $obj['id'] = $gallery->gid; 
  608. $obj['name'] = $gallery->name; 
  609. $obj['title'] = $gallery->title; 
  610. $obj['type'] = 'gallery'; 
  611.  
  612. // get the post name 
  613. $post = get_post($gallery->pageid); 
  614. $obj['pagenname'] = ($post == null) ? '---' : $post->post_title; 
  615.  
  616. // for spped reason we limit it to 50 
  617. if ( $this->num_galleries < 50 ) { 
  618. // set image url 
  619. $thumbURL = ""; 
  620. if ($gallery->previewpic) { 
  621. $image = $nggdb->find_image( $gallery->previewpic ); 
  622. $thumbURL = @add_query_arg('timestamp', time(), $image->thumbURL); 
  623. $preview_image = ( !is_null($thumbURL) ) ? '<div class="inlinepicture"><img rel="'.$gallery->previewpic.'" src="' . nextgen_esc_url( $thumbURL ). '" /></div>' : ''; 
  624.  
  625. $prefix = ''; 
  626.  
  627. // add class if it's in use in other albums 
  628. $used = $used ? ' inUse' : ''; 
  629.  
  630. echo '<div id="gid-' . $prefix . $obj['id'] . '" class="groupItem' . $used . '"> 
  631. <div class="innerhandle"> 
  632. <div class="item_top ' . $class . '"> 
  633. <a href="#" class="min" title="close">[-]</a> 
  634. ID: ' . $obj['id'] . ' | ' . wp_html_excerpt( esc_html ( M_I18N::translate( $obj['title'] ) ) , 25) . ' 
  635. </div> 
  636. <div class="itemContent"> 
  637. ' . $preview_image . ' 
  638. <p><strong>' . __('Name', 'nggallery') . ' : </strong>' . esc_html ( M_I18N::translate( $obj['name'] ) ). '</p> 
  639. <p><strong>' . __('Title', 'nggallery') . ' : </strong>' . esc_html ( M_I18N::translate( $obj['title'] ) ) . '</p> 
  640. <p><strong>' . __('Page', 'nggallery'). ' : </strong>' . esc_html ( M_I18N::translate( $obj['pagenname'] ) ) . '</p> 
  641. ' . apply_filters('ngg_display_album_item_content', '', $obj) . ' 
  642. </div> 
  643. </div> 
  644. </div>'; 
  645.  
  646. /** 
  647. * get all used galleries from all albums 
  648. * @return array $used_galleries_ids 
  649. */ 
  650. function get_used_galleries() { 
  651.  
  652. $used = array(); 
  653.  
  654. if ($this->albums) { 
  655. foreach($this->albums as $album) { 
  656. if (!is_array($album->sortorder)) continue; 
  657. foreach($album->sortorder as $galleryid) { 
  658. if (!in_array($galleryid, $used)) 
  659. $used[] = $galleryid; 
  660.  
  661. return $used; 
  662.  
  663. /** 
  664. * PHP5 style destructor 
  665. * @return bool Always true 
  666. */ 
  667. function __destruct() { 
  668. return true; 
  669.