function S2FilePicker_frame()
{
    media_upload_header();
    $path = WP_PLUGIN_DIR . '/s2member-files';
    $files = glob($path . '/*.{mp3,mp4,avi,mpeg,doc,docx,pdf,txt}', GLOB_BRACE);
    $html = '<form action="" id="s2member-files-archive-form">';
    foreach ($files as $i => $file) {
        $html .= '<input type="checkbox" data-filename="' . basename($file) . '" class="file" name="file[]" />';
        $html .= basename($file);
    }
    $html .= '
		<br />
		<br />
		<button type="button" onclick="javascript:s2member_files_pick();">' . esc_attr(__('Link selected files')) . '</button>
		<script>
		function s2member_files_pick() {
			jQuery("#s2member-files-archive-form").find("input[type=checkbox]:checked").each(function(index, el) {
				var $check = jQuery(el);
				parent.send_to_editor(\'[s2Link download="\' +$check.data("filename")+ \'" download_key="true" /]\');
			});
			
			parent.tb_remove();
		}
		</script>
	</form>
	';
    echo $html;
}
 function insert_media_upload()
 {
     global $wp_version;
     if ($wp_version < '2.6') {
         add_action('admin_head_middmedia_media_upload', 'media_admin_css');
     } else {
         wp_admin_css('media');
     }
     media_upload_header();
     return wp_iframe('middmedia_media_upload', $this);
 }
Example #3
0
function media_upload_crystal_form()
{
    global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types, $redir_tab;
    $redir_tab = 'crystal';
    media_upload_header();
    $post_id = intval($_REQUEST['post_id']);
    $form_action_url = admin_url("media-upload.php?type={$GLOBALS['type']}&tab=crystal&post_id={$post_id}");
    ?>
<script type="text/javascript">
<!--
jQuery(function($){
	var preloaded = $(".media-item.preloaded");
	if ( preloaded.length > 0 ) {
		preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
	}
	updateMediaForm();
});
-->
</script>
<form enctype="multipart/form-data" method="post" action="<?php 
    echo attribute_escape($form_action_url);
    ?>
" class="media-upload-form validate" id="gallery-form">
<div id="media-items">
<?php 
    echo get_media_items($post_id, $errors);
    ?>
</div>
<input type="submit" class="button" name="save" value="<?php 
    echo attribute_escape(__('Save all changes'));
    ?>
" />
<input type="submit" class="button" name="insert-gallery" value="<?php 
    echo attribute_escape(__('Insert Crystal gallery!'));
    ?>
" />
<input type="hidden" name="post_id" id="post_id" value="<?php 
    echo (int) $post_id;
    ?>
" />
<input type="hidden" name="type" value="<?php 
    echo attribute_escape($GLOBALS['type']);
    ?>
" />
<input type="hidden" name="tab" value="<?php 
    echo attribute_escape($GLOBALS['tab']);
    ?>
" />
</p>
</form>
<?php 
}
 function media_upload_gallery_form($errors)
 {
     global $redir_tab, $type;
     $redir_tab = 'gallery';
     media_upload_header();
     $post_id = intval($_REQUEST['post_id']);
     $form_action_url = admin_url("media-upload.php?type={$type}&tab=gallery&post_id={$post_id}");
     $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
     $form_class = 'media-upload-form validate';
     if (get_user_setting('uploader')) {
         $form_class .= ' html-uploader';
     }
     require_once dirname(__FILE__) . '/view/gallery_form.php';
 }
function upload_test_upload_form()
{
    //echos the tabs at the top of the media window
    media_upload_header();
    //Adds your javascript
    upload_test_scripts();
    ?>
	<div class="test-form">
		<input type='text' id='name' />
		<input id='insert_shortcode' type='button' class='button' value='Insert Shortcode'>
	</div> 	

<?php 
}
Example #6
0
function media_imgbedtab_form()
{
    $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
    $files = imgbed_get_files($post_id);
    media_upload_header();
    if (is_array($files) && count($files) > 0) {
        $msg = '点击图片添加到文章';
    } else {
        $msg = '还没有上传图片';
    }
    echo '<div style="margin-top:20px; margin:1em;"><h3 class="media-title">' . $msg . '</h3>';
    echo '<script type="text/javascript">imgbed_files = ' . json_encode($files, true) . '</script>';
    echo '<div id="media-tuku"></div></div>';
}
Example #7
0
function media_upload_flickr_form()
{
    global $type, $tab, $post_mime_types, $flickr_manager;
    add_filter('media_upload_tabs', array($flickr_manager, 'modifyMediaTab'));
    ?>
	
	<div id="media-upload-header">
		<?php 
    media_upload_header();
    ?>
	</div>
	
    <?php 
    flickrMediaBrowse();
}
function media_cincopabox_process()
{
    if (isset($_REQUEST['wrt'])) {
        _cpmp_media_upload_type_cincopa();
        return;
    }
    if (sizeof($_POST) > 0) {
        var_dump($_POST);
    }
    media_upload_header();
    ?>
    <iframe src="<?php 
    echo _cpmp_url() . '/media-platform/start.aspx?ver=' . _cpmp_plugin_ver() . '&rdt=' . urlencode(_cpmp_selfURL() . "&");
    ?>
&" width="100%" height="98%"></iframe>
    <?php 
}
/**
 * Modified From media_upload_type_form in WordPress 3.2.1 Core
 * {@internal Missing Short Description}}
 *
 * @since 2.5.0
 *
 * @param unknown_type $type
 * @param unknown_type $errors
 * @param unknown_type $id
 */
function media_upload_type_s2sfu($type = 'file', $errors = null, $id = null)
{
    media_upload_header();
    $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
    $form_action_url = admin_url("media-upload.php?type={$type}&tab=type&post_id={$post_id}");
    $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    ?>
	
	<form enctype="multipart/form-data" method="post" action="<?php 
    echo esc_attr($form_action_url);
    ?>
" class="media-upload-form type-form validate" id="<?php 
    echo $type;
    ?>
-form">
	<?php 
    submit_button('', 'hidden', 'save', false);
    ?>
	<input type="hidden" name="post_id" id="post_id" value="<?php 
    echo (int) $post_id;
    ?>
" />
	<?php 
    wp_nonce_field('media-form');
    ?>
	
	<h3 class="media-title"><?php 
    _e('Add media files from your computer');
    ?>
</h3>
	
	<?php 
    s2sfu_media_upload_form($errors);
    ?>
	
	</form>
	<?php 
}
/**
 * Download the picture selected, associate it to the post and displays the 
 * final form using get_media_item()
 *
 * @param noting.
 * @return noting.
 **/
function media_pac_pickapic_final_form()
{
    global $type, $wp_version;
    $post_id = absint($_REQUEST['post_id']);
    $form_action_url = admin_url("media-upload.php?type={$type}&tab=pickapictab&post_id={$post_id}");
    $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    media_upload_header();
    $flickr_info = pac_pickapic_flickr_getInfo($_POST['pac_pickapic_flickr_id']);
    $photo_url = pac_pickapic_flickr_getSizes($_POST['pac_pickapic_flickr_id']);
    if (is_wp_error($photo_url)) {
        pac_pickapic_show_error($rsp_obj);
        return;
    }
    ?>
    <form id="pickapic-media-form" enctype="multipart/form-data" action="<?php 
    echo esc_html($form_action_url);
    ?>
" class="media-upload-form type-form validate" method="post">
        <?php 
    wp_nonce_field('media-form');
    ?>

        <div id="media-items">
            <?php 
    if (version_compare($wp_version, '3.4', '<')) {
        $excerpt = __('Foto: ' . $flickr_info['owner'], 'pickapic');
    } else {
        $excerpt = __('Foto: ', 'pickapic') . "<a href='" . $flickr_info['url'] . "' target='_blank'>" . $flickr_info['owner'] . "</a>";
        $show_license = pac_pickapic_get_option('flickrshowlicense');
        if ($show_license) {
            $flickr_licenses = unserialize(PICKAPIC_FLICKR_LICENSES);
            $excerpt .= ' - ' . $flickr_licenses[$flickr_info['license']];
        }
    }
    $attachment_id = pac_pickapic_media_sideload_image($photo_url, $post_id, '', array('post_title' => __($flickr_info['title'], 'pickapic'), 'post_excerpt' => $excerpt), $flickr_info['url'], $flickr_info['owner']);
    if (is_wp_error($attachment_id)) {
        echo '<div id="media-upload-error">' . esc_html($attachment_id->get_error_message()) . '</div></div>';
    } else {
        // Render the form content using get_media_item
        $args = array('toggle' => false, 'show_title' => true);
        echo get_media_item($attachment_id, $args);
    }
    ?>
        </div>
    </form>
    <?php 
}
Example #11
0
 function thickboxInclude()
 {
     $pages = array('ecordia-score', 'ecordia-keyword-analysis', 'ecordia-change-keywords', 'ecordia-tags', 'ecordia-serp', 'ecordia-seo-best-practices', 'ecordia-error');
     if (defined('ECORDIA_DEBUG') && ECORDIA_DEBUG) {
         $pages[] = 'ecordia-debug';
     }
     $tab = in_array($_GET['tab'], $pages) ? $_GET['tab'] : 'ecordia-score';
     $page = str_replace('ecordia-', '', $tab);
     if (false === strpos($tab, 'error')) {
         add_filter('media_upload_tabs', array(&$this, 'thickboxTabs'));
         media_upload_header();
     }
     $info = $this->getSeoInfoForPost($_GET['post']);
     if (false === $info && false === strpos($tab, 'error')) {
         print '<form><p>No analysis present.</p></form>';
         return;
     }
     include 'views/popup/' . $page . '.php';
 }
    /**
     * {@internal Missing Short Description}}
     *
     * @since 2.5.0
     *
     * @param unknown_type $errors
     */
    function media_upload_shared_media($errors)
    {
        global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types, $blog_id;
        media_upload_header();
        if (count($this->blogs) == 0) {
            echo '<form><h3 class="media-title">' . __("You don't have access to any other sites media...", 'networksharedmedia') . '</h3></form>';
            return;
        }
        // set the first part of the form action url now, to the current active site, to prevent X-Frame-Options problems
        $form_action_url = plugins_url('media-upload.php', __FILE__);
        $nsm_blog_id = null;
        if (!array_key_exists('blog_id', $_GET)) {
            $_GET['blog_id'] = null;
        }
        foreach ($this->blogs as $blog) {
            if ($_GET['blog_id'] == $blog['blog_id']) {
                $nsm_blog_id = $blog['blog_id'];
                break;
            }
        }
        if (null == $nsm_blog_id) {
            $nsm_blog_id = $this->blogs[0]['blog_id'];
        }
        switch_to_blog($nsm_blog_id);
        ?>

<?php 
        $post_id = intval($_REQUEST['post_id']);
        // fix to make get_media_item add "Insert" button
        unset($_GET['post_id']);
        $form_action_url .= "?type={$type}&tab=library&post_id={$post_id}&blog_id={$blog_id}";
        $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
        $form_class = 'media-upload-form validate';
        $_GET['paged'] = isset($_GET['paged']) ? intval($_GET['paged']) : 0;
        if ($_GET['paged'] < 1) {
            $_GET['paged'] = 1;
        }
        $start = ($_GET['paged'] - 1) * 10;
        if ($start < 1) {
            $start = 0;
        }
        add_filter('post_limits', create_function('$a', "return 'LIMIT {$start}, 10';"));
        list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
        ?>
	
	<form id="filter" action="" method="get">
	<input type="hidden" name="type" value="<?php 
        echo esc_attr($type);
        ?>
" />
	<input type="hidden" name="tab" value="<?php 
        echo esc_attr($tab);
        ?>
" />
	<input type="hidden" name="post_id" value="<?php 
        echo (int) $post_id;
        ?>
" />
	<input type="hidden" name="blog_id" value="<?php 
        echo (int) $blog_id;
        ?>
" />
	<input type="hidden" name="post_mime_type" value="<?php 
        echo isset($_GET['post_mime_type']) ? esc_attr($_GET['post_mime_type']) : '';
        ?>
" />
	<?php 
        if (isset($_GET['chromeless'])) {
            ?>
	<input type="hidden" name="chromeless" value="<?php 
            echo (bool) $_GET['chromeless'];
            ?>
" />
	<?php 
        }
        ?>

	<style type="text/css">
		#media-upload #filter .nsm-site-select { float: none; width: 100%; margin: 0 1em 2em 1em; white-space: normal; }
	</style>

	<ul class="subsubsub nsm-site-select">
	<?php 
        if (count($this->blogs) == 1) {
            $blog = reset($this->blogs);
            echo "<li>" . __('Selected site:', 'networksharedmedia') . "</li>" . "<li><a href='" . esc_url(add_query_arg(array('blog_id' => $blog['blog_id'], 'paged' => false))) . "' class='current'>" . $blog['name'] . '</a>' . '</li>';
        } else {
            $all_blog_names = array();
            foreach ($this->blogs as $blog) {
                $all_blog_names[] = $blog['name'];
            }
            if (strlen(__('Select site:', 'networksharedmedia') . ' ' . implode(' | ', $all_blog_names)) < 71) {
                $blog_links = array();
                foreach ($this->blogs as $blog) {
                    $class = '';
                    if ($blog['blog_id'] == $blog_id) {
                        $class = ' class="current"';
                    }
                    $blog_links[] = "<li><a href='" . esc_url(add_query_arg(array('blog_id' => $blog['blog_id'], 'paged' => false))) . "'{$class}>" . $blog['name'] . '</a>';
                }
                echo "<li>" . __('Select site:', 'networksharedmedia') . " </li>" . implode(' | </li>', $blog_links) . '</li>';
                unset($blog_links);
            } else {
                $blog_options = array();
                foreach ($this->blogs as $blog) {
                    $selected = '';
                    if ($blog['blog_id'] == $blog_id) {
                        $selected = ' selected="selected"';
                    }
                    $blog_options[] = "<option value='{$blog['blog_id']}'{$selected}>" . $blog['name'] . '</option>';
                }
                echo "<li>" . __('Select site:', 'networksharedmedia') . "</li><li> <select name='blog_id'>" . implode('', $blog_options) . '</select></li><li> ' . get_submit_button(__('Select &#187;', 'networksharedmedia'), 'secondary', 'nsm-post-query-submit', false) . '</li>';
                unset($blog_options);
            }
            unset($all_blog_names);
        }
        ?>
	</ul>

	<p id="media-search" class="search-box">
		<label class="screen-reader-text" for="media-search-input"><?php 
        _e('Search Media');
        ?>
:</label>
		<input type="text" id="media-search-input" name="s" value="<?php 
        the_search_query();
        ?>
" />
		<?php 
        submit_button(__('Search Media'), 'button', '', false);
        ?>
	</p>
	
	<ul class="subsubsub">
	<?php 
        $type_links = array();
        $_num_posts = (array) wp_count_attachments();
        $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
        foreach ($matches as $_type => $reals) {
            foreach ($reals as $real) {
                if (isset($num_posts[$_type])) {
                    $num_posts[$_type] += $_num_posts[$real];
                } else {
                    $num_posts[$_type] = $_num_posts[$real];
                }
            }
        }
        // If available type specified by media button clicked, filter by that type
        if (empty($_GET['post_mime_type']) && !empty($num_posts[$type])) {
            $_GET['post_mime_type'] = $type;
            list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
        }
        if (empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all') {
            $class = ' class="current"';
        } else {
            $class = '';
        }
        $type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type' => 'all', 'paged' => false, 'm' => false))) . "'{$class}>" . __('All Types') . "</a>";
        foreach ($post_mime_types as $mime_type => $label) {
            $class = '';
            if (!wp_match_mime_types($mime_type, $avail_post_mime_types)) {
                continue;
            }
            if (isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type'])) {
                $class = ' class="current"';
            }
            $type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type' => $mime_type, 'paged' => false))) . "'{$class}>" . sprintf(translate_nooped_plural($label[2], $num_posts[$mime_type]), "<span id='{$mime_type}-counter'>" . number_format_i18n($num_posts[$mime_type]) . '</span>') . '</a>';
        }
        echo implode(' | </li>', apply_filters('media_upload_mime_type_links', $type_links)) . '</li>';
        unset($type_links);
        ?>
	</ul>
	
	<div class="tablenav">
	
	<?php 
        $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($wp_query->found_posts / 10), 'current' => $_GET['paged']));
        if ($page_links) {
            echo "<div class='tablenav-pages'>{$page_links}</div>";
        }
        ?>
	
	<div class="alignleft actions">
	<?php 
        $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM {$wpdb->posts} WHERE post_type = 'attachment' ORDER BY post_date DESC";
        $arc_result = $wpdb->get_results($arc_query);
        $month_count = count($arc_result);
        if ($month_count && !(1 == $month_count && 0 == $arc_result[0]->mmonth)) {
            ?>
	<select name='m'>
	<option<?php 
            selected(@$_GET['m'], 0);
            ?>
 value='0'><?php 
            _e('Show all dates');
            ?>
</option>
	<?php 
            foreach ($arc_result as $arc_row) {
                if ($arc_row->yyear == 0) {
                    continue;
                }
                $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
                if (isset($_GET['m']) && $arc_row->yyear . $arc_row->mmonth == $_GET['m']) {
                    $default = ' selected="selected"';
                } else {
                    $default = '';
                }
                echo "<option{$default} value='" . esc_attr($arc_row->yyear . $arc_row->mmonth) . "'>";
                echo esc_html($wp_locale->get_month($arc_row->mmonth) . " {$arc_row->yyear}");
                echo "</option>\n";
            }
            ?>
	</select>
	<?php 
        }
        ?>
	
	<?php 
        submit_button(__('Filter &#187;'), 'secondary', 'post-query-submit', false);
        ?>
	
	</div>
	
	<br class="clear" />
	</div>
	</form>
	
	<form enctype="multipart/form-data" method="post" action="<?php 
        echo esc_attr($form_action_url);
        ?>
