Ejemplo n.º 1
0
 function widget($args, $instance)
 {
     global $wpdb, $flagdb;
     extract($args);
     $title = apply_filters('widget_title', empty($instance['title']) ? ' ' : $instance['title'], $instance, $this->id_base);
     $album = $instance['album'];
     $qty = intval($instance['qty']) < 1 ? 1 : intval($instance['qty']);
     $gallerylist = $flagdb->get_album($album);
     $ids = explode(',', $gallerylist);
     foreach ($ids as $id) {
         $galID = (int) $id;
         $status = $wpdb->get_var("SELECT status FROM {$wpdb->flaggallery} WHERE gid={$galID}");
         if (intval($status)) {
             continue;
         }
         if ($instance['type'] == 'random') {
             $imageList[$galID] = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->flaggallery} AS t INNER JOIN {$wpdb->flagpictures} AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 AND t.gid = {$galID} ORDER by rand() LIMIT 0,{$qty}");
         } else {
             $flag_options = get_option('flag_options');
             $order_dir = $flag_options['galSortDir'] == 'DESC' ? 'DESC' : 'ASC';
             if (in_array($flag_options['galSort'], array('sortorder', 'pid', 'filename', 'alttext', 'imagedate', 'hitcounter', 'total_votes', 'rand()'))) {
                 $order_by = 'tt.' . $flag_options['galSort'];
             } else {
                 $order_by = 'tt.sortorder';
             }
             $imageList[$galID] = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->flaggallery} AS t INNER JOIN {$wpdb->flagpictures} AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 AND t.gid = {$galID} ORDER by {$order_by} {$order_dir} LIMIT 0,{$qty}");
         }
     }
     echo $before_widget . $before_title . $title . $after_title;
     echo "\n" . '<div class="flag-widget">' . "\n";
     if (is_array($imageList)) {
         $isMobile = (bool) preg_match('#\\b(ip(hone|od|ad)|android|opera m(ob|in)i|windows (phone|ce)|blackberry|tablet' . '|s(ymbian|eries60|amsung)|p(laybook|alm|rofile/midp|laystation portable)|nokia|fennec|htc[\\-_]' . '|mobile|up\\.browser|[1-4][0-9]{2}x[1-4][0-9]{2})\\b#i', $_SERVER['HTTP_USER_AGENT']);
         if (!$isMobile) {
             $thumbcode = 'class="flag_fancybox"';
         } else {
             $thumbcode = 'class="flag_newbox"';
         }
         foreach ($imageList as $gallery_) {
             foreach ($gallery_ as $_image) {
                 // get the URL constructor
                 $image = new flagImage($_image);
                 // enable i18n support for alttext and description
                 $alttext = strip_tags(htmlspecialchars(stripslashes(flagGallery::i18n($image->alttext, 'pic_' . $image->pid . '_alttext'))));
                 $description = strip_tags(htmlspecialchars(stripslashes(flagGallery::i18n($image->description, 'pic_' . $image->pid . '_description'))));
                 //TODO:For mixed portrait/landscape it's better to use only the height setting, if widht is 0 or vice versa
                 $out = '<a href="' . plugins_url() . '/flash-album-gallery/facebook.php?i=' . $image->galleryid . '&amp;f=' . $instance['skin'] . '&amp;h=' . $instance['fheight'] . '" title="' . $image->title . '" ' . $thumbcode . '>';
                 $out .= '<img src="' . $image->thumbURL . '" width="' . $instance['width'] . '" height="' . $instance['height'] . '" title="' . $alttext . '" alt="' . $description . '" />';
                 echo $out . '</a>' . "\n";
             }
         }
     }
     echo '</div>' . "\n";
     echo '<style type="text/css">.flag_fancybox img, .flag_newbox img { border: 1px solid #A9A9A9; margin: 0 2px 2px 0; padding: 1px; }</style>' . "\n";
     echo '<script type="text/javascript">var fbVar = "' . plugins_url('/', dirname(__FILE__)) . '"; var fbW = ' . $instance['fwidth'] . ', fbH = ' . $instance['fheight'] . '; waitJQ(fbVar,fbW,fbH);</script>' . "\n";
     echo $after_widget;
 }
