Exemplo n.º 1
0
function flag_tune($show_error = true, $skins_reset = false)
{
    /* Move skins outside the plugin folder */
    $flag_options = get_option('flag_options');
    $skins_dir = str_replace("\\", "/", WP_PLUGIN_DIR . '/flagallery-skins/');
    $old_skins_dir = FLAG_ABSPATH . 'skins/';
    $flag_options['skinsDirABS'] = $skins_dir;
    $flag_options['skinsDirURL'] = WP_PLUGIN_URL . '/flagallery-skins/';
    update_option('flag_options', $flag_options);
    if (version_compare(get_option('flagVersion'), '4.25', '<')) {
        $skins_reset = true;
        @unlink($skins_dir . 'banner_default');
        @unlink($skins_dir . 'banner_widget_default');
    }
    $errors = '';
    // check for main folder
    if (!wp_mkdir_p($skins_dir)) {
        $errors .= __('Directory <strong>"', 'flash-album-gallery') . $skins_dir . __('"</strong> doesn\'t exist. Please create first the <strong>"flagallery-skins"</strong> folder!', 'flash-album-gallery') . '<br />';
    } else {
        // check for permission settings, Safe mode limitations are not taken into account.
        if (!is_writeable($skins_dir)) {
            $errors .= __('Directory <strong>"', 'flash-album-gallery') . $skins_dir . __('"</strong> is not writeable!', 'flash-album-gallery') . '<br />';
        } else {
            // Files in flash-album-gallery/skins directory
            $open_old_skins_dir = @opendir($old_skins_dir);
            if ($open_old_skins_dir) {
                while (($file = readdir($open_old_skins_dir)) !== false) {
                    if (substr($file, 0, 1) == '.') {
                        continue;
                    }
                    if (is_dir($old_skins_dir . $file)) {
                        if (is_dir($skins_dir . $file)) {
                            if ($skins_reset) {
                                flagGallery::flagFolderDelete($skins_dir . $file);
                            } else {
                                continue;
                            }
                        }
                        if (!@rename($old_skins_dir . $file, $skins_dir . $file)) {
                            $errors .= sprintf(__('Failed to move files from %1$s to %2$s', 'flash-album-gallery'), '<strong>' . $old_skins_dir . $file . '</strong>', $skins_dir . $file) . '<br />';
                        }
                    }
                }
            }
            @closedir($open_old_skins_dir);
        }
    }
    if ($errors != '') {
        if ($show_error) {
            flagGallery::show_error($errors);
        }
        return false;
    }
    return true;
}
Exemplo n.º 2
0
function flagCreateNewThumb()
{
    global $wpdb;
    // check for correct capability
    if (!is_user_logged_in()) {
        die('-1');
    }
    // check for correct FlAG capability
    if (!current_user_can('FlAG Manage gallery')) {
        die('-1');
    }
    require_once dirname(dirname(__FILE__)) . '/flag-config.php';
    include_once flagGallery::graphic_library();
    $flag_options = get_option('flag_options');
    $id = (int) $_POST['id'];
    $picture = flagdb::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 flag_Thumbnail($picture->imagePath, TRUE);
    $thumb->crop($x, $y, $w, $h);
    if ($flag_options['thumbFix']) {
        if ($thumb->currentDimensions['height'] > $thumb->currentDimensions['width']) {
            $thumb->resize($flag_options['thumbWidth'], 0);
        } else {
            $thumb->resize(0, $flag_options['thumbHeight']);
        }
    } else {
        $thumb->resize($flag_options['thumbWidth'], $flag_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
        flagdb::update_image_meta($picture->pid, array('thumbnail' => $size));
        echo "OK";
    } else {
        header('HTTP/1.1 500 Internal Server Error');
        echo "KO";
    }
    exit;
}
Exemplo 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 = 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;
 }
Exemplo n.º 4
0
/**
 * @author Sergey Pasyuk
 * @copyright 2009
 */
