Exemplo n.º 1
0
function createNewThumb()
{
    global $ngg;
    // check for correct capability
    if (!is_user_logged_in()) {
        die('-1');
    }
    // check for correct NextGEN capability
    if (!current_user_can('NextGEN Manage gallery')) {
        die('-1');
    }
    $id = (int) $_POST['id'];
    $picture = nggdb::find_image($id);
    $x = round($_POST['x'] * $_POST['rr'], 0);
    $y = round($_POST['y'] * $_POST['rr'], 0);
    $w = round($_POST['w'] * $_POST['rr'], 0);
    $h = round($_POST['h'] * $_POST['rr'], 0);
    $crop_frame = array('x' => $x, 'y' => $y, 'width' => $w, 'height' => $h);
    $registry = C_Component_Registry::get_instance();
    $storage = C_Gallery_Storage::get_instance();
    // XXX NextGEN Legacy wasn't handling watermarks or reflections at this stage, so we're forcefully disabling them to maintain compatibility
    $params = array('watermark' => false, 'reflection' => false, 'crop' => true, 'crop_frame' => $crop_frame);
    $result = $storage->generate_thumbnail($id, $params);
    if ($result) {
        echo "OK";
    } else {
        header('HTTP/1.1 500 Internal Server Error');
        echo "KO";
    }
    C_NextGEN_Bootstrap::shutdown();
}
Exemplo n.º 2
0
 /**
  * nggMeta::nggMeta()
  * 
  * @param int $image path to a image
  * @param bool $onlyEXIF parse only exif if needed
  * @return
  */
 function nggMeta($pic_id, $onlyEXIF = false)
 {
     //get the path and other data about the image
     $this->image = nggdb::find_image($pic_id);
     $this->image = apply_filters('ngg_find_image_meta', $this->image);
     if (!file_exists($this->image->imagePath)) {
         return false;
     }
     $this->size = @getimagesize($this->image->imagePath, $metadata);
     if ($this->size && is_array($metadata)) {
         // get exif - data
         if (is_callable('exif_read_data')) {
             $this->exif_data = @exif_read_data($this->image->imagePath, 0, true);
         }
         // stop here if we didn't need other meta data
         if ($onlyEXIF) {
             return true;
         }
         // get the iptc data - should be in APP13
         if (is_callable('iptcparse') && isset($metadata['APP13'])) {
             $this->iptc_data = @iptcparse($metadata['APP13']);
         }
         // get the xmp data in a XML format
         if (is_callable('xml_parser_create')) {
             $this->xmp_data = $this->extract_XMP($this->image->imagePath);
         }
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
/**
 * Image edit functions via AJAX
 *
 * @author Alex Rabe
 *
 *
 * @return void
 */
function ngg_ajax_operation()
{
    // if nonce is not correct it returns -1
    check_ajax_referer("ngg-ajax");
    // check for correct capability
    if (!is_user_logged_in()) {
        die('-1');
    }
    // check for correct NextGEN capability
    if (!current_user_can('NextGEN Upload images') && !current_user_can('NextGEN Manage gallery')) {
        die('-1');
    }
    // include the ngg function
    include_once dirname(__FILE__) . '/functions.php';
    // Get the image id
    if (isset($_POST['image'])) {
        $id = (int) $_POST['image'];
        // let's get the image data
        $picture = nggdb::find_image($id);
        // what do you want to do ?
        switch ($_POST['operation']) {
            case 'create_thumbnail':
                $result = nggAdmin::create_thumbnail($picture);
                break;
            case 'resize_image':
                $result = nggAdmin::resize_image($picture);
                break;
            case 'rotate_cw':
                $result = nggAdmin::rotate_image($picture, 'CW');
                nggAdmin::create_thumbnail($picture);
                break;
            case 'rotate_ccw':
                $result = nggAdmin::rotate_image($picture, 'CCW');
                nggAdmin::create_thumbnail($picture);
                break;
            case 'set_watermark':
                $result = nggAdmin::set_watermark($picture);
                break;
            case 'recover_image':
                $result = nggAdmin::recover_image($id) ? '1' : '0';
                break;
            case 'import_metadata':
                $result = C_Image_Mapper::get_instance()->reimport_metadata($id) ? '1' : '0';
                break;
            case 'get_image_ids':
                $result = nggAdmin::get_image_ids($id);
                break;
            default:
                do_action('ngg_ajax_' . $_POST['operation']);
                die('-1');
                break;
        }
        // A success should return a '1'
        die($result);
    }
    // The script should never stop here
    die('0');
}
Exemplo n.º 4
0
function createNewThumb()
{
    global $ngg;
    // check for correct capability
    if (!is_user_logged_in()) {
        die('-1');
    }
    // check for correct NextGEN capability
    if (!current_user_can('NextGEN Manage gallery')) {
        die('-1');
    }
    include_once nggGallery::graphic_library();
    $id = (int) $_POST['id'];
    $picture = nggdb::find_image($id);
    $x = round($_POST['x'] * $_POST['rr'], 0);
    $y = round($_POST['y'] * $_POST['rr'], 0);
    $w = round($_POST['w'] * $_POST['rr'], 0);
    $h = round($_POST['h'] * $_POST['rr'], 0);
    $thumb = new ngg_Thumbnail($picture->imagePath, TRUE);
    $thumb->crop($x, $y, $w, $h);
    // Note : the routine is a bit different to create_thumbnail(), due to rounding it's resized in the other way
    if ($ngg->options['thumbfix']) {
        // check for portrait format
        if ($thumb->currentDimensions['height'] > $thumb->currentDimensions['width']) {
            // first resize to the wanted height, here changed to create_thumbnail()
            $thumb->resize(0, $ngg->options['thumbheight']);
            // get optimal y startpos
            $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2;
            $thumb->crop(0, $ypos, $ngg->options['thumbwidth'], $ngg->options['thumbheight']);
        } else {
            // first resize to the wanted width, here changed to create_thumbnail()
            $thumb->resize($ngg->options['thumbwidth'], 0);
            //
            // get optimal x startpos
            $xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2;
            $thumb->crop($xpos, 0, $ngg->options['thumbwidth'], $ngg->options['thumbheight']);
        }
        //this create a thumbnail but keep ratio settings
    } else {
        $thumb->resize($ngg->options['thumbwidth'], $ngg->options['thumbheight']);
    }
    if ($thumb->save($picture->thumbPath, 100)) {
        //read the new sizes
        $new_size = @getimagesize($picture->thumbPath);
        $size['width'] = $new_size[0];
        $size['height'] = $new_size[1];
        // add them to the database
        nggdb::update_image_meta($picture->pid, array('thumbnail' => $size));
        echo "OK";
    } else {
        header('HTTP/1.1 500 Internal Server Error');
        echo "KO";
    }
    exit;
}
Exemplo n.º 5
0
function createNewThumb()
{
    // check for correct capability
    if (!is_user_logged_in()) {
        die('-1');
    }
    // check for correct NextGEN capability
    if (!current_user_can('NextGEN Manage gallery')) {
        die('-1');
    }
    require_once dirname(dirname(__FILE__)) . '/ngg-config.php';
    include_once nggGallery::graphic_library();
    $ngg_options = get_option('ngg_options');
    $id = (int) $_POST['id'];
    $picture = nggdb::find_image($id);
    $x = round($_POST['x'] * $_POST['rr'], 0);
    $y = round($_POST['y'] * $_POST['rr'], 0);
    $w = round($_POST['w'] * $_POST['rr'], 0);
    $h = round($_POST['h'] * $_POST['rr'], 0);
    $thumb = new ngg_Thumbnail($picture->imagePath, TRUE);
    $thumb->crop($x, $y, $w, $h);
    if ($ngg_options['thumbfix']) {
        if ($thumb->currentDimensions['height'] > $thumb->currentDimensions['width']) {
            $thumb->resize($ngg_options['thumbwidth'], 0);
        } else {
            $thumb->resize(0, $ngg_options['thumbheight']);
        }
    } else {
        $thumb->resize($ngg_options['thumbwidth'], $ngg_options['thumbheight'], $ngg_options['thumbResampleMode']);
    }
    if ($thumb->save($picture->thumbPath, 100)) {
        //read the new sizes
        $new_size = @getimagesize($picture->thumbPath);
        $size['width'] = $new_size[0];
        $size['height'] = $new_size[1];
        // add them to the database
        nggdb::update_image_meta($picture->pid, array('thumbnail' => $size));
        echo "OK";
    } else {
        header('HTTP/1.1 500 Internal Server Error');
        echo "KO";
    }
    exit;
}
Exemplo n.º 6
0
function ngg_ajax_operation()
{
    global $wpdb;
    // if nonce is not correct it returns -1
    check_ajax_referer("ngg-ajax");
    // check for correct capability
    if (!is_user_logged_in()) {
        die('-1');
    }
    // check for correct NextGEN capability
    if (!current_user_can('NextGEN Upload images') || !current_user_can('NextGEN Manage gallery')) {
        die('-1');
    }
    // include the ngg function
    include_once dirname(__FILE__) . '/functions.php';
    // Get the image id
    if (isset($_POST['image'])) {
        $id = (int) $_POST['image'];
        // let's get the image data
        $picture = nggdb::find_image($id);
        // what do you want to do ?
        switch ($_POST['operation']) {
            case 'create_thumbnail':
                $result = nggAdmin::create_thumbnail($picture);
                break;
            case 'resize_image':
                $result = nggAdmin::resize_image($picture);
                break;
            case 'set_watermark':
                $result = nggAdmin::set_watermark($picture);
                break;
            default:
                die('-1');
                break;
        }
        // A success should retun a '1'
        die($result);
    }
    // The script should never stop here
    die('0');
}
Exemplo n.º 7
0
    function output()
    {
        global $wpdb, $nggdb;
        //TODO:Code MUST be optimized, how to flag a used gallery better ?
        $used_list = $this->get_used_galleries();
        ?>

<script type="text/javascript">

jQuery(document).ready(
	function()
	{
        jQuery("#previewpic").nggAutocomplete( {
            type: 'image',domain: "<?php 
        echo home_url('index.php', is_ssl() ? 'https' : 'http');
        ?>
",width: "95%"
        });
        
		jQuery('#selectContainer').sortable( {
			items: '.groupItem',
			placeholder: 'sort_placeholder',
			opacity: 0.7,
			tolerance: 'intersect',
			distance: 2,
			forcePlaceholderSize: true ,
			connectWith: ['#galleryContainer'] 
		} );

		jQuery('#galleryContainer').sortable( {
			items: '.groupItem',
			placeholder: 'sort_placeholder',
			opacity: 0.7,
			tolerance: 'intersect',
			distance: 2,
			forcePlaceholderSize: true ,
			connectWith: ['#selectContainer', '#albumContainer'] 
		} );

		jQuery('#albumContainer').sortable( {
			items: '.groupItem',
			placeholder: 'sort_placeholder',
			opacity: 0.7,
			tolerance: 'intersect',
			distance: 2,
			forcePlaceholderSize: true ,
			connectWith: ['#galleryContainer']
		} );
		
		jQuery('a.min').bind('click', toggleContent);

		// Hide used galleries
		jQuery('a#toggle_used').click(function()
			{
				jQuery('#selectContainer div.inUse').toggle();
				return false;
			}
		);	
			
		// Maximize All Portlets (whole site, no differentiation)
		jQuery('a#all_max').click(function()
			{
				jQuery('div.itemContent:hidden').show();
				return false;
			}
		);

		// Minimize All Portlets (whole site, no differentiation)
		jQuery('a#all_min').click(function()
			{
				jQuery('div.itemContent:visible').hide();
				return false;
			}
		);
	   // Auto Minimize if more than 4 (whole site, no differentiation)
	   if(jQuery('a.min').length > 4)
	   {
	   		jQuery('a.min').html('[+]');
	   		jQuery('div.itemContent:visible').hide();
	   		jQuery('#selectContainer div.inUse').toggle();
	   };
	}
);

var toggleContent = function(e)
{
	var targetContent = jQuery('div.itemContent', this.parentNode.parentNode);
	if (targetContent.css('display') == 'none') {
		targetContent.slideDown(300);
		jQuery(this).html('[-]');
	} else {
		targetContent.slideUp(300);
		jQuery(this).html('[+]');
	}
	return false;
}

function ngg_serialize(s)
{
	//serial = jQuery.SortSerialize(s);
	serial = jQuery('#galleryContainer').sortable('serialize');
	jQuery('input[name=sortorder]').val(serial);
}

function showDialog() {
	jQuery( "#editalbum").dialog({
		width: 640,
        resizable : false,
		modal: true,
        title: '<?php 
        echo esc_js(__('Edit Album', 'nggallery'));
        ?>
'        
	});
    jQuery('#editalbum .dialog-cancel').click(function() { jQuery( "#editalbum" ).dialog("close"); });
}

</script>

<div class="wrap album" id="wrap" >
    <?php 
        screen_icon('nextgen-gallery');
        ?>
	<h2><?php 
        esc_html_e('Manage Albums', 'nggallery');
        ?>
</h2>
	<form id="selectalbum" method="POST" onsubmit="ngg_serialize()" accept-charset="utf-8">
		<?php 
        wp_nonce_field('ngg_album');
        ?>
		<input name="sortorder" type="hidden" />
		<div class="albumnav tablenav">
			<div class="alignleft actions">
				<?php 
        esc_html_e('Select album', 'nggallery');
        ?>
				<select id="act_album" name="act_album" onchange="this.form.submit();">
					<option value="0" ><?php 
        esc_html_e('No album selected', 'nggallery');
        ?>
</option>
					<?php 
        if (is_array($this->albums)) {
            foreach ($this->albums as $album) {
                $selected = $this->currentID == $album->id ? 'selected="selected" ' : '';
                echo '<option value="' . $album->id . '" ' . $selected . '>' . $album->id . ' - ' . esc_attr($album->name) . '</option>' . "\n";
            }
        }
        ?>
				</select>
				<?php 
        if ($this->currentID > 0) {
            ?>
					<input class="button-primary" type="submit" name="update" value="<?php 
            esc_attr_e('Update', 'nggallery');
            ?>
"/>
					<?php 
            if (nggGallery::current_user_can('NextGEN Edit album settings')) {
                ?>
					<input class="button-secondary" type="submit" name="showThickbox" value="<?php 
                esc_attr_e('Edit album', 'nggallery');
                ?>
" onclick="showDialog(); return false;" />
					<?php 
            }
            ?>
					<?php 
            if (nggGallery::current_user_can('NextGEN Add/Delete album')) {
                ?>
					<input class="button-secondary action "type="submit" name="delete" value="<?php 
                esc_attr_e('Delete', 'nggallery');
                ?>
" onclick="javascript:check=confirm('<?php 
                echo esc_js('Delete album ?', 'nggallery');
                ?>
');if(check==false) return false;"/>
					<?php 
            }
            ?>
				<?php 
        } else {
            ?>
					<?php 
            if (nggGallery::current_user_can('NextGEN Add/Delete album')) {
                ?>
					<span><?php 
                esc_html_e('Add new album', 'nggallery');
                ?>
&nbsp;</span>
					<input class="search-input" id="newalbum" name="newalbum" type="text" value="" />			
					<input class="button-secondary action" type="submit" name="add" value="<?php 
                esc_attr_e('Add', 'nggallery');
                ?>
"/>
					<?php 
            }
            ?>
				<?php 
        }
        ?>
	
			</div>
		</div>
	</form>
	
	<br class="clear"/>
	
	<div>
		<div style="float:right;">
		  <a href="#" title="<?php 
        esc_attr_e('Show / hide used galleries', 'nggallery');
        ?>
" id="toggle_used"><?php 
        esc_html_e('[Show all]', 'nggallery');
        ?>
</a>
		| <a href="#" title="<?php 
        esc_attr_e('Maximize the widget content', 'nggallery');
        ?>
" id="all_max"><?php 
        esc_html_e('[Maximize]', 'nggallery');
        ?>
</a>
		| <a href="#" title="<?php 
        esc_attr_e('Minimize the widget content', 'nggallery');
        ?>
" id="all_min"><?php 
        esc_html_e('[Minimize]', 'nggallery');
        ?>
</a>
		</div>
		<?php 
        esc_html_e('After you create and select a album, you can drag and drop a gallery or another album into your new album below', 'nggallery');
        ?>
	</div>

	<br class="clear" />
	
	<div class="container">
		
		<!-- /#album container -->
		<div class="widget widget-right">
			<div class="widget-top">
				<h3><?php 
        esc_html_e('Select album', 'nggallery');
        ?>
</h3>
			</div>
			<div id="albumContainer" class="widget-holder">
			<?php 
        if (is_array($this->albums)) {
            foreach ($this->albums as $album) {
                $this->get_container('a' . $album->id);
            }
        }
        ?>
 
			</div>			
		</div>
		
		<!-- /#select container -->
		<div class="widget widget-right">
			<div class="widget-top">
				<h3><?php 
        esc_html_e('Select gallery', 'nggallery');
        ?>
</h3>
			</div>
			<div id="selectContainer" class="widget-holder">
		<?php 
        if (is_array($this->galleries)) {
            //get the array of galleries
            $sort_array = $this->currentID > 0 ? (array) $this->albums[$this->currentID]->galleries : array();
            foreach ($this->galleries as $gallery) {
                if (!in_array($gallery->gid, $sort_array)) {
                    if (in_array($gallery->gid, $used_list)) {
                        $this->get_container($gallery->gid, true);
                    } else {
                        $this->get_container($gallery->gid, false);
                    }
                }
            }
        }
        ?>
			</div>
		</div>
		
		<!-- /#target-album -->
		<div class="widget target-album widget-left">

		<?php 
        if ($this->currentID > 0) {
            $album = $this->albums[$this->currentID];
            ?>
				<div class="widget-top">
					<h3><?php 
            esc_html_e('Album ID', 'nggallery');
            ?>
 <?php 
            echo $album->id . ' : ' . esc_html($album->name);
            ?>
 </h3>
				</div>
				<div id="galleryContainer" class="widget-holder target">
				<?php 
            $sort_array = (array) $this->albums[$this->currentID]->galleries;
            foreach ($sort_array as $galleryid) {
                $this->get_container($galleryid, false);
            }
        } else {
            ?>
				<div class="widget-top">
					<h3><?php 
            esc_html_e('No album selected!', 'nggallery');
            ?>
</h3>
				</div>
				<div class="widget-holder target">
				<?php 
        }
        ?>
 
			</div>
		</div><!-- /#target-album -->

	</div><!-- /#container -->
</div><!-- /#wrap -->

<?php 
        if ($this->currentID > 0) {
            ?>
<!-- #editalbum -->
<div id="editalbum" style="display: none;" >
	<form id="form-edit-album" method="POST" accept-charset="utf-8">
	<?php 
            wp_nonce_field('ngg_thickbox_form');
            ?>
	<input type="hidden" id="current_album" name="act_album" value="<?php 
            echo $this->currentID;
            ?>
" />
	<table width="100%" border="0" cellspacing="3" cellpadding="3" >
	  	<tr>
	    	<th>
	    		<?php 
            esc_html_e('Album name:', 'nggallery');
            ?>
<br />
				<input class="search-input" id="album_name" name="album_name" type="text" value="<?php 
            echo esc_attr($album->name);
            ?>
" style="width:95%" />
	    	</th>
	  	</tr>
	  	<tr>
	    	<th>
	    		<?php 
            esc_html_e('Album description:', 'nggallery');
            ?>
<br />
	    		<textarea class="search-input" id="album_desc" name="album_desc" cols="50" rows="2" style="width:95%" ><?php 
            echo esc_attr($album->albumdesc);
            ?>
</textarea>
	    	</th>
	  	</tr>
	  	<tr>
	    	<th>
	    		<?php 
            esc_html_e('Select a preview image:', 'nggallery');
            ?>
<br />
					<select id="previewpic" name="previewpic" style="width:95%" >
                        <?php 
            if ($album->previewpic == 0) {
            }
            ?>
		                <option value="0"><?php 
            esc_html_e('No picture', 'nggallery');
            ?>
</option>
						<?php 
            if ($album->previewpic == 0) {
                echo '<option value="0" selected="selected">' . __('No picture', 'nggallery') . '</option>';
            } else {
                $picture = nggdb::find_image($album->previewpic);
                echo '<option value="' . $picture->pid . '" selected="selected" >' . $picture->pid . ' - ' . (empty($picture->alltext) ? esc_attr($picture->filename) : esc_attr($picture->alltext)) . ' </option>' . "\n";
            }
            ?>
					</select>
	    	</th>
	  	</tr>
        <tr>
            <th>
                <?php 
            esc_html_e('Page Link to', 'nggallery');
            ?>
<br />
                    <select name="pageid" style="width:95%">
                        <option value="0" ><?php 
            esc_html_e('Not linked', 'nggallery');
            ?>
</option>
                        <?php 
            if (!isset($album->pageid)) {
                $album->pageid = 0;
            }
            parent_dropdown($album->pageid);
            ?>
                    </select>
            </th>
        </tr>
        
        <?php 
            do_action('ngg_edit_album_settings', $this->currentID);
            ?>
        
	  	<tr align="right">
	    	<td class="submit">
	    		<input type="submit" class="button-primary" name="update_album" value="<?php 
            esc_attr_e('OK', 'nggallery');
            ?>
" />
	    		&nbsp;
	    		<input class="button-secondary dialog-cancel" type="reset" value="<?php 
            esc_attr_e('Cancel', 'nggallery');
            ?>
"/>
	    	</td>
		</tr>
	</table>
	</form>
</div>
<!-- /#editalbum -->
<?php 
        }
        ?>

<?php 
    }
Exemplo n.º 8
0
 function get_image_path()
 {
     global $post;
     $id = get_post_thumbnail_id();
     // check to see if NextGen Gallery is present
     if (stripos($id, 'ngg-') !== false && class_exists('nggdb')) {
         $nggImage = nggdb::find_image(str_replace('ngg-', '', $id));
         $thumbnail = array($nggImage->imageURL, $nggImage->width, $nggImage->height);
         // otherwise, just get the wp thumbnail
     } else {
         $thumbnail = wp_get_attachment_image_src($id, 'full', true);
     }
     $theimage = $thumbnail[0];
     return $theimage;
 }
Exemplo n.º 9
0
 NextGen Gallery : Alex Rabe | http://alexrabe.boelinger.com/wordpress-plugins/nextgen-gallery/
 jCrop : Kelly Hallman <*****@*****.**> | http://deepliquid.com/content/Jcrop.html
 
**/
require_once dirname(dirname(__FILE__)) . '/ngg-config.php';
require_once NGGALLERY_ABSPATH . '/lib/image.php';
if (!is_user_logged_in()) {
    die(__('Cheatin&#8217; uh?'));
}
if (!current_user_can('NextGEN Manage gallery')) {
    die(__('Cheatin&#8217; uh?'));
}
global $wpdb;
$id = (int) $_GET['id'];
// let's get the image data
$picture = nggdb::find_image($id);
include_once nggGallery::graphic_library();
$ngg_options = get_option('ngg_options');
$thumb = new ngg_Thumbnail($picture->imagePath, TRUE);
$thumb->resize(350, 350);
// we need the new dimension
$resizedPreviewInfo = $thumb->newDimensions;
$thumb->destruct();
$preview_image = NGGALLERY_URLPATH . 'nggshow.php?pid=' . $picture->pid . '&amp;width=350&amp;height=350';
$imageInfo = @getimagesize($picture->imagePath);
$rr = round($imageInfo[0] / $resizedPreviewInfo['newWidth'], 2);
if ($ngg_options['thumbfix'] == 1) {
    $WidthHtmlPrev = $ngg_options['thumbwidth'];
    $HeightHtmlPrev = $ngg_options['thumbheight'];
} else {
    // H > W
Exemplo n.º 10
0
 public function handleUpload_widget()
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/class.npu_uploader.php';
     require_once NGGALLERY_ABSPATH . '/lib/meta.php';
     $ngg->options['swfupload'] = false;
     //Where is this being instantiated?
     if (isset($_POST['uploadimage_widget'])) {
         check_admin_referer('ngg_addgallery');
         if (!isset($_FILES['MF__F_0_0']['error']) || $_FILES['MF__F_0_0']['error'] == 0) {
             $objUploaderNggAdmin = new UploaderNggAdmin();
             $messagetext = $objUploaderNggAdmin->upload_images_widget();
             $this->arrImageIds = $objUploaderNggAdmin->arrImageIds;
             $this->strGalleryPath = $objUploaderNggAdmin->strGalleryPath;
             $this->arrImageNames = $objUploaderNggAdmin->arrImageNames;
             if (is_array($objUploaderNggAdmin->arrThumbReturn) && count($objUploaderNggAdmin->arrThumbReturn) > 0) {
                 foreach ($objUploaderNggAdmin->arrThumbReturn as $strReturnMsg) {
                     if ($strReturnMsg != '1') {
                         $this->arrErrorMsg_widg[] = $strReturnMsg;
                     }
                 }
                 $this->arrImageMsg_widg[] = get_option('npu_upload_success') ? get_option('npu_upload_success') : __('Thank you! Your image has been submitted and is pending review.', 'nextgen-public-uploader');
                 $this->sendEmail();
             }
             //Used in update_details method.
             if (is_array($this->arrImageIds) && count($this->arrImageIds) > 0) {
                 foreach ($this->arrImageIds as $imageId) {
                     $pic = nggdb::find_image($imageId);
                     $objEXIF = new nggMeta($pic->imagePath);
                     $this->strTitle = $objEXIF->get_META('title');
                     $this->strDescription = $objEXIF->get_META('caption');
                     $this->strKeywords = $objEXIF->get_META('keywords');
                     $this->strTimeStamp = $objEXIF->get_date_time();
                 }
             } else {
                 $this->arrErrorMsg_widg[] = get_option('npu_no_file') ? get_option('npu_no_file') : __('You must select a file to upload', 'nextgen-public-uploader');
             }
             $this->update_details();
         } else {
             $this->arrErrorMsg_widg[] = get_option('npu_upload_failed') ? get_option('npu_upload_failed') : __('Upload failed!', 'nextgen-public-uploader');
         }
         //If we've encountered any errors, delete?
         if (count($this->arrErrorMsg_widg) > 0 && (is_array($this->arrImageIds) && count($this->arrImageIds) > 0)) {
             $gal_id = !empty($_POST['galleryselect']) ? absint($_POST['galleryselect']) : 1;
             foreach ($this->arrImageIds as $intImageId) {
                 $filename = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$intImageId}' ");
                 if ($filename) {
                     $gallerypath = $wpdb->get_var($wpdb->prepare("SELECT path FROM {$wpdb->nggallery} WHERE gid = %d", $gal_id));
                     if ($gallerypath) {
                         @unlink(WINABSPATH . $gallerypath . '/thumbs/thumbs_' . $filename);
                         @unlink(WINABSPATH . $gallerypath . '/' . $filename);
                     }
                     $delete_pic = $wpdb->delete($wpdb->nggpictures, array('pid' => $intImageId), array('%d'));
                 }
             }
         }
     }
 }
Exemplo n.º 11
0
<?php

require_once './wp-content/plugins/nextgen-gallery/ngg-config.php';
require_once './inc/php/cfg.php';
if (!empty($_GET['pid'])) {
    $foto = nggdb::find_image($_GET['pid']);
    if (empty($foto) or $foto->exclude == 1) {
        $fotos = nggdb::get_random_images();
        $foto = $fotos[0];
    }
    $tags = wp_get_object_terms($_GET['pid'], 'ngg_tag');
} else {
    if ($_SESSION['last_pid'] > 0) {
        $pid = mt_rand(1, $_SESSION['last_pid']);
        header("Location: /foto/{$pid}.html");
    } else {
        header('Location: /');
    }
}
$foto_url = str_replace($cfg['trueurl'], $cfg['baseurl'], $foto->imageURL);
//输出页头keywords
if (!empty($tags)) {
    $key_arr = array();
    foreach ($tags as $tag) {
        $key_arr[] = $tag->slug;
        $keywords = implode(',', $key_arr);
    }
} else {
    $keywords = $cfg['keywords'];
}
//输出keywords
Exemplo n.º 12
0
/**
 * nggCreateImageBrowser()
 *
 * @access internal
 * @param array $picturelist
 * @param string $template (optional) name for a template file, look for imagebrowser-$template
 * @return the content
 */
function nggCreateImageBrowser($picturelist, $template = '')
{
    global $nggRewrite, $ngg;
    require_once dirname(__FILE__) . '/lib/meta.php';
    // $_GET from wp_query
    $pid = get_query_var('pid');
    // we need to know the current page id
    $current_page = get_the_ID() == false ? 0 : get_the_ID();
    // create a array with id's for better walk inside
    foreach ($picturelist as $picture) {
        $picarray[] = $picture->pid;
    }
    $total = count($picarray);
    if (!empty($pid)) {
        if (is_numeric($pid)) {
            $act_pid = intval($pid);
        } else {
            // in the case it's a slug we need to search for the pid
            foreach ($picturelist as $key => $picture) {
                if ($picture->image_slug == $pid) {
                    $act_pid = $key;
                    break;
                }
            }
        }
    } else {
        reset($picarray);
        $act_pid = current($picarray);
    }
    // get ids for back/next
    $key = array_search($act_pid, $picarray);
    if (!$key) {
        $act_pid = reset($picarray);
        $key = key($picarray);
    }
    $back_pid = $key >= 1 ? $picarray[$key - 1] : end($picarray);
    $next_pid = $key < $total - 1 ? $picarray[$key + 1] : reset($picarray);
    // get the picture data
    $picture = nggdb::find_image($act_pid);
    // if we didn't get some data, exit now
    if ($picture == null) {
        return;
    }
    // add more variables for render output
    $picture->href_link = $picture->get_href_link();
    $args['pid'] = $ngg->options['usePermalinks'] ? $picturelist[$back_pid]->image_slug : $back_pid;
    $picture->previous_image_link = $nggRewrite->get_permalink($args);
    $picture->previous_pid = $back_pid;
    $args['pid'] = $ngg->options['usePermalinks'] ? $picturelist[$next_pid]->image_slug : $next_pid;
    $picture->next_image_link = $nggRewrite->get_permalink($args);
    $picture->next_pid = $next_pid;
    $picture->number = $key + 1;
    $picture->total = $total;
    $picture->linktitle = empty($picture->description) ? ' ' : htmlspecialchars(stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')));
    $picture->alttext = empty($picture->alttext) ? ' ' : html_entity_decode(stripslashes(nggGallery::i18n($picture->alttext, 'pic_' . $picture->pid . '_alttext')));
    $picture->description = empty($picture->description) ? ' ' : html_entity_decode(stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')));
    $picture->anchor = 'ngg-imagebrowser-' . $picture->galleryid . '-' . $current_page;
    // filter to add custom content for the output
    $picture = apply_filters('ngg_image_object', $picture, $act_pid);
    // let's get the meta data
    $meta = new nggMeta($act_pid);
    $meta->sanitize();
    $exif = $meta->get_EXIF();
    $iptc = $meta->get_IPTC();
    $xmp = $meta->get_XMP();
    $db = $meta->get_saved_meta();
    //if we get no exif information we try the database
    $exif = $exif == false ? $db : $exif;
    // look for imagebrowser-$template.php or pure imagebrowser.php
    $filename = empty($template) ? 'imagebrowser' : 'imagebrowser-' . $template;
    // create the output
    $out = nggGallery::capture($filename, array('image' => $picture, 'meta' => $meta, 'exif' => $exif, 'iptc' => $iptc, 'xmp' => $xmp, 'db' => $db));
    return $out;
}
Exemplo n.º 13
0
 /**
  * Method "ngg.editImage"
  * Edit a existing Image
  * 
  * @since 1.7.3
  * 
  * @param array $args Method parameters.
  * 			- int blog_id
  *	    	- string username
  *	    	- string password
  *	    	- int Image ID
  *	    	- string alt/title text
  *	    	- string description
  *	    	- int exclude from gallery (0 or 1)
  * @return true if success
  */
 function editImage($args)
 {
     global $ngg;
     require_once dirname(dirname(__FILE__)) . '/admin/functions.php';
     // admin functions
     $this->escape($args);
     $blog_ID = (int) $args[0];
     $username = $args[1];
     $password = $args[2];
     $id = (int) $args[3];
     $alttext = $args[4];
     $description = $args[5];
     $exclude = (int) $args[6];
     if (!($user = $this->login($username, $password))) {
         return $this->error;
     }
     if (!($image = nggdb::find_image($id))) {
         return new IXR_Error(404, __("Invalid image ID"));
     }
     if (!current_user_can('NextGEN Manage gallery') && !nggAdmin::can_manage_this_gallery($image->author)) {
         return new IXR_Error(401, __('Sorry, you must be able to edit this image'));
     }
     if (!empty($alttext)) {
         $result = nggdb::update_image($id, false, false, $description, $alttext, $exclude);
     }
     if (!$result) {
         return new IXR_Error(500, __('Sorry, could not update the image'));
     }
     return true;
 }
Exemplo n.º 14
0
 /**
  * Import some meta data into the database (if avialable)
  * 
  * @class nggAdmin
  * @param array|int $imagesIds
  * @return string result code
  */
 function import_MetaData($imagesIds)
 {
     global $wpdb;
     require_once NGGALLERY_ABSPATH . '/lib/image.php';
     if (!is_array($imagesIds)) {
         $imagesIds = array($imagesIds);
     }
     foreach ($imagesIds as $imageID) {
         $image = nggdb::find_image($imageID);
         if (!$image->error) {
             $meta = nggAdmin::get_MetaData($image->pid);
             // get the title
             $alttext = empty($meta['title']) ? $image->alttext : $meta['title'];
             // get the caption / description field
             $description = empty($meta['caption']) ? $image->description : $meta['caption'];
             // get the file date/time from exif
             $timestamp = $meta['timestamp'];
             // first update database
             $result = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggpictures} SET \r\n\t\t\t\t\t\talttext = %s, \r\n\t\t\t\t\t\tdescription = %s, \r\n\t\t\t\t\t\timagedate = %s\r\n\t\t\t\t\tWHERE pid = %d", $alttext, $description, $timestamp, $image->pid));
             if ($result === false) {
                 return ' <strong>' . $image->filename . ' ' . __('(Error : Couldn\'t not update data base)', 'nggallery') . '</strong>';
             }
             //this flag will inform us that the import is already one time performed
             $meta['common']['saved'] = true;
             $result = nggdb::update_image_meta($image->pid, $meta['common']);
             if ($result === false) {
                 return ' <strong>' . $image->filename . ' ' . __('(Error : Couldn\'t not update meta data)', 'nggallery') . '</strong>';
             }
             // add the tags if we found some
             if ($meta['keywords']) {
                 $taglist = explode(',', $meta['keywords']);
                 wp_set_object_terms($image->pid, $taglist, 'ngg_tag');
             }
         } else {
             return ' <strong>' . $image->filename . ' ' . __('(Error : Couldn\'t not find image)', 'nggallery') . '</strong>';
         }
         // error check
     }
     return '1';
 }
Exemplo n.º 15
0
function media_upload_nextgen_form($errors)
{
    global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types, $ngg;
    media_upload_header();
    $post_id = intval($_REQUEST['post_id']);
    $galleryID = 0;
    $total = 1;
    $picarray = array();
    $form_action_url = site_url("wp-admin/media-upload.php?type={$GLOBALS['type']}&tab=nextgen&post_id={$post_id}", 'admin');
    // Get number of images in gallery
    if (isset($_REQUEST['select_gal'])) {
        $galleryID = (int) $_REQUEST['select_gal'];
        $total = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->nggpictures} WHERE galleryid = '{$galleryID}'");
    }
    // Build navigation
    $_GET['paged'] = isset($_GET['paged']) ? intval($_GET['paged']) : 0;
    if ($_GET['paged'] < 1) {
        $_GET['paged'] = 1;
    }
    $start = ($_GET['paged'] - 1) * 10;
    if ($start < 1) {
        $start = 0;
    }
    // Get the images
    if ($galleryID != 0) {
        $picarray = $wpdb->get_col("SELECT pid FROM {$wpdb->nggpictures} WHERE galleryid = '{$galleryID}' AND exclude != 1 ORDER BY {$ngg->options['galSort']} {$ngg->options['galSortDir']} LIMIT {$start}, 10 ");
    }
    // WP-Core code for Post-thumbnail
    $calling_post_id = 0;
    if (isset($_GET['post_id'])) {
        $calling_post_id = $_GET['post_id'];
    }
    ?>

<script type="text/javascript"> 
<!--
	function NGGSetAsThumbnail(id){
		var $link = jQuery('a#ngg-post-thumbnail-' + id);
	
		$link.text( setPostThumbnailL10n.saving );
		jQuery.post(ajaxurl, {
			action:"ngg_set_post_thumbnail", post_id: post_id, thumbnail_id: id, cookie: encodeURIComponent(document.cookie)
		}, function(str){
			var win = window.dialogArguments || opener || parent || top;
			$link.text( setPostThumbnailL10n.setThumbnail );
			if ( str == '0' ) {
				alert( setPostThumbnailL10n.error );
			} else {
				jQuery('a.ngg-post-thumbnail').show();
				$link.text( setPostThumbnailL10n.done );
				$link.fadeOut( 2000 );
				// set some id as meta input filed
				win.WPSetThumbnailID('ngg-' + id);
				// replace the meta box with the image
				win.WPSetThumbnailHTML(str);
			}
		}
		);
	}
//-->
</script>

<form id="filter" action="" method="get">
<input type="hidden" name="type" value="<?php 
    echo esc_attr($GLOBALS['type']);
    ?>
" />
<input type="hidden" name="tab" value="<?php 
    echo esc_attr($GLOBALS['tab']);
    ?>
" />
<input type="hidden" name="post_id" value="<?php 
    echo (int) $post_id;
    ?>
" />

<div class="tablenav">
	<?php 
    $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'total' => ceil($total / 10), 'current' => $_GET['paged']));
    if ($page_links) {
        echo "<div class='tablenav-pages'>{$page_links}</div>";
    }
    ?>
	
	<div class="alignleft actions">
		<select id="select_gal" name="select_gal" style="width:120px;">;
			<option value="0" <?php 
    selected('0', $galleryID);
    ?>
 ><?php 
    esc_attr(_e('No gallery', "nggallery"));
    ?>
</option>
			<?php 
    // Show gallery selection
    $gallerylist = $wpdb->get_results("SELECT * FROM {$wpdb->nggallery} ORDER BY gid ASC");
    if (is_array($gallerylist)) {
        foreach ($gallerylist as $gallery) {
            $selected = $gallery->gid == $galleryID ? ' selected="selected"' : "";
            echo '<option value="' . $gallery->gid . '"' . $selected . ' >' . $gallery->title . '</option>' . "\n";
        }
    }
    ?>
		</select>
		<input type="submit" id="show-gallery" value="<?php 
    esc_attr(_e('Select &#187;', 'nggallery'));
    ?>
" class="button-secondary" />
	</div>
	<br style="clear:both;" />
</div>
</form>

<form enctype="multipart/form-data" method="post" action="<?php 
    echo esc_attr($form_action_url);
    ?>
" class="media-upload-form" id="library-form">

	<?php 
    wp_nonce_field('ngg-media-form');
    ?>

	<script type="text/javascript">
	<!--
	jQuery(function($){
		var preloaded = $(".media-item.preloaded");
		if ( preloaded.length > 0 ) {
			preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
			updateMediaForm();
		}
	});
	-->
	</script>
	
	<div id="media-items">
	<?php 
    if (is_array($picarray)) {
        foreach ($picarray as $picid) {
            //TODO:Reduce SQL Queries
            $picture = nggdb::find_image($picid);
            ?>
			<div id='media-item-<?php 
            echo $picid;
            ?>
' class='media-item preloaded'>
			  <div class='filename'></div>
			  <a class='toggle describe-toggle-on' href='#'><?php 
            esc_attr(_e('Show', "nggallery"));
            ?>
</a>
			  <a class='toggle describe-toggle-off' href='#'><?php 
            esc_attr(_e('Hide', "nggallery"));
            ?>
</a>
			  <div class='filename new'><?php 
            echo empty($picture->alttext) ? wp_html_excerpt($picture->filename, 60) : stripslashes(wp_html_excerpt($picture->alttext, 60));
            ?>
</div>
			  <table class='slidetoggle describe startclosed'><tbody>
				  <tr>
					<td rowspan='4'><img class='thumbnail' alt='<?php 
            echo esc_attr($picture->alttext);
            ?>
' src='<?php 
            echo esc_attr($picture->thumbURL);
            ?>
'/></td>
					<td><?php 
            esc_attr(_e('Image ID:', "nggallery"));
            echo $picid;
            ?>
</td>
				  </tr>
				  <tr><td><?php 
            echo esc_attr($picture->filename);
            ?>
</td></tr>
				  <tr><td><?php 
            echo esc_attr(stripslashes($picture->alttext));
            ?>
</td></tr>
				  <tr><td>&nbsp;</td></tr>
				  <tr>
					<td class="label"><label for="image[<?php 
            echo $picid;
            ?>
][alttext]"><?php 
            esc_attr_e('Alt/Title text', "nggallery");
            ?>
</label></td>
					<td class="field"><input id="image[<?php 
            echo $picid;
            ?>
][alttext]" name="image[<?php 
            echo $picid;
            ?>
][alttext]" value="<?php 
            esc_attr_e(stripslashes($picture->alttext));
            ?>
" type="text"/></td>
				  </tr>	
				  <tr>
					<td class="label"><label for="image[<?php 
            echo $picid;
            ?>
][description]"><?php 
            esc_attr_e("Description", "nggallery");
            ?>