" class="<?php 
        echo $form_class;
        ?>
" id="library-form">
	
	<?php 
        wp_nonce_field('media-form');
        ?>
	<?php 
        //media_upload_form( $errors );
        ?>

	<?php 
        if (isset($_GET['chromeless']) && $_GET['chromeless']) {
            // WP3.5+ Media Browser calls iframe 'chromeless' and handles inserting differently
            ?>
	<script type="text/javascript">
	/* <![CDATA[ */
	function nsm_media_send_to_editor(htmlString) {
		<?php 
            /* copied from /wp-admin/includes/media.php media_send_to_editor() */
            ?>
		var win = window.dialogArguments || opener || parent || top;
		win.send_to_editor(htmlString);
	}

	jQuery(function($){
		$('input[id^=send].button').click(function(event) {
			event.preventDefault();
			var $this = $(event.target);
			var form = $('#library-form');
			var result = $.ajax({
				url: form.attr('action'),
				type: form.attr('method'),
				data: form.serialize() + '&' + encodeURIComponent($this.attr('id') ) + '=true&chromeless=1',
				success: nsm_media_send_to_editor
			});
		});
	});
	/* ]]> */
	</script>
	<?php 
        }
        /* chromeless */
        ?>

	<script type="text/javascript">
	<!--
	jQuery(function($){
		var preloaded = $(".media-item.preloaded");
		if ( preloaded.length > 0 ) {
			preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
			updateMediaForm();
		}
	});
	-->
	</script>
	
	<div id="media-items">
	<?php 
        add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
        ?>
	<?php 
        echo $this->get_media_items(null, $errors);
        ?>
	</div>
	<p class="ml-submit"></p>
	</form>
	<?php 
    }
Example #13
0
    function popup_wp_upload($errors)
    {
        global $redir_tab, $type, $tab;
        $redir_tab = 'wp_upload';
        media_upload_header();
        $flash_action_url = admin_url('async-upload.php');
        // If Mac and mod_security, no Flash. :(
        $flash = true;
        /*
        	if(false !== stripos($_SERVER['HTTP_USER_AGENT'], 'mac') && apache_mod_loaded('mod_security')) {
                    $flash = false;
                }*/
        $flash = apply_filters('flash_uploader', $flash);
        $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
        $upload_size_unit = $max_upload_size = wp_max_upload_size();
        $sizes = array('KB', 'MB', 'GB');
        for ($u = -1; $upload_size_unit > 1024 && $u < count($sizes) - 1; $u++) {
            $upload_size_unit /= 1024;
        }
        if ($u < 0) {
            $upload_size_unit = 0;
            $u = 0;
        } else {
            $upload_size_unit = (int) $upload_size_unit;
        }
        echo $this->messages(true);
        ?>
        <div class="updated"><ul><li><?php 
        _e('Please update your WordPress to the latest version, in order to get the latest uploading system.', WYSIJA);
        ?>
</li></ul></div>
        <div id="overlay"><img id="loader" src="<?php 
        echo WYSIJA_URL;
        ?>
img/wpspin_light.gif" /></div>
        <div class="popup_content media-wp-upload">
            <script type="text/javascript">
            //<![CDATA[
            var uploaderMode = 0;
            jQuery(document).ready(function($){
                    uploaderMode = getUserSetting('uploader');
                    $('.upload-html-bypass a').click(function(){deleteUserSetting('uploader');uploaderMode=0;swfuploadPreLoad();return false;});
                    $('.upload-flash-bypass a').click(function(){setUserSetting('uploader', '1');uploaderMode=1;swfuploadPreLoad();return false;});
            });
            //]]>
            </script>

            <div id="media-upload-notice">
            <?php 
        if (isset($errors['upload_notice'])) {
            ?>
                    <?php 
            echo $errors['upload_notice'];
            ?>
            <?php 
        }
        ?>
            </div>
            <div id="media-upload-error">
            <?php 
        if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) {
            ?>
                    <?php 
            echo $errors['upload_error']->get_error_message();
            ?>
            <?php 
        }
        ?>
            </div>
            <?php 
        // Check quota for this blog if multisite
        if (is_multisite() && !is_upload_space_available()) {
            echo '<p>' . sprintf(__('Sorry, you have filled your storage quota (%s MB).'), get_space_allowed()) . '</p>';
            return;
        }
        do_action('pre-upload-ui');
        if ($flash) {
            ?>
            <script type="text/javascript">
            //<![CDATA[
            var swfu;
            SWFUpload.onload = function() {
                    var settings = {
                                    button_text: '<span class="button"><?php 
            _e('Select Files');
            ?>
<\/span>',
                                    button_text_style: '.button { text-align: center; font-weight: bold; font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; font-size: 11px; text-shadow: 0 1px 0 #FFFFFF; color:#464646; }',
                                    button_height: "23",
                                    button_width: "132",
                                    button_text_top_padding: 3,
                                    button_image_url: '<?php 
            echo includes_url('images/upload.png?ver=20100531');
            ?>
',
                                    button_placeholder_id: "flash-browse-button",
                                    upload_url : "<?php 
            echo esc_attr($flash_action_url);
            ?>
",
                                    flash_url : "<?php 
            echo includes_url() . 'js/swfupload/swfupload.swf';
            ?>
",
                                    file_post_name: "async-upload",
                                    file_types: "<?php 
            echo apply_filters('upload_file_glob', '*.*');
            ?>
",
                                    post_params : {
                                            "post_id" : "<?php 
            echo $post_id;
            ?>
",
                                            "auth_cookie" : "<?php 
            echo is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE];
            ?>
",
                                            "logged_in_cookie": "<?php 
            echo $_COOKIE[LOGGED_IN_COOKIE];
            ?>
",
                                            "_wpnonce" : "<?php 
            echo wp_create_nonce('media-form');
            ?>
",
                                            "type" : "<?php 
            echo $type;
            ?>
",
                                            "tab" : "<?php 
            echo $tab;
            ?>
",
                                            "short" : "1"
                                    },
                                    file_size_limit : "<?php 
            echo $max_upload_size;
            ?>
b",
                                    file_dialog_start_handler : fileDialogStart,
                                    file_queued_handler : fileQueued,
                                    upload_start_handler : uploadStart,
                                    upload_progress_handler : uploadProgress,
                                    upload_error_handler : uploadError,
                                    upload_success_handler : WYSIJAuploadSuccess,
                                    upload_complete_handler : WYSIJAuploadComplete,
                                    file_queue_error_handler : fileQueueError,
                                    file_dialog_complete_handler : fileDialogComplete,
                                    swfupload_pre_load_handler: swfuploadPreLoad,
                                    swfupload_load_failed_handler: swfuploadLoadFailed,
                                    custom_settings : {
                                            degraded_element_id : "html-upload-ui", // id of the element displayed when swfupload is unavailable
                                            swfupload_element_id : "flash-upload-ui" // id of the element displayed when swfupload is available
                                    },
                                    debug: false
                            };
                            swfu = new SWFUpload(settings);
            };
            //]]>
            </script>

            <div id="flash-upload-ui" class="hide-if-no-js">
            <?php 
            do_action('pre-flash-upload-ui');
            ?>

                    <div>
                    <?php 
            _e('Choose files to upload', WYSIJA);
            ?>
                    <div id="flash-browse-button"></div>
                    <span><input id="cancel-upload" disabled="disabled" onclick="cancelUpload()" type="button" value="<?php 
            esc_attr_e('Cancel Upload', WYSIJA);
            ?>