function flag_sortorder($galleryID = 0)
{
    global $wpdb;
    if ($galleryID == 0) {
        return;
    }
    $galleryID = (int) $galleryID;
    if (isset($_POST['updateSortorder'])) {
        check_admin_referer('flag_updatesortorder');
        // get variable new sortorder
        $neworder = array();
        foreach ($_POST as $id) {
            $neworder[] = (int) $id;
        }
        $sortindex = 1;
        foreach ($neworder as $pic_id) {
            $wpdb->query("UPDATE {$wpdb->flagpictures} SET sortorder = '{$sortindex}' WHERE pid = {$pic_id}");
            $sortindex++;
        }
        $firstImage = $wpdb->get_var("SELECT pid FROM {$wpdb->flagpictures} WHERE galleryid = '{$galleryID}' ORDER by pid DESC limit 0,1");
        if ($firstImage) {
            $wpdb->query("UPDATE {$wpdb->flaggallery} SET previewpic = '{$firstImage}' WHERE gid = '{$galleryID}'");
        }
        flagGallery::show_message(__('Sort order changed', 'flag'));
    }
    // get gallery values
    $act_gallery = $wpdb->get_row("SELECT * FROM {$wpdb->flaggallery} WHERE gid = '{$galleryID}' ");
    // set gallery url
    $act_gallery_url = get_option('siteurl') . "/" . $act_gallery->path . "/";
    $act_thumbnail_url = get_option('siteurl') . "/" . $act_gallery->path . flagGallery::create_thumbnail_folder($act_gallery->path, FALSE);
    // look for presort args
    $picturelist = $wpdb->get_results("SELECT * FROM {$wpdb->flagpictures} WHERE galleryid = '{$galleryID}' ORDER BY sortorder");
    //this is the url without any presort variable
    $base_url = admin_url() . 'admin.php?page=flag-manage-gallery&amp;mode=sort&amp;gid=' . $galleryID;
    ?>
<script type="text/javascript" src="<?php 
    echo FLAG_URLPATH;
    ?>
admin/js/jquery.tablednd_0_5.js"></script>
<script type="text/javascript" src="<?php 
    echo FLAG_URLPATH;
    ?>
admin/js/jquery.tablesorter.js"></script>
<div class="flag-wrap">
			<h2><?php 
    _e('Sort Gallery', 'flag');
    ?>
</h2>

	<form class="alignright" method="POST" action="<?php 
    echo admin_url() . 'admin.php?page=flag-manage-gallery&amp;mode=edit&amp;gid=' . $galleryID;
    ?>
" accept-charset="utf-8">
		<div class="alignright tablenav" style="margin-bottom: -36px;">
			<input class="button-secondary action" type="submit" name="backToGallery" value="<?php 
    _e('Back to gallery', 'flag');
    ?>
" />
		</div>
	</form>
	<form id="sortGallery" method="POST" action="<?php 
    echo $base_url;
    ?>
" accept-charset="utf-8">
		<div class="alignleft tablenav">
			<?php 
    wp_nonce_field('flag_updatesortorder');
    ?>
			<input class="button-primary action" type="submit" name="updateSortorder" value="<?php 
    _e('Update Sort Order', 'flag');
    ?>
" />
		</div>
		<br clear="all" />
<script type="text/javascript">
/*<![CDATA[*/
jQuery(document).ready(function($) {
    // Initialise the table
    jQuery("#listimages").tableDnD({
      onDragClass: "myDragClass",
	  	onDrop: function() {
				jQuery("#listimages tr:even").addClass('alternate');
				jQuery("#listimages tr:odd").removeClass('alternate');
      }
    });
		$("#flag-listitems").tablesorter({ 
        // pass the headers argument and assing a object 
        headers: { 
            // assign the secound column (we start counting zero) 
            1: { 
                // disable it by setting the property sorter to false 
                sorter: false 
            }
        } 
    });
		$("#flag-listitems").bind("sortEnd",function() { 
				jQuery("#listimages tr:even").addClass('alternate');
				jQuery("#listimages tr:odd").removeClass('alternate');
    }); 

});
/*]]>*/
</script>
<table id="flag-listitems" class="widefat fixed flag-table" cellspacing="0" >

	<thead>
	<tr>
		<th class="header" width="30px"><p style="margin-right:-10px;"><?php 
    _e('ID', 'flag');
    ?>
</p></th>
		<th width="120"><p><?php 
    _e('Thumb', 'flag');
    ?>
</p></th>
		<th class="header"><p><?php 
    _e('Filename', 'flag');
    ?>
</p></th>
		<th class="header" width="130"><p><?php 
    _e('Date', 'flag');
    ?>
</p></th>
		<th class="header"><p><?php 
    _e('Alt &amp; Title Text', 'flag');
    ?>
</p></th>
	</tr>
	</thead>
	<tfoot>
	<tr>
		<th><p><?php 
    _e('ID', 'flag');
    ?>
</p></th>
		<th><p><?php 
    _e('Thumb', 'flag');
    ?>
</p></th>
		<th><p><?php 
    _e('Filename', 'flag');
    ?>
</p></th>
		<th><p><?php 
    _e('Date', 'flag');
    ?>
</p></th>
		<th><p><?php 
    _e('Alt &amp; Title Text', 'flag');
    ?>
</p></th>
	</tr>
	</tfoot>
	<tbody id="listimages">
<?php 
    if ($picturelist) {
        $alternate = '';
        foreach ($picturelist as $picture) {
            $pid = (int) $picture->pid;
            $alternate = $alternate == 'alternate' ? '' : 'alternate';
            $date = mysql2date(get_option('date_format'), $picture->imagedate);
            $time = mysql2date(get_option('time_format'), $picture->imagedate);
            ?>
		<tr id="picture-<?php 
            echo $pid;
            ?>
" class="<?php 
            echo $alternate;
            ?>
 iedit"  valign="top">
				<td><strong><?php 
            echo $pid;
            ?>
</strong><input type="hidden" name="sortpid-<?php 
            echo $pid;
            ?>
" value="<?php 
            echo $pid;
            ?>
" /></td>
				<td><a href="<?php 
            echo $act_gallery_url . $picture->filename;
            ?>
" class="thickbox" title="<?php 
            echo $picture->filename;
            ?>
">
					<img class="thumb" src="<?php 
            echo $act_thumbnail_url . "thumbs_" . $picture->filename;
            ?>
" style="width:80px; height:auto;" id="thumb-<?php 
            echo $pid;
            ?>
" />
				</a></td>
				<td><?php 
            echo $picture->filename;
            ?>
</td>
				<td><?php 
            echo $date;
            ?>
</td>
				<td><?php 
            echo esc_html(stripslashes($picture->alttext));
            ?>
</td>
		</tr>
		<?php 
        }
    } else {
        echo '<tr><td colspan="5" align="center"><strong>' . __('No entries found', 'flag') . '</strong></td></tr>';
    }
    ?>
	
		</tbody>
	</table>
	<p class="actions"><input type="submit" class="button-primary action"  name="updateSortorder" onclick="saveImageOrder()" value="<?php 
    _e('Update Sort Order', 'flag');
    ?>
" /></p>
</form>	
<br class="clear"/>
</div><!-- /#wrap -->

<?php 
}
Exemplo n.º 5
0
function flag_admin_add_gallery()
{
    global $wpdb, $flagdb, $flag;
    // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
    $filepath = admin_url() . 'admin.php?page=' . urlencode($_GET['page']);
    // check for the max image size
    $maxsize = flagGallery::check_memory_limit();
    $defaultpath = $flag->options['galleryPath'];
    if ($_POST['addgallery']) {
        check_admin_referer('flag_addgallery');
        $newgallery = trim($_POST['galleryname']);
        if (!empty($newgallery)) {
            flagAdmin::create_gallery($newgallery, $defaultpath);
        }
    }
    if ($_POST['uploadimage']) {
        check_admin_referer('flag_upload');
        if ($_FILES['MF__F_0_0']['error'] == 0) {
            flagAdmin::upload_images();
        } else {
            flagGallery::show_error(__('Upload failed!', 'flag'));
        }
    }
    if ($_POST['importfolder']) {
        check_admin_referer('flag_addgallery');
        $galleryfolder = $_POST['galleryfolder'];
        if (!empty($galleryfolder) and $defaultpath != $galleryfolder and false === strpos($galleryfolder, '..')) {
            flagAdmin::import_gallery($galleryfolder);
        }
    }
    if (isset($_POST['disable_flash'])) {
        check_admin_referer('flag_upload');
        $flag->options['swfUpload'] = false;
        update_option('flag_options', $flag->options);
    }
    if (isset($_POST['enable_flash'])) {
        check_admin_referer('flag_upload');
        $flag->options['swfUpload'] = true;
        update_option('flag_options', $flag->options);
    }
    //get all galleries (after we added new ones)
    $gallerylist = $flagdb->find_all_galleries($flag->options['albSort'], $flag->options['albSortDir']);
    ?>

	
<?php 
    if (!IS_WPMU || current_user_can('FlAG Import folder')) {
        ?>

	<link rel="stylesheet" type="text/css" href="<?php 
        echo FLAG_URLPATH;
        ?>
admin/js/jqueryFileTree/jqueryFileTree.css" />
	<script type="text/javascript" src="<?php 
        echo FLAG_URLPATH;
        ?>
admin/js/jqueryFileTree/jqueryFileTree.js"></script>
	<script type="text/javascript">
	/* <![CDATA[ */
		  jQuery(function() {
		    jQuery("span.browsefiles").show().click(function(){
			    jQuery("#file_browser").fileTree({
			      script: "admin-ajax.php?action=flag_file_browser&nonce=<?php 
        echo wp_create_nonce('flag-ajax');
        ?>
",
			      root: jQuery("#galleryfolder").val()
			    }, function(file) {
			        //var path = file.replace("<?php 
        echo WINABSPATH;
        ?>
", "");
			        jQuery("#galleryfolder").val(file);
			    });

		    	jQuery("#file_browser").show("slide");
		    });
		  });
	/* ]]> */
	</script>
<?php 
    }
    ?>

	<div id="slider" class="wrap">
	
		<ul id="tabs" class="tabs">
			<li class="selected"><a href="#" rel="addgallery"><?php 
    _e('Add new gallery', 'flag');
    ?>
</a></li>
			<li><a href="#" rel="uploadimage"><?php 
    _e('Upload Images', 'flag');
    ?>
</a></li>
<?php 
    if (!IS_WPMU || current_user_can('FlAG Import folder')) {
        ?>

			<li><a href="#" rel="importfolder"><?php 
        _e('Import image folder', 'flag');
        ?>
</a></li>
<?php 
    }
    ?>

		</ul>

		<!-- create gallery -->
		<div id="addgallery" class="cptab">
			<h2><?php 
    _e('Create a new gallery', 'flag');
    ?>
</h2>
			<form name="addgallery" id="addgallery_form" method="POST" action="<?php 
    echo $filepath;
    ?>
" accept-charset="utf-8" >
			<?php 
    wp_nonce_field('flag_addgallery');
    ?>

				<table class="form-table" style="width: auto;"> 
				<tr>
					<th scope="col" colspan="2" style="padding-bottom: 0;"><strong><?php 
    _e('New Gallery', 'flag');
    ?>
</strong></th> 
				</tr>
				<tr valign="top"> 
					<td><input type="text" size="65" name="galleryname" value="" /><br />
					<?php 
    if (!IS_WPMU) {
        ?>

						<?php 
        _e('Create a new , empty gallery below the folder', 'flag');
        ?>
  <strong><?php 
        echo $defaultpath;
        ?>
</strong><br />
					<?php 
    }
    ?>

						<i>( <?php 
    _e('Allowed characters for file and folder names are', 'flag');
    ?>
: a-z, A-Z, 0-9, -, _ )</i></td>
					<?php 
    do_action('flag_add_new_gallery_form');
    ?>

					<td><div class="submit" style="margin: 0; padding: 0;"><input class="button-primary" type="submit" name= "addgallery" value="<?php 
    _e('Add gallery', 'flag');
    ?>
"/></div></td>
				</tr>
				</table>
				<p>&nbsp;</p>
			</form>
		</div>
		<!-- upload images -->
		<div id="uploadimage" class="cptab">
			<h2><?php 
    _e('Upload images', 'flag');
    ?>
</h2>
			<form name="uploadimage" id="gmUpload" method="POST" enctype="multipart/form-data" action="<?php 
    echo $filepath;
    ?>
" accept-charset="utf-8" >
				<?php 
    wp_nonce_field('flag_upload');
    ?>

				<table class="form-table">
				<tr valign="top">
					<td style="width: 216px;"><label for="galleryselect"><?php 
    _e('in to', 'flag');
    ?>
</label>
						<select name="galleryselect" id="galleryselect" style="width: 200px">
							<option value="0" ><?php 
    _e('Choose gallery', 'flag');
    ?>
</option>
							<?php 
    $ingallery = isset($_GET['gid']) ? (int) $_GET['gid'] : '';
    foreach ($gallerylist as $gallery) {
        if (!flagAdmin::can_manage_this_gallery($gallery->author)) {
            continue;
        }
        $name = empty($gallery->title) ? $gallery->name : esc_html(stripslashes($gallery->title));
        if ($flag->options['albSort'] == 'gid') {
            $name = $gallery->gid . ' - ' . $name;
        }
        if ($flag->options['albSort'] == 'title') {
            $name = $name . ' (' . $gallery->gid . ')';
        }
        $sel = $ingallery == $gallery->gid ? 'selected="selected" ' : '';
        echo '<option ' . $sel . 'value="' . $gallery->gid . '" >' . $name . '</option>' . "\n";
    }
    ?>

						</select>
						<?php 
    echo $maxsize;
    ?>

						<br /><?php 
    if (IS_WPMU && flagGallery::flag_wpmu_enable_function('wpmuQuotaCheck')) {
        display_space_usage();
    }
    ?>


						<div class="submit">
					<span class="useflashupload">
					<?php 
    if ($flag->options['swfUpload']) {
        ?>

						<input type="submit" name="disable_flash" id="disable_flash" title="<?php 
        _e('The batch upload via Plupload, disable it if you have problems', 'flag');
        ?>
" value="<?php 
        _e('Switch to Browser Upload', 'flag');
        ?>
" />
					<?php 
    } else {
        ?>

						<input type="submit" name="enable_flash" id="enable_flash" title="<?php 
        _e('Upload multiple files at once by ctrl/shift-selecting in dialog', 'flag');
        ?>
" value="<?php 
        _e('Switch to Plupload based Upload', 'flag');
        ?>
" />
					<?php 
    }
    ?>

					</span>
							<div class="clear"></div>
						</div>

					</td>

					<td><div id="pluploadUploader">
					<?php 
    if (!$flag->options['swfUpload']) {
        ?>

						<strong><?php 
        _e('Upload image(s):', 'flag');
        ?>
</strong><br>
						<input type="file" name="imagefiles[]" id="imagefiles" size="35" class="imagefiles"/></div>
						<span id="choosegalfirst">
							<input class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php 
        _e('Upload images', 'flag');
        ?>
" />
							<span class="disabledbut" style="display: none;"></span>
						</span>
					<?php 
    }
    ?>

					</td>
				</tr>
				</table>
				<div id="pl-message"></div>
			</form>
<?php 
    if ($flag->options['swfUpload']) {
        ?>

	<script type="text/javascript">
		// Convert divs to queue widgets when the DOM is ready
		jQuery(function () {
			var files_remaining = 0;
			jQuery("#pluploadUploader").pluploadQueue({
				// General settings
				runtimes        		: 'flash,html5,html4',
				url             		: '<?php 
        echo str_replace('&#038;', '&', wp_nonce_url(plugins_url(FLAGFOLDER . '/admin/upload.php'), 'flag_upload'));
        ?>
',
				multipart       		: true,
				multipart_params		: { postData: ''},
				max_file_size					: '<?php 
        echo min(floor(wp_max_upload_size() * 0.99 / 1024 / 1024) - 1, 8);
        ?>
Mb',
				unique_names    		: false,
				rename          		: true,
				urlstream_upload	: true,

				// Resize images on clientside if we can
				//resize 						: {width : 150, height : 150, quality : 90},

				// Specify what files to browse for
				filters         		: [{title: "Images", extensions: "jpg,gif,png"}],

				// Flash settings
				flash_swf_url   		: '<?php 
        echo plugins_url(FLAGFOLDER . '/admin/js/plupload/plupload.flash.swf');
        ?>
',

				// PreInit events, bound before any internal events
				preinit : {
					Init: function(up, info) {
						console.log('[Init]', 'Info:', info, 'Features:', up.features);
					},

					UploadFile: function(up, file) {
						console.log('[UploadFile]', file);
						up.settings.multipart_params = { galleryselect: jQuery('#galleryselect').val(), last: files_remaining };
						files_remaining--;
						// You can override settings before the file is uploaded
						// up.settings.url = 'upload.php?id=' + file.id;
						// up.settings.multipart_params = {param1 : 'value1', param2 : 'value2'};
					}
				},

				// Post init events, bound after the internal events
				init : {
					Refresh: function(up) {
						// Called when upload shim is moved
						console.log('[Refresh]');
						files_remaining = up.files.length;
						if(jQuery("#galleryselect").val() == 0) {
							jQuery(".plupload_start").addClass("plupload_disabled");
						}
					},

					StateChanged: function(up) {
						// Called when the state of the queue is changed
						console.log('[StateChanged]', up.state == plupload.STARTED ? "STARTED" : "STOPPED");
					},

					QueueChanged: function(up) {
						// Called when the files in queue are changed by adding/removing files
						console.log('[QueueChanged]');
					},

					UploadProgress: function(up, file) {
						// Called while a file is being uploaded
						console.log('[UploadProgress]', 'File:', file, "Total:", up.total);
					},

					FileUploaded: function(up, file, info) {
						// Called when a file has finished uploading
						console.log('[FileUploaded] File:', file, "Info:", info);
						if (info.response){
							file.status = plupload.FAILED;
							jQuery('<div/>').addClass('error').html('<span><u><em>'+file.name+':</em></u> '+info.response+'</span>').appendTo('#pl-message');
						}
					},

					Error: function(up, args) {
						// Called when a error has occured
						jQuery('<div/>').addClass('error').html('<span><u><em>'+args.file.name+':</em></u> '+args.message+' '+args.status+'</span>').appendTo('#pl-message');
						console.log('[error] ', args);
					},

					UploadComplete: function(up, file) {
						console.log('[UploadComplete]');
						jQuery(".plupload_buttons").css("display", "inline");
						jQuery(".plupload_upload_status").css("display", "inline");
						jQuery(".plupload_start").addClass("plupload_disabled");
						jQuery("#gmUpload").one("mousedown", ".plupload_add", function () {
							up.splice();
							up.trigger('Refresh');
							//up.refresh();
						});
						jQuery('<div/>').addClass('success').html('<?php 
        _e('Done!', 'flag');
        ?>
 <a href="<?php 
        echo wp_nonce_url($flag->manage_page->base_page . "&mode=edit", 'flag_editgallery');
        ?>
&gid=' + jQuery("#galleryselect").val() + '">Open Gallery</a>').appendTo('#pl-message');
					}
				}
			});
			jQuery("#gmUpload").on('click','.plupload_disabled',function(){
				if(files_remaining){
					alert("Choose gallery, please.")
				}
			});
			jQuery("#galleryselect").change(function () {
				if(jQuery(this).val() == 0) {
					jQuery(".plupload_start").addClass('plupload_disabled');
				} else {
					if(files_remaining){
						jQuery(".plupload_start").removeClass('plupload_disabled');
					}
				}
			});

		});
	</script>
<?php 
    } else {
        ?>

	<!-- MultiFile script -->
	<script type="text/javascript">
		/* <![CDATA[ */
		jQuery(document).ready(function(){
			jQuery('#imagefiles').MultiFile({
				STRING: {
					remove:'<?php 
        _e('remove', 'flag');
        ?>
'
				}
			});

			if(jQuery("#galleryselect").val() == 0) {
				jQuery("#choosegalfirst").animate({opacity: "0.5"}, 600);
				jQuery("#choosegalfirst .disabledbut").show();
			}
			jQuery("#choosegalfirst .disabledbut").click(function () {
				alert("Choose gallery, please.")
			});
			jQuery("#galleryselect").change(function () {
				if(jQuery(this).val() == 0) {
					jQuery("#choosegalfirst .disabledbut").show();
					jQuery("#choosegalfirst").animate({opacity: "0.5"}, 600);
				} else {
					jQuery("#choosegalfirst .disabledbut").hide();
					jQuery("#choosegalfirst").animate({opacity: "1"}, 600);
				}
			});
		});
		/* ]]> */
	</script>

<?php 
    }
    ?>

		</div>
<?php 
    if (!IS_WPMU || current_user_can('FlAG Import folder')) {
        ?>

		<!-- import folder -->
		<div id="importfolder" class="cptab">
		<h2><?php 
        _e('Import image folder', 'flag');
        ?>
</h2>
			<form name="importfolder" id="importfolder_form" method="POST" action="<?php 
        echo $filepath;
        ?>
" accept-charset="utf-8" >
			<?php 
        wp_nonce_field('flag_addgallery');
        ?>

				<table class="form-table">
				<tr valign="top"> 
					<th scope="row"><?php 
        _e('Import from Server path:', 'flag');
        ?>
</th> 
					<td><input type="text" size="35" id="galleryfolder" name="galleryfolder" value="<?php 
        echo $defaultpath;
        ?>
" /><span class="browsefiles button" style="display:none"><?php 
        _e('Browse...', "flag");
        ?>
</span>
					<div id="file_browser"></div>
					<div><?php 
        echo $maxsize;
        ?>

					<?php 
        if (SAFE_MODE) {
            ?>
<br /><?php 
            _e(' Please note : For safe-mode = ON you need to add the subfolder thumbs manually', 'flag');
        }
        ?>
</div></td> 
				</tr>
				</table>
				<div class="submit"><input class="button-primary" type="submit" name="importfolder" value="<?php 
        _e('Import folder', 'flag');
        ?>
"/></div>
			</form>
		</div>
<?php 
    }
    ?>


<script type="text/javascript">
	var cptabs=new ddtabcontent("tabs");
	cptabs.setpersist(true);
	cptabs.setselectedClassTarget("linkparent");
	cptabs.init();
</script>
</div>
<?php 
}
Exemplo n.º 6
0
                 die('{"status":"thumb_error: ' . $thumb . '"}');
             }
         } else {
             @unlink($file);
             fclose($out);
             die('{"status":"fwrite_error"}');
         }
         fclose($out);
     } else {
         die('{"status":"fopen_error"}');
     }
 }
 // new app
 if (isset($_POST['account']) && isset($_FILES['userfile']['name'])) {
     $path = $wpdb->get_var("SELECT path FROM {$wpdb->flaggallery} WHERE gid = {$gid}");
     $filepart = flagGallery::fileinfo($_FILES['userfile']['name']);
     $filename = $filepart['basename'];
     $file = ABSPATH . trailingslashit($path) . $filename;
     // check if this filename already exist
     $i = 0;
     while (file_exists($file)) {
         $filename = sanitize_title($filepart['filename']) . '_' . $i++ . '.' . $filepart['extension'];
     }
     $file = ABSPATH . trailingslashit($path) . $filename;
     // Open temp file
     if (@move_uploaded_file($_FILES['userfile']['tmp_name'], $file)) {
         $alttext = esc_sql($account->alttext);
         $description = esc_sql($account->description);
         $exclude = intval($account->exclude);
         $location = esc_sql($account->location);
         $wpdb->query("INSERT INTO {$wpdb->flagpictures} (galleryid, filename, alttext, description, exclude, location) VALUES ('{$gid}', '{$filename}', '{$alttext}', '{$description}', '{$exclude}', '{$location}')");
Exemplo n.º 7
0
function flag_banner_controler()
{
    $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 'main';
    if (isset($_POST['importfolder']) && $_POST['importfolder']) {
        check_admin_referer('flag_addbanner');
        $bannerfolder = $_POST['bannerfolder'];
        if (!empty($bannerfolder) and false === strpos($bannerfolder, '..')) {
            $crunch_list = flagAdmin::import_banner($bannerfolder);
            $mode = 'import';
        }
    }
    $action = isset($_REQUEST['bulkaction']) ? $_REQUEST['bulkaction'] : false;
    if ($action == 'no_action') {
        $action = false;
    }
    switch ($mode) {
        case 'sort':
            check_admin_referer('flag_sort');
            include_once dirname(__FILE__) . '/banner-sort.php';
            flag_b_playlist_order();
            break;
        case 'edit':
            $file = sanitize_flagname($_GET['playlist']);
            if (isset($_POST['updatePlaylist'])) {
                check_admin_referer('flag_update');
                $title = esc_html($_POST['playlist_title']);
                $descr = esc_html($_POST['playlist_descr']);
                $data = array();
                foreach ($_POST['item_a'] as $item_id => $item) {
                    if ($action == 'delete_items' && in_array($item_id, $_POST['doaction'])) {
                        continue;
                    }
                    $data[] = $item_id;
                }
                flagGallery::flagSaveWpMedia();
                flagSave_bPlaylist($title, $descr, $data, $file);
            }
            if (isset($_POST['updatePlaylistSkin'])) {
                check_admin_referer('flag_update');
                flagSave_bPlaylistSkin($file);
            }
            include_once dirname(__FILE__) . '/manage-banner.php';
            flag_b_playlist_edit($file);
            break;
        case 'save':
            if (isset($_POST['items_array'])) {
                check_admin_referer('flag_update');
                $title = esc_html($_POST['playlist_title']);
                $descr = esc_html($_POST['playlist_descr']);
                $data = $_POST['items_array'];
                $file = isset($_REQUEST['playlist']) ? sanitize_flagname($_REQUEST['playlist']) : false;
                flagGallery::flagSaveWpMedia();
                flagSave_bPlaylist($title, $descr, $data, $file);
            }
            if (isset($_GET['playlist'])) {
                include_once dirname(__FILE__) . '/manage-banner.php';
                flag_b_playlist_edit();
            } else {
                flag_created_b_playlists();
                flag_banner_wp_media_lib();
            }
            break;
        case 'add':
            check_admin_referer('flag_add');
            if (isset($_POST['items']) && isset($_GET['playlist'])) {
                $added = $_POST['items'];
            } elseif (isset($_GET['playlist'])) {
                $added = $_COOKIE['bannerboxplaylist_' . sanitize_flagname($_GET['playlist'])];
            } else {
                $added = false;
            }
            flag_banner_wp_media_lib($added);
            break;
        case 'delete':
            check_admin_referer('flag_delete');
            flag_b_playlist_delete(sanitize_flagname($_GET['playlist']));
        case 'import':
            flag_crunch($crunch_list);
        case 'main':
            if (isset($_POST['updateMedia'])) {
                check_admin_referer('flag_update');
                flagGallery::flagSaveWpMedia();
                flagGallery::show_message(__('Media updated', 'flag'));
            }
        default:
            flag_created_b_playlists();
            flag_banner_wp_media_lib();
            break;
    }
}
Exemplo n.º 8
0
/**
 * Show the Setup Box and some info for Flash Album Gallery
 * 
 * @return void
 */
function flag_overview_setup()
{
    global $flag;
    if (isset($_POST['resetdefault'])) {
        check_admin_referer('flag_uninstall');
        include_once dirname(__FILE__) . '/flag_install.php';
        include_once dirname(__FILE__) . '/tuning.php';
        flag_default_options();
        flag_tune(true, true);
        $flag->define_constant();
        $flag->load_options();
        flagGallery::show_message(__('Reset all settings to default parameter', 'flag'));
    }
    if (isset($_POST['uninstall'])) {
        check_admin_referer('flag_uninstall');
        include_once dirname(__FILE__) . '/flag_install.php';
        flag_uninstall();
        flagGallery::show_message(__('Uninstall sucessful ! Now delete the plugin and enjoy your life ! Good luck !', 'flag'));
    }
    ?>
		<div class="submitbox" id="submitpost">
			<div id="minor-publishing">
				<div id="misc-publishing-actions">
					<div class="misc-pub-section">
						<span id="plugin-home" class="icon">
							<strong><a href="http://codeasily.com/wordpress-plugins/flag/" style="text-decoration: none;"><?php 
    _e('Plugin Home', 'flag');
    ?>
</a></strong>
						</span>
					</div>
					<div class="misc-pub-section">
						<span id="plugin-comments" class="icon">
							<a href="http://codeasily.com/community/forum/flagallery-wordpress-plugin/" style="text-decoration: none;"><?php 
    _e('Plugin Forum', 'flag');
    ?>
</a>
						</span>
					</div>
					<div class="misc-pub-section">
						<span id="rate-plugin" class="icon">
							<a href="http://wordpress.org/extend/plugins/flash-album-gallery/" style="text-decoration: none;"><?php 
    _e('Rate Plugin', 'flag');
    ?>
</a>
						</span>
					</div>
					<div class="misc-pub-section curtime misc-pub-section-last">
						<span id="contact-me" class="icon">
							<a href="http://codeasily.com/support/contact/" style="text-decoration: none;"><?php 
    _e('Contact Me', 'flag');
    ?>
</a>
						</span>
					</div>
				</div>
			</div>
		</div>
	<?php 
    if (!IS_WPMU || flag_wpmu_site_admin()) {
        ?>
	<div id="major-publishing-actions">
	<form id="resetsettings" name="resetsettings" method="post">
		<?php 
        wp_nonce_field('flag_uninstall');
        ?>
			<div id="save-action" class="alignleft">
				<input class="button" id="save-post" type="submit" name="resetdefault" value="<?php 
        _e('Reset settings', 'flag');
        ?>
" onclick="javascript:check=confirm('<?php 
        _e('Reset all options to default settings ?\\n\\nChoose [Cancel] to Stop, [OK] to proceed.\\n', 'flag');
        ?>
');if(check==false) return false;" />
			</div>
			<div id="preview-action" class="alignright">
				<input type="submit" name="uninstall" class="button delete" value="<?php 
        _e('Uninstall plugin', 'flag');
        ?>
" onclick="javascript:check=confirm('<?php 
        _e('You are about to Uninstall this plugin from WordPress.\\nThis action is not reversible.\\n\\nChoose [Cancel] to Stop, [OK] to Uninstall.\\n', 'flag');
        ?>
');if(check==false) return false;" />
			</div>
			<br class="clear" />
	</form>
	</div>
	<?php 
    }
    ?>

<?php 
}
Exemplo n.º 9
0
 static function saveFile($sName, $sContent, $mode = 'w+')
 {
     if (!($dFile = fopen($sName, $mode))) {
         flagGallery::show_error(__("Can't create/open file '", "flag") . $sName . "'.");
         exit;
     }
     flock($dFile, LOCK_EX);
     ftruncate($dFile, 0);
     if ($result = fwrite($dFile, $sContent) === FALSE) {
         flagGallery::show_error(__("Can't write data to file '", "flag") . $sName . "'.");
         exit;
     }
     fflush($dFile);
     flock($dFile, LOCK_UN);
     fclose($dFile);
     return $result;
 }
Exemplo n.º 10
0
    case 'w':
        $stype = 'widget';
        $new_skins = __('New Widget Skins', 'flag');
        break;
    default:
        $stype = 'gallery';
        $new_skins = __('New Photo Skins', 'flag');
        break;
}
if (isset($_GET['skins_refresh'])) {
    check_admin_referer('skins_refresh');
    // upgrade plugin
    require_once FLAG_ABSPATH . 'admin/tuning.php';
    $ok = flag_tune();
    if ($ok) {
        flagGallery::show_message(__('Skins refreshed successfully', 'flag'));
    }
}
?>

<div id="slider" class="wrap">
	<ul id="tabs" class="tabs">
<?php 
if (current_user_can('FlAG Add skins')) {
    ?>

		<li class="selected"><a href="#" rel="addskin"><?php 
    _e('Add new skin', 'flag');
    ?>
</a></li>
<?php 
Exemplo n.º 11
0
if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
    die('You are not allowed to call this page directly.');
}
// check for correct capability
if (!is_user_logged_in()) {
    die('-1');
}
// check for correct FlAG capability
if (!current_user_can('FlAG iFrame page')) {
    die('-1');
}
if (isset($_POST['copy_file'])) {
    if (copy(FLAG_ABSPATH . 'flagframe.php', ABSPATH . 'flagframe.php')) {
        flagGallery::show_message(__('Success', 'flash-album-gallery'));
    } else {
        flagGallery::show_error(__('Failure', 'flash-album-gallery'));
    }
}
global $flag, $flagdb;
require_once dirname(__FILE__) . '/get_skin.php';
require_once dirname(__FILE__) . '/playlist.functions.php';
require_once dirname(__FILE__) . '/video.functions.php';
require_once dirname(__FILE__) . '/banner.functions.php';
$i_skins = get_skins();
$all_m_playlists = get_playlists();
$all_v_playlists = get_v_playlists();
$all_b_playlists = get_b_playlists();
$fb_url = plugins_url() . '/flash-album-gallery/flagframe.php';
if (file_exists(ABSPATH . 'flagframe.php')) {
    $fb_url = home_url() . '/flagframe.php';
}
Exemplo n.º 12
0
function flag_admin_add_gallery()
{
    global $wpdb, $flagdb, $flag;
    // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
    $filepath = admin_url() . 'admin.php?page=' . urlencode($_GET['page']);
    // check for the max image size
    $maxsize = flagGallery::check_memory_limit();
    $defaultpath = $flag->options['galleryPath'];
    if ($_POST['addgallery']) {
        check_admin_referer('flag_addgallery');
        $newgallery = trim($_POST['galleryname']);
        if (!empty($newgallery)) {
            flagAdmin::create_gallery($newgallery, $defaultpath);
        }
    }
    if ($_POST['uploadimage']) {
        check_admin_referer('flag_upload');
        $flag->options['thumbWidth'] = intval($_POST['thumbWidth']) ? intval($_POST['thumbWidth']) : 100;
        $flag->options['thumbHeight'] = intval($_POST['thumbHeight']) ? intval($_POST['thumbHeight']) : 100;
        $flag->options['thumbFix'] = isset($_POST['thumbFix']) ? 1 : 0;
        update_option('flag_options', $flag->options);
        if ($_FILES['MF__F_0_0']['error'] == 0) {
            flagAdmin::upload_images();
        } else {
            flagGallery::show_error(__('Upload failed!', 'flag'));
        }
    }
    if ($_POST['importfolder']) {
        check_admin_referer('flag_addgallery');
        $galleryfolder = $_POST['galleryfolder'];
        if (!empty($galleryfolder) and $defaultpath != $galleryfolder and false === strpos($galleryfolder, '..')) {
            flagAdmin::import_gallery($galleryfolder);
        }
    }
    if (isset($_POST['disable_flash'])) {
        check_admin_referer('flag_upload');
        $flag->options['swfUpload'] = false;
        update_option('flag_options', $flag->options);
    }
    if (isset($_POST['enable_flash'])) {
        check_admin_referer('flag_upload');
        $flag->options['swfUpload'] = true;
        update_option('flag_options', $flag->options);
    }
    //get all galleries (after we added new ones)
    $gallerylist = $flagdb->find_all_galleries($flag->options['albSort'], $flag->options['albSortDir'], false, 0, 0, 0, true);
    ?>

	<?php 
    if (!IS_WPMU || current_user_can('FlAG Import folder')) {
        ?>
		<link rel="stylesheet" type="text/css" href="<?php 
        echo FLAG_URLPATH;
        ?>
admin/js/jqueryFileTree/jqueryFileTree.css"/>
		<script type="text/javascript" src="<?php 
        echo FLAG_URLPATH;
        ?>
admin/js/jqueryFileTree/jqueryFileTree.js"></script>
		<script type="text/javascript">
			/* <![CDATA[ */
			jQuery(function(){
				jQuery("span.browsefiles").show().click(function(){
					jQuery("#file_browser").fileTree({
						script: "admin-ajax.php?action=flag_file_browser&nonce=<?php 
        echo wp_create_nonce('flag-ajax');
        ?>
",
						root: jQuery("#galleryfolder").val()
					}, function(file){
						//var path = file.replace("<?php 
        echo WINABSPATH;
        ?>
", "");
						jQuery("#galleryfolder").val(file);
					});

					jQuery("#file_browser").show("slide");
				});
			});
			/* ]]> */
		</script>
	<?php 
    }
    ?>
	<div id="slider" class="flag-wrap">

		<ul id="tabs" class="tabs">
			<li class="selected"><a href="#" rel="addgallery"><?php 
    _e('Add new gallery', 'flag');
    ?>
</a></li>
			<li><a href="#" rel="uploadimage"><?php 
    _e('Upload Images', 'flag');
    ?>
</a></li>
			<?php 
    if (!IS_WPMU || current_user_can('FlAG Import folder')) {
        ?>
				<li><a href="#" rel="importfolder"><?php 
        _e('Import image folder', 'flag');
        ?>
</a></li>
			<?php 
    }
    ?>
		</ul>

		<!-- create gallery -->
		<div id="addgallery" class="cptab">
			<h2><?php 
    _e('Create a new gallery', 'flag');
    ?>
</h2>

			<form name="addgallery" id="addgallery_form" method="POST" action="<?php 
    echo $filepath;
    ?>
" accept-charset="utf-8">
				<?php 
    wp_nonce_field('flag_addgallery');
    ?>
				<table class="form-table" style="width: auto;">
					<tr>
						<th scope="col" colspan="2" style="padding-bottom: 0;">
							<strong><?php 
    _e('New Gallery', 'flag');
    ?>
</strong></th>
					</tr>
					<tr valign="top">
						<td><input type="text" size="65" name="galleryname" value=""/><br/>
							<?php 
    if (!IS_WPMU) {
        ?>
								<?php 
        _e('Create a new , empty gallery below the folder', 'flag');
        ?>
								<strong><?php 
        echo $defaultpath;
        ?>
</strong><br/>
							<?php 
    }
    ?>
							<i>( <?php 
    _e('Allowed characters for file and folder names are', 'flag');
    ?>
: a-z, A-Z, 0-9, -, _ )</i>
						</td>
						<?php 
    do_action('flag_add_new_gallery_form');
    ?>
						<td>
							<div class="submit" style="margin: 0; padding: 0;">
								<input class="button-primary" type="submit" name="addgallery" value="<?php 
    _e('Add gallery', 'flag');
    ?>
"/>
							</div>
						</td>
					</tr>
				</table>
				<p>&nbsp;</p>
			</form>
		</div>
		<!-- upload images -->
		<div id="uploadimage" class="cptab">
			<h2><?php 
    _e('Upload images', 'flag');
    ?>
</h2>

			<form name="uploadimage" id="gmUpload" method="POST" enctype="multipart/form-data" action="<?php 
    echo $filepath;
    ?>
" accept-charset="utf-8">
				<?php 
    wp_nonce_field('flag_upload');
    ?>
				<table class="flag-form-table">
					<tr valign="top">
						<td style="width: 216px;">
							<label for="galleryselect"><?php 
    _e('Upload images in', 'flag');
    ?>
 *</label>
							<select name="galleryselect" id="galleryselect" style="width: 200px">
								<option value="0"><?php 
    _e('Choose gallery', 'flag');
    ?>
</option>
								<?php 
    $ingallery = isset($_GET['gid']) ? (int) $_GET['gid'] : '';
    foreach ($gallerylist as $gallery) {
        if (!flagAdmin::can_manage_this_gallery($gallery->author)) {
            continue;
        }
        $name = empty($gallery->title) ? $gallery->name : esc_html(stripslashes($gallery->title));
        if ($flag->options['albSort'] == 'gid') {
            $name = '#' . $gallery->gid . ' - ' . $name;
        }
        if ($flag->options['albSort'] == 'title') {
            $name = $name . ' (#' . $gallery->gid . ')';
        }
        $sel = $ingallery == $gallery->gid ? 'selected="selected" ' : '';
        echo '<option ' . $sel . 'value="' . $gallery->gid . '" >' . $name . '</option>' . "\n";
    }
    ?>
							</select>
							<?php 
    echo $maxsize;
    ?>
							<br/><?php 
    if (IS_WPMU && flagGallery::flag_wpmu_enable_function('wpmuQuotaCheck')) {
        display_space_usage();
    }
    ?>
							<br/>

							<p><?php 
    _e('Thumbnail WIDTH x HEIGHT (in pixel)', 'flag');
    ?>
 *
								<br/><input type="text" size="5" maxlength="5" name="thumbWidth" id="thumbWidth" value="<?php 
    echo $flag->options['thumbWidth'];
    ?>
"/> x
								<input type="text" size="5" maxlength="5" name="thumbHeight" id="thumbHeight" value="<?php 
    echo $flag->options['thumbHeight'];
    ?>
"/>
								<br/>
								<small><?php 
    _e('These values are maximum values ', 'flag');
    ?>
</small>
							</p>
							<p>
								<label><input type="checkbox" name="thumbFix" id="thumbFix" value="1" <?php 
    checked('1', $flag->options['thumbFix']);
    ?>
 /> <?php 
    _e('Ignore the aspect ratio, no portrait thumbnails', 'flag');
    ?>
								</label></p>

							<div class="submit">
					<span class="useflashupload">
					<?php 
    if ($flag->options['swfUpload']) {
        ?>
						<input type="submit" class="button-secondary" name="disable_flash" id="disable_flash" title="<?php 
        _e('The batch upload via Plupload, disable it if you have problems', 'flag');
        ?>
" value="<?php 
        _e('Switch to Browser Upload', 'flag');
        ?>
"/>
					<?php 
    } else {
        ?>
						<input type="submit" class="button-secondary" name="enable_flash" id="enable_flash" title="<?php 
        _e('Upload multiple files at once by ctrl/shift-selecting in dialog', 'flag');
        ?>
" value="<?php 
        _e('Switch to Plupload based Upload', 'flag');
        ?>
"/>
					<?php 
    }
    ?>
					</span>

								<div class="clear"></div>
							</div>

						</td>

						<td>
							<div id="pluploadUploader">
								<?php 
    if (!$flag->options['swfUpload']) {
        ?>
								<strong><?php 
        _e('Upload image(s):', 'flag');
        ?>
</strong><br>
								<input type="file" name="imagefiles[]" id="imagefiles" size="35" class="imagefiles"/>
							</div>
						<span id="choosegalfirst">
							<input class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php 
        _e('Upload images', 'flag');
        ?>
"/>
							<span class="disabledbut" style="display: none;"></span>
						</span>
							<?php 
    }
    ?>
						</td>
					</tr>
				</table>
				<div id="pl-message"></div>
			</form>
			<?php 
    if ($flag->options['swfUpload']) {
        $nonce = wp_create_nonce('flag_upload');
        ?>
				<script type="text/javascript">
					// Convert divs to queue widgets when the DOM is ready
					jQuery(function($){
						var files_remaining = 0;
						$("#pluploadUploader").plupload({
							runtimes: 'html5,flash,html4',
							url: '<?php 
        echo str_replace('&#038;', '&', wp_nonce_url(admin_url('admin-ajax.php?action=plupload_uploader'), 'flag_upload'));
        ?>
',
							multipart: true,
							multipart_params: {postData: '', pluploadimage: 1},
							max_file_size: '<?php 
        echo floor(wp_max_upload_size() * 0.99 / 1024 / 1024) - 1;
        ?>
Mb',
							unique_names: false,
							rename: true,
							chunk_size: '<?php 
        echo min(floor(wp_max_upload_size() * 0.99 / 1024 / 1024) - 1, 6);
        ?>
Mb',
							max_retries: 2,
							sortable: true,
							dragdrop: true,
							views: {
								list: true,
								thumbs: true,
								active: 'thumbs'
							},
							filters: [{title: "Images", extensions: "jpg,gif,png"}],
							flash_swf_url: '<?php 
        echo plugins_url(FLAGFOLDER . '/admin/js/plupload/plupload.flash.swf');
        ?>
'

						});

						var uploader = $("#pluploadUploader").plupload('getUploader');
						uploader.bind('QueueChanged StateChanged', function(up){
							if(up.state == plupload.QUEUED){
								files_remaining = up.files.length;
							}
							if(up.state == plupload.STARTED){
								up.settings.multipart_params = {
									galleryselect: jQuery('#galleryselect').val(),
									thumbw: jQuery('#thumbWidth').val(),
									thumbh: jQuery('#thumbHeight').val(),
									thumbf: jQuery('#thumbFix').prop("checked"),
									last: files_remaining,
									action: 'flag_plupload_uploader',
									_wpnonce: '<?php 
        echo $nonce;
        ?>
'
								};
							}
							if($("#galleryselect").val() == 0){
								$("#pluploadUploader_start").addClass('ui-button-disabled ui-state-disabled');
							}
							console.log('[StateChanged]', up.state, up.settings.multipart_params);
						});
						uploader.bind('ChunkUploaded', function(up, file, info){
							console.log('[ChunkUploaded] File:', file, "Info:", info);
							var response = jQuery.parseJSON(info.response);
							if(response && response.error){
								up.stop();
								file.status = plupload.FAILED;
								console.log(response.error);
								up.trigger('QueueChanged StateChanged');
								up.trigger('UploadProgress', file);
								up.start();
							}
						});
						uploader.bind('FileUploaded', function(up, file, info){
							console.log('[FileUploaded] File:', file, "Info:", info);
							files_remaining--;
							if(info.response){
								file.status = plupload.FAILED;
								jQuery('<div/>').addClass('error').html('<span><u><em>' + file.name + ':</em></u> ' + info.response + '</span>').appendTo('#pl-message');
							}
						});
						uploader.bind('UploadProgress', function(up, file){
							var percent = uploader.total.percent;
							$('#total-progress-info .progress-bar').css('width', percent + "%").attr('aria-valuenow', percent);
						});
						uploader.bind('Error', function(up, args){
							jQuery('<div/>').addClass('error').html('<span><u><em>' + args.file.name + ':</em></u> ' + args.message + ' ' + args.status + '</span>').appendTo('#pl-message');
							console.log('[error] ', args);
						});
						uploader.bind('UploadComplete', function(up, files){
							console.log('[UploadComplete]', files);
							jQuery('<div/>').addClass('success').html('<?php 
        _e('Done!', 'flag');
        ?>
 <a href="<?php 
        echo wp_nonce_url($flag->manage_page->base_page . "&mode=edit", 'flag_editgallery');
        ?>
&gid=' + jQuery("#galleryselect").val() + '">Open Gallery</a>').appendTo('#pl-message');
						});

						jQuery("#gmUpload").on('click', '.ui-button-disabled', function(){
							if(files_remaining){
								alert("Choose gallery, please.")
							}
						});
						jQuery("#galleryselect").change(function(){
							if(jQuery(this).val() == 0){
								jQuery("#pluploadUploader_start").addClass('ui-button-disabled ui-state-disabled');
							} else{
								if(files_remaining){
									jQuery("#pluploadUploader_start").removeClass('ui-button-disabled ui-state-disabled');
								}
							}
						});

					});
				</script>
			<?php 
    } else {
        ?>
				<!-- MultiFile script -->
				<script type="text/javascript">
					/* <![CDATA[ */
					jQuery(document).ready(function(){
						jQuery('#imagefiles').MultiFile({
							STRING: {
								remove: '<?php 
        _e('remove', 'flag');
        ?>
'
							}
						});

						if(jQuery("#galleryselect").val() == 0){
							jQuery("#choosegalfirst").animate({opacity: "0.5"}, 600);
							jQuery("#choosegalfirst .disabledbut").show();
						}
						jQuery("#choosegalfirst .disabledbut").click(function(){
							alert("Choose gallery, please.")
						});
						jQuery("#galleryselect").change(function(){
							if(jQuery(this).val() == 0){
								jQuery("#choosegalfirst .disabledbut").show();
								jQuery("#choosegalfirst").animate({opacity: "0.5"}, 600);
							} else{
								jQuery("#choosegalfirst .disabledbut").hide();
								jQuery("#choosegalfirst").animate({opacity: "1"}, 600);
							}
						});
					});
					/* ]]> */
				</script>

			<?php 
    }
    ?>
		</div>
		<?php 
    if (!IS_WPMU || current_user_can('FlAG Import folder')) {
        ?>
			<!-- import folder -->
			<div id="importfolder" class="cptab">
				<h2><?php 
        _e('Import image folder', 'flag');
        ?>
</h2>

				<form name="importfolder" id="importfolder_form" method="POST" action="<?php 
        echo $filepath;
        ?>
" accept-charset="utf-8">
					<?php 
        wp_nonce_field('flag_addgallery');
        ?>
					<table class="form-table">
						<tr valign="top">
							<th scope="row"><?php 
        _e('Import from Server path:', 'flag');
        ?>
</th>
							<td>
								<input type="text" size="35" id="galleryfolder" name="galleryfolder" value="<?php 
        echo $defaultpath;
        ?>
"/><span class="browsefiles button" style="display:none"><?php 
        _e('Browse...', "flag");
        ?>
</span>

								<div id="file_browser"></div>
								<div><?php 
        echo $maxsize;
        ?>
									<?php 
        if (SAFE_MODE) {
            ?>
										<br/><?php 
            _e(' Please note : For safe-mode = ON you need to add the subfolder thumbs manually', 'flag');
        }
        ?>
								</div>
							</td>
						</tr>
					</table>
					<div class="submit">
						<input class="button-primary" type="submit" name="importfolder" value="<?php 
        _e('Import folder', 'flag');
        ?>
"/>
					</div>
				</form>
			</div>
		<?php 
    }
    ?>

		<script type="text/javascript">
			var cptabs = new ddtabcontent("tabs");
			cptabs.setpersist(true);
			cptabs.setselectedClassTarget("linkparent");
			cptabs.init();
		</script>
	</div>
<?php 
}
Exemplo n.º 13
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;
 }
Exemplo n.º 14
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;
 }
Exemplo n.º 15
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";
Exemplo n.º 16
0
 /**
  * Copy images to another gallery
  * 
  * @class flagAdmin
  * @param array|int $pic_ids ID's of the images
  * @param int $dest_gid destination gallery
  * @return void
  */
 static function copy_images($pic_ids, $dest_gid)
 {
     $errors = $messages = '';
     if (!is_array($pic_ids)) {
         $pic_ids = array($pic_ids);
     }
     // Get destination gallery
     $destination = flagdb::find_gallery($dest_gid);
     if ($destination == null) {
         flagGallery::show_error(__('The destination gallery does not exist', 'flag'));
         return;
     }
     // Check for folder permission
     if (!is_writeable(WINABSPATH . $destination->path)) {
         $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'flag'), WINABSPATH . $destination->path);
         flagGallery::show_error($message);
         return;
     }
     // Get pictures
     $images = flagdb::find_images_in_list($pic_ids);
     $destination_path = WINABSPATH . $destination->path;
     foreach ($images as $image) {
         // WPMU action
         if (flagAdmin::check_quota()) {
             return;
         }
         $i = 0;
         $tmp_prefix = '';
         $destination_file_name = $image->filename;
         while (file_exists($destination_path . '/' . $destination_file_name)) {
             $tmp_prefix = 'copy_' . $i++ . '_';
             $destination_file_name = $tmp_prefix . $image->filename;
         }
         $destination_file_path = $destination_path . '/' . $destination_file_name;
         $destination_thumb_file_path = $destination_path . '/' . $image->thumbFolder . $image->thumbPrefix . $destination_file_name;
         // Copy files
         if (!@copy($image->imagePath, $destination_file_path)) {
             $errors .= sprintf(__('Failed to copy image %1$s to %2$s', 'flag'), $image->filename, $destination_file_path) . '<br />';
             continue;
         }
         // Copy the thumbnail if possible
         @copy($image->thumbPath, $destination_thumb_file_path);
         // Create new database entry for the image
         $new_pid = flagdb::insert_image($destination->gid, $destination_file_name, $image->alttext, $image->description, $image->exclude);
         if (!isset($new_pid)) {
             $errors .= sprintf(__('Failed to copy database row for picture %s', 'flag'), $image->pid) . '<br />';
             continue;
         }
         if ($tmp_prefix != '') {
             $messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s) &raquo; The file already existed in the destination gallery.', 'flag'), $image->pid, $image->filename, $new_pid, $destination_file_name) . '<br />';
         } else {
             $messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s)', 'flag'), $image->pid, $image->filename, $new_pid, $destination_file_name) . '<br />';
         }
     }
     // Finish by showing errors or success
     if ($errors == '') {
         $link = '<a href="' . admin_url() . 'admin.php?page=flag-manage-gallery&mode=edit&gid=' . $destination->gid . '" >' . $destination->title . '</a>';
         $messages .= '<hr />' . sprintf(__('Copied %1$s picture(s) to gallery: %2$s .', 'flag'), count($images), $link);
     }
     if ($messages != '') {
         flagGallery::show_message($messages);
     }
     if ($errors != '') {
         flagGallery::show_error($errors);
     }
     return;
 }
