Esempio n. 1
0
    /**
     * Load dbx javascript
     */
    function addHeaderCode()
    {
        if (function_exists('wp_enqueue_script')) {
            if ($this->_oc->getValue('enableBatchUploads')) {
                wp_enqueue_script('swfu-callback', plugins_url('photoq-photoblog-plugin/js/swfu-callback.js'), array('jquery', 'swfupload'), '20080217');
                wp_localize_script('swfu-callback', 'swfuCallbackL10n', array('cancelConfirm' => __('Are you sure you want to cancel the upload?', 'PhotoQ'), 'allUp' => __('All files uploaded.', 'PhotoQ'), 'select' => __('Select Photos...', 'PhotoQ'), 'uploading' => __('Uploading', 'PhotoQ'), 'file' => __('The file', 'PhotoQ'), 'isZero' => __('has a size of zero.', 'PhotoQ'), 'invType' => __('has an invalid filetype.', 'PhotoQ'), 'exceed' => __('exceeds the upload file size limit of', 'PhotoQ'), 'ini' => __('KB in your php.ini config file.', 'PhotoQ'), 'tooMany' => __('You have attempted to queue too many files.', 'PhotoQ'), 'queueEmpty' => __('Upload Queue is empty', 'PhotoQ'), 'addMore' => __('Add more...', 'PhotoQ'), 'queued' => __('photos queued for upload', 'PhotoQ'), 'cancelled' => __('cancelled', 'PhotoQ')));
            }
            wp_enqueue_script('ajax-queue', plugins_url('photoq-photoblog-plugin/js/ajax-queue.js'), array('jquery-ui-sortable'), '20080302');
            wp_localize_script('ajax-queue', 'ajaxQueueL10n', array('allowReorder' => current_user_can('reorder_photoq')));
        }
        if ($this->_oc->getValue('enableBatchUploads') && (isset($_POST['add_entry']) || isset($_POST['update_photos']))) {
            $uploadLink = get_bloginfo('wpurl') . '/wp-admin/edit.php?page=whoismanu-photoq.php';
            $uploadLink = function_exists('wp_nonce_url') ? wp_nonce_url($uploadLink, 'photoq-uploadBatch') : $uploadLink;
            //flash doesn't seem to like encoded ampersands, so convert them back here
            $uploadLink = str_replace('&', '&', $uploadLink);
            ?>
	
			<script type="text/javascript">
				//<![CDATA[
			
				var swfu; 
				var uplsize = 0;
				
				
				window.onload = function () { 
					swfu = new SWFUpload({ 
						debug: false,
						upload_url : "<?php 
            echo $uploadLink;
            ?>
", 
						flash_url : "<?php 
            echo includes_url('js/swfupload/swfupload.swf');
            ?>
", 
						file_size_limit : <?php 
            echo PhotoQHelper::getMaxFileSizeFromPHPINI();
            ?>
,	// max allowed by php.ini
						file_queue_limit: 0,
						file_types : "*.jpg;*.gif;*.png",
						file_types_description: "Web Image Files...",
						post_params : { "auth_cookie" : "<?php 
            if (is_ssl()) {
                echo $_COOKIE[SECURE_AUTH_COOKIE];
            } else {
                echo $_COOKIE[AUTH_COOKIE];
            }
            ?>
",
										"batch_upload" : "1",
										"_wpnonce" : "<?php 
            echo wp_create_nonce('photoq-uploadBatch');
            ?>
" },
						file_queue_error_handler : fileQueueError,
						file_queued_handler : fileQueued, 
						file_dialog_complete_handler : fileDialogComplete, 
						upload_start_handler : uploadStart,
						upload_progress_handler : uploadProgress,
						upload_error_handler : uploadError,
						upload_success_handler : uploadSuccess,
						upload_complete_handler : uploadComplete,
						button_text: '<span class="button"><?php 
            _e('Select Photos...', 'PhotoQ');
            ?>
<\/span>',
						button_text_style: '.button { color: #ffffff; text-align: center; font-size: 11px; font-weight: bold; font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif; }',
						button_height: "22",
						button_width: "134",
						button_image_url: '<?php 
            echo plugins_url('photoq-photoblog-plugin/imgs/upload.png');
            ?>
',
						button_placeholder_id: "flash-browse-button"
					}); 
					
				};
	
				//]]>
							
			</script>
		
			<?php 
        }
        //if($this->_oc->getValue('enableBatchUploads'))
        // the following are needed to pass stuff to the ajax js
        ?>
	
		<script type="text/javascript">
			var ajaxUrl = "<?php 
        echo plugins_url('photoq-photoblog-plugin/whoismanu-photoq-ajax.php');
        ?>
";
		</script>
	
	<?php 
    }