/**
  * Gets existing galleries
  * @return array
  */
 public function get_existing_galleries_action()
 {
     $this->debug = TRUE;
     $response = array();
     if ($this->object->validate_ajax_request('nextgen_edit_displayed_gallery')) {
         $limit = $this->object->param('limit');
         $offset = $this->object->param('offset');
         // We return the total # of galleries, so that the client can make
         // pagination requests
         $mapper = C_Gallery_Mapper::get_instance();
         $response['total'] = $mapper->count();
         $response['limit'] = $limit = $limit ? $limit : 0;
         $response['offset'] = $offset = $offset ? $offset : 0;
         // Get the galleries
         $mapper->select();
         if ($limit) {
             $mapper->limit($limit, $offset);
         }
         $response['items'] = $mapper->run_query();
     } else {
         $response['error'] = 'insufficient access';
     }
     $this->debug = FALSE;
     return $response;
 }
예제 #2
0
 /**
  * Flushes cache from all available galleries
  *
  * @param array $galleries When provided only the requested galleries' cache is flushed
  */
 public function flush_galleries($galleries = array())
 {
     if (empty($galleries)) {
         $galleries = C_Gallery_Mapper::get_instance()->find_all();
     }
     foreach ($galleries as $gallery) {
         C_Gallery_Storage::get_instance()->flush_cache($gallery);
     }
 }
 /**
  * Flushes cache from all available galleries
  *
  * @param array $galleries When provided only the requested galleries' cache is flushed
  */
 public function flush_galleries($galleries = array())
 {
     global $wpdb;
     if (empty($galleries)) {
         $galleries = C_Gallery_Mapper::get_instance()->find_all();
     }
     foreach ($galleries as $gallery) {
         C_Gallery_Storage::get_instance()->flush_cache($gallery);
     }
     // Remove images still in the DB whose gallery no longer exists
     $wpdb->query("DELETE FROM `{$wpdb->nggpictures}` WHERE `galleryid` NOT IN (SELECT `gid` FROM `{$wpdb->nggallery}`)");
 }
 function upload_images()
 {
     $storage = C_Gallery_Storage::get_instance();
     $image_mapper = C_Image_Mapper::get_instance();
     $gallery_mapper = C_Gallery_Mapper::get_instance();
     // Get Gallery ID
     $galleryID = absint($_POST['galleryselect']);
     if (0 == $galleryID) {
         $galleryID = get_option('npu_default_gallery');
         if (empty($galleryID)) {
             self::show_error(__('No gallery selected.', 'nextgen-public-uploader'));
             return;
         }
     }
     // Get the Gallery
     $gallery = $gallery_mapper->find($galleryID);
     if (!$gallery->path) {
         self::show_error(__('Failure in database, no gallery path set.', 'nextgen-public-uploader'));
         return;
     }
     // Read Image List
     foreach ($_FILES as $key => $value) {
         if (0 == $_FILES[$key]['error']) {
             try {
                 if ($storage->is_image_file($_FILES[$key]['tmp_name'])) {
                     $image = $storage->object->upload_base64_image($gallery, file_get_contents($_FILES[$key]['tmp_name']), $_FILES[$key]['name']);
                     if (get_option('npu_exclude_select')) {
                         $image->exclude = 1;
                         $image_mapper->save($image);
                     }
                     // Add to Image and Dir List
                     $this->arrImgNames[] = $image->filename;
                     $this->arrImageIds[] = $image->id();
                     $this->strGalleryPath = $gallery->path;
                 } else {
                     unlink($_FILES[$key]['tmp_name']);
                     $error_msg = sprintf(__('<strong>%s</strong> is not a valid file.', 'nextgen-public-uploader'), $_FILES[$key]['name']);
                     self::show_error($error_msg);
                     continue;
                 }
             } catch (E_NggErrorException $ex) {
                 self::show_error('<strong>' . $ex->getMessage() . '</strong>');
                 continue;
             } catch (Exception $ex) {
                 self::show_error('<strong>' . $ex->getMessage() . '</strong>');
                 continue;
             }
         }
     }
 }
 function _render_gallery($display_type, $original_display_type, $original_settings, $original_entities, $return = FALSE)
 {
     // Try finding the gallery by slug first. If nothing is found, we assume that
     // the user passed in a gallery id instead
     $gallery = $gallery_slug = $this->object->param('gallery');
     $mapper = C_Gallery_Mapper::get_instance();
     $result = reset($mapper->select()->where(array('slug = %s', $gallery))->limit(1)->run_query());
     if ($result) {
         $gallery = $result->{$result->id_field};
     }
     add_filter('ngg_displayed_gallery_rendering', array($this, 'add_breadcrumbs_to_legacy_templates'), 10, 2);
     $renderer = C_Displayed_Gallery_Renderer::get_instance();
     $output = $renderer->display_images(array('source' => 'galleries', 'container_ids' => array($gallery), 'display_type' => $display_type, 'original_display_type' => $original_display_type, 'original_settings' => $original_settings, 'original_album_entities' => $original_entities), $return);
     remove_filter('ngg_displayed_gallery_rendering', array($this, 'add_breadcrumbs_to_legacy_templates'));
     return $output;
 }
예제 #6
0
 /**
  * Import an image from the filesystem into NextGen
  *
  * @synopsis --filename=<absolute-path> --gallery=<gallery-id>
  */
 function import_image($args, $assoc_args)
 {
     $mapper = C_Gallery_Mapper::get_instance();
     $storage = C_Gallery_Storage::get_instance();
     if ($gallery = $mapper->find($assoc_args['gallery'], TRUE)) {
         $file_data = @file_get_contents($assoc_args['filename']);
         $file_name = M_I18n::mb_basename($assoc_args['filename']);
         if (empty($file_data)) {
             WP_CLI::error('Could not load file');
         }
         $image = $storage->upload_base64_image($gallery, $file_data, $file_name);
         $image_id = $image->{$image->id_field};
         if (!$image) {
             WP_CLI::error('Could not import image');
         } else {
             WP_CLI::success("Imported image with id #{$image_id}");
         }
     } else {
         WP_CLI::error("Gallery not found (with id #{$assoc_args['gallery']}");
     }
 }
예제 #7
0
 /**
  * Parse the gallery/imagebrowser/slideshow shortcode and return all images into an array
  *
  * @param string $atts
  * @return
  */
 function add_gallery($atts)
 {
     global $wpdb;
     extract(shortcode_atts(array('id' => 0), $atts));
     $gallery_mapper = C_Gallery_Mapper::get_instance();
     if (!is_numeric($id)) {
         if ($gallery = array_shift($gallery_mapper->select()->where(array('name = %s', $id))->limit(1)->run_query())) {
             $id = $gallery->{$gallery->id_field};
         } else {
             $id = NULL;
         }
     }
     if ($id) {
         $gallery_storage = C_Gallery_Storage::get_instance();
         $image_mapper = C_Image_Mapper::get_instance();
         foreach ($image_mapper->find_all_for_gallery($id) as $image) {
             $this->images[] = array('src' => $gallery_storage->get_image_url($image), 'title' => $image->title, 'alt' => $image->alttext);
         }
     }
     return '';
 }
