parse() public method

Parses the variables of the fragment into the file $filename.
public parse ( string $filename, boolean $delete_whitespaces = true ) : string
$filename string the filename of the fragment to parse
$delete_whitespaces boolean
return string
Ejemplo n.º 1
0
 public static function getWidget($id, $name, $value, array $args = [])
 {
     $art_name = '';
     $art = rex_article::get($value);
     $category = 0;
     // Falls ein Artikel vorausgewählt ist, dessen Namen anzeigen und beim öffnen der Linkmap dessen Kategorie anzeigen
     if ($art instanceof rex_article) {
         $art_name = $art->getName();
         $category = $art->getCategoryId();
     }
     $open_params = '&clang=' . rex_clang::getCurrentId();
     if ($category || isset($args['category']) && ($category = (int) $args['category'])) {
         $open_params .= '&category_id=' . $category;
     }
     $class = ' rex-disabled';
     $open_func = '';
     $delete_func = '';
     if (rex::getUser()->getComplexPerm('structure')->hasStructurePerm()) {
         $class = '';
         $open_func = 'openLinkMap(\'REX_LINK_' . $id . '\', \'' . $open_params . '\');';
         $delete_func = 'deleteREXLink(' . $id . ');';
     }
     $e = [];
     $e['field'] = '<input class="form-control" type="text" name="REX_LINK_NAME[' . $id . ']" value="' . htmlspecialchars($art_name) . '" id="REX_LINK_' . $id . '_NAME" readonly="readonly" /><input type="hidden" name="' . $name . '" id="REX_LINK_' . $id . '" value="' . $value . '" />';
     $e['functionButtons'] = '
                     <a href="#" class="btn btn-popup' . $class . '" onclick="' . $open_func . 'return false;" title="' . rex_i18n::msg('var_link_open') . '"><i class="rex-icon rex-icon-open-linkmap"></i></a>
                     <a href="#" class="btn btn-popup' . $class . '" onclick="' . $delete_func . 'return false;" title="' . rex_i18n::msg('var_link_delete') . '"><i class="rex-icon rex-icon-delete-link"></i></a>';
     $fragment = new rex_fragment();
     $fragment->setVar('elements', [$e], false);
     $media = $fragment->parse('core/form/widget.php');
     return $media;
 }
Ejemplo n.º 2
0
 /**
  * Parses the variables of the fragment into the file $filename.
  *
  * @param string $filename           the filename of the fragment to parse
  * @param bool   $delete_whitespaces
  *
  * @throws InvalidArgumentException
  * @throws rex_exception
  *
  * @return string
  */
 public function parse($filename, $delete_whitespaces = true)
 {
     if (!is_string($filename)) {
         throw new InvalidArgumentException(sprintf('Expecting $filename to be a string, %s given!', gettype($filename)));
     }
     $this->filename = $filename;
     foreach (self::$fragmentDirs as $fragDir) {
         $fragment = $fragDir . $filename;
         if (is_readable($fragment)) {
             ob_start();
             if ($delete_whitespaces) {
                 preg_replace('/(?:(?<=\\>)|(?<=\\/\\>))(\\s+)(?=\\<\\/?)/', '', require $fragment);
             } else {
                 require $fragment;
             }
             $content = ob_get_clean();
             if ($this->decorator) {
                 $this->decorator->setVar('rexDecoratedContent', $content, false);
                 $content = $this->decorator->parse($this->decorator->filename);
             }
             return $content;
         }
     }
     throw new rex_exception(sprintf('Fragmentfile "%s" not found!', $filename));
 }
Ejemplo n.º 3
0
 public function formatElement()
 {
     $s = '';
     $values = explode('|', trim($this->getValue(), '|'));
     $options = $this->getOptions();
     $name = $this->getAttribute('name');
     $id = $this->getAttribute('id');
     $attr = '';
     foreach ($this->getAttributes() as $attributeName => $attributeValue) {
         if ($attributeName == 'name' || $attributeName == 'id') {
             continue;
         }
         $attr .= ' ' . htmlspecialchars($attributeName) . '="' . htmlspecialchars($attributeValue) . '"';
     }
     $formElements = [];
     foreach ($options as $opt_name => $opt_value) {
         $opt_id = $id;
         if ($opt_value != '') {
             $opt_id .= '-' . rex_string::normalize($opt_value, '-');
         }
         $opt_attr = $attr . ' id="' . htmlspecialchars($opt_id) . '"';
         $checked = in_array($opt_value, $values) ? ' checked="checked"' : '';
         $n = [];
         $n['label'] = '<label class="control-label" for="' . htmlspecialchars($opt_id) . '">' . htmlspecialchars($opt_name) . '</label>';
         $n['field'] = '<input type="checkbox" name="' . htmlspecialchars($name) . '[' . htmlspecialchars($opt_value) . ']" value="' . htmlspecialchars($opt_value) . '"' . $opt_attr . $checked . ' />';
         $formElements[] = $n;
     }
     $fragment = new rex_fragment();
     $fragment->setVar('elements', $formElements, false);
     $fragment->setVar('grouped', true);
     $s = $fragment->parse('core/form/checkbox.php');
     return $s;
 }
Ejemplo n.º 4
0
 public function formatElement()
 {
     $s = '';
     $value = $this->getValue();
     $options = $this->getOptions();
     $id = $this->getAttribute('id');
     $attr = '';
     foreach ($this->getAttributes() as $attributeName => $attributeValue) {
         if ($attributeName == 'id') {
             continue;
         }
         $attr .= ' ' . htmlspecialchars($attributeName) . '="' . htmlspecialchars($attributeValue) . '"';
     }
     $formElements = [];
     foreach ($options as $opt_name => $opt_value) {
         $checked = $opt_value == $value ? ' checked="checked"' : '';
         $opt_id = $id . '-' . rex_string::normalize($opt_value, '-');
         $opt_attr = $attr . ' id="' . $opt_id . '"';
         $n = [];
         $n['label'] = '<label class="control-label" for="' . $opt_id . '">' . htmlspecialchars($opt_name) . '</label>';
         $n['field'] = '<input type="radio" value="' . htmlspecialchars($opt_value) . '"' . $opt_attr . $checked . ' />';
         $formElements[] = $n;
     }
     $fragment = new rex_fragment();
     $fragment->setVar('elements', $formElements, false);
     $s = $fragment->parse('core/form/radio.php');
     return $s;
 }
Ejemplo n.º 5
0
    public function formatElement()
    {
        $name = $this->getAttribute('name') . '[]';
        $value = explode('|', htmlspecialchars($this->getValue()));
        if (count($value) != 4) {
            $value = [null, 1, 'd'];
        }
        $options = ['i' => rex_i18n::msg('cronjob_interval_minutes'), 'h' => rex_i18n::msg('cronjob_interval_hour'), 'd' => rex_i18n::msg('cronjob_interval_day'), 'w' => rex_i18n::msg('cronjob_interval_week'), 'm' => rex_i18n::msg('cronjob_interval_month'), 'y' => rex_i18n::msg('cronjob_interval_year')];
        $items = [];
        $buttonLabel = '';
        foreach ($options as $optionValue => $optionTitle) {
            $item = [];
            $item['title'] = $optionTitle;
            $item['href'] = '#';
            $item['attributes'] = 'data-value="' . $optionValue . '"';
            if ($optionValue == $value[2]) {
                $buttonLabel = $optionTitle;
            }
            $items[] = $item;
        }
        $toolbar = '';
        $fragment = new rex_fragment();
        $fragment->setVar('button_label', $buttonLabel);
        $fragment->setVar('items', $items, false);
        $fragment->setVar('group', true);
        $fragment->setVar('right', true);
        $dropdown = $fragment->parse('core/dropdowns/dropdown.php');
        $formElements = [];
        $n = [];
        $n['field'] = '<input class="form-control" type="text" name="' . $name . '" value="' . $value[1] . '" />';
        $n['right'] = $dropdown;
        $formElements[] = $n;
        $fragment = new rex_fragment();
        $fragment->setVar('elements', $formElements, false);
        $field = '<div class="rex-js-cronjob-interval">' . $fragment->parse('core/form/input_group.php') . '<input class="rex-js-cronjob-interval-value" type="hidden" name="' . $name . '" value="' . $value[2] . '" /></div>';
        $javascript = '
        <script type="text/javascript">
        // <![CDATA[
            jQuery(function($){
                $(".rex-js-cronjob-interval .dropdown-menu li a").click(function(event){
                    event.preventDefault();
                    var $title = $(this).text();
                    $(this).closest(".input-group-btn").find(".btn > b").html($title);

                    var $value = $(this).closest("li").attr("data-value");
                    $(".rex-js-cronjob-interval-value").val($value);
                });
            });
        // ]]>
        </script>';
        return $field . $javascript;
    }
Ejemplo n.º 6
0
 public static function showHelpOverview()
 {
     $formats = self::getHelpOverviewFormats();
     $echo = '';
     $echo .= '
         <div class="textile-help-overview">
             <h4>' . rex_i18n::msg('textile_instructions') . '</h4>';
     foreach ($formats as $format) {
         $title = $format[0];
         $content = '';
         $content .= '
             <table class="table">
                 <thead>
                     <tr>
                         <th>' . rex_i18n::msg('textile_input') . '</th>
                         <th>' . rex_i18n::msg('textile_preview') . '</th>
                     </tr>
                 </thead>
                 <tbody>
                      ';
         foreach ($format[1] as $perm => $formats) {
             foreach ($formats as $_format) {
                 $desc = $_format[0];
                 $code = '';
                 if (isset($_format[1])) {
                     $code = $_format[1];
                 }
                 if ($code == '') {
                     $code = $desc;
                 }
                 $code = trim(self::parse($code));
                 $content .= '<tr>
                         <td>' . nl2br(htmlspecialchars($desc)) . '</td>
                         <td>' . $code . '</td>
                     </tr>';
             }
         }
         $content .= '</tbody></table>';
         $fragment = new rex_fragment();
         $fragment->setVar('title', '<i class="rex-icon rex-icon-package-addon"></i> ' . $title, false);
         $fragment->setVar('content', $content, false);
         $fragment->setVar('collapse', true);
         $fragment->setVar('collapsed', true);
         $echo .= $fragment->parse('core/page/section.php');
     }
     $echo .= '</div>';
     echo $echo;
 }