Ejemplo n.º 2
0
function flag_manage_gallery_main()
{
    global $flag, $flagdb, $wp_query;
    //Build the pagination for more than 25 galleries
    if (!isset($_GET['paged']) || $_GET['paged'] < 1) {
        $_GET['paged'] = 1;
    }
    $sort_gall_by = isset($_GET['galsort']) ? $_GET['galsort'] : $flag->options['albSort'];
    $sort_gall_dir = isset($_GET['sortdir']) ? $_GET['sortdir'] : $flag->options['albSortDir'];
    $ascdesc = $sort_gall_dir == 'DESC' ? 'ASC' : 'DESC';
    $_GET['paged'] = intval($_GET['paged']);
    $perpage = intval($flag->options['albPerPage']) ? intval($flag->options['albPerPage']) : 50;
    $start = ($_GET['paged'] - 1) * $perpage;
    $gallerylist = $flagdb->find_all_galleries($sort_gall_by, $sort_gall_dir, $counter = true, $perpage, $start, $exclude = false, $draft = true);
    $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => $flagdb->paged['max_objects_per_page'], 'current' => $_GET['paged']));
    ?>
	<script type="text/javascript"> 
	<!--
	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('editgalleries'));
		 
		if(numchecked < 1) { 
			alert('<?php 
    echo esc_js(__('No images selected', 'flag'));
    ?>
');
			return false; 
		} 
		
		actionId = jQuery('#bulkaction').val();
		
		switch (actionId) {
			case "resize_images":
				showDialog('resize_images', 120);
				return false;
				break;
			case "new_thumbnail":
				showDialog('new_thumbnail', 160);
				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.", 'flag')), "' + numchecked + '");
    ?>
');
	}

	function showDialog( windowId, height ) {
		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);
		// console.log (jQuery("#TB_imagelist").val());
		tb_show("", "#TB_inline?width=640&height=" + height + "&inlineId=" + windowId + "&modal=true", false);
	}
	
	//-->
	</script>
	<div class="flag-wrap" style="margin-top:40px;">
		<h2><?php 
    _e('Gallery Overview', 'flag');
    ?>
</h2>
		<form class="search-form" action="" method="get">
		<p class="search-box">
			<label class="hidden" for="media-search-input"><?php 
    _e('Search Images', 'flag');
    ?>
:</label>
			<input type="hidden" id="page-name" name="page" value="flag-manage-gallery" />
			<input type="text" id="media-search-input" name="s" value="<?php 
    the_search_query();
    ?>
" />
			<input type="submit" value="<?php 
    _e('Search Images', 'flag');
    ?>
" class="button" />
		</p>
		</form>
		<form id="editgalleries" class="flagform" method="POST" action="<?php 
    echo $flag->manage_page->base_page . '&amp;paged=' . $_GET['paged'];
    ?>
" accept-charset="utf-8">
		<?php 
    wp_nonce_field('flag_bulkgallery');
    ?>
		<input type="hidden" name="page" value="manage-galleries" />
		
		<div class="tablenav">
			
			<div class="alignleft actions">
				<?php 
    if (function_exists('json_encode')) {
        ?>
				<select name="bulkaction" id="bulkaction">
					<option value="no_action" ><?php 
        _e("No action", 'flag');
        ?>
</option>
					<option value="webview_images" ><?php 
        _e("Create images optimized for web", 'flag');
        ?>
</option>
					<option value="new_thumbnail" ><?php 
        _e("Create new thumbnails", 'flag');
        ?>
</option>
					<option value="resize_images" ><?php 
        _e("Resize images", 'flag');
        ?>
</option>
					<option value="import_meta" ><?php 
        _e("Import metadata", 'flag');
        ?>
</option>
					<option value="copy_meta" ><?php 
        _e("Metadata to description", 'flag');
        ?>
</option>
					<?php 
        do_action('flag_manage_galleries_bulkaction');
        ?>
				</select>
				<input name="showThickbox" class="button-secondary" type="submit" value="<?php 
        _e('Apply', 'flag');
        ?>
" onclick="if ( !checkSelected() ) return false;" />
				<?php 
    }
    ?>
			</div>
			
		<?php 
    if ($page_links) {
        ?>
			<div class="tablenav-pages"><?php 
        $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>%s', number_format_i18n(($_GET['paged'] - 1) * $perpage + 1), number_format_i18n(min($_GET['paged'] * $perpage, $flagdb->paged['total_objects'])), number_format_i18n($flagdb->paged['total_objects']), $page_links);
        echo $page_links_text;
        ?>
</div>
			<br class="clear" />
		<?php 
    }
    ?>
		
		</div>
		<table class="widefat flag-table" cellspacing="0">
			<thead>
			<tr>
				<th scope="col" class="cb column-cb" >
					<input type="checkbox" onclick="checkAll(document.getElementById('editgalleries'));" name="checkall"/>
				</th>
				<th scope="col"><a href="<?php 
    echo $flag->manage_page->base_page . "&galsort=gid&sortdir={$ascdesc}&paged=" . $_GET['paged'];
    ?>
