Пример #1
0
 public static function getFieldParams()
 {
     $options = array_map(function (rex_clang $clang) {
         return $clang->getName();
     }, rex_clang::getAll());
     return ['label' => rex_i18n::msg('clangs'), 'all_label' => rex_i18n::msg('all_clangs'), 'options' => $options];
 }
Пример #2
0
    ';
// Add form
if ($func == 'addclang') {
    //ggf wiederanzeige des add forms, falls ungueltige id uebermittelt
    $content .= '
                <tr class="mark">
                    <td class="rex-table-icon"><i class="rex-icon rex-icon-language"></i></td>
                    <td class="rex-table-id" data-title="' . rex_i18n::msg('id') . '">–</td>
                    <td data-title="' . rex_i18n::msg('clang_code') . '"><input class="form-control" type="text" id="rex-form-clang-code" name="clang_code" value="' . htmlspecialchars($clang_code) . '" autofocus /></td>
                    <td data-title="' . rex_i18n::msg('clang_name') . '"><input class="form-control" type="text" id="rex-form-clang-name" name="clang_name" value="' . htmlspecialchars($clang_name) . '" /></td>
                    <td class="rex-table-priority" data-title="' . rex_i18n::msg('clang_priority') . '"><input class="form-control" type="text" id="rex-form-clang-prio" name="clang_prio" value="' . ($clang_prio ?: rex_clang::count() + 1) . '" /></td>
                    <td class="rex-table-action" colspan="2"><button class="btn btn-save" type="submit" name="add_clang_save"' . rex::getAccesskey(rex_i18n::msg('clang_add'), 'save') . ' value="1">' . rex_i18n::msg('clang_add') . '</button></td>
                </tr>
            ';
}
foreach (rex_clang::getAll() as $lang_id => $lang) {
    $add_td = '<td class="rex-table-id" data-title="' . rex_i18n::msg('id') . '">' . $lang_id . '</td>';
    $delLink = rex_i18n::msg('delete');
    if ($lang_id == rex_clang::getStartId()) {
        $delLink = '<span class="text-muted"><i class="rex-icon rex-icon-delete"></i> ' . $delLink . '</span>';
    } else {
        $delLink = '<a href="' . rex_url::currentBackendPage(['func' => 'deleteclang', 'clang_id' => $lang_id]) . '" data-confirm="' . rex_i18n::msg('delete') . ' ?"><i class="rex-icon rex-icon-delete"></i> ' . $delLink . '</a>';
    }
    // Edit form
    if ($func == 'editclang' && $clang_id == $lang_id) {
        $content .= '
                    <tr class="mark">
                        <td class="rex-table-icon"><i class="rex-icon rex-icon-language"></i></td>
                        ' . $add_td . '
                        <td data-title="' . rex_i18n::msg('clang_code') . '"><input class="form-control" type="text" id="rex-form-clang-code" name="clang_code" value="' . htmlspecialchars($lang->getCode()) . '" autofocus /></td>
                        <td data-title="' . rex_i18n::msg('clang_name') . '"><input class="form-control" type="text" id="rex-form-clang-name" name="clang_name" value="' . htmlspecialchars($lang->getName()) . '" /></td>
Пример #3
0
 /**
  * Returns a clang switch.
  *
  * @param rex_context $context
  *
  * @return string
  */
 public static function clangSwitchAsDropdown(rex_context $context)
 {
     if (rex_clang::count() == 1) {
         return '';
     }
     $button_label = '';
     $items = [];
     foreach (rex_clang::getAll() as $id => $clang) {
         if (rex::getUser()->getComplexPerm('clang')->hasPerm($id)) {
             $item = [];
             $item['title'] = rex_i18n::translate($clang->getName());
             $item['href'] = $context->getUrl(['clang' => $id]);
             if ($id == $context->getParam('clang')) {
                 $item['active'] = true;
                 $button_label = rex_i18n::translate($clang->getName());
             }
             $items[] = $item;
         }
     }
     $fragment = new rex_fragment();
     $fragment->setVar('class', 'rex-language');
     $fragment->setVar('button_prefix', rex_i18n::msg('language'));
     $fragment->setVar('button_label', $button_label);
     $fragment->setVar('header', rex_i18n::msg('clang_select'));
     $fragment->setVar('items', $items, false);
     if (rex::getUser()->isAdmin()) {
         $fragment->setVar('footer', '<a href="' . rex_url::backendPage('system/lang') . '"><i class="fa fa-flag"></i> ' . rex_i18n::msg('languages_edit') . '</a>', false);
     }
     return $fragment->parse('core/dropdowns/dropdown.php');
 }
Пример #4
0
if (!rex::isBackend()) {
    \rex_extension::register('OUTPUT_FILTER', '\\Sprog\\Extension::replaceWildcards');
}
if (rex::isBackend() && rex::getUser()) {
    \rex_extension::register('CLANG_ADDED', '\\Sprog\\Extension::clangAdded');
    \rex_extension::register('CLANG_DELETED', '\\Sprog\\Extension::clangDeleted');
    rex_extension::register('PAGES_PREPARED', function () {
        if (rex::getUser()->isAdmin()) {
            if (\rex_be_controller::getCurrentPage() == 'sprog/settings') {
                $func = rex_request('func', 'string');
                if ($func == 'update') {
                    \rex_config::set('sprog', 'wildcard_clang_switch', rex_request('clang_switch', 'bool'));
                }
            }
        }
        if (rex::getUser()->isAdmin() || rex::getUser()->hasPerm('sprog[wildcard]')) {
            $page = \rex_be_controller::getPageObject('sprog/wildcard');
            if (Wildcard::isClangSwitchMode()) {
                $clang_id = str_replace('clang', '', rex_be_controller::getCurrentPagePart(3));
                $page->setSubPath(rex_path::addon('sprog', 'pages/wildcard.clang_switch.php'));
                foreach (\rex_clang::getAll() as $id => $clang) {
                    if (rex::getUser()->getComplexPerm('clang')->hasPerm($id)) {
                        $page->addSubpage((new rex_be_page('clang' . $id, $clang->getName()))->setSubPath(rex_path::addon('sprog', 'pages/wildcard.clang_switch.php'))->setIsActive($id == $clang_id));
                    }
                }
            } else {
                $page->setSubPath(rex_path::addon('sprog', 'pages/wildcard.clang_all.php'));
            }
        }
    });
}