PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/applications/noviusos_media/views/admin/upload.view.php

https://github.com/jay3/core
PHP | 126 lines | 112 code | 6 blank | 8 comment | 0 complexity | 09900d433ee1cdc798f84e909b250145 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * NOVIUS OS - Web OS for digital communication
  4. *
  5. * @copyright 2011 Novius
  6. * @license GNU Affero General Public License v3 or (at your option) any later version
  7. * http://www.gnu.org/licenses/agpl-3.0.html
  8. * @link http://www.novius-os.org
  9. */
  10. Nos\I18n::current_dictionary(array('noviusos_media::common', 'nos::common'));
  11. $uniqid = uniqid('id_');
  12. $fields = array(
  13. 'media[]' => array(
  14. 'form' => array(
  15. 'type' => 'file',
  16. 'multiple' => true,
  17. ),
  18. 'validation' => array(
  19. 'required',
  20. ),
  21. 'label' => __('Files from your hard drive:'),
  22. ),
  23. 'unzip' => array(
  24. 'form' => array(
  25. 'type' => 'select',
  26. 'options' => array(
  27. 'unzip' => __('Unzip (both files and folders)'),
  28. 'leave' => __('Leave unzipped'),
  29. ),
  30. ),
  31. 'label' => __('What to do with ZIP files:'),
  32. ),
  33. 'media_folder_id' => array(
  34. 'renderer' => 'Nos\Media\Renderer_Folder',
  35. 'form' => array(
  36. 'type' => 'hidden',
  37. ),
  38. 'label' => __('Select a folder where to put your media files:'),
  39. ),
  40. 'save' => array(
  41. 'label' => '',
  42. 'form' => array(
  43. 'type' => 'submit',
  44. 'tag' => 'button',
  45. 'value' => __('Add'),
  46. 'class' => 'ui-priority-primary',
  47. 'data-icon' => 'check',
  48. ),
  49. ),
  50. );
  51. $fieldset = \Fieldset::build_from_config($fields);
  52. $form_attributes = $fieldset->get_config('form_attributes', array());
  53. $form_attributes['enctype'] = 'multipart/form-data';
  54. $fieldset->set_config('form_attributes', $form_attributes);
  55. $fieldset->js_validation();
  56. echo $fieldset->open('admin/noviusos_media/upload/save');
  57. $fieldset->form()->set_config('field_template', '{field}');
  58. echo $fieldset->build_hidden_fields();
  59. ?>
  60. <div class="page line mediamassupload">
  61. <div class="col c1"></div>
  62. <div class="col c10">
  63. <div class="line" style="margin-bottom:1em;">
  64. <table class="fieldset standalone">
  65. <tr>
  66. <th></th>
  67. <td>
  68. <p><strong><?= __('Hold the Ctrl/Cmd key to select multiple files.') ?></strong></p>
  69. </td>
  70. </tr>
  71. <tr class="title">
  72. <th><?= $fieldset->field('media[]')->label ?></th>
  73. <td><?= $fieldset->field('media[]')->build() ?></td>
  74. </tr>
  75. <tr>
  76. <th></th>
  77. <td>
  78. <p><em><?= strtr(__('Total files size must not exceed {{size}}.'), array('{{size}}' => ini_get('upload_max_filesize'))) ?> <?= strtr(__('What’s more these file types are not allowed: {{extensions}}.'), array('{{extensions}}' => implode(', ', \Config::get('novius-os.upload.disabled_extensions', array('php'))))) ?></em></p>
  79. </td>
  80. </tr>
  81. <tr>
  82. <th><?= $fieldset->field('unzip')->label ?></th>
  83. <td><?= $fieldset->field('unzip')->build() ?></td>
  84. </tr>
  85. <tr>
  86. <th><?= $fieldset->field('media_folder_id')->label ?></th>
  87. <td><?= $fieldset->field('media_folder_id')->build() ?></td>
  88. </tr>
  89. </table>
  90. </div>
  91. </div>
  92. <div class="col c1"></div>
  93. </div>
  94. <?= $fieldset->close() ?>
  95. <?php
  96. $json = array(
  97. 'tabParams' => $tab_params,
  98. 'saveField' => (string) \View::forge('form/layout_save', array('save_field' => $fieldset->field('save')), false),
  99. 'maxFileSize' => \Num::bytes(ini_get('upload_max_filesize')),
  100. 'texts' => array(
  101. 'exceedMaxSize' => strtr(
  102. __('Total files size exceeds the upload limit {{size}}.'),
  103. array('{{size}}' => ini_get('upload_max_filesize'))
  104. ),
  105. ),
  106. );
  107. ?>
  108. <script type="text/javascript">
  109. require(
  110. [
  111. 'static/apps/noviusos_media/js/jquery.novius-os.media-mass-upload',
  112. 'link!static/apps/noviusos_media/css/media-mass-upload.css'
  113. ],
  114. function($) {
  115. $(function() {
  116. $('#<?= $fieldset->form()->get_attribute('id') ?>')
  117. .nosMediaMassUpload(<?= \Format::forge($json)->to_json() ?>);
  118. });
  119. });
  120. </script>