</label></td>
						<td class="field"><textarea name="image[<?php 
            echo $picid;
            ?>
][description]" id="image[<?php 
            echo $picid;
            ?>
][description]"><?php 
            esc_attr_e(stripslashes($picture->description));
            ?>
</textarea></td>
				  </tr>
					<tr class="align">
						<td class="label"><label for="image[<?php 
            echo $picid;
            ?>
][align]"><?php 
            esc_attr_e("Alignment");
            ?>
</label></td>
						<td class="field">
							<input name="image[<?php 
            echo $picid;
            ?>
][align]" id="image-align-none-<?php 
            echo $picid;
            ?>
" checked="checked" value="none" type="radio" />
							<label for="image-align-none-<?php 
            echo $picid;
            ?>
" class="align image-align-none-label"><?php 
            esc_attr_e("None");
            ?>
</label>
							<input name="image[<?php 
            echo $picid;
            ?>
][align]" id="image-align-left-<?php 
            echo $picid;
            ?>
" value="left" type="radio" />
							<label for="image-align-left-<?php 
            echo $picid;
            ?>
" class="align image-align-left-label"><?php 
            esc_attr_e("Left");
            ?>
</label>
							<input name="image[<?php 
            echo $picid;
            ?>
][align]" id="image-align-center-<?php 
            echo $picid;
            ?>
