add_block(new Block("Upload", $this->build_upload_block(), "left", 20)); } public function display_full(Page $page) { $page->add_block(new Block("Upload", "Disk nearly full, uploads disabled", "left", 20)); } public function display_page(Page $page) { global $config, $page; $tl_enabled = ($config->get_string("transload_engine", "none") != "none"); $max_size = $config->get_int('upload_size'); $max_kb = to_shorthand_int($max_size); $upload_list = $this->h_upload_list_1(); $html = " ".make_form(make_link("upload"), "POST", $multipart=True, 'file_upload')." $upload_list
Tags
Source
(Max file size is $max_kb) "; $page->set_title("Upload"); $page->set_heading("Upload"); $page->add_block(new NavBlock()); $page->add_block(new Block("Upload", $html, "main", 20)); if($tl_enabled) { $page->add_block(new Block("Bookmarklets", $this->h_bookmarklets(), "left", 20)); } } protected function h_upload_list_1() { global $config; $upload_list = ""; $upload_count = $config->get_int('upload_count'); $tl_enabled = ($config->get_string("transload_engine", "none") != "none"); if($tl_enabled) { $upload_list .= " Files URLs Image-Specific Tags "; for($i=0; $i<$upload_count; $i++) { $upload_list .= " "; } } else { $upload_list .= " Files Image-Specific Tags "; for($i=0; $i<$upload_count; $i++) { $upload_list .= " "; } } return $upload_list; } protected function h_upload_List_2() { global $config; $tl_enabled = ($config->get_string("transload_engine", "none") != "none"); // Uploader 2.0! $upload_list = ""; $upload_count = $config->get_int('upload_count'); for($i=0; $i<$upload_count; $i++) { $a = $i+1; $s = $i-1; if($i != 0) { $upload_list .=""; }else{ $upload_list .= ""; } $upload_list .= ""; if($i == 0) { $js = 'javascript:$(function() { $("#row'.$a.'").show(); $("#hide'.$i.'").hide(); $("#hide'.$a.'").show();});'; $upload_list .= "
"; } else { $js = 'javascript:$(function() { $("#row'.$i.'").hide(); $("#hide'.$i.'").hide(); $("#hide'.$s.'").show(); $("#data'.$i.'").val(""); $("#url'.$i.'").val(""); });'; $upload_list .="
"; if($a == $upload_count){ $upload_list .=""; } else{ $js1 = 'javascript:$(function() { $("#row'.$a.'").show(); $("#hide'.$i.'").hide(); $("#hide'.$a.'").show(); });'; $upload_list .= "". ""; } $upload_list .= "
"; } $upload_list .= ""; $js2 = 'javascript:$(function() { $("#url'.$i.'").hide(); $("#url'.$i.'").val(""); $("#data'.$i.'").show(); });'; $upload_list .= "
File
"; if($tl_enabled) { $js = 'javascript:$(function() { $("#data'.$i.'").hide(); $("#data'.$i.'").val(""); $("#url'.$i.'").show(); });'; $upload_list .= " URL
"; } else { $upload_list .= " "; } $upload_list .= " "; } return $upload_list; } protected function h_bookmarklets() { global $config; $link = make_http(make_link("upload")); $main_page = make_http(make_link()); $title = $config->get_string('title'); $max_size = $config->get_int('upload_size'); $max_kb = to_shorthand_int($max_size); $delimiter = $config->get_bool('nice_urls') ? '?' : '&'; $html = ''; $js='javascript:( function() { if(typeof window=="undefined" || !window.location || window.location.href=="about:blank") { window.location = "'. $main_page .'"; } else if(typeof document=="undefined" || !document.body) { window.location = "'. $main_page .'?url="+encodeURIComponent(window.location.href); } else if(window.location.href.match("\/\/'. $_SERVER["HTTP_HOST"] .'.*")) { alert("You are already at '. $title .'!"); } else { var tags = prompt("Please enter tags", "tagme"); if(tags != "" && tags != null) { var link = "'. $link . $delimiter .'url="+location.href+"&tags="+tags; var w = window.open(link, "_blank"); } } } )();'; $html .= 'Upload to '.$title.''; $html .= ' (Drag & drop onto your bookmarks toolbar, then click when looking at an image)'; // Bookmarklet checks if shimmie supports ext. If not, won't upload to site/shows alert saying not supported. $supported_ext = "jpg jpeg gif png"; if(class_exists("FlashFileHandler")){$supported_ext .= " swf";} if(class_exists("ICOFileHandler")){$supported_ext .= " ico ani cur";} if(class_exists("MP3FileHandler")){$supported_ext .= " mp3";} if(class_exists("SVGFileHandler")){$supported_ext .= " svg";} $title = "Booru to " . $config->get_string('title'); // CA=0: Ask to use current or new tags | CA=1: Always use current tags | CA=2: Always use new tags $html .= '

'. $title . ' (Click when looking at an image page. Works on sites running Shimmie / Danbooru / Gelbooru. (This also grabs the tags / rating / source!))'; return $html; } /** * Only allows 1 file to be uploaded - for replacing another image file. * * @param Page $page * @param int $image_id */ public function display_replace_page(Page $page, /*int*/ $image_id) { global $config, $page; $tl_enabled = ($config->get_string("transload_engine", "none") != "none"); $upload_list = " File "; if($tl_enabled) { $upload_list .=" or URL "; } $upload_list .= ""; $max_size = $config->get_int('upload_size'); $max_kb = to_shorthand_int($max_size); $image = Image::by_id($image_id); $thumbnail = $this->build_thumb_html($image, null); $html = "

Replacing Image ID ".$image_id."
Please note: You will have to refresh the image page, or empty your browser cache.

" .$thumbnail."
" .make_form(make_link("upload/replace/".$image_id), "POST", $multipart=True)." $upload_list
Source
(Max file size is $max_kb) "; $page->set_title("Replace Image"); $page->set_heading("Replace Image"); $page->add_block(new NavBlock()); $page->add_block(new Block("Upload Replacement Image", $html, "main", 20)); } /** * @param Page $page * @param bool $ok */ public function display_upload_status(Page $page, /*bool*/ $ok) { if($ok) { $page->set_mode("redirect"); $page->set_redirect(make_link()); } else { $page->set_title("Upload Status"); $page->set_heading("Upload Status"); $page->add_block(new NavBlock()); } } /** * @param Page $page * @param string $title * @param string $message */ public function display_upload_error(Page $page, /*string*/ $title, /*string*/ $message) { $page->add_block(new Block($title, $message)); } protected function build_upload_block() { global $config; $upload_list = ""; $upload_count = $config->get_int('upload_count'); for($i=0; $i<$upload_count; $i++) { if($i == 0) $style = ""; // "style='display:visible'"; else $style = "style='display:none'"; $upload_list .= "\n"; } $max_size = $config->get_int('upload_size'); $max_kb = to_shorthand_int($max_size); // return "
".make_form(make_link("upload"), "POST", $multipart=True)." $upload_list (Max file size is $max_kb)
"; } }