Exemplo n.º 17
0
function flag_playlist_delete($playlist)
{
    $playlist = sanitize_flagname($playlist);
    $flag_options = get_option('flag_options');
    $playlistXML = ABSPATH . $flag_options['galleryPath'] . 'playlists/' . $playlist . '.xml';
    if (file_exists($playlistXML)) {
        if (unlink($playlistXML)) {
            flagGallery::show_message("'" . $playlist . ".xml' " . __('deleted', 'flag'));
        }
    }
}
Exemplo n.º 18
0
    case 'w':
        $stype = 'widget';
        $new_skins = __('New Widget Skins', 'flash-album-gallery');
        break;
    default:
        $stype = 'gallery';
        $new_skins = __('New Photo Skins', 'flash-album-gallery');
        break;
}
if (isset($_GET['skins_refresh'])) {
    check_admin_referer('skins_refresh');
    // upgrade plugin
    require_once FLAG_ABSPATH . 'admin/tuning.php';
    $ok = flag_tune();
    if ($ok) {
        flagGallery::show_message(__('Skins refreshed successfully', 'flash-album-gallery'));
    }
}
?>
<div id="slider" class="flag-wrap">
	<ul id="tabs" class="tabs">
<?php 
if (current_user_can('FlAG Add skins')) {
    ?>
		<li class="selected"><a href="#" rel="addskin"><?php 
    _e('Add new skin', 'flash-album-gallery');
    ?>
</a></li>
<?php 
}
?>
Exemplo n.º 19
0
<?php

