From cd11e75e405f1f8470750b929bd29197d37733ce Mon Sep 17 00:00:00 2001 From: Daku Date: Fri, 23 Dec 2011 21:27:38 +0000 Subject: [PATCH 1/6] Can now set rating/external source while uploading via the bookmarklets. --- core/extension.class.php | 7 ++++++ ext/upload/main.php | 46 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/core/extension.class.php b/core/extension.class.php index 9b514318..7906822b 100644 --- a/core/extension.class.php +++ b/core/extension.class.php @@ -177,6 +177,13 @@ abstract class DataHandlerExtension implements Extension { $iae = new ImageAdditionEvent($event->user, $image); send_event($iae); $event->image_id = $iae->image->id; + + // Rating Stuff. + if(file_exists("ext/rating") && !empty($event->metadata['rating'])){ + global $database; + $rating = $event->metadata['rating']; + $database->Execute("UPDATE images SET rating=? WHERE id=?", array($rating, $event->image_id)); + } } } diff --git a/ext/upload/main.php b/ext/upload/main.php index 167bce07..fd8e5e6a 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -173,7 +173,35 @@ class Upload implements Extension { if(!empty($_GET['tags']) && $_GET['tags'] != "null") { $tags = Tag::explode($_GET['tags']); } - $ok = $this->try_transload($url, $tags, $url); + + + + // Checks if url contains rating, also checks if the rating extension is enabled. + if($config->get_string("transload_engine", "none") != "none" && file_exists("ext/rating") && !empty($_GET['rating'])) { + $rating = strtolower($_GET['rating']); + // There must be a less messy way to do this.. + if($rating !== "") { + if($rating == "s" || $rating == "safe" || $rating == "q" || $rating == "questionable" || $rating == "e" || $rating == "explicit") { + if($rating == "s" || $rating == "safe" || $rating == "q" || $rating == "questionable") { + if($rating == "s" || $rating == "safe") { + $rating = "s"; + }else{ + $rating = "q"; + } + }else{ + $rating = "e"; + } + }else{ + $rating = "u"; + } + }else{ + $rating = "u"; + } + }else{ + $rating = ""; + } + + $ok = $this->try_transload($url, $tags, $rating, $url); $this->theme->display_upload_status($page, $ok); } else @@ -250,7 +278,7 @@ class Upload implements Extension { } } - private function try_upload($file, $tags, $source, $replace='') { + private function try_upload($file, $tags, $rating, $source, $replace='') { global $page; global $config; global $user; @@ -296,13 +324,18 @@ class Upload implements Extension { return $ok; } - private function try_transload($url, $tags, $source, $replace='') { + private function try_transload($url, $tags, $rating, $source, $replace='') { global $page; global $config; $ok = true; - if(empty($source)) $source = $url; + //Allows external source to be set. + if(!empty($_GET['source'])){ + $source = $_GET['source']; + }else{ + $source = $url; + } // PHP falls back to system default if /tmp fails, can't we just // use the system default to start with? :-/ @@ -363,6 +396,11 @@ class Upload implements Extension { $metadata['tags'] = $tags; $metadata['source'] = $source; + /* check for rating > adds to metadata if it has */ + if($config->get_string("transload_engine", "none") != "none" && file_exists("ext/rating") && !empty($_GET['rating'])){ + $metadata['rating'] = $rating; + } + /* check if we have been given an image ID to replace */ if (!empty($replace)) { $metadata['replace'] = $replace; From 42b902ecb56c762c1685173ac1205e26080a84cd Mon Sep 17 00:00:00 2001 From: Daku Date: Fri, 23 Dec 2011 21:28:47 +0000 Subject: [PATCH 2/6] Bookmarklet should now grab the rating, aswell as the image page link for source. --- ext/upload/theme.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ext/upload/theme.php b/ext/upload/theme.php index a18adbe5..7ce049cf 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -80,13 +80,17 @@ class UploadTheme extends Themelet { $title . ' (Drag & drop onto your bookmarks toolbar, then click when looking at an image)'; } { + /* Danbooru > Shimmie Bookmarklet. + This "should" work on any site running danbooru, unless for some odd reason they switched around the id's or aren't using post/list. + */ $title = "Danbooru to " . $config->get_string('title'); $html .= '

' . - $title . ' (As above, Click on a Danbooru-run image page. (This also grabs the tags!))'; + $link . $delimiter . 'url=";var tag=document.getElementById("post_old_tags").value;var doc=document.documentElement.innerHTML;var rtg=doc.match("

  • Rating: (.*)<\/li>");var srx="http://" + document.location.hostname + document.location.href.match("\/post\/show\/.*\/");' . + 'if (confirm("OK = Use Current tags.\nCancel = Use new tags.")==true)' . + '{if(tag.search(/\bflash\b/)==-1){location.href=ste+img+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;}else{location.href=ste+document.getElementsByName("movie")[0].value' . + '+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;}}else{var p=prompt("Enter Tags","");if(tag.search(/\bflash\b/)==-1){location.href=ste+img+"&tags="+p+"&rating="+rtg[1]+"&source="+srx;}' . + 'else{location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+p+"&rating="+rtg[1]+"&source="+srx;}}">' . + $title . ' (As above, Click on a Danbooru-run image page. (This also grabs the tags, rating & source!))'; } From ee1fc7e3ae9a88ac297a7de51be8b10cdf383534 Mon Sep 17 00:00:00 2001 From: Daku Date: Sat, 24 Dec 2011 20:18:00 +0000 Subject: [PATCH 3/6] Admin can now lock image while transloading. --- core/extension.class.php | 8 ++++- ext/upload/main.php | 78 +++++++++++++++++++++++----------------- 2 files changed, 53 insertions(+), 33 deletions(-) diff --git a/core/extension.class.php b/core/extension.class.php index 7906822b..4571b1c0 100644 --- a/core/extension.class.php +++ b/core/extension.class.php @@ -179,11 +179,17 @@ abstract class DataHandlerExtension implements Extension { $event->image_id = $iae->image->id; // Rating Stuff. - if(file_exists("ext/rating") && !empty($event->metadata['rating'])){ + if(!empty($event->metadata['rating'])){ global $database; $rating = $event->metadata['rating']; $database->Execute("UPDATE images SET rating=? WHERE id=?", array($rating, $event->image_id)); } + + // Locked Stuff. + if(!empty($event->metadata['locked'])){ + $locked = $event->metadata['locked']; + send_event(new LockSetEvent($image, !empty($locked))); + } } } diff --git a/ext/upload/main.php b/ext/upload/main.php index fd8e5e6a..36e0914c 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -173,35 +173,8 @@ class Upload implements Extension { if(!empty($_GET['tags']) && $_GET['tags'] != "null") { $tags = Tag::explode($_GET['tags']); } - - - - // Checks if url contains rating, also checks if the rating extension is enabled. - if($config->get_string("transload_engine", "none") != "none" && file_exists("ext/rating") && !empty($_GET['rating'])) { - $rating = strtolower($_GET['rating']); - // There must be a less messy way to do this.. - if($rating !== "") { - if($rating == "s" || $rating == "safe" || $rating == "q" || $rating == "questionable" || $rating == "e" || $rating == "explicit") { - if($rating == "s" || $rating == "safe" || $rating == "q" || $rating == "questionable") { - if($rating == "s" || $rating == "safe") { - $rating = "s"; - }else{ - $rating = "q"; - } - }else{ - $rating = "e"; - } - }else{ - $rating = "u"; - } - }else{ - $rating = "u"; - } - }else{ - $rating = ""; - } - - $ok = $this->try_transload($url, $tags, $rating, $url); + + $ok = $this->try_transload($url, $tags, $url); $this->theme->display_upload_status($page, $ok); } else @@ -278,7 +251,7 @@ class Upload implements Extension { } } - private function try_upload($file, $tags, $rating, $source, $replace='') { + private function try_upload($file, $tags, $source, $replace='') { global $page; global $config; global $user; @@ -324,9 +297,10 @@ class Upload implements Extension { return $ok; } - private function try_transload($url, $tags, $rating, $source, $replace='') { + private function try_transload($url, $tags, $source, $replace='') { global $page; global $config; + global $user; $ok = true; @@ -336,6 +310,41 @@ class Upload implements Extension { }else{ $source = $url; } + + // Checks if user is admin > check if you want locked. + if($user->is_admin()){ + // There must be a less messy way to do this.. + if($_GET['locked'] == "y" || $_GET['locked'] == "yes" || $_GET['locked'] == "true" || $_GET['locked'] == "on" || $_GET['locked'] == "n" || $_GET['locked'] == "no" || $_GET['locked'] == "false" || $_GET['locked'] == "off"){ + if($_GET['locked'] == "y" || $_GET['locked'] == "yes" || $_GET['locked'] == "true" || $_GET['locked'] == "on"){ + $locked = "on"; + } + } + } + + // Checks if url contains rating, also checks if the rating extension is enabled. + if($config->get_string("transload_engine", "none") != "none" && file_exists("ext/rating") && !empty($_GET['rating'])) { + $rating = strtolower($_GET['rating']); + // There REALLY must be a less messy way to do this.. + if($rating !== "") { + if($rating == "s" || $rating == "safe" || $rating == "q" || $rating == "questionable" || $rating == "e" || $rating == "explicit") { + if($rating == "s" || $rating == "safe" || $rating == "q" || $rating == "questionable") { + if($rating == "s" || $rating == "safe") { + $rating = "s"; + }else{ + $rating = "q"; + } + }else{ + $rating = "e"; + } + }else{ + $rating = "u"; + } + }else{ + $rating = "u"; + } + }else{ + $rating = ""; + } // PHP falls back to system default if /tmp fails, can't we just // use the system default to start with? :-/ @@ -396,8 +405,13 @@ class Upload implements Extension { $metadata['tags'] = $tags; $metadata['source'] = $source; + /* check for locked > adds to metadata if it has */ + if(!empty($locked)){ + $metadata['locked'] = $locked; + } + /* check for rating > adds to metadata if it has */ - if($config->get_string("transload_engine", "none") != "none" && file_exists("ext/rating") && !empty($_GET['rating'])){ + if(!empty($rating)){ $metadata['rating'] = $rating; } From 394f4518a31192b5403320b679210f2c0c744e65 Mon Sep 17 00:00:00 2001 From: Daku Date: Sat, 24 Dec 2011 23:28:33 +0000 Subject: [PATCH 4/6] More improvements to the uploader. --- ext/upload/minus.png | Bin 0 -> 212 bytes ext/upload/plus.png | Bin 0 -> 269 bytes ext/upload/style.css | 5 +++++ ext/upload/theme.php | 51 ++++++++++++++++++++++++++++++++++--------- 4 files changed, 46 insertions(+), 10 deletions(-) create mode 100644 ext/upload/minus.png create mode 100644 ext/upload/plus.png diff --git a/ext/upload/minus.png b/ext/upload/minus.png new file mode 100644 index 0000000000000000000000000000000000000000..57c86dec53054cc72ef0452fb7718bbc2e205be9 GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^{2~)xwMhD znL)t$V!5F82G3JItw%CKzG!e8IHxTzU=1m0n4-4v$*EsOiQz)wUkjY~bC?H&%Eq<7 z=@gUS!+&$mlI{Mc3hFkhH)k0pSzhM(YJXDvVJXAKB`RVCdTLofTNpfD{an^LB{Ts5 DG$%k} literal 0 HcmV?d00001 diff --git a/ext/upload/plus.png b/ext/upload/plus.png new file mode 100644 index 0000000000000000000000000000000000000000..d7ec0ae3036fcfceb702ee3787cc2e6ddf410d1b GIT binary patch literal 269 zcmeAS@N?(olHy`uVBq!ia0vp^{2L&MZ!+2Ho1iJ6}se26bfKAWr&*O?9_h$NA0ETrpy1get_int('upload_count'); $i++) { - $n = $i + 1; - $upload_list .= " - -
    File
    "; + $a=$i+1; + $s=$i-1; + if(!$i==0){ + $upload_list .=""; + }else{ + $upload_list .= ""; + } + $upload_list .= ""; + + if($i==0){ + $upload_list .= "
    " . + "". + "
    "; + }else{ + $upload_list .="
    + ". + ""; + if($a==$config->get_int('upload_count')){ + $upload_list .=""; + }else{ + $upload_list .= + "". + ""; + } + $upload_list .= "
    "; + } + + $upload_list .= + " File
    "; if($tl_enabled) { - $upload_list .=" - URL
    + $upload_list .= + " URL "; @@ -58,8 +89,8 @@ class UploadTheme extends Themelet { ".make_form(make_link("upload"), "POST", $multipart=True)." $upload_list - - + +
    Tags
    Source
    Tags
    Source
    @@ -110,10 +141,10 @@ class UploadTheme extends Themelet { $upload_list = ''; $upload_list .= " -
    File
    "; + File
    "; if($tl_enabled) { $upload_list .=" - URL
    + URL "; } else { From c645fb4b0ef27a5141ecb69d5fa2bc7df72ff88c Mon Sep 17 00:00:00 2001 From: Daku Date: Sun, 25 Dec 2011 09:47:34 +0000 Subject: [PATCH 5/6] Title should now always stay as site name, to avoid tag hell for images with loads of tags. --- themes/warm/layout.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/themes/warm/layout.class.php b/themes/warm/layout.class.php index 3d6c2cb7..c843eb3a 100644 --- a/themes/warm/layout.class.php +++ b/themes/warm/layout.class.php @@ -10,7 +10,9 @@ class Layout { global $config; $theme_name = $config->get_string('theme', 'default'); + $site_name = $config->get_string('title'); $data_href = get_base_href(); + $main_page = $config->get_string('main_page'); $contact_link = $config->get_string('contact_link'); $header_html = ""; @@ -67,7 +69,7 @@ $header_html $head_block_html From 66484a8e68fcd7de3a01eb852a04e98c0466d759 Mon Sep 17 00:00:00 2001 From: Daku Date: Sun, 25 Dec 2011 10:04:07 +0000 Subject: [PATCH 6/6] Thumbs should now be centered. --- themes/lite/themelet.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/lite/themelet.class.php b/themes/lite/themelet.class.php index d5b5e479..a9a21f8b 100644 --- a/themes/lite/themelet.class.php +++ b/themes/lite/themelet.class.php @@ -59,13 +59,13 @@ class Themelet { $tsize = get_thumbnail_size($image->width, $image->height); } return " -
    +
    $h_tip -
    +
    "; }