Ejemplo n.º 7
0
 public static function extendBackendSlices(rex_extension_point $ep)
 {
     $Config = rex_config::get('slice_ui');
     $article_id = rex_get('article_id');
     $clang = rex_get('clang');
     $ctype = rex_get('ctype');
     $content = '';
     $Subject = $ep->getSubject();
     if (rex::isBackend() && !empty($Config['online_from_to']) && (in_array($ep->getParam('module_id'), $Config['online_from_to']) || in_array('all', $Config['online_from_to']))) {
         $sql = rex_sql::factory();
         $sql->setTable(rex::getTablePrefix() . 'article_slice');
         $sql->setWhere(array('id' => $ep->getParam('slice_id')));
         $sql->select();
         $online_from = $sql->getValue('online_from');
         $online_to = $sql->getValue('online_to');
         $fragment = new rex_fragment();
         $fragment->setVar('online_from', $online_from ? date('d.m.Y', $online_from) : null, false);
         $fragment->setVar('online_to', $online_to ? date('d.m.Y', $online_to) : null, false);
         $content = $fragment->parse('status/status.php');
     }
     $strContent = rex_extension::registerPoint(new rex_extension_point('EXTEND_SLICE_FORMS', '', ['slice_id' => $ep->getParam('slice_id'), 'article_id' => $ep->getParam('article_id'), 'clang' => $ep->getParam('clang'), 'ctype' => $ep->getParam('ctype'), 'content' => $Subject]));
     if ($strContent) {
         $content .= $strContent;
     }
     if ($content) {
         $fragment = new rex_fragment();
         $fragment->setVar('action', 'index.php?page=content/status&article_id=' . $article_id . '&clang=' . $clang . '&ctype=' . $clang, false);
         $fragment->setVar('slice_id', $ep->getParam('slice_id'), false);
         $fragment->setVar('body', $content, false);
         $content = $fragment->parse('status/slice_form.php');
     }
     $strContent = rex_extension::registerPoint(new rex_extension_point('ADD_AFTER_SLICE_FORMS', '', ['slice_id' => $ep->getParam('slice_id'), 'article_id' => $ep->getParam('article_id'), 'clang' => $ep->getParam('clang'), 'ctype' => $ep->getParam('ctype'), 'content' => $Subject]));
     if ($strContent) {
         $content .= $strContent;
     }
     $Subject = str_replace('<div class="panel-body">', $content . '<div class="panel-body">', $Subject);
     $strContent = rex_extension::registerPoint(new rex_extension_point('ADD_AFTER_SLICE', '', ['slice_id' => $ep->getParam('slice_id'), 'article_id' => $ep->getParam('article_id'), 'clang' => $ep->getParam('clang'), 'ctype' => $ep->getParam('ctype'), 'content' => $Subject]));
     if ($strContent) {
         $fragment = new rex_fragment();
         $fragment->setVar('body', $strContent, false);
         $strContent = $fragment->parse('panel/footer.php');
         $Subject = preg_replace('|(<\\/div>)([^<]*<\\/div>[^<]*<\\/section>[^<]*<\\/li>$)|is', '$1' . $strContent . '$2', $Subject);
     }
     return $Subject;
 }
Ejemplo n.º 8
0
 public static function getForm($field, $label, $output)
 {
     $fragment = new rex_fragment();
     $fragment->setVar('label', $label, false);
     $fragment->setVar('field', $field, false);
     $output = explode(':', $output);
     if ($output[0] == 'form') {
         $labelClass = 'col-md-2';
         $fieldClass = $label == '' ? 'col-md-12' : 'col-md-10';
         if (count($output) == 3) {
             $labelClass = is_numeric($output[1]) ? 'col-md-' . $output[1] : $output[1];
             $fieldClass = is_numeric($output[2]) ? 'col-md-' . $output[2] : $output[2];
         }
         $fragment->setVar('labelClass', $labelClass, false);
         $fragment->setVar('fieldClass', $fieldClass, false);
     }
     return $fragment->parse('dao/form.php');
 }
Ejemplo n.º 9
0
 public static function getWidget($id, $name, $value, array $args = [])
 {
     $open_params = '&clang=' . rex_clang::getCurrentId();
     if (isset($args['category']) && ($category = (int) $args['category'])) {
         $open_params .= '&amp;category_id=' . $category;
     }
     $options = '';
     $linklistarray = explode(',', $value);
     if (is_array($linklistarray)) {
         foreach ($linklistarray as $link) {
             if ($link != '') {
                 if ($article = rex_article::get($link)) {
                     $options .= '<option value="' . $link . '">' . htmlspecialchars($article->getName()) . '</option>';
                 }
             }
         }
     }
     $disabled = ' disabled';
     $open_func = '';
     $delete_func = '';
     if (rex::getUser()->getComplexPerm('structure')->hasStructurePerm()) {
         $disabled = '';
         $open_func = 'openREXLinklist(' . $id . ', \'' . $open_params . '\');';
         $delete_func = 'deleteREXLinklist(' . $id . ');';
     }
     $e = [];
     $e['field'] = '
             <select class="form-control" name="REX_LINKLIST_SELECT[' . $id . ']" id="REX_LINKLIST_SELECT_' . $id . '" size="10">
                 ' . $options . '
             </select>
             <input type="hidden" name="' . $name . '" id="REX_LINKLIST_' . $id . '" value="' . $value . '" />';
     $e['moveButtons'] = '
                 <a href="#" class="btn btn-popup" onclick="moveREXLinklist(' . $id . ',\'top\');return false;" title="' . rex_i18n::msg('var_linklist_move_top') . '"><i class="rex-icon rex-icon-top"></i></a>
                 <a href="#" class="btn btn-popup" onclick="moveREXLinklist(' . $id . ',\'up\');return false;" title="' . rex_i18n::msg('var_linklist_move_up') . '"><i class="rex-icon rex-icon-up"></i></a>
                 <a href="#" class="btn btn-popup" onclick="moveREXLinklist(' . $id . ',\'down\');return false;" title="' . rex_i18n::msg('var_linklist_move_down') . '"><i class="rex-icon rex-icon-down"></i></a>
                 <a href="#" class="btn btn-popup" onclick="moveREXLinklist(' . $id . ',\'bottom\');return false;" title="' . rex_i18n::msg('var_linklist_move_bottom') . '"><i class="rex-icon rex-icon-bottom"></i></a>';
     $e['functionButtons'] = '
                 <a href="#" class="btn btn-popup" onclick="' . $open_func . 'return false;" title="' . rex_i18n::msg('var_link_open') . '"' . $disabled . '><i class="rex-icon rex-icon-open-linkmap"></i></a>
                 <a href="#" class="btn btn-popup" onclick="' . $delete_func . 'return false;" title="' . rex_i18n::msg('var_link_delete') . '"' . $disabled . '><i class="rex-icon rex-icon-delete-link"></i></a>';
     $fragment = new rex_fragment();
     $fragment->setVar('elements', [$e], false);
     $link = $fragment->parse('core/form/widget_list.php');
     return $link;
 }
Ejemplo n.º 10
0
 public static function getWidget($id, $name, $value, array $args = [])
 {
     $open_params = '';
     if (isset($args['category']) && ($category = (int) $args['category'])) {
         $open_params .= '&amp;rex_file_category=' . $category;
     }
     foreach ($args as $aname => $avalue) {
         $open_params .= '&amp;args[' . urlencode($aname) . ']=' . urlencode($avalue);
     }
     $wdgtClass = ' rex-js-widget-media';
     if (isset($args['preview']) && $args['preview']) {
         $wdgtClass .= ' rex-js-widget-preview';
         if (rex_addon::get('media_manager')->isAvailable()) {
             $wdgtClass .= ' rex-js-widget-preview-media-manager';
         }
     }
     $disabled = ' disabled';
     $open_func = '';
     $add_func = '';
     $delete_func = '';
     $view_func = '';
     if (rex::getUser()->getComplexPerm('media')->hasMediaPerm()) {
         $disabled = '';
         $open_func = 'openREXMedia(' . $id . ',\'' . $open_params . '\');';
         $add_func = 'addREXMedia(' . $id . ',\'' . $open_params . '\');';
         $delete_func = 'deleteREXMedia(' . $id . ');';
         $view_func = 'viewREXMedia(' . $id . ',\'' . $open_params . '\');';
     }
     $e = [];
     $e['before'] = '<div class="rex-js-widget' . $wdgtClass . '">';
     $e['field'] = '<input class="form-control" type="text" name="' . $name . '" value="' . $value . '" id="REX_MEDIA_' . $id . '" readonly />';
     $e['functionButtons'] = '
             <a href="#" class="btn btn-popup" onclick="' . $open_func . 'return false;" title="' . rex_i18n::msg('var_media_open') . '"' . $disabled . '><i class="rex-icon rex-icon-open-mediapool"></i></a>
             <a href="#" class="btn btn-popup" onclick="' . $add_func . 'return false;" title="' . rex_i18n::msg('var_media_new') . '"' . $disabled . '><i class="rex-icon rex-icon-add-media"></i></a>
             <a href="#" class="btn btn-popup" onclick="' . $delete_func . 'return false;" title="' . rex_i18n::msg('var_media_remove') . '"' . $disabled . '><i class="rex-icon rex-icon-delete-media"></i></a>
             <a href="#" class="btn btn-popup" onclick="' . $view_func . 'return false;" title="' . rex_i18n::msg('var_media_view') . '"' . $disabled . '><i class="rex-icon rex-icon-view-media"></i></a>';
     $e['after'] = '<div class="rex-js-media-preview"></div></div>';
     $fragment = new rex_fragment();
     $fragment->setVar('elements', [$e], false);
     $media = $fragment->parse('core/form/widget.php');
     return $media;
 }