" class="button" /></span>
                    </div>
                    <p class="media-upload-size"><?php 
            printf(__('Maximum upload file size: %d%s', WYSIJA), $upload_size_unit, $sizes[$u]);
            ?>
</p>
            <?php 
            do_action('post-flash-upload-ui');
            ?>
            </div>
            <?php 
        }
        // $flash
        ?>

            <div id="html-upload-ui">
            <?php 
        do_action('pre-html-upload-ui');
        ?>
                    <p id="async-upload-wrap">
                    <label class="screen-reader-text" for="async-upload"><?php 
        _e('Upload', WYSIJA);
        ?>
</label>
                    <input type="file" name="async-upload" id="async-upload" /> <input type="submit" class="button" name="html-upload" value="<?php 
        esc_attr_e('Upload', WYSIJA);
        ?>
" /> <a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php 
        _e('Cancel', WYSIJA);
        ?>
</a>
                    </p>
                    <div class="clear"></div>
                    <p class="media-upload-size"><?php 
        printf(__('Maximum upload file size: %d%s', WYSIJA), $upload_size_unit, $sizes[$u]);
        ?>
</p>
                    <?php 
        if (is_lighttpd_before_150()) {
            ?>
                    <p><?php 
            _e('If you want to use all capabilities of the uploader, like uploading multiple files at once, please upgrade to lighttpd 1.5.');
            ?>
</p>
                    <?php 
        }
        ?>
            <?php 
        do_action('post-html-upload-ui', $flash);
        ?>
            </div>
            <?php 
        do_action('post-upload-ui');
        ?>
            <div id="media-items" class="clearfix"></div>
        </div>
        <?php 
    }
function fpGrabFromURLIframe()
{
    media_upload_header();
    if (isset($_POST['grabfrom_url'])) {
        // this is an upload request. let's see!
        $attachmentId = fpHandleUpload();
        if (is_wp_error($attachmentId)) {
            fpUploadForm('<div class="error form-invalid">' . $attachmentId->get_error_message() . '</div>');
        } else {
            echo "<style>h3, #plupload-upload-ui,.max-upload-size { display: none }</style>";
            media_upload_type_form("image", null, $attachmentId);
        }
    } else {
        fpUploadForm();
    }
}
    function media_tab_process()
    {
        media_upload_header();
        ?>
		<form id="new_royalslider_add_shortcode" action="media-new.php" method="post">
			<?php 
        submit_button(__('Add RoyalSlider', 'new_royalslider'));
        ?>
		</form>
		<?php 
    }
/**
 * {@internal Missing Short Description}}
 *
 * @since unknown
 *
 * @param unknown_type $type
 * @param unknown_type $errors
 * @param unknown_type $id
 */
