1: <?php
2: zp_register_filter('admin_headers', 'jQueryUpload_headers', 0);
3: zp_register_filter('admin_head', 'jQueryUpload_head');
4:
5: function jQueryUpload_headers() {
6: ob_start();
7: }
8:
9: function jQueryUpload_head() {
10: $head = ob_get_contents();
11: ob_end_clean();
12:
13: preg_match_all('~(<script.*/js/jquery\.js.*</script>)~', $head, $matches);
14: $head = str_replace($matches[1], '<script src="//code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>', $head);
15: $head = str_replace('<script src="' . WEBPATH . '/' . ZENFOLDER . '/js/jqueryui/jquery-ui-zenphoto.js" type="text/javascript"></script>', '<script src="' . WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/uploader_jQuery/jqueryui/jquery-ui-zenphoto.js"></script>', $head);
16: echo $head;
17: }
18:
19: function upload_head() {
20: $myfolder = WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/uploader_jQuery';
21: ?>
22: <script type="text/javascript" src="<?php echo $myfolder; ?>/jquery.tmpl.min.js"></script>
23: <script type="text/javascript" src="<?php echo $myfolder; ?>/jquery.iframe-transport.js"></script>
24: <script type="text/javascript" src="<?php echo $myfolder; ?>/jquery.fileupload.js"></script>
25: <script type="text/javascript" src="<?php echo $myfolder; ?>/jquery.fileupload-ui.js"></script>
26: <link rel="stylesheet" href="<?php echo $myfolder; ?>/jquery.fileupload-ui.css">
27: <?php
28: return $myfolder . '/uploader.php';
29: }
30:
31: function upload_extra($uploadlimit, $passedalbum) {
32: global $_zp_current_admin_obj;
33: ?>
34: <script type="text/javascript">
35:
36:
37: var upload_fail = false;
38: $(function() {
39: 'use strict';
40:
41:
42: $('#fileupload').fileupload({
43: url: '<?php echo WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/uploader_jQuery/uploader.php' ?>'<?php if ($uploadlimit) echo ",
44: maxFileSize:" . $uploadlimit; ?>
45: });
46:
47:
48:
49: $('#fileupload .files').delegate(
50: 'a:not([target^=_blank])',
51: 'click',
52: function(e) {
53: e.preventDefault();
54: $('<iframe style="display:none;"></iframe>')
55: .prop('src', this.href)
56: .appendTo('body');
57: }
58: );
59:
60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71:
72:
73: $('#fileupload').bind('fileuploadfail', function(e, data) {
74:
75: upload_fail = true;
76: });
77:
78: $('#fileupload').bind('fileuploadstop', function(e, data) {
79: if (upload_fail) {
80:
81:
82: upload_fail = false;
83: } else {
84: <?php
85: if (zp_loggedin(ALBUM_RIGHTS | MANAGE_ALL_ALBUM_RIGHTS)) {
86: ?>
87: launchScript('admin-edit.php', ['page=edit', 'subpage=1', 'tab=imageinfo', 'album=' + encodeURIComponent($('#folderdisplay').val()), 'uploaded=1', 'albumimagesort=id_desc']);
88: <?php
89: } else {
90: ?>
91: launchScript('admin-upload.php', ['uploaded=1']);
92: <?php
93: }
94: ?>
95: }
96: });
97:
98: });
99:
100: </script>
101: <div id="fileupload">
102: <form action="uploader.php" method="POST" enctype="multipart/form-data">
103: <input type="hidden" name="existingfolder" id="existingfolder" value="false" />
104: <input type="hidden" name="auth" id="auth" value="<?php echo $_zp_current_admin_obj->getPass(); ?>" />
105: <input type="hidden" name="id" id="id" value="<?php echo $_zp_current_admin_obj->getID(); ?>" />
106: <input type="hidden" name="folder" id="folderslot" value="<?php echo html_encode($passedalbum); ?>" />
107: <input type="hidden" name="albumtitle" id="albumtitleslot" value="" />
108: <input type="hidden" name="publishalbum" id="publishalbumslot" value="" />
109: <div class="fileupload-buttonbar">
110: <label class="fileinput-button"> <span><?php echo gettext('Add files...'); ?>
111: </span> <input type="file" name="files[]" multiple>
112: </label>
113: <span id="fileUploadbuttons">
114: <button type="submit" class="start"><?php echo gettext('Start upload'); ?></button>
115: <button type="reset" class="cancel"><?php echo gettext('Cancel upload'); ?></button>
116: </span>
117: </div>
118: </form>
119: <div class="fileupload-content">
120: <table class="files"></table>
121: <div class="fileupload-progressbar"></div>
122: </div>
123: </div>
124: <script id="template-upload" type="text/x-jquery-tmpl">
125: <tr class="template-upload{{if error}} ui-state-error{{/if}}">
126: <td class="preview"></td>
127: <td class="name">{{if name}}${name}{{else}}Untitled{{/if}}</td>
128: <td class="size">${sizef}</td>
129: {{if error}}
130: <td class="error" colspan="2"><?php echo gettext('Error:'); ?>
131: {{if error === 'maxFileSize'}}<?php echo gettext('File is too big'); ?>
132: {{else error === 'minFileSize'}}<?php echo gettext('File is too small'); ?>
133: {{else error === 'acceptFileTypes'}}<?php echo gettext('Filetype not allowed'); ?>
134: {{else error === 'maxNumberOfFiles'}}<?php echo gettext('Max number of files exceeded'); ?>
135: {{else}}${error}
136: {{/if}}
137: </td>
138: {{else}}
139: <td class="progress"><div></div></td>
140: <td class="start" style="display:none"><button><?php echo gettext('Start'); ?></button></td>
141: {{/if}}
142: <td class="cancel"><button><?php echo gettext('Cancel'); ?></button></td>
143: </tr>
144: </script>
145: <script id="template-download" type="text/x-jquery-tmpl">
146: {{if error !== 'emptyResult'}}
147: <tr class="template-download{{if error}}} ui-state-error{{/if}}">
148: {{if error}}
149: <td></td>
150: <td class="name">${name}</td>
151: <td class="size">${sizef}</td>
152: <td class="error" colspan="2"><?php echo gettext('Error:'); ?>
153: {{if error === 1}}<?php echo gettext('File exceeds upload_max_filesize (php.ini directive)'); ?>
154: {{else error === 2}}<?php echo gettext('File exceeds MAX_FILE_SIZE (HTML form directive)'); ?>
155: {{else error === 3}}<?php echo gettext('File was only partially uploaded'); ?>
156: {{else error === 4}}<?php echo gettext('No File was uploaded'); ?>
157: {{else error === 5}}<?php echo gettext('Missing a temporary folder'); ?>
158: {{else error === 6}}<?php echo gettext('Failed to write file to disk'); ?>
159: {{else error === 7}}<?php echo gettext('File upload stopped by extension'); ?>
160: {{else error === 'maxFileSize'}}<?php echo gettext('File is too big'); ?>
161: {{else error === 'minFileSize'}}<?php echo gettext('File is too small'); ?>
162: {{else error === 'acceptFileTypes'}}<?php echo gettext('Filetype not allowed'); ?>
163: {{else error === 'maxNumberOfFiles'}}<?php echo gettext('Max number of files exceeded'); ?>
164: {{else error === 'uploadedBytes'}}<?php echo gettext('Uploaded bytes exceed file size'); ?>
165: {{else error === 'emptyResult'}}<?php echo gettext('Empty file upload result'); ?>
166: {{else}}${error}
167: {{/if}}
168: </td>
169: <td class="delete">
170: <button data-type="${delete_type}" data-url="${delete_url}">Delete</button>
171: </td>
172: {{else}}
173: <td class="preview">
174: {{if thumbnail_url}}
175: <a href="${url}" target="_blank"><img src="${thumbnail_url}"></a>
176: {{/if}}
177: </td>
178: <td class="name">
179: <a href="${url}"{{if thumbnail_url}} target="_blank"{{/if}}>${name}</a>
180: </td>
181: <td class="size">${sizef}</td>
182: <td colspan="2"></td>
183: <td class="delete"><img src="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/images/pass.png" /></td>
184: {{/if}}
185: </tr>
186: {{/if}}
187: </script>
188: <?php
189: }
190:
191: function upload_form($uploadlimit, $passedalbum) {
192:
193: }
194: ?>