}
        echo '
    </form></div>
    ';
        $OUT = false;
    }
}
if ($OUT) {
    if ($info != '') {
        echo rex_info($info);
    }
    if ($warning != '') {
        echo rex_warning($warning);
    }
    if ($warning_block != '') {
        echo rex_warning_block($warning_block);
    }
    $list = rex_list::factory('SELECT id, name FROM ' . $REX['TABLE_PREFIX'] . 'module ORDER BY name');
    $list->setCaption($I18N->msg('module_caption'));
    $list->addTableAttribute('summary', $I18N->msg('module_summary'));
    $list->addTableColumnGroup(array(40, 40, '*', 153));
    $tdIcon = '<span class="rex-i-element rex-i-module"><span class="rex-i-element-text">###name###</span></span>';
    $thIcon = '<a class="rex-i-element rex-i-module-add" href="' . $list->getUrl(array('function' => 'add')) . '"' . rex_accesskey($I18N->msg('create_module'), $REX['ACKEY']['ADD']) . '><span class="rex-i-element-text">' . $I18N->msg('create_module') . '</span></a>';
    $list->addColumn($thIcon, $tdIcon, 0, array('<th class="rex-icon">###VALUE###</th>', '<td class="rex-icon">###VALUE###</td>'));
    $list->setColumnParams($thIcon, array('function' => 'edit', 'modul_id' => '###id###'));
    $list->setColumnLabel('id', 'ID');
    $list->setColumnLayout('id', array('<th class="rex-small">###VALUE###</th>', '<td class="rex-small">###VALUE###</td>'));
    $list->setColumnLabel('name', $I18N->msg('module_description'));
    $list->setColumnParams('name', array('function' => 'edit', 'modul_id' => '###id###'));
    $list->addColumn($I18N->msg('module_functions'), $I18N->msg('delete_module'));
    $list->setColumnParams($I18N->msg('module_functions'), array('function' => 'delete', 'modul_id' => '###id###'));
        $warning = $I18N->msg('pool_selectedmedia_error');
    }
}
// *************************************** SUBPAGE: "" -> MEDIEN ANZEIGEN
if ($subpage == '') {
    $cats_sel = new rex_mediacategory_select();
    $cats_sel->setSize(1);
    $cats_sel->setStyle('class="rex-form-select"');
    $cats_sel->setName("rex_file_category");
    $cats_sel->setId("rex_file_category");
    $cats_sel->addOption($I18N->msg('pool_kats_no'), "0");
    $cats_sel->setSelected($rex_file_category);
    echo $cat_out;
    if (is_array($warning)) {
        if (count($warning) > 0) {
            echo rex_warning_block(implode('<br />', $warning));
        }
        $warning = '';
    } else {
        if ($warning != '') {
            echo rex_warning($warning);
            $warning = '';
        }
    }
    if (is_array($info)) {
        if (count($info) > 0) {
            echo rex_info_block(implode('<br />', $info));
        }
        $info = '';
    } else {
        if ($info != '') {
           ' . $REX['TABLE_PREFIX'] . 'module m
          ON
            ma.module_id = m.id
          WHERE
            ma.action_id = a.id AND
            ma.action_id=' . $action_id;
    $del->setQuery($qry);
    // module mit dieser aktion vorhanden ?
    if ($del->getRows() > 0) {
        $action_name = htmlspecialchars($del->getValue('a.name'));
        for ($i = 0; $i < $del->getRows(); $i++) {
            $action_in_use_msg .= '<li><a href="index.php?page=module&amp;function=edit&amp;modul_id=' . $del->getValue('ma.module_id') . '">' . htmlspecialchars($del->getValue('m.name')) . ' [' . $del->getValue('ma.module_id') . ']</a></li>';
            $del->next();
        }
        if ($action_in_use_msg != '') {
            $action_in_use_msg = rex_warning_block('<ul>' . $action_in_use_msg . '</ul>');
        }
        $message = $I18N->msg("action_cannot_be_deleted", $action_name);
    } else {
        $del->setQuery("DELETE FROM " . $REX['TABLE_PREFIX'] . "action WHERE id='{$action_id}' LIMIT 1");
        $message = $I18N->msg("action_deleted");
    }
}
if ($function == "add" or $function == "edit") {
    $name = rex_post('name', 'string');
    $previewaction = rex_post('previewaction', 'string');
    $presaveaction = rex_post('presaveaction', 'string');
    $postsaveaction = rex_post('postsaveaction', 'string');
    $previewstatus = 0;
    $presavestatus = 0;
    $postsavestatus = 0;
    if ($del->getRows() > 0) {
        $modulname = htmlspecialchars($del->getValue($REX['TABLE_PREFIX'] . "module.name"));
        for ($i = 0; $i < $del->getRows(); $i++) {
            $aid = $del->getValue($REX['TABLE_PREFIX'] . "article_slice.article_id");
            $clang_id = $del->getValue($REX['TABLE_PREFIX'] . "article_slice.clang");
            $ctype = $del->getValue($REX['TABLE_PREFIX'] . "article_slice.ctype");
            $OOArt = OOArticle::getArticleById($aid, $clang_id);
            $label = $OOArt->getName() . ' [' . $aid . ']';
            if (count($REX['CLANG']) > 1) {
                $label = '(' . rex_translate($REX['CLANG'][$clang_id]) . ') ' . $label;
            }
            $module_in_use_message .= '<li><a href="index.php?page=content&amp;article_id=' . $aid . '&clang=' . $clang_id . '&ctype=' . $ctype . '">' . htmlspecialchars($label) . '</a></li>';
            $del->next();
        }
        if ($module_in_use_message != '') {
            $module_in_use_message = rex_warning_block('<ul>' . $module_in_use_message . '</ul>');
        }
        $message = $I18N->msg("module_cannot_be_deleted", $modulname);
    } else {
        $del->setQuery("DELETE FROM " . $REX['TABLE_PREFIX'] . "module WHERE id='{$modul_id}'");
        $del->setQuery("DELETE FROM " . $REX['TABLE_PREFIX'] . "module_action WHERE module_id='{$modul_id}'");
        $message = $I18N->msg("module_deleted");
    }
}
if ($function == 'add' or $function == 'edit') {
    if (isset($save) and $save == 'ja') {
        $modultyp = new rex_sql();
        if ($function == 'add') {
            // $modultyp->setQuery("INSERT INTO ".$REX['TABLE_PREFIX']."modultyp (category_id, name, eingabe, ausgabe) VALUES ('$category_id', '$mname', '$eingabe', '$ausgabe')");
            $IMOD = new rex_sql();
            $IMOD->setTable($REX['TABLE_PREFIX'] . 'module');
/**
 * Ausgabe des Medienpool Formulars
 */
function rex_mediapool_Mediaform($form_title, $button_title, $rex_file_category, $file_chooser, $close_form)
{
    global $I18N, $REX, $subpage, $ftitle, $warning, $info;
    $s = '';
    $cats_sel = new rex_mediacategory_select();
    $cats_sel->setStyle('class="rex-form-select"');
    $cats_sel->setSize(1);
    $cats_sel->setName('rex_file_category');
    $cats_sel->setId('rex_file_category');
    $cats_sel->addOption($I18N->msg('pool_kats_no'), '0');
    $cats_sel->setAttribute('onchange', 'this.form.submit()');
    $cats_sel->setSelected($rex_file_category);
    if (isset($warning) and $warning != '') {
        $s .= rex_warning_block($warning);
        $warning = '';
    }
    if (is_array($info) && count($info) > 0) {
        $info = implode('<br />', $info);
    }
    if (is_string($info) && $info != '') {
        $s .= rex_info_block($info);
        $info = '';
    }
    if (!isset($ftitle)) {
        $ftitle = '';
    }
    $add_file = '';
    if ($file_chooser) {
        $devInfos = '';
        if ($REX['USER']->hasPerm('advancedMode[]')) {
            $devInfos = '<span class="rex-form-notice">
                 ' . $I18N->msg('phpini_settings') . ':<br />
                 ' . (rex_ini_get('file_uploads') == 0 ? '<span>' . $I18N->msg('pool_upload') . ':</span> <em>' . $I18N->msg('pool_upload_disabled') . '</em><br />' : '') . '
                 <span>' . $I18N->msg('pool_max_uploadsize') . ':</span> ' . OOMedia::_getFormattedSize(rex_ini_get('upload_max_filesize')) . '<br />
                 <span>' . $I18N->msg('pool_max_uploadtime') . ':</span> ' . rex_ini_get('max_input_time') . 's
             </span>';
        }
        $add_file = '
                                <div class="rex-form-row">
                                    <p class="rex-form-file">
                                        <label for="file_new">' . $I18N->msg('pool_file_file') . '</label>
                                        <input class="rex-form-file" type="file" id="file_new" name="file_new" size="30" />
                                        ' . $devInfos . '
                                    </p>
                                </div>';
    }
    $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 = '<input type="submit" class="rex-form-submit" name="saveandexit" value="' . $I18N->msg('pool_file_upload_get') . '"' . rex_accesskey($I18N->msg('pool_file_upload_get'), $REX['ACKEY']['SAVE']) . ' />';
    }
    $s .= '
            <div class="rex-form" id="rex-form-mediapool-other">
                <form action="index.php" method="post" enctype="multipart/form-data">
                    <fieldset class="rex-form-col-1">
                        <legend>' . $form_title . '</legend>
                        <div class="rex-form-wrapper">
                            <input type="hidden" name="page" value="mediapool" />
                            <input type="hidden" name="media_method" value="add_file" />
                            <input type="hidden" name="subpage" value="' . $subpage . '" />
                            ' . $arg_fields . '

                            <div class="rex-form-row">
                                <p class="rex-form-text">
                                    <label for="ftitle">' . $I18N->msg('pool_file_title') . '</label>
                                    <input class="rex-form-text" type="text" size="20" id="ftitle" name="ftitle" value="' . htmlspecialchars(stripslashes($ftitle)) . '" />
                                </p>
                            </div>

                            <div class="rex-form-row">
                                <p class="rex-form-select">
                                    <label for="rex_file_category">' . $I18N->msg('pool_file_category') . '</label>
                                    ' . $cats_sel->get() . '
                                </p>
                            </div>

                            <div class="rex-clearer"></div>';
    // ----- EXTENSION POINT
    $s .= rex_register_extension_point('MEDIA_FORM_ADD', '');
    $s .= $add_file . '
                            <div class="rex-form-row">
                                <p class="rex-form-submit">
                                 <input class="rex-form-submit" type="submit" name="save" value="' . $button_title . '"' . rex_accesskey($button_title, $REX['ACKEY']['SAVE']) . ' />
                                 ' . $add_submit . '
                                </p>
                            </div>

                            <div class="rex-clearer"></div>
                        </div>
                    </fieldset>
                ';
    if ($close_form) {
        $s .= '</form></div>' . "\n";
    }
    return $s;
}