function powerpress_media_upload_type_form($type = 'file', $errors = null, $id = null)
{
    media_upload_header();
    $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
    $form_action_url = admin_url("media-upload.php?type={$type}&tab=type&post_id={$post_id}");
    $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    if ($id && !is_wp_error($id)) {
        $image_url = wp_get_attachment_url($id);
        powerpress_send_to_episode_entry_box($image_url);
    }
    ?>

<form enctype="multipart/form-data" method="post" action="<?php 
    echo esc_attr($form_action_url);
    ?>
" class="media-upload-form type-form validate" id="<?php 
    echo $type;
    ?>
-form">
<input type="submit" class="hidden" name="save" value="" />
<input type="hidden" name="post_id" id="post_id" value="<?php 
    echo (int) $post_id;
    ?>
" />
<?php 
    wp_nonce_field('media-form');
    ?>

<h3 class="media-title"><?php 
    echo __('Select poster image from your computer.', 'powerpress');
    ?>
</h3>

<?php 
    media_upload_form($errors);
    ?>

<script type="text/javascript">
//<![CDATA[
jQuery(document).ready( function() {
	jQuery('#sidemenu').css('display','none');
	jQuery('body').css('margin','0px 20px');
	jQuery('body').css('height','auto');
	jQuery('html').css('height','auto'); // Elimate the weird scroll bar
});
//]]>
</script>
<div id="media-items">
<?php 
    if ($id && is_wp_error($id)) {
        echo '<div id="media-upload-error">' . esc_html($id->get_error_message()) . '</div>';
    }
    ?>
</div>
</form>
<?php 
}
function gmshc_tab_process()
{
    gmshc_head();
    if (!isset($_REQUEST['map'])) {
        media_upload_header();
        $options = get_gmshc_options();
        $post_id = $_REQUEST["post_id"];
        $custom_fieds = get_post_custom($post_id);
        $address = isset($_REQUEST['new_address']) ? gmshc_clean_string($_REQUEST['new_address']) : "";
        $latitude = isset($_REQUEST['latitude']) ? gmshc_clean_string($_REQUEST['latitude']) : "";
        $longitude = isset($_REQUEST['longitude']) ? gmshc_clean_string($_REQUEST['longitude']) : "";
        $verify = isset($_REQUEST['verify']) ? true : false;
        $verify_point = true;
        if ($latitude != "" && $longitude != "") {
            $ltlg = $latitude . "," . $longitude;
            if ($verify) {
                $verify_point = true;
            } else {
                $verify_point = false;
            }
        } else {
            $ltlg = "";
        }
        $title = isset($_REQUEST['new_title']) ? gmshc_clean_string($_REQUEST['new_title']) : get_the_title($post_id);
        $description = isset($_REQUEST['new_description']) ? gmshc_clean_string($_REQUEST['new_description']) : "";
        $icon = isset($_REQUEST['default_icon']) ? stripslashes($_REQUEST['default_icon']) : "";
        $selected_thumbnail = isset($_REQUEST['selected_thumbnail']) ? stripslashes($_REQUEST['selected_thumbnail']) : "";
        $add_point = isset($_REQUEST['add_point']) ? $_REQUEST['add_point'] : '';
        $del_point = isset($_REQUEST['delp']) ? $_REQUEST['delp'] : '';
        $update_point = isset($_REQUEST['update']) ? $_REQUEST['update'] : '';
        $width = isset($_REQUEST['width']) ? $_REQUEST['width'] : $options['width'];
        $height = isset($_REQUEST['height']) ? $_REQUEST['height'] : $options['height'];
        $margin = isset($_REQUEST['margin']) ? $_REQUEST['margin'] : $options['margin'];
        $align = isset($_REQUEST['align']) ? $_REQUEST['align'] : $options['align'];
        $zoom = isset($_REQUEST['zoom']) ? $_REQUEST['zoom'] : $options['zoom'];
        $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : $options['type'];
        $focus = isset($_REQUEST['focus']) ? $_REQUEST['focus'] : $options['focus'];
        $focus_type = isset($_REQUEST['focus_type']) ? $_REQUEST['focus_type'] : $options['focus_type'];
        $id_list = isset($_REQUEST['pid']) ? $_REQUEST['pid'] : "";
        $address_list = isset($_REQUEST['addr']) ? gmshc_stripslashes_deep($_REQUEST['addr']) : "";
        $title_list = isset($_REQUEST['title']) ? gmshc_stripslashes_deep($_REQUEST['title']) : "";
        $desc_list = isset($_REQUEST['desc']) ? gmshc_stripslashes_deep($_REQUEST['desc']) : "";
        $ltlg_list = isset($_REQUEST['ltlg']) ? $_REQUEST['ltlg'] : "";
        $icon_list = isset($_REQUEST['icon']) ? $_REQUEST['icon'] : "";
        $thumb_list = isset($_REQUEST['thumb']) ? $_REQUEST['thumb'] : "";
        $post_points = new GMSHC_Post_Map();
        $post_points->create_post_map($post_id);
        if (!empty($add_point)) {
            $new_point = new GMSHC_Point();
            if ($new_point->create_point($ltlg, $address, $ltlg, $title, $description, $icon, $selected_thumbnail, $post_id, $verify_point)) {
                if ($post_points->add_point($new_point)) {
                    echo "<div class='updated'><p>" . __("The Point was added.", "google-map-sc") . "</p></div>";
                } else {
                    echo "<div class='error'><p>" . __("The point can't be saved or already exist.", "google-map-sc") . "</p></div>";
                }
            } else {
                echo "<div class='error'><p>" . __("The Address can't be located.", "google-map-sc") . "</p></div>";
            }
        } else {
            if (!empty($update_point)) {
                if ($post_points->update_point($id_list, $address_list, $ltlg_list, $title_list, $desc_list, $icon_list, $thumb_list)) {
                    echo "<div class='updated'><p>" . __("The Point was updated.", "google-map-sc") . "</p></div>";
                } else {
                    echo "<div class='error'><p>" . __("The Points can't be updated.", "google-map-sc") . "</p></div>";
                }
            } else {
                if ($del_point != "") {
                    if ($post_points->delete_point($del_point)) {
                        echo "<div class='updated'><p>" . __("The Point was deleted.", "google-map-sc") . "</p></div>";
                    }
                }
            }
        }
        ?>
    
    <?php 
        $post_points->load_points();
        ?>
        
    <script type="text/javascript" src="<?php 
        echo GMSC_PLUGIN_URL;
        ?>
/js/gmshc-admin.js"></script>
        
    <link href="<?php 
        echo GMSC_PLUGIN_URL;
        ?>
/styles/gmshc-admin-styles.css" rel="stylesheet" type="text/css"/>       
       
       
        <div style="width:620px; margin:10px auto">
       
        <?php 
        echo gmshc_plugin_menu();
        ?>
    
        <form  action="#" method="post">
           <input id="default_width" type="hidden" value="<?php 
        echo $width;
        ?>
"/>
           <input id="default_height" type="hidden" value="<?php 
        echo $height;
        ?>
"/>
           <input id="default_margin" type="hidden" value="<?php 
        echo $margin;
        ?>
"/>
           <input id="default_align" type="hidden" value="<?php 
        echo $align;
        ?>
"/>
           <input id="default_zoom" type="hidden" value="<?php 
        echo $zoom;
        ?>
"/>
           <input id="default_focus" type="hidden" value="<?php 
        echo $focus;
        ?>
"/>
           <input id="default_focus_type" type="hidden" value="<?php 
        echo $focus_type;
        ?>
"/>           
           <input id="default_type" type="hidden" value="<?php 
        echo $type;
        ?>
"/>
           
           <table width="620" border="0" cellspacing="5" cellpadding="5">
            <tr>
                <td colspan="2">
                <h3 class="gmshc_editor"><?php 
        _e("Add New Point", "google-map-sc");
        ?>
</h3>
                <p><?php 
        _e("Points can be added using Address or Lat/Long.", "google-map-sc");
        ?>
</p>
                </td>
           </tr> 
            <tr>
                <td align="right" valign="top">
                <strong><?php 
        _e("Full Address", "google-map-sc");
        ?>
</strong>
                </td>
				<td valign="top">    
				<textarea name="new_address" cols="32" rows="2" id="new_address"></textarea>
				</td>
            </tr>           
            <tr>
                <td align="right" valign="top">
                <strong><?php 
        _e("Latitude ", "google-map-sc");
        ?>
</strong>
                </td>
				<td valign="top">    
				<input name="latitude" size="35" id="latitude" />
				</td>
            </tr>
            <tr>
                <td align="right" valign="top">
                <strong><?php 
        _e("Longitude", "google-map-sc");
        ?>
</strong>
                </td>
				<td valign="top">    
				<input name="longitude" size="35" id="longitude" />
				</td>
            </tr>
            <tr>
                <td align="right" valign="top">
                <input type="checkbox" value="1" name="verify" />
                </td>
				<td valign="top">    
				<?php 
        _e("Verify this latitude and longitude using Geocoding. This could overwrite the point address.", "google-map-sc");
        ?>
				</td>
            </tr>            
            <tr>
                <td align="right" valign="top">
                <strong><?php 
        _e("Title", "google-map-sc");
        ?>
</strong>
                </td>
				<td valign="top">    
				<input name="new_title"  size="54" id="new_title" value="<?php 
        echo $title;
        ?>
" />
				</td>
            </tr> 
            <tr>
                <td align="right" valign="top">
                <strong><?php 
        _e("Description", "google-map-sc");
        ?>
</strong>
                </td>
				<td valign="top">    
				<textarea name="new_description" cols="47" rows="2" id="new_description"></textarea>
				</td>
            </tr>	

            <tr>
				<td align="right" valign="top" colspan="2">
					<?php 
        gmshc_deploy_icons();
        ?>
				</td>
            </tr> 
            <tr>
				<td align="center" valign="top" colspan="2">
                	<?php 
        $thumbnail_list = gmshc_all_post_thumb($post_id);
        if (count($thumbnail_list) > 0) {
            ?>
                        <div class="gmshc_label">
                            <?php 
            _e("Select the thumbnail by clicking on the images", "google-map-sc");
            ?>
                        </div>
                        <div id="gmshc_thumb_cont">
                        <input type="hidden" name="selected_thumbnail" value="<?php 
            echo $default_icon;
            ?>
" id="selected_thumbnail" />
                        <?php 
            foreach ($thumbnail_list as $thumbnail) {
                ?>
                            <div class="gmshc_thumb">
                                <img src="<?php 
                echo $thumbnail;
                ?>
" width="40" height="40" />
                            </div>
                        <?php 
            }
            ?>
                        </div>
					<?php 
        } else {
            ?>
                        <div class="gmshc_label">
                            <strong><?php 
            _e("Thumbnail: ", "google-map-sc");
            ?>
</strong><?php 
            _e("If you want to attach an image to the point you need to upload it first to the post gallery", "google-map-sc");
            ?>
                        </div> 
                    <?php 
        }
        ?>
 
                    <p align="left"><a class="button" href = "?post_id=<?php 
        echo $post_id;
        ?>
&type=image" title="Upload Images"><?php 
        _e("Upload Images", "google-map-sc");
        ?>
</a></p>                     
				    <p class="endbox"><input class="button-primary" value="<?php 
        _e("Add Point", "google-map-sc");
        ?>
" name="add_point" type="submit"></p>
                </td>
            </tr>
            <?php 
        if ($post_points->points_number > 0) {
            ?>
            
            <tr>
                <td colspan="2">
                <h3 class="gmshc_editor"><?php 
            _e("Map Configuration", "google-map-sc");
            ?>
</h3>
                </td>
            </tr>  
            <tr>
                <td align="right"><?php 
            _e("Width", "google-map-sc");
            ?>
</td>
                <td valign="top"><input name="width" type="text" id="width" size="10" value = "<?php 
            echo $width;
            ?>
"/></td>
            </tr>  
            <tr>
                <td align="right"><?php 
            _e("Height", "google-map-sc");
            ?>
</td>
                <td valign="top"><input name="height" type="text" id="height" size="10" value = "<?php 
            echo $height;
            ?>
" /></td>
            </tr>
            <tr>
              <td align="right"><?php 
            _e("Margin", "google-map-sc");
            ?>
</td>
              <td><input name="margin" id="margin" type="text" size="6" value="<?php 
            echo $margin;
            ?>
" /></td>
            </tr>  
            <tr>
              <td align="right"><?php 
            _e("Align", "google-map-sc");
            ?>
</td>
              <td>
                  <input name="align" type="radio" id="aleft" value="left" <?php 
            echo $align == "left" ? "checked = 'checked'" : "";
            ?>
 /> <?php 
            _e("left", "google-map-sc");
            ?>
                  <input name="align" type="radio" id="acenter" value="center" <?php 
            echo $align == "center" ? "checked = 'checked'" : "";
            ?>
 /> <?php 
            _e("center", "google-map-sc");
            ?>
                  <input name="align" type="radio" id="aright" value="right" <?php 
            echo $align == "right" ? "checked = 'checked'" : "";
            ?>
 /> <?php 
            _e("right", "google-map-sc");
            ?>
        
            </tr>            
            <tr>
              <td align="right"><?php 
            _e("Zoom", "google-map-sc");
            ?>
</td>
              <td>              
              <select name="zoom" id="zoom">              
                  <?php 
            for ($i = 0; $i <= 20; $i++) {
                ?>
                      <option value="<?php 
                echo $i;
                ?>
" <?php 
                echo $i == $zoom ? "selected" : "";
                ?>
 ><?php 
                echo $i;
                ?>
</option>
                  <?php 
            }
            ?>
              </select>         
            </tr> 
            <tr>
              <td align="right"><?php 
            _e("Maps Type", "google-map-sc");
            ?>
</td>
              <td>
                  <select name="type" id="type">
                      <option value="ROADMAP" <?php 
            if ($type == "ROADMAP") {
                echo "selected";
            }
            ?>
><?php 
            _e("ROADMAP - Displays a normal street map", "google-map-sc");
            ?>
</option>
                      <option value="SATELLITE" <?php 
            if ($type == "SATELLITE") {
                echo "selected";
            }
            ?>
><?php 
            _e("SATELLITE - Displays satellite images", "google-map-sc");
            ?>
</option>
                      <option value="TERRAIN" <?php 
            if ($type == "TERRAIN") {
                echo "selected";
            }
            ?>
><?php 
            _e("TERRAIN - Displays maps with physical features such as terrain and vegetation", "google-map-sc");
            ?>
</option>
                      <option value="HYBRID" <?php 
            if ($type == "HYBRID") {
                echo "selected";
            }
            ?>
><?php 
            _e("HYBRID - Displays a transparent layer of major streets on satellite images", "google-map-sc");
            ?>
</option>
                  </select>
              </td>        
            </tr>  
            <tr>
              <td align="right"><?php 
            _e("Focus", "google-map-sc");
            ?>
</td>
              <td>
                  <select name="focus" id="focus">
                      <option value="0" <?php 
            if ($focus == 0) {
                echo "selected";
            }
            ?>
><?php 
            _e("None", "google-map-sc");
            ?>
</option>
                      <?php 
            for ($i = 1; $i <= $post_points->points_number; $i++) {
                ?>
                      	<option value="<?php 
                echo $i;
                ?>
" <?php 
                if ($focus == $i) {
                    echo "selected";
                }
                ?>
><?php 
                echo $i;
                ?>
</option>
                      <?php 
            }
            ?>
                      <?php 
            if ($post_points->points_number > 1) {
                ?>
                      <option value="all" <?php 
                if ($focus == "all") {
                    echo "selected";
                }
                ?>
><?php 
                _e("All", "google-map-sc");
                ?>
</option>
                      <?php 
            }
            ?>
                      
                  </select>
                  <em><?php 
            _e("Select the point to be focused after loading the map", "google-map-sc");
            ?>
</em>
              </td>        
            </tr> 
            <tr>
              <td align="right" valign="top"><?php 
            _e("Focus Type", "google-map-sc");
            ?>
</td>
              <td>
              <select name="focus_type" id="focus_type">
                 <option value="open" <?php 
            echo $focus_type == "open" ? "selected" : "";
            ?>
 ><?php 
            _e("Open Markers", "google-map-sc");
            ?>
</option>
                 <option value="center" <?php 
            echo $focus_type == "center" ? "selected" : "";
            ?>
 ><?php 
            _e("Center Markers", "google-map-sc");
            ?>
</option>
              </select>
              </td>        
            </tr>                                   
            <?php 
        }
        ?>
			
            </table>
            
			<?php 
        if ($post_points->points_number > 0) {
            ?>
  
                
                <p class="endbox"><input class="button-primary insert_map" value="<?php 
            _e("Insert Map", "google-map-sc");
            ?>
" type="button" \> 
                   <a class="button gmshc_show" href="#gmshc_map" show="<?php 
            _e("Show Map", "google-map-sc");
            ?>
" hide="<?php 
            _e("Hide Map", "google-map-sc");
            ?>
">
                    <?php 
            _e("Show Map", "google-map-sc");
            ?>
                   </a>&nbsp;  
                   <a class="button gmshc_refresh" href="#gmshc_map">
                    <?php 
            _e("Refresh Map", "google-map-sc");
            ?>
                   </a>
                </p>
                                     
                <p><?php 
            echo $post_points->points_number . " " . __("Points Added", "google-map-sc");
            ?>
</p>                    
            <?php 
        }
        ?>
            
			<?php 
        if (count($post_points->points) > 0) {
            rsort($post_points->points);
            ?>
     
            <table class="widefat" cellspacing="0">
                <thead>
                <tr>
                <th><?php 
            _e("#");
            ?>
</th>
                <th><?php 
            _e("Marker", "google-map-sc");
            ?>
</th>
                <th><?php 
            _e("Thumbnail", "google-map-sc");
            ?>
</th>
                <th><?php 
            _e("Title/Description", "google-map-sc");
            ?>
</th>
                <th width="140"><?php 
            _e("Address/LtLg", "google-map-sc");
            ?>
</th>
                </tr>
                </thead>
                <tbody class="media-item-info">   
                
                <?php 
            $i = 0;
            foreach ($post_points->points as $point) {
                ?>
                     
                    <tr>
                      <td><?php 
                echo $post_points->points_number - $i;
                ?>
</td>	
                      <td>
                      	<img src="<?php 
                echo $point->icon;
                ?>
" atl="<?php 
                _e("Icon", "google-map-sc");
                ?>
" />
                        <input name="icon[]" type="hidden" id="icon_<?php 
                echo $i;
                ?>
" size="30" value = "<?php 
                echo $point->icon;
                ?>
"/>
                        <input name="pid[]" type="hidden" id="id_<?php 
                echo $i;
                ?>
" size="30" value = "<?php 
                echo $point->id;
                ?>
"/>
                      </td>                    
                      <td>
                      	<div class="gmshc_thumb gmshc_selected">
                        <?php 
                if ($point->thumbnail != "") {
                    ?>
						       
                      	<img src="<?php 
                    echo $point->thumbnail;
                    ?>
" atl="<?php 
                    _e("Thumbnail", "google-map-sc");
                    ?>
" width = "40" height="40" />
                        <input name="thumb[]" type="hidden" id="thumb_<?php 
                    echo $i;
                    ?>
" size="30" value = "<?php 
                    echo $point->thumbnail;
                    ?>
"/>                        
                         <?php 
                }
                ?>
                         </div>                  
                      </td>
                      <td>
						<input name="title[]" type="text" id="title_<?php 
                echo $i;
                ?>
" size="33" value = "<?php 
                echo $point->title;
                ?>
"/>
                        <textarea name="desc[]" cols="30" rows="2" id="desc_<?php 
                echo $i;
                ?>
"><?php 
                echo $point->description;
                ?>
</textarea>							
                      </td>
                      <td>
                      	<textarea name="addr[]" cols="30" rows="2" id="addr_<?php 
                echo $i;
                ?>
"><?php 
                echo $point->address;
                ?>
</textarea>
						<input name="ltlg[]" type="hidden" id="ltlg_<?php 
                echo $i;
                ?>
" size="30" value = "<?php 
                echo $point->ltlg;
                ?>
"/>
                        <p><?php 
                echo $point->ltlg;
                ?>
</p>                        
                        <div>                        
                        <input class="button" value="<?php 
                _e("Update", "google-map-sc");
                ?>
" name="update" type="submit"> 
                        <a href="?post_id=<?php 
                echo $post_id;
                ?>
&tab=gmshc&delp=<?php 
                echo $point->id;
                ?>
" class="delete_point" onclick="if(confirm('<?php 
                _e("You will not be able to roll back deletion. Are you sure?", "google-map-sc");
                ?>
')) return true; else return false"><?php 
                _e("Delete", "google-map-sc");
                ?>
</a>
                        </div>
                      </td>
                    </tr>
                 <?php 
                $i++;
            }
            ?>
          
                </tbody> 	    
            </table>
        
   	    <p><input class="button-primary insert_map" value="<?php 
            _e("Insert Map", "google-map-sc");
            ?>
" type="button" \> 
           <a class="button gmshc_show" href="#gmshc_map" show="<?php 
            _e("Show Map", "google-map-sc");
            ?>
" hide="<?php 
            _e("Hide Map", "google-map-sc");
            ?>
">
		   	<?php 
            _e("Show Map", "google-map-sc");
            ?>
           </a>&nbsp; 
           <a class="button gmshc_refresh" href="#gmshc_map">
		   	<?php 
            _e("Refresh Map", "google-map-sc");
            ?>
           </a>
        </p>        
        </div>
		
        <div id="gmshc_map" style="height:0px; overflow:hidden;" tabindex="100">
        <input type="hidden" id="iframe_url" value="?post_id=<?php 
            echo $post_id;
            ?>
&tab=gmshc&"  />
        <iframe id = "iframe_sc" src="" width="600" height="420" scrolling="no" />        
        </div>
        <br />        
			<?php 
        }
        ?>
		</form>
        <?php 
    } else {
        $map_attr = array("post_id", "type", "zoom", "focus", "focus_type");
        $shc_attr = "";
        foreach ($map_attr as $attr) {
            if (isset($_REQUEST[$attr])) {
                $shc_attr .= " " . ($attr == "post_id" ? "id" : $attr) . "=" . $_REQUEST[$attr];
            }
        }
        echo do_shortcode("[google-map-sc width=600 height=420 align=center margin=0" . $shc_attr . "]");
    }
}
function wpgmp_google_map_icon()
{
    echo media_upload_header();
    $form_action_url = site_url("wp-admin/media-upload.php?type={$GLOBALS['type']}&tab=ell_insert_gmap_tab", 'admin');
    ?>
<script type="text/javascript">
 function add_icon_to_images()
 {
	  if(jQuery('.read_icons').hasClass('active'))
	  {	  
	  	imgsrc = jQuery('.active').find('img').attr('src');
   		
		var win = window.dialogArguments || opener || parent || top;
   		
		win.send_icon_to_map(imgsrc);
  		
	  }
	  else
	  {
   		alert('Choose your icon.');
  	  }
 }
</script>
<form enctype="multipart/form-data" method="post" action="<?php 
    echo esc_attr($form_action_url);
    ?>
" class="media-upload-form" id="library-form">
<h3 class="media-title" style="color: #5A5A5A; font-family: Georgia, 'Times New Roman', Times, serif; font-weight: normal; font-size: 1.6em; margin-left: 10px;"><?php 
    _e('Select Icons', 'wpgmp_google_map');
    ?>
</h3>
<div style="margin-bottom:30px; float:left;">
<ul style="margin-left:10px; float:left;" id="select_icons">
<?php 
    $dir = plugin_dir_path(__FILE__) . 'icons/';
    if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
            while (($file = readdir($dh)) !== false) {
                ?>
	
<li class="read_icons" style="float:left;">	
      <img src="<?php 
                echo plugins_url('/icons/' . $file . '', __FILE__);
                ?>
" style="cursor:pointer;" />
</li>
<?php 
            }
            closedir($dh);
        }
    }
    ?>
</ul>
<button type="button" class="button" style="margin-left:10px;" value="1" onclick="add_icon_to_images();" name="send[<?php 
    echo $picid;
    ?>
]"><?php 
    _e('Insert into Post', 'wpgmp_google_map');
    ?>