// Create XML output
header("content-type:text/xml;charset=utf-8");
preg_match('|^(.*?/)(wp-content)/|i', str_replace('\\', '/', __FILE__), $_m);
require_once $_m[1] . 'wp-load.php';
$flag_options = get_option('flag_options');
$file = $_GET['playlist'];
$playlistPath = $_m[1] . $flag_options['galleryPath'] . 'playlists/banner/' . $file . '.xml';
if (file_exists($playlistPath)) {
    require_once FLAG_ABSPATH . 'admin/banner.functions.php';
    $settings = file_get_contents(dirname(__FILE__) . '/settings/settings.xml');
    $properties = '<properties>' . flagGallery::flagGetBetween($settings, '<properties>', '</properties>') . '</properties>
<category';
    $xml = file_get_contents($playlistPath);
    $playlist = get_b_playlist_data($playlistPath);
    if (count($playlist['items'])) {
        $content = '<items>';
        foreach ($playlist['items'] as $id) {
            $ban = get_post($id);
            if ($ban->ID) {
                $track = wp_get_attachment_url($ban->ID);
                $thumbnail = get_post_meta($id, 'thumbnail', true);
                $link = get_post_meta($id, 'link', true);
                $preview = get_post_meta($id, 'preview', true);
                $content .= '
		<item id="' . $ban->ID . '">
	          <track__>' . $track . '</track__>
	          <title><![CDATA[' . $ban->post_title . ']]></title>
	          <link>' . $link . '</link>
	          <preview>' . $preview . '</preview>
Exemplo n.º 20
0
 jCrop : Kelly Hallman <*****@*****.**> | http://deepliquid.com/content/Jcrop.html
 
**/
require_once dirname(dirname(__FILE__)) . '/flag-config.php';
require_once FLAG_ABSPATH . '/lib/image.php';
if (!is_user_logged_in()) {
    die(__('Cheatin&#8217; uh?'));
}
if (!current_user_can('FlAG Manage gallery')) {
    die(__('Cheatin&#8217; uh?'));
}
global $wpdb;
$id = (int) $_GET['id'];
// let's get the image data
$picture = flagdb::find_image($id);
include_once flagGallery::graphic_library();
$flag_options = get_option('flag_options');
$thumb = new flag_Thumbnail($picture->imagePath, TRUE);
$thumb->resize(350, 350);
// we need the new dimension
$resizedPreviewInfo = $thumb->newDimensions;
$thumb->destruct();
$preview_image = FLAG_URLPATH . 'flagshow.php?pid=' . $picture->pid . '&amp;width=350&amp;height=350';
$imageInfo = @getimagesize($picture->imagePath);
$rr = round($imageInfo[0] / $resizedPreviewInfo['newWidth'], 2);
$WidthHtmlPrev = $flag_options['thumbWidth'];
$HeightHtmlPrev = $flag_options['thumbHeight'];
if ($flag_options['thumbFix'] == 1) {
    $WidthHtmlPrev = $flag_options['thumbWidth'];
    $HeightHtmlPrev = $flag_options['thumbHeight'];
} else {
Exemplo n.º 21
0
function flag_admin_options()
{
    global $flag;
    // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
    $filepath = admin_url() . 'admin.php?page=' . urlencode($_GET['page']);
    if (isset($_POST['updateoption'])) {
        check_admin_referer('flag_settings');
        // get the hidden option fields, taken from WP core
        $options = array();
        if ($_POST['page_options']) {
            $options = explode(',', stripslashes($_POST['page_options']));
        }
        if (!empty($options)) {
            foreach ($options as $option) {
                $option = trim($option);
                if (isset($_POST[$option])) {
                    $value = trim($_POST[$option]);
                } else {
                    $value = false;
                }
                $flag->options[$option] = $value;
            }
            if (isset($_POST['galleryPath'])) {
                // the path should always end with a slash
                $flag->options['galleryPath'] = trailingslashit($flag->options['galleryPath']);
            }
            // the custom sortorder must be ascending
            //$flag->options['galSortDir'] = ($flag->options['galSort'] == 'sortorder') ? 'ASC' : $flag->options['galSortDir'];
        }
        // Save options
        update_option('flag_options', $flag->options);
        flagGallery::show_message(__('Update Successfully', 'flag'));
    }
    $regform = 0;
    if (isset($_POST['membership'])) {
        if (function_exists('curl_init')) {
            check_admin_referer('flag_settings');
            $ch = curl_init('http://mypgc.co/app/account_st.php');
            curl_setopt($ch, CURLOPT_REFERER, site_url());
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, array('access_key' => $_POST['access_key'], 'access_url' => $_POST['access_url'], 'license_key' => $_POST['license_key']));
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
            $access_key_return = curl_exec($ch);
            curl_close($ch);
        } else {
            $access_key_return = __('cURL library is not installed on your server.', 'flag');
        }
        if (strpos($access_key_return, 'Error') !== FALSE) {
            $_POST['license_key'] = '';
        }
        $options = explode(',', stripslashes($_POST['page_options']));
        foreach ($options as $option) {
            $option = trim($option);
            $value = trim($_POST[$option]);
            $flag->options[$option] = $value;
        }
        if (strpos($access_key_return, 'Error') === FALSE || strpos($access_key_return, 'not a member') !== FALSE) {
            flagGallery::show_message($access_key_return);
            if (strpos($access_key_return, 'not a member') !== FALSE) {
                $regform = 1;
                //$flag->options['access_key'] = '';
            }
        } else {
            flagGallery::show_error($access_key_return);
            //$flag->options['access_key'] = '';
        }
        // Save options
        update_option('flag_options', $flag->options);
    }
    if (isset($_POST['register_subscriber'])) {
        if (empty($_POST['customer_first_name']) || empty($_POST['customer_last_name']) || empty($_POST['customer_email'])) {
            $regform = 1;
            flagGallery::show_error(__('Error: All fields required.'));
        } else {
            if (function_exists('curl_init')) {
                check_admin_referer('flag_settings');
                $ch = curl_init('http://mypgc.co/app/account_st.php');
                curl_setopt($ch, CURLOPT_REFERER, site_url());
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, array('access_key' => $_POST['access_key'], 'access_url' => $_POST['access_url'], 'customer_first_name' => $_POST['customer_first_name'], 'customer_last_name' => $_POST['customer_last_name'], 'customer_email' => $_POST['customer_email']));
                $reg_return = curl_exec($ch);
                curl_close($ch);
            } else {
                $reg_return = __('cURL library is not installed on your server.', 'flag');
            }
            if (strpos($reg_return, 'Error') === FALSE) {
                flagGallery::show_message($reg_return);
            } else {
                flagGallery::show_error($reg_return);
                $regform = 1;
            }
        }
    }
    if (isset($_POST['update_cap'])) {
        check_admin_referer('flag_addroles');
        // now set or remove the capability
        flag_set_capability($_POST['general'], "FlAG overview");
        flag_set_capability($_POST['tinymce'], "FlAG Use TinyMCE");
        flag_set_capability($_POST['add_gallery'], "FlAG Upload images");
        flag_set_capability($_POST['import_gallery'], "FlAG Import folder");
        flag_set_capability($_POST['manage_gallery'], "FlAG Manage gallery");
        flag_set_capability($_POST['manage_others'], "FlAG Manage others gallery");
        flag_set_capability($_POST['change_skin'], "FlAG Change skin");
        flag_set_capability($_POST['add_skins'], "FlAG Add skins");
        flag_set_capability($_POST['delete_skins'], "FlAG Delete skins");
        flag_set_capability($_POST['change_options'], "FlAG Change options");
        flag_set_capability($_POST['manage_music'], "FlAG Manage music");
        flag_set_capability($_POST['manage_video'], "FlAG Manage video");
        flag_set_capability($_POST['manage_banners'], "FlAG Manage banners");
        flag_set_capability($_POST['flagframe_page'], "FlAG iFrame page");
        flagGallery::show_message(__('Updated capabilities', "flag"));
    }
    // message windows
    if (!empty($messagetext)) {
        echo '<!-- Last Action --><div id="message" class="updated fade"><p>' . $messagetext . '</p></div>';
    }
    $flag_options = get_option('flag_options');
    ?>
	
<div id="slider" class="flag-wrap">

	<ul id="tabs" class="tabs">
		<li class="selected"><a href="#" rel="imageoptions"><?php 
    _e('Gallery Options', 'flag');
    ?>
</a></li>
		<li><a href="#" rel="grandpages"><?php 
    _e('GRAND Pages', 'flag');
    ?>
</a></li>
		<?php 
    if (current_user_can('administrator')) {
        ?>
		<li><a href="#" rel="rControl"><?php 
        _e('License Key & Remote Control', 'flag');
        ?>
</a></li>
		<?php 
    }
    ?>
		<li><a href="#" rel="vPlayer"><?php 
    _e('FLV Single Player Options', 'flag');
    ?>
</a></li>
		<li><a href="#" rel="mPlayer"><?php 
    _e('MP3 Single Player Options', 'flag');
    ?>
</a></li>
<?php 
    if (flagGallery::flag_wpmu_enable_function('wpmuRoles')) {
        ?>
		<li><a href="#" rel="roles"><?php 
        _e('Roles', 'flag');
        ?>
</a></li>
<?php 
    }
    ?>
	</ul>
	<!-- Image Gallery Options -->
<script type="text/javascript">
jQuery(document).ready(function() {
	jQuery('.flag_colors .colorPick').each( function(){
		var inpID = jQuery(this).attr('name');
		jQuery('#cp_'+inpID).farbtastic('#'+inpID);
		jQuery('#'+inpID).focus( function(){
		    jQuery('#cp_'+inpID).show();
		});
		jQuery('#'+inpID).blur( function(){
		    jQuery('#cp_'+inpID).hide();
		});
	});
});
</script>
	<div id="imageoptions" class="cptab">
		<form name="generaloptions" method="post">
		<?php 
    wp_nonce_field('flag_settings');
    ?>
			<input type="hidden" name="page_options" value="galleryPath,flashWidth,flashHeight,deleteImg,deepLinks,useMediaRSS,optimized_imgs,jAlterGal,jAlterGalScript,BarsBG,CatBGColor,CatBGColorOver,CatColor,CatColorOver,ThumbBG,ThumbLoaderColor,TitleColor,DescrColor,imgQuality,albSort,albSortDir,albPerPage,galSort,galSortDir,disableViews" />
			<h2><?php 
    _e('Image Gallery Options', 'flag');
    ?>
</h2>
			<h3><?php 
    _e('General Options', 'flag');
    ?>
</h3>
			<table class="form-table flag-options" style="width: auto; white-space: nowrap;">
				<tr valign="top">
					<th align="left" width="200"><?php 
    _e('Gallery path', 'flag');
    ?>
</th>
					<td><input readonly="readonly" type="text" size="35" name="galleryPath" value="<?php 
    echo $flag_options['galleryPath'];
    ?>
" />
					<span class="setting-description"><?php 
    _e('This is the default path for all galleries', 'flag');
    ?>
</span></td>
				</tr>
				<tr valign="top">
					<th><?php 
    _e('Default flash size (W x H)', 'flag');
    ?>
:</th>
					<td><input type="text" size="4" maxlength="4" name="flashWidth" value="<?php 
    echo $flag_options['flashWidth'];
    ?>
" /> x
					<input type="text" size="4" maxlength="4" name="flashHeight" value="<?php 
    echo $flag_options['flashHeight'];
    ?>
" /></td>
				</tr>					
				<tr valign="top">
					<th align="left"><?php 
    _e('Delete image files', 'flag');
    ?>
</th>
					<td><input <?php 
    if (IS_WPMU) {
        echo 'readonly = "readonly"';
    }
    ?>
 type="checkbox" name="deleteImg" value="1" <?php 
    checked('1', $flag_options['deleteImg']);
    ?>
 />
					<?php 
    _e('Delete files, when removing a gallery in the database', 'flag');
    ?>
</td>
				</tr>
				<tr>
					<th align="left"><?php 
    _e('Activate Deep Linking (optional)', 'flag');
    ?>
<br /><small><?php 
    _e('Not all skins support this feature.', 'flag');
    ?>
</small></th>
					<td><input type="checkbox" name="deepLinks" value="1" <?php 
    checked('1', $flag_options['deepLinks']);
    ?>
 />
					<span class="setting-description"><?php 
    _e('Deep links for images in flash.', 'flag');
    ?>
</span></td>
				</tr>
				<tr>
					<th align="left"><?php 
    _e('Activate Media RSS feed', 'flag');
    ?>
</th>
					<td><input type="checkbox" name="useMediaRSS" value="1" <?php 
    checked('1', $flag_options['useMediaRSS']);
    ?>
 />
					<span class="setting-description"><?php 
    _e('A RSS feed will be added to you blog header.', 'flag');
    ?>
</span></td>
				</tr>
			</table>

			<h3><?php 
    _e('Image settings', 'flag');
    ?>
</h3>
			<table class="form-table flag-options" style="width: auto; white-space: nowrap;">
				<tr valign="top">
					<th scope="row" width="200"><label><?php 
    _e('Use optimized images for mobile browsers', 'flag');
    ?>
</label><br /><small>(Manage Gallery -> 'Optimize images for web' action)</small></th>
					<td><input type="checkbox" name="optimized_imgs" value="1" <?php 
    checked('1', $flag_options['optimized_imgs']);
    ?>
 />
						<span class="setting-description"><?php 
    _e('Optimized images loads faster, save traffic and make page more lightweight for browser', 'flag');
    ?>
</span></td>
				</tr>
				<tr valign="top">
					<th align="left"><?php 
    _e('Image quality', 'flag');
    ?>
</th>
					<td><input type="text" size="3" maxlength="3" name="imgQuality" value="<?php 
    echo $flag_options['imgQuality'];
    ?>
" /> % &nbsp;&nbsp;<span class="setting-description"><?php 
    _e('Default: 85%', 'flag');
    ?>
</span></td>
				</tr>
			</table>

			<h3><?php 
    _e('Sort options', 'flag');
    ?>
</h3>
			<table class="form-table flag-options" style="width: auto; white-space: nowrap;">
				<tr>
					<th valign="top" width="200"><?php 
    _e('Sort galleries', 'flag');
    ?>
:</th>
					<td valign="top">
						<label><input name="albSort" type="radio" value="gid" <?php 
    checked('gid', $flag_options['albSort']);
    ?>
 /> <?php 
    _e('Gallery ID', 'flag');
    ?>
</label><br />
						<label><input name="albSort" type="radio" value="title" <?php 
    checked('title', $flag_options['albSort']);
    ?>
 /> <?php 
    _e('Title', 'flag');
    ?>
</label><br />
					</td>
					<td valign="top"><label><input name="albSortDir" type="radio" value="ASC" <?php 
    checked('ASC', $flag_options['albSortDir']);
    ?>
 /> <?php 
    _e('Ascending', 'flag');
    ?>
</label><br />
						<label><input name="albSortDir" type="radio" value="DESC" <?php 
    checked('DESC', $flag_options['albSortDir']);
    ?>
 /> <?php 
    _e('Descending', 'flag');
    ?>
</label>
					</td>
				</tr>
				<tr style="border-bottom: 1px solid #000000;">
					<th valign="top" width="200"><?php 
    _e('Galleries per page: <br><small>on Manage Galleries page</small>', 'flag');
    ?>
</th>
					<td valign="top">
						<input name="albPerPage" type="text" value="<?php 
    echo $flag_options['albPerPage'];
    ?>
" />
					</td>
					<td valign="top"></td>
				</tr>
				<tr>
					<th valign="top" width="200"><?php 
    _e('Sort images', 'flag');
    ?>
:</th>
					<td valign="top">
						<label><input name="galSort" type="radio" value="sortorder" <?php 
    checked('sortorder', $flag_options['galSort']);
    ?>
 /> <?php 
    _e('Custom order', 'flag');
    ?>
</label><br />
						<label><input name="galSort" type="radio" value="pid" <?php 
    checked('pid', $flag_options['galSort']);
    ?>
 /> <?php 
    _e('Image ID', 'flag');
    ?>
</label><br />
						<label><input name="galSort" type="radio" value="filename" <?php 
    checked('filename', $flag_options['galSort']);
    ?>
 /> <?php 
    _e('File name', 'flag');
    ?>
</label><br />
						<label><input name="galSort" type="radio" value="alttext" <?php 
    checked('alttext', $flag_options['galSort']);
    ?>
 /> <?php 
    _e('Alt / Title text', 'flag');
    ?>
</label><br />
						<label><input name="galSort" type="radio" value="imagedate" <?php 
    checked('imagedate', $flag_options['galSort']);
    ?>
 /> <?php 
    _e('Date / Time', 'flag');
    ?>
</label><br />
						<label><input name="galSort" type="radio" value="hitcounter" <?php 
    checked('hitcounter', $flag_options['galSort']);
    ?>
 /> <?php 
    _e('Image views', 'flag');
    ?>
</label><br />
						<label><input name="galSort" type="radio" value="total_votes" <?php 
    checked('total_votes', $flag_options['galSort']);
    ?>
 /> <?php 
    _e('Image likes', 'flag');
    ?>
</label><br />
						<label><input name="galSort" type="radio" value="rand()" <?php 
    checked('rand()', $flag_options['galSort']);
    ?>
 /> <?php 
    _e('Randomly', 'flag');
    ?>
</label>
					</td>
					<td valign="top"><label><input name="galSortDir" type="radio" value="ASC" <?php 
    checked('ASC', $flag_options['galSortDir']);
    ?>
 /> <?php 
    _e('Ascending', 'flag');
    ?>
</label><br />
						<label><input name="galSortDir" type="radio" value="DESC" <?php 
    checked('DESC', $flag_options['galSortDir']);
    ?>
 /> <?php 
    _e('Descending', 'flag');
    ?>
</label>
					</td>
				</tr>
			</table>

			<h3><?php 
    _e('Alternative Gallery Options', 'flag');
    ?>
 <br><small style="color: darkgreen;"><?php 
    _e('(Note: this is not flash skin option. Options below only for alternative gallery in mobile browsers)', 'flag');
    ?>
</small></h3>
			<table class="flag_colors form-table flag-options" style="width: auto; white-space: nowrap;">
				<tr>
					<th align="left"><?php 
    _e('Show jQuery gallery for browsers without flashplayer', 'flag');
    ?>
</th>
					<td><input type="checkbox" name="jAlterGal" value="1" <?php 
    checked('1', $flag_options['jAlterGal']);
    ?>
 /></td>
				</tr>
				<tr>
					<th align="left"><?php 
    _e('jQuery gallery script', 'flag');
    ?>
</th>
					<td><select name="jAlterGalScript">
							<option value="0" <?php 
    selected('0', $flag_options['jAlterGalScript']);
    ?>
>FancyBox</option>
							<option value="1" <?php 
    selected('1', $flag_options['jAlterGalScript']);
    ?>
>PhotoSwipe</option>
						</select>
					</td>
				</tr>
				<tr>
					<th align="left"><?php 
    _e('Disable image views/likes counter on thumbnails', 'flag');
    ?>
</th>
					<td><input type="checkbox" name="disableViews" value="1" <?php 
    checked('1', $flag_options['disableViews']);
    ?>
 /></td>
				</tr>
				<tr>
					<th width="200"><?php 
    _e('Top Bar BG', 'flag');
    ?>
:</th>
					<td><input class="colorPick" type="text" size="7" maxlength="6" id="BarsBG" name="BarsBG" value="<?php 
    echo $flag_options['BarsBG'];
    ?>
" /><div id="cp_BarsBG" style="background:#F9F9F9;position:absolute;display:none;"></div></td>
				</tr>
				<tr>					
					<th><?php 
    _e('Category Buttons BG', 'flag');
    ?>
:</th>
					<td>
						<input class="colorPick" type="text" size="7" maxlength="6" id="CatBGColorOver" name="CatBGColorOver" value="<?php 
    echo $flag_options['CatBGColorOver'];
    ?>
" /> mouseOver<br />
						<div id="cp_CatBGColorOver" style="background:#F9F9F9;position:absolute;display:none;"></div>
						<input class="colorPick" type="text" size="7" maxlength="6" id="CatBGColor" name="CatBGColor" value="<?php 
    echo $flag_options['CatBGColor'];
    ?>
" /> mouseOut<br />
						<div id="cp_CatBGColor" style="background:#F9F9F9;position:absolute;display:none;"></div>
					</td>
				</tr>
				<tr>					
					<th><?php 
    _e('Category Buttons Color', 'flag');
    ?>
:</th>
					<td>
						<input class="colorPick" type="text" size="7" maxlength="6" id="CatColorOver" name="CatColorOver" value="<?php 
    echo $flag_options['CatColorOver'];
    ?>
" /> mouseOver<br />
						<div id="cp_CatColorOver" style="background:#F9F9F9;position:absolute;display:none;"></div>
						<input class="colorPick" type="text" size="7" maxlength="6" id="CatColor" name="CatColor" value="<?php 
    echo $flag_options['CatColor'];
    ?>
" /> mouseOut<br />
						<div id="cp_CatColor" style="background:#F9F9F9;position:absolute;display:none;"></div>
					</td>
				</tr>
				<tr>					
					<th><?php 
    _e('Thumbnail BG', 'flag');
    ?>
:</th>
					<td><input class="colorPick" type="text" size="7" maxlength="6" id="ThumbBG" name="ThumbBG" value="<?php 
    echo $flag_options['ThumbBG'];
    ?>
" /><div id="cp_ThumbBG" style="background:#F9F9F9;position:absolute;display:none;"></div></td>
				</tr>
				<tr>					
					<th><?php 
    _e('Thumbnail MouseOver BG', 'flag');
    ?>
:</th>
					<td><input class="colorPick" type="text" size="7" maxlength="6" id="ThumbLoaderColor" name="ThumbLoaderColor" value="<?php 
    echo $flag_options['ThumbLoaderColor'];
    ?>
" /><div id="cp_ThumbLoaderColor" style="background:#F9F9F9;position:absolute;display:none;"></div></td>
				</tr>
				<tr>
					<th><?php 
    _e('Fancybox Title', 'flag');
    ?>
:<br /><small><?php 
    _e('Only if FancyBox script is selected', 'flag');
    ?>
</small></th>
					<td><input class="colorPick" type="text" size="7" maxlength="6" id="TitleColor" name="TitleColor" value="<?php 
    echo $flag_options['TitleColor'];
    ?>
" /><div id="cp_TitleColor" style="background:#F9F9F9;position:absolute;display:none;"></div></td>
				</tr>
				<tr>
					<th><?php 
    _e('Fancybox Description Text', 'flag');
    ?>
:<br /><small><?php 
    _e('Only if FancyBox script is selected', 'flag');
    ?>
</small></th>
					<td><input class="colorPick" type="text" size="7" maxlength="6" id="DescrColor" name="DescrColor" value="<?php 
    echo $flag_options['DescrColor'];
    ?>
" /><div id="cp_DescrColor" style="background:#F9F9F9;position:absolute;display:none;"></div></td>
				</tr>
			</table>
			<div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php 
    _e('Save Changes', 'flag');
    ?>
"/></div>
		</form>	
	</div>

	<div id="grandpages" class="cptab">
		<form name="grandpages"  method="post">
			<?php 
    wp_nonce_field('flag_settings');
    ?>
			<input type="hidden" name="page_options" value="gp_jscode" />
			<h2><?php 
    _e('GRAND Pages settings', 'flag');
    ?>
</h2>
			<h3><?php 
    _e('Google Analytics Tracking Code', 'flag');
    ?>
</h3>
			<textarea name="gp_jscode" rows="5" cols="50"><?php 
    if (isset($flag_options['gp_jscode'])) {
        echo stripslashes($flag_options['gp_jscode']);
    }
    ?>
</textarea>
			<p><?php 
    _e('Enter your Google analytics tracking Code here. It will automatically be added to GRAND Pages so google can track your visitors behavior.', 'flag');
    ?>
</p>
			<div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php 
    _e('Save Changes', 'flag');
    ?>
"/></div>
		</form>
	</div>

<?php 
    if (current_user_can('administrator')) {
        ?>
	<div id="rControl" class="cptab">
		<form name="rControl"  method="post" style="float: left;width: 50%;">
			<?php 
        wp_nonce_field('flag_settings');
        ?>
			<input type="hidden" name="page_options" value="access_key,license_key" />
			<h2><?php 
        _e('License Key & Remote Control', 'flag');
        ?>
</h2>
			<input type="hidden" name="access_url" value="<?php 
        echo plugins_url() . '/' . FLAGFOLDER . '/lib/app.php';
        ?>
" />
			<table class="form-table flag-options" style="">
				<tr>
					<th valign="top" width="200"><a href="http://mypgc.co/membership/" target="_blank"><?php 
        _e('License Key', 'flag');
        ?>
</a>:</th>
					<td valign="top"><input type="text" size="40" id="license_key" name="license_key" value="<?php 
        echo $flag_options['license_key'];
        ?>
" /></td>
				</tr>
				<tr>
					<td colspan="2"><br><?php 
        _e('If you want to upload photos to FlAGallery right from your iPhone <a href="https://itunes.apple.com/us/app/mypgc/id663405181?ls=1&mt=8">download application</a> and enter access key below. You can enter your own access key. You can change these at any point in time and this will force all users to have to log in again in application.', 'flag');
        ?>
 </td>
				</tr>
				<tr>
					<th valign="top" width="200"><?php 
        _e('Remote App Access Key', 'flag');
        ?>
:</th>
					<td valign="top"><input type="text" size="40" id="access_key" name="access_key" value="<?php 
        echo $flag_options['access_key'];
        ?>
" />
						<button type="button" onclick="jQuery('#flag_register_form').toggle();"><?php 
        _e('Register free account Form', 'flag');
        ?>
</button>
						<br><small><?php 
        _e('Leave blank to disable access from application', 'flag');
        ?>
</small></td>
				</tr>
			</table>
			<p><a href="https://itunes.apple.com/us/app/mypgc/id663405181?ls=1&mt=8"><img src="<?php 
        echo plugins_url() . '/' . FLAGFOLDER;
        ?>
/admin/images/appstore_button.png" alt="Download from AppStore" /></a></p>
			<div class="submit"><input class="button-primary" type="submit" name="membership" value="<?php 
        _e('Update Settings for Remote Access', 'flag');
        ?>
"/></div>
		</form>

		<form id="flag_register_form" name="reg_on_mypgc" method="post" style="<?php 
        if (!$regform || !empty($flag_options['access_key'])) {
            ?>
display:none;<?php 
        }
        ?>
 float: left; border: 1px solid #666666; background-color: #ffffee; margin-top: 95px; width: 49%;">
			<?php 
        wp_nonce_field('flag_settings');
        ?>
			<h3 style="padding-left: 10px;"><?php 
        _e('Register with form below or <a href="http://mypgc.co/membership/" target="_blank">purchase license key</a>', 'flag');
        ?>
</h3>
			<div style="padding:0 10px;">
				<p><?php 
        _e("this email and password that you'll receive will be used to login in iOS application", 'flag');
        ?>
</p>
				<p><b><?php 
        _e("Note: if you already purchased license key or already registered this website you don't need register again. Just create your own Access Key and Save", 'flag');
        ?>
</b></p>
			</div>
			<input type="hidden" name="access_key" value="<?php 
        echo $flag_options['access_key'];
        ?>
" />
			<input type="hidden" name="access_url" value="<?php 
        echo plugins_url() . '/' . FLAGFOLDER . '/lib/app.php';
        ?>
" />
			<table class="form-table" style="100%;">
				<tr>
					<td valign="top" style="width: 50%;"><?php 
        _e('First Name', 'flag');
        ?>
:<br><input type="text" id="customer_first_name" name="customer_first_name" value="" style="width: 95%;" /></td>
					<td valign="top"><?php 
        _e('Last Name', 'flag');
        ?>
:<br><input type="text" id="customer_last_name" name="customer_last_name" value="" style="width: 95%;" /></td>
				</tr>
				<tr>
					<td valign="top"><?php 
        _e('Email', 'flag');
        ?>
:<br><input type="text" size="54" id="customer_email" name="customer_email" value="" style="width: 95%;" /></td>
					<td valign="top"><div class="submit"><input class="button-primary" type="submit" name="register_subscriber" value="<?php 
        _e('Register', 'flag');
        ?>
"/></div></td>
				</tr>
			</table>
		</form>

		<div style="clear: both;"> </div>
	</div>
<?php 
    }
    ?>

	<div id="vPlayer" class="cptab">
		<form name="vPlayer"  method="post">
			<?php 
    wp_nonce_field('flag_settings');
    ?>
			<input type="hidden" name="page_options" value="videoBG,vmColor1,vmColor2,vmAutoplay,vmWidth,vmHeight" />
			<h2><?php 
    _e('Flash Video Player Colors', 'flag');
    ?>
</h2>
			<table class="flag_colors form-table flag-options" style="width: auto; white-space: nowrap;">
				<tr>
					<th width="200"><?php 
    _e('Video BG', 'flag');
    ?>
:</th>
					<td><input class="colorPick" type="text" size="7" maxlength="6" id="videoBG" name="videoBG" value="<?php 
    echo $flag_options['videoBG'];
    ?>
" /><div id="cp_videoBG" style="background:#F9F9F9;position:absolute;display:none;"></div></td>
				</tr>
				<tr>
					<th><?php 
    _e('Color 1', 'flag');
    ?>
:</th>
					<td><input class="colorPick" type="text" size="7" maxlength="6" id="vmColor1" name="vmColor1" value="<?php 
    echo $flag_options['vmColor1'];
    ?>
" /><div id="cp_vmColor1" style="background:#F9F9F9;position:absolute;display:none;"></div></td>
				</tr>
				<tr>
					<th><?php 
    _e('Color 2', 'flag');
    ?>
:</th>
					<td>
						<input class="colorPick" type="text" size="7" maxlength="6" id="vmColor2" name="vmColor2" value="<?php 
    echo $flag_options['vmColor2'];
    ?>
" /><div id="cp_vmColor2" style="background:#F9F9F9;position:absolute;display:none;"></div></td>
				</tr>
				<tr>
					<th><?php 
    _e('Autoplay', 'flag');
    ?>
:</th>
					<td>
						<label><input name="vmAutoplay" type="radio" value="true" <?php 
    checked('true', $flag_options['vmAutoplay']);
    ?>
 /> <?php 
    _e('True', 'flag');
    ?>
</label><br />
						<label><input name="vmAutoplay" type="radio" value="false" <?php 
    checked('false', $flag_options['vmAutoplay']);
    ?>
 /> <?php 
    _e('False', 'flag');
    ?>
</label><br />
					</td>
				</tr>
				<tr>
					<th><?php 
    _e('Default Size', 'flag');
    ?>
:<br /><small>(width x height)</small></th>
					<td>
						<input name="vmWidth" type="text" size="3" maxlength="3" value="<?php 
    echo $flag_options['vmWidth'];
    ?>
" /> x <input name="vmHeight" type="text" size="3" maxlength="3" value="<?php 
    echo $flag_options['vmHeight'];
    ?>
" />
					</td>
				</tr>
			</table>
			<div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php 
    _e('Save Changes', 'flag');
    ?>
"/></div>
		</form>
	</div>

	<div id="mPlayer" class="cptab">
		<form name="mPlayer"  method="post">
			<?php 
    wp_nonce_field('flag_settings');
    ?>
			<input type="hidden" name="page_options" value="mpBG,mpColor1,mpColor2,mpAutoplay" />
			<h2><?php 
    _e('MP3 Player Colors', 'flag');
    ?>
</h2>
			<table class="flag_colors form-table flag-options" style="width: auto; white-space: nowrap;">
				<tr>
					<th width="200"><?php 
    _e('Player BG', 'flag');
    ?>
:</th>
					<td><input class="colorPick" type="text" size="7" maxlength="6" id="mpBG" name="mpBG" value="<?php 
    echo $flag_options['mpBG'];
    ?>
" /><div id="cp_mpBG" style="background:#F9F9F9;position:absolute;display:none;"></div></td>
				</tr>
				<tr>
					<th><?php 
    _e('Color 1', 'flag');
    ?>
:</th>
					<td><input class="colorPick" type="text" size="7" maxlength="6" id="mpColor1" name="mpColor1" value="<?php 
    echo $flag_options['mpColor1'];
    ?>
" /><div id="cp_mpColor1" style="background:#F9F9F9;position:absolute;display:none;"></div></td>
				</tr>
				<tr>					
					<th><?php 
    _e('Color 2', 'flag');
    ?>
:</th>
					<td>
						<input class="colorPick" type="text" size="7" maxlength="6" id="mpColor2" name="mpColor2" value="<?php 
    echo $flag_options['mpColor2'];
    ?>
" /><div id="cp_mpColor2" style="background:#F9F9F9;position:absolute;display:none;"></div></td>
				</tr>
				<tr>
					<th><?php 
    _e('Autoplay', 'flag');
    ?>
:</th>
					<td>
						<label><input name="mpAutoplay" type="radio" value="true" <?php 
    checked('true', $flag_options['mpAutoplay']);
    ?>
 /> <?php 
    _e('True', 'flag');
    ?>
</label><br />
						<label><input name="mpAutoplay" type="radio" value="false" <?php 
    checked('false', $flag_options['mpAutoplay']);
    ?>
 /> <?php 
    _e('False', 'flag');
    ?>
</label><br />
					</td>
				</tr>
			</table>
			<div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php 
    _e('Save Changes', 'flag');
    ?>
"/></div>
		</form>
	</div>
	
<?php 
    if (flagGallery::flag_wpmu_enable_function('wpmuRoles')) {
        ?>
	<div id="roles" class="cptab">
		<form method="POST" name="addroles" id="addroles" accept-charset="utf-8">
			<?php 
        wp_nonce_field('flag_addroles');
        ?>
			<h2><?php 
        _e('Roles / capabilities', 'flag');
        ?>
</h2>
			<div>&nbsp;</div>
			<p><?php 
        _e('Select the lowest role which should be able to access the follow capabilities. Flash Album Gallery supports the standard roles from WordPress.', 'flag');
        ?>
</p>
			<table class="form-table"> 
			<tr valign="top"> 
				<th scope="row" style="white-space: nowrap"><?php 
        _e('Main Flash Album Gallery overview', 'flag');
        ?>
:</th> 
				<td><label for="general"><select style="width: 150px;" name="general" id="general"><?php 
        wp_dropdown_roles(flag_get_role('FlAG overview'));
        ?>
</select></label></td>
			</tr>
			<tr valign="top"> 
				<th scope="row" style="white-space: nowrap"><?php 
        _e('View TinyMCE Button / GRAND Pages', 'flag');
        ?>
:</th>
				<td><label for="tinymce"><select style="width: 150px;" name="tinymce" id="tinymce"><?php 
        wp_dropdown_roles(flag_get_role('FlAG Use TinyMCE'));
        ?>
</select></label></td>
			</tr>
			<tr valign="top"> 
				<th scope="row" style="white-space: nowrap"><?php 
        _e('Add gallery / Upload images', 'flag');
        ?>
:</th> 
				<td><label for="add_gallery"><select style="width: 150px;" name="add_gallery" id="add_gallery"><?php 
        wp_dropdown_roles(flag_get_role('FlAG Upload images'));
        ?>
</select></label></td>
			</tr>
			<tr valign="top"> 
				<th scope="row" style="white-space: nowrap"><?php 
        _e('Import images folder', 'flag');
        ?>
:</th> 
				<td><label for="add_gallery"><select style="width: 150px;" name="import_gallery" id="import_gallery"><?php 
        wp_dropdown_roles(flag_get_role('FlAG Import folder'));
        ?>
</select></label></td>
			</tr>
			<tr valign="top"> 
				<th scope="row" style="white-space: nowrap"><?php 
        _e('Manage gallery', 'flag');
        ?>
:</th> 
				<td><label for="manage_gallery"><select style="width: 150px;" name="manage_gallery" id="manage_gallery"><?php 
        wp_dropdown_roles(flag_get_role('FlAG Manage gallery'));
        ?>
</select></label></td>
			</tr>
			<tr valign="top"> 
				<th scope="row" style="white-space: nowrap"><?php 
        _e('Manage others galleries and Albums', 'flag');
        ?>
:</th>
				<td><label for="manage_others"><select style="width: 150px;" name="manage_others" id="manage_others"><?php 
        wp_dropdown_roles(flag_get_role('FlAG Manage others gallery'));
        ?>
</select></label></td>
			</tr>
			<tr valign="top"> 
				<th scope="row" style="white-space: nowrap"><?php 
        _e('Manage music', 'flag');
        ?>
:</th> 
				<td><label for="manage_music"><select style="width: 150px;" name="manage_music" id="manage_music"><?php 
        wp_dropdown_roles(flag_get_role('FlAG Manage music'));
        ?>
</select></label></td>
			</tr>
			<tr valign="top"> 
				<th scope="row" style="white-space: nowrap"><?php 
        _e('Manage video', 'flag');
        ?>
:</th> 
				<td><label for="manage_video"><select style="width: 150px;" name="manage_video" id="manage_video"><?php 
        wp_dropdown_roles(flag_get_role('FlAG Manage video'));
        ?>
</select></label></td>
			</tr>
			<tr valign="top"> 
				<th scope="row" style="white-space: nowrap"><?php 
        _e('Manage banners', 'flag');
        ?>
:</th> 
				<td><label for="manage_banners"><select style="width: 150px;" name="manage_banners" id="manage_banners"><?php 
        wp_dropdown_roles(flag_get_role('FlAG Manage banners'));
        ?>
</select></label></td>
			</tr>
			<tr valign="top"> 
				<th scope="row" style="white-space: nowrap"><?php 
        _e('Change skin', 'flag');
        ?>
:</th> 
				<td><label for="change_skin"><select style="width: 150px;" name="change_skin" id="change_skin"><?php 
        wp_dropdown_roles(flag_get_role('FlAG Change skin'));
        ?>
</select></label></td>
			</tr>
			<tr valign="top"> 
				<th scope="row" style="white-space: nowrap"><?php 
        _e('Add skins', 'flag');
        ?>
:</th> 
				<td><label for="add_skins"><select style="width: 150px;" name="add_skins" id="add_skins"><?php 
        wp_dropdown_roles(flag_get_role('FlAG Add skins'));
        ?>
</select></label></td>
			</tr>
			<tr valign="top"> 
				<th scope="row" style="white-space: nowrap"><?php 
        _e('Delete skins', 'flag');
        ?>
:</th> 
				<td><label for="delete_skins"><select style="width: 150px;" name="delete_skins" id="delete_skins"><?php 
        wp_dropdown_roles(flag_get_role('FlAG Delete skins'));
        ?>
</select></label></td>
			</tr>
			<tr valign="top"> 
				<th scope="row" style="white-space: nowrap"><?php 
        _e('Change options', 'flag');
        ?>
:</th> 
				<td><label for="change_options"><select style="width: 150px;" name="change_options" id="change_options"><?php 
        wp_dropdown_roles(flag_get_role('FlAG Change options'));
        ?>
</select></label></td>
			</tr>
			<tr valign="top"> 
				<th scope="row" style="white-space: nowrap"><?php 
        _e('iFrame page', 'flag');
        ?>
:</th>
				<td><label for="flagframe_page"><select style="width: 150px;" name="flagframe_page" id="flagframe_page"><?php 
        wp_dropdown_roles(flag_get_role('FlAG iFrame page'));
        ?>
</select></label></td>
			</tr>
			</table>
			<div class="submit"><input type="submit" class="button-primary" name= "update_cap" value="<?php 
        _e('Update capabilities', 'flag');
        ?>
"/></div>
		</form>
	</div>
<?php 
    }
    ?>
</div>
<script type="text/javascript">
	var cptabs=new ddtabcontent("tabs");
	cptabs.setpersist(true);
	cptabs.setselectedClassTarget("linkparent");
	cptabs.init();
</script>

	<?php 
}
Exemplo n.º 22
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 
}
Exemplo n.º 23
0
function flag_picturelist()
{
    // *** show picture list
    global $wpdb, $flagdb, $user_ID, $flag;
    // Look if its a search result
    $is_search = isset($_GET['s']) ? true : false;
    if ($is_search) {
        // fetch the imagelist
        $picturelist = $flag->manage_page->search_result;
        // we didn't set a gallery or a pagination
        $act_gid = 0;
        $_GET['paged'] = 1;
        $page_links = false;
    } else {
        // GET variables
        $act_gid = $flag->manage_page->gid;
        // Load the gallery metadata
        $gallery = $flagdb->find_gallery($act_gid);
        if (!$gallery) {
            flagGallery::show_error(__('Gallery not found.', 'flash-album-gallery'));
            return;
        }
        // Check if you have the correct capability
        if (!flagAdmin::can_manage_this_gallery($gallery->author)) {
            flagGallery::show_error(__('Sorry, you have no access here', 'flash-album-gallery'));
            return;
        }
        // look for pagination
        if (!isset($_GET['paged']) || intval($_GET['paged']) < 1) {
            $_GET['paged'] = 1;
        }
        $_GET['paged'] = intval($_GET['paged']);
        $start = ($_GET['paged'] - 1) * 50;
        // get picture values
        $picturelist = $flagdb->get_gallery($act_gid, $flag->options['galSort'], $flag->options['galSortDir'], false, 50, $start);
        // build pagination
        $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']));
        // get the current author
        $act_author_user = get_userdata((int) $gallery->author);
    }
    // list all galleries
    $gallerylist = $flagdb->find_all_galleries();
    //get the columns
    $gallery_columns = flag_manage_gallery_columns();
    $hidden_columns = get_hidden_columns('flag-manage-images');
    $hidden_columns = array_filter($hidden_columns);
    if ($picturelist) {
        $a_hits = array();
        foreach ($picturelist as $p) {
            $a_hits[] = $p->hitcounter;
        }
        if (!array_sum($a_hits)) {
            $hidden_columns[] = 'views_likes';
            $hidden_columns[] = 'rating';
        }
    } else {
        $hidden_columns[] = 'views_likes';
        $hidden_columns[] = 'rating';
    }
    $num_columns = count($gallery_columns) - count($hidden_columns);
    ?>
<!--[if lt IE 8]>
	<style type="text/css">
		.custom_thumb {
			display : none;
		}
	</style>
<![endif]-->

<script type="text/javascript"> 
//<![CDATA[
function showDialog( windowId, height ) {
	var form = document.getElementById('updategallery');
	var elementlist = "";
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].name == "doaction[]")
				if(form.elements[i].checked == true)
					if (elementlist == "")
						elementlist = form.elements[i].value;
					else
						elementlist += "," + form.elements[i].value ;
		}
	}
	jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val());
	jQuery("#" + windowId + "_imagelist").val(elementlist);
	// console.log (jQuery("#TB_imagelist").val());
	tb_show("", "#TB_inline?width=640&height=" + height + "&inlineId=" + windowId + "&modal=true", false);
}

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

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

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

	var numchecked = getNumChecked(document.getElementById('updategallery'));
	 
	if(numchecked < 1) { 
		alert('<?php 
    echo esc_js(__("No images selected", "flash-album-gallery"));
    ?>
');
		return false; 
	} 
	
	actionId = jQuery('#bulkaction').val();
	
	switch (actionId) {
		case "copy_to":
		case "move_to":
			showDialog('selectgallery', 120);
			return false;
			break;
		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 images \n \n 'Cancel' to stop, 'OK' to proceed.", 'flash-album-gallery')), "' + numchecked + '");
    ?>
');
}

jQuery(document).ready( function() {
	// close postboxes that should be closed
	jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
	postboxes.add_postbox_toggles('flag-manage-gallery'); 

});
//]]>
</script>

<div class="flag-wrap">

<?php 
    if ($is_search) {
        ?>
<h2><?php 
        printf(__('Search results for &#8220;%s&#8221;', 'flash-album-gallery'), esc_html(stripslashes(get_search_query())));
        ?>
</h2>
<form class="search-form" action="" method="get">
<p class="search-box">
	<label class="hidden" for="media-search-input"><?php 
        _e('Search Images', 'flash-album-gallery');
        ?>
:</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', 'flash-album-gallery');
        ?>
" class="button" />
</p>
</form>

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

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

<?php 
    } else {
        ?>

<h2><?php 
        echo _n('Gallery', 'Galleries', 1, 'flash-album-gallery');
        ?>
 : <?php 
        echo esc_html($gallery->title);
        ?>
</h2>
<select name="select_gid" style="width:180px; float: right; margin: -20px 3px 0 0;" onchange="window.location.href=this.options[this.selectedIndex].value">
	<option selected="selected"><?php 
        _e('Choose another gallery', 'flash-album-gallery');
        ?>
</option>
<?php 
        foreach ($gallerylist as $gal) {
            if ($gal->gid != $act_gid) {
                ?>
	<option value="<?php 
                echo wp_nonce_url($flag->manage_page->base_page . "&amp;mode=edit&amp;gid=" . $gal->gid, 'flag_editgallery');
                ?>
" ><?php 
                if ($flag->options['albSort'] == 'gid') {
                    echo $gal->gid . ' - ';
                }
                echo esc_html(stripslashes($gal->title));
                if ($flag->options['albSort'] == 'title') {
                    echo ' (' . $gal->gid . ')';
                }
                ?>
</option>
<?php 
            }
        }
        ?>
</select>

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

<div id="poststuff" class="metabox-holder">
	<?php 
        wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
        ?>
<div id="post-body"><div id="post-body-content"><div id="normal-sortables" class="meta-box-sortables ui-sortable" style="position: relative;">
	<div id="flagalleryset" class="postbox <?php 
        echo postbox_classes('flagalleryset', 'flag-manage-gallery');
        ?>
" >
		<div class="handlediv" title="Click to toggle"><br/></div>
		<h3 class="hndle"><span><?php 
        _e('Gallery settings', 'flash-album-gallery');
        ?>
</span></h3>
		<div class="inside">
			<table class="flag-form-table" >
				<tr>
					<th align="right" scope="row"><?php 
        _e('Title', 'flash-album-gallery');
        ?>
:</th>
					<td> </td>
					<td align="left"><input type="text" size="50" name="title" value="<?php 
        echo esc_html($gallery->title);
        ?>
"  /></td>
				</tr>
				<tr>
					<th align="right" valign="top" scope="row"><?php 
        _e('Description', 'flash-album-gallery');
        ?>
:</th>
					<td> </td>
					<td align="left"><textarea name="gallerydesc" cols="30" rows="3" style="width: 95%" ><?php 
        echo esc_html($gallery->galdesc);
        ?>
</textarea></td>
				</tr>
				<tr>
					<th align="right" scope="row"><?php 
        _e('Path', 'flash-album-gallery');
        ?>
:</th>
					<td> </td>
					<td align="left"><input <?php 
        if (IS_WPMU) {
            echo 'readonly = "readonly"';
        }
        ?>
 type="text" size="50" name="path" value="<?php 
        echo esc_attr($gallery->path);
        ?>
"  /></td>
				</tr>
				<tr>
					<th align="right" scope="row"><?php 
        _e('Author', 'flash-album-gallery');
        ?>
:</th>
					<td> </td>
					<td align="left">
					<?php 
        $editable_ids = $flag->manage_page->get_editable_user_ids($user_ID);
        if ($editable_ids && count($editable_ids) > 1) {
            wp_dropdown_users(array('include' => $editable_ids, 'name' => 'author', 'selected' => empty($gallery->author) ? 0 : $gallery->author));
        } else {
            echo $act_author_user->display_name;
        }
        ?>
						<input type="hidden" name="previewpic" value="<?php 
        if (is_array($picturelist)) {
            echo $picturelist[0]->pid;
        }
        ?>
" />
					</td>
				</tr>
			</table>
			
			<div class="submit">
				<input type="submit" class="button-secondary" name="scanfolder" value="<?php 
        _e("Scan Folder for new images", 'flash-album-gallery');
        ?>
 " />
				<input type="submit" class="button-primary action" name="updatepictures" value="<?php 
        _e("Save Changes", 'flash-album-gallery');
        ?>
" />
			</div>
			<div class="clear"></div>
		</div>
	</div>
</div></div></div>
</div> <!-- poststuff -->
<?php 
    }
    ?>

<div class="tablenav flag-tablenav">
	<?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) * $flagdb->paged['objects_per_page'] + 1), number_format_i18n(min($_GET['paged'] * $flagdb->paged['objects_per_page'], $flagdb->paged['total_objects'])), number_format_i18n($flagdb->paged['total_objects']), $page_links);
        echo $page_links_text;
        ?>