Ejemplo n.º 11
0
function rex_metainfo_content_sidebar($extionPointParams)
{
    $params = $extionPointParams->getParams();
    $article = rex_article::get($params['article_id'], $params['clang']);
    $articleStatusTypes = rex_article_service::statusTypes();
    $panel = '';
    $panel .= '<dl class="dl-horizontal">';
    $panel .= '<dt>' . rex_i18n::msg('created_by') . '</dt>';
    $panel .= '<dd>' . $article->getValue('createuser') . '</dd>';
    $panel .= '<dt>' . rex_i18n::msg('created_on') . '</dt>';
    $panel .= '<dd>' . rex_formatter::strftime($article->getValue('createdate'), 'date') . '</dd>';
    $panel .= '<dt>' . rex_i18n::msg('updated_by') . '</dt>';
    $panel .= '<dd>' . $article->getValue('updateuser') . '</dd>';
    $panel .= '<dt>' . rex_i18n::msg('updated_on') . '</dt>';
    $panel .= '<dd>' . rex_formatter::strftime($article->getValue('updatedate'), 'date') . '</dd>';
    $panel .= '<dt>' . rex_i18n::msg('status') . '</dt>';
    $panel .= '<dd class="' . $articleStatusTypes[$article->getValue('status')][1] . '">' . $articleStatusTypes[$article->getValue('status')][0] . '</dd>';
    $panel .= '</dl>';
    $fragment = new rex_fragment();
    $fragment->setVar('title', rex_i18n::msg('metadata'), false);
    $fragment->setVar('body', $panel, false);
    $content = $fragment->parse('core/page/section.php');
    return $content;
}
Ejemplo n.º 12
0
$fragment = new rex_fragment();
$fragment->setVar('elements', $formElements, false);
$content .= $fragment->parse('core/form/checkbox.php');
$content .= '</fieldset>';
$formElements = [];
$n = [];
$n['field'] = '<button class="btn btn-primary" type="submit"><i class="rex-icon rex-icon-sign-in"></i> ' . rex_i18n::msg('login') . ' </button>';
$formElements[] = $n;
$fragment = new rex_fragment();
$fragment->setVar('elements', $formElements, false);
$buttons = $fragment->parse('core/form/submit.php');
$fragment = new rex_fragment();
$fragment->setVar('title', rex_i18n::msg('login_welcome'), false);
$fragment->setVar('body', $content, false);
$fragment->setVar('buttons', $buttons, false);
$content = $fragment->parse('core/page/section.php');
$content = '
<form id="rex-form-login" action="' . rex_url::backendController() . '" method="post">
    ' . $content . '
</form>
<script type="text/javascript">
     <!--
    jQuery(function($) {
        $("#rex-form-login")
            .submit(function(){
                var pwInp = $("#rex-id-login-password");
                if(pwInp.val() != "") {
                    $("#rex-form-login").append(\'<input type="hidden" name="\'+pwInp.attr("name")+\'" value="\'+Sha1.hash(pwInp.val())+\'" />\');
                    pwInp.removeAttr("name");
                }
        });
Ejemplo n.º 13
0
                $select .= '<option value="' . $version['history_date'] . '">' . $version['history_date'] . '</option>';
            }
            $content1select = '<select id="content-history-select-date-1" class="content-history-select" data-iframe="content-history-iframe-1" style="">' . $select . '</select>';
            $content1iframe = '<iframe id="content-history-iframe-1" class="history-iframe"></iframe>';
            $content2select = '<select id="content-history-select-date-2" class="content-history-select" data-iframe="content-history-iframe-2">' . $select . '</select>';
            $content2iframe = '<iframe id="content-history-iframe-2" class="history-iframe"></iframe>';
            $button_restore = '<a class="btn btn-apply" href="javascript:rex_history_snapVersion(\'content-history-select-date-2\');">' . $this->i18n('snapshot_reactivate') . '</a>';
            // fragment holen und ausgeben
            $fragment = new rex_fragment();
            $fragment->setVar('title', $this->i18n('overview_versions'));
            $fragment->setVar('info', $info, false);
            $fragment->setVar('content1select', $content1select, false);
            $fragment->setVar('content1iframe', $content1iframe, false);
            $fragment->setVar('content2select', $content2select, false);
            $fragment->setVar('content2iframe', $content2iframe, false);
            $fragment->setVar('button_restore', $button_restore, false);
            echo $fragment->parse('history/layer.php');
            exit;
    }
    rex_extension::register('STRUCTURE_CONTENT_HEADER', function (rex_extension_point $ep) {
        if ($ep->getParam('page') == 'content/edit') {
            echo '<script>
                    var history_article_id = ' . rex_article::getCurrentId() . ';
                    var history_clang_id = ' . rex_clang::getCurrentId() . ';
                    var history_ctype_id = ' . rex_request('ctype', 'int', 0) . ';
                    var history_revision = ' . rex_request('rex_set_version', 'int', 0) . ';
                    var history_article_link = "' . rex_getUrl(rex_article::getCurrentId(), rex_clang::getCurrentId(), ['history_revision' => rex_request('rex_set_version', 'int', 0)], '&') . '";
                    </script>';
        }
    });
}
Ejemplo n.º 14
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');
 }
Ejemplo n.º 15
0
        // ------------------------------------------ END: CONTENT HEAD MENUE
        // ------------------------------------------ WARNING
        if ($global_warning != '') {
            $contentMain .= rex_view::warning($global_warning);
        }
        if ($global_info != '') {
            $contentMain .= rex_view::success($global_info);
        }
        // --------------------------------------------- API MESSAGES
        $contentMain .= rex_api_function::getMessage();
        if ($warning != '') {
            $contentMain .= rex_view::warning($warning);
        }
        if ($info != '') {
            $contentMain .= rex_view::success($info);
        }
        // ----- EXTENSION POINT
        $contentMain .= rex_extension::registerPoint(new rex_extension_point('STRUCTURE_CONTENT_BEFORE_SLICES', '', ['article_id' => $article_id, 'clang' => $clang, 'function' => $function, 'slice_id' => $slice_id, 'page' => rex_be_controller::getCurrentPage(), 'ctype' => $ctype, 'category_id' => $category_id, 'article_revision' => &$article_revision, 'slice_revision' => &$slice_revision]));
        // ------------------------------------------ START: MODULE EDITIEREN/ADDEN ETC.
        $contentMain .= (include rex_be_controller::getCurrentPageObject()->getSubPath());
        // ------------------------------------------ END: AUSGABE
        // ----- EXTENSION POINT
        $contentMain .= rex_extension::registerPoint(new rex_extension_point('STRUCTURE_CONTENT_AFTER_SLICES', '', ['article_id' => $article_id, 'clang' => $clang, 'function' => $function, 'slice_id' => $slice_id, 'page' => rex_be_controller::getCurrentPage(), 'ctype' => $ctype, 'category_id' => $category_id, 'article_revision' => &$article_revision, 'slice_revision' => &$slice_revision]));
        // ----- EXTENSION POINT
        $contentSidebar = rex_extension::registerPoint(new rex_extension_point('STRUCTURE_CONTENT_SIDEBAR', '', ['article_id' => $article_id, 'clang' => $clang, 'function' => $function, 'slice_id' => $slice_id, 'page' => rex_be_controller::getCurrentPage(), 'ctype' => $ctype, 'category_id' => $category_id, 'article_revision' => &$article_revision, 'slice_revision' => &$slice_revision]));
        $fragment = new rex_fragment();
        $fragment->setVar('content', $contentMain, false);
        $fragment->setVar('sidebar', $contentSidebar, false);
        echo $fragment->parse('core/page/main_content.php');
    }
}
Ejemplo n.º 16
0
    protected function editSlice($RE_CONTS, $RE_MODUL_IN, $RE_CTYPE, $RE_MODUL_ID, $artDataSql)
    {
        $formElements = [];
        $n = [];
        $n['field'] = '<a class="btn btn-abort" href="' . rex_url::currentBackendPage(['article_id' => $this->article_id, 'slice_id' => $RE_CONTS, 'ctype' => $RE_CTYPE, 'clang' => $this->clang]) . '#slice' . $RE_CONTS . '">' . rex_i18n::msg('form_abort') . '</a>';
        $formElements[] = $n;
        $n = [];
        $n['field'] = '<button class="btn btn-save" type="submit" name="btn_save" value="1"' . rex::getAccesskey(rex_i18n::msg('save_block'), 'save') . '>' . rex_i18n::msg('save_block') . '</button>';
        $formElements[] = $n;
        $n = [];
        $n['field'] = '<button class="btn btn-apply" type="submit" name="btn_update" value="1"' . rex::getAccesskey(rex_i18n::msg('update_block'), 'apply') . '>' . rex_i18n::msg('update_block') . '</button>';
        $formElements[] = $n;
        $fragment = new rex_fragment();
        $fragment->setVar('elements', $formElements, false);
        $slice_footer = $fragment->parse('core/form/submit.php');
        $panel = '
                <fieldset>
                    <legend>' . rex_i18n::msg('edit_block') . '</legend>
                    <input type="hidden" name="module_id" value="' . $RE_MODUL_ID . '" />
                    <input type="hidden" name="function" value="edit" />
                    <input type="hidden" name="save" value="1" />
                    <input type="hidden" name="update" value="0" />

                    <div class="rex-slice-input">
                        ' . $this->getStreamOutput('module/' . $RE_MODUL_ID . '/input', $RE_MODUL_IN) . '
                    </div>
                </fieldset>

            </form>';
        $fragment = new rex_fragment();
        $fragment->setVar('class', 'edit', false);
        $fragment->setVar('title', $this->getSliceHeading($artDataSql), false);
        $fragment->setVar('options', $this->getSliceMenu($artDataSql), false);
        $fragment->setVar('body', $panel, false);
        $fragment->setVar('footer', $slice_footer, false);
        $slice_content = $fragment->parse('core/page/section.php');
        $slice_content = '
            <li class="rex-slice rex-slice-edit" id="slice' . $RE_CONTS . '">
                <form enctype="multipart/form-data" action="' . rex_url::currentBackendPage(['article_id' => $this->article_id, 'slice_id' => $RE_CONTS, 'ctype' => $RE_CTYPE, 'clang' => $this->clang]) . '#slice' . $RE_CONTS . '" method="post" id="REX_FORM">
                    ' . $slice_content . '
                </form>
                <script type="text/javascript">
                     <!--
                    jQuery(function($) {
                        $(":input:visible:enabled:not([readonly]):first", $("#REX_FORM")).focus();
                    });
                     //-->
                </script>
            </li>
            ';
        return $slice_content;
    }
Ejemplo n.º 17
0
<?php

$fragment = new rex_fragment();
$fragment->setVar('buttons', $this->items, false);
$fragment->setVar('size', 'xs', false);
echo $fragment->parse('core/buttons/button_group.php');
Ejemplo n.º 18
0
 public static function getMissingWildcardsAsTable()
 {
     $missingWildcards = self::getMissingWildcards();
     if (count($missingWildcards)) {
         $content = '';
         $content .= '
             <table class="table table-striped table-hover">
                <thead>
                    <tr>
                        <th class="rex-table-icon"></th>
                        <th>' . \rex_addon::get('sprog')->i18n('wildcard') . '</th>
                        <th class="rex-table-action" colspan="2">' . \rex_addon::get('sprog')->i18n('function') . '</th>
                    </tr>
                </thead>
                <tbody>
            ';
         foreach ($missingWildcards as $name => $params) {
             $content .= '
                        <tr>
                            <td class="rex-table-icon"><i class="rex-icon rex-icon-refresh"></i></td>
                            <td data-title="' . \rex_addon::get('sprog')->i18n('wildcard') . '">' . $name . '</td>
                            <td class="rex-table-action"><a href="' . \rex_url::currentBackendPage(['func' => 'add', 'wildcard_name' => $params['wildcard']]) . '"><i class="rex-icon rex-icon-edit"></i> ' . \rex_addon::get('sprog')->i18n('function_add') . '</a></td>
                            <td class="rex-table-action"><a href="' . $params['url'] . '"><i class="rex-icon rex-icon-article"></i> ' . \rex_addon::get('sprog')->i18n('wildcard_go_to_the_article') . '</a></td>
                        </tr>';
         }
         $content .= '
                </tbody>
            </table>';
         $fragment = new \rex_fragment();
         $fragment->setVar('title', \rex_addon::get('sprog')->i18n('wildcard_caption_missing', \rex_addon::get('structure')->i18n('title_structure')), false);
         $fragment->setVar('content', $content, false);
         $content = $fragment->parse('core/page/section.php');
         return $content;
     }
 }