</button>
</div>
</form>
<?php 
}
Example #19
0
    public function media_html()
    {
        $type = 'document';
        wp_enqueue_media();
        wp_enqueue_script('jquery');
        wp_enqueue_script('media-upload');
        wp_enqueue_script('thickbox');
        wp_enqueue_style('thickbox');
        wp_enqueue_script('pdfjs', $this->myBase . '/classes/pdf.js/pdf.js');
        wp_enqueue_script('pdf-viewer-admin', $this->myBase . '/classes/script-admin.js');
        wp_enqueue_style('pdf-viewer-admin', $this->myBase . '/classes/style-admin.css');
        //wp_enqueue_script('jquery-validate', $this->myBase .'/classes/jquery.validate.min.js');
        media_upload_header();
        //get current user id
        global $current_user;
        get_currentuserinfo();
        //insert new doc into post
        $error = array();
        if (isset($_POST['insert_existing'])) {
            //validate
            $post = $_POST;
            $post['linktext'] = sanitize_text_field($post['linktext']);
            if (!$post['post_id']) {
                $error[] = "Oops. Looks like you forgot to pick a document to insert.";
            }
            //submit
            if (empty($error)) {
                $this->insert_doc_into_post($post);
            }
        }
        if (isset($_POST['insert_new'])) {
            //validate
            $post = $_POST;
            $post['title'] = sanitize_text_field($post['title']);
            $post['linktext'] = sanitize_text_field($post['linktext']);
            if ($post['title'] == '') {
                $error[] = "Oops. You forgot to include a title for the document.";
            }
            if ($_FILES["uploadfile"]["error"] > 0) {
                $error[] = "Hmm. Somthing went wrong. Will you try uploading the file again?";
            }
            if ($_FILES["uploadfile"]["type"] != "application/pdf") {
                $error[] = "Oops. Looks like you didn't upload a PDF file. Sadly, that's all you can embed right now.";
            }
            //submit
            if (empty($error)) {
                $post_id = $this->upload($post);
                if (is_numeric($post_id)) {
                    $post['post_id'] = $post_id;
                    $this->insert_doc_into_post($post);
                } else {
                    $error[] = "Hmm. Somthing went wrong. Will you try uploading the file again?";
                }
            }
        }
        //Upload new doc
        ?>
	  <div class='document-nav-menu'>
        	<div id="upload" class="active">Upload Document</div>
            <div id="doc-lib" class="">Document Library</div>
      </div>
      <div style="clear:both;" id="upload_div"></div>
      <div id="upload-div" class="major-sec">
		  <?php 
        if (isset($_POST['insert_new']) && !empty($error)) {
            $error_msg = "<div class='error'><ul>";
            foreach ($error as $e) {
                $error_msg .= "<li>{$e}</li>";
            }
            $error_msg .= "</ul></div>";
            echo $error_msg;
        }
        ?>
      	<form id="upload-form" action="" method="post" enctype="multipart/form-data">
        	<input type="hidden" name="insert_new" value="1">
            <div id="media-items">
            <h3 class="media-title">Upload a new document</h3>

            <table class="describe">
            <tr>
            <th valign="top" scope="row" class="label">
            <label for="title">Document title</label><span class="alignright"><abbr title="required" class="required">*</abbr></span>
            </th>
            <td class="field">
            <input type="text" name="title" aria-required="true" placeholder="Used as the document's title" class="required" minlength="2" value="<?php 
        echo $post['title'];
        ?>
">
            </td></tr>
            
            <tr>
            <th valign="top" scope="row" class="label">
            <label for="uploadfile">Choose a PDF file</label><span class="alignright"><abbr title="required" class="required">*</abbr></span>
            </th>
            <td class="field">
            <input type="file" name="uploadfile" id="uploadfile" size="40" aria-required="true" class="required" accept="application/pdf"> The file <em>must</em> be a PDF!
            </td></tr>
            
            <tr class="extra-space">
            <th valign="top" scope="row" class="label">
            <label for="lightbox">Lightbox</label>
            </th>
            <td class="field">
            <input type="checkbox" name="lightbox" class="show_other" <?php 
        if ($post['lightbox']) {
            echo "checked";
        }
        ?>
> Insert a link to a popup window view of the document?
            </td></tr>
			
            <tr class="initial-hide" id="linktext-row">
            <th valign="top" scope="row" class="label">
            <label for="linktext">Link</label>
            </th>
            <td class="field">
            <input type="text" size="30" name="linktext" placeholder="What should the link to the lightbox say?" value="<?php 
        echo $post['linktext'];
        ?>
">
            </td></tr>
			
            <tr class="extra-space">
            <th valign="top" scope="row" class="label">
            <label for="booklet">Booklet</label>
            </th>
            <td class="field">
            <input type="checkbox" name="booklet" class="show_other" <?php 
        if ($post['booklet']) {
            echo "checked";
        }
        ?>
> Display as a booklet with side-by-side pages?
            </td></tr>
			
            <tr class="initial-hide" id="coverpage-row">
            <th valign="top" scope="row" class="label">
            <label for="coverpage">Cover page</label>
            </th>
            <td class="field">
            <input type="checkbox" name="coverpage" <?php 
        if ($post['coverpage']) {
            echo "checked";
        }
        ?>
> Does the PDF have a cover page?
            </td></tr>
            
            <tr>
            <th valign="top" scope="row" class="label">
            </th>
            <td class="field">
            <input type="submit" class="button" value="Insert new document"></input>
            </td></tr>
            
            </table>
            
            </div>
        </form>
        <p id="f1_upload_process">Loading...<br/><img src="<?php 
        echo $this->myBase;
        ?>
/images/loader.gif" /></p>
		<p id="result"></p>
      </div>
	  
	  <?php 
        //Choose existing  doc
        ?>
 
      <div id="doc-lib-div" class="major-sec">
		  <?php 
        if (isset($_POST['insert_existing']) && !empty($error)) {
            $error_msg = "<div class='error'><ul>";
            foreach ($error as $e) {
                $error_msg .= "<li>{$e}</li>";
            }
            $error_msg .= "</ul></div>";
            echo $error_msg;
        }
        ?>
      <h3 class="media-title">Pick a document to insert</h3>
      <div id="doc-lib-container">
      <?php 
        echo $this->list_posts();
        ?>
      </div>
        <form id="doc-lib-form" action="" method="post" style="clear:both;">
        	<input type="hidden" name="insert_existing" value="1">
        	<input type="hidden" id="existing_post_id" name="post_id" value="0">
            <input type="hidden" id="existing_title" name="title" value="none">
           	<table class="describe">
               <tr class="extra-space">
               <th valign="top" scope="row" class="label">
               <label for="lightbox">Lightbox</label>
               </th>
               <td class="field">
               <input type="checkbox" name="lightbox" class="show_other" <?php 
        if ($post['lightbox']) {
            echo "checked";
        }
        ?>
> Insert a link to a popup window view of the document?
               </td></tr>
			
               <tr class="initial-hide" id="linktext-row">
               <th valign="top" scope="row" class="label">
               <label for="linktext">Link</label>
               </th>
               <td class="field">
               <input type="text" size="30" name="linktext" placeholder="What should the link to the lightbox say?" value="<?php 
        echo $post['linktext'];
        ?>
">
               </td></tr>
			
               <tr class="extra-space">
               <th valign="top" scope="row" class="label">
               <label for="booklet">Booklet</label>
               </th>
               <td class="field">
               <input type="checkbox" name="booklet" class="show_other" <?php 
        if ($post['booklet']) {
            echo "checked";
        }
        ?>
> Display as a booklet with side-by-side pages?
               </td></tr>
			
               <tr class="initial-hide" id="coverpage-row">
               <th valign="top" scope="row" class="label">
               <label for="coverpage">Cover page</label>
               </th>
               <td class="field">
               <input type="checkbox" name="coverpage" <?php 
        if ($post['coverpage']) {
            echo "checked";
        }
        ?>
> Does the PDF have a cover page?
               </td></tr>
            
            
		    <tr>
            <th scope="row" class="label">
            </th>
            <td class="field">
              <input type="submit" class="button" value="Insert document"></input>
            </td>
            </tr>
          </table>
        </form>
	  </div>
	  <?php 
    }