예제 #8
0
파일: manage.php 프로젝트: vadia007/frg
 function post_processor_images()
 {
     global $wpdb, $ngg, $nggdb;
     // bulk update in a single gallery
     if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) {
         check_admin_referer('ngg_updategallery');
         switch ($_POST['bulkaction']) {
             case 'no_action':
                 break;
             case 'rotate_cw':
                 nggAdmin::do_ajax_operation('rotate_cw', $_POST['doaction'], __('Rotate images', 'nggallery'));
                 break;
             case 'rotate_ccw':
                 nggAdmin::do_ajax_operation('rotate_ccw', $_POST['doaction'], __('Rotate images', 'nggallery'));
                 break;
             case 'recover_images':
                 nggAdmin::do_ajax_operation('recover_image', $_POST['doaction'], __('Recover from backup', 'nggallery'));
                 break;
             case 'set_watermark':
                 nggAdmin::do_ajax_operation('set_watermark', $_POST['doaction'], __('Set watermark', 'nggallery'));
                 break;
             case 'delete_images':
                 if (is_array($_POST['doaction'])) {
                     foreach ($_POST['doaction'] as $imageID) {
                         $image = $nggdb->find_image($imageID);
                         if ($image) {
                             if ($ngg->options['deleteImg']) {
                                 $storage = C_Gallery_Storage::get_instance();
                                 $storage->delete_image($image->pid);
                             }
                             do_action('ngg_delete_picture', $image->pid);
                             $delete_pic = C_Image_Mapper::get_instance()->destroy($image->pid);
                         }
                     }
                     if ($delete_pic) {
                         nggGallery::show_message(__('Pictures deleted successfully ', 'nggallery'));
                     }
                 }
                 break;
             case 'import_meta':
                 nggAdmin::do_ajax_operation('import_metadata', $_POST['doaction'], __('Import metadata', 'nggallery'));
                 break;
         }
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_ResizeImages'])) {
         check_admin_referer('ngg_thickbox_form');
         //save the new values for the next operation
         $ngg->options['imgWidth'] = (int) $_POST['imgWidth'];
         $ngg->options['imgHeight'] = (int) $_POST['imgHeight'];
         update_option('ngg_options', $ngg->options);
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         nggAdmin::do_ajax_operation('resize_image', $pic_ids, __('Resize images', 'nggallery'));
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_NewThumbnail'])) {
         check_admin_referer('ngg_thickbox_form');
         // save the new values for the next operation
         $settings = C_NextGen_Settings::get_instance();
         $settings->thumbwidth = (int) $_POST['thumbwidth'];
         $settings->thumbheight = (int) $_POST['thumbheight'];
         $settings->thumbfix = isset($_POST['thumbfix']) ? TRUE : FALSE;
         $settings->save();
         ngg_refreshSavedSettings();
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         nggAdmin::do_ajax_operation('create_thumbnail', $pic_ids, __('Create new thumbnails', 'nggallery'));
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_SelectGallery'])) {
         check_admin_referer('ngg_thickbox_form');
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         $dest_gid = (int) $_POST['dest_gid'];
         switch ($_POST['TB_bulkaction']) {
             case 'copy_to':
                 C_Gallery_Storage::get_instance()->copy_images($pic_ids, $dest_gid);
                 break;
             case 'move_to':
                 C_Gallery_Storage::get_instance()->move_images($pic_ids, $dest_gid);
                 break;
         }
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_EditTags'])) {
         // do tags update
         check_admin_referer('ngg_thickbox_form');
         // get the images list
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         $taglist = explode(',', $_POST['taglist']);
         $taglist = array_map('trim', $taglist);
         if (is_array($pic_ids)) {
             foreach ($pic_ids as $pic_id) {
                 // which action should be performed ?
                 switch ($_POST['TB_bulkaction']) {
                     case 'no_action':
                         // No action
                         break;
                     case 'overwrite_tags':
                         // Overwrite tags
                         wp_set_object_terms($pic_id, $taglist, 'ngg_tag');
                         break;
                     case 'add_tags':
                         // Add / append tags
                         wp_set_object_terms($pic_id, $taglist, 'ngg_tag', TRUE);
                         break;
                     case 'delete_tags':
                         // Delete tags
                         $oldtags = wp_get_object_terms($pic_id, 'ngg_tag', 'fields=names');
                         // get the slugs, to vaoid  case sensitive problems
                         $slugarray = array_map('sanitize_title', $taglist);
                         $oldtags = array_map('sanitize_title', $oldtags);
                         // compare them and return the diff
                         $newtags = array_diff($oldtags, $slugarray);
                         wp_set_object_terms($pic_id, $newtags, 'ngg_tag');
                         break;
                 }
             }
             nggGallery::show_message(__('Tags changed', 'nggallery'));
         }
     }
     if (isset($_POST['updatepictures'])) {
         // Update pictures
         check_admin_referer('ngg_updategallery');
         if (nggGallery::current_user_can('NextGEN Edit gallery options') && !isset($_GET['s'])) {
             $tags = array('<a>', '<abbr>', '<acronym>', '<address>', '<b>', '<base>', '<basefont>', '<big>', '<blockquote>', '<br>', '<br/>', '<caption>', '<center>', '<cite>', '<code>', '<col>', '<colgroup>', '<dd>', '<del>', '<dfn>', '<dir>', '<div>', '<dl>', '<dt>', '<em>', '<fieldset>', '<font>', '<h1>', '<h2>', '<h3>', '<h4>', '<h5>', '<h6>', '<hr>', '<i>', '<ins>', '<label>', '<legend>', '<li>', '<menu>', '<noframes>', '<noscript>', '<ol>', '<optgroup>', '<option>', '<p>', '<pre>', '<q>', '<s>', '<samp>', '<select>', '<small>', '<span>', '<strike>', '<strong>', '<sub>', '<sup>', '<table>', '<tbody>', '<td>', '<tfoot>', '<th>', '<thead>', '<tr>', '<tt>', '<u>', '<ul>');
             $fields = array('title', 'galdesc');
             // Sanitize fields
             foreach ($fields as $field) {
                 $html = $_POST[$field];
                 $html = preg_replace('/\\s+on\\w+=(["\']).*?\\1/i', '', $html);
                 $html = preg_replace('/(<\\/[^>]+?>)(<[^>\\/][^>]*?>)/', '$1 $2', $html);
                 $html = strip_tags($html, implode('', $tags));
                 $_POST[$field] = $html;
             }
             // Update the gallery
             $mapper = C_Gallery_Mapper::get_instance();
             if ($entity = $mapper->find($this->gid)) {
                 foreach ($_POST as $key => $value) {
                     $entity->{$key} = $value;
                 }
                 $mapper->save($entity);
             }
             wp_cache_delete($this->gid, 'ngg_gallery');
         }
         $this->update_pictures();
         //hook for other plugin to update the fields
         do_action('ngg_update_gallery', $this->gid, $_POST);
         nggGallery::show_message(__('Update successful', 'nggallery'));
     }
     if (isset($_POST['scanfolder'])) {
         // Rescan folder
         check_admin_referer('ngg_updategallery');
         $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         nggAdmin::import_gallery($gallerypath, $this->gid);
     }
     // Add a new page
     if (isset($_POST['addnewpage'])) {
         check_admin_referer('ngg_updategallery');
         $parent_id = esc_attr($_POST['parent_id']);
         $gallery_title = esc_attr($_POST['title']);
         $mapper = C_Gallery_Mapper::get_instance();
         $gallery = $mapper->find($this->gid);
         $gallery_name = $gallery->name;
         // Create a WP page
         global $user_ID;
         $page['post_type'] = 'page';
         $page['post_content'] = apply_filters('ngg_add_page_shortcode', '[nggallery id="' . $this->gid . '"]');
         $page['post_parent'] = $parent_id;
         $page['post_author'] = $user_ID;
         $page['post_status'] = 'publish';
         $page['post_title'] = $gallery_title == '' ? $gallery_name : $gallery_title;
         $page = apply_filters('ngg_add_new_page', $page, $this->gid);
         $gallery_pageid = wp_insert_post($page);
         if ($gallery_pageid != 0) {
             $gallery->pageid = $gallery_pageid;
             $mapper->save($gallery);
             nggGallery::show_message(__('New gallery page ID', 'nggallery') . ' ' . $gallery_pageid . ' -> <strong>' . $gallery_title . '</strong> ' . __('created', 'nggallery'));
         }
         do_action('ngg_gallery_addnewpage', $this->gid);
     }
 }
