2009-02-14 23:03:09 +00:00
<? php defined ( "SYSPATH" ) or die ( "No direct script access." ) ?>
2009-11-09 13:54:55 -08:00
<script type="text/javascript" src="<?= url::file("lib/swfobject.js") ?>"></script>
<script type="text/javascript" src="<?= url::file("lib/uploadify/jquery.uploadify.min.js") ?>"></script>
<script type="text/javascript">
$("#g-add-photos-canvas").ready(function () {
$("#g-uploadify").uploadify({
2010-01-23 09:23:08 -08:00
width: 150,
height: 33,
2009-11-09 13:54:55 -08:00
uploader: "<?= url::file("lib/uploadify/uploadify.swf") ?>",
2010-07-15 12:37:44 -07:00
script: "<?= url::site("uploader/add_photo/{$album->id}") ?>",
2009-11-20 19:41:45 -08:00
scriptData: <?= json_encode($script_data) ?>,
2010-07-04 21:53:57 +02:00
fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.m4v;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4;*.M4V",
2009-11-09 13:54:55 -08:00
fileDesc: <?= t("Photos and movies")->for_js() ?>,
cancelImg: "<?= url::file("lib/uploadify/cancel.png") ?>",
2009-12-02 19:08:13 -08:00
simUploadLimit: <?= $simultaneous_upload_limit ?>,
2009-11-16 07:49:17 -08:00
wmode: "transparent",
hideButton: true, /* should be true */
2009-11-09 13:54:55 -08:00
auto: true,
multi: true,
onAllComplete: function(filesUploaded, errors, allbytesLoaded, speed) {
$("#g-upload-cancel-all")
.addClass("ui-state-disabled")
.attr("disabled", "disabled");
return true;
},
onClearQueue: function(event) {
$("#g-upload-cancel-all")
.addClass("ui-state-disabled")
.attr("disabled", "disabled");
return true;
},
2009-11-10 12:49:13 -08:00
onComplete: function(event, queueID, fileObj, response, data) {
2009-11-11 18:47:10 -08:00
var re = /^error: (.*)$/i;
var msg = re.exec(response);
if (msg) {
$("#g-add-photos-status ul").append(
"<li class=\"g-error\">" + fileObj.name + " - " + msg[1] + "</li>");
} else {
$("#g-add-photos-status ul").append(
2010-01-28 09:37:33 -08:00
"<li class=\"g-success\">" + fileObj.name + " - " + <?= t("Completed")->for_js() ?> + "</li>");
2009-11-11 18:47:10 -08:00
}
2009-11-10 12:49:13 -08:00
return true;
},
2009-11-11 18:47:10 -08:00
onError: function(event, queueID, fileObj, errorObj) {
var msg = " - ";
if (errorObj.type == "HTTP") {
if (errorObj.info == "500") {
2009-11-20 12:42:40 -08:00
msg += <?= t("Unable to process this file")->for_js() ?>;
2009-11-11 18:47:10 -08:00
// Server error - check server logs
} else if (errorObj.info == "404") {
2009-11-20 12:42:40 -08:00
msg += <?= t("The upload script was not found.")->for_js() ?>;
2009-11-11 18:47:10 -08:00
// Server script not found
} else {
// Server Error: status: errorObj.info
2009-11-20 12:42:40 -08:00
msg += (<?= t("Server error: __INFO__")->for_js() ?>.replace("__INFO__", errorObj.info));
2009-11-11 18:47:10 -08:00
}
} else if (errorObj.type == "File Size") {
var sizelimit = $("#g-uploadify").uploadifySettings(sizeLimit);
msg += fileObj.name+' '+errorObj.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB';
} else {
2009-11-20 12:42:40 -08:00
msg += (<?= t("Server error: __INFO__ (__TYPE__)")->for_js() ?>
.replace("__INFO__", errorObj.info)
.replace("__TYPE__", errorObj.type));
2009-11-11 18:47:10 -08:00
}
$("#g-add-photos-status ul").append(
"<li class=\"g-error\">" + fileObj.name + msg + "</li>");
$("#g-uploadify" + queueID).remove();
},
2009-11-09 13:54:55 -08:00
onSelect: function(event) {
if ($("#g-upload-cancel-all").hasClass("ui-state-disabled")) {
$("#g-upload-cancel-all")
.removeClass("ui-state-disabled")
.attr("disabled", null);
}
return true;
}
});
});
</script>
2009-03-17 05:20:37 +00:00
2009-11-20 19:41:45 -08:00
<? if (ini_get("suhosin.session.encrypt")): ?>
<ul id="g-action-status" class="g-message-block">
<li class="g-error">
<?= t("Error: your server is configured to use the <a href=\"%encrypt_url\"><code>suhosin.session.encrypt</code></a> setting from <a href=\"%suhosin_url\">Suhosin</a>. You must disable this setting to upload photos.",
array("encrypt_url" => "http://www.hardened-php.net/suhosin/configuration.html#suhosin.session.encrypt",
"suhosin_url" => "http://www.hardened-php.net/suhosin/")) ?>
</li>
</ul>
<? endif ?>
2009-03-17 05:20:37 +00:00
2009-11-20 19:41:45 -08:00
<div>
<p>
<?= t("Photos will be uploaded to album: ") ?>
</p>
2010-02-28 22:09:40 -07:00
<ul class="g-breadcrumbs ui-helper-clearfix">
2009-11-20 19:41:45 -08:00
<? foreach ($album->parents() as $i => $parent): ?>
<li<? if ($i == 0) print " class=\"g-first\"" ?>> <?= html::clean($parent->title) ?> </li>
<? endforeach ?>
<li class="g-active"> <?= html::purify($album->title) ?> </li>
</ul>
</div>
2009-11-20 12:42:40 -08:00
2010-02-28 18:46:43 -07:00
<div id="g-add-photos-canvas">
<button id="g-add-photos-button" class="g-button ui-state-default ui-corner-all" href="#"><?= t("Select photos...") ?></button>
2009-11-20 19:41:45 -08:00
<span id="g-uploadify"></span>
</div>
2010-02-28 18:46:43 -07:00
<div id="g-add-photos-status">
<ul id="g-action-status" class="g-message-block">
2009-11-20 19:41:45 -08:00
</ul>
</div>