示例#1
0
 public function __construct($tag = '', rex_metainfo_table_expander $table = null, array $attributes = [])
 {
     parent::__construct('', $table, $attributes);
     $this->chkbox_element = new rex_form_checkbox_element('');
     $this->chkbox_element->setAttribute('name', 'enable_restrictions');
     $this->chkbox_element->setAttribute('id', 'enable-restrictions-checkbox');
     $this->chkbox_element->addOption(rex_i18n::msg('minfo_field_label_no_restrictions'), '');
     if ($table->getPrefix() == rex_metainfo_article_handler::PREFIX || $table->getPrefix() == rex_metainfo_category_handler::PREFIX) {
         $restrictionsSelect = new rex_category_select(false, false, true, false);
     } elseif ($table->getPrefix() == rex_metainfo_media_handler::PREFIX) {
         $restrictionsSelect = new rex_media_category_select();
     } else {
         throw new rex_exception('Unexpected TablePrefix "' . $table->getPrefix() . '"!');
     }
     $restrictionsSelect->setMultiple(true);
     $this->setSelect($restrictionsSelect);
     $this->setNotice(rex_i18n::msg('ctrl'));
 }
示例#2
0
文件: media.php 项目: alsahh/redaxo
                    $error[] = rex_i18n::msg('no_permission');
                }
            } else {
                $error[] = rex_i18n::msg('pool_file_not_found');
            }
        }
        if ($countDeleted) {
            $success[] = rex_i18n::msg('pool_files_deleted', $countDeleted);
        }
    } else {
        $error = rex_i18n::msg('pool_selectedmedia_error');
    }
}
// *************************************** SUBPAGE: "" -> MEDIEN ANZEIGEN
if (!$file_id) {
    $cats_sel = new rex_media_category_select();
    $cats_sel->setSize(1);
    $cats_sel->setStyle('class="form-control"');
    $cats_sel->setName('rex_file_category');
    $cats_sel->setId('rex_file_category');
    $cats_sel->addOption(rex_i18n::msg('pool_kats_no'), '0');
    $cats_sel->setSelected($rex_file_category);
    if (is_array($error)) {
        if (count($error) > 0) {
            echo rex_view::error(implode('<br />', $error));
        }
        $error = '';
    } elseif ($error != '') {
        echo rex_view::error($error);
        $error = '';
    }
示例#3
0
/**
 * Ausgabe des Medienpool Formulars.
 */
function rex_mediapool_Mediaform($form_title, $button_title, $rex_file_category, $file_chooser, $close_form)
{
    global $ftitle, $warning, $info;
    $s = '';
    $cats_sel = new rex_media_category_select();
    $cats_sel->setStyle('class="form-control"');
    $cats_sel->setSize(1);
    $cats_sel->setName('rex_file_category');
    $cats_sel->setId('rex-mediapool-category');
    $cats_sel->addOption(rex_i18n::msg('pool_kats_no'), '0');
    $cats_sel->setAttribute('onchange', 'this.form.submit()');
    $cats_sel->setSelected($rex_file_category);
    if (isset($warning)) {
        if (is_array($warning)) {
            if (count($warning) > 0) {
                $s .= rex_view::error(implode('<br />', $warning));
            }
        } elseif ($warning != '') {
            $s .= rex_view::error($warning);
        }
        $warning = '';
    }
    if (isset($info)) {
        if (is_array($info)) {
            if (count($info) > 0) {
                $s .= rex_view::success(implode('<br />', $info));
            }
        } elseif ($info != '') {
            $s .= rex_view::success($info);
        }
        $info = '';
    }
    if (!isset($ftitle)) {
        $ftitle = '';
    }
    $arg_fields = '';
    foreach (rex_request('args', 'array') as $arg_name => $arg_value) {
        $arg_fields .= '<input type="hidden" name="args[' . $arg_name . ']" value="' . $arg_value . '" />' . "\n";
    }
    $opener_input_field = rex_request('opener_input_field', 'string');
    if ($opener_input_field != '') {
        $arg_fields .= '<input type="hidden" name="opener_input_field" value="' . htmlspecialchars($opener_input_field) . '" />' . "\n";
    }
    $add_submit = '';
    if ($close_form && $opener_input_field != '') {
        $add_submit = '<button class="btn btn-save" type="submit" name="saveandexit" value="' . rex_i18n::msg('pool_file_upload_get') . '"' . rex::getAccesskey(rex_i18n::msg('pool_file_upload_get'), 'save') . '>' . rex_i18n::msg('pool_file_upload_get') . '</button>';
    }
    $panel = '';
    $formElements = [];
    $e = [];
    $e['label'] = '<label for="rex-mediapool-title">' . rex_i18n::msg('pool_file_title') . '</label>';
    $e['field'] = '<input class="form-control" type="text" id="rex-mediapool-title" name="ftitle" value="' . htmlspecialchars($ftitle) . '" />';
    $formElements[] = $e;
    $e = [];
    $e['label'] = '<label for="rex-mediapool-category">' . rex_i18n::msg('pool_file_category') . '</label>';
    $e['field'] = $cats_sel->get();
    $formElements[] = $e;
    $fragment = new rex_fragment();
    $fragment->setVar('elements', $formElements, false);
    $panel .= $fragment->parse('core/form/form.php');
    $panel .= rex_extension::registerPoint(new rex_extension_point('MEDIA_FORM_ADD', ''));
    if ($file_chooser) {
        $e = [];
        $e['label'] = '<label for="rex-mediapool-choose-file">' . rex_i18n::msg('pool_file_file') . '</label>';
        $e['field'] = '<input id="rex-mediapool-choose-file" type="file" name="file_new" />';
        $e['note'] = '<h3>' . rex_i18n::msg('phpini_settings') . '</h3>
                        <dl class="dl-horizontal">
                        ' . (rex_ini_get('file_uploads') == 0 ? '<dt><span class="text-warning">' . rex_i18n::msg('pool_upload') . '</span></dt><dd><span class="text-warning">' . rex_i18n::msg('pool_upload_disabled') . '</span></dd>' : '') . '
                            <dt>' . rex_i18n::msg('pool_max_uploadsize') . ':</dt><dd>' . rex_formatter::bytes(rex_ini_get('upload_max_filesize')) . '</dd>
                            <dt>' . rex_i18n::msg('pool_max_uploadtime') . ':</dt><dd>' . rex_ini_get('max_input_time') . 's</dd>
                        </dl>';
        $fragment = new rex_fragment();
        $fragment->setVar('elements', [$e], false);
        $panel .= $fragment->parse('core/form/form.php');
    }
    $formElements = [];
    $e = [];
    $e['field'] = '<button class="btn btn-save" type="submit" name="save" value="' . $button_title . '"' . rex::getAccesskey($button_title, 'save') . '>' . $button_title . '</button>';
    $formElements[] = $e;
    $e = [];
    $e['field'] = $add_submit;
    $formElements[] = $e;
    $fragment = new rex_fragment();
    $fragment->setVar('elements', $formElements, false);
    $buttons = $fragment->parse('core/form/submit.php');
    $fragment = new rex_fragment();
    $fragment->setVar('title', $form_title, false);
    $fragment->setVar('body', $panel, false);
    $fragment->setVar('buttons', $buttons, false);
    $content = $fragment->parse('core/page/section.php');
    $s .= ' <form action="' . rex_url::currentBackendPage() . '" method="post" enctype="multipart/form-data">
                <fieldset>
                    <input type="hidden" name="media_method" value="add_file" />
                    ' . $arg_fields . '
                    ' . $content . '
                </fieldset>
            ';
    if ($close_form) {
        $s .= '</form>' . "\n";
    }
    return $s;
}
 /**
  * creates and returns the uploadform
  */
 public function createUploadForm()
 {
     $rex_file_category = rex_request('rex_file_category', 'int');
     $output = '';
     $script_page_header = '';
     $uploadPath = "index.php?page=" . $this->addon_name . "/upload&upload_folder=" . $this->folder;
     if ($this->sync_cat) {
         $cats_sel = new rex_media_category_select();
         $cats_sel->setStyle('class="form-control"');
         $cats_sel->setSize(1);
         $cats_sel->setName('rex_file_category');
         $cats_sel->setId('rex_file_category_' . $this->time);
         $cats_sel->addOption(rex_i18n::msg('pool_kats_no'), '0');
         $cats_sel->setAttribute('onchange', 'this.form.submit()');
         $cats_sel->setSelected($rex_file_category);
         $arg_fields = '';
         foreach (rex_request('args', 'array') as $arg_name => $arg_value) {
             $arg_fields .= '<input type="hidden" name="args[' . $arg_name . ']" value="' . $arg_value . '" />' . "\n";
         }
         $opener_input_field = rex_request('opener_input_field', 'string');
         if ($opener_input_field != '') {
             $arg_fields .= '<input type="hidden" name="opener_input_field" value="' . htmlspecialchars($opener_input_field) . '" />' . "\n";
         }
         $panel = '';
         $formElements = [];
         if ($this->markup) {
             $e = [];
             $e['label'] = '<label for="rex_file_category_' . $this->time . '">' . rex_i18n::msg('pool_file_category') . '</label>';
             $e['field'] = $cats_sel->get();
             $formElements[] = $e;
             $fragment = new rex_fragment();
             $fragment->setVar('elements', $formElements, false);
             $panel .= $fragment->parse('core/form/form.php');
             $panel .= rex_extension::registerPoint(new rex_extension_point('MEDIA_FORM_ADD', ''));
             $fragment = new rex_fragment();
             $fragment->setVar('class', 'info', false);
             $fragment->setVar('title', "Medienpool Kategorie");
             $fragment->setVar('body', $panel, false);
             $content = $fragment->parse('core/page/section.php');
             $output .= '
             <form action="' . rex_url::currentBackendPage() . '" method="post" enctype="multipart/form-data">
             <fieldset>
               <input type="hidden" name="media_method" value="add_file" />
                 ' . $arg_fields . '
                 ' . $content . '
             </fieldset></form>';
         }
     }
     # end sync_cat
     $output_upload_button = '';
     $output_upload_button .= '
     <div id="multiupload' . $this->time . '" class="' . ($this->markup ? 'behave_normal' : 'styleless') . '">
     <noscript>      
       <p>JavaScript muss aktiviert sein.</p>
     </noscript>
     </div>';
     if ($this->markup) {
         if (!$this->clear_uploadlist_automatically) {
             $content = '';
             $content .= $output_upload_button;
             $content .= '
             <p>weitere Aktionen:</p>
             <a href="javascript:void(0)" onclick="clearUploadList();">Abgeschlossene / fehlerhafte aus der Liste entfernen</a>
             </p>';
             $sections = '';
             $fragment = new rex_fragment();
             $fragment->setVar('class', 'info', false);
             $fragment->setVar('title', "Aktionen");
             $fragment->setVar('body', $content, false);
             $output .= $fragment->parse('core/page/section.php');
         }
     }
     $script_page_header .= '
     <script type="text/javascript">
       
       function rex_multiupload_createUploader' . $this->time . '(){            
         var uploader = new qq.FileUploader({
           element: document.getElementById("multiupload' . $this->time . '"),
           action: "' . $uploadPath . '",
           mediaPoolSelector: "rex_file_category_' . $this->time . '",
           sizeLimit: 0, // max size   
           minSizeLimit: 0, // min size';
     $script_page_header .= '
         onSubmit: function(id,filename) {' . "\n";
     if ($this->clear_uploadlist_automatically) {
         $script_page_header .= '
         clearUploadList();';
     }
     if ($this->onSubmitCallback) {
         $script_page_header .= '
         if(typeof ' . $this->onSubmitCallback . ' == "function") { 
             // user callback function
             ' . $this->onSubmitCallback . '(filename);
         }';
     }
     $script_page_header .= '
     },';
     # end onSubmit
     $script_page_header .= '
         onUpload: function(id,fileName, xhr) {' . "\n";
     if ($this->onUploadCallback) {
         $script_page_header .= '
         if(typeof ' . $this->onUploadCallback . ' == "function") { 
             // user callback function
             ' . $this->onUploadCallback . '(fileName, xhr);
         }';
     }
     $script_page_header .= '
     },';
     # end onUpload
     $script_page_header .= '
         onProgress: function(id,fileName, loaded, total) {' . "\n";
     if ($this->onProgressCallback) {
         $script_page_header .= '
         if(typeof ' . $this->onProgressCallback . ' == "function") { 
             // user callback function
             ' . $this->onProgressCallback . '(fileName, loaded, total);
         }';
     }
     $script_page_header .= '
     },';
     # end onProgress
     $script_page_header .= '
         onComplete: function(id,filename,json) {' . "\n";
     if ($this->clear_file_after_finish) {
         $script_page_header .= '                        
             window.setTimeout(function(){
                 clearUploadListSuccess();
             }, 5000);';
     }
     if ($this->onCompleteCallback) {
         $script_page_header .= '
         if(typeof ' . $this->onCompleteCallback . ' == "function" && json.success) { 
             // user callback function
             ' . $this->onCompleteCallback . '(json);
         }';
     }
     $script_page_header .= '
     },';
     # end onComplete
     $script_page_header .= '
           onCancel: function(id,filename) {' . "\n";
     if ($this->onCancelCallback) {
         $script_page_header .= '
         if(typeof ' . $this->onCancelCallback . ' == "function") { 
             // user callback function
             ' . $this->onCancelCallback . '(filename);
         }';
     }
     $script_page_header .= '
     },';
     # end onCancel
     if ($this->upload_simultaneously && is_numeric($this->upload_simultaneously)) {
         $script_page_header .= ' 
             maxConnections: ' . $this->upload_simultaneously . ',';
     }
     $script_page_header .= '
             debug: ' . ($this->javascript_debug ? "true" : "false") . '
         });
     }
     jQuery(document).ready(function(){
         rex_multiupload_createUploader' . $this->time . '();
     });
     </script>' . "\n";
     if ($this->markup) {
         if ($this->showFootnote) {
             $output .= '<div class="rex-form-row edit_panel">
             <label>Dateien editieren</label>
             <ul class="qq-upload-list edit_uploads">
                 
             </ul>
             </div>' . "\n";
         }
     }
     if ($this->markup) {
         if ($this->showFootnote) {
             $output .= '<section class="rex-page-section">
                 <p class="rex-form-file">
                     <span class="rex-form-notice">
                     Mehrfachauswahl mit STRG(WIN) oder CMD(MAC).<br />
                     Die Dateien werden automatisch in die ausgewählte Kategorie sychronisiert.
                     Ein Wechsel der Medienkategorie greift immer vor Auswahl einer Datei. 
                     Findet ein Upload bereits statt, kann für diese Datei die Kategorie nicht mehr verändert werden.
                 </span>
                 </p>
             </section>' . "\n";
         }
     }
     rex_extension::register('OUTPUT_FILTER', function (rex_extension_point $ep) use($script_page_header) {
         $suchmuster = "<!-- ###MULTIUPLOAD_EP_REPLACE### -->";
         $ersetzen = "<!-- MULTIUPLOAD_EP_REPLACE -->\n" . $script_page_header . "<!-- /MULTIUPLOAD_EP_REPLACE -->\n</head>";
         $ep->setSubject(str_replace($suchmuster, $ersetzen, $ep->getSubject()));
     });
     // TIME FOR OUTPUT
     return $output;
 }