function nggallery_manage_gallery_main()
{
    global $ngg, $nggdb, $wp_query;
    //Build the pagination for more than 25 galleries
    $_GET['paged'] = isset($_GET['paged']) && $_GET['paged'] > 0 ? absint($_GET['paged']) : 1;
    $items_per_page = apply_filters('ngg_manage_galleries_items_per_page', 25);
    $start = ($_GET['paged'] - 1) * $items_per_page;
    if (!empty($_GET['order']) && in_array($_GET['order'], array('DESC', 'ASC'))) {
        $order = $_GET['order'];
    } else {
        $order = apply_filters('ngg_manage_galleries_items_order', 'ASC');
    }
    if (!empty($_GET['orderby']) && in_array($_GET['orderby'], array('gid', 'title', 'author'))) {
        $orderby = $_GET['orderby'];
    } else {
        $orderby = apply_filters('ngg_manage_galleries_items_orderby', 'gid');
    }
    $mapper = C_Gallery_Mapper::get_instance();
    $total_number_of_galleries = $mapper->count();
    $gallerylist = $mapper->select()->order_by($orderby, $order)->limit($items_per_page, $start)->run_query();
    // Need for upgrading from 2.0.40 to 2.0.52 or later.
    // For some reason, the installer doesn't always run.
    // TODO: Remove in 2.1
    if (!$gallerylist) {
        global $wpdb;
        if ($wpdb->get_results("SELECT gid FROM {$wpdb->nggallery} LIMIT 1")) {
            $installer = new C_NggLegacy_Installer();
            $installer->install();
            $gallerylist = $mapper->select()->order_by($orderby, $order)->limit($items_per_page, $start)->run_query();
        }
    }
    $wp_list_table = new _NGG_Galleries_List_Table('nggallery-manage-gallery');
    ?>
	<script type="text/javascript">
	<!--

	// Listen for frame events
	jQuery(function($){
		if ($(this).data('ready')) return;

		if (window.Frame_Event_Publisher) {

			// If a new gallery is added, refresh the page
			Frame_Event_Publisher.listen_for('attach_to_post:new_gallery attach_to_post:manage_images attach_to_post:images_added',function(){
				window.location.href = window.location.href;
			});
		}

		$(this).data('ready', true);
	});


	function checkAll(form)
	{
		for (i = 0, n = form.elements.length; i < n; i++) {
			if(form.elements[i].type == "checkbox") {
				if(form.elements[i].name == "doaction[]") {
					if(form.elements[i].checked == true)
						form.elements[i].checked = false;
					else
						form.elements[i].checked = true;
				}
			}
		}
	}

	function getNumChecked(form)
	{
		var num = 0;
		for (i = 0, n = form.elements.length; i < n; i++) {
			if(form.elements[i].type == "checkbox") {
				if(form.elements[i].name == "doaction[]")
					if(form.elements[i].checked == true)
						num++;
			}
		}
		return num;
	}

	// this function check for a the number of selected images, sumbmit false when no one selected
	function checkSelected() {

        if (typeof document.activeElement == "undefined" && document.addEventListener) {
        	document.addEventListener("focus", function (e) {
        		document.activeElement = e.target;
        	}, true);
        }

        if ( document.activeElement.name == 'post_paged' )
            return true;

		var numchecked = getNumChecked(document.getElementById('editgalleries'));

		if(numchecked < 1) {
			alert('<?php 
    echo esc_js(__('No images selected', 'nggallery'));
    ?>
');
			return false;
		}

		actionId = jQuery('#bulkaction').val();

		switch (actionId) {
			case "resize_images":
                showDialog('resize_images', '<?php 
    echo esc_js(__('Resize images', 'nggallery'));
    ?>
');
				return false;
				break;
			case "new_thumbnail":
				showDialog('new_thumbnail', '<?php 
    echo esc_js(__('Create new thumbnails', 'nggallery'));
    ?>
');
				return false;
				break;
		}

		return confirm('<?php 
    echo sprintf(esc_js(__("You are about to start the bulk edit for %s galleries \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '");
    ?>
');
	}

	function showDialog( windowId, title ) {
		var form = document.getElementById('editgalleries');
		var elementlist = "";
		for (i = 0, n = form.elements.length; i < n; i++) {
			if(form.elements[i].type == "checkbox") {
				if(form.elements[i].name == "doaction[]")
					if(form.elements[i].checked == true)
						if (elementlist == "")
							elementlist = form.elements[i].value;
						else
							elementlist += "," + form.elements[i].value ;
			}
		}
		jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val());
		jQuery("#" + windowId + "_imagelist").val(elementlist);
        // now show the dialog
    	jQuery( "#" + windowId ).dialog({
    		width: 640,
            resizable : false,
    		modal: true,
            title: title,
			position: {
				my:		'center',
				at:		'center',
				of:		window.parent
			}
    	});
        jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); });
	}

	function showAddGallery() {
    	jQuery( "#addGallery").dialog({
    		width: 640,
            resizable : false,
    		modal: true,
            title: '<?php 
    echo esc_js(__('Add new gallery', 'nggallery'));
    ?>
',
			position: {
				my:		'center',
				at:		'center',
				of:		window.parent
			}
    	});
        jQuery("#addGallery .dialog-cancel").click(function() { jQuery( "#addGallery" ).dialog("close"); });
	}
	//-->
	</script>
	<div class="wrap">
		<?php 
    screen_icon('nextgen-gallery');
    ?>
		<h2><?php 
    echo _n('Manage Galleries', 'Manage Galleries', 2, 'nggallery');
    ?>
</h2>
		<form class="search-form" action="" method="get">
		<p class="search-box">
			<label class="hidden" for="media-search-input"><?php 
    _e('Search Images', 'nggallery');
    ?>
:</label>
			<input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" />
			<input type="text" id="media-search-input" name="s" value="<?php 
    the_search_query();
    ?>
" />
			<input type="submit" value="<?php 
    _e('Search Images', 'nggallery');
    ?>
" class="button" />
		</p>
		</form>
		<form id="editgalleries" class="nggform" method="POST" action="<?php 
    echo $ngg->manage_page->base_page . '&amp;paged=' . esc_attr($_GET['paged']);
    ?>
" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_bulkgallery');
    ?>
		<input type="hidden" name="page" value="manage-galleries" />

		<div class="tablenav top">

			<div class="alignleft actions">
				<?php 
    if (function_exists('json_encode')) {
        ?>
				<select name="bulkaction" id="bulkaction">
					<option value="no_action" ><?php 
        _e("Bulk actions", 'nggallery');
        ?>
</option>
					<option value="delete_gallery" ><?php 
        _e("Delete", 'nggallery');
        ?>
</option>
                    <option value="set_watermark" ><?php 
        _e("Set watermark", 'nggallery');
        ?>
</option>
					<option value="new_thumbnail" ><?php 
        _e("Create new thumbnails", 'nggallery');
        ?>
</option>
					<option value="resize_images" ><?php 
        _e("Resize images", 'nggallery');
        ?>
</option>
					<option value="import_meta" ><?php 
        _e("Import metadata", 'nggallery');
        ?>
</option>
					<option value="recover_images" ><?php 
        _e("Recover from backup", 'nggallery');
        ?>
</option>
				</select>
				<input name="showThickbox" class="button-secondary" type="submit" value="<?php 
        _e('Apply', 'nggallery');
        ?>
" onclick="if ( !checkSelected() ) return false;" />
				<?php 
    }
    ?>
				<?php 
    if (current_user_can('NextGEN Upload images') && nggGallery::current_user_can('NextGEN Add new gallery')) {
        ?>
					<input name="doaction" class="button-secondary action" type="submit" onclick="showAddGallery(); return false;" value="<?php 
        _e('Add new gallery', 'nggallery');
        ?>
"/>
				<?php 
    }
    ?>
			</div>


        <?php 
    $ngg->manage_page->pagination('top', $_GET['paged'], $total_number_of_galleries, $items_per_page);
    ?>

		</div>
		<table class="wp-list-table widefat" cellspacing="0">
			<thead>
			<tr>
<?php 
    $wp_list_table->print_column_headers(true);
    ?>
			</tr>
			</thead>
			<tfoot>
			<tr>
<?php 
    $wp_list_table->print_column_headers(false);
    ?>
			</tr>
			</tfoot>
			<tbody id="the-list">
<?php 
    if ($gallerylist) {
        //get the columns
        $gallery_columns = $wp_list_table->get_columns();
        $hidden_columns = get_hidden_columns('nggallery-manage-gallery');
        $num_columns = count($gallery_columns) - count($hidden_columns);
        $image_mapper = C_Image_Mapper::get_instance();
        foreach ($gallerylist as $gallery) {
            $alternate = !isset($alternate) || $alternate == 'class="alternate"' ? '' : 'class="alternate"';
            $gid = $gallery->gid;
            $name = empty($gallery->title) ? $gallery->name : $gallery->title;
            $author_user = get_userdata((int) $gallery->author);
            ?>
		<tr id="gallery-<?php 
            echo $gid;
            ?>
" <?php 
            echo $alternate;
            ?>
 >
		<?php 
            foreach ($gallery_columns as $gallery_column_key => $column_display_name) {
                $class = "class=\"{$gallery_column_key} column-{$gallery_column_key}\"";
                $style = '';
                if (in_array($gallery_column_key, $hidden_columns)) {
                    $style = ' style="display:none;"';
                }
                $attributes = "{$class}{$style}";
                switch ($gallery_column_key) {
                    case 'cb':
                        ?>
        			<th scope="row" class="column-cb check-column">
        				<?php 
                        if (nggAdmin::can_manage_this_gallery($gallery->author)) {
                            ?>
        					<input name="doaction[]" type="checkbox" value="<?php 
                            echo $gid;
                            ?>
" />
        				<?php 
                        }
                        ?>
        			</th>
        			<?php 
                        break;
                    case 'id':
                        ?>
					<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $gid;
                        ?>
</td>
					<?php 
                        break;
                    case 'title':
                        ?>
        			<td class="title column-title">
        				<?php 
                        if (nggAdmin::can_manage_this_gallery($gallery->author)) {
                            ?>
        					<a href="<?php 
                            echo wp_nonce_url($ngg->manage_page->base_page . '&amp;mode=edit&amp;gid=' . $gid, 'ngg_editgallery');
                            ?>
" class='edit' title="<?php 
                            _e('Edit');
                            ?>
" >
        						<?php 
                            echo esc_html(M_I18N::translate($name));
                            ?>
        					</a>
        				<?php 
                        } else {
                            ?>
        					<?php 
                            echo esc_html(M_I18N::translate($gallery->title));
                            ?>
        				<?php 
                        }
                        ?>
                        <div class="row-actions"></div>
        			</td>
        			<?php 
                        break;
                    case 'description':
                        ?>
					<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo esc_html(M_I18N::translate($gallery->galdesc));
                        ?>
&nbsp;</td>
					<?php 
                        break;
                    case 'author':
                        ?>
					<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo esc_html($author_user->display_name);
                        ?>
</td>
					<?php 
                        break;
                    case 'page_id':
                        ?>
        			<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $gallery->pageid;
                        ?>
</td>
        			<?php 
                        break;
                    case 'quantity':
                        $gallery->counter = count($image_mapper->select($image_mapper->get_primary_key_column())->where(array("galleryid = %d", $gallery->{$gallery->id_field}))->run_query(FALSE, FALSE, TRUE));
                        ?>
        			<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $gallery->counter;
                        ?>
</td>
        			<?php 
                        break;
                    default:
                        ?>
					<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        do_action('ngg_manage_gallery_custom_column', $gallery_column_key, $gid);
                        ?>
</td>
					<?php 
                        break;
                }
            }
            ?>
		</tr>
		<?php 
        }
    } else {
        echo '<tr><td colspan="7" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>';
    }
    ?>
			</tbody>
		</table>
        <div class="tablenav bottom">
		<?php 
    $ngg->manage_page->pagination('bottom', $_GET['paged'], $total_number_of_galleries, $items_per_page);
    ?>
        </div>
		</form>
	</div>
	<!-- #addGallery -->
	<div id="addGallery" style="display: none;" >
		<form id="form-tags" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_addgallery');
    ?>
		<input type="hidden" name="page" value="manage-galleries" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
		  	<tr>
		    	<td>
					<strong><?php 
    _e('New Gallery', 'nggallery');
    ?>
:</strong> <input type="text" size="35" name="galleryname" value="" /><br />
					<?php 
    if (!is_multisite()) {
        ?>
					<?php 
        _e('Create a new , empty gallery below the folder', 'nggallery');
        ?>
  <strong><?php 
        echo $ngg->options['gallerypath'];
        ?>
</strong><br />
					<?php 
    }
    ?>
					<i>( <?php 
    _e('Allowed characters for file and folder names are', 'nggallery');
    ?>
: a-z, A-Z, 0-9, -, _ )</i>
				</td>
		  	</tr>
            <?php 
    do_action('ngg_add_new_gallery_form');
    ?>
		  	<tr align="right">
		    	<td class="submit">
		    		<input class="button-primary" type="submit" name="addgallery" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#addGallery -->

	<!-- #resize_images -->
	<div id="resize_images" style="display: none;" >
		<form id="form-resize-images" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-galleries" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<td>
					<strong><?php 
    _e('Resize Images to', 'nggallery');
    ?>
:</strong>
				</td>
				<td>
					<input type="text" size="5" name="imgWidth" value="<?php 
    echo $ngg->options['imgWidth'];
    ?>
" /> x <input type="text" size="5" name="imgHeight" value="<?php 
    echo $ngg->options['imgHeight'];
    ?>
" />
					<br /><small><?php 
    _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery');
    ?>
</small>
				</td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#resize_images -->

	<!-- #new_thumbnail -->
	<div id="new_thumbnail" style="display: none;" >
		<form id="form-new-thumbnail" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-galleries" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<th align="left"><?php 
    _e('Width x height (in pixel)', 'nggallery');
    ?>
</th>
				<td>
				<?php 
    include dirname(__FILE__) . '/thumbnails-template.php';
    ?>
				</td>
			</tr>
			<tr valign="top">
				<th align="left"><?php 
    _e('Set fix dimension', 'nggallery');
    ?>
</th>
				<td><input type="checkbox" name="thumbfix" value="1" <?php 
    checked('1', $ngg->options['thumbfix']);
    ?>
 />
				<br /><small><?php 
    _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery');
    ?>
</small></td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#new_thumbnail -->

<?php 
}
예제 #10
0
 function _get_gallery($id)
 {
     $retval = NULL;
     if (isset($this->galleries[$id])) {
         $retval = $this->galleries[$id];
     } else {
         $retval = C_Gallery_Mapper::get_instance()->find($id);
     }
     return $retval;
 }
 /**
  * Returns the parameter objects necessary for legacy template rendering (legacy_render())
  *
  * @param $images
  * @param $displayed_gallery
  * @param array $params
  *
  * @return array
  */
 function prepare_legacy_parameters($images, $displayed_gallery, $params = array())
 {
     // setup
     $image_map = C_Image_Mapper::get_instance();
     $gallery_map = C_Gallery_Mapper::get_instance();
     $image_key = $image_map->get_primary_key_column();
     $gallery_key = $gallery_map->get_primary_key_column();
     $gallery_id = $displayed_gallery->id();
     $pid = $this->object->param('pid');
     // because picture_list implements ArrayAccess any array-specific actions must be taken on
     // $picture_list->container or they won't do anything
     $picture_list = new C_Image_Wrapper_Collection();
     $current_pid = NULL;
     // begin processing
     $current_page = @get_the_ID() == FALSE ? 0 : @get_the_ID();
     // determine what the "current image" is; used mostly for carousel
     if (!is_numeric($pid) && !empty($pid)) {
         $picture = $image_map->find_first(array('image_slug = %s', $pid));
         $pid = $picture->{$image_key};
     }
     // create our new wrappers
     foreach ($images as &$image) {
         if ($image && isset($params['effect_code'])) {
             if (is_object($image)) {
                 $image->thumbcode = $params['effect_code'];
             } elseif (is_array($image)) {
                 $image['thumbcode'] = $params['effect_code'];
             }
         }
         $new_image = new C_Image_Wrapper($image, $displayed_gallery);
         if ($pid == $new_image->{$image_key}) {
             $current_pid = $new_image;
         }
         $picture_list[] = $new_image;
     }
     reset($picture_list->container);
     // assign current_pid
     $current_pid = is_null($current_pid) ? current($picture_list->container) : $current_pid;
     foreach ($picture_list as &$image) {
         if (isset($image->hidden) && $image->hidden) {
             $tmp = $displayed_gallery->display_settings['number_of_columns'];
             $image->style = $tmp > 0 ? 'style="width:' . floor(100 / $tmp) . '%;display: none;"' : 'style="display: none;"';
         }
     }
     // find our gallery to build the new one on
     $orig_gallery = $gallery_map->find(current($picture_list->container)->galleryid);
     // create the 'gallery' object
     $gallery = new stdclass();
     $gallery->ID = $displayed_gallery->id();
     $gallery->name = stripslashes($orig_gallery->name);
     $gallery->title = stripslashes($orig_gallery->title);
     $gallery->description = html_entity_decode(stripslashes($orig_gallery->galdesc));
     $gallery->pageid = $orig_gallery->pageid;
     $gallery->anchor = 'ngg-gallery-' . $gallery_id . '-' . $current_page;
     $gallery->displayed_gallery =& $displayed_gallery;
     $gallery->columns = @intval($displayed_gallery->display_settings['number_of_columns']);
     $gallery->imagewidth = $gallery->columns > 0 ? 'style="width:' . floor(100 / $gallery->columns) . '%;"' : '';
     if (!empty($displayed_gallery->display_settings['show_slideshow_link'])) {
         $gallery->show_slideshow = TRUE;
         $gallery->slideshow_link = $params['slideshow_link'];
         $gallery->slideshow_link_text = $displayed_gallery->display_settings['slideshow_link_text'];
     } else {
         $gallery->show_slideshow = FALSE;
     }
     $gallery = apply_filters('ngg_gallery_object', $gallery, 4);
     // build our array of things to return
     $return = array('registry' => C_Component_Registry::get_instance(), 'gallery' => $gallery);
     // single_image is an internally added flag
     if (!empty($params['single_image'])) {
         $return['image'] = $picture_list[0];
     } else {
         $return['current'] = $current_pid;
         $return['images'] = $picture_list->container;
     }
     // this is expected to always exist
     if (!empty($params['pagination'])) {
         $return['pagination'] = $params['pagination'];
     } else {
         $return['pagination'] = NULL;
     }
     if (!empty($params['next'])) {
         $return['next'] = $params['next'];
     } else {
         $return['next'] = FALSE;
     }
     if (!empty($params['prev'])) {
         $return['prev'] = $params['prev'];
     } else {
         $return['prev'] = FALSE;
     }
     return $return;
 }
예제 #12
0
 /**
  * nggAdmin::set_gallery_preview() - define a preview pic after the first upload, can be changed in the gallery settings
  *
  * @class nggAdmin
  * @param int $galleryID
  * @return void
  */
 static function set_gallery_preview($galleryID)
 {
     $gallery_mapper = C_Gallery_Mapper::get_instance();
     if ($gallery = $gallery_mapper->find($galleryID)) {
         if (!$gallery->previewpic) {
             $image_mapper = C_Image_Mapper::get_instance();
             if ($image = $image_mapper->select()->where(array('galleryid = %d', $galleryID))->where(array('exclude != 1'))->order_by($image_mapper->get_primary_key_column())->limit(1)->run_query()) {
                 $gallery->previewpic = $image->{$image->id_field};
                 $gallery_mapper->save($gallery);
             }
         }
     }
 }
 /**
  * Renders the front-end for the NextGen Basic Album display type
  *
  * @param $displayed_gallery
  * @param bool $return
  */
 public function index_action($displayed_gallery, $return = FALSE)
 {
     $display_settings = $displayed_gallery->display_settings;
     // We need to fetch the album containers selected in the Attach
     // to Post interface. We need to do this, because once we fetch the
     // included entities, we need to iterate over each entity and assign it
     // a parent_id, which is the album that it belongs to. We need to do this
     // because the link to the gallery, is not /nggallery/gallery--id, but
     // /nggallery/album--id/gallery--id
     // Are we to display a gallery?
     if ($gallery = $gallery_slug = $this->param('gallery')) {
         // basic albums only support one per post
         if (isset($GLOBALS['nggShowGallery'])) {
             return;
         }
         $GLOBALS['nggShowGallery'] = TRUE;
         // Try finding the gallery by slug first. If nothing is found, we assume that
         // the user passed in a gallery id instead
         $mapper = C_Gallery_Mapper::get_instance();
         $result = reset($mapper->select()->where(array('slug = %s', $gallery))->limit(1)->run_query());
         if ($result) {
             $gallery = $result->{$result->id_field};
         }
         $renderer = C_Displayed_Gallery_Renderer::get_instance('inner');
         $gallery_params = array('source' => 'galleries', 'container_ids' => array($gallery), 'display_type' => $display_settings['gallery_display_type'], 'original_display_type' => $displayed_gallery->display_type, 'original_settings' => $display_settings);
         if (!empty($display_settings['gallery_display_template'])) {
             $gallery_params['template'] = $display_settings['gallery_display_template'];
         }
         return $renderer->display_images($gallery_params, $return);
     } else {
         if ($album = $this->param('album')) {
             $mapper = C_Album_Mapper::get_instance();
             $result = array_pop($mapper->select()->where(array('slug = %s', $album))->limit(1)->run_query());
             $album_sub = $result ? $result->{$result->id_field} : null;
             if ($album_sub != null) {
                 $album = $album_sub;
             }
             $displayed_gallery->entity_ids = array();
             $displayed_gallery->sortorder = array();
             $displayed_gallery->container_ids = ($album === '0' or $album === 'all') ? array() : array($album);
         }
     }
     // Get the albums
     // TODO: This should probably be moved to the elseif block above
     $this->albums = $displayed_gallery->get_albums();
     // None of the above: Display the main album. Get the settings required for display
     $current_page = (int) $this->param('nggpage', 1);
     $offset = $display_settings['galleries_per_page'] * ($current_page - 1);
     $entities = $displayed_gallery->get_included_entities($display_settings['galleries_per_page'], $offset);
     // If there are entities to be displayed
     if ($entities) {
         if (!empty($display_settings['template'])) {
             // Add additional parameters
             $pagination_result = $this->object->create_pagination($current_page, $displayed_gallery->get_entity_count(), $display_settings['galleries_per_page'], urldecode($this->object->param('ajax_pagination_referrer')));
             $this->object->remove_param('ajax_pagination_referrer');
             $display_settings['current_page'] = $current_page;
             $display_settings['entities'] =& $entities;
             $display_settings['pagination_prev'] = $pagination_result['prev'];
             $display_settings['pagination_next'] = $pagination_result['next'];
             $display_settings['pagination'] = $pagination_result['output'];
             // Render legacy template
             $this->object->add_mixin('Mixin_NextGen_Basic_Templates');
             $display_settings = $this->prepare_legacy_album_params($displayed_gallery->get_entity(), $display_settings);
             return $this->object->legacy_render($display_settings['template'], $display_settings, $return, 'album');
         } else {
             $params = $display_settings;
             $albums = $this->prepare_legacy_album_params($displayed_gallery->get_entity(), array('entities' => $entities));
             $params['image_gen_params'] = $albums['image_gen_params'];
             $params['galleries'] = $albums['galleries'];
             $params['displayed_gallery'] = $displayed_gallery;
             $params = $this->object->prepare_display_parameters($displayed_gallery, $params);
             switch ($displayed_gallery->display_type) {
                 case NGG_BASIC_COMPACT_ALBUM:
                     $template = 'compact';
                     break;
                 case NGG_BASIC_EXTENDED_ALBUM:
                     $template = 'extended';
                     break;
             }
             return $this->object->render_view("photocrati-nextgen_basic_album#{$template}", $params, $return);
         }
     } else {
         return $this->object->render_partial('photocrati-nextgen_gallery_display#no_images_found', array(), $return);
     }
 }
 function widget($args, $instance)
 {
     $router = C_Router::get_instance();
     wp_enqueue_style('nextgen_widgets_style', $router->get_static_url('photocrati-widget#widgets.css'), FALSE, NGG_SCRIPT_VERSION);
     wp_enqueue_style('nextgen_basic_thumbnails_style', $router->get_static_url('photocrati-nextgen_basic_gallery#thumbnails/nextgen_basic_thumbnails.css'), FALSE, NGG_SCRIPT_VERSION);
     // these are handled by extract() but I want to silence my IDE warnings that these vars don't exist
     $before_widget = NULL;
     $before_title = NULL;
     $after_widget = NULL;
     $after_title = NULL;
     $widget_id = NULL;
     extract($args);
     $title = apply_filters('widget_title', empty($instance['title']) ? '&nbsp;' : $instance['title'], $instance, $this->id_base);
     $renderer = C_Displayed_Gallery_Renderer::get_instance();
     $factory = C_Component_Factory::get_instance();
     $view = $factory->create('mvc_view', '');
     // IE8 webslice support if needed
     if (!empty($instance['webslice'])) {
         $before_widget .= '<div class="hslice" id="ngg-webslice">';
         $before_title = str_replace('class="', 'class="entry-title ', $before_title);
         $after_widget = '</div>' . $after_widget;
     }
     $source = $instance['type'] == 'random' ? 'random_images' : 'recent';
     $template = !empty($instance['template']) ? $instance['template'] : $view->get_template_abspath('photocrati-widget#display_gallery');
     $params = array('slug' => 'widget-' . $args['widget_id'], 'source' => $source, 'display_type' => NGG_BASIC_THUMBNAILS, 'images_per_page' => $instance['items'], 'maximum_entity_count' => $instance['items'], 'template' => $template, 'image_type' => $instance['show'] == 'original' ? 'full' : 'thumb', 'show_all_in_lightbox' => FALSE, 'show_slideshow_link' => FALSE, 'show_thumbnail_link' => FALSE, 'use_imagebrowser_effect' => FALSE, 'disable_pagination' => TRUE, 'image_width' => $instance['width'], 'image_height' => $instance['height'], 'ngg_triggers_display' => 'never', 'widget_setting_title' => $title, 'widget_setting_before_widget' => $before_widget, 'widget_setting_before_title' => $before_title, 'widget_setting_after_widget' => $after_widget, 'widget_setting_after_title' => $after_title, 'widget_setting_width' => $instance['width'], 'widget_setting_height' => $instance['height'], 'widget_setting_show_setting' => $instance['show'], 'widget_setting_widget_id' => $widget_id);
     switch ($instance['exclude']) {
         case 'all':
             break;
         case 'denied':
             $mapper = C_Gallery_Mapper::get_instance();
             $gallery_ids = array();
             $list = explode(',', $instance['list']);
             foreach ($mapper->find_all() as $gallery) {
                 if (!in_array($gallery->{$gallery->id_field}, $list)) {
                     $gallery_ids[] = $gallery->{$gallery->id_field};
                 }
             }
             $params['container_ids'] = implode(',', $gallery_ids);
             break;
         case 'allow':
             $params['container_ids'] = $instance['list'];
             break;
     }
     echo $renderer->display_images($params);
 }
 function index_action()
 {
     $factory = C_Component_Factory::get_instance();
     $router = C_Router::get_instance();
     $gallery_mapper = C_Gallery_Mapper::get_instance();
     $lightbox_mapper = $this->object->get_registry()->get_utility('I_Lightbox_Library_Mapper');
     // retrieve by transient id
     $transient_id = $this->object->param('id');
     // ! denotes a non-nextgen gallery -- skip processing them
     if ($transient_id !== '!') {
         $displayed_gallery = $factory->create('displayed_gallery', array(), $gallery_mapper);
         if (!$displayed_gallery->apply_transient($transient_id)) {
             $response = array();
             // if the transient does not exist we make an HTTP request to the referer to rebuild the transient
             if (!empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], home_url()) !== FALSE) {
                 $referrer = $_SERVER['HTTP_REFERER'];
                 if (strpos($referrer, '?') === FALSE) {
                     $referrer .= '?ngg_no_resources=1';
                 } else {
                     $referrer .= '&ngg_no_resources=1';
                 }
                 $response = wp_remote_get($referrer);
             }
             // WP has cached the results of our last get_transient() calls and must be flushed
             global $wp_object_cache;
             $wp_object_cache->flush();
             // and try again to retrieve the transient
             if (!$displayed_gallery->apply_transient($transient_id)) {
                 $displayed_gallery->id($transient_id);
             }
         }
         $displayed_gallery_id = $displayed_gallery->id();
     } else {
         $displayed_gallery_id = '!';
     }
     // TODO: (possibly?) find a better solution, This feels too hackish.
     // Remove all currently enqueued CSS & JS. Resources needed by the pro-lightbox incidentally happen
     // to be enqueued after this particular code is run anyway.
     global $wp_styles;
     global $wp_scripts;
     $wp_styles->queue = array();
     $wp_scripts->queue = array();
     // our only necessary script
     wp_enqueue_script('galleria', $this->object->get_static_url('photocrati-galleria#galleria-1.2.9.min.js'), array('jquery'), FALSE, FALSE);
     wp_enqueue_script('pro-lightbox-galleria-init', $this->object->get_static_url('photocrati-nextgen_pro_lightbox_legacy#galleria_init.js'), array('galleria'), FALSE, FALSE);
     if (!wp_style_is('fontawesome', 'registered')) {
         C_Display_Type_Controller::get_instance()->enqueue_displayed_gallery_trigger_buttons_resources();
     }
     wp_enqueue_style('fontawesome');
     wp_enqueue_script('velocity', $this->object->get_static_url('photocrati-nextgen_pro_lightbox_legacy#jquery.velocity.min.js'));
     // retrieve and add some fields to the lightbox settings
     $library = $lightbox_mapper->find_by_name(NGG_PRO_LIGHTBOX, TRUE);
     $ls =& $library->display_settings;
     $ls['theme'] = $this->object->get_static_url('photocrati-nextgen_pro_lightbox_legacy#theme/galleria.nextgen_pro_lightbox.js');
     $ls['load_images_url'] = $router->get_url('/nextgen-pro-lightbox-load-images/' . $transient_id, TRUE, 'root');
     $ls['gallery_url'] = $router->get_url('/nextgen-pro-lightbox-gallery/{gallery_id}/', TRUE, 'root');
     $ls['share_url'] = $router->get_url('/nextgen-share/{gallery_id}/{image_id}/{named_size}', TRUE, 'root');
     $ls['wp_site_url'] = $router->get_base_url();
     $ls['image_protect'] = !empty(C_NextGen_Settings::get_instance()->protect_images) ? TRUE : FALSE;
     if (!empty($ls['style'])) {
         wp_enqueue_style('nextgen_pro_lightbox_user_style', $router->get_static_url('photocrati-nextgen_pro_lightbox_legacy#styles/' . $ls['style']));
     }
     // this should come after all other enqueue'ings
     $settings = C_NextGen_Settings::get_instance();
     if ((!is_multisite() || is_multisite() && $settings->wpmuStyle) && $settings->activateCSS) {
         wp_enqueue_style('nggallery', C_NextGen_Style_Manager::get_instance()->get_selected_stylesheet_url());
     }
     // The Pro Lightbox can be extended with components that enqueue their own resources
     // and render some markup
     $component_markup = array();
     foreach ($this->object->_components as $name => $handler) {
         $handler = new $handler();
         $handler->name = $name;
         if (!empty($displayed_gallery)) {
             $handler->displayed_gallery = $displayed_gallery;
         }
         $handler->lightbox_library = $library;
         $handler->enqueue_static_resources();
         $component_markup[] = $handler->render();
     }
     $params = array('displayed_gallery_id' => $displayed_gallery_id, 'lightbox_settings' => $library->display_settings, 'component_markup' => implode("\n", $component_markup));
     return $this->object->render_view('photocrati-nextgen_pro_lightbox_legacy#index', $params, FALSE);
 }
 /**
  * Returns the galleries queries in this displayed gallery
  * @return array
  */
 public function get_galleries()
 {
     $retval = array();
     if ($source = $this->object->get_source()) {
         if (in_array('image', $source->returns)) {
             $mapper = C_Gallery_Mapper::get_instance();
             $gallery_key = $mapper->get_primary_key_column();
             $mapper->select();
             if ($this->object->container_ids) {
                 $mapper->where(array("{$gallery_key} IN %s", $this->object->container_ids));
             }
             $retval = $mapper->run_query();
         }
     }
     return $retval;
 }