Ejemplo n.º 19
0
 public static function addFooterForm(rex_extension_point $ep)
 {
     $fragment = new rex_fragment();
     $fragment->setVar('deletePath', 'index.php?page=content/delete&article_id=' . $ep->getParam('article_id') . '&mode=edit&module_id=' . $ep->getParam('module_id') . '&slice_id=' . $ep->getParam('slice_id') . '&clang=' . $ep->getParam('clang') . '&ctype=' . $ep->getParam('ctype'), false);
     return $fragment->parse('page/footer.php');
 }
Ejemplo n.º 20
0
 /**
  * Gibt die Navigation der Liste zurück.
  *
  * @return string
  */
 protected function getPagination()
 {
     $fragment = new rex_fragment();
     $fragment->setVar('urlprovider', $this);
     $fragment->setVar('pager', $this->pager);
     return $fragment->parse('core/navigations/pagination.php');
 }
Ejemplo n.º 21
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;
}
Ejemplo n.º 22
0
 public static function showHelp($script = false)
 {
     $return = '';
     $arr = ['value' => 'rex_yform_value_', 'validate' => 'rex_yform_validate_', 'action' => 'rex_yform_action_'];
     $classes = rex_autoload::getClasses();
     natsort($classes);
     $classesDescription = [];
     foreach ($arr as $arr_key => $arr_split) {
         $classesDescription[$arr_key] = '';
         foreach ($classes as $class) {
             $exploded = explode($arr_split, $class);
             if (count($exploded) == 2) {
                 $name = $exploded[1];
                 if ($name != 'abstract') {
                     $class = new $class();
                     $desc = trim($class->getDescription());
                     if ($desc == '') {
                         $definitions = $class->getDefinitions();
                         $desc = isset($definitions['description']) ? $definitions['description'] : '';
                     }
                     $classesDescription[$arr_key] .= '<tr><th><span class="btn btn-default btn-block"><code>' . $name . '</code></span></th><td class="vertical-middle">' . $desc . '</td></tr>';
                 }
             }
         }
     }
     $return = '';
     foreach ($classesDescription as $title => $content) {
         $fragment = new rex_fragment();
         $fragment->setVar('title', rex_i18n::msg("yform_" . $title));
         $fragment->setVar('content', '<table class="table table-hover yform-table-help">' . $content . '</table>', false);
         $fragment->setVar('collapse', true);
         $fragment->setVar('collapsed', true);
         $content = $fragment->parse('core/page/section.php');
         $return .= $content;
     }
     return $return;
 }
Ejemplo n.º 23
0
 /**
  * Erstellt den nötigen HTML Code um ein Formular zu erweitern.
  *
  * @param rex_sql $sqlFields rex_sql-objekt, dass die zu verarbeitenden Felder enthält
  * @param array   $epParams  Array of all EP parameters
  *
  * @return string
  */
 public function renderMetaFields(rex_sql $sqlFields, array $epParams)
 {
     $s = '';
     // Startwert für MEDIABUTTON, MEDIALIST, LINKLIST zähler
     $media_id = 1;
     $mlist_id = 1;
     $link_id = 1;
     $llist_id = 1;
     $activeItem = isset($epParams['activeItem']) ? $epParams['activeItem'] : null;
     $sqlFields->reset();
     for ($i = 0; $i < $sqlFields->getRows(); $i++, $sqlFields->next()) {
         // Umschliessendes Tag von Label und Formularelement
         $tag = 'p';
         $tag_attr = '';
         $name = $sqlFields->getValue('name');
         $title = $sqlFields->getValue('title');
         $params = $sqlFields->getValue('params');
         $typeLabel = $sqlFields->getValue('label');
         $attr = $sqlFields->getValue('attributes');
         $dblength = $sqlFields->getValue('dblength');
         $attrArray = rex_string::split($attr);
         if (isset($attrArray['perm'])) {
             if (!rex::getUser()->hasPerm($attrArray['perm'])) {
                 continue;
             }
             unset($attrArray['perm']);
         }
         $defaultValue = $sqlFields->getValue('default');
         if ($activeItem) {
             $itemValue = $activeItem->getValue($name);
             if (strpos($itemValue, '|+|') !== false) {
                 // Alte notation mit |+| als Trenner
                 $dbvalues = explode('|+|', $activeItem->getValue($name));
             } else {
                 // Neue Notation mit | als Trenner
                 $dbvalues = explode('|', $activeItem->getValue($name));
             }
         } else {
             $dbvalues = (array) $sqlFields->getValue('default');
         }
         if ($title != '') {
             $label = rex_i18n::translate($title);
         } else {
             $label = htmlspecialchars($name);
         }
         $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $label);
         $labelIt = true;
         $label = '<label for="' . $id . '">' . $label . '</label>';
         $field = '';
         switch ($typeLabel) {
             case 'text':
                 $tag_attr = ' class="form-control"';
                 $rexInput = rex_input::factory($typeLabel);
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setAttribute('id', $id);
                 $rexInput->setAttribute('name', $name);
                 if ($dblength > 0) {
                     $rexInput->setAttribute('maxlength', $dblength);
                 }
                 if ($activeItem) {
                     $rexInput->setValue($activeItem->getValue($name));
                 } else {
                     $rexInput->setValue($defaultValue);
                 }
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 break;
             case 'checkbox':
                 // Beachte auch default values in multiple fields bei ADD.
                 // Im EDIT wurde dies bereits vorher gehandelt
                 if (!$activeItem) {
                     $defaultValue = explode('|', $defaultValue);
                 }
                 $name .= '[]';
             case 'radio':
                 $formElements = [];
                 $values = [];
                 if (rex_sql::getQueryType($params) == 'SELECT') {
                     $sql = rex_sql::factory();
                     $value_groups = $sql->getDBArray($params, [], PDO::FETCH_NUM);
                     foreach ($value_groups as $value_group) {
                         if (isset($value_group[1])) {
                             $values[$value_group[1]] = $value_group[0];
                         } else {
                             $values[$value_group[0]] = $value_group[0];
                         }
                     }
                 } else {
                     $value_groups = explode('|', $params);
                     foreach ($value_groups as $value_group) {
                         // check ob key:value paar
                         // und der wert beginnt nicht mit "translate:"
                         if (strpos($value_group, ':') !== false && strpos($value_group, 'translate:') !== 0) {
                             $temp = explode(':', $value_group, 2);
                             $values[$temp[0]] = rex_i18n::translate($temp[1]);
                         } else {
                             $values[$value_group] = rex_i18n::translate($value_group);
                         }
                     }
                 }
                 $oneValue = count($values) == 1;
                 $attrStr = '';
                 $classAdd = '';
                 $inline = false;
                 if (false !== ($key = array_search('inline', $attrArray))) {
                     $inline = true;
                     unset($attrArray[$key]);
                 }
                 foreach ($attrArray as $key => $value) {
                     if ($key == 'class') {
                         $classAdd = ' ' . $value;
                     } else {
                         $attrStr = ' ' . $key . '="' . $value . '"';
                     }
                 }
                 if (!$activeItem) {
                     $dbvalues = (array) $defaultValue;
                 }
                 foreach ($values as $key => $value) {
                     $id = preg_replace('/[^a-zA-Z\\-0-9_]/', '_', $id . $key);
                     // wenn man keine Werte angibt (Boolean Chkbox/Radio)
                     // Dummy Wert annehmen, damit an/aus unterscheidung funktioniert
                     if ($oneValue && $key == '') {
                         $key = 'true';
                     }
                     $selected = '';
                     if (in_array($key, $dbvalues)) {
                         $selected = ' checked="checked"';
                     }
                     $e = [];
                     if ($oneValue) {
                         $e['label'] = $label;
                     } else {
                         $e['label'] = '<label for="' . $id . '">' . htmlspecialchars($value) . '</label>';
                     }
                     $e['field'] = '<input type="' . $typeLabel . '" name="' . $name . '" value="' . htmlspecialchars($key) . '" id="' . $id . '" ' . $attrStr . $selected . ' />';
                     $formElements[] = $e;
                 }
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', $formElements, false);
                 $fragment->setVar('inline', $inline);
                 if ($typeLabel == 'radio') {
                     $field = $fragment->parse('core/form/radio.php');
                 } else {
                     if (!$oneValue) {
                         $fragment->setVar('grouped', true);
                     }
                     $field = $fragment->parse('core/form/checkbox.php');
                 }
                 if (!$oneValue) {
                     $e = [];
                     $e['label'] = $label;
                     $e['field'] = $field;
                     $fragment = new rex_fragment();
                     $fragment->setVar('elements', [$e], false);
                     $field = $fragment->parse('core/form/form.php');
                 }
                 break;
             case 'select':
                 $tag_attr = ' class="form-control"';
                 $select = new rex_select();
                 $select->setStyle('class="form-control"');
                 $select->setName($name);
                 $select->setId($id);
                 $multiple = false;
                 foreach ($attrArray as $attr_name => $attr_value) {
                     if (empty($attr_name)) {
                         continue;
                     }
                     $select->setAttribute($attr_name, $attr_value);
                     if ($attr_name == 'multiple') {
                         $multiple = true;
                         $select->setName($name . '[]');
                         $select->setMultiple();
                     }
                 }
                 // Beachte auch default values in multiple fields bei ADD.
                 // Im EDIT wurde dies bereits vorher gehandelt
                 if ($multiple && !$activeItem) {
                     $dbvalues = explode('|', $defaultValue);
                 }
                 // hier mit den "raw"-values arbeiten, da die rex_select klasse selbst escaped
                 $select->setSelected($dbvalues);
                 if (rex_sql::getQueryType($params) == 'SELECT') {
                     // Werte via SQL Laden
                     $select->addDBSqlOptions($params);
                 } else {
                     // Optionen mit | separiert
                     // eine einzelne Option kann mit key:value separiert werden
                     $values = [];
                     $value_groups = explode('|', $params);
                     foreach ($value_groups as $value_group) {
                         // check ob key:value paar
                         // und der wert beginnt nicht mit "translate:"
                         if (strpos($value_group, ':') !== false && strpos($value_group, 'translate:') !== 0) {
                             $temp = explode(':', $value_group, 2);
                             $values[$temp[0]] = rex_i18n::translate($temp[1]);
                         } else {
                             $values[$value_group] = rex_i18n::translate($value_group);
                         }
                     }
                     $select->addOptions($values);
                 }
                 $field .= $select->get();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 break;
             case 'date':
             case 'time':
             case 'datetime':
                 $tag_attr = ' class="form-control-date"';
                 $active = $dbvalues[0] != 0;
                 if ($dbvalues[0] == '') {
                     $dbvalues[0] = time();
                 }
                 $inputValue = [];
                 $inputValue['year'] = date('Y', $dbvalues[0]);
                 $inputValue['month'] = date('n', $dbvalues[0]);
                 $inputValue['day'] = date('j', $dbvalues[0]);
                 $inputValue['hour'] = date('G', $dbvalues[0]);
                 $inputValue['minute'] = date('i', $dbvalues[0]);
                 $rexInput = rex_input::factory($typeLabel);
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setAttribute('id', $id);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue($inputValue);
                 $field = $rexInput->getHtml();
                 $checked = $active ? ' checked="checked"' : '';
                 $field .= '<input class="rex-metainfo-checkbox" type="checkbox" name="' . $name . '[active]" value="1"' . $checked . ' />';
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 break;
             case 'textarea':
                 $tag_attr = ' class="form-control"';
                 $rexInput = rex_input::factory($typeLabel);
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setAttribute('id', $id);
                 $rexInput->setAttribute('name', $name);
                 if ($activeItem) {
                     $rexInput->setValue($activeItem->getValue($name));
                 } else {
                     $rexInput->setValue($defaultValue);
                 }
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 break;
             case 'legend':
                 $tag = '';
                 $tag_attr = '';
                 $labelIt = false;
                 // tabindex entfernen, macht bei einer legend wenig sinn
                 $attr = preg_replace('@tabindex="[^"]*"@', '', $attr);
                 $field = '</fieldset><fieldset><legend id="' . $id . '"' . $attr . '>' . $label . '</legend>';
                 break;
             case 'REX_MEDIA_WIDGET':
                 $tag = 'div';
                 $tag_attr = ' class="rex-form-widget"';
                 $paramArray = rex_string::split($params);
                 $rexInput = rex_input::factory('mediabutton');
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setButtonId($media_id);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue($dbvalues[0]);
                 if (isset($paramArray['category'])) {
                     $rexInput->setCategoryId($paramArray['category']);
                 }
                 if (isset($paramArray['types'])) {
                     $rexInput->setTypes($paramArray['types']);
                 }
                 if (isset($paramArray['preview'])) {
                     $rexInput->setPreview($paramArray['preview']);
                 }
                 $id = $rexInput->getAttribute('id');
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 ++$media_id;
                 break;
             case 'REX_MEDIALIST_WIDGET':
                 $tag = 'div';
                 $tag_attr = ' class="rex-form-widget"';
                 $paramArray = rex_string::split($params);
                 $name .= '[]';
                 $rexInput = rex_input::factory('medialistbutton');
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setButtonId($mlist_id);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue($dbvalues[0]);
                 if (isset($paramArray['category'])) {
                     $rexInput->setCategoryId($paramArray['category']);
                 }
                 if (isset($paramArray['types'])) {
                     $rexInput->setTypes($paramArray['types']);
                 }
                 if (isset($paramArray['preview'])) {
                     $rexInput->setPreview($paramArray['preview']);
                 }
                 $id = $rexInput->getAttribute('id');
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 ++$mlist_id;
                 break;
             case 'REX_LINK_WIDGET':
                 $tag = 'div';
                 $tag_attr = ' class="rex-form-widget"';
                 $paramArray = rex_string::split($params);
                 $category = '';
                 if (isset($paramArray['category'])) {
                     $category = $paramArray['category'];
                 } elseif ($activeItem) {
                     $category = $activeItem->getValue('category_id');
                 }
                 $rexInput = rex_input::factory('linkbutton');
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setButtonId($link_id);
                 $rexInput->setCategoryId($category);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue($dbvalues[0]);
                 $id = $rexInput->getAttribute('id');
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 ++$link_id;
                 break;
             case 'REX_LINKLIST_WIDGET':
                 $tag = 'div';
                 $tag_attr = ' class="rex-form-widget"';
                 $paramArray = rex_string::split($params);
                 $category = '';
                 if (isset($paramArray['category'])) {
                     $category = $paramArray['category'];
                 } elseif ($activeItem) {
                     $category = $activeItem->getValue('category_id');
                 }
                 $name .= '[]';
                 $rexInput = rex_input::factory('linklistbutton');
                 $rexInput->addAttributes($attrArray);
                 $rexInput->setButtonId($llist_id);
                 $rexInput->setCategoryId($category);
                 $rexInput->setAttribute('name', $name);
                 $rexInput->setValue(implode(',', $dbvalues));
                 $id = $rexInput->getAttribute('id');
                 $field = $rexInput->getHtml();
                 $e = [];
                 $e['label'] = $label;
                 $e['field'] = $field;
                 $fragment = new rex_fragment();
                 $fragment->setVar('elements', [$e], false);
                 $field = $fragment->parse('core/form/form.php');
                 ++$llist_id;
                 break;
             default:
                 // ----- EXTENSION POINT
                 list($field, $tag, $tag_attr, $id, $label, $labelIt) = rex_extension::registerPoint(new rex_extension_point('METAINFO_CUSTOM_FIELD', [$field, $tag, $tag_attr, $id, $label, $labelIt, 'values' => $dbvalues, 'rawvalues' => $dbvalues, 'type' => $typeLabel, 'sql' => $sqlFields]));
         }
         $s .= $this->renderFormItem($field, $tag, $tag_attr, $id, $label, $labelIt, $typeLabel);
     }
     return $s;
 }
