Merge branch 'develop' of https://github.com/shish/shimmie2 into develop

This commit is contained in:
Shish 2015-07-12 22:40:34 +01:00
commit 06d8c7a879
6 changed files with 58 additions and 43 deletions

View File

@ -680,6 +680,7 @@ class Database {
*/ */
public function create_table($name, $data) { public function create_table($name, $data) {
if(is_null($this->engine)) { $this->connect_engine(); } if(is_null($this->engine)) { $this->connect_engine(); }
$data = trim($data, ", \t\n\r\0\x0B"); // mysql doesn't like trailing commas
$this->execute($this->engine->create_table_sql($name, $data)); $this->execute($this->engine->create_table_sql($name, $data));
} }

View File

@ -960,11 +960,6 @@ function transload($url, $mfile) {
fwrite($fp, $data); fwrite($fp, $data);
fclose($fp); fclose($fp);
//
// Scrutinizer-ci complains that $http_response_header does not exist,
// however, $http_response_header is actually a super-global.
// I have filed a bug with PHP-Analyzer here: https://github.com/scrutinizer-ci/php-analyzer/issues/212
//
$headers = http_parse_headers(implode("\n", $http_response_header)); $headers = http_parse_headers(implode("\n", $http_response_header));
return $headers; return $headers;
@ -996,17 +991,29 @@ if (!function_exists('http_parse_headers')) { #http://www.php.net/manual/en/func
} }
} }
function findHeader ($headers, $name){ /**
//HTTP Headers can sometimes be lowercase which will cause issues. * HTTP Headers can sometimes be lowercase which will cause issues.
//In cases like these, we need to make sure to check for them if the camelcase version does not exist. * In cases like these, we need to make sure to check for them if the camelcase version does not exist.
$header = FALSE; *
* @param array $headers
* @param mixed $key
* @return mixed
*/
function findHeader ($headers, $name) {
if (!is_array($headers)) {
return false;
}
$header = false;
if(array_key_exists($name, $headers)){ if(array_key_exists($name, $headers)) {
$header = $headers[$name]; $header = $headers[$name];
}else{ } else {
$headers = array_change_key_case($headers); $headers = array_change_key_case($headers); // convert all to lower case.
if(array_key_exists(strtolower($name), $headers)){ $lc_name = strtolower($name);
$header = $headers[strtolower($name)];
if(array_key_exists($lc_name, $headers)) {
$header = $headers[$lc_name];
} }
} }

View File

@ -1,4 +1,29 @@
$(function() { $(function() {
function zoom(zoom_type) {
var img = $('.shm-main-image');
if(zoom_type == "full") {
img.css('max-width', img.data('width') + 'px');
img.css('max-height', img.data('height') + 'px');
}
if(zoom_type == "width") {
img.css('max-width', '95%');
img.css('max-height', img.data('height') + 'px');
}
if(zoom_type == "height") {
img.css('max-width', img.data('width') + 'px');
img.css('max-height', (window.innerHeight * 0.95) + 'px');
}
if(zoom_type == "both") {
img.css('max-width', '95%');
img.css('max-height', (window.innerHeight * 0.95) + 'px');
}
$(".shm-zoomer").val(zoom_type);
$.cookie("ui-image-zoom", zoom_type, {path: '/', expires: 365});
}
$(".shm-zoomer").change(function(e) { $(".shm-zoomer").change(function(e) {
zoom(this.options[this.selectedIndex].value); zoom(this.options[this.selectedIndex].value);
}); });
@ -14,27 +39,3 @@ $(function() {
zoom($.cookie("ui-image-zoom")); zoom($.cookie("ui-image-zoom"));
} }
}); });
function zoom(zoom_type) {
var img = $('.shm-main-image');
if(zoom_type == "full") {
img.css('max-width', img.data('width') + 'px');
img.css('max-height', img.data('height') + 'px');
}
if(zoom_type == "width") {
img.css('max-width', '95%');
img.css('max-height', img.data('height') + 'px');
}
if(zoom_type == "height") {
img.css('max-width', img.data('width') + 'px');
img.css('max-height', (window.innerHeight * 0.95) + 'px');
}
if(zoom_type == "both") {
img.css('max-width', '95%');
img.css('max-height', (window.innerHeight * 0.95) + 'px');
}
$(".shm-zoomer").val(zoom_type);
$.cookie("ui-image-zoom", zoom_type, {path: '/', expires: 365});
}

View File

@ -49,7 +49,7 @@ class TagEditTheme extends Themelet {
<td> <td>
".($user->can("edit_image_tag") ? " ".($user->can("edit_image_tag") ? "
<span class='view'>$h_tag_links</span> <span class='view'>$h_tag_links</span>
<input class='edit' type='text' name='tag_edit__tags' value='$h_tags' class='autocomplete_tags' id='tag_editor' autocomplete='off'> <input class='edit autocomplete_tags' type='text' name='tag_edit__tags' value='$h_tags' id='tag_editor' autocomplete='off'>
" : " " : "
$h_tag_links $h_tag_links
")." ")."

View File

@ -364,9 +364,10 @@ class Upload extends Extension {
$tmp_filename = tempnam(ini_get('upload_tmp_dir'), "shimmie_transload"); $tmp_filename = tempnam(ini_get('upload_tmp_dir'), "shimmie_transload");
// transload() returns Array or Bool, depending on the transload_engine.
$headers = transload($url, $tmp_filename); $headers = transload($url, $tmp_filename);
$s_filename = findHeader($headers, 'Content-Disposition'); $s_filename = is_array($headers) ? findHeader($headers, 'Content-Disposition') : null;
$h_filename = ($s_filename ? preg_replace('/^.*filename="([^ ]+)"/i', '$1', $s_filename) : null); $h_filename = ($s_filename ? preg_replace('/^.*filename="([^ ]+)"/i', '$1', $s_filename) : null);
$filename = $h_filename ?: basename($url); $filename = $h_filename ?: basename($url);
@ -384,10 +385,15 @@ class Upload extends Extension {
$pathinfo = pathinfo($url); $pathinfo = pathinfo($url);
$metadata = array(); $metadata = array();
$metadata['filename'] = $filename; $metadata['filename'] = $filename;
$metadata['extension'] = getExtension(findHeader($headers, 'Content-Type')) ?: $pathinfo['extension'];
$metadata['tags'] = $tags; $metadata['tags'] = $tags;
$metadata['source'] = (($url == $source) && !$config->get_bool('upload_tlsource') ? "" : $source); $metadata['source'] = (($url == $source) && !$config->get_bool('upload_tlsource') ? "" : $source);
if (is_array($headers)) {
$metadata['extension'] = getExtension(findHeader($headers, 'Content-Type'));
} else {
$metadata['extension'] = $pathinfo['extension'];
}
/* check for locked > adds to metadata if it has */ /* check for locked > adds to metadata if it has */
if(!empty($locked)){ if(!empty($locked)){
$metadata['locked'] = $locked ? "on" : ""; $metadata['locked'] = $locked ? "on" : "";

View File

@ -14,4 +14,4 @@
* Copyright (c) 2008-2013, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org) * Copyright (c) 2008-2013, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
*/ */
(function(e){if(typeof define==="function"&&define.amd){define(["jquery"],e)}else{e(jQuery)}})(function(e){function r(){var n=i(this);var r=t.settings;if(!isNaN(n.datetime)){if(r.cutoff==0||o(n.datetime)<r.cutoff){e(this).text(s(n.datetime))}}return this}function i(n){n=e(n);if(!n.data("timeago")){n.data("timeago",{datetime:t.datetime(n)});var r=e.trim(n.text());if(t.settings.localeTitle){n.attr("title",n.data("timeago").datetime.toLocaleString())}else if(r.length>0&&!(t.isTime(n)&&n.attr("title"))){n.attr("title",r)}}return n.data("timeago")}function s(e){return t.inWords(o(e))}function o(e){return(new Date).getTime()-e.getTime()}e.timeago=function(t){if(t instanceof Date){return s(t)}else if(typeof t==="string"){return s(e.timeago.parse(t))}else if(typeof t==="number"){return s(new Date(t))}else{return s(e.timeago.datetime(t))}};var t=e.timeago;e.extend(e.timeago,{settings:{refreshMillis:6e4,allowFuture:false,localeTitle:false,cutoff:0,strings:{prefixAgo:null,prefixFromNow:null,suffixAgo:"ago",suffixFromNow:"from now",seconds:"less than a minute",minute:"about a minute",minutes:"%d minutes",hour:"about an hour",hours:"about %d hours",day:"a day",days:"%d days",month:"about a month",months:"%d months",year:"about a year",years:"%d years",wordSeparator:" ",numbers:[]}},inWords:function(t){function l(r,i){var s=e.isFunction(r)?r(i,t):r;var o=n.numbers&&n.numbers[i]||i;return s.replace(/%d/i,o)}var n=this.settings.strings;var r=n.prefixAgo;var i=n.suffixAgo;if(this.settings.allowFuture){if(t<0){r=n.prefixFromNow;i=n.suffixFromNow}}var s=Math.abs(t)/1e3;var o=s/60;var u=o/60;var a=u/24;var f=a/365;var c=s<45&&l(n.seconds,Math.round(s))||s<90&&l(n.minute,1)||o<45&&l(n.minutes,Math.round(o))||o<90&&l(n.hour,1)||u<24&&l(n.hours,Math.round(u))||u<42&&l(n.day,1)||a<30&&l(n.days,Math.round(a))||a<45&&l(n.month,1)||a<365&&l(n.months,Math.round(a/30))||f<1.5&&l(n.year,1)||l(n.years,Math.round(f));var h=n.wordSeparator||"";if(n.wordSeparator===undefined){h=" "}return e.trim([r,c,i].join(h))},parse:function(t){var n=e.trim(t);n=n.replace(/\.\d+/,"");n=n.replace(/-/,"/").replace(/-/,"/");n=n.replace(/T/," ").replace(/Z/," UTC");n=n.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2");return new Date(n)},datetime:function(n){var r=t.isTime(n)?e(n).attr("datetime"):e(n).attr("title");return t.parse(r)},isTime:function(t){return e(t).get(0).tagName.toLowerCase()==="time"}});var n={init:function(){var n=e.proxy(r,this);n();var i=t.settings;if(i.refreshMillis>0){setInterval(n,i.refreshMillis)}},update:function(n){e(this).data("timeago",{datetime:t.parse(n)});r.apply(this)}};e.fn.timeago=function(e,t){var r=e?n[e]:n.init;if(!r){throw new Error("Unknown function name '"+e+"' for timeago")}this.each(function(){r.call(this,t)});return this};document.createElement("abbr");document.createElement("time")}) (function(e){if(typeof define==="function"&&define.amd){define(["jquery"],e)}else{e(jQuery)}})(function(e){function r(){var n=i(this);var r=t.settings;if(!isNaN(n.datetime)){if(r.cutoff==0||o(n.datetime)<r.cutoff){e(this).text(s(n.datetime))}}return this}function i(n){n=e(n);if(!n.data("timeago")){n.data("timeago",{datetime:t.datetime(n)});var r=e.trim(n.text());if(t.settings.localeTitle){n.attr("title",n.data("timeago").datetime.toLocaleString())}else if(r.length>0&&!(t.isTime(n)&&n.attr("title"))){n.attr("title",r)}}return n.data("timeago")}function s(e){return t.inWords(o(e))}function o(e){return(new Date).getTime()-e.getTime()}e.timeago=function(t){if(t instanceof Date){return s(t)}else if(typeof t==="string"){return s(e.timeago.parse(t))}else if(typeof t==="number"){return s(new Date(t))}else{return s(e.timeago.datetime(t))}};var t=e.timeago;e.extend(e.timeago,{settings:{refreshMillis:6e4,allowFuture:false,localeTitle:false,cutoff:0,strings:{prefixAgo:null,prefixFromNow:null,suffixAgo:"ago",suffixFromNow:"from now",seconds:"less than a minute",minute:"about a minute",minutes:"%d minutes",hour:"about an hour",hours:"about %d hours",day:"a day",days:"%d days",month:"about a month",months:"%d months",year:"about a year",years:"%d years",wordSeparator:" ",numbers:[]}},inWords:function(t){function l(r,i){var s=e.isFunction(r)?r(i,t):r;var o=n.numbers&&n.numbers[i]||i;return s.replace(/%d/i,o)}var n=this.settings.strings;var r=n.prefixAgo;var i=n.suffixAgo;if(this.settings.allowFuture){if(t<0){r=n.prefixFromNow;i=n.suffixFromNow}}var s=Math.abs(t)/1e3;var o=s/60;var u=o/60;var a=u/24;var f=a/365;var c=s<45&&l(n.seconds,Math.round(s))||s<90&&l(n.minute,1)||o<45&&l(n.minutes,Math.round(o))||o<90&&l(n.hour,1)||u<24&&l(n.hours,Math.round(u))||u<42&&l(n.day,1)||a<30&&l(n.days,Math.round(a))||a<45&&l(n.month,1)||a<365&&l(n.months,Math.round(a/30))||f<1.5&&l(n.year,1)||l(n.years,Math.round(f));var h=n.wordSeparator||"";if(n.wordSeparator===undefined){h=" "}return e.trim([r,c,i].join(h))},parse:function(t){var n=e.trim(t);n=n.replace(/\.\d+/,"");n=n.replace(/-/,"/").replace(/-/,"/");n=n.replace(/T/," ").replace(/Z/," UTC");n=n.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2");return new Date(n)},datetime:function(n){var r=t.isTime(n)?e(n).attr("datetime"):e(n).attr("title");return t.parse(r)},isTime:function(t){return e(t).get(0).tagName.toLowerCase()==="time"}});var n={init:function(){var n=e.proxy(r,this);n();var i=t.settings;if(i.refreshMillis>0){setInterval(n,i.refreshMillis)}},update:function(n){e(this).data("timeago",{datetime:t.parse(n)});r.apply(this)}};e.fn.timeago=function(e,t){var r=e?n[e]:n.init;if(!r){throw new Error("Unknown function name '"+e+"' for timeago")}this.each(function(){r.call(this,t)});return this};document.createElement("abbr");document.createElement("time")});