"><?php 
    _e('ID');
    ?>
</a></th>
				<th scope="col"><a href="<?php 
    echo $flag->manage_page->base_page . "&galsort=title&sortdir={$ascdesc}&paged=" . $_GET['paged'];
    ?>
"><?php 
    _e('Title', 'flag');
    ?>
</a></th>
				<th scope="col"><?php 
    _e('Description', 'flag');
    ?>
</th>
				<th scope="col"><?php 
    _e('Author', 'flag');
    ?>
</th>
				<th scope="col"><?php 
    _e('Quantity', 'flag');
    ?>
</th>
				<th scope="col"><?php 
    _e('Action', 'flag');
    ?>
</th>
			</tr>
			</thead>
			<tbody>
<?php 
    if ($gallerylist) {
        foreach ($gallerylist as $gallery) {
            $class = !isset($class) || $class == 'alt ' ? '' : 'alt ';
            $gid = $gallery->gid;
            $name = empty($gallery->title) ? $gallery->name : $gallery->title;
            $author_user = get_userdata((int) $gallery->author);
            ?>
		<tr id="gallery-<?php 
            echo $gid;
            ?>
" class="<?php 
            echo $class;
            echo $gallery->status ? 'flag_draft' : 'flag_public';
            ?>
" >
			<th scope="row" class="cb column-cb">
				<?php 
            if (flagAdmin::can_manage_this_gallery($gallery->author)) {
                ?>
					<input name="doaction[]" type="checkbox" value="<?php 
                echo $gid;
                ?>
" />
				<?php 
            }
            ?>
			</th>
			<td scope="row"><?php 
            echo $gid;
            ?>
</td>
			<td style="width:30%">
				<?php 
            if (flagAdmin::can_manage_this_gallery($gallery->author)) {
                ?>
					<a href="<?php 
                echo wp_nonce_url($flag->manage_page->base_page . "&amp;mode=edit&amp;gid=" . $gid, 'flag_editgallery');
                ?>
" class='edit' title="<?php 
                _e('Edit');
                ?>
" >
						<?php 
                echo esc_html(flagGallery::i18n($name));
                ?>
					</a>
				<?php 
            } else {
                ?>
					<?php 
                echo esc_html(flagGallery::i18n($gallery->title));
                ?>
				<?php 
            }
            if ($gallery->status) {
                echo ' <b>- ' . __('Draft', 'flag') . '</b>';
            }
            ?>
			</td>
			<td style="width:30%"><?php 
            echo esc_html(flagGallery::i18n($gallery->galdesc));
            ?>
&nbsp;</td>
			<td><?php 
            echo $author_user->display_name;
            ?>
</td>
			<td><?php 
            echo $gallery->counter;
            ?>
</td>
			<td style="white-space:nowrap;">
				<?php 
            if (flagAdmin::can_manage_this_gallery($gallery->author)) {
                ?>
					<a href="<?php 
                echo wp_nonce_url($flag->manage_page->base_page . "&amp;mode=delete&amp;gid=" . $gid, 'flag_editgallery');
                ?>
" class="delete" onclick="javascript:check=confirm( '<?php 
                _e("Delete this gallery ?", 'flag');
                ?>
');if(check==false) return false;"><?php 
                _e('Delete', 'flag');
                ?>
</a>
					<?php 
                if ($gallery->status) {
                    ?>
					| <a href="<?php 
                    echo wp_nonce_url($flag->manage_page->base_page . "&amp;mode=publish&amp;gid=" . $gid, 'flag_editgallery');
                    ?>
" class="status" onclick="javascript:check=confirm( '<?php 
                    _e("Publish this gallery?", 'flag');
                    ?>
');if(check==false) return false;"><?php 
                    _e('Publish', 'flag');
                    ?>
</a>
					<?php 
                } else {
                    ?>
					| <a href="<?php 
                    echo wp_nonce_url($flag->manage_page->base_page . "&amp;mode=draft&amp;gid=" . $gid, 'flag_editgallery');
                    ?>
" class="status" onclick="javascript:check=confirm( '<?php 
                    _e("Make this gallery draft?", 'flag');
                    ?>
');if(check==false) return false;"><?php 
                    _e('Draft', 'flag');
                    ?>
</a>
					<?php 
                }
                ?>
				<?php 
            }
            ?>
			</td>
		</tr>
		<?php 
        }
    } else {
        echo '<tr><td colspan="7" align="center"><strong>' . __('No entries found', 'flag') . '</strong></td></tr>';
    }
    ?>
			
			</tbody>
		</table>
		</form>
	</div>
<?php 
    if (current_user_can('FlAG Manage others gallery')) {
        ?>
<script type="text/javascript">
/*<![CDATA[*/
jQuery(document).ready(function(){
	jQuery(".album_categoties").sortable({ opacity: 0.6, cursor: 'move', connectWith: ".album_categoties", update: function() {}}).disableSelection();
	jQuery( "#draggable .acat" ).draggable({
		connectToSortable: ".album_categoties",
		helper: "clone",
		revert: "invalid"
	}).disableSelection();
	jQuery( ".album_categoties" ).droppable({
		accept: ".acat",
		hoverClass: "active",
		drop: function( event, ui ) {
			jQuery( this ).find(jQuery(ui.draggable)).addClass( "highlight_new" ).attr("id", "g_"+jQuery(ui.draggable).attr('rel')).removeAttr('style');
			jQuery( this ).find( "p" ).hide();
		}
	});
	jQuery( ".album_categoties .drop" ).live('click',function(){
		var acat_parent = jQuery(this).parent().parent();
		jQuery(this).parent().remove();
		if(!acat_parent.find('.acat').length){
			acat_parent.find('p').show();
		}
	});
	jQuery('.flag-ajax-post').click(function(e){
		var form = jQuery(this).attr('data-form');
		var edata = jQuery(this).dataset();
		edata.form = jQuery('#'+form).serialize()+'&'+jQuery(this).parents('.album').find('.album_categoties').sortable("serialize"); 
		jQuery.post( ajaxurl, edata,
			function( response ) {
				jQuery(e.target).parent().find('.alb_msg').show().html(response).fadeOut(1200);
				if(jQuery(e.target).hasClass('del')) {
					jQuery(e.target).parent().parent().parent().remove();
				}
				if(response == 'Success'){
					jQuery(e.target).parents('div.album:first').find('.acat').removeClass('highlight_new');
					jQuery(e.target).parents('span.album_actions').find('.alb_msg').show().text('OK').fadeOut(1200);
				}
			}
		);
		return false;
	});
});
/*]]>*/
</script>
	<div class="flag-wrap">
		<h2><?php 
        _e('Albums', 'flag');
        ?>
</h2>
		<form method="post" style="width: 658px; float: left;" action="<?php 
        echo admin_url('admin.php?page=flag-manage-gallery');
        ?>
"><?php 
        wp_nonce_field('flag_album');
        ?>
		<p><input type="text" id="album_name" name="album_name" value="" /> &nbsp; <input type="submit" value="<?php 
        _e('Create New Album', 'flag');
        ?>
" class="button-primary" /></p></form>
		<h2><?php 
        _e('Categories', 'flag');
        ?>
</h2>
		<div class="clear"></div>
		<div class="floatholder">
			<div class="albums_table">
<?php 
        $albumlist = $flagdb->find_all_albums();
        $nonce = wp_create_nonce('wpMediaLib');
        if ($albumlist) {
            foreach ($albumlist as $album) {
                ?>
				<div class="album">
					<div class="album_name"><span class="albID"><?php 
                echo $album->id;
                ?>
.</span> <form method="post" id="albName_<?php 
                echo $album->id;
                ?>
" name="albName_<?php 
                echo $album->id;
                ?>
"><input type="text" name="album_name" value="<?php 
                echo esc_html($album->name);
                ?>
" /><input type="hidden" name="album_id" value="<?php 
                echo $album->id;
                ?>
" /></form> <span class="album_actions"><span class="alb_msg"></span>&nbsp;&nbsp;&nbsp;<span class="button del flag-ajax-post" data-action="flag_delete_album" data-_ajax_nonce="<?php 
                echo $nonce;
                ?>
" data-post="<?php 
                echo $album->id;
                ?>
"><?php 
                _e('Delete', 'flag');
                ?>
</span>&nbsp;&nbsp;<span class="album_save flag-ajax-post button-primary" data-action="flag_save_album" data-_ajax_nonce="<?php 
                echo $nonce;
                ?>
" data-form="albName_<?php 
                echo $album->id;
                ?>
"><strong><?php 
                _e('Save', 'flag');
                ?>
</strong></span></span></div>
					<div class="album_categoties">
					<?php 
                $galids = explode(',', $album->categories);
                if ($album->categories) {
                    foreach ($galids as $galid) {
                        $acat = $flagdb->find_gallery($galid);
                        ?>
								
						<div class="acat" id="g_<?php 
                        echo $acat->gid;
                        ?>
"><?php 
                        echo esc_html($acat->title);
                        ?>
<span class="drop">x</span></div>
						<?php 
                    }
                } else {
                    echo '<p style="text-align:center; padding: 7px 0; margin: 0;">' . __('Drag&Drop Categories Here', 'flag') . '</p>';
                }
                ?>
					</div>
				</div>
<?php 
            }
        } else {
            echo '<p style="text-align:center; padding: 20px 0; margin: 0;">' . __('No Albums', 'flag') . '</p>';
        }
        ?>
			</div>
			<div class="all_galleries" id="draggable">
<?php 
        if ($gallerylist) {
            foreach ($gallerylist as $gallery) {
                $gid = $gallery->gid;
                $name = empty($gallery->title) ? $gallery->name : esc_html($gallery->title);
                $author_user = get_userdata((int) $gallery->author);
                if (flagAdmin::can_manage_this_gallery($gallery->author)) {
                    ?>
				<div class="acat" rel="<?php 
                    echo $gid;
                    ?>
"><?php 
                    echo $name;
                    ?>
<span class="drop">x</span></div>
<?php 
                }
            }
        }
        ?>
				
			</div>
		</div>
	</div>
<?php 
    }
    ?>
	<!-- #resize_images -->
	<div id="resize_images" style="display: none;" >
		<form id="form_resize_images" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('flag_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', 'flag');
    ?>
:</strong> 
				</td>
				<td>
					<input type="text" size="5" name="imgWidth" value="<?php 
    echo $flag->options['imgWidth'];
    ?>
" /> x <input type="text" size="5" name="imgHeight" value="<?php 
    echo $flag->options['imgHeight'];
    ?>
" />
					<br /><small><?php 
    _e('Width x height (in pixel). FlAGallery will keep ratio size', 'flag');
    ?>
</small>
				</td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php 
    _e('OK', 'flag');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'flag');
    ?>
&nbsp;" onclick="tb_remove()"/>
		    	</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('flag_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)', 'flag');
    ?>
</th>
				<td><input type="text" size="5" maxlength="5" name="thumbWidth" value="<?php 
    echo $flag->options['thumbWidth'];
    ?>
" /> x <input type="text" size="5" maxlength="5" name="thumbHeight" value="<?php 
    echo $flag->options['thumbHeight'];
    ?>
" />
				<br /><small><?php 
    _e('These values are maximum values ', 'flag');
    ?>
</small></td>
			</tr>
			<tr valign="top">
				<th align="left"><?php 
    _e('Set fix dimension', 'flag');
    ?>
</th>
				<td><input type="checkbox" name="thumbFix" value="1" <?php 
    checked('1', $flag->options['thumbFix']);
    ?>
 />
				<br /><small><?php 
    _e('Ignore the aspect ratio, no portrait thumbnails', 'flag');
    ?>
</small></td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php 
    _e('OK', 'flag');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'flag');
    ?>
&nbsp;" onclick="tb_remove()"/>
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#new_thumbnail -->	

<?php 
}
Ejemplo n.º 3
0
 function widget($args, $instance)
 {
     global $wpdb, $flagdb;
     extract($args);
     $title = apply_filters('widget_title', empty($instance['title']) ? '&nbsp;' : $instance['title'], $instance, $this->id_base);
     $album = $instance['album'];
     $qty = !isset($instance['qty']) || intval($instance['qty']) < 1 ? 1 : intval($instance['qty']);
     $gallerylist = $flagdb->get_album($album);
     $ids = explode(',', $gallerylist);
     $imageList = array();
     foreach ($ids as $id) {
         $galID = (int) $id;
         $status = $wpdb->get_var("SELECT status FROM {$wpdb->flaggallery} WHERE gid={$galID}");
         if (intval($status)) {
             continue;
         }
         if ($instance['type'] == 'random') {
             $imageList[$galID] = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->flaggallery} AS t INNER JOIN {$wpdb->flagpictures} AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 AND t.gid = {$galID} ORDER by rand() LIMIT 0,{$qty}");
         } else {
             $flag_options = get_option('flag_options');
             $order_dir = $flag_options['galSortDir'] == 'DESC' ? 'DESC' : 'ASC';
             if (in_array($flag_options['galSort'], array('sortorder', 'pid', 'filename', 'alttext', 'imagedate', 'hitcounter', 'total_votes', 'rand()'))) {
                 $order_by = 'tt.' . $flag_options['galSort'];
             } else {
                 $order_by = 'tt.sortorder';
             }
             $imageList[$galID] = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->flaggallery} AS t INNER JOIN {$wpdb->flagpictures} AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 AND t.gid = {$galID} ORDER by {$order_by} {$order_dir} LIMIT 0,{$qty}");
         }
     }
     echo $before_widget . $before_title . $title . $after_title;
     echo "\n" . '<div class="flag-widget">' . "\n";
     if (!empty($imageList)) {
         $isMobile = (bool) preg_match('#\\b(ip(hone|od|ad)|android|opera m(ob|in)i|windows (phone|ce)|blackberry|tablet' . '|s(ymbian|eries60|amsung)|p(laybook|alm|rofile/midp|laystation portable)|nokia|fennec|htc[\\-_]' . '|mobile|up\\.browser|[1-4][0-9]{2}x[1-4][0-9]{2})\\b#i', $_SERVER['HTTP_USER_AGENT']);
         if (!$isMobile) {
             $thumbcode = 'class="flag_fancybox"';
         } else {
             $thumbcode = 'class="flag_newbox"';
         }
         $wrapper_r = $instance['width'] / $instance['height'];
         foreach ($imageList as $gallery_) {
             foreach ($gallery_ as $_image) {
                 // get the URL constructor
                 $image = new flagImage($_image);
                 // enable i18n support for alttext and description
                 $alttext = strip_tags(htmlspecialchars(stripslashes(flagGallery::i18n($image->alttext, 'pic_' . $image->pid . '_alttext'))));
                 $description = strip_tags(htmlspecialchars(stripslashes(flagGallery::i18n($image->description, 'pic_' . $image->pid . '_description'))));
                 $thumburl = $image->thumbURL;
                 $thumbinfo = @getimagesize($image->thumbPath);
                 if ($thumbinfo[0] - $instance['width'] < -20) {
                     $thumburl = $image->webimageURL;
                     $thumbpath = $image->webimagePath;
                     if (!file_exists($image->webimagePath)) {
                         $thumburl = $image->imageURL;
                         $thumbpath = $image->imagePath;
                     }
                     $thumbinfo = @getimagesize($thumbpath);
                 }
                 $thumb_r = $thumbinfo[0] / $thumbinfo[1];
                 if ($wrapper_r < $thumb_r) {
                     $orientation = 'flag_thumb_landscape';
                     $style = 'width:auto;height:100%;margin:0 0 0 -' . floor(($instance['height'] * $thumb_r - $instance['width']) / $instance['width'] * 50) . '%;';
                 } else {
                     $orientation = 'flag_thumb_portrait';
                     $style = 'width:100%;height:auto;margin:-' . floor(($instance['width'] / $thumb_r - $instance['height']) / $instance['height'] * 25) . '% 0 0 0;';
                 }
                 $out = '<a href="' . plugins_url() . '/flash-album-gallery/flagframe.php?i=' . $image->galleryid . '&amp;f=' . $instance['skin'] . '&amp;h=' . $instance['fheight'] . '" title="' . $image->title . '" ' . $thumbcode . ' style="overflow:hidden;display:inline-block;text-align:center;width:' . $instance['width'] . 'px;height:' . $instance['height'] . 'px;">';
                 $out .= '<img src="' . $thumburl . '" style="' . $style . '" class="' . $orientation . '" title="' . $alttext . '" alt="' . $description . '" />';
                 echo $out . '</a>' . "\n";
             }
         }
     }
     echo '</div>' . "\n";
     echo '<style type="text/css">.flag_fancybox, .flag_newbox {box-sizing:border-box; border: 1px solid #A9A9A9; margin: 0 2px 2px 0; padding: 0; } .flag_fancybox img, .flag_newbox img {max-width:none;max-height:none;} </style>' . "\n";
     echo '<script type="text/javascript" defer="defer">jQuery(function(){ var fbVar = "' . plugins_url('/', dirname(__FILE__)) . '"; var fbW = ' . $instance['fwidth'] . ', fbH = ' . $instance['fheight'] . '; waitJQ(fbVar,fbW,fbH); });</script>' . "\n";
     echo $after_widget;
 }
