Merge pull request #63 from DakuTree/master

Few new features + More fixes
This commit is contained in:
Shish Moom 2011-12-25 06:31:36 -08:00
commit d25ef4e6f6
8 changed files with 126 additions and 19 deletions

View file

@ -177,6 +177,19 @@ abstract class DataHandlerExtension implements Extension {
$iae = new ImageAdditionEvent($event->user, $image); $iae = new ImageAdditionEvent($event->user, $image);
send_event($iae); send_event($iae);
$event->image_id = $iae->image->id; $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)));
}
} }
} }

View file

@ -173,6 +173,7 @@ class Upload implements Extension {
if(!empty($_GET['tags']) && $_GET['tags'] != "null") { if(!empty($_GET['tags']) && $_GET['tags'] != "null") {
$tags = Tag::explode($_GET['tags']); $tags = Tag::explode($_GET['tags']);
} }
$ok = $this->try_transload($url, $tags, $url); $ok = $this->try_transload($url, $tags, $url);
$this->theme->display_upload_status($page, $ok); $this->theme->display_upload_status($page, $ok);
} }
@ -299,10 +300,51 @@ class Upload implements Extension {
private function try_transload($url, $tags, $source, $replace='') { private function try_transload($url, $tags, $source, $replace='') {
global $page; global $page;
global $config; global $config;
global $user;
$ok = true; $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 // PHP falls back to system default if /tmp fails, can't we just
// use the system default to start with? :-/ // use the system default to start with? :-/
@ -363,6 +405,16 @@ class Upload implements Extension {
$metadata['tags'] = $tags; $metadata['tags'] = $tags;
$metadata['source'] = $source; $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 */ /* check if we have been given an image ID to replace */
if (!empty($replace)) { if (!empty($replace)) {
$metadata['replace'] = $replace; $metadata['replace'] = $replace;

BIN
ext/upload/minus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

BIN
ext/upload/plus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

View file

@ -5,5 +5,10 @@
#radio_button { #radio_button {
width: auto; 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". */ /* This is needed since the theme style.css forcibly sets vertical align to "top". */
TABLE.vert TD, TABLE.vert TH {vertical-align: middle;} TABLE.vert TD, TABLE.vert TH {vertical-align: middle;}

View file

@ -16,13 +16,44 @@ class UploadTheme extends Themelet {
// Uploader 2.0! // Uploader 2.0!
$upload_list = ""; $upload_list = "";
for($i=0; $i<$config->get_int('upload_count'); $i++) { for($i=0; $i<$config->get_int('upload_count'); $i++) {
$n = $i + 1; $a=$i+1;
$upload_list .= " $s=$i-1;
<tr> if(!$i==0){
<td width='60'><form><input id='radio_buttona' type='radio' name='method' value='file' checked='checked' onclick='javascript:document.getElementById(&quot;url$i&quot;).style.display = &quot;none&quot;;document.getElementById(&quot;url$i&quot;).value = &quot;&quot;;document.getElementById(&quot;data$i&quot;).style.display = &quot;inline&quot;' /> File<br>"; $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(&quot;row$a&quot;).style.display = &quot;&quot;;javascript:document.getElementById(&quot;hide$i&quot;).style.display = &quot;none&quot;;javascript:document.getElementById(&quot;hide$a&quot;).style.display = &quot;&quot;;'>".
"<img src='ext/upload/plus.png'></a></div></td>";
}else{
$upload_list .="<div id='hide$i'>
<a href='javascript:document.getElementById(&quot;row$i&quot;).style.display = &quot;none&quot;;".
"document.getElementById(&quot;hide$i&quot;).style.display = &quot;none&quot;;".
"document.getElementById(&quot;hide$s&quot;).style.display = &quot;&quot;;".
"document.getElementById(&quot;data$i&quot;).value = &quot;&quot;;".
"document.getElementById(&quot;url$i&quot;).value = &quot;&quot;;'>".
"<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(&quot;row$a&quot;).style.display = &quot;&quot;;".
"document.getElementById(&quot;hide$i&quot;).style.display = &quot;none&quot;;".
"document.getElementById(&quot;hide$a&quot;).style.display = &quot;&quot;;'>".
"<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(&quot;url$i&quot;).style.display = &quot;none&quot;;document.getElementById(&quot;url$i&quot;).value = &quot;&quot;;document.getElementById(&quot;data$i&quot;).style.display = &quot;&quot;' /> File<br>";
if($tl_enabled) { if($tl_enabled) {
$upload_list .=" $upload_list .=
<input id='radio_buttonb' type='radio' name='method' value='url' onclick='javascript:document.getElementById(&quot;data$i&quot;).style.display = &quot;none&quot;;document.getElementById(&quot;data$i&quot;).value = &quot;&quot;;document.getElementById(&quot;url$i&quot;).style.display = &quot;inline&quot;' /> URL</ br></td></form> "<input id='radio_buttonb' type='radio' name='method' value='url' onclick='javascript:document.getElementById(&quot;data$i&quot;).style.display = &quot;none&quot;;document.getElementById(&quot;data$i&quot;).value = &quot;&quot;;document.getElementById(&quot;url$i&quot;).style.display = &quot;&quot;' /> 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> <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)." ".make_form(make_link("upload"), "POST", $multipart=True)."
<table id='large_upload_form' class='vert'> <table id='large_upload_form' class='vert'>
$upload_list $upload_list
<tr><td>Tags</td><td colspan='3'><input id='tag_box' name='tags' type='text'></td></tr> <tr><td></td><td>Tags<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>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> <tr><td colspan='4'><input id='uploadbutton' type='submit' value='Post'></td></tr>
</table> </table>
</form> </form>
@ -80,13 +111,17 @@ class UploadTheme extends Themelet {
$title . '</a> (Drag & drop onto your bookmarks toolbar, then click when looking at an image)'; $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'); $title = "Danbooru to " . $config->get_string('title');
$html .= '<p><a href="javascript:var img=document.getElementById(&quot;highres&quot;).href;var ste=&quot;' . $html .= '<p><a href="javascript:var img=document.getElementById(&quot;highres&quot;).href;var ste=&quot;' .
$link . $delimiter . 'url=&quot;;var tag=document.getElementById(&quot;post_old_tags&quot;).value;if (confirm(&quot;OK = Use Current tags.\nCancel = Use new tags.&quot;)==true)' . $link . $delimiter . 'url=&quot;;var tag=document.getElementById(&quot;post_old_tags&quot;).value;var doc=document.documentElement.innerHTML;var rtg=doc.match(&quot;<li>Rating: (.*)<\/li>&quot;);var srx=&quot;http://&quot; + document.location.hostname + document.location.href.match(&quot;\/post\/show\/.*\/&quot;);' .
'{if(tag.search(/\bflash\b/)==-1){location.href=ste+img+&quot;&amp;tags=&quot;+tag;}else{location.href=ste+document.getElementsByName(&quot;movie&quot;)[0].value' . 'if (confirm(&quot;OK = Use Current tags.\nCancel = Use new tags.&quot;)==true)' .
'+&quot;&amp;tags=&quot;+tag;}}else{var p=prompt(&quot;Enter Tags&quot;,&quot;&quot;);if(tag.search(/\bflash\b/)==-1){location.href=ste+img+&quot;&amp;tags=&quot;+p;}' . '{if(tag.search(/\bflash\b/)==-1){location.href=ste+img+&quot;&amp;tags=&quot;+tag+&quot;&rating=&quot;+rtg[1]+&quot;&amp;source=&quot;+srx;}else{location.href=ste+document.getElementsByName(&quot;movie&quot;)[0].value' .
'else{location.href=ste+document.getElementsByName(&quot;movie&quot;)[0].value+&quot;&amp;tags=&quot;+p;}}">' . '+&quot;&amp;tags=&quot;+tag+&quot;&amp;rating=&quot;+rtg[1]+&quot;&amp;source=&quot;+srx;}}else{var p=prompt(&quot;Enter Tags&quot;,&quot;&quot;);if(tag.search(/\bflash\b/)==-1){location.href=ste+img+&quot;&amp;tags=&quot;+p+&quot;&amp;rating=&quot;+rtg[1]+&quot;&amp;source=&quot;+srx;}' .
$title . '</a> (As above, Click on a Danbooru-run image page. (This also grabs the tags!))'; 'else{location.href=ste+document.getElementsByName(&quot;movie&quot;)[0].value+&quot;&amp;tags=&quot;+p+&quot;&amp;rating=&quot;+rtg[1]+&quot;&amp;source=&quot;+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 = '';
$upload_list .= " $upload_list .= "
<tr> <tr>
<td width='60'><form><input id='radio_buttona' type='radio' name='method' value='file' checked='checked' onclick='javascript:document.getElementById(&quot;url0&quot;).style.display = &quot;none&quot;;document.getElementById(&quot;url0&quot;).value = &quot;&quot;;document.getElementById(&quot;data0&quot;).style.display = &quot;inline&quot;' /> File<br>"; <td width='60'><form><input id='radio_buttona' type='radio' name='method' value='file' checked='checked' onclick='javascript:document.getElementById(&quot;url0&quot;).style.display = &quot;none&quot;;document.getElementById(&quot;url0&quot;).value = &quot;&quot;;document.getElementById(&quot;data0&quot;).style.display = &quot;&quot;' /> File<br>";
if($tl_enabled) { if($tl_enabled) {
$upload_list .=" $upload_list .="
<input id='radio_buttonb' type='radio' name='method' value='url' onclick='javascript:document.getElementById(&quot;data0&quot;).style.display = &quot;none&quot;;document.getElementById(&quot;data0&quot;).value = &quot;&quot;;document.getElementById(&quot;url0&quot;).style.display = &quot;inline&quot;' /> URL</ br></td></form> <input id='radio_buttonb' type='radio' name='method' value='url' onclick='javascript:document.getElementById(&quot;data0&quot;).style.display = &quot;none&quot;;document.getElementById(&quot;data0&quot;).value = &quot;&quot;;document.getElementById(&quot;url0&quot;).style.display = &quot;&quot;' /> 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> <td><input id='data0' name='data0' class='wid' type='file'><input id='url0' name='url0' class='wid' type='text' style='display:none'></td>
"; ";
} else { } else {

View file

@ -59,13 +59,13 @@ class Themelet {
$tsize = get_thumbnail_size($image->width, $image->height); } $tsize = get_thumbnail_size($image->width, $image->height); }
return " 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;'> <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'> <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> </a>
</div> </div></center>
"; ";
} }

View file

@ -10,7 +10,9 @@ class Layout {
global $config; global $config;
$theme_name = $config->get_string('theme', 'default'); $theme_name = $config->get_string('theme', 'default');
$site_name = $config->get_string('title');
$data_href = get_base_href(); $data_href = get_base_href();
$main_page = $config->get_string('main_page');
$contact_link = $config->get_string('contact_link'); $contact_link = $config->get_string('contact_link');
$header_html = ""; $header_html = "";
@ -67,7 +69,7 @@ $header_html
<table id="header" class="bgtop" width="100%" height="113px"> <table id="header" class="bgtop" width="100%" height="113px">
<tr> <tr>
<td><center> <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] <p>[Navigation links go here]
</center></td> </center></td>
$head_block_html $head_block_html