Example #20
0
 function tab_handler()
 {
     if (!$this->user_allowed()) {
         return;
     }
     //Set the body ID
     $GLOBALS['body_id'] = 'media-upload';
     //Do an IFrame header
     iframe_header(__('Add From Server', 'add-from-server'));
     //Add the Media buttons
     media_upload_header();
     //Handle any imports:
     $this->handle_imports();
     //Do the content
     $this->main_content();
     //Do a footer
     iframe_footer();
 }
Example #21
0
    /**
     * Create the tab content to be displayed.
     * @since  1.0.0
     * @uses  global $wooslider Global $wooslider object
     * @return void
     */
    public function media_tab_process()
    {
        global $wooslider;
        media_upload_header();
        $wooslider->post_types->setup_slide_pages_taxonomy();
        ?>
<form action="media-new.php" method="post" id="wooslider-insert">
	<?php 
        submit_button(__('Insert Slideshow', 'wooslider'));
        ?>
	<?php 
        $this->popup_fields();
        ?>
	<p class="hide-if-no-js"><a href="#advanced-settings" class="advanced-settings button"><?php 
        _e('Advanced Settings', 'wooslider');
        ?>
</a></p>
	<div id="wooslider-advanced-settings">
		<div class="updated fade"><p><?php 
        _e('Optionally override the default slideshow settings using the fields below.', 'wooslider');
        ?>
</p></div>
		<?php 
        $this->display_special_settings();
        settings_fields($wooslider->settings->token);
        do_settings_sections($wooslider->settings->token);
        ?>
	</div><!--/#wooslider-advanced-settings-->
	<?php 
        submit_button(__('Insert Slideshow', 'wooslider'));
        ?>
</form>
<?php 
    }
        /**
         * Read images/icons folder.
         */
        function wpgmp_google_map_icon()
        {
            wp_enqueue_style('media');
            media_upload_header();
            $form_action_url = site_url("wp-admin/media-upload.php?type={$GLOBALS['type']}&tab=ell_insert_gmap_tab", 'admin');
            ?>

		<style type="text/css">
		#select_icons .read_icons {
		width: 32px;
		height: 32px;ß
		}
		#select_icons .active img {
		border: 3px solid #000;
		width: 26px;
		}
		</style>

		<script type="text/javascript">

		jQuery(document).ready(function($) {

		$(".read_icons").click(function () {

		$(".read_icons").removeClass('active');
		$(this).addClass('active');
		});

		$('input[name="wpgmp_search_icon"]').keyup(function() {
		if($(this).val() == '')
		$('.read_icons').show();
		else {
		$('.read_icons').hide();
        $('img[title^="' + $(this).val() + '"]').parent().show();
		}

    	});

		});

		function add_icon_to_images(target) {

		if(jQuery('.read_icons').hasClass('active'))
		{
		imgsrc = jQuery('.active').find('img').attr('src');
		var win = window.dialogArguments || opener || parent || top;
		win.send_icon_to_map(imgsrc,target);
		}
		else
		{
		alert('Choose your icon.');
		}
		}
		</script>

		<form enctype="multipart/form-data" method="post" action="<?php 
            echo esc_attr($form_action_url);
            ?>
" class="media-upload-form" id="library-form">
	<h3 class="media-title" style="color: #5A5A5A; font-family: Georgia, 'Times New Roman', Times, serif; font-weight: normal; font-size: 1.6em; margin-left: 10px;"><?php 
            _e('Choose icon', WPGMP_TEXT_DOMAIN);
            ?>
 	<input name="wpgmp_search_icon" id="wpgmp_search_icon" type='text' value="" placeholder="<?php 
            _e('Search icons', WPGMP_TEXT_DOMAIN);
            ?>
" />
</h3>
	<div style="margin-bottom:20px; float:left; width:100%;">
	<ul style="float:left; width:100%;" id="select_icons">
	<?php 
            $dir = WPGMP_ICONS_DIR;
            $file_display = array('jpg', 'jpeg', 'png', 'gif');
            if (file_exists($dir) == false) {
                echo 'Directory \'', $dir, '\' not found!';
            } else {
                $dir_contents = scandir($dir);
                foreach ($dir_contents as $file) {
                    $image_data = explode('.', $file);
                    $file_type = strtolower(end($image_data));
                    if ('.' !== $file && '..' !== $file && true == in_array($file_type, $file_display)) {
                        ?>
			<li class="read_icons" style="float:left;">
			<img alt="<?php 
                        echo $image_data[0];
                        ?>
" title="<?php 
                        echo $image_data[0];
                        ?>
" src="<?php 
                        echo WPGMP_ICONS . $file;
                        ?>
" style="cursor:pointer;" />
		</li>
		<?php 
                    }
                }
            }
            ?>
		</ul>
		<button type="button" class="button" style="margin-left:10px;" value="1" onclick="add_icon_to_images('<?php 
            echo wp_unslash($_GET['target']);
            ?>
');" name="send[<?php 
            echo $picid;
            ?>
]"><?php 
            _e('Insert into Post', WPGMP_TEXT_DOMAIN);
            ?>
</button>
	</div>
	</form>
	<?php 
        }
/**
 * Renders the form for inserting URL files into the Media Library.
 * @global string $redir_tab The tab to redirect to on form submits.
 * @global string $type The type of media being considered.
 * @param undefined $errors Any errors the occurred.
 */
function media_jwplayer_url_insert_form($errors)
{
    global $redir_tab, $type;
    $redir_tab = 'jwplayer_url';
    media_upload_header();
    $post_id = intval($_REQUEST['post_id']);
    $form_action_url = admin_url("media-upload.php?type={$type}&tab={$redir_tab}&post_id={$post_id}");
    $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    if (isset($_POST["insertonlybutton"])) {
        $youtube_pattern = "/youtube.com\\/watch\\?v=([0-9a-zA-Z_-]*)/i";
        $url = $_POST["insertonly"]["href"];
        $attachment = array("post_mime_type" => "video/x-flv", "guid" => $url, "post_parent" => $post_id);
        if (preg_match($youtube_pattern, $url, $match)) {
            $youtube_api = get_youtube_meta_data($match[1]);
            if ($youtube_api) {
                $attachment["post_title"] = $youtube_api["title"];
                $attachment["post_content"] = $youtube_api["description"];
            }
        } else {
            $file_info = wp_check_filetype($url);
            if ($file_info["type"] != null) {
                $attachment["post_mime_type"] = $file_info["type"];
                $attachment["post_content"] = "";
                $attachment["post_title"] = "";
            }
        }
        $id = wp_insert_attachment($attachment, $url, $post_id);
        if ($youtube_api) {
            update_post_meta($id, LONGTAIL_KEY . "thumbnail_url", $youtube_api["thumbnail_url"]);
            update_post_meta($id, LONGTAIL_KEY . "creator", $youtube_api["author"]);
        } else {
            if (strstr($url, "rtmp://")) {
                update_post_meta($id, LONGTAIL_KEY . "streamer", str_replace(basename($url), "", $url));
                update_post_meta($id, LONGTAIL_KEY . "file", basename($url));
                update_post_meta($id, LONGTAIL_KEY . "rtmp", true);
            }
        }
        update_post_meta($id, LONGTAIL_KEY . "external", true);
        wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $url));
    }
    ?>

  <form enctype="multipart/form-data" method="post" action="<?php 
    echo esc_attr($form_action_url);
    ?>
" class="media-upload-form type-form validate" id="<?php 
    echo $type;
    ?>
-form">
    <input type="submit" class="hidden" name="save" value="" />
    <input type="hidden" name="post_id" id="post_id" value="<?php 
    echo (int) $post_id;
    ?>
" />
  <?php 
    wp_nonce_field('media-form');
    ?>

    <h3 class="media-title"><?php 
    _e('Add media file from URL', 'jw-player-plugin-for-wordpress');
    ?>
</h3>

    <div id="url-upload-ui">
      <table class="describe">
        <tbody>
          <tr>
            <th valign="top" scope="row" class="label">
              <span class="alignleft"><label for="insertonly[href]"><?php 
    _e('URL', 'jw-player-plugin-for-wordpress');
    ?>