예제 #17
0
/**
 * Send custom event about 1st gallery creation.
 *
 * @author Vova Feldman (@svovaf)
 */
function fs_track_new_gallery()
{
    global $ngg_fs;
    $galleries = C_Gallery_Mapper::get_instance()->count();
    if (1 == $galleries) {
        // Only track event on 1st gallery creation.
        $ngg_fs->track_event_once('new_gallery');
    }
}
예제 #18
0
 function remove_collection($collectionId)
 {
     global $wplr;
     $id = $wplr->get_meta("nextgen_gallery_id", $collectionId);
     C_Gallery_Mapper::get_instance()->destroy($id, TRUE);
     $wplr->delete_meta("nextgen_gallery_id", $collectionId);
 }
예제 #19
0
 /**
  * Registers gallery strings with WPML
  *
  * @param object $gallery
  */
 function register_gallery_strings($gallery_id)
 {
     if (function_exists('icl_register_string')) {
         $gallery = C_Gallery_Mapper::get_instance()->find($gallery_id);
         if ($gallery) {
             icl_register_string('plugin_ngg', 'gallery_' . $gallery->{$gallery->id_field} . '_name', $gallery->title, TRUE);
             icl_register_string('plugin_ngg', 'gallery_' . $gallery->{$gallery->id_field} . '_description', $gallery->galdesc, TRUE);
         }
     }
 }
 /**
  * Set up and register our settings
  */
 public function plugin_settings()
 {
     // Register our settings section
     add_settings_section('npu_settings', __('Settings', 'nextgen-public-uploader'), array($this, 'settings_description'), 'nextgen-public-uploader');
     // Register all our settings
     register_setting('npu_settings', 'npu_default_gallery', array($this, 'settings_sanitization'));
     register_setting('npu_settings', 'npu_user_role_select', array($this, 'settings_sanitization'));
     register_setting('npu_settings', 'npu_image_description_select', array($this, 'settings_sanitization'));
     register_setting('npu_settings', 'npu_exclude_select', array($this, 'settings_sanitization'));
     register_setting('npu_settings', 'npu_notification_email', array($this, 'settings_sanitization'));
     register_setting('npu_settings', 'npu_upload_button', array($this, 'settings_sanitization'));
     register_setting('npu_settings', 'npu_no_file', array($this, 'settings_sanitization'));
     register_setting('npu_settings', 'npu_description_text', array($this, 'settings_sanitization'));
     register_setting('npu_settings', 'npu_notlogged', array($this, 'settings_sanitization'));
     register_setting('npu_settings', 'npu_upload_success', array($this, 'settings_sanitization'));
     register_setting('npu_settings', 'npu_upload_failed', array($this, 'settings_sanitization'));
     // Setup the options for our gallery selector
     $gallery_options = array();
     $mapper = C_Gallery_Mapper::get_instance();
     $gallerylist = $mapper->find_all();
     foreach ($gallerylist as $gallery) {
         $name = !empty($gallery->title) ? $gallery->title : $gallery->name;
         $gallery_options[$gallery->gid] = $gallery->gid . ' &ndash; ' . $name;
     }
     $role_options = apply_filters('npu_plugin_roles', array('99' => __('Visitor', 'nextgen-public-uploader'), '0' => __('Subscriber', 'nextgen-public-uploader'), '1' => __('Contributor', 'nextgen-public-uploader'), '2' => __('Author', 'nextgen-public-uploader'), '7' => __('Editor', 'nextgen-public-uploader'), '10' => __('Admin', 'nextgen-public-uploader')));
     // Add our settings fields
     add_settings_field('npu_default_gallery', __('Default Gallery:', 'nextgen-public-uploader'), array($this, 'settings_select'), 'nextgen-public-uploader', 'npu_settings', array('ID' => 'npu_default_gallery', 'description' => sprintf(__('The default gallery ID when using %s with no ID specified.', 'nextgen-public-uploader'), '<code>[ngg_uploader]</code>'), 'options' => $gallery_options));
     add_settings_field('npu_user_role_select', __('Minimum User Role:', 'nextgen-public-uploader'), array($this, 'settings_select'), 'nextgen-public-uploader', 'npu_settings', array('ID' => 'npu_user_role_select', 'description' => __('The minimum user role required for image uploading.', 'nextgen-public-uploader'), 'options' => $role_options));
     add_settings_field('npu_exclude_select', __('Uploads Require Approval:', 'nextgen-public-uploader'), array($this, 'settings_checkbox'), 'nextgen-public-uploader', 'npu_settings', array('ID' => 'npu_exclude_select', 'description' => '', 'value' => 'Enabled', 'label' => __('Exclude images from appearing in galleries until they have been approved.', 'nextgen-public-uploader')));
     add_settings_field('npu_image_description_select', __('Show Description Field:', 'nextgen-public-uploader'), array($this, 'settings_checkbox'), 'nextgen-public-uploader', 'npu_settings', array('ID' => 'npu_image_description_select', 'description' => '', 'value' => 'Enabled', 'label' => __('Enable the Image Description text field.', 'nextgen-public-uploader')));
     add_settings_field('npu_description_text', __('Image Description Label:', 'nextgen-public-uploader'), array($this, 'settings_text'), 'nextgen-public-uploader', 'npu_settings', array('ID' => 'npu_description_text', 'description' => __('Default label shown for the image description textbox.', 'nextgen-public-uploader')));
     add_settings_field('npu_notification_email', __('Notification Email:', 'nextgen-public-uploader'), array($this, 'settings_text'), 'nextgen-public-uploader', 'npu_settings', array('ID' => 'npu_notification_email', 'description' => __('The email address to be notified when a image has been submitted.', 'nextgen-public-uploader')));
     add_settings_field('npu_upload_button', __('Upload Button Text:', 'nextgen-public-uploader'), array($this, 'settings_text'), 'nextgen-public-uploader', 'npu_settings', array('ID' => 'npu_upload_button', 'description' => __('Custom text for upload button.', 'nextgen-public-uploader')));
     add_settings_field('npu_no_file', __('No File Selected Warning:', 'nextgen-public-uploader'), array($this, 'settings_text'), 'nextgen-public-uploader', 'npu_settings', array('ID' => 'npu_no_file', 'description' => __('Warning displayed when no file has been selected for upload.', 'nextgen-public-uploader')));
     add_settings_field('npu_notlogged', __('Unauthorized Warning:', 'nextgen-public-uploader'), array($this, 'settings_text'), 'nextgen-public-uploader', 'npu_settings', array('ID' => 'npu_notlogged', 'description' => __('Warning displayed when a user does not have permission to upload.', 'nextgen-public-uploader')));
     add_settings_field('npu_upload_success', __('Upload Success Message:', 'nextgen-public-uploader'), array($this, 'settings_text'), 'nextgen-public-uploader', 'npu_settings', array('ID' => 'npu_upload_success', 'description' => __('Message displayed when an image has been successfully uploaded.', 'nextgen-public-uploader')));
     add_settings_field('npu_upload_failed', __('Upload Failed Message:', 'nextgen-public-uploader'), array($this, 'settings_text'), 'nextgen-public-uploader', 'npu_settings', array('ID' => 'npu_upload_failed', 'description' => __('Message displayed when an image failed to upload.', 'nextgen-public-uploader')));
 }
