__construct(); } /** * Init the album output * */ function __construct() { return true; } function controller() { global $nggdb; $this->currentID = isset($_REQUEST['act_album']) ? (int) $_REQUEST['act_album'] : 0 ; if (isset ($_POST['update']) || isset( $_POST['delete'] ) || isset( $_POST['add'] ) ) $this->processor(); if (isset ($_POST['update_album']) ) $this->update_album(); // get first all galleries & albums $this->albums = $nggdb->find_all_album(); $this->galleries = $nggdb->find_all_galleries(); $this->num_albums = count( $this->albums ); $this->num_galleries = count( $this->galleries ); $this->output(); } function processor() { global $wpdb; check_admin_referer('ngg_album'); if ( isset($_POST['add']) && isset ($_POST['newalbum']) ) { if (!nggGallery::current_user_can( 'NextGEN Add/Delete album' )) wp_die(__('Cheatin’ uh?')); $result = nggdb::add_album( $_POST['newalbum'] ); $this->currentID = ($result) ? $result : 0 ; //hook for other plugins do_action('ngg_add_album', $this->currentID); if ($result) nggGallery::show_message(__('Update Successfully','nggallery')); } if ( isset($_POST['update']) && ($this->currentID > 0) ) { $gid = ''; // get variable galleryContainer parse_str($_POST['sortorder']); if ( is_array($gid) ){ $serial_sort = serialize($gid); $wpdb->query("UPDATE $wpdb->nggalbum SET sortorder = '$serial_sort' WHERE id = $this->currentID "); } else { $wpdb->query("UPDATE $wpdb->nggalbum SET sortorder = '0' WHERE id = $this->currentID "); } //hook for other plugins do_action('ngg_update_album_sortorder', $this->currentID); nggGallery::show_message(__('Update Successfully','nggallery')); } if ( isset($_POST['delete']) ) { if (!nggGallery::current_user_can( 'NextGEN Add/Delete album' )) wp_die(__('Cheatin’ uh?')); $result = nggdb::delete_album( $this->currentID ); //hook for other plugins do_action('ngg_delete_album', $this->currentID); // jump back to main selection $this->currentID = 0; if ($result) nggGallery::show_message(__('Album deleted','nggallery')); } } function update_album() { global $wpdb, $nggdb; check_admin_referer('ngg_thickbox_form'); if (!nggGallery::current_user_can( 'NextGEN Edit album settings' )) wp_die(__('Cheatin’ uh?')); $name = $_POST['album_name']; $desc = $_POST['album_desc']; $prev = (int) $_POST['previewpic']; $link = (int) $_POST['pageid']; // slug must be unique, we use the title for that $slug = nggdb::get_unique_slug( sanitize_title( $name ), 'album', $this->currentID ); $result = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->nggalbum SET slug= '%s', name= '%s', albumdesc= '%s', previewpic= %d, pageid= %d WHERE id = '%d'" , $slug, $name, $desc, $prev, $link, $this->currentID ) ); //hook for other plugin to update the fields do_action('ngg_update_album', $this->currentID, $_POST); if ($result) nggGallery::show_message(__('Update Successfully','nggallery')); } function output() { global $wpdb, $nggdb; //TODO:Code MUST be optimized, how to flag a used gallery better ? $used_list = $this->get_used_galleries(); ?>
' . __('Name', 'nggallery') . ' : ' . esc_html ( nggGallery::i18n( $obj['name'] ) ). '
' . __('Title', 'nggallery') . ' : ' . esc_html ( nggGallery::i18n( $obj['title'] ) ) . '
' . __('Page', 'nggallery'). ' : ' . esc_html ( nggGallery::i18n( $obj['pagenname'] ) ) . '
' . apply_filters('ngg_display_album_item_content', '', $obj) . '