" value="center" type="radio" />
							<label for="image-align-center-<?php 
            echo $picid;
            ?>
" class="align image-align-center-label"><?php 
            esc_attr_e("Center");
            ?>
</label>
							<input name="image[<?php 
            echo $picid;
            ?>
][align]" id="image-align-right-<?php 
            echo $picid;
            ?>
" value="right" type="radio" />
							<label for="image-align-right-<?php 
            echo $picid;
            ?>
" class="align image-align-right-label"><?php 
            esc_attr_e("Right");
            ?>
</label>
						</td>
					</tr>
					<tr class="image-size">
						<th class="label"><label for="image[<?php 
            echo $picid;
            ?>
][size]"><span class="alignleft"><?php 
            esc_attr_e("Size");
            ?>
</span></label>
						</th>
						<td class="field">
							<input name="image[<?php 
            echo $picid;
            ?>
][size]" id="image-size-thumb-<?php 
            echo $picid;
            ?>
" type="radio" checked="checked" value="thumbnail" />
							<label for="image-size-thumb-<?php 
            echo $picid;
            ?>
"><?php 
            esc_attr_e("Thumbnail");
            ?>
</label>
							<input name="image[<?php 
            echo $picid;
            ?>
][size]" id="image-size-full-<?php 
            echo $picid;
            ?>