예제 #21
0
 /**
  * Returns all galleries
  * @param $args (blog_id, username, password)
  */
 function get_galleries($args)
 {
     $retval = new IXR_Error(403, 'Invalid username or password');
     $blog_id = intval($args[0]);
     $username = strval($args[1]);
     $password = strval($args[2]);
     // Authenticate the user
     if ($this->login($username, $password, $blog_id)) {
         // Do we have permission?
         $security = $this->get_registry()->get_utility('I_Security_Manager');
         if ($security->is_allowed('nextgen_edit_gallery')) {
             $mapper = C_Gallery_Mapper::get_instance();
             $image_mapper = C_Image_Mapper::get_instance();
             $storage = C_Gallery_Storage::get_instance();
             $retval = array();
             foreach ($mapper->find_all() as $gallery) {
                 // Vladimir's Lightroom plugins requires the 'id' to be a string
                 // Ask if he can accept integers as well. Currently, integers break
                 // his plugin
                 $gallery->gid = (string) $gallery->gid;
                 // Set other gallery properties
                 $image_counter = array_pop($image_mapper->select('COUNT(*) as counter')->where(array("galleryid = %d", $gallery->gid))->run_query());
                 $gallery->counter = $image_counter->counter;
                 $gallery->abspath = $storage->get_gallery_abspath($gallery);
                 $retval[$gallery->{$gallery->id_field}] = (array) $gallery;
             }
         } else {
             $retval = new IXR_Error(401, __('Sorry, you must be able to manage galleries'));
         }
     }
     return $retval;
 }
 /**
  * Renders the front-end for the NextGen Basic Album display type
  *
  * @param $displayed_gallery
  * @param bool $return
  */
 public function index_action($displayed_gallery, $return = FALSE)
 {
     // Ensure that the open_gallery_in_lightbox setting is present
     if (!array_key_exists('open_gallery_in_lightbox', $displayed_gallery->display_settings)) {
         $displayed_gallery->display_settings['open_gallery_in_lightbox'] = 0;
     }
     $display_settings = $displayed_gallery->display_settings;
     // We need to fetch the album containers selected in the Attach
     // to Post interface. We need to do this, because once we fetch the
     // included entities, we need to iterate over each entity and assign it
     // a parent_id, which is the album that it belongs to. We need to do this
     // because the link to the gallery, is not /nggallery/gallery--id, but
     // /nggallery/album--id/gallery--id
     $parent_albums = $displayed_gallery->get_albums();
     // Are we to display a gallery? Ensure our 'gallery' isn't just a paginated album view
     $gallery = $gallery_slug = $this->param('gallery');
     if ($gallery && strpos($gallery, 'nggpage--') !== 0) {
         // basic albums only support one per post
         if (isset($GLOBALS['nggShowGallery'])) {
             return;
         }
         $GLOBALS['nggShowGallery'] = TRUE;
         // Try finding the gallery by slug first. If nothing is found, we assume that
         // the user passed in a gallery id instead
         $mapper = C_Gallery_Mapper::get_instance();
         $tmp = $mapper->select()->where(array('slug = %s', $gallery))->limit(1)->run_query();
         $result = reset($tmp);
         unset($tmp);
         if ($result) {
             $gallery = $result->{$result->id_field};
         }
         $renderer = C_Displayed_Gallery_Renderer::get_instance('inner');
         $gallery_params = array('source' => 'galleries', 'container_ids' => array($gallery), 'display_type' => $display_settings['gallery_display_type'], 'original_display_type' => $displayed_gallery->display_type, 'original_settings' => $display_settings, 'original_album_entities' => $parent_albums);
         if (!empty($display_settings['gallery_display_template'])) {
             $gallery_params['template'] = $display_settings['gallery_display_template'];
         }
         add_filter('ngg_displayed_gallery_rendering', array($this, 'add_description_to_legacy_templates'), 8, 2);
         add_filter('ngg_displayed_gallery_rendering', array($this, 'add_breadcrumbs_to_legacy_templates'), 9, 2);
         $output = $renderer->display_images($gallery_params, $return);
         remove_filter('ngg_displayed_gallery_rendering', array($this, 'add_breadcrumbs_to_legacy_templates'));
         remove_filter('ngg_displayed_gallery_rendering', array($this, 'add_description_to_legacy_templates'));
         return $output;
     } else {
         if ($album = $this->param('album')) {
             $mapper = C_Album_Mapper::get_instance();
             $result = $mapper->select()->where(array('slug = %s', $album))->limit(1)->run_query();
             $result = array_pop($result);
             $album_sub = $result ? $result->{$result->id_field} : null;
             if ($album_sub != null) {
                 $album = $album_sub;
             }
             $displayed_gallery->entity_ids = array();
             $displayed_gallery->sortorder = array();
             $displayed_gallery->container_ids = ($album === '0' or $album === 'all') ? array() : array($album);
             $displayed_gallery->display_settings['original_album_id'] = 'a' . $album_sub;
             $displayed_gallery->display_settings['original_album_entities'] = $parent_albums;
         }
     }
     // Get the albums
     // TODO: This should probably be moved to the elseif block above
     $this->albums = $displayed_gallery->get_albums();
     // None of the above: Display the main album. Get the settings required for display
     $current_page = (int) $this->param('page', $displayed_gallery->id(), 1);
     $offset = $display_settings['galleries_per_page'] * ($current_page - 1);
     $entities = $displayed_gallery->get_included_entities($display_settings['galleries_per_page'], $offset);
     // If there are entities to be displayed
     if ($entities) {
         $pagination_result = $this->object->create_pagination($current_page, $displayed_gallery->get_entity_count(), $display_settings['galleries_per_page'], urldecode($this->object->param('ajax_pagination_referrer')));
         if (!empty($display_settings['template']) && $display_settings['template'] != 'default') {
             // Add additional parameters
             $this->object->remove_param('ajax_pagination_referrer');
             $display_settings['current_page'] = $current_page;
             $display_settings['entities'] =& $entities;
             $display_settings['pagination_prev'] = $pagination_result['prev'];
             $display_settings['pagination_next'] = $pagination_result['next'];
             $display_settings['pagination'] = $pagination_result['output'];
             // Legacy templates lack a good way of injecting content at the right time
             $this->object->add_mixin('A_NextGen_Album_Breadcrumbs');
             $this->object->add_mixin('A_NextGen_Album_Descriptions');
             $breadcrumbs = $this->object->render_legacy_template_breadcrumbs($displayed_gallery, $entities);
             $description = $this->object->render_legacy_template_description($displayed_gallery);
             // Render legacy template
             $this->object->add_mixin('Mixin_NextGen_Basic_Templates');
             $display_settings = $this->prepare_legacy_album_params($displayed_gallery->get_entity(), $display_settings);
             $retval = $this->object->legacy_render($display_settings['template'], $display_settings, $return, 'album');
             if (!empty($description)) {
                 $retval = $description . $retval;
             }
             if (!empty($breadcrumbs)) {
                 $retval = $breadcrumbs . $retval;
             }
             return $retval;
         } else {
             $params = $display_settings;
             $albums = $this->prepare_legacy_album_params($displayed_gallery->get_entity(), array('entities' => $entities));
             $params['pagination'] = $pagination_result['output'];
             $params['image_gen_params'] = $albums['image_gen_params'];
             $params['galleries'] = $albums['galleries'];
             foreach ($params['galleries'] as &$gallery) {
                 $gallery->entity_type = isset($gallery->is_gallery) && intval($gallery->is_gallery) ? 'gallery' : 'album';
                 // If we're to open a gallery in a lightbox, we need to expose it to the lightbox
                 // as a displayed gallery
                 if (isset($params['open_gallery_in_lightbox']) && $gallery->entity_type == 'gallery') {
                     $gallery->displayed_gallery = new C_Displayed_Gallery();
                     $gallery->displayed_gallery->container_ids = array($gallery->{$gallery->id_field});
                     $gallery->displayed_gallery->display_settings = $displayed_gallery->display_settings;
                     $gallery->displayed_gallery->returns = 'included';
                     $gallery->displayed_gallery->source = 'galleries';
                     $gallery->displayed_gallery->images_list_count = $gallery->displayed_gallery->get_entity_count();
                     $gallery->displayed_gallery->is_album_gallery = TRUE;
                     $gallery->displayed_gallery->to_transient();
                     if ($this->does_lightbox_support_displayed_gallery($displayed_gallery)) {
                         $gallery->displayed_gallery->effect_code = $this->object->get_effect_code($gallery->displayed_gallery);
                     }
                     // Add "galleries.gallery_1 = {};"
                     $this->object->_add_script_data('ngg_common', 'galleries.gallery_' . $gallery->displayed_gallery->id(), (array) $gallery->displayed_gallery->get_entity(), FALSE);
                     $this->object->_add_script_data('ngg_common', 'galleries.gallery_' . $gallery->displayed_gallery->id() . '.wordpress_page_root', get_permalink(), FALSE);
                 }
             }
             $params['displayed_gallery'] = $displayed_gallery;
             $params = $this->object->prepare_display_parameters($displayed_gallery, $params);
             switch ($displayed_gallery->display_type) {
                 case NGG_BASIC_COMPACT_ALBUM:
                     $template = 'compact';
                     break;
                 case NGG_BASIC_EXTENDED_ALBUM:
                     $template = 'extended';
                     break;
             }
             return $this->object->render_view("photocrati-nextgen_basic_album#{$template}", $params, $return);
         }
     } else {
         return $this->object->render_partial('photocrati-nextgen_gallery_display#no_images_found', array(), $return);
     }
 }