</div>
	<?php 
    }
    ?>
	<div class="alignleft actions">
	<select id="bulkaction" name="bulkaction" class="alignleft">
		<option value="no_action" ><?php 
    _e("No action", 'flash-album-gallery');
    ?>
</option>
		<option value="webview_images" ><?php 
    _e("Create images optimized for web", 'flash-album-gallery');
    ?>
</option>
		<option value="new_thumbnail" ><?php 
    _e("Create new thumbnails", 'flash-album-gallery');
    ?>
</option>
		<option value="resize_images" ><?php 
    _e("Resize images", 'flash-album-gallery');
    ?>
</option>
		<option value="delete_images" ><?php 
    _e("Delete images", 'flash-album-gallery');
    ?>
</option>
		<option value="import_meta" ><?php 
    _e("Import metadata", 'flash-album-gallery');
    ?>
</option>
		<option value="copy_meta" ><?php 
    _e("Metadata to description", 'flash-album-gallery');
    ?>
</option>
		<option value="copy_to" ><?php 
    _e("Copy to...", 'flash-album-gallery');
    ?>
</option>
		<option value="move_to"><?php 
    _e("Move to...", 'flash-album-gallery');
    ?>
</option>
		<option value="reset_counters"><?php 
    _e("Reset Views & Likes counters", 'flash-album-gallery');
    ?>
