18 require_once SQ_SYSTEM_ROOT.
'/core/assets/system/tool/tool.inc';
19 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
20 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
21 require_once SQ_DATA_PATH.
'/private/conf/tools.inc';
22 require_once SQ_DATA_PATH.
'/private/conf/import_tools_manager.inc';
49 $this->
Tool($assetid);
65 $am =& $GLOBALS[
'SQ_SYSTEM']->am;
66 $itm = $am->getSystemAsset(
'import_tools_manager');
67 $import_option = $itm->attr(
'allowed_import_type');
68 $import_dir = BULK_FILE_IMPORT_DIR;
69 $process_local = ($import_option !=
'Server Only');
70 $process_server = ($import_option !=
'Local Only');
72 $o->openSection(translate(
'file_import_tools_global_options'));
73 $o->openField(translate(
'file_import_tools_allow_unrestricted'));
74 combo_box($type_code.
'_allow_unrestricted', Array(1 =>
'Yes', 0 =>
'No'));
75 echo
'<br />'.translate(
'file_import_tools_allow_unrestricted_note');
78 $o->openField(
'Link Type');
79 combo_box($type_code.
'_link_type', Array(SQ_LINK_TYPE_1 =>
'TYPE_1', SQ_LINK_TYPE_2 =>
'TYPE_2'));
80 echo
'<br />'.translate(
'file_import_tools_file_link_type_msg');
84 $o->openSection(translate(
'file_import_tools_file_dir_selection'));
85 if (empty($import_dir)) {
86 $o->openField(translate(
'file_import_tools_warning'));
87 echo translate(
'file_import_tools_not_ready_msg');
91 if ($process_server) {
93 $o->openField(translate(
'file_import_tools_server_import'));
95 $compatible_types = $itm->attr(
'valid_file_types');
98 $dirs_array = list_dirs($import_dir, TRUE);
100 <table
class=
"sq-backend-table" style=
"width: 600px;">
102 <th
class=
"sq-backend-table-header" style=
"width: 130px;"><?php echo
'Directory'; ?></th>
103 <th
class=
"sq-backend-table-header" style=
"width: 80px; text-align: center;"><?php echo
'Select for Import'; ?></th>
104 <th
class=
"sq-backend-table-header" style=
"width: 390px; text-align: center;"><?php echo
'Import Under'; ?></th>
108 if (!empty($files)) {
109 $num_of_files = count($files);
112 <td
class=
"sq-backend-table-cell" style=
"border-bottom: 0px;"><?php echo $num_of_files; ?> file<?php echo ($num_of_files > 1) ?
's' :
''; ?>.</td>
113 <td
class=
"sq-backend-table-cell" style=
"border-bottom: 0px; text-align: center;"><?php check_box(
'chunk_file_import',
'1', FALSE); ?></td>
114 <td
class=
"sq-backend-table-cell" style=
"border-bottom: 0px; text-align: center;"><?php asset_finder(
'chunk_file_import_root_assetid',
''); ?></td>
117 <td
class=
"sq-backend-table-cell" style=
"border-top: 0px;"colspan=
"3"><?php echo translate(
'file_import_tools_file_chunk',
'<b>'.$import_dir.
'</b>') ?></td>
123 foreach ($dirs_array as $dir_name) {
125 $num_of_files = count($files);
126 $stripped_dname = substr($dir_name, strrpos($dir_name,
'/') + 1);
129 if (strpos($stripped_dname,
'__tmp_file_upload__') !== FALSE) {
135 <td
class=
"sq-backend-table-cell"><?php echo $stripped_dname; ?> (<?php echo $num_of_files; ?> file<?php echo ($num_of_files > 1) ?
's' :
''; ?>)</td>
136 <td
class=
"sq-backend-table-cell" style=
"text-align: center;"><?php check_box(
'file_import_dirname_'.str_replace(
' ',
'_', $stripped_dname), $dir_name, FALSE); ?></td>
137 <td
class=
"sq-backend-table-cell" style=
"text-align: center;"><?php asset_finder(str_replace(
' ',
'_', $stripped_dname).
'_root_assetid',
''); ?></td>
143 <td
class=
"sq-backend-table-cell" style=
"border-top: 0px;"colspan=
"3">
145 echo
"Sort the files alphanumerically on import? ";
146 check_box(
'sort_file_import',
'1', FALSE);
152 $o->note(translate(
'file_import_tools_select_file'));
157 if ($process_local) {
159 $o->openField(translate(
'file_import_tools_local_import'));
161 if (!is_writable($import_dir)) {
162 $o->note(translate(
'file_import_tools_local_import_permission_warning', $import_dir));
167 <table
class=
"sq-backend-table" style=
"width: 600px;">
169 <th
class=
"sq-backend-table-header" colspan=
"2"><?php
170 echo translate(
'file_import_tools_local_file_import_root');
174 <td
class=
"sq-backend-table-header" style=
"width: 100px;"><?php
175 echo translate(
'file_import_tools_root_asset');
177 <td
class=
"sq-backend-table-header" style=
"width: 500px;"><?php
178 asset_finder(
'bulk_file_import_local_upload_root_asset',
'');
183 <div style=
'display: none;`' id=
'bulk_file_import_local_file_input_container'></div>
184 <div
id=
'bulk_file_import_table_container'></div>
186 <span style=
"font-size: 11px;"> <?php echo translate(
'core_cannot_upload_file_larger_than',
'<b>'.strtoupper(easy_filesize($max_size)).
'</b>'); ?></span>
187 <input
type=
"hidden" name=
"MAX_FILE_SIZE" value=
"<?php echo $max_size; ?>" />
189 <script type=
"text/javascript">
192 function local_file_import_table()
195 this.table = document.createElement(
"table");
197 this.file_names = Array();
200 this.is_gecko = (navigator.product ==
'Gecko');
202 (navigator.userAgent.toLowerCase().indexOf(
"msie") != -1)
206 this.image_exts = Array(
'jpg',
'jpeg',
'gif',
'png');
207 this.doc_exts = Array(
'doc',
'dot',
'docx');
208 this.pdf_exts = Array(
'pdf');
209 this.xls_exts = Array(
'xls',
'xlt',
'xlsx',
'xlsm',
'xltx',
'xltm');
210 this.rtf_exts = Array(
'rtf');
211 this.txt_exts = Array(
'txt');
212 this.js_exts = Array(
'js');
213 this.ppt_exts = Array(
'ppt',
'pps',
'pot',
'pptx',
'ppsx',
'potx',
'pptm',
'potm',
'ppsm');
214 this.css_exts = Array(
'css');
215 this.mp3_exts = Array(
'mp3');
216 this.video_exts = Array(
'mov',
'avi',
'wmv',
'asf',
'flv',
'mp4',
'm4v',
'mpg',
'mpeg');
219 this.init =
function()
221 var container = document.getElementById(
'bulk_file_import_table_container');
223 this.table.className =
'sq-backend-table';
224 this.table.style.width =
'600px';
227 var thead = document.createElement(
'thead');
228 var header_row = document.createElement(
'tr');
229 var th = document.createElement(
'th');
231 th.className =
'sq-backend-table-header';
232 th.style.width =
'100px';
233 th.innerHTML =
'Files to Import';
234 header_row.appendChild(th);
235 thead.appendChild(header_row);
238 var tbody = document.createElement(
'tbody');
239 var body_row = document.createElement(
'tr');
240 var row_id =
'bulk_file_upload_new_row_0';
241 body_row.id = row_id;
242 var td_1 = document.createElement(
'td');
243 var td_2 = document.createElement(
'td');
244 var td_3 = document.createElement(
'td');
246 td_1.className =
'sq-backend-table-cell';
247 td_2.className =
'sq-backend-table-cell';
248 td_3.className =
'sq-backend-table-cell';
250 td_1.style.borderTop =
'1px solid #1A1A1A';
251 td_2.style.borderTop =
'1px solid #1A1A1A';
252 td_3.style.borderTop =
'1px solid #1A1A1A';
254 td_1.style.width =
'100px';
255 td_2.style.width =
'470px';
256 td_3.style.width =
'30px';
258 td_1.innerHTML =
'<b>Choose File</b>';
259 td_2.innerHTML =
'<input type="file" size="50" name="bulk_file_upload_file_chooser_0" id="bulk_file_upload_file_chooser_0" class="sq-form-field" onchange="local_file_table.fileSelected(this, \'0\');" />';
260 td_3.innerHTML =
'<img title="Delete News" src="<?php echo sq_web_path('data
'); ?>/asset_types/bodycopy/images/icons/delete.png" onclick="local_file_table.removeRow(\'0\', true);">';
262 body_row.appendChild(td_1);
263 body_row.appendChild(td_2);
264 body_row.appendChild(td_3);
265 tbody.appendChild(body_row);
269 var tfoot = document.createElement(
'tfoot');
270 var footer_row = document.createElement(
'tr');
271 var td = document.createElement(
'td');
272 td.className =
'sq-backend-table-cell';
275 td.style.borderTop =
'1px solid #000000';
276 td.innerHTML =
'<div id="insert_file_link" onclick="local_file_table.addRow();"><b>[Click Here to Add]</b></div>';
277 footer_row.appendChild(td);
278 tfoot.appendChild(footer_row);
281 this.table.appendChild(thead);
282 this.table.appendChild(tbody);
283 this.table.appendChild(tfoot);
284 container.appendChild(this.table);
289 this.addRow =
function()
291 children = this.tbody.childNodes;
292 this.tbody.appendChild(this._newRow(this.id_count));
297 this._newRow =
function(id)
299 var new_tr = document.createElement(
'tr');
300 var row_id =
'bulk_file_upload_new_row_' + id;
302 var td_1 = document.createElement(
'td');
303 var td_2 = document.createElement(
'td');
304 var td_3 = document.createElement(
'td');
306 td_1.className =
'sq-backend-table-cell';
307 td_2.className =
'sq-backend-table-cell';
308 td_3.className =
'sq-backend-table-cell';
309 td_1.style.borderTop =
'1px solid #19212A';
310 td_2.style.borderTop =
'1px solid #19212A';
311 td_3.style.borderTop =
'1px solid #19212A';
312 td_1.innerHTML =
'<b>Choose File</b>';
313 td_2.innerHTML =
'<input type="file" size="50" name="bulk_file_upload_file_chooser_' +
id +
'" id="bulk_file_upload_file_chooser_' +
id +
'" class="sq-form-field" onchange="local_file_table.fileSelected(this, \'' +
id +
'\');
" />';
314 td_3.innerHTML = '<img title="Delete News
" src="<?php echo sq_web_path(
'data'); ?>/asset_types/bodycopy/images/icons/
delete.png
" onclick="local_file_table.removeRow(\
'' +
id +
'\',
true);
">';
316 new_tr.appendChild(td_1);
317 new_tr.appendChild(td_2);
318 new_tr.appendChild(td_3);
324 this.removeRow = function(id, removeFromList)
326 elt = document.getElementById('bulk_file_upload_file_chooser_' + id);
327 if (elt.tagName.toLowerCase() == 'span') {
328 file_name = document.getElementById('bulk_file_upload_file_chooser_' + id + '_').value;
329 } else if (elt.tagName == 'input') {
333 children = this.tbody.childNodes;
334 for (var i = 0; i < children.length; i++) {
335 if (children[i].id == 'bulk_file_upload_new_row_' + id) {
336 type = this._currentFileType(id);
337 if (type == 'image') {
338 this.tbody.removeChild(children[i + 4]);
339 this.tbody.removeChild(children[i + 3]);
340 this.tbody.removeChild(children[i + 2]);
341 this.tbody.removeChild(children[i + 1]);
343 if (children[i + 1] != null) {
344 if (children[i + 1].id == 'bulk_file_upload_new_row_file_type_' + id) {
345 this.tbody.removeChild(children[i + 2]);
346 this.tbody.removeChild(children[i + 1]);
350 this.tbody.removeChild(children[i]);
355 // Remove the file name from the list
356 if (removeFromList) {
357 new_file_names = Array();
358 for (i = 0; i < this.file_names.length; i++) {
359 if (file_name != this.file_names[i]) {
360 new_file_names.push(this.file_names[i]);
363 this.file_names = new_file_names;
368 // Set the type of the file as one of the specialised types, or file if none match
369 this.fileSelected = function(elt, id)
371 // Replace input tag with span so that people can double select the file
372 span = document.createElement('span');
373 span.innerHTML = elt.value;
375 p_node = elt.parentNode;
376 p_node.insertBefore(span, elt);
377 elt.style.display = 'none';
378 elt.id = elt.id + '_';
380 // Duplication Checks.
381 file_name = elt.value;
382 for (i = 0; i < this.file_names.length; i++) {
383 if (file_name == this.file_names[i]) {
384 alert('The file, ' + file_name + ' already has been added.');
385 this.removeRow(id, false);
389 this.file_names.push(file_name);
391 row_id = 'bulk_file_upload_new_row_' + id;
392 children = this.tbody.childNodes;
393 for (var i = 0; i < children.length; i++) {
394 if (children[i].id == row_id) {
395 extension = this._getFileType(file_name);
396 if (i == (children.length - 1)) {
397 // Last element, appendChild
398 this.tbody.appendChild(this._fileTypeRow(id, extension));
399 this.tbody.appendChild(this._newImageRow(id, 'Title'));
400 if (this._currentFileType(id) == 'image') {
401 this.tbody.appendChild(this._newImageRow(id, 'Alt'));
402 this.tbody.appendChild(this._newImageRow(id, 'Caption'));
405 // Somewhere in the middle, insertBefore
406 this.tbody.insertBefore(this._fileTypeRow(id, extension), children[i + 1]);
407 this.tbody.insertBefore(this._newImageRow(id, 'Title'), children[i + 2]);
408 if (this._currentFileType(id) == 'image') {
409 this.tbody.insertBefore(this._newImageRow(id, 'Alt'), children[i + 3]);
410 this.tbody.insertBefore(this._newImageRow(id, 'Caption'), children[i + 4]);
417 }//end fileSelected()
419 this._fileTypeRow = function(id, ext)
421 new_tr = document.createElement('tr');
422 new_tr.id = 'bulk_file_upload_new_row_file_type_' + id;
423 td_1 = document.createElement('td');
424 td_2 = document.createElement('td');
427 td_1.className = 'sq-backend-table-cell';
428 td_2.className = 'sq-backend-table-cell';
429 td_1.innerHTML = 'File Type';
431 // Detect the initial file type from the file extension
432 if (this._isFileTypeIn(this.image_exts, ext)) {
433 td_2.innerHTML = 'Image<input type="hidden
" value="1
" name="bulk_file_upload_row_
' + id + '_file_type_image
" id="bulk_file_upload_row_
' + id + '_file_type_image
" >';
434 } else if (this._isFileTypeIn(this.doc_exts, ext)) {
435 td_2.innerHTML = 'MS Word<input type="hidden
" value="1
" name="bulk_file_upload_row_
' + id + '_file_type_word
" id="bulk_file_upload_row_
' + id + '_file_type_word
" >';
436 } else if (this._isFileTypeIn(this.pdf_exts, ext)) {
437 td_2.innerHTML = 'PDF<input type="hidden
" value="1
" name="bulk_file_upload_row_
' + id + '_file_type_pdf
" id="bulk_file_upload_row_
' + id + '_file_type_pdf
" >';
438 } else if (this._isFileTypeIn(this.ppt_exts, ext)) {
439 td_2.innerHTML = 'MS Powerpoint<input type="hidden
" value="1
" name="bulk_file_upload_row_
' + id + '_file_type_powerpoint
" id="bulk_file_upload_row_
' + id + '_file_type_powerpoint
" >';
440 } else if (this._isFileTypeIn(this.xls_exts, ext)) {
441 td_2.innerHTML = 'MS Excel<input type="hidden
" value="1
" name="bulk_file_upload_row_
' + id + '_file_type_excel
" id="bulk_file_upload_row_
' + id + '_file_type_excel
" >';
442 } else if (this._isFileTypeIn(this.rtf_exts, ext)) {
443 td_2.innerHTML = 'RTF<input type="hidden
" value="1
" name="bulk_file_upload_row_
' + id + '_file_type_rtf
" id="bulk_file_upload_row_
' + id + '_file_type_rtf
" >';
444 } else if (this._isFileTypeIn(this.txt_exts, ext)) {
445 td_2.innerHTML = 'Text<input type="hidden
" value="1
" name="bulk_file_upload_row_
' + id + '_file_type_text
" id="bulk_file_upload_row_
' + id + '_file_type_textf
" >';
446 } else if (this._isFileTypeIn(this.css_exts, ext)) {
447 td_2.innerHTML = 'CSS<input type="hidden
" value="1
" name="bulk_file_upload_row_
' + id + '_file_type_css
" id="bulk_file_upload_row_
' + id + '_file_type_css
" >';
448 } else if (this._isFileTypeIn(this.js_exts, ext)) {
449 td_2.innerHTML = 'JS<input type="hidden
" value="1
" name="bulk_file_upload_row_
' + id + '_file_type_js
" id="bulk_file_upload_row_
' + id + '_file_type_js
" >';
450 } else if (this._isFileTypeIn(this.mp3_exts, ext)) {
451 td_2.innerHTML = 'MP3<input type="hidden
" value="1
" name="bulk_file_upload_row_
' + id + '_file_type_mp3
" id="bulk_file_upload_row_
' + id + '_file_type_mp3
" >';
452 } else if (this._isFileTypeIn(this.video_exts, ext)) {
453 td_2.innerHTML = 'Video<input type="hidden
" value="1
" name="bulk_file_upload_row_
' + id + '_file_type_video
" id="bulk_file_upload_row_
' + id + '_file_type_video
" >';
455 td_2.innerHTML = 'Others<input type="hidden
" value="1
" name="bulk_file_upload_row_
' + id + '_file_type_others
" id="bulk_file_upload_row_
' + id + '_file_type_others
" >';
459 new_tr.appendChild(td_1);
460 new_tr.appendChild(td_2);
464 }//end _fileTypeRow()
466 this._isFileTypeIn = function(list, findme)
468 for (var i = 0; i < list.length; i++) {
469 if (findme.toLowerCase() == list[i]) {
475 }//end _isFileTypeIn()
477 this._getFileType = function(name)
479 if (name.indexOf('.') == -1) {
482 var arr = name.split('.');
483 extension = arr[arr.length - 1];
484 return extension.toLowerCase();
488 // Return the currently chosen file type name in String
489 // (one of the specialised types, or 'others' for other file types)
490 // It also returns 'none' if the file has been chosen
491 this._currentFileType = function(id)
493 types = Array('image', 'pdf', 'word', 'powerpoint', 'excel', 'rtf', 'text', 'js' , 'css', 'mp3', 'video', 'others');
494 for (i = 0; i < types.length; i++) {
495 radio_button = document.getElementById('bulk_file_upload_row_' + id + '_file_type_' + types[i]);
496 if (radio_button != null) {
497 if (radio_button.value == "1
") {
503 }//end _currentFileType()
505 this._newImageRow = function(id, type)
507 var new_tr = document.createElement('tr');
508 new_tr.id = 'bulk_file_upload_new_row_' + type.toLowerCase() + '_' + id;
509 var td_1 = document.createElement('td');
510 var td_2 = document.createElement('td');
512 td_1.className = 'sq-backend-table-cell';
513 td_2.className = 'sq-backend-table-cell';
515 td_1.innerHTML = type;
516 if (type == 'Caption') {
517 td_2.innerHTML = '<textarea cols="60
" rows="2
" name="bulk_file_upload_new_row_
' + type.toLowerCase() + '_msg_
' + id + '" size="30
" maxlength="255
"></textarea>';
519 td_2.innerHTML = '<input type="text
" name="bulk_file_upload_new_row_
' + type.toLowerCase() + '_msg_
' + id + '" size="30
" maxlength="255
" />';
523 new_tr.appendChild(td_1);
524 new_tr.appendChild(td_2);
528 }//end _newCaptionRow()
530 }//end class local_file_import_table()
532 var local_file_table = new local_file_import_table();
533 local_file_table.init();
541 }//end if Local Upload
548 $o->openSection(' ');
563 public static function processTool(&$o, $type_code)
565 $am =& $GLOBALS['SQ_SYSTEM']->am;
567 $itm = $am->getSystemAsset('import_tools_manager');
568 $import_dir = BULK_FILE_IMPORT_DIR;
569 $import_option = $itm->attr('allowed_import_type');
570 $process_local = ($import_option != 'Server Only');
571 $process_server = ($import_option != 'Local Only');
573 // Process Server Upload
574 if ($process_server) {
575 $sorting = array_get_index($_POST, 'sort_file_import', FALSE);
576 $dirs_array = list_dirs($import_dir, TRUE);
578 foreach ($dirs_array as $dir_name) {
579 $files = Tool_Bulk_File_Import::_getFileList($dir_name);
580 $num_of_files = count($files);
582 $stripped_dname = substr($dir_name, strrpos($dir_name, '/') + 1);
583 $replaced_dname = str_replace(' ', '_', $stripped_dname);
584 $tmp = array_get_index($_POST, 'file_import_dirname_'.$replaced_dname, '');
587 $tmp = array_get_index($_POST, $replaced_dname.'_root_assetid', '');
588 if (!empty($tmp['assetid'])) {
589 if (!isset($vars['total_count'])) {
590 $vars['total_count'] = $num_of_files;
592 $vars['total_count'] = $vars['total_count'] + $num_of_files;
594 $vars['server_file_import'][$dir_name]['file_list'] = $files;
595 $vars['server_file_import'][$dir_name]['num_of_files'] = $num_of_files;
596 $vars['server_file_import'][$dir_name]['root_id'] = $tmp['assetid'];
601 $tmp = array_get_index($_POST, 'chunk_file_import', '');
605 $tmp = array_get_index($_POST, 'chunk_file_import_root_assetid', '');
606 if (!empty($tmp['assetid'])) {
607 $files = Tool_Bulk_File_Import::_getFileList($import_dir);
608 if (!isset($vars['total_count'])) {
609 $vars['total_count'] = count($files);
611 $vars['total_count'] = $vars['total_count'] + count($files);
613 $vars['server_file_import'][$import_dir]['file_list'] = $files;
614 $vars['server_file_import'][$import_dir]['num_of_files'] = count($files);
615 $vars['server_file_import'][$import_dir]['root_id'] = $tmp['assetid'];
619 if ($sorting && isset($vars['server_file_import'])) {
620 foreach ($vars['server_file_import'] as $import_dir_name => $import_file_info) {
621 if (isset($vars['server_file_import'][$import_dir_name]['file_list']))
622 sort($vars['server_file_import'][$import_dir_name]['file_list']);
627 // Process Local Upload
628 if ($process_local) {
630 if (isset($_POST['bulk_file_import_local_upload_root_asset'])) {
631 $local_import_rootid = $_POST['bulk_file_import_local_upload_root_asset']['assetid'];
633 if (!empty($_FILES)) {
634 // the user didn't pick the root asset, show some warning.
635 trigger_error(translate('file_import_tools_local_file_no_root_asset'), E_USER_WARNING);
639 if (!empty($local_import_rootid) && !empty($_FILES)) {
642 $file_types = Array('image', 'pdf', 'word','powerpoint', 'excel', 'rtf', 'text', 'js' , 'css', 'mp3', 'video', 'others');
643 $uploaded_files = Array();
644 $tmp_dir_name = $type_code.'__tmp_file_upload__';
646 foreach ($_FILES as $id => $data) {
647 $file_info = get_file_upload_info($id);
649 if (!empty($file_info)) {
652 if (!file_exists($import_dir.'/'.$tmp_dir_name)) {
653 if (!mkdir($import_dir.'/'.$tmp_dir_name)) {
654 trigger_error(translate('file_import_tools_cannot_create_temp_dir'), E_USER_WARNING);
659 $result = commit_file_upload($id, $import_dir.'/'.$tmp_dir_name, TRUE);
660 if ($result === FALSE) {
661 trigger_error(translate('file_import_tools_local_file_upload_error', $file_info['name']), E_USER_WARNING);
663 } else if ($result === '') {
664 trigger_error(translate('file_import_tools_local_file_cannot_upload', $file_info['name']), E_USER_WARNING);
666 } else if ($result == $file_info['name']) {
668 $text_length = strlen('bulk_file_upload_file_chooser_');
669 $file_id = substr($id, $text_length);
672 foreach ($file_types as $file_type) {
673 $value = array_get_index($_POST, 'bulk_file_upload_row_'.$file_id.'_file_type_'.$file_type, '');
674 if (!empty($value)) {
675 $file_info['file_type'] = $file_type;
680 // if it's image, get title, alt and caption
681 if ($file_info['file_type'] == 'image') {
682 foreach (Array('title', 'alt', 'caption') as $name) {
683 $file_info[$name] = array_get_index($_POST, 'bulk_file_upload_new_row_'.$name.'_msg_'.$file_id, '');
686 $file_info['title'] = array_get_index($_POST, 'bulk_file_upload_new_row_title_msg_'.$file_id, '');
689 $uploaded_files[] = $file_info;
692 // We may want to delete the uploaded files here, if it is required.
693 if ($error) return FALSE;
697 }//end foreach $_FILES
699 if (!empty($uploaded_files)) {
700 $vars['local_file_import']['rootid'] = $local_import_rootid;
701 $vars['local_file_import']['location'] = $import_dir.'/'.$tmp_dir_name;
702 $vars['local_file_import']['files'] = $uploaded_files;
705 }//end if !empty($_FILES)
708 }//end if Process Local
710 if (!empty($vars['server_file_import']) || !empty($vars['local_file_import'])) {
712 $vars['allow_unrestricted'] = array_get_index($_POST, $type_code.'_allow_unrestricted', TRUE);
713 $vars['link_type'] = array_get_index($_POST, $type_code.'_link_type', SQ_LINK_TYPE_1);
714 // We have all the required data, so queue up our HIPO and go to town
715 $hh = $GLOBALS['SQ_SYSTEM']->getHipoHerder();
716 $result = $hh->queueHipo('hipo_job_bulk_file_import', $vars, '', SQ_PACKAGES_PATH.'/import_tools/hipo_jobs/');
717 $url = $hh->runQueuedJobs();
718 if (!empty($url)) $o->setRedirect($url);
735 protected static function _getFileList($dir)
737 $files = list_files($dir);
738 foreach ($files as $key => $file_name) {
739 if (substr($file_name, 0, 1) == '.') {
746 }//end _getFileList()
755 protected static function _getMaxFileSize()
757 $user_prefs_max_file_size = $GLOBALS['SQ_SYSTEM']->getUserPrefs('file', 'SQ_FILE_MAX_SIZE');
758 $max_size = strtolower($user_prefs_max_file_size);
760 if (substr($max_size, -1) == 'k') {
761 $max_size = $max_size * 1024;
762 } else if (substr($max_size, -1) == 'm') {
763 $max_size = $max_size * 1024 * 1024;
766 // work out the max file size that PHP is allowing
767 $ini_size = strtolower(ini_get('upload_max_filesize'));
768 if (substr($ini_size, -1) == 'k') {
769 $ini_size = $ini_size * 1024;
770 } else if (substr($ini_size, -1) == 'm') {
771 $ini_size = $ini_size * 1024 * 1024;
774 // work out the max post size that PHP is allowing
775 $post_size = strtolower(ini_get('post_max_size'));
776 if (substr($post_size, -1) == 'k') {
777 $post_size = $post_size * 1024;
778 } else if (substr($post_size, -1) == 'm') {
779 $post_size = $post_size * 1024 * 1024;
782 $mem_limit_size = strtolower(ini_get('memory_limit'));
783 if (substr($mem_limit_size, -1) == 'k') {
784 $mem_limit_size = $mem_limit_size * 1024;
785 } else if (substr($mem_limit_size, -1) == 'm') {
786 $mem_limit_size = $mem_limit_size * 1024 * 1024;
788 $max_size = min($ini_size, $post_size, $mem_limit_size);
792 }//end _getMaxFileSize()