예제 #23
0
 /**
  * Gets a single gallery instance
  * @param $args (blog_id, username, password, gallery_id)
  */
 function get_gallery($args, $return_model = FALSE)
 {
     $retval = new IXR_Error(403, 'Invalid username or password');
     $blog_id = intval($args[0]);
     $username = strval($args[1]);
     $password = strval($args[2]);
     $gallery_id = intval($args[3]);
     // Authenticate the user
     if ($this->_login($username, $password, $blog_id)) {
         $mapper = C_Gallery_Mapper::get_instance();
         if ($gallery = $mapper->find($gallery_id, TRUE)) {
             if ($this->_can_manage_gallery($gallery)) {
                 $this->_add_gallery_properties($gallery);
                 $retval = $return_model ? $gallery : $gallery->get_entity();
             } else {
                 $retval = new IXR_Error(403, "Sorry, but you don't have permission to manage gallery #{$gallery->gid}");
             }
         } else {
             $retval = FALSE;
         }
     }
     return $retval;
 }
예제 #24
0
 /**
  * Retrieves I_Gallery_Mapper instance.
  *
  * @param int $gallery_id Gallery ID
  * @return mixed
  */
 function get_legacy_gallery($gallery_id)
 {
     return C_Gallery_Mapper::get_instance()->find($gallery_id);
 }
 public function get_galleries()
 {
     $security = $this->get_registry()->get_utility('I_Security_Manager');
     $sec_actor = $security->get_current_actor();
     $galleries = array();
     if ($sec_actor->is_allowed('nextgen_edit_gallery')) {
         $gallery_mapper = C_Gallery_Mapper::get_instance();
         $galleries = $gallery_mapper->find_all();
         if (!$sec_actor->is_allowed('nextgen_edit_gallery_unowned')) {
             $galleries_all = $galleries;
             $galleries = array();
             foreach ($galleries_all as $gallery) {
                 if ($sec_actor->is_user() && $sec_actor->get_entity_id() == (int) $gallery->author) {
                     $galleries[] = $gallery;
                 }
             }
         }
     }
     return $galleries;
 }
 /**
  * Retrieves and caches an I_Gallery_Mapper instance for this gallery id
  *
  * @param int $gallery_id Gallery ID
  * @return mixed
  */
 public function get_gallery($gallery_id)
 {
     if (!isset($this->galleries[$gallery_id]) || is_null($this->galleries[$gallery_id])) {
         $this->galleries[$gallery_id] = C_Gallery_Mapper::get_instance();
     }
     return $this->galleries[$gallery_id];
 }