" type="radio" value="full" />
							<label for="image-size-full-<?php 
            echo $picid;
            ?>
"><?php 
            esc_attr_e("Full size");
            ?>
</label>
							<input name="image[<?php 
            echo $picid;
            ?>
][size]" id="image-size-singlepic-<?php 
            echo $picid;
            ?>
" type="radio" value="singlepic" />
							<label for="image-size-singlepic-<?php 
            echo $picid;
            ?>
"><?php 
            esc_attr_e("Singlepic", "nggallery");
            ?>
</label>
						</td>
					</tr>
				   <tr class="submit">
						<td>
							<input type="hidden"  name="image[<?php 
            echo $picid;
            ?>
][thumb]" value="<?php 
            echo $picture->thumbURL;
            ?>
" />
							<input type="hidden"  name="image[<?php 
            echo $picid;
            ?>
][url]" value="<?php 
            echo $picture->imageURL;
            ?>
" />
						</td>
						<td class="savesend">
							<?php 
            if ($calling_post_id && current_theme_supports('post-thumbnails', get_post_type($calling_post_id))) {
                echo "<a class='ngg-post-thumbnail' id='ngg-post-thumbnail-" . $picid . "' href='#' onclick='NGGSetAsThumbnail(\"{$picid}\");return false;'>" . esc_html__('Use as featured image') . "</a>";
            }
            ?>
							<button type="submit" class="button" value="1" name="send[<?php 
            echo $picid;
            ?>
]"><?php 
            esc_html_e('Insert into Post');
            ?>
