Merge pull request #63 from DakuTree/master
Few new features + More fixes
This commit is contained in:
commit
d25ef4e6f6
8 changed files with 126 additions and 19 deletions
|
@ -177,6 +177,19 @@ abstract class DataHandlerExtension implements Extension {
|
|||
$iae = new ImageAdditionEvent($event->user, $image);
|
||||
send_event($iae);
|
||||
$event->image_id = $iae->image->id;
|
||||
|
||||
// Rating Stuff.
|
||||
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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,6 +173,7 @@ class Upload implements Extension {
|
|||
if(!empty($_GET['tags']) && $_GET['tags'] != "null") {
|
||||
$tags = Tag::explode($_GET['tags']);
|
||||
}
|
||||
|
||||
$ok = $this->try_transload($url, $tags, $url);
|
||||
$this->theme->display_upload_status($page, $ok);
|
||||
}
|
||||
|
@ -299,10 +300,51 @@ class Upload implements Extension {
|
|||
private function try_transload($url, $tags, $source, $replace='') {
|
||||
global $page;
|
||||
global $config;
|
||||
global $user;
|
||||
|
||||
$ok = true;
|
||||
|
||||
if(empty($source)) $source = $url;
|
||||
//Allows external source to be set.
|
||||
if(!empty($_GET['source'])){
|
||||
$source = $_GET['source'];
|
||||
}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? :-/
|
||||
|
@ -363,6 +405,16 @@ 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(!empty($rating)){
|
||||
$metadata['rating'] = $rating;
|
||||
}
|
||||
|
||||
/* check if we have been given an image ID to replace */
|
||||
if (!empty($replace)) {
|
||||
$metadata['replace'] = $replace;
|
||||
|
|
BIN
ext/upload/minus.png
Normal file
BIN
ext/upload/minus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 212 B |
BIN
ext/upload/plus.png
Normal file
BIN
ext/upload/plus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 269 B |
|
@ -5,5 +5,10 @@
|
|||
#radio_button {
|
||||
width: auto;
|
||||
}
|
||||
#wrapper {
|
||||
opacity : 0.4;
|
||||
filter: alpha(opacity=40); // msie
|
||||
}
|
||||
|
||||
/* This is needed since the theme style.css forcibly sets vertical align to "top". */
|
||||
TABLE.vert TD, TABLE.vert TH {vertical-align: middle;}
|
||||
|
|
|
@ -16,13 +16,44 @@ class UploadTheme extends Themelet {
|
|||
// Uploader 2.0!
|
||||
$upload_list = "";
|
||||
for($i=0; $i<$config->get_int('upload_count'); $i++) {
|
||||
$n = $i + 1;
|
||||
$upload_list .= "
|
||||
<tr>
|
||||
<td width='60'><form><input id='radio_buttona' type='radio' name='method' value='file' checked='checked' onclick='javascript:document.getElementById("url$i").style.display = "none";document.getElementById("url$i").value = "";document.getElementById("data$i").style.display = "inline"' /> File<br>";
|
||||
$a=$i+1;
|
||||
$s=$i-1;
|
||||
if(!$i==0){
|
||||
$upload_list .="<tr id='row$i' style='display:none'>";
|
||||
}else{
|
||||
$upload_list .= "<tr id='row$i'>";
|
||||
}
|
||||
$upload_list .= "<td width='15'>";
|
||||
|
||||
if($i==0){
|
||||
$upload_list .= "<div id='hide$i'><img id='wrapper' src='ext/upload/minus.png' />" .
|
||||
"<a href='javascript:document.getElementById("row$a").style.display = "";javascript:document.getElementById("hide$i").style.display = "none";javascript:document.getElementById("hide$a").style.display = "";'>".
|
||||
"<img src='ext/upload/plus.png'></a></div></td>";
|
||||
}else{
|
||||
$upload_list .="<div id='hide$i'>
|
||||
<a href='javascript:document.getElementById("row$i").style.display = "none";".
|
||||
"document.getElementById("hide$i").style.display = "none";".
|
||||
"document.getElementById("hide$s").style.display = "";".
|
||||
"document.getElementById("data$i").value = "";".
|
||||
"document.getElementById("url$i").value = "";'>".
|
||||
"<img src='ext/upload/minus.png' /></a>";
|
||||
if($a==$config->get_int('upload_count')){
|
||||
$upload_list .="<img id='wrapper' src='ext/upload/plus.png' />";
|
||||
}else{
|
||||
$upload_list .=
|
||||
"<a href='javascript:document.getElementById("row$a").style.display = "";".
|
||||
"document.getElementById("hide$i").style.display = "none";".
|
||||
"document.getElementById("hide$a").style.display = "";'>".
|
||||
"<img src='ext/upload/plus.png' /></a>";
|
||||
}
|
||||
$upload_list .= "</div></td>";
|
||||
}
|
||||
|
||||
$upload_list .=
|
||||
"<td width='60'><form><input id='radio_buttona' type='radio' name='method' value='file' checked='checked' onclick='javascript:document.getElementById("url$i").style.display = "none";document.getElementById("url$i").value = "";document.getElementById("data$i").style.display = ""' /> File<br>";
|
||||
if($tl_enabled) {
|
||||
$upload_list .="
|
||||
<input id='radio_buttonb' type='radio' name='method' value='url' onclick='javascript:document.getElementById("data$i").style.display = "none";document.getElementById("data$i").value = "";document.getElementById("url$i").style.display = "inline"' /> URL</ br></td></form>
|
||||
$upload_list .=
|
||||
"<input id='radio_buttonb' type='radio' name='method' value='url' onclick='javascript:document.getElementById("data$i").style.display = "none";document.getElementById("data$i").value = "";document.getElementById("url$i").style.display = ""' /> URL</ br></td></form>
|
||||
|
||||
<td><input id='data$i' name='data$i' class='wid' type='file'><input id='url$i' name='url$i' class='wid' type='text' style='display:none'></td>
|
||||
";
|
||||
|
@ -58,8 +89,8 @@ class UploadTheme extends Themelet {
|
|||
".make_form(make_link("upload"), "POST", $multipart=True)."
|
||||
<table id='large_upload_form' class='vert'>
|
||||
$upload_list
|
||||
<tr><td>Tags</td><td colspan='3'><input id='tag_box' name='tags' type='text'></td></tr>
|
||||
<tr><td>Source</td><td colspan='3'><input name='source' type='text'></td></tr>
|
||||
<tr><td></td><td>Tags<td colspan='3'><input id='tag_box' name='tags' type='text'></td></tr>
|
||||
<tr><td></td><td>Source</td><td colspan='3'><input name='source' type='text'></td></tr>
|
||||
<tr><td colspan='4'><input id='uploadbutton' type='submit' value='Post'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
|
@ -80,13 +111,17 @@ class UploadTheme extends Themelet {
|
|||
$title . '</a> (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 .= '<p><a href="javascript:var img=document.getElementById("highres").href;var ste="' .
|
||||
$link . $delimiter . 'url=";var tag=document.getElementById("post_old_tags").value;if (confirm("OK = Use Current tags.\nCancel = Use new tags.")==true)' .
|
||||
'{if(tag.search(/\bflash\b/)==-1){location.href=ste+img+"&tags="+tag;}else{location.href=ste+document.getElementsByName("movie")[0].value' .
|
||||
'+"&tags="+tag;}}else{var p=prompt("Enter Tags","");if(tag.search(/\bflash\b/)==-1){location.href=ste+img+"&tags="+p;}' .
|
||||
'else{location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+p;}}">' .
|
||||
$title . '</a> (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("<li>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 . '</a> (As above, Click on a Danbooru-run image page. (This also grabs the tags, rating & source!))';
|
||||
|
||||
}
|
||||
|
||||
|
@ -106,10 +141,10 @@ class UploadTheme extends Themelet {
|
|||
$upload_list = '';
|
||||
$upload_list .= "
|
||||
<tr>
|
||||
<td width='60'><form><input id='radio_buttona' type='radio' name='method' value='file' checked='checked' onclick='javascript:document.getElementById("url0").style.display = "none";document.getElementById("url0").value = "";document.getElementById("data0").style.display = "inline"' /> File<br>";
|
||||
<td width='60'><form><input id='radio_buttona' type='radio' name='method' value='file' checked='checked' onclick='javascript:document.getElementById("url0").style.display = "none";document.getElementById("url0").value = "";document.getElementById("data0").style.display = ""' /> File<br>";
|
||||
if($tl_enabled) {
|
||||
$upload_list .="
|
||||
<input id='radio_buttonb' type='radio' name='method' value='url' onclick='javascript:document.getElementById("data0").style.display = "none";document.getElementById("data0").value = "";document.getElementById("url0").style.display = "inline"' /> URL</ br></td></form>
|
||||
<input id='radio_buttonb' type='radio' name='method' value='url' onclick='javascript:document.getElementById("data0").style.display = "none";document.getElementById("data0").value = "";document.getElementById("url0").style.display = ""' /> URL</ br></td></form>
|
||||
<td><input id='data0' name='data0' class='wid' type='file'><input id='url0' name='url0' class='wid' type='text' style='display:none'></td>
|
||||
";
|
||||
} else {
|
||||
|
|
|
@ -59,13 +59,13 @@ class Themelet {
|
|||
$tsize = get_thumbnail_size($image->width, $image->height); }
|
||||
|
||||
return "
|
||||
<div class='thumbblock'>
|
||||
<center><div class='thumbblock'>
|
||||
|
||||
<a href='$h_view_link' style='position: relative; display: block; height: {$tsize[1]}px; width: {$tsize[0]}px;'>
|
||||
<img id='thumb_$i_id' title='$h_tip' alt='$h_tip' class='highlighted' style='height: {$tsize[1]}px; width: {$tsize[0]}px;' src='$h_thumb_link'>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div></center>
|
||||
";
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
|||
<table id="header" class="bgtop" width="100%" height="113px">
|
||||
<tr>
|
||||
<td><center>
|
||||
<h1><a href="/">{$page->heading}</a></h1>
|
||||
<h1><a href="$data_href/$main_page">{$site_name}</a></h1>
|
||||
<p>[Navigation links go here]
|
||||
</center></td>
|
||||
$head_block_html
|
||||
|
|
Reference in a new issue