Ejemplo n.º 24
0
Archivo: top.php Proyecto: eaCe/redaxo
    $fragment = new rex_fragment();
    $fragment->setVar('pageTitle', rex_be_controller::getPageTitle());
    $fragment->setVar('cssFiles', rex_view::getCssFiles());
    $fragment->setVar('jsFiles', rex_view::getJsFiles());
    $fragment->setVar('jsProperties', json_encode(rex_view::getJsProperties()), false);
    $fragment->setVar('favicon', rex_view::getFavicon());
    $fragment->setVar('pageHeader', rex_extension::registerPoint(new rex_extension_point('PAGE_HEADER', '')), false);
    $fragment->setVar('bodyAttr', $body, false);
    echo $fragment->parse('core/top.php');
    $fragment = new rex_fragment();
    $fragment->setVar('items', $meta_items, false);
    $meta_navigation = $fragment->parse('core/navigations/meta.php');
    $fragment = new rex_fragment();
    // $fragment->setVar('pageHeader', rex_extension::registerPoint(new rex_extension_point('PAGE_HEADER', '')), false);
    $fragment->setVar('meta_navigation', $meta_navigation, false);
    echo $fragment->parse('core/header.php');
    echo '<div id="rex-js-page-container" class="rex-page-container">';
} elseif (rex_request::isPJAXRequest()) {
    // add title to the page, so pjax can update it. see gh#136
    echo '<title>' . htmlspecialchars(rex_be_controller::getPageTitle()) . '</title>';
}
$fragment = new rex_fragment();
$fragment->setVar('navigation', $navigation, false);
echo $fragment->parse('core/navigation.php');
$pjax = $curPage->allowsPjax() ? ' data-pjax-container="#rex-js-page-main"' : '';
?>
<div class="rex-page-main"><section class="rex-page-main-inner" id="rex-js-page-main"<?php 
echo $pjax;
?>
>
Ejemplo n.º 25
0
// Variable definiert und vorbelegt wenn nicht existent
$KAToutARR = [];
// Variable definiert und vorbelegt wenn nicht existent
$navigation = [];
$object_id = $article_id > 0 ? $article_id : $category_id;
$object = rex_article::get($object_id, $clang);
if ($object) {
    $tree = $object->getParentTree();
    if (!$object->isStartarticle()) {
        $tree[] = $object;
    }
    foreach ($tree as $parent) {
        $id = $parent->getId();
        if (rex::getUser()->getComplexPerm('structure')->hasCategoryPerm($id)) {
            $n = [];
            $n['title'] = str_replace(' ', '&nbsp;', htmlspecialchars($parent->getName()));
            if ($parent->isStartarticle()) {
                $n['href'] = rex_url::backendPage('structure', ['category_id' => $id, 'clang' => $clang]);
            }
            $navigation[] = $n;
        }
    }
}
$title = '<a href="' . rex_url::backendPage('structure', ['category_id' => 0, 'clang' => $clang]) . '"><i class="rex-icon rex-icon-sitestartarticle"></i> ' . rex_i18n::msg('homepage') . '</a>';
$fragment = new rex_fragment();
$fragment->setVar('id', 'rex-js-structure-breadcrumb', false);
$fragment->setVar('title', $title, false);
$fragment->setVar('items', $navigation, false);
echo $fragment->parse('core/navigations/breadcrumb.php');
unset($fragment);
unset($navigation);
Ejemplo n.º 26
0
 public static function getWidget($id, $name, $value, array $args = [])
 {
     $open_params = '';
     if (isset($args['category']) && ($category = (int) $args['category'])) {
         $open_params .= '&amp;rex_file_category=' . $category;
     }
     foreach ($args as $aname => $avalue) {
         $open_params .= '&amp;args[' . $aname . ']=' . urlencode($avalue);
     }
     $wdgtClass = ' rex-js-widget-medialist';
     if (isset($args['preview']) && $args['preview']) {
         $wdgtClass .= ' rex-js-widget-preview';
         if (rex_addon::get('media_manager')->isAvailable()) {
             $wdgtClass .= ' rex-js-widget-preview-media-manager';
         }
     }
     $options = '';
     $medialistarray = explode(',', $value);
     if (is_array($medialistarray)) {
         foreach ($medialistarray as $file) {
             if ($file != '') {
                 $options .= '<option value="' . $file . '">' . $file . '</option>';
             }
         }
     }
     $disabled = ' disabled';
     $open_func = '';
     $add_func = '';
     $delete_func = '';
     $view_func = '';
     if (rex::getUser()->getComplexPerm('media')->hasMediaPerm()) {
         $disabled = '';
         $open_func = 'openREXMedialist(' . $id . ',\'' . $open_params . '\');';
         $add_func = 'addREXMedialist(' . $id . ',\'' . $open_params . '\');';
         $delete_func = 'deleteREXMedialist(' . $id . ');';
         $view_func = 'viewREXMedialist(' . $id . ',\'' . $open_params . '\');';
     }
     $e = [];
     $e['before'] = '<div class="rex-js-widget' . $wdgtClass . '">';
     $e['field'] = '<select class="form-control" name="REX_MEDIALIST_SELECT[' . $id . ']" id="REX_MEDIALIST_SELECT_' . $id . '" size="8">' . $options . '</select><input type="hidden" name="' . $name . '" id="REX_MEDIALIST_' . $id . '" value="' . $value . '" />';
     $e['moveButtons'] = '
             <a href="#" class="btn btn-popup" onclick="moveREXMedialist(' . $id . ',\'top\');return false;" title="' . rex_i18n::msg('var_medialist_move_top') . '"><i class="rex-icon rex-icon-top"></i></a>
             <a href="#" class="btn btn-popup" onclick="moveREXMedialist(' . $id . ',\'up\');return false;" title="' . rex_i18n::msg('var_medialist_move_up') . '"><i class="rex-icon rex-icon-up"></i></a>
             <a href="#" class="btn btn-popup" onclick="moveREXMedialist(' . $id . ',\'down\');return false;" title="' . rex_i18n::msg('var_medialist_move_down') . '"><i class="rex-icon rex-icon-down"></i></a>
             <a href="#" class="btn btn-popup" onclick="moveREXMedialist(' . $id . ',\'bottom\');return false;" title="' . rex_i18n::msg('var_medialist_move_bottom') . '"><i class="rex-icon rex-icon-bottom"></i></a>';
     $e['functionButtons'] = '
             <a href="#" class="btn btn-popup" onclick="' . $open_func . 'return false;" title="' . rex_i18n::msg('var_media_open') . '"' . $disabled . '><i class="rex-icon rex-icon-open-mediapool"></i></a>
             <a href="#" class="btn btn-popup" onclick="' . $add_func . 'return false;" title="' . rex_i18n::msg('var_media_new') . '"' . $disabled . '><i class="rex-icon rex-icon-add-media"></i></a>
             <a href="#" class="btn btn-popup" onclick="' . $delete_func . 'return false;" title="' . rex_i18n::msg('var_media_remove') . '"' . $disabled . '><i class="rex-icon rex-icon-delete-media"></i></a>
             <a href="#" class="btn btn-popup" onclick="' . $view_func . 'return false;" title="' . rex_i18n::msg('var_media_view') . '"' . $disabled . '><i class="rex-icon rex-icon-view-media"></i></a>';
     $e['after'] = '<div class="rex-js-media-preview"></div></div>';
     $fragment = new rex_fragment();
     $fragment->setVar('elements', [$e], false);
     $media = $fragment->parse('core/form/widget_list.php');
     return $media;
 }