</button>
						</td>
				   </tr>
			  </tbody></table>
			</div>
		<?php 
        }
    }
    ?>
	</div>
	<p class="ml-submit">
		<input type="submit" class="button savebutton" name="save" value="<?php 
    esc_attr(_e('Save all changes', 'nggallery'));
    ?>
" />
	</p>
	<input type="hidden" name="post_id" id="post_id" value="<?php 
    echo (int) $post_id;
    ?>
" />
	<input type="hidden" name="select_gal" id="select_gal" value="<?php 
    echo (int) $galleryID;
    ?>
" />
</form>

<?php 
}
Exemplo n.º 16
0
 function start_process()
 {
     global $ngg;
     if (!$this->valid_access()) {
         return;
     }
     switch ($this->method) {
         case 'search':
             //search for some images
             $this->result['images'] = array_merge((array) nggdb::search_for_images($this->term), (array) nggTags::find_images_for_tags($this->term, 'ASC'));
             break;
         case 'album':
             //search for some album  //TODO : Get images for each gallery, could end in a big db query
             $this->result['album'] = nggdb::find_album($this->id);
             break;
         case 'gallery':
             //search for some gallery
             $this->result['images'] = $this->id == 0 ? nggdb::find_last_images(0, 100) : nggdb::get_gallery($this->id, $ngg->options['galSort'], $ngg->options['galSortDir'], true, 0, 0, true);
             break;
         case 'image':
             //search for some image
             $this->result['images'] = nggdb::find_image($this->id);
             break;
         case 'tag':
             //search for images based on tags
             $this->result['images'] = nggTags::find_images_for_tags($this->term, 'ASC');
             break;
         case 'recent':
             //search for images based on tags
             $this->result['images'] = nggdb::find_last_images(0, $this->limit);
             break;
         case 'autocomplete':
             //return images, galleries or albums for autocomplete drop down list
             return $this->autocomplete();
             break;
         case 'version':
             $this->result = array('stat' => 'ok', 'version' => $ngg->version);
             return;
             break;
         default:
             $this->result = array('stat' => 'fail', 'code' => '98', 'message' => 'Method not known.');
             return false;
             break;
     }
     // result should be fine
     $this->result['stat'] = 'ok';
 }
 /**
  * Output HTML for the post thumbnail meta-box.
  *
  * @see wp-admin\includes\post.php
  * @param int $thumbnail_id ID of the image used for thumbnail
  * @return string html output
  */
 function _wp_post_thumbnail_html($thumbnail_id = NULL)
 {
     global $_wp_additional_image_sizes, $post_ID;
     $set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__('Set featured image') . '" href="' . esc_url(get_upload_iframe_src('image')) . '" id="set-post-thumbnail" class="thickbox">%s</a></p>';
     $content = sprintf($set_thumbnail_link, esc_html__('Set featured image'));
     $image = nggdb::find_image($thumbnail_id);
     $img_src = false;
     // get the options
     $ngg_options = nggGallery::get_option('ngg_options');
     if ($image) {
         if (is_array($_wp_additional_image_sizes) && isset($_wp_additional_image_sizes['post-thumbnail'])) {
             // Use post thumbnail settings if defined
             $width = absint($_wp_additional_image_sizes['post-thumbnail']['width']);
             $height = absint($_wp_additional_image_sizes['post-thumbnail']['height']);
             $mode = $_wp_additional_image_sizes['post-thumbnail']['crop'] ? 'crop' : '';
             // check fo cached picture
             $img_src = $image->cached_singlepic_file($width, $height, $mode);
         }
         // if we didn't use a cached image then we take the on-the-fly mode
         if ($img_src == false) {
             $img_src = trailingslashit(home_url()) . 'index.php?callback=image&amp;pid=' . $image->pid . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;mode=crop';
         }
         $thumbnail_html = '<img width="266" src="' . $img_src . '" alt="' . $image->alttext . '" title="' . $image->alttext . '" />';
         if (!empty($thumbnail_html)) {
             $ajax_nonce = wp_create_nonce("set_post_thumbnail-{$post_ID}");
             $content = sprintf($set_thumbnail_link, $thumbnail_html);
             $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__('Remove featured image') . '</a></p>';
         }
     }
     return $content;
 }