</label></span>
              <span class="alignright"><abbr title="required" class="required">*</abbr></span>
            </th>
            <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td>
          </tr>
          <tr>
            <td></td>
            <td>
              <input type="submit" class="button" name="insertonlybutton" value="<?php 
    echo esc_attr__('Add Media', 'jw-player-plugin-for-wordpress');
    ?>
" />
            </td>
          </tr>
        </tbody>
      </table>
    </div>

    <script type="text/javascript">
      //<![CDATA[
      jQuery(function($){
        var preloaded = $(".media-item.preloaded");
        if ( preloaded.length > 0 ) {
          preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
        }
        updateMediaForm();
      });
      //]]>
    </script>
    <div id="media-items">
  <?php 
    if (isset($id)) {
        if (!is_wp_error($id)) {
            add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
            echo get_media_items($id, $errors);
        } else {
            echo '<div id="media-upload-error">' . esc_html($id->get_error_message()) . '</div>';
            exit;
        }
    }
    ?>
    </div>
    <p class="savebutton ml-submit">
      <input type="submit" class="button" name="save" value="<?php 
    esc_attr_e('Save all changes', 'jw-player-plugin-for-wordpress');
    ?>
" />
    </p>
  </form>
  <?php 
}
Example #24
0
 function linkBuildingResearchThickboxInclude()
 {
     $pages = array('ecordia-link-building-external', 'ecordia-link-building-internal', 'ecordia-link-building-social');
     $tab = in_array($_GET['tab'], $pages) ? $_GET['tab'] : 'ecordia-link-building-external';
     $page = str_replace('ecordia-', '', $tab);
     if (false === strpos($tab, 'error')) {
         add_filter('media_upload_tabs', array(&$this, 'linkBuildingThickboxTabs'));
         media_upload_header();
     }
     $info = $this->getSeoInfoForPost($_GET['post']);
     $keywordInfo = $info['GetAnalysisResult']['Analysis']['PrimaryKeywords'];
     $keywords = $keywordInfo['Keywords']['Keyword'];
     $properKeywords = array();
     foreach ($keywords as $keyword) {
         if (in_array($keyword['Rank'], array('Primary', 'Important', 'Significant'))) {
             $properKeywords[] = $keyword;
         }
     }
     $type = str_replace('link-building-', '', $page);
     $research = $this->getLinkBuildingResearchForPostAndType($_GET['post'], $type);
     if (false === $info && false === strpos($tab, 'error')) {
         print '<form><p>No analysis present.</p></form>';
         return;
     }
     echo '<span id="link-building-type" data-type="' . $type . '"></span>';
     echo '<span id="link-building-post-id" data-id="' . absint($_GET['post']) . '"></span>';
     $klout_logo_url = plugins_url('/resources/images/klout-powered-gray.png', __FILE__);
     include 'views/link-building/' . $page . '.php';
 }
Example #25
0
function media_upload_nextgen_form($errors)
{
    global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types, $ngg;
    media_upload_header();
    $post_id = intval($_REQUEST['post_id']);
    $galleryID = 0;
    $total = 1;
    $picarray = array();
    $form_action_url = site_url("wp-admin/media-upload.php?type={$GLOBALS['type']}&tab=nextgen&post_id={$post_id}", 'admin');
    // Get number of images in gallery
    if (isset($_REQUEST['select_gal'])) {
        $galleryID = (int) $_REQUEST['select_gal'];
        $total = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->nggpictures} WHERE galleryid = '{$galleryID}'");
    }
    // Build navigation
    $_GET['paged'] = isset($_GET['paged']) ? intval($_GET['paged']) : 0;
    if ($_GET['paged'] < 1) {
        $_GET['paged'] = 1;
    }
    $start = ($_GET['paged'] - 1) * 10;
    if ($start < 1) {
        $start = 0;
    }
    // Get the images
    if ($galleryID != 0) {
        $picarray = $wpdb->get_col("SELECT pid FROM {$wpdb->nggpictures} WHERE galleryid = '{$galleryID}' AND exclude != 1 ORDER BY {$ngg->options['galSort']} {$ngg->options['galSortDir']} LIMIT {$start}, 10 ");
    }
    // WP-Core code for Post-thumbnail
    $calling_post_id = 0;
    if (isset($_GET['post_id'])) {
        $calling_post_id = $_GET['post_id'];
    }
    ?>

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

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

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

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

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

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

<?php 
}
Example #26
0
 /**
  * LazyestUploadTab::display()
  * Main display function for media upload tab
  * 
  * @return
  */
 function display()
 {
     global $lg_gallery;
     media_upload_header();
     if (isset($_REQUEST['folder'])) {
         $file = $lg_gallery->get_file_by_id($_REQUEST['folder']);
         $folder = new LazyestFolder($file[0]);
         if ($folder->valid()) {
             $this->display_folder($folder);
         }
     } else {
         $this->show_gallery();
     }
 }
Example #27
0
/**
 * {@internal Missing Short Description}}
 *
 * @since unknown
 *
 * @param unknown_type $errors
 */
function media_upload_library_form($errors)
{
    global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types;
    media_upload_header();
    $post_id = intval($_REQUEST['post_id']);
    $form_action_url = admin_url("media-upload.php?type={$GLOBALS['type']}&tab=library&post_id={$post_id}");
    $_GET['paged'] = isset($_GET['paged']) ? intval($_GET['paged']) : 0;
    if ($_GET['paged'] < 1) {
        $_GET['paged'] = 1;
    }
    $start = ($_GET['paged'] - 1) * 10;
    if ($start < 1) {
        $start = 0;
    }
    add_filter('post_limits', $limit_filter = create_function('$a', "return 'LIMIT {$start}, 10';"));
    list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
    ?>

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

<p id="media-search" class="search-box">
	<label class="screen-reader-text" for="media-search-input"><?php 
    _e('Search Media');
    ?>
:</label>
	<input type="text" id="media-search-input" name="s" value="<?php 
    the_search_query();
    ?>
" />
	<input type="submit" value="<?php 
    esc_attr_e('Search Media');
    ?>
" class="button" />
</p>

<ul class="subsubsub">
<?php 
    $type_links = array();
    $_num_posts = (array) wp_count_attachments();
    $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
    foreach ($matches as $_type => $reals) {
        foreach ($reals as $real) {
            if (isset($num_posts[$_type])) {
                $num_posts[$_type] += $_num_posts[$real];
            } else {
                $num_posts[$_type] = $_num_posts[$real];
            }
        }
    }
    // If available type specified by media button clicked, filter by that type
    if (empty($_GET['post_mime_type']) && !empty($num_posts[$type])) {
        $_GET['post_mime_type'] = $type;
        list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
    }
    if (empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all') {
        $class = ' class="current"';
    } else {
        $class = '';
    }
    $type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type' => 'all', 'paged' => false, 'm' => false))) . "'{$class}>" . __('All Types') . "</a>";
    foreach ($post_mime_types as $mime_type => $label) {
        $class = '';
        if (!wp_match_mime_types($mime_type, $avail_post_mime_types)) {
            continue;
        }
        if (isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type'])) {
            $class = ' class="current"';
        }
        $type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type' => $mime_type, 'paged' => false))) . "'{$class}>" . sprintf(_n($label[2][0], $label[2][1], $num_posts[$mime_type]), "<span id='{$mime_type}-counter'>" . number_format_i18n($num_posts[$mime_type]) . '</span>') . '</a>';
    }
    echo implode(' | </li>', $type_links) . '</li>';
    unset($type_links);
    ?>
</ul>

<div class="tablenav">

<?php 
    $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($wp_query->found_posts / 10), 'current' => $_GET['paged']));
    if ($page_links) {
        echo "<div class='tablenav-pages'>{$page_links}</div>";
    }
    ?>

<div class="alignleft actions">
<?php 
    $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM {$wpdb->posts} WHERE post_type = 'attachment' ORDER BY post_date DESC";
    $arc_result = $wpdb->get_results($arc_query);
    $month_count = count($arc_result);
    if ($month_count && !(1 == $month_count && 0 == $arc_result[0]->mmonth)) {
        ?>
<select name='m'>
<option<?php 
        selected(@$_GET['m'], 0);
        ?>
 value='0'><?php 
        _e('Show all dates');
        ?>
</option>
<?php 
        foreach ($arc_result as $arc_row) {
            if ($arc_row->yyear == 0) {
                continue;
            }
            $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
            if ($arc_row->yyear . $arc_row->mmonth == $_GET['m']) {
                $default = ' selected="selected"';
            } else {
                $default = '';
            }
            echo "<option{$default} value='" . esc_attr($arc_row->yyear . $arc_row->mmonth) . "'>";
            echo esc_html($wp_locale->get_month($arc_row->mmonth) . " {$arc_row->yyear}");
            echo "</option>\n";
        }
        ?>
</select>
<?php 
    }
    ?>

<input type="submit" id="post-query-submit" value="<?php 
    echo esc_attr(__('Filter &#187;'));
    ?>
" class="button-secondary" />

</div>

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

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

<?php 
    wp_nonce_field('media-form');
    //media_upload_form( $errors );
    ?>

<script type="text/javascript">
<!--
jQuery(function($){
	var preloaded = $(".media-item.preloaded");
	if ( preloaded.length > 0 ) {
		preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
		updateMediaForm();
	}
});
-->
</script>

<div id="media-items">
<?php 
    add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
    echo get_media_items(null, $errors);
    ?>
</div>
<p class="ml-submit">
<input type="submit" class="button savebutton" name="save" value="<?php 
    esc_attr_e('Save all changes');
    ?>
" />
<input type="hidden" name="post_id" id="post_id" value="<?php 
    echo (int) $post_id;
    ?>
" />
</p>
</form>
<?php 
}
function sb_media_upload_suggested_form($errors)
{
    global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types, $images;
    media_upload_header();
    $images = explode(', ', $_GET['suggested']);
    ?>
    <script type="text/javascript">
    function doSend(url) {
        var win = window.dialogArguments || opener || parent || top;
        window.parent.send_to_editor(url);
        return false;
    }
    </script>

    <div style="margin:1em;">
        <h3 class="media-title">Use media files suggested by your theme</h3>
        <div id="media-items">
<?php 
    $missing = array();
    // to store all missing files for later error output
    foreach ($images as $index => $image) {
        global $blog_id;
        $replace = explode('/', get_blog_details($blog_id)->path);
        // necessary for timthumb to play nice with WordPress Multisite
        if (is_subdomain_install()) {
            $theme_uri = THEME_URI;
        } else {
            $theme_uri = str_replace($replace[2] . '/', '', THEME_URI);
        }
        $fullimage = $theme_uri . '/' . $image;
        if (!@getimagesize($fullimage)) {
            array_push($missing, $image);
            continue;
        }
        ?>
            <div id="media-item-<?php 
        echo $index;
        ?>
" class="media-item">
                <div style="float:right; width:30%; text-align:center; padding-top:35px;"><input type="button" value="Insert into Post" class="button" onclick="doSend('<?php 
        echo $fullimage;
        ?>
')"></div>
                <div style="width:70%; height:100px; overflow:hidden;">
                    <img src="<?php 
        echo SCRIPTS_URL;
        ?>
/timthumb.php?src=<?php 
        echo $fullimage;
        ?>
&amp;h=100&amp;zc=1&amp;cropfrom=middleleft&amp;q=100" alt="" height="100" />
                </div>
                <div style="clear:both;"></div>
            </div>
<?php 
    }
    // error output:
    if (count($missing) > 0) {
        ?>
        <div class="media-item">
            <div style="padding:1em;">
                Warning! The following items are missing from the current theme's directory:
                <ul style="list-style:inside circle; margin-top:1em;">
                <?php 
        foreach ($missing as $index => $url) {
            echo '<li style="padding-left:1em;">' . $url . '</li>';
        }
        ?>
                </ul>
            </div>
        </div>
<?php 
    }
    ?>
        </div>
    </div>
<?php 
}
Example #29
0
/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.0
 *
 * @param array $errors
 */