Ejemplo n.º 27
0
        <fieldset>';
$formElements = [];
$n = [];
$n['label'] = '<label for="rex-out5-wartungsarbeiten-url">URL</label>';
$n['field'] = '<input class="form-control" type="text" id="rex-out5-wartungsarbeiten-url" name="config[url]" value="' . $plugin->getConfig('url') . '"/>';
$formElements[] = $n;
$fragment = new rex_fragment();
$fragment->setVar('elements', $formElements, false);
$content .= $fragment->parse('core/form/form.php');
$content .= '
        </fieldset>

        <fieldset class="rex-form-action">';
$formElements = [];
$n = [];
$n['field'] = '<div class="btn-toolbar"><button id="rex-out5-wartungsarbeiten-save" type="submit" name="config-submit" class="btn btn-save rex-form-aligned" value="1">Einstellungen speichern</button></div>';
$formElements[] = $n;
$fragment = new rex_fragment();
$fragment->setVar('elements', $formElements, false);
$content .= $fragment->parse('core/form/submit.php');
$content .= '
        </fieldset>

    </form>
</div>';
$fragment = new rex_fragment();
$fragment->setVar('class', 'edit');
$fragment->setVar('title', 'Wartungsarbeiten - Einstellungen');
$fragment->setVar('body', $content, false);
echo $fragment->parse('core/page/section.php');
Ejemplo n.º 28
0
<?php

$curPage = rex_be_controller::getCurrentPageObject();
if (!$curPage->hasLayout()) {
    if (rex_request::isPJAXRequest()) {
        echo '</section>';
    }
    return;
}
?>