Exemplo n.º 18
0
                <img src="<?php 
    echo CONSTRUCTOR_DIRECTORY_URI;
    ?>
/admin/images/default.png" title="<?php 
    _e('Default', 'constructor');
    ?>
" alt="<?php 
    _e('Default', 'constructor');
    ?>
"/>
            </a>
            <?php 
    foreach ($gallerylist as $gallery) {
        ?>
                <?php 
        $img = nggdb::find_image($gallery->previewpic);
        ?>
                <a href="#" title="<?php 
        echo $gallery->title;
        ?>
" name="<?php 
        echo $gallery->gid;
        ?>
" <?php 
        if ($constructor['slideshow']['id'] == $gallery->gid) {
            echo 'class="selected"';
        }
        ?>
>
                <img src="<?php 
        echo $img->thumbURL;
Exemplo n.º 19
0
 public function handleUpload_widget()
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/class.npu_uploader.php';
     require_once NGGALLERY_ABSPATH . '/lib/meta.php';
     $ngg->options['swfupload'] = false;
     if ($_POST['uploadimage_widget']) {
         check_admin_referer('ngg_addgallery');
         if ($_FILES['MF__F_0_0']['error'] == 0) {
             $objUploaderNggAdmin = new UploaderNggAdmin();
             $messagetext = $objUploaderNggAdmin->upload_images_widget();
             $this->arrImageIds = $objUploaderNggAdmin->arrImageIds;
             $this->strGalleryPath = $objUploaderNggAdmin->strGalleryPath;
             $this->arrImageNames = $objUploaderNggAdmin->arrImageNames;
             if (is_array($objUploaderNggAdmin->arrThumbReturn) && count($objUploaderNggAdmin->arrThumbReturn) > 0) {
                 foreach ($objUploaderNggAdmin->arrThumbReturn as $strReturnMsg) {
                     if ($strReturnMsg != '1') {
                         $this->arrErrorMsg_widg[] = $strReturnMsg;
                     }
                 }
                 if (get_option('npu_upload_success')) {
                     $this->arrImageMsg_widg[] = get_option('npu_upload_success');
                 } else {
                     $this->arrImageMsg_widg[] = "Thank you! Your image has been submitted and is pending review.";
                 }
                 $this->sendEmail();
             }
             if (is_array($this->arrImageIds) && count($this->arrImageIds) > 0) {
                 foreach ($this->arrImageIds as $imageId) {
                     $pic = nggdb::find_image($imageId);
                     $objEXIF = new nggMeta($pic->imagePath);
                     $this->strTitle = $objEXIF->get_META('title');
                     $this->strDescription = $objEXIF->get_META('caption');
                     $this->strKeywords = $objEXIF->get_META('keywords');
                     $this->strTimeStamp = $objEXIF->get_date_time();
                 }
             } else {
                 if (get_option('npu_no_file')) {
                     $this->arrErrorMsg_widg[] = get_option('npu_no_file');
                 } else {
                     $this->arrErrorMsg_widg[] = "You must select a file to upload";
                 }
             }
             $this->update_details();
         } else {
             if (get_option('npu_upload_failed')) {
                 $this->arrErrorMsg_widg[] = get_option('npu_upload_failed');
             } else {
                 $this->arrErrorMsg_widg[] = "Upload failed!";
             }
         }
         if (count($this->arrErrorMsg_widg) > 0 && (is_array($this->arrImageIds) && count($this->arrImageIds) > 0)) {
             $gal_id = $_POST['galleryselect'];
             foreach ($this->arrImageIds as $intImageId) {
                 $filename = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$intImageId}' ");
                 if ($filename) {
                     $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$gal_id}' ");
                     if ($gallerypath) {
                         @unlink(WINABSPATH . $gallerypath . '/thumbs/thumbs_' . $filename);
                         @unlink(WINABSPATH . $gallerypath . '/' . $filename);
                     }
                     $delete_pic = $wpdb->query("DELETE FROM {$wpdb->nggpictures} WHERE pid = {$intImageId}");
                 }
             }
         }
     }
 }
Exemplo n.º 20
0
 /** indevd: As a NextGen Gallery user, I encountered a problem showing my image URL for post where postthumbnail was not uploaded to the WP media gallery but picked from the NextGen Gallery.
  * http://wordpress.org/support/topic/mod-for-nextgen-gallery-users?replies=2#post-3807567
  * @since 3.3.2
  * @author indevd
  * @date 2013-02-06
  */
 public function itempropwp_get_image($post_id)
 {
     if (!$post_id || $post_id == '') {
         global $post;
         $post_id = $post->ID;
     }
     $id = get_post_thumbnail_id($post_id);
     if (stripos($id, 'ngg-') !== false && class_exists('nggdb')) {
         $nggImage = nggdb::find_image(str_replace('ngg-', '', $id));
         $thumbnail = array(str_replace('?uamfiletype=nggImage', '', $nggImage->imageURL), $nggImage->width, $nggImage->height);
     } else {
         $thumbnail = wp_get_attachment_image_src($id, 'full');
         //$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');
     }
     return apply_filters('ipwp_post_imguri', $thumbnail);
 }
Exemplo n.º 21
0
/**
 * nggSinglePicture() - show a single picture based on the id
 * 
 * @access public 
 * @param int $imageID, db-ID of the image
 * @param int (optional) $width, width of the image
 * @param int (optional) $height, height of the image
 * @param string $mode (optional) could be none, watermark, web20
 * @param string $float (optional) could be none, left, right
 * @param string $template (optional) name for a template file, look for singlepic-$template
 * @param string $caption (optional) additional caption text
 * @return the content
 */
function nggSinglePicture($imageID, $width = 250, $height = 250, $mode = '', $float = '', $template = '', $caption = '')
{
    global $post;
    $ngg_options = nggGallery::get_option('ngg_options');
    // get picturedata
    $picture = nggdb::find_image($imageID);
    // if we didn't get some data, exit now
    if ($picture == null) {
        return __('[SinglePic not found]', 'nggallery');
    }
    // add float to img
    if (!empty($float)) {
        switch ($float) {
            case 'left':
                $float = ' ngg-left';
                break;
            case 'right':
                $float = ' ngg-right';
                break;
            case 'center':
                $float = ' ngg-center';
                break;
            default:
                $float = '';
                break;
        }
    }
    // check fo cached picture
    if ($ngg_options['imgCacheSinglePic'] && $post->post_status == 'publish') {
        $picture->thumbnailURL = $picture->cached_singlepic_file($width, $height, $mode);
    } else {
        $picture->thumbnailURL = NGGALLERY_URLPATH . 'nggshow.php?pid=' . $imageID . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;mode=' . $mode;
    }
    // add more variables for render output
    $picture->href_link = $picture->get_href_link();
    $picture->alttext = html_entity_decode(stripslashes($picture->alttext));
    $picture->description = html_entity_decode(stripslashes($picture->description));
    $picture->classname = 'ngg-singlepic' . $float;
    $picture->thumbcode = $picture->get_thumbcode('singlepic' . $imageID);
    $picture->height = (int) $height;
    $picture->width = (int) $width;
    $picture->caption = $caption;
    // let's get the meta data
    $meta = new nggMeta($picture->imagePath);
    $exif = $meta->get_EXIF();
    $iptc = $meta->get_IPTC();
    $xmp = $meta->get_XMP();
    // look for singlepic-$template.php or pure singlepic.php
    $filename = empty($template) ? 'singlepic' : 'singlepic-' . $template;
    // create the output
    $out = nggGallery::capture($filename, array('image' => $picture, 'meta' => $meta, 'exif' => $exif, 'iptc' => $iptc, 'xmp' => $xmp));
    $out = apply_filters('ngg_show_singlepic_content', $out, $picture);
    return $out;
}
Exemplo n.º 22
0
 function import_MetaData($imagesIds)
 {
     // add images to database
     global $wpdb;
     require_once NGGALLERY_ABSPATH . '/lib/image.php';
     if (!is_array($imagesIds)) {
         $imagesIds = array($imagesIds);
     }
     foreach ($imagesIds as $pic_id) {
         $picture = nggdb::find_image($pic_id);
         if (!$picture->error) {
             $meta = nggAdmin::get_MetaData($picture->imagePath);
             // get the title
             if (!($alttext = $meta['title'])) {
                 $alttext = $picture->alttext;
             }
             // get the caption / description field
             if (!($description = $meta['caption'])) {
                 $description = $picture->description;
             }
             // get the file date/time from exif
             $timestamp = $meta['timestamp'];
             // update database
             $result = $wpdb->query("UPDATE {$wpdb->nggpictures} SET alttext = '{$alttext}', description = '{$description}', imagedate = '{$timestamp}'  WHERE pid = {$pic_id}");
             // add the tags
             if ($meta['keywords']) {
                 $taglist = explode(",", $meta['keywords']);
                 wp_set_object_terms($pic_id, $taglist, 'ngg_tag');
             }
             // add tags
         }
         // error check
     }
     // foreach
     return true;
 }