Ejemplo n.º 4
0
 /**
  * Get the XML <item> node corresponding to one single image
  *
  * @param object $image
  * @param string $indent
  * @return string
  */
 function get_image_mrss_node($image, $indent = "\t\t")
 {
     $flag_options = get_option('flag_options');
     $title = html_entity_decode(stripslashes($image->alttext));
     $desc = html_entity_decode(stripslashes($image->description));
     $thumbwidth = $flag_options['thumbWidth'];
     $thumbheight = $flag_options['thumbFix'] ? $flag_options['thumbHeight'] : $thumbwidth;
     $out = $indent . "<item>\n";
     $out .= $indent . "\t<title><![CDATA[" . flagGallery::i18n($title) . "]]></title>\n";
     $out .= $indent . "\t<description><![CDATA[" . flagGallery::i18n($desc) . "]]></description>\n";
     $out .= $indent . "\t<media:content url='" . $image->imageURL . "' medium='image' />\n";
     $out .= $indent . "\t<media:title><![CDATA[" . flagGallery::i18n($title) . "]]></media:title>\n";
     $out .= $indent . "\t<media:description><![CDATA[" . flagGallery::i18n($desc) . "]]></media:description>\n";
     $out .= $indent . "\t<media:thumbnail url='" . $image->thumbURL . "' width='" . $thumbwidth . "' height='" . $thumbheight . "' />\n";
     $out .= $indent . "\t<media:copyright><![CDATA[Copyright (c) " . get_option("blogname") . " (" . get_option("siteurl") . ")]]></media:copyright>\n";
     $out .= $indent . "</item>\n";
     return $out;
 }