예제 #27
0
function nggallery_picturelist($controller)
{
    // *** show picture list
    global $wpdb, $nggdb, $user_ID, $ngg;
    // Look if its a search result
    $is_search = isset($_GET['s']) ? true : false;
    $counter = 0;
    $wp_list_table = new _NGG_Images_List_Table('nggallery-manage-images');
    if ($is_search) {
        // fetch the imagelist
        $picturelist = $ngg->manage_page->search_result;
        // we didn't set a gallery or a pagination
        $act_gid = 0;
        $_GET['paged'] = 1;
        $page_links = false;
    } else {
        // GET variables
        $act_gid = $ngg->manage_page->gid;
        // Load the gallery metadata
        $mapper = C_Gallery_Mapper::get_instance();
        $gallery = $mapper->find($act_gid);
        if (!$gallery) {
            nggGallery::show_error(__('Gallery not found.', 'nggallery'));
            return;
        }
        // Check if you have the correct capability
        if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
            nggGallery::show_error(__('Sorry, you have no access here', 'nggallery'));
            return;
        }
        // look for pagination
        $_GET['paged'] = isset($_GET['paged']) && $_GET['paged'] > 0 ? absint($_GET['paged']) : 1;
        $items_per_page = 50;
        $start = ($_GET['paged'] - 1) * $items_per_page;
        // get picture values
        $image_mapper = C_Image_Mapper::get_instance();
        $total_number_of_images = count($image_mapper->select($image_mapper->get_primary_key_column())->where(array("galleryid = %d", $act_gid))->run_query(FALSE, TRUE));
        $picturelist = $image_mapper->select()->where(array("galleryid = %d", $act_gid))->order_by($ngg->options['galSort'], $ngg->options['galSortDir'])->limit($items_per_page, $start)->run_query();
        // get the current author
        $act_author_user = get_userdata((int) $gallery->author);
    }
    // list all galleries
    $gallerylist = $nggdb->find_all_galleries();
    //get the columns
    $image_columns = $wp_list_table->get_columns();
    $hidden_columns = get_hidden_columns('nggallery-manage-images');
    $num_columns = count($image_columns) - count($hidden_columns);
    $attr = nggGallery::current_user_can('NextGEN Edit gallery options') ? '' : 'disabled="disabled"';
    ?>
<script type="text/javascript">
<!--
function showDialog( windowId, title ) {
	var form = document.getElementById('updategallery');
	var elementlist = "";
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].name == "doaction[]")
				if(form.elements[i].checked == true)
					if (elementlist == "")
						elementlist = form.elements[i].value;
					else
						elementlist += "," + form.elements[i].value ;
		}
	}
	jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val());
	jQuery("#" + windowId + "_imagelist").val(elementlist);
    // now show the dialog
	jQuery( "#" + windowId ).dialog({
		width: 640,
        resizable : false,
		modal: true,
        title: title,
		position: {
			my:		'center',
			at:		'center',
			of:		window.parent
		}
	});
    jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); });
}

jQuery(function (){

    jQuery('span.tooltip, label.tooltip').tooltip();

    // load a content via ajax
    jQuery('a.ngg-dialog').click(function() {
    	var dialogs = jQuery('.ngg-overlay-dialog:visible');
    	if (dialogs.size() > 0) {
    		return false;
    	}

      if ( jQuery( "#spinner" ).length == 0) {
      	jQuery("body").append('<div id="spinner"></div>');
      }

    	var $this = jQuery(this);
      var results = new RegExp('[\\?&]w=([^&#]*)').exec(this.href);
    	var width  = ( results ) ? results[1] : 600;
      var results = new RegExp('[\\?&]h=([^&#]*)').exec(this.href);
	    var height = ( results ) ? results[1] : 440;
      var container = window;

      if (window.parent) {
      	container = window.parent;
      }

      jQuery('#spinner').fadeIn();
      jQuery('#spinner').position({ my: "center", at: "center", of: container });

      var dialog = jQuery('<div class="ngg-overlay-dialog" style="display:hidden"></div>').appendTo('body');
      // load the remote content
      dialog.load(
          this.href,
          {},
          function () {
              jQuery('#spinner').hide();

              dialog.dialog({
                  title: ($this.attr('title')) ? $this.attr('title') : '',
                  position: { my: "center", at: "center", of: container },
                  width: width,
                  height: height,
                  modal: true,
                  resizable: false,
                  close: function() { dialog.remove(); }
              }).width(width - 30).height(height - 30);
          }
      );

      //prevent the browser to follow the link
      return false;
    });
});

function checkAll(form)
{
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].name == "doaction[]") {
				if(form.elements[i].checked == true)
					form.elements[i].checked = false;
				else
					form.elements[i].checked = true;
			}
		}
	}
}

function getNumChecked(form)
{
	var num = 0;
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].name == "doaction[]")
				if(form.elements[i].checked == true)
					num++;
		}
	}
	return num;
}