Exemplo n.º 23
0
 /**
  * Add images to database
  *
  * @class nggAdmin
  * @param int $galleryID
  * @param array $imageslist
  * @return array $image_ids Id's which are sucessful added
  */
 static function add_Images($galleryID, $imageslist)
 {
     global $wpdb, $ngg;
     $image_ids = array();
     if (is_array($imageslist)) {
         foreach ($imageslist as $picture) {
             // filter function to rename/change/modify image before
             $picture = apply_filters('ngg_pre_add_new_image', $picture, $galleryID);
             // strip off the extension of the filename
             $path_parts = M_I18n::mb_pathinfo($picture);
             $alttext = !isset($path_parts['filename']) ? substr($path_parts['basename'], 0, strpos($path_parts['basename'], '.')) : $path_parts['filename'];
             // save it to the database
             $pic_id = nggdb::add_image($galleryID, $picture, '', $alttext);
             if (C_NextGen_Settings::get_instance()->imgBackup && !empty($pic_id)) {
                 $storage = C_Gallery_Storage::get_instance();
                 $storage->backup_image($pic_id);
             }
             if (!empty($pic_id)) {
                 $image_ids[] = $pic_id;
             }
             // add the metadata
             nggAdmin::import_MetaData($pic_id);
             // auto rotate
             nggAdmin::rotate_image($pic_id);
             // Autoresize image if required
             if ($ngg->options['imgAutoResize']) {
                 $imagetmp = nggdb::find_image($pic_id);
                 $sizetmp = @getimagesize($imagetmp->imagePath);
                 $widthtmp = $ngg->options['imgWidth'];
                 $heighttmp = $ngg->options['imgHeight'];
                 if ($sizetmp[0] > $widthtmp && $widthtmp || $sizetmp[1] > $heighttmp && $heighttmp) {
                     nggAdmin::resize_image($pic_id);
                 }
             }
             // action hook for post process after the image is added to the database
             $image = array('id' => $pic_id, 'filename' => $picture, 'galleryID' => $galleryID);
             do_action('ngg_added_new_image', $image);
         }
     }
     // is_array
     // delete dirsize after adding new images
     delete_transient('dirsize_cache');
     do_action('ngg_after_new_images_added', $galleryID, $image_ids);
     return $image_ids;
 }
Exemplo n.º 24
0
function knews_get_image_path()
{
    global $post;
    $id = get_post_thumbnail_id();
    if (stripos($id, 'ngg-') !== false && class_exists('nggdb')) {
        $nggImage = nggdb::find_image(str_replace('ngg-', '', $id));
        $thumbnail = array($nggImage->imageURL);
    } else {
        $thumbnail = wp_get_attachment_image_src($id, 'full', true);
    }
    $theimage = $thumbnail[0];
    return $theimage;
}
Exemplo n.º 25
0
 /**
  * display_thumb()
  *
  * This method displays the post thumbnail.
  *
  * @author Luca Grandicelli <*****@*****.**>
  * @copyright (C) 2011-2014 Luca Grandicelli
  * @package special-recent-posts-free
  * @version 2.0.4
  * @param $post The global WP post object.
  * @access private
  * @return mixed It could return the HTML code for the post thumbnail or false in case of some error.
  */
 private function display_thumb($post)
 {
     // Checking if featured thumbnails setting is active, if the current post has one and if it exists as file.
     if (function_exists('has_post_thumbnail') && has_post_thumbnail($post->ID)) {
         // Fetching Thumbnail ID.
         $thumbnail_id = get_post_thumbnail_id($post->ID);
         // Checking if current featured thumbnail comes from the NExtGen Plugin.
         if (stripos($thumbnail_id, 'ngg-') !== false && class_exists('nggdb')) {
             try {
                 // Creating New NextGen Class instance.
                 $nggdb = new nggdb();
                 // Fetching NGG thumbnail object.
                 $nggImage = $nggdb->find_image(str_replace('ngg-', '', $thumbnail_id));
                 // Retrieving physical path of NGG thumbnail image.
                 $featured_physical_path = $nggImage->imagePath;
                 // Fetching NGG thumbnail image URL.
                 $featured_thumb_url = $nggImage->imageURL;
             } catch (Exception $e) {
             }
         } else {
             // Retrieving featured image attachment src.
             $featured_thumb_attachment = wp_get_attachment_image_src($thumbnail_id, 'large');
             // Retrieving physical path of featured image.
             $featured_physical_path = get_attached_file($thumbnail_id);
             // Retrieving featured image url.
             $featured_thumb_url = $featured_thumb_attachment[0];
         }
         // Parsing featured image url.
         $featured_thumb_url_obj = parse_url($featured_thumb_url);
         // Retrieving featured image basename.
         $featured_thumb_basename = pathinfo(basename($featured_thumb_url));
         // Removing querystring from image to save. This fixed the Jetpack Photon Issue.
         $featured_thumb_basename['extension'] = preg_replace('/\\?.*/', '', $featured_thumb_basename['extension']);
         // Building featured image cached path.
         $featured_thumb_cache = $this->cache_basepath . 'srpthumb-p' . $post->ID . '-' . $this->widget_args['thumbnail_width'] . 'x' . $this->widget_args['thumbnail_height'] . '-' . $this->widget_args['thumbnail_rotation'] . '.' . $featured_thumb_basename['extension'];
         // Checking if the thumbnail already exists. In this case, simply render it. Otherwise generate it.
         if (file_exists(SRP_PLUGIN_DIR . $featured_thumb_cache) || $this->generate_gd_image($post, 'featured', $featured_physical_path, SRP_PLUGIN_DIR . $featured_thumb_cache, $this->widget_args['thumbnail_width'], $this->widget_args['thumbnail_height'], $this->widget_args['thumbnail_rotation'])) {
             // Return cached image as source (URL path).
             $featured_thumb_src = SRP_PLUGIN_URL . $featured_thumb_cache;
             // Generating Image HTML Tag.
             $featured_htmltag = '<img src="' . $featured_thumb_src . '" class="srp-post-thumbnail" alt="' . esc_attr($post->post_title) . '" />';
         } else {
             // No featured image has been found. Trying to fetch the first image tag from the post content.
             $featured_htmltag = $this->get_first_image_url($post, $this->widget_args['thumbnail_width'], $this->widget_args['thumbnail_height'], $post->post_title);
         }
         // Checking if thumbnail should be linked to post.
         if ('yes' == $this->widget_args['thumbnail_link']) {
             // Building featured image link tag.
             $featured_temp_content = $this->srp_create_tag('a', $featured_htmltag, array('class' => 'srp-post-thumbnail-link', 'href' => get_permalink($post->ID), 'title' => $post->post_title));
         } else {
             // Displaying post thumbnail without link.
             $featured_temp_content = $featured_htmltag;
         }
     } else {
         // No featured image has been found. Trying to fetch the first image tag from the post content.
         $featured_htmltag = $this->get_first_image_url($post, $this->widget_args['thumbnail_width'], $this->widget_args['thumbnail_height'], $post->post_title);
         // Checking if returned image is real or it is a false value due to skip_noimage_posts option enabled.
         if ($featured_htmltag) {
             // Checking if thumbnail should be linked to post.
             if ('yes' == $this->widget_args['thumbnail_link']) {
                 // Building image tag.
                 $featured_temp_content = $this->srp_create_tag('a', $featured_htmltag, array('class' => 'srp-post-thumbnail-link', 'href' => get_permalink($post->ID), 'title' => $post->post_title));
             } else {
                 // Displaying post thumbnail without link.
                 $featured_temp_content = $featured_htmltag;
             }
         } else {
             // Return false.
             return false;
         }
     }
     // Return all the image process.
     return $featured_temp_content;
 }
function eStore_get_ngg_image_url_html($pictureID, $item_name)
{
    $eStore_auto_shorten_url = WP_ESTORE_AUTO_SHORTEN_DOWNLOAD_LINKS;
    $script_location = get_option('eStore_download_script');
    $image = nggdb::find_image($pictureID);
    $imageUrl = $image->imageURL;
    $product_id = get_option('eStore_ngg_template_product_id');
    eStore_payment_debug('Generating download key for Nextgen gallery image using product ID: ' . $product_id, true);
    $download_key = eStore_generate_download_key($product_id, $imageUrl);
    $encrypted_download_url = eStore_construct_raw_encrypted_dl_url($download_key);
    $raw_download = '<a href="' . $encrypted_download_url . '">' . $encrypted_download_url . '</a>';
    $download_link = "<br /><strong>" . $item_name . "</strong> - " . $raw_download;
    eStore_register_link_in_db('', $download_key, $encrypted_download_url, '', '', '', 0, '');
    return $download_link;
}
Exemplo n.º 27
0
/**
 * nggSinglePicture() - show a single picture based on the id
 * 
 * @access public 
 * @param int $imageID, db-ID of the image
 * @param int (optional) $width, width of the image
 * @param int (optional) $height, height of the image
 * @param string $mode (optional) could be none, watermark, web20
 * @param string $float (optional) could be none, left, right
 * @param string $template (optional) name for a template file, look for singlepic-$template
 * @param string $caption (optional) additional caption text
 * @param string $link (optional) link to a other url instead the full image
 * @return the content
 */