</option>
		<?php 
    do_action('flag_manage_images_bulkaction');
    ?>
	</select>
	<input class="button-secondary alignleft" style="margin-right:10px;" type="submit" name="showThickbox" value="<?php 
    _e("OK", 'flash-album-gallery');
    ?>
" onclick="if ( !checkSelected() ) return false;" />
	
<?php 
    if ($flag->options['galSort'] == "sortorder" && !$is_search) {
        ?>
	<a href="<?php 
        echo wp_nonce_url($flag->manage_page->base_page . "&amp;mode=sort&amp;gid=" . $act_gid, 'flag_sortgallery');
        ?>
" class="button-secondary alignleft" style="margin:1px 10px 0 0;"><?php 
        _e("Sort gallery", 'flash-album-gallery');
        ?>
</a>
<?php 
    }
    if (current_user_can('FlAG Upload images') && !$is_search) {
        ?>
	<a href="<?php 
        echo wp_nonce_url($flag->manage_page->base_page . "&amp;gid=" . $act_gid . "&amp;tabs=1", 'flag_addimages');
        ?>
" class="button-secondary alignleft" style="margin:1px 10px 0 0;"><?php 
        _e("Add Images", 'flash-album-gallery');
        ?>
</a>
<?php 
    }
    ?>
	<input type="submit" name="updatepictures" class="button-primary action alignleft"  value="<?php 
    _e("Save Changes", 'flash-album-gallery');
    ?>