// this function check for a the number of selected images, sumbmit false when no one selected
function checkSelected() {

	var numchecked = getNumChecked(document.getElementById('updategallery'));

    if (typeof document.activeElement == "undefined" && document.addEventListener) {
    	document.addEventListener("focus", function (e) {
    		document.activeElement = e.target;
    	}, true);
    }

    if ( document.activeElement.name == 'post_paged' )
        return true;

	if(numchecked < 1) {
		alert('<?php 
    echo esc_js(__('No images selected', 'nggallery'));
    ?>
');
		return false;
	}

	actionId = jQuery('#bulkaction').val();

	switch (actionId) {
		case "copy_to":
			showDialog('selectgallery', '<?php 
    echo esc_js(__('Copy image to...', 'nggallery'));
    ?>
');
			return false;
			break;
		case "move_to":
			showDialog('selectgallery', '<?php 
    echo esc_js(__('Move image to...', 'nggallery'));
    ?>
');
			return false;
			break;
		case "add_tags":
			showDialog('entertags', '<?php 
    echo esc_js(__('Add new tags', 'nggallery'));
    ?>
');
			return false;
			break;
		case "delete_tags":
			showDialog('entertags', '<?php 
    echo esc_js(__('Delete tags', 'nggallery'));
    ?>
');
			return false;
			break;
		case "overwrite_tags":
			showDialog('entertags', '<?php 
    echo esc_js(__('Overwrite', 'nggallery'));
    ?>
');
			return false;
			break;
		case "resize_images":
			showDialog('resize_images', '<?php 
    echo esc_js(__('Resize images', 'nggallery'));
    ?>
');
			return false;
			break;
		case "new_thumbnail":
			showDialog('new_thumbnail', '<?php 
    echo esc_js(__('Create new thumbnails', 'nggallery'));
    ?>
');
			return false;
			break;
	}

	return confirm('<?php 
    echo sprintf(esc_js(__("You are about to start the bulk edit for %s images \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '");
    ?>
');
}

jQuery(document).ready( function($) {
	if ($(this).data('ready')) return;

	// close postboxes that should be closed
	jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
	postboxes.add_postbox_toggles('ngg-manage-gallery');

	jQuery('.iedit').mouseover(
		function(e){
			jQuery(this).parent().find('.row-actions').css('visibility', 'hidden');
			jQuery(this).next('.row_actions:first').find('.row-actions:first').css('visibility', 'visible');
		}
	);

	$(this).data('ready', true);
});

//-->
</script>
<div class="wrap">
<?php 
    //include('templates/social_media_buttons.php');
    screen_icon('nextgen-gallery');
    if ($is_search) {
        ?>
<h2><?php 
        printf(__('Search results for &#8220;%s&#8221;', 'nggallery'), esc_html(get_search_query()));
        ?>
</h2>
<form class="search-form" action="" method="get">
<p class="search-box">
	<label class="hidden" for="media-search-input"><?php 
        _e('Search Images', 'nggallery');
        ?>
:</label>
	<input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" />
	<input type="text" id="media-search-input" name="s" value="<?php 
        the_search_query();
        ?>
" />
	<input type="submit" value="<?php 
        _e('Search Images', 'nggallery');
        ?>
" class="button" />
</p>
</form>

<br style="clear: both;" />

<form id="updategallery" class="nggform" method="POST" action="<?php 
        echo $ngg->manage_page->base_page . '&amp;mode=edit&amp;s=' . get_search_query();
        ?>
" accept-charset="utf-8">
<?php 
        wp_nonce_field('ngg_updategallery');
        ?>
<input type="hidden" name="page" value="manage-images" />

<?php 
    } else {
        ?>
<h2><?php 
        echo _n('Gallery', 'Galleries', 1, 'nggallery');
        ?>
 : <?php 
        echo esc_html(nggGallery::i18n($gallery->title));
        ?>
</h2>

<br style="clear: both;" />

<form id="updategallery" class="nggform" method="POST" action="<?php 
        echo $ngg->manage_page->base_page . '&amp;mode=edit&amp;gid=' . $act_gid . '&amp;paged=' . esc_attr($_GET['paged']);
        ?>
" accept-charset="utf-8">
<?php 
        wp_nonce_field('ngg_updategallery');
        ?>
<input type="hidden" name="page" value="manage-images" />

<?php 
        if (nggGallery::current_user_can('NextGEN Edit gallery options')) {
            ?>
<div id="poststuff">
	<?php 
            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
            ?>
	<div id="gallerydiv" class="postbox <?php 
            echo postbox_classes('gallerydiv', 'ngg-manage-gallery');
            ?>
" >
		<h3><?php 
            _e('Gallery settings', 'nggallery');
            ?>
<small> (<?php 
            _e('Click here for more settings', 'nggallery');
            ?>
)</small></h3>
		<div class="inside">
			<?php 
            $controller->render_gallery_fields();
            ?>

			<div class="submit">
				<?php 
            if (wpmu_enable_function('wpmuImportFolder') && nggGallery::current_user_can('NextGEN Import image folder')) {
                ?>
				<input type="submit" class="button-secondary" name="scanfolder" value="<?php 
                _e("Scan Folder for new images", 'nggallery');
                ?>
 " />
				<?php 
            }
            ?>
				<input type="submit" class="button-primary action" name="updatepictures" value="<?php 
            _e("Save Changes", 'nggallery');
            ?>
" />
			</div>

		</div>
	</div>
</div> <!-- poststuff -->
<?php 
        }
        ?>

<?php 
    }
    ?>

<div class="tablenav top ngg-tablenav">
    <?php 
    $ngg->manage_page->pagination('top', $_GET['paged'], $total_number_of_images, $items_per_page);
    ?>
	<div class="alignleft actions">
	<select id="bulkaction" name="bulkaction">
		<option value="no_action" ><?php 
    _e("Bulk actions", 'nggallery');
    ?>
</option>
		<option value="set_watermark" ><?php 
    _e("Set watermark", 'nggallery');
    ?>
</option>
		<option value="new_thumbnail" ><?php 
    _e("Create new thumbnails", 'nggallery');
    ?>
</option>
		<option value="resize_images" ><?php 
    _e("Resize images", 'nggallery');
    ?>
</option>
		<option value="recover_images" ><?php 
    _e("Recover from backup", 'nggallery');
    ?>
</option>
		<option value="delete_images" ><?php 
    _e("Delete images", 'nggallery');
    ?>
</option>
		<option value="import_meta" ><?php 
    _e("Import metadata", 'nggallery');
    ?>
</option>
		<option value="rotate_cw" ><?php 
    _e("Rotate images clockwise", 'nggallery');
    ?>
</option>
		<option value="rotate_ccw" ><?php 
    _e("Rotate images counter-clockwise", 'nggallery');
    ?>
</option>
		<option value="copy_to" ><?php 
    _e("Copy to...", 'nggallery');
    ?>
</option>
		<option value="move_to"><?php 
    _e("Move to...", 'nggallery');
    ?>
</option>
		<option value="add_tags" ><?php 
    _e("Add tags", 'nggallery');
    ?>
</option>
		<option value="delete_tags" ><?php 
    _e("Delete tags", 'nggallery');
    ?>
</option>
		<option value="overwrite_tags" ><?php 
    _e("Overwrite tags", 'nggallery');
    ?>
</option>
	</select>
	<input class="button-secondary" type="submit" name="showThickbox" value="<?php 
    _e('Apply', 'nggallery');
    ?>
" onclick="if ( !checkSelected() ) return false;" />

	<?php 
    if ($ngg->options['galSort'] == "sortorder" && !$is_search) {
        ?>
		<input class="button-secondary" type="submit" name="sortGallery" value="<?php 
        _e('Sort gallery', 'nggallery');
        ?>
" />
	<?php 
    }
    ?>

	<input type="submit" name="updatepictures" class="button-primary action"  value="<?php 
    _e('Save Changes', 'nggallery');
    ?>
" />
	</div>
</div>
<table id="ngg-listimages" class="widefat fixed" cellspacing="0" >

	<thead>
		<?php 
    $controller->render_image_row_header();
    ?>
	</thead>
	<tfoot>
		<?php 
    $controller->render_image_row_header();
    ?>
	</tfoot>
	<tbody id="the-list">
<?php 
    if ($picturelist) {
        $thumbsize = '';
        $storage = C_Gallery_Storage::get_instance();
        if ($ngg->options['thumbfix']) {
            $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbheight'] . '"';
        }
        foreach ($picturelist as $picture) {
            //for search result we need to check the capatibiliy
            if (!nggAdmin::can_manage_this_gallery($gallery->author) && $is_search) {
                continue;
            }
            $counter++;
            $picture->imageURL = $storage->get_image_url($picture);
            $picture->thumbURL = $storage->get_thumb_url($picture);
            $picture->imagePath = $storage->get_image_abspath($picture);
            $picture->thumbPath = $storage->get_thumb_abspath($picture);
            echo apply_filters('ngg_manage_images_row', $picture, $counter);
        }
    }
    // In the case you have no capaptibility to see the search result
    if ($counter == 0) {
        echo '<tr><td colspan="' . $num_columns . '" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>';
    }
    ?>

		</tbody>
	</table>
    <div class="tablenav bottom">
    <input type="submit" class="button-primary action" name="updatepictures" value="<?php 
    _e('Save Changes', 'nggallery');
    ?>
" />
    <?php 
    $ngg->manage_page->pagination('bottom', $_GET['paged'], $total_number_of_images, $items_per_page);
    ?>
    </div>
	</form>
	<br class="clear"/>
	</div><!-- /#wrap -->

	<!-- #entertags -->
	<div id="entertags" style="display: none;" >
		<form id="form-tags" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="entertags_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="entertags_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
		  	<tr>
		    	<th><?php 
    _e("Enter the tags", 'nggallery');
    ?>
 : <input name="taglist" type="text" style="width:90%" value="" /></th>
		  	</tr>
		  	<tr align="right">
		    	<td class="submit">
		    		<input class="button-primary" type="submit" name="TB_EditTags" value="<?php 
    _e("OK", 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e("Cancel", 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#entertags -->

	<!-- #selectgallery -->
	<div id="selectgallery" style="display: none;" >
		<form id="form-select-gallery" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="selectgallery_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="selectgallery_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
		  	<tr>
		    	<th>
		    		<?php 
    _e('Select the destination gallery:', 'nggallery');
    ?>
&nbsp;
		    		<select name="dest_gid" style="width:90%" >
		    			<?php 
    foreach ($gallerylist as $gallery) {
        if ($gallery->gid != $act_gid) {
            ?>
						<option value="<?php 
            echo $gallery->gid;
            ?>
" ><?php 
            echo $gallery->gid;
            ?>
 - <?php 
            echo esc_attr(stripslashes($gallery->title));
            ?>
</option>
						<?php 
        }
    }
    ?>
		    		</select>
		    	</th>
		  	</tr>
		  	<tr align="right">
		    	<td class="submit">
		    		<input type="submit" class="button-primary" name="TB_SelectGallery" value="<?php 
    _e("OK", 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="<?php 
    _e("Cancel", 'nggallery');
    ?>
" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#selectgallery -->

	<!-- #resize_images -->
	<div id="resize_images" style="display: none;" >
		<form id="form-resize-images" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<td>
					<strong><?php 
    _e('Resize Images to', 'nggallery');
    ?>
:</strong>
				</td>
				<td>
					<input type="text" size="5" name="imgWidth" value="<?php 
    echo $ngg->options['imgWidth'];
    ?>
" /> x <input type="text" size="5" name="imgHeight" value="<?php 
    echo $ngg->options['imgHeight'];
    ?>
" />
					<br /><small><?php 
    _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery');
    ?>
</small>
				</td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#resize_images -->

	<!-- #new_thumbnail -->
	<div id="new_thumbnail" style="display: none;" >
		<form id="form-new-thumbnail" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
    <table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<th align="left"><?php 
    _e('Width x height (in pixel)', 'nggallery');
    ?>
</th>
				<td>
				<?php 
    include dirname(__FILE__) . '/thumbnails-template.php';
    ?>
				</td>
			</tr>
			<tr valign="top">
				<th align="left"><?php 
    _e('Set fix dimension', 'nggallery');
    ?>
</th>
				<td><input type="checkbox" name="thumbfix" value="1" <?php 
    checked('1', $ngg->options['thumbfix']);
    ?>
 />
				<br /><small><?php 
    _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery');
    ?>
</small></td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#new_thumbnail -->

	<script type="text/javascript">
	/* <![CDATA[ */
	jQuery(document).ready(function(){columns.init('nggallery-manage-images');});
	/* ]]> */
	</script>
	<?php 
}
 /**
  * Notify frames that a new gallery has been created
  * @param int $gallery_id
  */
 function new_gallery_event($gallery_id)
 {
     $gallery = C_Gallery_Mapper::get_instance()->find($gallery_id);
     if ($gallery) {
         $this->_get_frame_event_publisher()->add_event(array('event' => 'new_gallery', 'gallery_id' => intval($gallery_id), 'gallery_title' => $gallery->title));
     }
 }
예제 #29
0
 /**
  * Finds all galleries
  * @deprecated
  * @return array
  */
 static function find_all_galleries()
 {
     $mapper = C_Gallery_Mapper::get_instance();
     return $mapper->find_all();
 }
예제 #30
0
    function form($instance)
    {
        // Set Defaults
        $instance = wp_parse_args((array) $instance, array('gal_id' => '0'));
        $mapper = C_Gallery_Mapper::get_instance();
        $gallerylist = $mapper->find_all();
        ?>

		<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'nextgen-public-uploader');
        ?>
</label>
		<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($instance['title']);
        ?>
" /></p>

		<p>
		<label for="<?php 
        echo $this->get_field_id('gal_id');
        ?>
"><?php 
        _e('Upload to :', 'nextgen-public-uploader');
        ?>
</label>
		<select id="<?php 
        echo $this->get_field_id('gal_id');
        ?>
" name="<?php 
        echo $this->get_field_name('gal_id');
        ?>
">
			<option value="0" ><?php 
        _e('Choose gallery', 'nextgen-public-uploader');
        ?>
</option>
			<?php 
        foreach ($gallerylist as $gallery) {
            $name = empty($gallery->title) ? $gallery->name : $gallery->title;
            echo '<option ' . selected($instance['gal_id'], $gallery->gid, false) . ' value="' . $gallery->gid . '">ID: ' . $gallery->gid . ' &ndash; ' . $name . '</option>';
        }
        ?>
		</select>
		</p>
	<?php 
    }