</section></div><?php 
if (rex_request::isPJAXContainer('#rex-js-page-container')) {
    return;
}
echo '</div>';
$sidebar = rex_extension::registerPoint(new rex_extension_point('PAGE_SIDEBAR', ''));
if ($sidebar != '') {
    $sidebarfragment = new rex_fragment();
    $sidebarfragment->content = $sidebar;
    echo $sidebarfragment->parse('core/sidebar.php');
    unset($sidebarfragment);
}
unset($fragment);
$footerfragment = new rex_fragment();
$footerfragment->setVar('time', rex::getProperty('timer')->getFormattedDelta(rex_timer::SEC));
echo $footerfragment->parse('core/footer.php');
unset($footerfragment);
$bottomfragment = new rex_fragment();
echo $bottomfragment->parse('core/bottom.php');
unset($bottomfragment);
Ejemplo n.º 29
0
 function getFieldPage()
 {
     // ********************************************* FIELD ADD/EDIT/LIST
     $func = rex_request('func', 'string', 'list');
     $type_id = rex_request('type_id', 'string');
     $type_name = rex_request('type_name', 'string');
     $field_id = rex_request('field_id', 'int');
     $link_vars = '';
     foreach ($this->getLinkVars() as $k => $v) {
         $link_vars .= '&' . urlencode($k) . '=' . urlencode($v);
     }
     $TYPE = array('value' => rex_i18n::msg('yform_values'), 'validate' => rex_i18n::msg('yform_validates'), 'action' => rex_i18n::msg('yform_action'));
     // ********************************** TABELLE HOLEN
     $table = $this->table;
     $table_info = '<b>' . rex_i18n::translate($table->getName()) . ' [' . $table->getTableName() . ']</b> ';
     echo rex_view::info($table_info);
     // ********************************************* Missing Fields
     $mfields = $table->getMissingFields();
     // ksort($mfields);
     $type_real_field = rex_request('type_real_field', 'string');
     if ($type_real_field != '' && !array_key_exists($type_real_field, $mfields)) {
         $type_real_field = '';
     }
     if ($type_real_field != '') {
         $panel = '';
         $panel .= '<dl class="dl-horizontal text-left">';
         $rfields = $this->table->getColumns();
         foreach ($rfields[$type_real_field] as $k => $v) {
             $panel .= '<dt>' . ucfirst($k) . ':</dt><dd>' . $v . '</dd>';
         }
         $panel .= '</dl>';
         $fragment = new rex_fragment();
         $fragment->setVar('class', 'info');
         $fragment->setVar('title', 'Folgendes Feld wird verwendet: ' . $type_real_field);
         $fragment->setVar('body', $panel, false);
         echo $fragment->parse('core/page/section.php');
     }
     // ********************************************* CHOOSE FIELD
     $types = rex_yform::getTypeArray();
     if ($func == 'choosenadd') {
         $link = 'index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=add&';
         $content = [];
         $panels = [];
         if (!$table->hasId()) {
             $content[] = rex_i18n::msg('yform_id_is_missing') . '' . rex_i18n::msg('yform_id_missing_info');
         } else {
             if ($type_real_field == '' && count($mfields) > 0) {
                 $tmp = '';
                 $d = 0;
                 foreach ($mfields as $k => $v) {
                     $d++;
                     $l = 'index.php?' . $link_vars . '&table_name=' . $table->getTableName() . '&func=choosenadd&type_real_field=' . $k . '&type_layout=t';
                     $tmp .= '<a class="btn btn-default" href="' . $l . '">' . $k . '</a> ';
                 }
                 $fragment = new rex_fragment();
                 $fragment->setVar('class', 'info');
                 $fragment->setVar('title', 'Es gibt noch Felder in der Tabelle welche nicht zugewiesen sind.');
                 $fragment->setVar('body', $tmp, false);
                 echo $fragment->parse('core/page/section.php');
             }
             $tmp = '';
             if (isset($types['value'])) {
                 ksort($types['value']);
                 $tmp .= '<table class="table table-hover">';
                 foreach ($types['value'] as $k => $v) {
                     $tmp .= '<tr><th><a class="btn btn-default btn-block" href="' . $link . 'type_id=value&type_name=' . $k . '&type_real_field=' . $type_real_field . '"><code>' . $k . '</code></a></th><td class="vertical-middle">' . $v['description'] . '</td></tr>';
                 }
                 $tmp .= '</table>';
             }
             $fragment = new rex_fragment();
             $fragment->setVar('title', $TYPE['value']);
             $fragment->setVar('content', $tmp, false);
             $panels[] = $fragment->parse('core/page/section.php');
             $tmp = '';
             if (isset($types['validate'])) {
                 ksort($types['validate']);
                 $tmp .= '<table class="table table-hover">';
                 foreach ($types['validate'] as $k => $v) {
                     $tmp .= '<tr><th><a class="btn btn-default btn-block" href="' . $link . 'type_id=validate&type_name=' . $k . '"><code>' . $k . '</code></a></th><td class="vertical-middle">' . $v['description'] . '</td></tr>';
                 }
                 $tmp .= '</table>';
             }
             $fragment = new rex_fragment();
             $fragment->setVar('title', $TYPE['validate']);
             $fragment->setVar('content', $tmp, false);
             $panels[] = $fragment->parse('core/page/section.php');
         }
         $fragment = new rex_fragment();
         $fragment->setVar('title', rex_i18n::msg('yform_choosenadd'));
         $fragment->setVar('body', rex_i18n::msg('yform_choosenadd_description'), false);
         echo $fragment->parse('core/page/section.php');
         $fragment = new rex_fragment();
         $fragment->setVar('content', $panels, false);
         echo $fragment->parse('core/page/grid.php');
         $table_echo = '<a class="btn btn-default" href="index.php?' . $link_vars . '&amp;table_name=' . $table->getTableName() . '">' . rex_i18n::msg('yform_back_to_overview') . '</a>';
         $fragment = new rex_fragment();
         $fragment->setVar('footer', $table_echo, false);
         echo $fragment->parse('core/page/section.php');
     }
     // ********************************************* FORMULAR
     if (($func == 'add' || $func == 'edit') && isset($types[$type_id][$type_name])) {
         $yform = new rex_yform();
         $yform->setDebug(false);
         foreach ($this->getLinkVars() as $k => $v) {
             $yform->setHiddenField($k, $v);
         }
         $yform->setHiddenField('func', $func);
         $yform->setHiddenField('table_name', $table->getTableName());
         $yform->setHiddenField('type_real_field', $type_real_field);
         $yform->setHiddenField('list', rex_request('list', 'string'));
         $yform->setHiddenField('sort', rex_request('sort', 'string'));
         $yform->setHiddenField('sorttype', rex_request('sorttype', 'string'));
         $yform->setHiddenField('start', rex_request('start', 'string'));
         $yform->setValueField('hidden', array('table_name', $table->getTableName()));
         $yform->setValueField('hidden', array('type_name', $type_name, 'REQUEST'));
         $yform->setValueField('hidden', array('type_id', $type_id, 'REQUEST'));
         $yform->setValueField('prio', array('prio', 'Prioritaet', array('name', 'type_id', 'type_name'), array('table_name')));
         $selectFields = array();
         $i = 1;
         foreach ($types[$type_id][$type_name]['values'] as $k => $v) {
             $field = $this->getFieldName($k, $type_id);
             $selectFields['f' . $i] = $field;
             $i++;
             switch ($v['type']) {
                 case 'name':
                     if ($func == 'edit') {
                         $yform->setValueField('showvalue', array($field, 'Name'));
                     } else {
                         if (!isset($v['value']) && $type_real_field != '') {
                             $v['value'] = $type_real_field;
                         } elseif (!isset($v['value'])) {
                             $v['value'] = '';
                         }
                         $yform->setValueField('text', array($field, 'Name', $v['value']));
                         $yform->setValidateField('empty', array($field, rex_i18n::msg('yform_validatenamenotempty')));
                         $yform->setValidateField('preg_match', array($field, "/(([a-zA-Z])+([a-zA-Z0-9\\_])*)/", rex_i18n::msg('yform_validatenamepregmatch')));
                         $yform->setValidateField('customfunction', array($field, 'rex_yform_manager_checkField', array('table_name' => $table->getTableName()), rex_i18n::msg('yform_validatenamecheck')));
                     }
                     break;
                 case 'no_db':
                     if (!isset($v['default']) || $v['default'] != 1) {
                         $v['default'] = 0;
                     }
                     $yform->setValueField('checkbox', array($field, rex_i18n::msg('yform_donotsaveindb'), 'no_db', $v['default']));
                     break;
                 case 'boolean':
                     // checkbox|check_design|Bezeichnung|Value|1/0|[no_db]
                     if (!isset($v['default'])) {
                         $v['default'] = '';
                     }
                     $yform->setValueField('checkbox', array($field, $v['label'], '', $v['default']));
                     break;
                 case 'select':
                     // select|gender|Geschlecht *|Frau=w;Herr=m|[no_db]|defaultwert|multiple=1
                     $yform->setValueField('select', array($field, $v['label'], $v['options'], '', $v['default'], 0));
                     break;
                 case 'table':
                     // ist fest eingetragen, damit keine Dinge durcheinandergehen
                     if ($func == 'edit') {
                         $yform->setValueField('showvalue', array($field, $v['label']));
                     } else {
                         $_tables = rex_yform_manager_table::getAll();
                         $_options = array();
                         if (isset($v['empty_option']) && $v['empty_option']) {
                             $_options[0] = '–=';
                         }
                         foreach ($_tables as $_table) {
                             $_options[$_table['table_name']] = str_replace('=', '-', rex_i18n::translate($_table['name']) . ' [' . $_table['table_name'] . ']') . '=' . $_table['table_name'];
                             $_options[$_table['table_name']] = str_replace(',', '.', $_options[$_table['table_name']]);
                         }
                         if (!isset($v['default'])) {
                             $v['default'] = '';
                         }
                         $yform->setValueField('select', array($field, $v['label'], implode(',', $_options), '', $v['default'], 0));
                     }
                     break;
                 case 'textarea':
                     $yform->setValueField('textarea', array($field, $v['label']));
                     break;
                 case 'table.field':
                     // Todo:
                 // Todo:
                 case 'select_name':
                     $_fields = array();
                     foreach ($table->getValueFields() as $_k => $_v) {
                         $_fields[] = $_k;
                     }
                     $yform->setValueField('select', array($field, $v['label'], implode(',', $_fields), '', '', 0));
                     break;
                 case 'select_names':
                     $_fields = array();
                     foreach ($table->getValueFields() as $_k => $_v) {
                         $_fields[] = $_k;
                     }
                     $yform->setValueField('select', array($field, $v['label'], implode(',', $_fields), '', '', 1, 5));
                     break;
                 default:
                     // nur beim "Bezeichnungsfeld"
                     if ($field == 'label' && $type_real_field != '' && !isset($v['value'])) {
                         $v['value'] = $type_real_field;
                     } elseif (!isset($v['value'])) {
                         $v['value'] = '';
                     }
                     $yform->setValueField('text', array($field, $v['label'], $v['value']));
             }
         }
         $yform->setActionField('showtext', array('', '<p>' . rex_i18n::msg('yform_thankyouforentry') . '</p>'));
         $yform->setObjectparams('main_table', rex_yform_manager_field::table());
         if ($func == 'edit') {
             $yform->setObjectparams('submit_btn_label', rex_i18n::msg('yform_save'));
             $yform->setHiddenField('field_id', $field_id);
             $yform->setActionField('manage_db', array(rex_yform_manager_field::table(), "id={$field_id}"));
             $yform->setObjectparams('main_id', $field_id);
             $yform->setObjectparams('main_where', "id={$field_id}");
             $sql = rex_sql::factory();
             $sql->setQuery('SELECT * FROM ' . rex_yform_manager_field::table() . " WHERE id={$field_id}");
             foreach ($selectFields as $alias => $field) {
                 if ($alias != $field) {
                     if ((!$sql->hasValue($field) || null === $sql->getValue($field) || '' === $sql->getValue($field)) && $sql->hasValue($alias)) {
                         $sql->setValue($field, $sql->getValue($alias));
                     }
                     $yform->setValueField('hidden', array($alias, ''));
                 }
             }
             $yform->setObjectparams('sql_object', $sql);
             $yform->setObjectparams('getdata', true);
         } elseif ($func == 'add') {
             $yform->setObjectparams('submit_btn_label', rex_i18n::msg('yform_add'));
             $yform->setActionField('manage_db', array(rex_yform_manager_field::table()));
         }
         if ($type_id == 'value') {
             $yform->setValueField('checkbox', array('list_hidden', rex_i18n::msg('yform_hideinlist'), 1, '1'));
             $yform->setValueField('checkbox', array('search', rex_i18n::msg('yform_useassearchfieldalidatenamenotempty'), 1, '1'));
         } elseif ($type_id == 'validate') {
             $yform->setValueField('hidden', array('list_hidden', 1));
         }
         $form = $yform->getForm();
         if ($yform->objparams['form_show']) {
             if ($func == 'add') {
                 $title = rex_i18n::msg('yform_addfield') . ' "' . $type_name . '"';
             } else {
                 $title = rex_i18n::msg('yform_editfield') . ' "' . $type_name . '"';
             }
             $fragment = new rex_fragment();
             $fragment->setVar('class', 'edit', false);
             $fragment->setVar('title', $title);
             $fragment->setVar('body', $form, false);
             // $fragment->setVar('buttons', $buttons, false);
             $form = $fragment->parse('core/page/section.php');
             echo $form;
             $table_echo = '<a class="btn btn-default" href="index.php?' . $link_vars . '&amp;table_name=' . $table->getTableName() . '">' . rex_i18n::msg('yform_back_to_overview') . '</a>';
             $fragment = new rex_fragment();
             $fragment->setVar('footer', $table_echo, false);
             echo $fragment->parse('core/page/section.php');
             $func = '';
         } else {
             if ($func == 'edit') {
                 $this->generateAll();
                 echo rex_view::success(rex_i18n::msg('yform_thankyouforupdate'));
             } elseif ($func == 'add') {
                 $this->generateAll();
                 echo rex_view::success(rex_i18n::msg('yform_thankyouforentry'));
             }
             $func = 'list';
         }
     }
     // ********************************************* LOESCHEN
     if ($func == 'delete') {
         $sf = rex_sql::factory();
         $sf->debugsql = self::$debug;
         $sf->setQuery('select * from ' . rex_yform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id);
         $sfa = $sf->getArray();
         if (count($sfa) == 1) {
             $query = 'delete from ' . rex_yform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id;
             $delsql = rex_sql::factory();
             $delsql->debugsql = self::$debug;
             $delsql->setQuery($query);
             echo rex_view::success(rex_i18n::msg('yform_tablefielddeleted'));
             $this->generateAll();
         } else {
             echo rex_view::warning(rex_i18n::msg('yform_tablefieldnotfound'));
         }
         $func = 'list';
     }
     // ********************************************* CREATE/UPDATE FIELDS
     if ($func == 'updatetable') {
         $this->generateAll();
         echo rex_view::info(rex_i18n::msg('yform_tablesupdated'));
         $func = 'list';
     }
     if ($func == 'updatetablewithdelete') {
         $this->generateAll(array('delete_fields' => true));
         echo rex_view::info(rex_i18n::msg('yform_tablesupdated'));
         $func = 'list';
     }
     if ($func == 'show_form_notation') {
         $formbuilder_fields = $table->getFields();
         $notation_php = '';
         $notation_pipe = '';
         $notation_email = '';
         $notation_php_pre = array('$yform = new rex_yform();', '$yform->setObjectparams(\'form_skin\', \'default\');', '$yform->setObjectparams(\'form_showformafterupdate\', 0);', '$yform->setObjectparams(\'real_field_names\', true);');
         $notation_php .= implode("\n", $notation_php_pre) . "\n";
         $notation_pipe_pre = array('objparams|form_skin|bootstrap', 'objparams|form_showformafterupdate|0', 'objparams|real_field_names|true');
         $notation_pipe .= implode("\n", $notation_pipe_pre) . "\n";
         foreach ($formbuilder_fields as $field) {
             $class = 'rex_yform_' . $field->getType() . '_' . $field->getTypeName();
             $cl = new $class();
             $definitions = $cl->getDefinitions();
             $values = array();
             $i = 1;
             foreach ($definitions['values'] as $key => $_) {
                 $key = $this->getFieldName($key, $field['type_id']);
                 if (isset($field[$key])) {
                     $values[] = $field[$key];
                 } elseif (isset($field['f' . $i])) {
                     $values[] = $field['f' . $i];
                 } else {
                     $values[] = '';
                 }
                 $i++;
             }
             if ($field['type_id'] == 'value') {
                 $notation_php .= "\n" . '$yform->setValueField(\'' . $field['type_name'] . '\', array("' . rtrim(implode('","', $values), '","') . '"));';
                 $notation_pipe .= "\n" . $field['type_name'] . '|' . rtrim(implode('|', $values), '|') . '|';
                 $notation_email .= "\n" . $field['label'] . ': ###' . $field['name'] . '###';
             } elseif ($field['type_id'] == 'validate') {
                 $notation_php .= "\n" . '$yform->setValidateField(\'' . $field['type_name'] . '\', array("' . rtrim(implode('","', $values), '","') . '"));';
                 $notation_pipe .= "\n" . $field['type_id'] . '|' . $field['type_name'] . '|' . rtrim(implode('|', $values), '|') . '|';
             } elseif ($field['type_id'] == 'action') {
                 $notation_php .= "\n" . '$yform->setActionField(\'' . $field['type_name'] . '\', array("' . rtrim(implode('","', $values), '","') . '"));';
                 $notation_pipe .= "\n" . $field['type_id'] . '|' . $field['type_name'] . '|' . rtrim(implode('|', $values), '|') . '|';
             }
         }
         $notation_php .= "\n\n" . '$yform->setActionField(\'email\', array(\'emailtemplate\', \'emaillabel\', \'email@domain.de\'));';
         $notation_php .= "\n" . 'echo $yform->getForm();';
         $notation_pipe .= "\n\n" . 'action|email|emailtemplate|emaillabel|email@domain.de';
         $fragment = new rex_fragment();
         $fragment->setVar('title', 'PHP');
         $fragment->setVar('body', '<pre class="pre-scrollable">' . $notation_php . '</pre>', false);
         $content = $fragment->parse('core/page/section.php');
         echo $content;
         $fragment = new rex_fragment();
         $fragment->setVar('title', 'Pipe');
         $fragment->setVar('body', '<pre class="pre-scrollable">' . $notation_pipe . '</pre>', false);
         $content = $fragment->parse('core/page/section.php');
         echo $content;
         $fragment = new rex_fragment();
         $fragment->setVar('title', 'E-Mail');
         $fragment->setVar('body', '<pre class="pre-scrollable">' . $notation_email . '</pre>', false);
         $content = $fragment->parse('core/page/section.php');
         echo $content;
         $func = 'list';
     }
     // ********************************************* LIST
     if ($func == 'list') {
         $show_list = true;
         $show_list = rex_extension::registerPoint(new rex_extension_point('YFORM_MANAGER_TABLE_FIELD_FUNC', $show_list, ['table' => $table, 'link_vars' => $this->getLinkVars()]));
         if ($show_list) {
             function rex_yform_list_format($p, $value = '')
             {
                 if ($value != '') {
                     $p['value'] = $value;
                 }
                 switch ($p['list']->getValue('type_id')) {
                     case 'validate':
                         $style = 'color:#aaa;';
                         // background-color:#cfd9d9;
                         break;
                     case 'action':
                         $style = 'background-color:#cfd9d9;';
                         break;
                     default:
                         $style = 'background-color:#eff9f9;';
                         break;
                 }
                 return '<td style="' . $style . '">' . $p['value'] . '</td>';
             }
             function rex_yform_list_edit_format($p)
             {
                 return rex_yform_list_format($p, $p['list']->getColumnLink(rex_i18n::msg('yform_function'), '<i class="rex-icon rex-icon-edit"></i> ' . rex_i18n::msg('yform_edit')));
             }
             function rex_yform_list_delete_format($p)
             {
                 return rex_yform_list_format($p, $p['list']->getColumnLink(rex_i18n::msg('yform_delete'), '<i class="rex-icon rex-icon-delete"></i> ' . rex_i18n::msg('yform_delete')));
             }
             $context = new rex_context($this->getLinkVars());
             $items = [];
             $item = [];
             $item['label'] = rex_i18n::msg('yform_manager_show_form_notation');
             $item['url'] = $context->getUrl(['table_name' => $table->getTableName(), 'func' => 'show_form_notation']);
             $item['attributes']['class'][] = 'btn-default';
             if (rex_request('func', 'string') == 'show_form_notation') {
                 $item['attributes']['class'][] = 'active';
             }
             $items[] = $item;
             $item = [];
             $item['label'] = rex_i18n::msg('yform_updatetable');
             $item['url'] = $context->getUrl(['table_name' => $table->getTableName(), 'func' => 'updatetable']);
             $item['attributes']['class'][] = 'btn-default';
             if (rex_request('func', 'string') == 'updatetable') {
                 $item['attributes']['class'][] = 'active';
             }
             $items[] = $item;
             $item = [];
             $item['label'] = rex_i18n::msg('yform_updatetable_with_delete');
             $item['url'] = $context->getUrl(['table_name' => $table->getTableName(), 'func' => 'updatetablewithdelete']);
             $item['attributes']['class'][] = 'btn-default';
             if (rex_request('func', 'string') == 'updatetablewithdelete') {
                 $item['attributes']['class'][] = 'active';
             }
             $item['attributes']['onclick'][] = 'return confirm(\'' . rex_i18n::msg('yform_updatetable_with_delete_confirm') . '\')';
             $items[] = $item;
             $fragment = new rex_fragment();
             $fragment->setVar('buttons', $items, false);
             $fragment->setVar('size', 'xs', false);
             $panel_options = $fragment->parse('core/buttons/button_group.php');
             $sql = 'select id, prio, type_id, type_name, name from ' . rex_yform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" order by prio';
             $list = rex_list::factory($sql, 30);
             // $list->debug = 1;
             // $list->setColumnFormat('id', 'Id');
             $tdIcon = '<i class="rex-icon rex-icon-table"></i>';
             $thIcon = '<a href="' . $list->getUrl(['table_name' => $table->getTableName(), 'func' => 'choosenadd']) . '"' . rex::getAccesskey(rex_i18n::msg('add'), 'add') . '><i class="rex-icon rex-icon-add"></i></a>';
             $list->addColumn($thIcon, $tdIcon, 0, ['<th class="rex-table-icon">###VALUE###</th>', '<td class="rex-table-icon">###VALUE###</td>']);
             $list->setColumnParams($thIcon, ['field_id' => '###id###', 'func' => 'edit', 'type_name' => '###type_name###', 'type_id' => '###type_id###']);
             foreach ($this->getLinkVars() as $k => $v) {
                 $list->addParam($k, $v);
             }
             $list->addParam('start', rex_request('start', 'int'));
             $list->addParam('table_name', $table->getTableName());
             $list->removeColumn('id');
             $list->setColumnLabel('prio', rex_i18n::msg('yform_manager_table_prio_short'));
             //$list->setColumnLayout('prio', ['<th class="rex-table-priority">###VALUE###</th>', '<td class="rex-table-priority" data-title="' . rex_i18n::msg('yform_manager_table_prio_short') . '">###VALUE###</td>']);
             $list->setColumnLayout('prio', array('<th>###VALUE###</th>', '###VALUE###'));
             $list->setColumnFormat('prio', 'custom', 'rex_yform_list_format');
             $list->setColumnLabel('type_id', rex_i18n::msg('yform_manager_type_id'));
             $list->setColumnLayout('type_id', array('<th>###VALUE###</th>', '###VALUE###'));
             $list->setColumnFormat('type_id', 'custom', 'rex_yform_list_format');
             $list->setColumnLabel('type_name', rex_i18n::msg('yform_manager_type_name'));
             $list->setColumnLayout('type_name', array('<th>###VALUE###</th>', '###VALUE###'));
             $list->setColumnFormat('type_name', 'custom', 'rex_yform_list_format');
             $list->setColumnLabel('name', rex_i18n::msg('yform_manager_name'));
             $list->setColumnLayout('name', array('<th>###VALUE###</th>', '###VALUE###'));
             // ###VALUE###
             $list->setColumnFormat('name', 'custom', 'rex_yform_list_format');
             $list->addColumn(rex_i18n::msg('yform_function'), '<i class="rex-icon rex-icon-edit"></i> ' . rex_i18n::msg('yform_edit'));
             $list->setColumnParams(rex_i18n::msg('yform_function'), array('field_id' => '###id###', 'func' => 'edit', 'type_name' => '###type_name###', 'type_id' => '###type_id###'));
             $list->setColumnLayout(rex_i18n::msg('yform_function'), array('<th class="rex-table-action" colspan="2">###VALUE###</th>', '###VALUE###'));
             $list->setColumnFormat(rex_i18n::msg('yform_function'), 'custom', 'rex_yform_list_edit_format');
             $list->addColumn(rex_i18n::msg('yform_delete'), '<i class="rex-icon rex-icon-delete"></i> ' . rex_i18n::msg('yform_delete'));
             $list->setColumnParams(rex_i18n::msg('yform_delete'), array('field_id' => '###id###', 'func' => 'delete'));
             $list->setColumnLayout(rex_i18n::msg('yform_delete'), array('', '###VALUE###'));
             $list->setColumnFormat(rex_i18n::msg('yform_delete'), 'custom', 'rex_yform_list_delete_format');
             $list->addLinkAttribute(rex_i18n::msg('yform_delete'), 'onclick', 'return confirm(\' [###type_id###, ###type_name###, ###name###] ' . rex_i18n::msg('yform_delete') . ' ?\')');
             $content = $list->get();
             $fragment = new rex_fragment();
             $fragment->setVar('title', rex_i18n::msg('yform_manager_tablefield_overview'));
             $fragment->setVar('options', $panel_options, false);
             $fragment->setVar('content', $content, false);
             $content = $fragment->parse('core/page/section.php');
             echo $content;
         }
     }
 }
Ejemplo n.º 30
0
 protected function _get()
 {
     $class = $this->formatClass();
     $class = $class == '' ? '' : ' ' . $class;
     $formElements = [];
     $n = [];
     $n['header'] = $this->getHeader();
     $n['id'] = '';
     //$n['class']     = $class;
     $n['label'] = $this->formatLabel();
     $n['before'] = $this->getPrefix();
     $n['field'] = $this->formatElement();
     $n['after'] = $this->getSuffix();
     $n['note'] = $this->formatNotice();
     $n['footer'] = $this->getFooter();
     $formElements[] = $n;
     $fragment = new rex_fragment();
     $fragment->setVar('elements', $formElements, false);
     return $fragment->parse($this->getFragment());
 }