" />
	</div>
</div>

<table id="flag-listimages" class="widefat fixed flag-table" cellspacing="0" >

	<thead>
	<tr>
<?php 
    foreach ($gallery_columns as $key => $value) {
        if (in_array($key, $hidden_columns)) {
            continue;
        }
        echo $cols = '<th class="manage-column column-' . $key . '">' . $value . '</td>';
    }
    ?>
	</tr>
	</thead>
	<tfoot>
	<tr>
<?php 
    foreach ($gallery_columns as $key => $value) {
        if (in_array($key, $hidden_columns)) {
            continue;
        }
        if ($key == 'cb') {
            $value = '';
        }
        echo $cols = '<th class="manage-column column-' . $key . '">' . $value . '</td>';
    }
    ?>
	</tr>
	</tfoot>
	<tbody>
<?php 
    $counter = 0;
    if ($picturelist) {
        $rt = array(24.5, 45.7, 54.8, 59.3, 64.7, 68.90000000000001, 71.5, 73.7, 75.90000000000001, 77.09999999999999);
        foreach ($picturelist as $picture) {
            //for search result we need to check the capatibiliy
            if (!flagAdmin::can_manage_this_gallery($picture->author) && $is_search) {
                continue;
            }
            $hits = intval($picture->hitcounter);
            $votes = intval($picture->total_votes);
            $counter++;
            $pid = (int) $picture->pid;
            $alternate = !isset($alternate) || $alternate == 'alternate' ? '' : 'alternate';
            $exclude = $picture->exclude ? 'checked="checked"' : '';
            $date = mysql2date(get_option('date_format'), $picture->imagedate);
            $time = mysql2date(get_option('time_format'), $picture->imagedate);
            ?>
		<tr id="picture-<?php 
            echo $pid;
            ?>
" class="<?php 
            echo $alternate;
            ?>
 iedit"  valign="top">
			<?php 
            foreach ($gallery_columns as $gallery_column_key => $column_display_name) {
                $class = "class=\"{$gallery_column_key} column-{$gallery_column_key}\"";
                $style = '';
                if (in_array($gallery_column_key, $hidden_columns)) {
                    continue;
                }
                $attributes = "{$class}{$style}";
                switch ($gallery_column_key) {
                    case 'cb':
                        ?>
 
						<th <?php 
                        echo $attributes;
                        ?>
 scope="row"><input name="doaction[]" type="checkbox" value="<?php 
                        echo $pid;
                        ?>
" /></th>
						<?php 
                        break;
                    case 'id':
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $pid;
                        ?>
							<input type="hidden" name="pid[]" value="<?php 
                        echo $pid;
                        ?>
" />
						</td>
						<?php 
                        break;
                    case 'thumbnail':
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
><a href="<?php 
                        echo $picture->imageURL;
                        ?>
" class="thickbox" title="<?php 
                        echo $picture->filename;
                        ?>
">
								<img class="thumb" src="<?php 
                        echo $picture->thumbURL;
                        ?>
" id="thumb-<?php 
                        echo $pid;
                        ?>
" />
							</a>
						</td>
						<?php 
                        break;
                    case 'filename':
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
>
							<strong><a href="<?php 
                        echo $picture->imageURL;
                        ?>
" class="thickbox" title="<?php 
                        echo $picture->filename;
                        ?>
">
								<?php 
                        echo $picture->filename;
                        ?>
							</a></strong>
							<br /><?php 
                        echo $date;
                        ?>
							<?php 
                        if (!empty($picture->meta_data['width'])) {
                            echo '<br />' . __('Image size: ', 'flash-album-gallery') . $picture->meta_data['width'] . 'x' . $picture->meta_data['height'];
                        } else {
                            $imgpath = WINABSPATH . $picture->path . "/" . $picture->filename;
                            $img = @getimagesize($imgpath);
                            if ($img) {
                                echo '<br />' . __('Image size: ', 'flash-album-gallery') . $img[0] . 'x' . $img[1];
                            }
                        }
                        ?>
							<?php 
                        if (!empty($picture->meta_data['thumbnail'])) {
                            echo '<br />' . __('Thumbnail size: ', 'flash-album-gallery') . $picture->meta_data['thumbnail']['width'] . 'x' . $picture->meta_data['thumbnail']['height'];
                        }
                        ?>
							<?php 
                        if (!empty($picture->meta_data['webview'])) {
                            echo '<br />' . __('Optimized size: ', 'flash-album-gallery') . $picture->meta_data['webview'][0] . 'x' . $picture->meta_data['webview'][1];
                        } else {
                            echo '<br />' . __('Optimized size: ', 'flash-album-gallery') . __('not optimized ', 'flash-album-gallery');
                        }
                        ?>
							<p>
							<?php 
                        $actions = array();
                        $actions['view'] = '<a class="thickbox" href="' . $picture->imageURL . '" title="' . esc_attr(sprintf(__('View "%s"'), $picture->filename)) . '">' . __('View', 'flash-album-gallery') . '</a>';
                        $actions['meta'] = '<a class="thickbox" href="' . FLAG_URLPATH . 'admin/showmeta.php?id=' . $pid . '" title="' . __('Show Meta data', 'flash-album-gallery') . '">' . __('Meta', 'flash-album-gallery') . '</a>';
                        $actions['custom_thumb'] = '<a class="thickbox" href="' . FLAG_URLPATH . 'admin/manage_thumbnail.php?id=' . $pid . '" title="' . __('Customize thumbnail', 'flash-album-gallery') . '">' . __('Edit thumb', 'flash-album-gallery') . '</a>';
                        $actions['delete'] = '<a class="submitdelete" href="' . wp_nonce_url("admin.php?page=flag-manage-gallery&amp;mode=delpic&amp;gid=" . $act_gid . "&amp;pid=" . $pid, 'flag_delpicture') . '" class="delete column-delete" onclick="javascript:check=confirm( \'' . esc_attr(sprintf(__('Delete "%s"', 'flash-album-gallery'), $picture->filename)) . '\');if(check==false) return false;">' . __('Delete', 'flash-album-gallery') . '</a>';
                        $action_count = count($actions);
                        $i = 0;
                        echo '<div class="row-actions">';
                        foreach ($actions as $action => $link) {
                            ++$i;
                            $i == $action_count ? $sep = '' : ($sep = ' | ');
                            echo "<span class='{$action}'>{$link}{$sep}</span>";
                        }
                        echo '</div>';
                        ?>
</p>
						</td>
						<?php 
                        break;
                    case 'views_likes':
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
>
							<input name="hitcounter[<?php 
                        echo $pid;
                        ?>
]" type="text" value="<?php 
                        echo stripslashes($picture->hitcounter);
                        ?>
" /> /
							<input name="total_votes[<?php 
                        echo $pid;
                        ?>
]" type="text" value="<?php 
                        echo stripslashes($picture->total_votes);
                        ?>
" />
						</td>
						<?php 
                        break;
                    case 'rating':
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
>
							<?php 
                        if ($votes == 0) {
                            $like = '0.0';
                        } else {
                            if ($votes < 11) {
                                $like = $rt[$votes - 1];
                            } else {
                                $like = round((100 - $rt[count($rt) - 1]) / ($hits > 0 ? $hits : 1) * ($votes <= $hits ? $votes : $hits), 1) + $rt[count($rt) - 1];
                            }
                        }
                        echo $like . '%';
                        ?>
						</td>
						<?php 
                        break;
                    case 'alt_title_desc':
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
>
							<input name="alttext[<?php 
                        echo $pid;
                        ?>
]" type="text" style="width:95%; margin-bottom: 2px;" value="<?php 
                        echo esc_html(stripslashes($picture->alttext));
                        ?>
" /><br/>
							<textarea name="description[<?php 
                        echo $pid;
                        ?>
]" style="width:95%; margin-top: 2px;" rows="2" ><?php 
                        echo esc_html(stripslashes($picture->description));
                        ?>
