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 " >
2010-08-30 22:19:57 -07:00
< ? $flash_minimum_version = " 9.0.24 " ?>
2010-08-31 00:03:46 -07:00
var success_count = 0 ;
var error_count = 0 ;
var updating = 0 ;
2009-11-09 13:54:55 -08:00
$ ( " #g-add-photos-canvas " ) . ready ( function () {
2010-08-31 00:03:46 -07:00
var update_status = function () {
if ( updating ) {
// poor man's mutex
setTimeout ( function () { update_status (); }, 500 );
}
updating = 1 ;
$ . get ( " <?= url::site( " uploader / status / _S / _E " ) ?> "
. replace ( " _S " , success_count ) . replace ( " _E " , error_count ),
function ( data ) {
$ ( " #g-add-photos-status-message " ) . html ( data );
updating = 0 ;
});
};
2010-08-30 22:19:57 -07:00
if ( swfobject . hasFlashPlayerVersion ( " <?= $flash_minimum_version ?> " )) {
$ ( " #g-uploadify " ) . uploadify ({
2012-10-08 16:41:02 -04:00
width : 298 ,
height : 32 ,
2010-08-30 22:19:57 -07:00
uploader : " <?= url::file( " lib / uploadify / uploadify . swf " ) ?> " ,
script : " <?= url::site( " uploader / add_photo / { $album -> id } " ) ?> " ,
scriptData : < ? = json_encode ( $script_data ) ?> ,
2011-04-28 19:41:44 -06:00
fileExt : " <?= implode( " ; " , $extensions ) ?> " ,
2010-08-30 22:19:57 -07:00
fileDesc : < ? = t ( " Photos and movies " ) -> for_js () ?> ,
cancelImg : " <?= url::file( " lib / uploadify / cancel . png " ) ?> " ,
simUploadLimit : < ? = $simultaneous_upload_limit ?> ,
2011-04-23 10:07:32 -07:00
sizeLimit : < ? = $size_limit_bytes ?> ,
2010-08-30 22:19:57 -07:00
wmode : " transparent " ,
hideButton : true , /* should be true */
auto : true ,
multi : true ,
onAllComplete : function ( filesUploaded , errors , allbytesLoaded , speed ) {
2009-11-09 13:54:55 -08:00
$ ( " #g-upload-cancel-all " )
2010-08-30 22:19:57 -07:00
. addClass ( " ui-state-disabled " )
. attr ( " disabled " , " disabled " );
$ ( " #g-upload-done " )
2009-11-09 13:54:55 -08:00
. removeClass ( " ui-state-disabled " )
. attr ( " disabled " , null );
2010-08-30 22:19:57 -07:00
return true ;
},
onClearQueue : function ( event ) {
$ ( " #g-upload-cancel-all " )
2010-08-29 16:39:01 -07:00
. addClass ( " ui-state-disabled " )
. attr ( " disabled " , " disabled " );
2010-08-30 22:19:57 -07:00
$ ( " #g-upload-done " )
. removeClass ( " ui-state-disabled " )
. attr ( " disabled " , null );
return true ;
},
onComplete : function ( event , queueID , fileObj , response , data ) {
var re = /^ error : ( .* ) $ / i ;
var msg = re . exec ( response );
2010-08-31 00:03:46 -07:00
$ ( " #g-add-photos-status ul " ) . append (
2012-06-05 20:20:21 -07:00
" <li id= \" q " + queueID + " \" class= \" g-success \" ><span></span> - " +
2010-08-31 00:03:46 -07:00
< ? = t ( " Completed " ) -> for_js () ?> + "</li>");
2012-06-05 20:20:21 -07:00
$ ( " #g-add-photos-status li#q " + queueID + " span " ) . text ( fileObj . name );
2010-09-01 22:00:26 -07:00
setTimeout ( function () { $ ( " #q " + queueID ) . slideUp ( " slow " ) . remove () }, 5000 );
2010-08-31 00:03:46 -07:00
success_count ++ ;
update_status ();
2010-08-30 22:19:57 -07:00
return true ;
},
onError : function ( event , queueID , fileObj , errorObj ) {
if ( errorObj . type == " HTTP " ) {
if ( errorObj . info == " 500 " ) {
2011-04-23 10:07:32 -07:00
error_msg = < ? = t ( " Unable to process this photo " ) -> for_js () ?> ;
2010-08-30 22:19:57 -07:00
} else if ( errorObj . info == " 404 " ) {
2011-04-23 10:07:32 -07:00
error_msg = < ? = t ( " The upload script was not found " ) -> for_js () ?> ;
} else if ( errorObj . info == " 400 " ) {
error_msg = < ? = t ( " This photo is too large (max is %size bytes) " ,
array ( " size " => $size_limit )) -> for_js () ?> ;
2010-08-30 22:19:57 -07:00
} else {
2011-04-23 10:07:32 -07:00
msg += ( < ? = t ( " Server error: __INFO__ (__TYPE__) " ) -> for_js () ?>
. replace ( " __INFO__ " , errorObj . info )
. replace ( " __TYPE__ " , errorObj . type ));
2010-08-30 22:19:57 -07:00
}
} else if ( errorObj . type == " File Size " ) {
2011-04-23 10:07:32 -07:00
error_msg = < ? = t ( " This photo is too large (max is %size bytes) " ,
array ( " size " => $size_limit )) -> for_js () ?> ;
2010-08-30 22:19:57 -07:00
} else {
2011-04-23 10:07:32 -07:00
error_msg = < ? = t ( " Server error: __INFO__ (__TYPE__) " ) -> for_js () ?>
. replace ( " __INFO__ " , errorObj . info )
. replace ( " __TYPE__ " , errorObj . type );
2010-08-30 22:19:57 -07:00
}
2013-01-22 18:39:24 -05:00
msg = " - <a target= \" _blank \" href= \" http://codex.galleryproject.org/Gallery3:Troubleshooting:Uploading \" > " +
2011-04-23 10:07:32 -07:00
error_msg + " </a> " ;
2010-08-30 22:19:57 -07:00
$ ( " #g-add-photos-status ul " ) . append (
2012-06-05 20:20:21 -07:00
" <li id= \" q " + queueID + " \" class= \" g-error \" ><span></span> " + msg + " </li> " );
$ ( " #g-add-photos-status li#q " + queueID + " span " ) . text ( fileObj . name );
2010-09-01 22:00:26 -07:00
$ ( " #g-uploadify " ) . uploadifyCancel ( queueID );
2010-08-31 00:03:46 -07:00
error_count ++ ;
update_status ();
2010-08-30 22:19:57 -07:00
},
onSelect : function ( event ) {
if ( $ ( " #g-upload-cancel-all " ) . hasClass ( " ui-state-disabled " )) {
$ ( " #g-upload-cancel-all " )
. removeClass ( " ui-state-disabled " )
. attr ( " disabled " , null );
$ ( " #g-upload-done " )
. addClass ( " ui-state-disabled " )
. attr ( " disabled " , " disabled " );
}
return true ;
2009-11-09 13:54:55 -08:00
}
2010-08-30 22:19:57 -07:00
});
} else {
$ ( " .requires-flash " ) . hide ();
$ ( " .no-flash " ) . show ();
}
2009-11-09 13:54:55 -08:00
});
</ script >
2009-03-17 05:20:37 +00:00
2010-08-30 22:19:57 -07:00
< div class = " requires-flash " >
2010-12-15 15:15:48 -08:00
< ? if ( $suhosin_session_encrypt || ( identity :: active_user () -> admin && ! $movies_allowed )) : ?>
2010-08-30 22:19:57 -07:00
< div class = " g-message-block g-info " >
< ? if ( $suhosin_session_encrypt ) : ?>
< p 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/ " )) ?>
</ p >
< ? endif ?>
2010-08-21 15:11:06 -07:00
2010-12-15 15:15:48 -08:00
< ? if ( identity :: active_user () -> admin && ! $movies_allowed ) : ?>
2010-08-30 22:19:57 -07:00
< p class = " g-warning " >
2013-01-22 18:39:24 -05:00
< ? = t ( " Can't find <i>ffmpeg</i> on your system. Movie uploading disabled. <a href= \" %help_url \" >Help!</a> " , array ( " help_url " => " http://codex.galleryproject.org/Gallery3:FAQ#Why_does_it_say_I.27m_missing_ffmpeg.3F " )) ?>
2010-08-30 22:19:57 -07:00
</ p >
< ? endif ?>
</ div >
2010-08-21 15:11:06 -07:00
< ? endif ?>
2010-08-30 22:19:57 -07:00
< div >
2011-04-23 10:07:32 -07:00
< ul class = " g-breadcrumbs " >
2010-08-30 22:19:57 -07: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 >
< div id = " g-add-photos-canvas " >
2011-04-23 10:07:32 -07:00
< button id = " g-add-photos-button " class = " g-button ui-state-default ui-corner-all " href = " # " >< ? = t ( " Select photos (%size max per file)... " , array ( " size " => $size_limit )) ?> </button>
2010-08-30 22:19:57 -07:00
< span id = " g-uploadify " ></ span >
</ div >
< div id = " g-add-photos-status " >
< ul id = " g-action-status " class = " g-message-block " >
</ ul >
</ div >
2010-08-21 15:11:06 -07:00
</ div >
2009-03-17 05:20:37 +00:00
2010-08-30 22:19:57 -07:00
< div class = " no-flash " style = " display: none " >
2009-11-20 19:41:45 -08:00
< p >
2010-08-30 22:19:57 -07:00
< ? = t ( " Your browser must have Adobe Flash Player version %flash_minimum_version or greater installed to use this feature. " , array ( " flash_minimum_version " => $flash_minimum_version )) ?>
2009-11-20 19:41:45 -08:00
</ p >
2010-08-30 22:19:57 -07:00
< a href = " http://www.adobe.com/go/getflashplayer " >
< img src = " <?= request::protocol() ?>://www.adobe.com/images/shared/download_buttons/get_flash_player.gif "
alt =< ? = t ( " Get Adobe Flash Player " ) -> for_js () ?> />
</ a >
2009-11-20 19:41:45 -08:00
</ div >