2009-02-14 23:03:09 +00:00
< ? php defined ( " SYSPATH " ) or die ( " No direct script access. " ) ?>
2009-11-16 07:49:17 -08:00
< style >
#g-uploadifyUploader {
left : - 50 px ;
position : relative ;
z - index : 100 ;
}
#g-add-photos-button {
left : 55 px ;
position : relative ;
top : - 15 px ;
z - index : - 1 ;
}
</ style >
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 ({
uploader : " <?= url::file( " lib / uploadify / uploadify . swf " ) ?> " ,
script : " <?= url::site( " simple_uploader / add_photo / { $item -> id } " ) ?> " ,
scriptData : < ? = json_encode ( array (
" g3sid " => Session :: instance () -> id (),
" user_agent " => Input :: instance () -> server ( " HTTP_USER_AGENT " ),
" csrf " => $csrf )) ?> ,
fileExt : " *.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4 " ,
fileDesc : < ? = t ( " Photos and movies " ) -> for_js () ?> ,
cancelImg : " <?= url::file( " lib / uploadify / cancel . png " ) ?> " ,
2009-11-11 20:21:40 -08:00
buttonText : < ? = t ( " Select Photos ... " ) -> for_js () ?> ,
2009-11-09 13:54:55 -08:00
simUploadLimit : 10 ,
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
// @todo handle a response of "Error: xxxx" as an error
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 (
2009-11-11 20:21:40 -08:00
" <li class= \" g-success \" > " + fileObj . name + " - <?= t( " Completed " ) ?></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 " ) {
msg += " Error occurred processing the file " ;
// Server error - check server logs
} else if ( errorObj . info == " 404 " ) {
msg += " The upload script was not found. " ;
// Server script not found
} else {
// Server Error: status: errorObj.info
msg += " Error occurred communication with the server, status: " + errorObj . info ;
}
} 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 {
msg += " Error occurred communication with the server, error " + errorObj . type + " : " + errorObj . info ;
}
$ ( " #g-add-photos-status ul " ) . append (
" <li class= \" g-error \" > " + fileObj . name + msg + " </li> " );
$ ( " #g-uploadify " + queueID ) . remove ();
//return false;
},
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-10-04 00:27:22 -06:00
< form id = " g-add-photos-form " action = " <?= url::site( " simple_uploader / finish ? csrf = $csrf " ) ?> " >
2009-02-18 07:33:38 +00:00
< fieldset >
2009-08-29 22:54:20 -07:00
< legend > < ? = t ( " Add photos to %album_title " , array ( " album_title " => html :: purify ( $item -> title ))) ?> </legend>
2009-03-17 05:20:37 +00:00
2009-11-09 13:54:55 -08:00
</ fieldset >
2009-11-10 12:49:13 -08:00
< div id = " g-add-photos " >
< ? 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. " ,
2009-05-10 21:32:27 +00:00
array ( " encrypt_url " => " http://www.hardened-php.net/suhosin/configuration.html#suhosin.session.encrypt " ,
2009-11-10 12:49:13 -08:00
" suhosin_url " => " http://www.hardened-php.net/suhosin/ " )) ?>
</ li >
</ ul >
< ? endif ?>
2009-05-10 20:54:15 +00:00
2009-11-10 12:49:13 -08:00
< div >
< p >
< ? = t ( " Photos will be uploaded to album: " ) ?>
</ p >
< ul class = " g-breadcrumbs " >
< ? foreach ( $item -> parents () as $i => $parent ) : ?>
< li < ? if ( $i == 0 ) print " class= \" g-first \" " ?> > <?= html::clean($parent->title) ?> </li>
< ? endforeach ?>
< li class = " g-active " > < ? = html :: purify ( $item -> title ) ?> </li>
</ ul >
</ div >
2009-11-09 13:54:55 -08:00
< div id = " g-add-photos-canvas " style = " text-align: center; " >
2009-11-16 07:49:17 -08:00
< a id = " g-add-photos-button " class = " ui-corner-all " style = " padding-bottom: 1em; " href = " # " >< ? = t ( " Select Photos... " ) ?> </a>
2009-11-13 14:30:38 -08:00
< span id = " g-uploadify " ></ span >
2009-11-10 12:49:13 -08:00
</ div >
< div id = " g-add-photos-status " style = " text-align: center; " >
2009-11-11 18:47:10 -08:00
< ul >
</ ul >
2009-11-10 12:49:13 -08:00
</ div >
2009-03-17 05:20:37 +00:00
2009-11-10 12:49:13 -08:00
<!-- Proxy the done request back to our form , since its been ajaxified -->
< button id = " g-upload-done " class = " ui-state-default ui-corner-all " onclick = " $ ('#g-add-photos-form').submit();return false; " >
< ? = t ( " Done " ) ?>
</ button >
< button id = " g-upload-cancel-all " class = " ui-state-default ui-corner-all ui-state-disabled " onclick = " $ ('#g-uploadify').uploadifyClearQueue();return false; " disabled = " disabled " >
< ? = t ( " Cancel All " ) ?>
</ button >
</ div >
2009-11-09 13:54:55 -08:00
</ form >