Ejemplo n.º 5
0
    if (intval($status)) {
        continue;
    }
    if ($galleryID == 0) {
        $thepictures = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->flaggallery} AS t INNER JOIN {$wpdb->flagpictures} AS tt ON t.gid = tt.galleryid WHERE 1=1 {$exclude_clause} ORDER BY tt.{$flag_options['galSort']} {$flag_options['galSortDir']} ");
    } else {
        $thepictures = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->flaggallery} AS t INNER JOIN {$wpdb->flagpictures} AS tt ON t.gid = tt.galleryid WHERE t.gid = '{$galleryID}' {$exclude_clause} ORDER BY tt.{$flag_options['galSort']} {$flag_options['galSortDir']} ");
    }
    if (is_array($thepictures) && count($thepictures)) {
        echo "\t<category id='" . $galleryID . "'>\n";
        echo "\t\t<properties>\n";
        echo "\t\t\t<title>" . esc_html(flagGallery::i18n(stripslashes($thepictures[0]->title))) . "</title>\n";
        echo "\t\t</properties>\n";
        echo "\t\t<items>\n";
        if (is_array($thepictures)) {
            foreach ($thepictures as $picture) {
                echo "\t\t\t<item id='" . $picture->pid . "'>\n";
                echo "\t\t\t\t<thumbnail>" . $siteurl . "/" . $picture->path . "/thumbs/thumbs_" . $picture->filename . "</thumbnail>\n";
                echo "\t\t\t\t<title><![CDATA[" . esc_html(flagGallery::i18n(stripslashes($picture->alttext))) . "]]></title>\n";
                echo "\t\t\t\t<description><![CDATA[" . html_entity_decode(esc_html(flagGallery::i18n(stripslashes($picture->description)))) . "]]></description>\n";
                //echo "				<link>".$picture->link."</link>\n";
                echo "\t\t\t\t<photo>" . $siteurl . "/" . $picture->path . "/" . $picture->filename . "</photo>\n";
                echo "\t\t\t\t<date>" . $picture->imagedate . "</date>\n";
                echo "\t\t\t</item>\n";
            }
        }
        echo "\t\t</items>\n";
        echo "\t</category>\n";
    }
}
echo "</gallery>\n";