function nggSinglePicture($imageID, $width = 250, $height = 250, $mode = '', $float = '', $template = '', $caption = '', $link = '')
{
    global $post;
    $ngg_options = nggGallery::get_option('ngg_options');
    // get picturedata
    $picture = nggdb::find_image($imageID);
    // if we didn't get some data, exit now
    if ($picture == null) {
        return __('[SinglePic not found]', 'nggallery');
    }
    // add float to img
    switch ($float) {
        case 'left':
            $float = ' ngg-left';
            break;
        case 'right':
            $float = ' ngg-right';
            break;
        case 'center':
            $float = ' ngg-center';
            break;
        default:
            $float = '';
            break;
    }
    // clean mode if needed
    $mode = preg_match('/(web20|watermark)/i', $mode) ? $mode : '';
    //let's initiate the url
    $picture->thumbnailURL = false;
    // check fo cached picture
    if ($post->post_status == 'publish') {
        $picture->thumbnailURL = $picture->cached_singlepic_file($width, $height, $mode);
    }
    // if we didn't use a cached image then we take the on-the-fly mode
    if (!$picture->thumbnailURL) {
        $picture->thumbnailURL = trailingslashit(home_url()) . 'index.php?callback=image&amp;pid=' . $imageID . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;mode=' . $mode;
    }
    // add more variables for render output
    $picture->imageURL = empty($link) ? $picture->imageURL : $link;
    $picture->href_link = $picture->get_href_link();
    $picture->alttext = html_entity_decode(stripslashes(nggGallery::i18n($picture->alttext, 'pic_' . $picture->pid . '_alttext')));
    $picture->linktitle = htmlspecialchars(stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')));
    $picture->description = html_entity_decode(stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')));
    $picture->classname = 'ngg-singlepic' . $float;
    $picture->thumbcode = $picture->get_thumbcode('singlepic' . $imageID);
    $picture->height = (int) $height;
    $picture->width = (int) $width;
    $picture->caption = nggGallery::i18n($caption);
    // filter to add custom content for the output
    $picture = apply_filters('ngg_image_object', $picture, $imageID);
    // let's get the meta data
    $meta = new nggMeta($imageID);
    $meta->sanitize();
    $exif = $meta->get_EXIF();
    $iptc = $meta->get_IPTC();
    $xmp = $meta->get_XMP();
    $db = $meta->get_saved_meta();
    //if we get no exif information we try the database
    $exif = $exif == false ? $db : $exif;
    // look for singlepic-$template.php or pure singlepic.php
    $filename = empty($template) ? 'singlepic' : 'singlepic-' . $template;
    // create the output
    $out = nggGallery::capture($filename, array('image' => $picture, 'meta' => $meta, 'exif' => $exif, 'iptc' => $iptc, 'xmp' => $xmp, 'db' => $db));
    $out = apply_filters('ngg_show_singlepic_content', $out, $picture);
    return $out;
}
Exemplo n.º 28
0
<?php

// Load wp-config
require_once dirname(__FILE__) . '/ngg-config.php';
// reference thumbnail class
include_once nggGallery::graphic_library();
include_once 'lib/core.php';
// get the plugin options
$ngg_options = get_option('ngg_options');
// Some parameters from the URL
$pictureID = (int) $_GET['pid'];
$mode = isset($_GET['mode']) ? esc_attr($_GET['mode']) : '';
// let's get the image data
$picture = nggdb::find_image($pictureID);
$thumb = new ngg_Thumbnail($picture->imagePath);
// Resize if necessary
if (!empty($_GET['width']) || !empty($_GET['height'])) {
    // Sanitize
    $w = !empty($_GET['width']) ? intval($_GET['width']) : 0;
    $h = !empty($_GET['height']) ? intval($_GET['height']) : 0;
    // limit the maxium size, prevent server memory overload
    if ($w > 1280) {
        $w = 1280;
    }
    if ($h > 1280) {
        $h = 1280;
    }
    $thumb->resize($w, $h);
}
// Apply effects according to the mode parameter
if ($mode == 'watermark') {
function getNGGalleryImages($ngGalleries, $ngImages, $dt, $lat, $lon, $dtoffset, &$error)
{
    $result = array();
    $galids = explode(',', $ngGalleries);
    $imgids = explode(',', $ngImages);
    if (!isNGGalleryActive()) {
        return '';
    }
    try {
        $pictures = array();
        foreach ($galids as $g) {
            $pictures = array_merge($pictures, nggdb::get_gallery($g));
        }
        foreach ($imgids as $i) {
            array_push($pictures, nggdb::find_image($i));
        }
        foreach ($pictures as $p) {
            $item = array();
            $item["data"] = $p->thumbHTML;
            if (is_callable('exif_read_data')) {
                $exif = @exif_read_data($p->imagePath);
                if ($exif !== false) {
                    $item["lon"] = getExifGps($exif["GPSLongitude"], $exif['GPSLongitudeRef']);
                    $item["lat"] = getExifGps($exif["GPSLatitude"], $exif['GPSLatitudeRef']);
                    if ($item["lat"] != 0 || $item["lon"] != 0) {
                        $result[] = $item;
                    } else {
                        if (isset($p->imagedate)) {
                            $_dt = strtotime($p->imagedate) + $dtoffset;
                            $_item = findItemCoordinate($_dt, $dt, $lat, $lon);
                            if ($_item != null) {
                                $item["lat"] = $_item["lat"];
                                $item["lon"] = $_item["lon"];
                                $result[] = $item;
                            }
                        }
                    }
                }
            } else {
                $error .= "Sorry, <a href='http://php.net/manual/en/function.exif-read-data.php' target='_blank' >exif_read_data</a> function not found! check your hosting..<br />";
            }
        }
        /* START FIX NEXT GEN GALLERY 2.x */
        if (class_exists("C_Component_Registry")) {
            $renderer = C_Component_Registry::get_instance()->get_utility('I_Displayed_Gallery_Renderer');
            $params['gallery_ids'] = $ngGalleries;
            $params['image_ids'] = $ngImages;
            $params['display_type'] = NEXTGEN_GALLERY_BASIC_THUMBNAILS;
            $params['images_per_page'] = 999;
            // also add js references to get the gallery working
            $dummy = $renderer->display_images($params, $inner_content);
            /* START FIX NEXT GEN GALLERY PRO */
            if (preg_match("/data-nplmodal-gallery-id=[\"'](.*?)[\"']/", $dummy, $m)) {
                $galid = $m[1];
                if ($galid) {
                    for ($i = 0; $i < count($result); ++$i) {
                        $result[$i]["data"] = str_replace("%PRO_LIGHTBOX_GALLERY_ID%", $galid, $result[$i]["data"]);
                    }
                }
            }
            /* END FIX NEXT GEN GALLERY PRO */
        }
        /* END FIX NEXT GEN GALLERY 2.x */
    } catch (Exception $e) {
        $error .= 'Error When Retrieving NextGen Gallery galleries/images: $e <br />';
    }
    return $result;
}
Exemplo n.º 30
0
 /**
  * Method "ngg.uploadImage"
  * Uploads a image to a gallery
  *
  * @since 1.4
  * 
  * @copyright addapted from WP Core
  * @param array $args Method parameters.
  * 			- int blog_id
  *	    	- string username
  *	    	- string password
  *	    	- struct data
  *	          o string name
  *            o string type (optional)
  *	          o base64 bits 
  *	          o bool overwrite (optional)
  *			  o int gallery 
  *			  o int image_id  (optional) 	 
  * @return array with image meta data
  */
 function uploadImage($args)
 {
     global $wpdb;
     require_once dirname(dirname(__FILE__)) . '/admin/functions.php';
     // admin functions
     require_once 'meta.php';
     // meta data import
     $blog_ID = (int) $args[0];
     $username = $wpdb->escape($args[1]);
     $password = $wpdb->escape($args[2]);
     $data = $args[3];
     $name = $data['name'];
     $type = $data['type'];
     $bits = $data['bits'];
     // gallery & image id
     $gid = (int) $data['gallery'];
     // required field
     $pid = (int) $data['image_id'];
     // optional but more foolproof of overwrite
     $image = false;
     // container for the image object
     logIO('O', '(NGG) Received ' . strlen($bits) . ' bytes');
     if (!($user = $this->login($username, $password))) {
         return $this->error;
     }
     // Check if you have the correct capability for upload
     if (!current_user_can('NextGEN Upload images')) {
         logIO('O', '(NGG) User does not have upload_files capability');
         $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.'));
         return $this->error;
     }
     // Look for the gallery , could we find it ?
     if (!($gallery = nggdb::find_gallery($gid))) {
         return new IXR_Error(404, __('Could not find gallery ' . $gid));
     }
     // Now check if you have the correct capability for this gallery
     if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
         logIO('O', '(NGG) User does not have upload_files capability');
         $this->error = new IXR_Error(401, __('You are not allowed to upload files to this gallery.'));
         return $this->error;
     }
     //clean filename and extract extension
     $filepart = nggGallery::fileinfo($name);
     $name = $filepart['basename'];
     // check for allowed extension and if it's an image file
     $ext = array('jpg', 'png', 'gif');
     if (!in_array($filepart['extension'], $ext)) {
         logIO('O', '(NGG) Not allowed file type');
         $this->error = new IXR_Error(401, __('This is no valid image file.', 'nggallery'));
         return $this->error;
     }
     // in the case you would overwrite the image, let's delete the old one first
     if (!empty($data["overwrite"]) && $data["overwrite"] == true) {
         // search for the image based on the filename, if it's not already provided
         if ($pid == 0) {
             $pid = $wpdb->get_col(" SELECT pid FROM {$wpdb->nggpictures} WHERE filename = '{$name}' AND galleryid = '{$gid}' ");
         }
         if (!($image = nggdb::find_image($pid))) {
             return new IXR_Error(404, __('Could not find image id ' . $pid));
         }
         // sync the gallery<->image parameter, otherwise we may copy it to the wrong gallery
         $gallery = $image;
         // delete now the image
         if (!@unlink($image->imagePath)) {
             $errorString = sprintf(__('Failed to delete image %1$s ', 'nggallery'), $image->imagePath);
             logIO('O', '(NGG) ' . $errorString);
             return new IXR_Error(500, $errorString);
         }
     }
     // upload routine from wp core, load first the image to the upload folder, $upload['file'] contain the path
     $upload = wp_upload_bits($name, $type, $bits);
     if (!empty($upload['error'])) {
         $errorString = sprintf(__('Could not write file %1$s (%2$s)'), $name, $upload['error']);
         logIO('O', '(NGG) ' . $errorString);
         return new IXR_Error(500, $errorString);
     }
     // this is the dir to the gallery
     $path = WINABSPATH . $gallery->path;
     // check if the filename already exist, if not add a counter index
     $filename = wp_unique_filename($path, $name);
     $destination = $path . '/' . $filename;
     // Move files to gallery folder
     if (!@rename($upload['file'], $destination)) {
         $errorString = sprintf(__('Failed to move image %1$s to %2$s', 'nggallery'), '<strong>' . $upload['file'] . '</strong>', $destination);
         logIO('O', '(NGG) ' . $errorString);
         return new IXR_Error(500, $errorString);
     }
     //add to database if it's a new image
     if (empty($data["overwrite"]) || $data["overwrite"] == false) {
         $pid_array = nggAdmin::add_Images($gallery->gid, array($filename));
         // the first element is our new image id
         if (count($pid_array) == 1) {
             $pid = $pid_array[0];
         }
     }
     //get all information about the image, in the case it's a new one
     if (!$image) {
         $image = nggdb::find_image($pid);
     }
     // create again the thumbnail, should return a '1'
     nggAdmin::create_thumbnail($image);
     return apply_filters('ngg_upload_image', $image);
 }