</textarea>
							<input name="link[<?php 
                        echo $pid;
                        ?>
]" type="text" style="width:95%; margin-bottom: 2px;" value="<?php 
                        echo esc_attr(stripslashes($picture->link));
                        ?>
" placeholder="(optional for skin) URL for linked button" /><br/>
						</td>
						<?php 
                        break;
                    case 'exclude':
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
><input name="exclude[<?php 
                        echo $pid;
                        ?>
]" type="checkbox" value="1" <?php 
                        echo $exclude;
                        ?>
 /></td>
						<?php 
                        break;
                        /* 
                        case 'views' :
                        						?>
                        						<td <?php echo $attributes; ?>><?php echo $picture->hitcounter; ?></td>
                        						<?php						
                        					break;
                        */
                    /* 
                    case 'views' :
                    						?>
                    						<td <?php echo $attributes; ?>><?php echo $picture->hitcounter; ?></td>
                    						<?php						
                    					break;
                    */
                    default:
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        do_action('flag_manage_gallery_custom_column', $gallery_column_key, $pid);
                        ?>
</td>
						<?php 
                        break;
                }
                ?>
			<?php 
            }
            ?>
		</tr>
		<?php 
        }
    }
    // In the case you have no capaptibility to see the search result
    if ($counter == 0) {
        echo '<tr><td colspan="' . $num_columns . '" align="center"><strong>' . __('No entries found', 'flash-album-gallery') . '</strong></td></tr>';
    }
    ?>
	
		</tbody>
	</table>
	<p class="submit"><input type="submit" class="button-primary action" name="updatepictures" value="<?php 
    _e("Save Changes", 'flash-album-gallery');
    ?>
" /></p>
	</form>	
	<br class="clear"/>
	</div><!-- /#wrap -->

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

	<!-- #resize_images -->
	<div id="resize_images" style="display: none;" >
		<form id="form-resize-images" method="POST" action="<?php 
    echo admin_url('admin.php?page=flag-manage-gallery&mode=edit&gid=' . $act_gid . '&paged=1');
    ?>
" 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-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<td>
					<strong><?php 
    _e('Resize Images to', 'flash-album-gallery');
    ?>
:</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). Grand Flagallery will keep ratio size', 'flash-album-gallery');
    ?>
</small>
				</td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php 
    _e('OK', 'flash-album-gallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'flash-album-gallery');
    ?>
&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" action="<?php 
    echo admin_url('admin.php?page=flag-manage-gallery&mode=edit&gid=' . $act_gid . '&paged=1');
    ?>
" 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-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<th align="left"><?php 
    _e('Width x height (in pixel)', 'flash-album-gallery');
    ?>
</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 ', 'flash-album-gallery');
    ?>
</small></td>
			</tr>
			<tr valign="top">
				<th align="left"><?php 
    _e('Set fix dimension', 'flash-album-gallery');
    ?>
</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', 'flash-album-gallery');
    ?>
</small></td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php 
    _e('OK', 'flash-album-gallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'flash-album-gallery');
    ?>
&nbsp;" onclick="tb_remove()"/>
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#new_thumbnail -->	

	<script type="text/javascript">
	/* <![CDATA[ */
	jQuery(document).ready(function(){columns.init('flag-manage-images');});	
	/* ]]> */
	</script>
	<?php 
}
Exemplo n.º 24
0
 function grandmp3($atts)
 {
     global $wpdb;
     extract(shortcode_atts(array('id' => '', 'autoplay' => 'false'), $atts));
     $out = '';
     $flag_options = get_option('flag_options');
     if ($id) {
         $url = wp_get_attachment_url($id);
         $url = str_replace(array('.mp3'), array(''), $url);
         if (!flagGallery::getUserNow($_SERVER['HTTP_USER_AGENT'])) {
             $out = '<script type="text/javascript">swfobject.embedSWF("' . plugins_url('/lib/mini.swf', dirname(__FILE__)) . '", "c-' . $id . '", "250", "20", "10.1.52", "expressInstall.swf", {path:"' . $url . '",bgcolor:"' . $flag_options["mpBG"] . '",color1:"' . $flag_options["mpColor1"] . '",color2:"' . $flag_options["mpColor2"] . '",autoplay:"' . $autoplay . '"}, {wmode:"transparent"}, {id:"f-' . $id . '",name:"f-' . $id . '"});</script>';
         }
         $out .= '<div id="c-' . $id . '" class="grandmp3"><audio src="' . $url . '.mp3" controls preload="none" autobuffer="false"></audio></div>';
     }
     return $out;
 }
Exemplo n.º 25
0
 function post_processor_images()
 {
     global $wpdb, $flag, $flagdb;
     do_action('flag_manage_post_processor_images');
     // bulk update in a single gallery
     if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) {
         check_admin_referer('flag_updategallery');
         switch ($_POST['bulkaction']) {
             case 'no_action':
                 break;
             case 'delete_images':
                 if (is_array($_POST['doaction'])) {
                     $delete_pic = false;
                     foreach ($_POST['doaction'] as $imageID) {
                         $image = $flagdb->find_image($imageID);
                         if ($image) {
                             if ($flag->options['deleteImg']) {
                                 @unlink($image->imagePath);
                                 @unlink($image->webimagePath);
                                 @unlink($image->thumbPath);
                             }
                             $delete_pic = flagdb::delete_image($image->pid);
                         }
                     }
                     if ($delete_pic) {
                         flagGallery::show_message(__('Pictures deleted successfully ', 'flash-album-gallery'));
                     }
                 }
                 break;
             case 'import_meta':
                 flagAdmin::do_ajax_operation('import_metadata', $_POST['doaction'], __('Import metadata', 'flash-album-gallery'));
                 break;
             case 'copy_meta':
                 flagAdmin::do_ajax_operation('copy_metadata', $_POST['doaction'], __('Copy metadata to image Description', 'flash-album-gallery'));
                 break;
             case 'webview_images':
                 flagAdmin::do_ajax_operation('webview_image', $_POST['doaction'], __('Creating images optimized for web', 'flash-album-gallery'));
                 break;
             case 'reset_counters':
                 if (is_array($_POST['doaction'])) {
                     $images = $flagdb->find_images_in_list($_POST['doaction']);
                     foreach ($images as $image) {
                         $img_id = $image->pid;
                         $wpdb->query("UPDATE {$wpdb->flagpictures} SET hitcounter = '0', total_votes = '0' WHERE pid = {$img_id}");
                     }
                 }
                 break;
         }
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_ResizeImages'])) {
         check_admin_referer('flag_thickbox_form');
         //save the new values for the next operation
         $flag->options['imgWidth'] = (int) $_POST['imgWidth'];
         $flag->options['imgHeight'] = (int) $_POST['imgHeight'];
         update_option('flag_options', $flag->options);
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         flagAdmin::do_ajax_operation('resize_image', $pic_ids, __('Resize images', 'flash-album-gallery'));
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_NewThumbnail'])) {
         check_admin_referer('flag_thickbox_form');
         //save the new values for the next operation
         $flag->options['thumbWidth'] = (int) $_POST['thumbWidth'];
         $flag->options['thumbHeight'] = (int) $_POST['thumbHeight'];
         $flag->options['thumbFix'] = (bool) $_POST['thumbFix'];
         update_option('flag_options', $flag->options);
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         flagAdmin::do_ajax_operation('create_thumbnail', $pic_ids, __('Create new thumbnails', 'flash-album-gallery'));
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_SelectGallery'])) {
         check_admin_referer('flag_thickbox_form');
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         $pic_ids = array_filter($pic_ids, 'intval');
         $dest_gid = (int) $_POST['dest_gid'];
         switch ($_POST['TB_bulkaction']) {
             case 'copy_to':
                 // Copy images
                 flagAdmin::copy_images($pic_ids, $dest_gid);
                 break;
             case 'move_to':
                 // Move images
                 flagAdmin::move_images($pic_ids, $dest_gid);
                 break;
         }
     }
     if (isset($_POST['updatepictures'])) {
         // Update pictures
         check_admin_referer('flag_updategallery');
         $gallery_title = esc_html($_POST['title']);
         $gallery_path = esc_attr(str_replace('..', '', $_POST['path']));
         $gallery_desc = esc_html($_POST['gallerydesc']);
         $gallery_preview = (int) $_POST['previewpic'];
         $wpdb->query("UPDATE {$wpdb->flaggallery} SET title= '{$gallery_title}', path= '{$gallery_path}', galdesc = '{$gallery_desc}', previewpic = '{$gallery_preview}' WHERE gid = '{$this->gid}'");
         if (isset($_POST['author'])) {
             $gallery_author = (int) $_POST['author'];
             $wpdb->query("UPDATE {$wpdb->flaggallery} SET author = '{$gallery_author}' WHERE gid = '{$this->gid}'");
         }
         $this->update_pictures();
         //hook for other plugin to update the fields
         do_action('flag_update_gallery', $this->gid, $_POST);
         flagGallery::show_message(__('Update successful', "flash-album-gallery"));
     }
     if (isset($_POST['scanfolder'])) {
         // Rescan folder
         check_admin_referer('flag_updategallery');
         $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->flaggallery} WHERE gid = '{$this->gid}' ");
         flagAdmin::import_gallery($gallerypath);
     }
 }
Exemplo n.º 26
0
if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
    die('You are not allowed to call this page directly.');
}
// check for correct capability
if (!is_user_logged_in()) {
    die('-1');
}
// check for correct FlAG capability
if (!current_user_can('FlAG Facebook page')) {
    die('-1');
}
if (isset($_POST['copy_file'])) {
    if (copy(FLAG_ABSPATH . 'facebook.php', ABSPATH . 'facebook.php')) {
        flagGallery::show_message(__('Success', 'flag'));
    } else {
        flagGallery::show_error(__('Failure', 'flag'));
    }
}
global $flag, $flagdb;
require_once dirname(__FILE__) . '/get_skin.php';
require_once dirname(__FILE__) . '/playlist.functions.php';
require_once dirname(__FILE__) . '/video.functions.php';
require_once dirname(__FILE__) . '/banner.functions.php';
$i_skins = get_skins();
$all_m_playlists = get_playlists();
$all_v_playlists = get_v_playlists();
$all_b_playlists = get_b_playlists();
$fb_url = FLAG_URLPATH . 'facebook.php';
if (file_exists(ABSPATH . 'facebook.php')) {
    $fb_url = home_url() . '/facebook.php';
}