function media_upload_library_form($errors)
{
    global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types;
    media_upload_header();
    $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
    $form_action_url = admin_url("media-upload.php?type={$type}&tab=library&post_id={$post_id}");
    /** This filter is documented in wp-admin/includes/media.php */
    $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    $form_class = 'media-upload-form validate';
    if (get_user_setting('uploader')) {
        $form_class .= ' html-uploader';
    }
    $q = $_GET;
    $q['posts_per_page'] = 10;
    $q['paged'] = isset($q['paged']) ? intval($q['paged']) : 0;
    if ($q['paged'] < 1) {
        $q['paged'] = 1;
    }
    $q['offset'] = ($q['paged'] - 1) * 10;
    if ($q['offset'] < 1) {
        $q['offset'] = 0;
    }
    list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query($q);
    ?>

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

<p id="media-search" class="search-box">
	<label class="screen-reader-text" for="media-search-input"><?php 
    _e('Search Media');
    ?>
:</label>
	<input type="search" id="media-search-input" name="s" value="<?php 
    the_search_query();
    ?>
" />
	<?php 
    submit_button(__('Search Media'), 'button', '', false);
    ?>
</p>

<ul class="subsubsub">
<?php 
    $type_links = array();
    $_num_posts = (array) wp_count_attachments();
    $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
    foreach ($matches as $_type => $reals) {
        foreach ($reals as $real) {
            if (isset($num_posts[$_type])) {
                $num_posts[$_type] += $_num_posts[$real];
            } else {
                $num_posts[$_type] = $_num_posts[$real];
            }
        }
    }
    // If available type specified by media button clicked, filter by that type
    if (empty($_GET['post_mime_type']) && !empty($num_posts[$type])) {
        $_GET['post_mime_type'] = $type;
        list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
    }
    if (empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all') {
        $class = ' class="current"';
    } else {
        $class = '';
    }
    $type_links[] = '<li><a href="' . esc_url(add_query_arg(array('post_mime_type' => 'all', 'paged' => false, 'm' => false))) . '"' . $class . '>' . __('All Types') . '</a>';
    foreach ($post_mime_types as $mime_type => $label) {
        $class = '';
        if (!wp_match_mime_types($mime_type, $avail_post_mime_types)) {
            continue;
        }
        if (isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type'])) {
            $class = ' class="current"';
        }
        $type_links[] = '<li><a href="' . esc_url(add_query_arg(array('post_mime_type' => $mime_type, 'paged' => false))) . '"' . $class . '>' . sprintf(translate_nooped_plural($label[2], $num_posts[$mime_type]), '<span id="' . $mime_type . '-counter">' . number_format_i18n($num_posts[$mime_type]) . '</span>') . '</a>';
    }
    /**
     * Filter the media upload mime type list items.
     *
     * Returned values should begin with an <li> tag.
     *
     * @since 3.1.0
     *
     * @param array $type_links An array of list items containing mime type link HTML.
     */
    echo implode(' | </li>', apply_filters('media_upload_mime_type_links', $type_links)) . '</li>';
    unset($type_links);
    ?>
</ul>

<div class="tablenav">

<?php 
    $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($wp_query->found_posts / 10), 'current' => $q['paged']));
    if ($page_links) {
        echo "<div class='tablenav-pages'>{$page_links}</div>";
    }
    ?>

<div class="alignleft actions">
<?php 
    $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM {$wpdb->posts} WHERE post_type = 'attachment' ORDER BY post_date DESC";
    $arc_result = $wpdb->get_results($arc_query);
    $month_count = count($arc_result);
    $selected_month = isset($_GET['m']) ? $_GET['m'] : 0;
    if ($month_count && !(1 == $month_count && 0 == $arc_result[0]->mmonth)) {
        ?>
<select name='m'>
<option<?php 
        selected($selected_month, 0);
        ?>
 value='0'><?php 
        _e('All dates');
        ?>
</option>
<?php 
        foreach ($arc_result as $arc_row) {
            if ($arc_row->yyear == 0) {
                continue;
            }
            $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
            if ($arc_row->yyear . $arc_row->mmonth == $selected_month) {
                $default = ' selected="selected"';
            } else {
                $default = '';
            }
            echo "<option{$default} value='" . esc_attr($arc_row->yyear . $arc_row->mmonth) . "'>";
            echo esc_html($wp_locale->get_month($arc_row->mmonth) . " {$arc_row->yyear}");
            echo "</option>\n";
        }
        ?>
</select>
<?php 
    }
    ?>

<?php 
    submit_button(__('Filter &#187;'), 'button', 'post-query-submit', false);
    ?>

</div>

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

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

<?php 
    wp_nonce_field('media-form');
    //media_upload_form( $errors );
    ?>

<script type="text/javascript">
<!--
jQuery(function($){
	var preloaded = $(".media-item.preloaded");
	if ( preloaded.length > 0 ) {
		preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
		updateMediaForm();
	}
});
-->
</script>

<div id="media-items">
<?php 
    add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
    echo get_media_items(null, $errors);
    ?>
</div>
<p class="ml-submit">
<?php 
    submit_button(__('Save all changes'), 'button savebutton', 'save', false);
    ?>
<input type="hidden" name="post_id" id="post_id" value="<?php 
    echo (int) $post_id;
    ?>
" />
</p>
</form>
<?php 
}
Example #30
0
    public function s3_library_tab($type = 'file', $errors = null, $id = null)
    {
        media_upload_header();
        wp_enqueue_style('media');
        $page = isset($_GET['p']) ? $_GET['p'] : 1;
        $per_page = 30;
        $offset = $per_page * ($page - 1);
        $offset = $offset < 1 ? 30 : $offset;
        $start = isset($_GET['start']) ? rawurldecode($_GET['start']) : '';
        $bucket = isset($_GET['bucket']) ? rawurldecode($_GET['bucket']) : false;
        if (!$bucket) {
            $buckets = $this->get_s3_buckets();
            if (false === $buckets) {
                $errors = edd_get_errors();
                if (array_key_exists('edd-amazon-s3', $errors)) {
                    if (current_user_can('manage_options')) {
                        $message = $errors['edd-amazon-s3'];
                    } else {
                        $message = __('Error retrieving file. Please contact the site administrator.', 'edd_s3');
                    }
                    echo '<div class="update error"><p>' . $message . '</p></div>';
                    exit;
                }
            }
        } else {
            $this->bucket = $bucket;
            $files = $this->get_s3_files($start, $offset);
            if (false === $files) {
                $errors = edd_get_errors();
                if (array_key_exists('edd-amazon-s3', $errors)) {
                    if (current_user_can('manage_options')) {
                        $message = $errors['edd-amazon-s3'];
                    } else {
                        $message = __('Error retrieving file. Please contact the site administrator.', 'edd_s3');
                    }
                    echo '<div class="update error"><p>' . $message . '</p></div>';
                    exit;
                }
            }
        }
        ?>
		<script type="text/javascript">
			//<![CDATA[
			jQuery(function($){
				$('.insert-s3').on('click', function() {
					var file = $(this).data('s3');
					$(parent.window.edd_filename).val(file);
					$(parent.window.edd_fileurl).val( "<?php 
        echo $this->bucket;
        ?>
/" + file);
					parent.window.tb_remove();
				});
			});
			//]]>
		</script>
		<div style="margin: 20px 1em 1em; padding-right:20px;" id="media-items">
<?php 
        if (!$this->api_keys_entered()) {
            ?>
			<div class="error"><p><?php 
            printf(__('Please enter your <a href="%s" target="blank">Amazon S3 API keys</a>.', 'edd_s3'), admin_url('edit.php?post_type=download&page=edd-settings&tab=extensions'));
            ?>
</p></div>
<?php 
            return;
        }
        if (!$bucket) {
            ?>
				<h3 class="media-title"><?php 
            _e('Select a Bucket', 'edd_s3');
            ?>
</h3>
				<?php 
            if (is_array($buckets)) {
                echo '<table class="wp-list-table widefat fixed striped" style="max-height: 500px;overflow-y:scroll;">';
                echo '<tr>';
                echo '<th>' . __('Bucket name', 'edd_s3') . '</th>';
                echo '<th>' . __('Actions', 'edd_s3') . '</th>';
                echo '</tr>';
                foreach ($buckets as $key => $bucket) {
                    echo '<tr>';
                    echo '<td>' . $bucket . '</td>';
                    echo '<td>';
                    echo '<a href="' . esc_url(add_query_arg('bucket', $bucket)) . '">' . __('Browse', 'edd_s3') . '</a>';
                    echo '</td>';
                    echo '</tr>';
                }
                echo '</table>';
            }
        } else {
            $back = admin_url('media-upload.php?post_id=' . absint($_GET['post_id']));
            if (is_array($files)) {
                $i = 0;
                $total_items = count($files);
                echo '<p><button class="button-secondary" onclick="history.back();">' . __('Go Back', 'edd_s3') . '</button></p>';
                echo '<table class="wp-list-table widefat fixed striped" style="max-height: 500px;overflow-y:scroll;">';
                echo '<tr>';
                echo '<th>' . __('File name', 'edd_s3') . '</th>';
                echo '<th>' . __('Actions', 'edd_s3') . '</th>';
                echo '</tr>';
                foreach ($files as $key => $file) {
                    echo '<tr>';
                    if ($i == 0) {
                        $first_file = $key;
                    }
                    if ($i == 14) {
                        $last_file = $key;
                    }
                    if ($file['name'][strlen($file['name']) - 1] === '/') {
                        continue;
                        // Don't show folders
                    }
                    echo '<td style="padding-right:20px;">' . $file['name'] . '</td>';
                    echo '<td>';
                    echo '<a class="insert-s3 button-secondary" href="#" data-s3="' . esc_attr($file['name']) . '">' . __('Use File', 'edd_s3') . '</a>';
                    echo '</td>';
                    echo '</tr>';
                    $i++;
                }
                echo '</table>';
            }
            $base = admin_url('media-upload.php?post_id=' . absint($_GET['post_id']) . '&tab=s3_library');
            if ($bucket) {
                $base = add_query_arg('bucket', $bucket, $base);
            }
            echo '<div class="s3-pagination tablenav">';
            echo '<div class="tablenav-pages alignright">';
            if (isset($_GET['p']) && $_GET['p'] > 1) {
                echo '<a class="page-numbers prev" href="' . esc_url(remove_query_arg('p', $base)) . '">' . __('Start Over', 'edd_s3') . '</a>';
            }
            if ($i >= 10) {
                echo '<a class="page-numbers next" href="' . esc_url(add_query_arg(array('p' => $page + 1, 'start' => $last_file), $base)) . '">' . __('View More', 'edd_s3') . '</a>';
            }
            echo '</div>';
            echo '</div>';
        }
        ?>
		</div>
<?php 
    }