protected function getOutput()
 {
     $id = $this->getArg('id', 0, true);
     if (!in_array($this->getContext(), ['module', 'action']) || !is_numeric($id) || $id < 1 || $id > 20) {
         return false;
     }
     $value = $this->getContextData()->getValue('value' . $id);
     if ($this->hasArg('isset') && $this->getArg('isset')) {
         return $value ? 'true' : 'false';
     }
     if ($this->hasArg('widget') && $this->getArg('widget')) {
         if (!$this->environmentIs(self::ENV_INPUT)) {
             return false;
         }
         $select = new rex_category_select();
         if ($this->hasArg('multiple') && $this->getArg('multiple')) {
             $select->setName('REX_INPUT_VALUE[' . $id . '][]');
             $select->setMultiple();
             $select->setSelected(rex_var::toArray($value));
         } else {
             $select->setName('REX_INPUT_VALUE[' . $id . ']');
             $select->setSelected($value);
         }
         if ($this->hasArg('root') && $this->getArg('root')) {
             $select->setRootId(explode(',', $this->getArg('root')));
         }
         $widget = '<div class="rex-select-style">' . $select->get() . '</div>';
         if ($this->hasArg('output') && $this->getArg('output')) {
             $label = $this->hasArg('label') ? $this->getArg('label') : '';
             $widget = Dao::getForm($widget, $label, $this->getArg('output'));
         }
         return self::quote($widget);
     }
     return self::quote(htmlspecialchars($value));
 }
 static function replaceVars($template, $er = array())
 {
     $r = rex_extension::registerPoint(new rex_extension_point('YFORM_EMAIL_BEFORE_REPLACEVARS', ['template' => $template, 'search_replace' => $er, 'status' => false]));
     $template = $r['template'];
     $er = $r['search_replace'];
     $status = $r['status'];
     if ($status) {
         return true;
     }
     $er['REX_SERVER'] = rex::getServer();
     $er['REX_ERROR_EMAIL'] = rex::getErrorEmail();
     $er['REX_SERVERNAME'] = rex::getServerName();
     $er['REX_NOTFOUND_ARTICLE_ID'] = rex_article::getNotfoundArticleId();
     $er['REX_ARTICLE_ID'] = rex_article::getCurrentId();
     $template['body'] = rex_var::parse($template['body'], '', 'yform_email_template', $er);
     $template['body_html'] = rex_var::parse($template['body_html'], '', 'yform_email_template', $er);
     // rex_vars bug: sonst wird der Zeilenumbruch entfernt - wenn DATA_VAR am Ende einer Zeile
     if (rex_string::versionCompare(rex::getVersion(), '5.0.1', '<')) {
         $template['body'] = str_replace("?>\r", "?>\r\n\r", $template['body']);
         $template['body'] = str_replace("?>\n", "?>\n\r\n", $template['body']);
         $template['body_html'] = str_replace("?>\r", "?>\r\n\r", $template['body_html']);
         $template['body_html'] = str_replace("?>\n", "?>\n\r\n", $template['body_html']);
     }
     $template['body'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/body', $template['body']));
     $template['body_html'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/body_html', $template['body_html']));
     return $template;
 }
 /**
  * @see rex_var::handleDefaultParam
  */
 function handleDefaultParam($varname, $args, $name, $value)
 {
     switch ($name) {
         case '1':
         case 'category':
             $args['category'] = (int) $value;
             break;
     }
     return parent::handleDefaultParam($varname, $args, $name, $value);
 }
 /**
  * @see rex_var::handleDefaultParam
  */
 function handleDefaultParam($varname, $args, $name, $value)
 {
     switch ($name) {
         case 'field':
             $args['field'] = (string) $value;
             break;
         case 'clang':
             $args['clang'] = (int) $value;
             break;
     }
     return parent::handleDefaultParam($varname, $args, $name, $value);
 }
Beispiel #5
0
 public function exec($type)
 {
     if (!in_array($type, [self::PREVIEW, self::PRESAVE, self::POSTSAVE])) {
         throw new InvalidArgumentException('$type musst be rex_article_action::PREVIEW, ::PRESAVE or ::POSTSAVE');
     }
     $this->messages = [];
     $this->save = true;
     $ga = rex_sql::factory();
     $ga->setQuery('SELECT a.id, `' . $type . '` as code FROM ' . rex::getTable('module_action') . ' ma,' . rex::getTable('action') . ' a WHERE `' . $type . '` != "" AND ma.action_id=a.id AND module_id=? AND (a.' . $type . 'mode & ?)', [$this->moduleId, $this->mode]);
     foreach ($ga as $row) {
         $action = $row->getValue('code');
         $action = str_replace($this->vars['search'], $this->vars['replace'], $action);
         $action = rex_var::parse($action, rex_var::ENV_BACKEND | rex_var::ENV_INPUT, 'action', $this->sql);
         require rex_stream::factory('action/' . $row->getValue('id') . '/' . $type, $action);
     }
 }
 function getBEOutput(&$sql, $content)
 {
     $var = 'REX_DATA';
     $matches = $this->getVarParams($content, $var);
     foreach ($matches as $match) {
         list($param_str, $args) = $match;
         list($field, $args) = $this->extractArg('field', $args, 0);
         if ($field != '') {
             $varname = '$__rex_data';
             // $varname = str_replace('"', '\"', $varname);
             $value = '';
             $value = rex_var::handleGlobalVarParams($varname, $args, $sql->getValue($field));
             $content = str_replace($var . '[' . $param_str . ']', $value, $content);
         }
     }
     return $content;
 }
Beispiel #7
0
 public function generate()
 {
     $template_id = $this->getId();
     if ($template_id < 1) {
         return false;
     }
     $sql = rex_sql::factory();
     $qry = 'SELECT * FROM ' . rex::getTablePrefix() . 'template WHERE id = ' . $template_id;
     $sql->setQuery($qry);
     if ($sql->getRows() == 1) {
         $templateFile = self::getFilePath($template_id);
         $content = $sql->getValue('content');
         $content = rex_var::parse($content, rex_var::ENV_FRONTEND, 'template');
         if (rex_file::put($templateFile, $content) !== false) {
             return true;
         } else {
             throw new rex_exception('Unable to generate template ' . $template_id . '!');
         }
     } else {
         throw new rex_exception('Template with id "' . $template_id . '" does not exist!');
     }
 }
 function getBEOutput(&$sql, $content)
 {
     global $REX;
     $var = 'REX_DATA';
     $matches = $this->getVarParams($content, $var);
     foreach ($matches as $match) {
         list($param_str, $args) = $match;
         //list ($field, $args) = $this->extractArg('field', $args, 0);
         $field = $args['field'];
         if ($field != "") {
             $varname = '$__rex_data';
             // $varname = str_replace('"', '\"', $varname);
             $value = "";
             $suffix = '';
             if (isset($args['translate']) && $args['translate'] == "1" && $REX['CUR_CLANG'] >= 1) {
                 $suffix = '_' . $REX['CUR_CLANG'];
                 $value = rex_var::handleGlobalVarParams($varname, $args, $sql->getValue($field . $suffix));
             }
             if ($value == '') {
                 // Fallback, falls Feld fuer SPrache nciht gefuellt ist
                 $value = rex_var::handleGlobalVarParams($varname, $args, $sql->getValue($field));
             }
             $content = str_replace($var . '[' . $param_str . ']', $value, $content);
         }
     }
     return $content;
 }
Beispiel #9
0
 protected function replaceObjectVars(rex_sql $sql, $content)
 {
     $sliceId = $sql->getValue(rex::getTablePrefix() . 'article_slice.id');
     if ($this->mode == 'edit') {
         $env = rex_var::ENV_BACKEND;
         if ($this->function == 'add' && $sliceId == null || $this->function == 'edit' && $sliceId == $this->slice_id) {
             $env = $env | rex_var::ENV_INPUT;
         }
     } else {
         $env = rex_var::ENV_FRONTEND;
     }
     $content = rex_var::parse($content, $env, 'module', $sql);
     return $content;
 }
 function handleDefaultParam($varname, $args, $name, $value)
 {
     switch ($name) {
         case '0':
             $args['id'] = (int) $value;
             break;
         case '1':
         case 'category':
             $args['category'] = (int) $value;
             break;
         case 'types':
             $args[$name] = (string) $value;
             break;
         case 'preview':
             $args[$name] = (bool) $value;
             break;
         case 'mimetype':
             $args[$name] = (string) $value;
             break;
     }
     return parent::handleDefaultParam($varname, $args, $name, $value);
 }
 function set_selectextra($extra)
 {
     foreach (rex_var::splitString($extra) as $name => $value) {
         $this->setAttribute($name, $value);
     }
 }
 protected function getOutput()
 {
     $id = $this->getArg('id', 0, true);
     if (!in_array($this->getContext(), ['module', 'action']) || !is_numeric($id) || $id < 1 || $id > 20) {
         return false;
     }
     $value = $this->getContextData()->getValue('value' . $id);
     if ($this->hasArg('isset') && $this->getArg('isset')) {
         return $value ? 'true' : 'false';
     }
     if ($this->hasArg('widget') && $this->getArg('widget')) {
         if (!$this->environmentIs(self::ENV_INPUT)) {
             return false;
         }
         $select = new rex_select();
         if ($this->hasArg('multiple') && $this->getArg('options')) {
             $select->setName('REX_INPUT_VALUE[' . $id . '][]');
             $select->setMultiple();
             $select->setSelected(rex_var::toArray($value));
         } else {
             $select->setName('REX_INPUT_VALUE[' . $id . ']');
             $select->setSelected($value);
         }
         if ($this->hasArg('options') && $this->getArg('options')) {
             $options = $this->getArg('options');
             if (rex_sql::getQueryType($options) == 'SELECT') {
                 $select->addSqlOptions($options);
             } else {
                 $groups = explode('|', $options);
                 if (count($groups)) {
                     foreach ($groups as $group) {
                         $parseGroup = explode(':', $group);
                         $groupOptions = $parseGroup[0];
                         if (count($parseGroup) == 2) {
                             $select->addOptgroup($parseGroup[0]);
                             $groupOptions = $parseGroup[1];
                         }
                         if (rex_sql::getQueryType($groupOptions) == 'SELECT') {
                             $select->addSqlOptions($groupOptions);
                         } else {
                             $groupOptions = explode(',', $groupOptions);
                             if (count($groupOptions)) {
                                 foreach ($groupOptions as $groupOption) {
                                     $optionPair = explode('=', $groupOption);
                                     if (count($optionPair) == 1) {
                                         $select->addOption($optionPair[0], $optionPair[0]);
                                     } elseif (count($optionPair) == 2) {
                                         $select->addOption($optionPair[0], $optionPair[1]);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $widget = '<div class="rex-select-style">' . $select->get() . '</div>';
         if ($this->hasArg('output') && $this->getArg('output')) {
             $label = $this->hasArg('label') ? $this->getArg('label') : '';
             $widget = Dao::getForm($widget, $label, $this->getArg('output'));
         }
         return self::quote($widget);
     }
     return self::quote(htmlspecialchars($value));
 }
Beispiel #13
0
 /**
  * Parses all REX_VARs in the given content.
  *
  * @param string $content     Content
  * @param int    $env         Environment
  * @param string $context     Context
  * @param mixed  $contextData Context data
  *
  * @return string
  */
 public static function parse($content, $env = null, $context = null, $contextData = null)
 {
     if (($env & self::ENV_INPUT) != self::ENV_INPUT) {
         $env = $env | self::ENV_OUTPUT;
     }
     self::$env = $env;
     self::$context = $context;
     self::$contextData = $contextData;
     $tokens = token_get_all($content);
     $countTokens = count($tokens);
     $content = '';
     for ($i = 0; $i < $countTokens; ++$i) {
         $token = $tokens[$i];
         if (is_string($token)) {
             $add = $token;
         } else {
             $add = $token[1];
             if (in_array($token[0], [T_INLINE_HTML, T_CONSTANT_ENCAPSED_STRING, T_STRING, T_START_HEREDOC])) {
                 $useVariables = false;
                 $stripslashes = null;
                 switch ($token[0]) {
                     case T_INLINE_HTML:
                         $format = '<?= %s ?>';
                         break;
                     case T_CONSTANT_ENCAPSED_STRING:
                         $format = $token[1][0] == '"' ? '" . %s . "' : "' . %s . '";
                         $stripslashes = $token[1][0];
                         break;
                     case T_STRING:
                         while (isset($tokens[++$i]) && (is_string($tokens[$i]) && in_array($tokens[$i], ['=', '[', ']']) || in_array($tokens[$i][0], [T_WHITESPACE, T_STRING, T_CONSTANT_ENCAPSED_STRING, T_LNUMBER, T_ISSET]))) {
                             $add .= is_string($tokens[$i]) ? $tokens[$i] : $tokens[$i][1];
                         }
                         --$i;
                         $format = '%s';
                         break;
                     case T_START_HEREDOC:
                         while (isset($tokens[++$i]) && (is_string($tokens[$i]) || $tokens[$i][0] != T_END_HEREDOC)) {
                             $add .= is_string($tokens[$i]) ? $tokens[$i] : $tokens[$i][1];
                         }
                         --$i;
                         if (preg_match("/'(.*)'/", $token[1], $match)) {
                             // nowdoc
                             $format = "\n" . $match[1] . "\n. %s . <<<'" . $match[1] . "'\n";
                         } else {
                             // heredoc
                             $format = '{%s}';
                             $useVariables = true;
                         }
                         break;
                 }
                 $add = self::replaceVars($add, $format, $useVariables, $stripslashes);
                 if ($token[0] == T_CONSTANT_ENCAPSED_STRING) {
                     $start = substr($add, 0, 5);
                     $end = substr($add, -5);
                     if ($start == '"" . ' || $start == "'' . ") {
                         $add = substr($add, 5);
                     }
                     if ($end == ' . ""' || $end == " . ''") {
                         $add = substr($add, 0, -5);
                     }
                 }
             }
         }
         $content .= $add;
     }
     return $content;
 }
Beispiel #14
0
 protected function getParseOutput($content)
 {
     return rex_file::getOutput(rex_stream::factory('rex-var-test', rex_var::parse($content)));
 }
Beispiel #15
0
 public static function quote($string)
 {
     // make quote() public
     return parent::quote($string);
 }
}
$html_block = array();
$values = array();
$values[1] = rex_var::toArray('REX_VALUE[1]');
$values[1]['media_1'] = 'REX_MEDIA[id=1 output=1]';
$values[1]['link_intern'] = 'REX_LINK[id=1 output="id"]';
$values[1]['medialist_1'] = 'REX_MEDIALIST[id=1 output=1]';
$values[2] = rex_var::toArray('REX_VALUE[2]');
$values[2]['media_1'] = 'REX_MEDIA[id=2 output=1]';
$values[2]['link_intern'] = 'REX_LINK[id=2 output="id"]';
$values[2]['medialist_1'] = 'REX_MEDIALIST[id=2 output=1]';
$values[3] = rex_var::toArray('REX_VALUE[3]');
$values[3]['media_1'] = 'REX_MEDIA[id=3 output=1]';
$values[3]['link_intern'] = 'REX_LINK[id=3 output="id"]';
$values[3]['medialist_1'] = 'REX_MEDIALIST[id=3 output=1]';
$values[4] = rex_var::toArray('REX_VALUE[4]');
$values[4]['media_1'] = 'REX_MEDIA[id=4 output=1]';
$values[4]['link_intern'] = 'REX_LINK[id=4 output="id"]';
$values[4]['medialist_1'] = 'REX_MEDIALIST[id=4 output=1]';
if ($grid == '12') {
    unset($values[2]);
    unset($values[3]);
    unset($values[4]);
}
if ($grid == '6_6' || $grid == '8_4' || $grid == '4_8') {
    unset($values[3]);
    unset($values[4]);
}
if ($grid == '4_4_4' || $grid == '6_3_3' || $grid == '3_6_3' || $grid == '3_3_6') {
    unset($values[4]);
}
 protected function getOutput()
 {
     $id = $this->getArg('id', 0, true);
     if (!in_array($this->getContext(), ['module', 'action']) || !is_numeric($id) || $id < 1 || $id > 20) {
         return false;
     }
     $valueArray = rex_var::toArray($this->getContextData()->getValue('value' . $id));
     $value = isset($valueArray['value']) ? $valueArray['value'] : '';
     $clang = isset($valueArray['clang']) ? $valueArray['clang'] : '';
     $label = isset($valueArray['label']) ? $valueArray['label'] : '';
     if ($this->hasArg('isset') && $this->getArg('isset')) {
         return $value ? 'true' : 'false';
     }
     if ($this->hasArg('widget') && $this->getArg('widget')) {
         if (!$this->environmentIs(self::ENV_INPUT)) {
             return false;
         }
         $args = [];
         if (!$this->hasArg('linkmap')) {
             $args['linkmap'] = true;
         }
         if (!$this->hasArg('url')) {
             $args['url'] = false;
         }
         if (!$this->hasArg('text')) {
             $args['text'] = false;
         }
         foreach (['category', 'linkmap', 'url', 'text'] as $key) {
             if ($this->hasArg($key)) {
                 $args[$key] = $this->getArg($key);
             }
         }
         $widget = self::getWidget($id, 'REX_INPUT_VALUE[' . $id . '][value]', $valueArray, $args);
         $label = $this->hasArg('label') ? $this->getArg('label') : '';
         $widget = Dao::getForm($widget, $label, $this->getArg('output'));
         return self::quote($widget);
     } elseif ($this->hasArg('output') && $this->getArg('output')) {
         if (is_numeric($value)) {
             if ($label == '') {
                 $art = rex_article::get($value);
                 if ($art instanceof rex_article) {
                     $label = $art->getName();
                 }
             }
             $value = rex_getUrl($value, $clang);
         } else {
             if ($label == '') {
                 $label = $value;
             }
         }
         if ($this->getArg('output') == 'link') {
             $class = '';
             if ($this->hasArg('class')) {
                 $class = ' class="' . $this->getArg('class') . '"';
             }
             return self::quote('<a' . $class . ' href="' . $value . '">' . $label . '</a>');
         } else {
             return self::quote($value);
         }
     }
     return self::quote(json_encode($valueArray));
 }
    function outputSlice($artDataSql, $module_id, $I_ID, $RE_CONTS, $RE_CONTS_CTYPE, $RE_MODUL_IN, $RE_MODUL_OUT, $RE_MODUL_ID, $RE_MODUL_NAME, $RE_C)
    {
        global $REX, $I18N;
        if ($this->mode == 'edit') {
            $form_url = 'index.php#addslice';
            // ----- add select box einbauen
            if ($this->function == 'add' && $this->slice_id == $I_ID) {
                $slice_content = $this->addSlice($I_ID, $module_id);
            } else {
                // ----- BLOCKAUSWAHL - SELECT
                $this->MODULESELECT[$this->ctype]->setId('module_id' . $I_ID);
                $slice_content = '
                            <div class="rex-form rex-form-content-editmode">
                            <form action="' . $form_url . '" method="get" id="slice' . $RE_CONTS[$I_ID] . '">
                                <fieldset class="rex-form-col-1">
                                    <legend><span>' . $I18N->msg('add_block') . '</span></legend>
                                    <input type="hidden" name="article_id" value="' . $this->article_id . '" />
                                    <input type="hidden" name="page" value="content" />
                                    <input type="hidden" name="mode" value="' . $this->mode . '" />
                                    <input type="hidden" name="slice_id" value="' . $I_ID . '" />
                                    <input type="hidden" name="function" value="add" />
                                    <input type="hidden" name="clang" value="' . $this->clang . '" />
                                    <input type="hidden" name="ctype" value="' . $this->ctype . '" />

                                    <div class="rex-form-wrapper">
                                        <div class="rex-form-row">
                                            <p class="rex-form-col-a rex-form-select">
                                                ' . $this->MODULESELECT[$this->ctype]->get() . '
                                                <noscript><input class="rex-form-submit" type="submit" name="btn_add" value="' . $I18N->msg('add_block') . '" /></noscript>
                                            </p>
                                        </div>
                                    </div>
                                </fieldset>
                            </form>
                            </div>';
            }
            // ----- Slicemenue
            $sliceUrl = 'index.php?page=content&amp;article_id=' . $this->article_id . '&amp;mode=edit&amp;slice_id=' . $RE_CONTS[$I_ID] . '&amp;clang=' . $this->clang . '&amp;ctype=' . $this->ctype . '%s#slice' . $RE_CONTS[$I_ID];
            $listElements = array();
            if ($REX['USER']->isAdmin() || $REX['USER']->hasPerm('module[' . $RE_MODUL_ID[$I_ID] . ']')) {
                $templateHasModule = rex_template::hasModule($this->template_attributes, $this->ctype, $RE_MODUL_ID[$I_ID]);
                if ($templateHasModule) {
                    $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;function=edit') . '" class="rex-tx3">' . $I18N->msg('edit') . ' <span>' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                }
                $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;function=delete&amp;save=1') . '" class="rex-tx2" onclick="return confirm(\'' . $I18N->msg('delete') . ' ?\')">' . $I18N->msg('delete') . ' <span>' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                if ($templateHasModule && $REX['USER']->hasPerm('moveSlice[]')) {
                    $moveUp = $I18N->msg('move_slice_up');
                    $moveDown = $I18N->msg('move_slice_down');
                    // upd stamp uebergeben, da sonst ein block nicht mehrfach hintereindander verschoben werden kann
                    // (Links waeren sonst gleich und der Browser laesst das klicken auf den gleichen Link nicht zu)
                    $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;upd=' . time() . '&amp;function=moveup') . '" title="' . $moveUp . '" class="rex-slice-move-up"><span>' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                    $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;upd=' . time() . '&amp;function=movedown') . '" title="' . $moveDown . '" class="rex-slice-move-down"><span>' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                }
            } else {
                $listElements[] = '<b class="rex-tx2">' . $I18N->msg('no_editing_rights') . ' <span>' . $RE_MODUL_NAME[$I_ID] . '</span></b>';
            }
            // ----- EXTENSION POINT
            $listElements = rex_register_extension_point('ART_SLICE_MENU', $listElements, array('article_id' => $this->article_id, 'clang' => $this->clang, 'ctype' => $RE_CONTS_CTYPE[$I_ID], 'module_id' => $RE_MODUL_ID[$I_ID], 'slice_id' => $RE_CONTS[$I_ID], 'perm' => $REX['USER']->isAdmin() || $REX['USER']->hasPerm('module[' . $RE_MODUL_ID[$I_ID] . ']')));
            $mne = '';
            if ($this->function == 'edit' && $this->slice_id == $RE_CONTS[$I_ID]) {
                $mne .= '<div class="rex-content-editmode-module-name rex-form-content-editmode-edit-slice">';
            } else {
                $mne .= '<div class="rex-content-editmode-module-name">';
            }
            $mne .= '
                            <h3 class="rex-hl4">' . rex_translate($RE_MODUL_NAME[$I_ID]) . '</h3>
                            <div class="rex-navi-slice">
                                <ul>
                        ';
            $listElementFlag = true;
            foreach ($listElements as $listElement) {
                $class = '';
                if ($listElementFlag) {
                    $class = ' class="rex-navi-first"';
                    if (count($listElements) == 1) {
                        $class = ' class="rex-navi-first rex-navi-onlyone"';
                    }
                    $listElementFlag = false;
                }
                $mne .= '<li' . $class . '>' . $listElement . '</li>';
            }
            $mne .= '</ul></div></div>';
            // ----- EDIT/DELETE BLOCK - Wenn Rechte vorhanden
            if ($REX['USER']->isAdmin() || $REX['USER']->hasPerm('module[' . $RE_MODUL_ID[$I_ID] . ']')) {
                $msg = '';
                if ($this->function != 'add' && $this->slice_id == $RE_CONTS[$I_ID]) {
                    if ($this->warning != '') {
                        $msg .= rex_warning($this->warning);
                    }
                    if ($this->info != '') {
                        $msg .= rex_info($this->info);
                    }
                }
                $slice_content .= $msg . $mne;
                if ($this->function == 'edit' && $this->slice_id == $RE_CONTS[$I_ID]) {
                    // **************** Aktueller Slice
                    $REX_ACTION = array();
                    // nach klick auf den übernehmen button,
                    // die POST werte übernehmen
                    if (rex_request_method() == 'post' && rex_var::isEditEvent()) {
                        foreach ($REX['VARIABLES'] as $obj) {
                            $REX_ACTION = $obj->getACRequestValues($REX_ACTION);
                        }
                    } else {
                        foreach ($REX['VARIABLES'] as $obj) {
                            $REX_ACTION = $obj->getACDatabaseValues($REX_ACTION, $artDataSql);
                        }
                    }
                    // ----- PRE VIEW ACTION [EDIT]
                    $REX_ACTION = rex_execPreViewAction($RE_MODUL_ID[$I_ID], 'edit', $REX_ACTION);
                    // ----- / PRE VIEW ACTION
                    // ****************** Action Werte in SQL-Objekt uebernehmen
                    foreach ($REX['VARIABLES'] as $obj) {
                        $obj->setACValues($artDataSql, $REX_ACTION);
                    }
                    $slice_content .= $this->editSlice($RE_CONTS[$I_ID], $RE_MODUL_IN[$I_ID], $RE_CONTS_CTYPE[$I_ID], $RE_MODUL_ID[$I_ID]);
                    $slice_content = $this->replaceVars($artDataSql, $slice_content);
                } else {
                    // Modulinhalt ausgeben
                    $slice_content .= '
                                <!-- *** OUTPUT OF MODULE-OUTPUT - START *** -->
                                <div class="rex-content-editmode-slice-output">
                                    <div class="rex-content-editmode-slice-output-2">
                                        ' . $RE_MODUL_OUT[$I_ID] . '
                                    </div>
                                </div>
                                <!-- *** OUTPUT OF MODULE-OUTPUT - END *** -->
                                ';
                    $slice_content = $this->replaceVars($artDataSql, $slice_content);
                }
            } else {
                // ----- hat keine rechte an diesem modul
                $slice_content .= $mne;
                // Modulinhalt ausgeben
                $slice_content .= '
                                <!-- *** OUTPUT OF MODULE-OUTPUT - START *** -->
                                <div class="rex-content-editmode-slice-output">
                                    <div class="rex-content-editmode-slice-output-2">
                                        ' . $RE_MODUL_OUT[$I_ID] . '
                                    </div>
                                </div>
                                <!-- *** OUTPUT OF MODULE-OUTPUT - END *** -->
                                ';
                // $slice_content .= $mne. $RE_MODUL_OUT[$I_ID];
                $slice_content = $this->replaceVars($artDataSql, $slice_content);
            }
        } else {
            // ----- wenn mode nicht edit
            $slice_content = parent::outputSlice($artDataSql, $module_id, $I_ID, $RE_CONTS, $RE_CONTS_CTYPE, $RE_MODUL_IN, $RE_MODUL_OUT, $RE_MODUL_ID, $RE_MODUL_NAME, $RE_C);
        }
        return $slice_content;
    }
    protected function getOutput()
    {
        $id = $this->getArg('id', 0, true);
        if (!in_array($this->getContext(), ['module', 'action']) || !is_numeric($id) || $id < 1 || $id > 20) {
            return false;
        }
        $value = $this->getContextData()->getValue('value' . $id);
        if ($this->hasArg('isset') && $this->getArg('isset')) {
            return $value ? 'true' : 'false';
        }
        if ($this->hasArg('widget') && $this->getArg('widget')) {
            if (!$this->environmentIs(self::ENV_INPUT)) {
                return false;
            }
            $value = rex_var::toArray($value);
            echo '<pre>';
            print_r($value);
            echo '</pre>';
            $initHeadRows = $this->hasArg('trows') ? $this->getArg('trows') : self::$initHeadRows;
            $initFootRows = $this->hasArg('frows') ? $this->getArg('frows') : self::$initFootRows;
            $initBodyRows = $this->hasArg('rows') ? $this->getArg('rows') : self::$initBodyRows;
            $initCols = $this->hasArg('cols') ? $this->getArg('cols') : self::$initCols;
            $initTitleCols = $this->hasArg('tcols') ? $this->getArg('tcols') : self::$initTitleCols;
            if (count($value) == 0) {
                $appendCols = array_fill(1, $initCols, '');
                if ($initHeadRows > 0) {
                    $value['thead'] = array_fill(1, $initHeadRows, $appendCols);
                }
                if ($initFootRows > 0) {
                    $value['tfoot'] = array_fill(1, $initFootRows, $appendCols);
                }
                $value['tbody'] = array_fill(1, $initBodyRows, $appendCols);
            }
            $table = '';
            $table .= '<table id="toolbox">
				<tbody>
					<tr>
						<td>
							<span class="btn btn-apply" onclick="redips.merge()" title="Merge marked table cells horizontally and verically">Merge</span>
						</td>
						<td>
							<span class="btn btn-apply" onclick="redips.split(\'h\')" title="Split marked table cell horizontally">Split H</span>
							<span class="btn btn-apply" onclick="redips.split(\'v\')" title="Split marked table cell vertically">Split V</span>
						</td>
						<td>
							<span class="btn btn-apply" onclick="redips.row(\'insert\')" title="Add table row">Row +</span>
							<span class="btn btn-apply" onclick="redips.row(\'delete\')" title="Delete table row">Row -</span>
						</td>
						<td>
							<span class="btn btn-apply" onclick="redips.column(\'insert\')" title="Add table column">Col +</span>
							<span class="btn btn-apply" onclick="redips.column(\'delete\')" title="Delete table column">Col -</span>
						</td>
					</tr>
				</tbody>
			</table>';
            $table .= '<table id="dao-table" class="dao-table table table-bordered">';
            $rows = isset($value['thead']) ? $value['thead'] : [];
            $table .= $this->getTableGroup($id, 'thead', $rows, $initHeadRows, $initCols);
            $rows = isset($value['tfoot']) ? $value['tfoot'] : [];
            $table .= $this->getTableGroup($id, 'tfoot', $rows, $initFootRows, $initCols);
            $rows = $value['tbody'];
            $table .= $this->getTableGroup($id, 'tbody', $rows, $initBodyRows, $initCols, $initTitleCols);
            $table .= '</table>';
            $table .= '
            <script>

//$(document).on("rex:ready", function (event, container) {
//jQuery(function($) {
getCellCoords = function (table) {
		var matrix = [],
			matrixrow,
			lookup = {},
			c,			// current cell
			ri,			// row index
			rowspan,
			colspan,
			firstAvailCol,
			tr,			// TR collection
			i, j, k, l;	// loop variables
		// set HTML collection of table rows
		tr = table.rows;
		// open loop for each TR element
		for (i = 0; i < tr.length; i++) {
			// open loop for each cell within current row
			for (j = 0; j < tr[i].cells.length; j++) {
				// define current cell
				c = tr[i].cells[j];
				// set row index
				ri = c.parentNode.rowIndex;
				// define cell rowspan and colspan values
				rowspan = c.rowSpan || 1;
				colspan = c.colSpan || 1;
				// if matrix for row index is not defined then initialize array
				matrix[ri] = matrix[ri] || [];
				// find first available column in the first row
				for (k = 0; k < matrix[ri].length + 1; k++) {
					if (typeof(matrix[ri][k]) === "undefined") {
						firstAvailCol = k;
						break;
					}
				}
				// set cell coordinates and reference to the table cell
				lookup[ri + "-" + firstAvailCol] = c;
				for (k = ri; k < ri + rowspan; k++) {
					matrix[k] = matrix[k] || [];
					matrixrow = matrix[k];
					for (l = firstAvailCol; l < firstAvailCol + colspan; l++) {
						matrixrow[l] = "x";
					}
				}
			}
		}
		return lookup;
	};

    // create redips container
    var redips = {};
    var tbl = document.getElementById("dao-table");
    var id = ' . $id . ';


    // REDIPS.table initialization
    redips.init = function () {
        // define reference to the REDIPS.table object
        var rt = REDIPS.table;
        // activate onmousedown event listener on cells within table with id="mainTable"
        rt.onmousedown(tbl, true);
        // show cellIndex (it is nice for debugging)
        // rt.cell_index(false);
        // define background color for marked cell
        rt.color.cell = "#9BB3DA";
        redips.updateTable("init");
    };


    // function merges table cells
    redips.merge = function () {
        // first merge cells horizontally and leave cells marked
        REDIPS.table.merge("h", false);
        // and then merge cells vertically and clear cells (second parameter is true by default)
        REDIPS.table.merge("v", false);
        redips.updateTable("merge");
    };


    // function splits table cells if colspan/rowspan is greater then 1
    // mode is "h" or "v" (cells should be marked before)
    redips.split = function (mode) {
        REDIPS.table.split(mode);
        redips.updateTable("split");
    };


    // insert/delete table row
    redips.row = function (type) {
        REDIPS.table.row(tbl, type);
        redips.updateTable(type);
    };


    // insert/delete table column
    redips.column = function (type) {
        REDIPS.table.column(tbl, type);
        redips.updateTable(type);
    };


    redips.updateTable = function (type) {
        console.log(getCellCoords(tbl));
        if (tbl.tHead !== null && tbl.tHead.rows.length > 0) {
            var thead_tr = tbl.tHead.rows;
            redips.updateCell(type, "thead", thead_tr);
        }

        if (tbl.tBodies !== null && tbl.tBodies[0].rows.length > 0) {
            var tbody_tr = tbl.tBodies[0].rows;
            redips.updateCell(type, "tbody", tbody_tr);
        }

        if (tbl.tFoot !== null && tbl.tFoot.rows.length > 0) {
            var tfoot_tr = tbl.tFoot.rows;
            redips.updateCell(type, "tfoot", tfoot_tr);
        }

    }
    redips.updateCell = function (type, group, rows) {
        // local variable
        var r, c, numberOfRows, numberOfCells, cell, cellContent;
        numberOfRows = rows.length;
        // loop through all TD elements
        for (r = 0; r < numberOfRows; r++) {
            numberOfCells = rows[r].cells.length;
            // loop through all TD elements
            var $cIndex = -1;
            for (c = 0; c < numberOfCells; c++) {
                cell = rows[r].cells[c];
                $cIndex++;
                if (cell.colSpan > 1) {
                    $cIndex = $cIndex + cell.colSpan - 1;
                }

                // ignore thead and tfoot
                // no merge and split
                if (group == "thead" || group == "tfoot") {
                    REDIPS.table.cell_ignore(cell);
                }

                if (type == "init" || type == "insert" || type == "split") {
                    if (cell.innerHTML == "") {
                        //cell.innerHTML += \'<input type="hidden" name="REX_INPUT_VALUE[\'+ id + \'][\'+ group + \'][\'+ r + \'][\'+ c + \'][colspan]" value="\' + cell.colSpan + \'" />\';
                        //cell.innerHTML += \'<input type="hidden" name="REX_INPUT_VALUE[\'+ id + \'][\'+ group + \'][\'+ r + \'][\'+ c + \'][rowspan]" value="\' + cell.rowSpan + \'" />\';
                        cell.innerHTML += \'<textarea name="REX_INPUT_VALUE[\'+ id + \'][\'+ group + \'][\'+ r + \'][\'+ $cIndex + \'][cell]"></textarea>\';
                    }
                }
                if (type == "merge" && cell.redips && cell.redips.selected === true) {
                    var textarea = cell.getElementsByTagName("TEXTAREA");
                    var j;
                    var content = "";
                    for (j = 0; j < textarea.length; j++) {
                        content += textarea[j].value;
                    }
                    cell.innerHTML = "";
                    //cell.innerHTML += \'<input title="" name="REX_INPUT_VALUE[\'+ id + \'][\'+ group + \'][\'+ r + \'][\'+ c + \'][colspan]" value="\' + cell.colSpan + \'" type="hidden" />\';
                    //cell.innerHTML += \'<input    name="REX_INPUT_VALUE[\'+ id + \'][\'+ group + \'][\'+ r + \'][\'+ c + \'][rowspan]" value="\' + cell.rowSpan + \'" type="hidden" />\';
                    cell.innerHTML += \'<textarea name="REX_INPUT_VALUE[\'+ id + \'][\'+ group + \'][\'+ r + \'][\'+ $cIndex + \'][cell]">\' + content + \'</textarea>\';
                    REDIPS.table.mark(false, cell);
                }

                cellContent = cell.getElementsByTagName("TEXTAREA")[0].outerHTML;
                cell.innerHTML = "";
                cell.innerHTML += \'<input name="REX_INPUT_VALUE[\'+ id + \'][\'+ group + \'][\'+ r + \'][\'+ $cIndex + \'][colspan]" value="\' + cell.colSpan + \'" type="hidden" />\';
                cell.innerHTML += \'<input name="REX_INPUT_VALUE[\'+ id + \'][\'+ group + \'][\'+ r + \'][\'+ $cIndex + \'][rowspan]" value="\' + cell.rowSpan + \'" type="hidden" />\';
                cell.innerHTML += cellContent;


                /*
                // if table cell is selected
                if (td[i].redips && td[i].redips.selected === true) {
                    // set value from selected item to the cell content
                    td[i].innerHTML = "text";
                    // unselect TD
                    REDIPS.table.mark(false, td[i]);
                }
                */
            }
        }
    }

    // add onload event listener
    if (window.addEventListener) {
        window.addEventListener("load", redips.init, false);
    }
    else if (window.attachEvent) {
        window.attachEvent("onload", redips.init);
    }
    $(document).on("rex:ready", function (event, container) {
        redips.init();
    });
//});
            </script>';
            $widget = $table;
            if ($this->hasArg('output') && $this->getArg('output')) {
                $label = $this->hasArg('label') ? $this->getArg('label') : '';
                $widget = Dao::getForm($widget, $label, $this->getArg('output'));
            }
            return self::quote($widget);
        }
        return self::quote(htmlspecialchars($value));
    }
    function getArticle($curctype = -1)
    {
        global $module_id, $REX_USER, $REX, $I18N;
        $this->ctype = $curctype;
        $sliceLimit = '';
        if ($this->getSlice) {
            //$REX['GG'] = 0;
            $sliceLimit = " AND " . $REX['TABLE_PREFIX'] . "article_slice.id = '" . $this->getSlice . "' ";
        }
        // ----- start: article caching
        ob_start();
        ob_implicit_flush(0);
        if ($REX['GG'] && !$this->viasql && !$this->getSlice) {
            if ($this->article_id != 0) {
                $this->contents = '';
                $article_content_file = $REX['INCLUDE_PATH'] . '/generated/articles/' . $this->article_id . '.' . $this->clang . '.content';
                if ($cont = rex_get_file_contents($article_content_file)) {
                    $this->contents = $cont;
                    eval($this->contents);
                }
            }
        } else {
            if ($this->article_id != 0) {
                // ---------- alle teile/slices eines artikels auswaehlen
                $sql = "SELECT " . $REX['TABLE_PREFIX'] . "module.id, " . $REX['TABLE_PREFIX'] . "module.name, " . $REX['TABLE_PREFIX'] . "module.ausgabe, " . $REX['TABLE_PREFIX'] . "module.eingabe, " . $REX['TABLE_PREFIX'] . "article_slice.*, " . $REX['TABLE_PREFIX'] . "article.re_id\r\n          FROM\r\n            " . $REX['TABLE_PREFIX'] . "article_slice\r\n          LEFT JOIN " . $REX['TABLE_PREFIX'] . "module ON " . $REX['TABLE_PREFIX'] . "article_slice.modultyp_id=" . $REX['TABLE_PREFIX'] . "module.id\r\n          LEFT JOIN " . $REX['TABLE_PREFIX'] . "article ON " . $REX['TABLE_PREFIX'] . "article_slice.article_id=" . $REX['TABLE_PREFIX'] . "article.id\r\n          WHERE\r\n            " . $REX['TABLE_PREFIX'] . "article_slice.article_id='" . $this->article_id . "' AND\r\n            " . $REX['TABLE_PREFIX'] . "article_slice.clang='" . $this->clang . "' AND\r\n            " . $REX['TABLE_PREFIX'] . "article.clang='" . $this->clang . "'\r\n            " . $sliceLimit . "\r\n            ORDER BY " . $REX['TABLE_PREFIX'] . "article_slice.re_article_slice_id";
                $this->CONT = new rex_sql();
                $this->CONT->debugsql = 0;
                $this->CONT->setQuery($sql);
                $RE_CONTS = array();
                $RE_CONTS_CTYPE = array();
                $RE_MODUL_OUT = array();
                $RE_MODUL_IN = array();
                $RE_MODUL_ID = array();
                $RE_MODUL_NAME = array();
                $RE_C = array();
                // ---------- SLICE IDS/MODUL SETZEN - speichern der daten
                for ($i = 0; $i < $this->CONT->getRows(); $i++) {
                    $RE_CONTS[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'article_slice.id');
                    $RE_CONTS_CTYPE[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'article_slice.ctype');
                    $RE_MODUL_IN[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.eingabe');
                    $RE_MODUL_OUT[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.ausgabe');
                    $RE_MODUL_ID[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.id');
                    $RE_MODUL_NAME[$this->CONT->getValue('re_article_slice_id')] = $this->CONT->getValue($REX['TABLE_PREFIX'] . 'module.name');
                    $RE_C[$this->CONT->getValue('re_article_slice_id')] = $i;
                    $this->CONT->next();
                }
                // ---------- moduleselect: nur module nehmen auf die der user rechte hat
                if ($this->mode == 'edit') {
                    $MODULE = new rex_sql();
                    $MODULE->setQuery('select * from ' . $REX['TABLE_PREFIX'] . 'module order by name');
                    $MODULESELECT = new rex_select();
                    $MODULESELECT->setName('module_id');
                    $MODULESELECT->setSize('1');
                    $MODULESELECT->setAttribute('onchange', 'this.form.submit();');
                    $MODULESELECT->addOption('----------------------------  ' . $I18N->msg('add_block'), '');
                    for ($i = 0; $i < $MODULE->getRows(); $i++) {
                        if ($REX_USER->hasPerm('module[' . $MODULE->getValue('id') . ']') || $REX_USER->hasPerm('admin[]')) {
                            $MODULESELECT->addOption(rex_translate($MODULE->getValue('name'), NULL, FALSE), $MODULE->getValue('id'));
                        }
                        $MODULE->next();
                    }
                }
                // ---------- SLICE IDS SORTIEREN UND AUSGEBEN
                $I_ID = 0;
                $PRE_ID = 0;
                $LCTSL_ID = 0;
                $this->CONT->reset();
                $this->article_content = "";
                for ($i = 0; $i < $this->CONT->getRows(); $i++) {
                    // ----- ctype unterscheidung
                    if ($this->mode != "edit" && $i == 0) {
                        $this->article_content = "<?php if (\$this->ctype == '" . $RE_CONTS_CTYPE[$I_ID] . "' || (\$this->ctype == '-1')) { ?>";
                    }
                    // ------------- EINZELNER SLICE - AUSGABE
                    $this->CONT->counter = $RE_C[$I_ID];
                    $slice_content = "";
                    $SLICE_SHOW = TRUE;
                    if ($this->mode == "edit") {
                        $form_url = 'index.php';
                        if ($this->setanker) {
                            $form_url .= '#addslice';
                        }
                        $this->ViewSliceId = $RE_CONTS[$I_ID];
                        // ----- add select box einbauen
                        if ($this->function == "add" && $this->slice_id == $I_ID) {
                            $slice_content = $this->addSlice($I_ID, $module_id);
                        } else {
                            // ----- BLOCKAUSWAHL - SELECT
                            $MODULESELECT->setId("module_id" . $I_ID);
                            $slice_content = '
              <form action="' . $form_url . '" method="get" id="slice' . $RE_CONTS[$I_ID] . '">
                <fieldset>
                  <legend class="rex-lgnd"><span class="rex-hide">' . $I18N->msg("add_block") . '</span></legend>
                  <input type="hidden" name="article_id" value="' . $this->article_id . '" />
                  <input type="hidden" name="page" value="content" />
                  <input type="hidden" name="mode" value="' . $this->mode . '" />
                  <input type="hidden" name="slice_id" value="' . $I_ID . '" />
                  <input type="hidden" name="function" value="add" />
                  <input type="hidden" name="clang" value="' . $this->clang . '" />
                  <input type="hidden" name="ctype" value="' . $this->ctype . '" />

                  <p class="rex-slct">
                    ' . $MODULESELECT->get() . '
                    <noscript><input type="submit" class="rex-sbmt" name="btn_add" value="' . $I18N->msg("add_block") . '" /></noscript>
                  </p>

                </fieldset>
              </form>';
                        }
                        // ----- EDIT/DELETE BLOCK - Wenn Rechte vorhanden
                        if ($REX_USER->hasPerm("module[" . $RE_MODUL_ID[$I_ID] . "]") || $REX_USER->hasPerm("admin[]")) {
                            $msg = '';
                            if ($this->slice_id == $RE_CONTS[$I_ID] && $this->message != '') {
                                $msg = rex_warning($this->message);
                            }
                            $sliceUrl = 'index.php?page=content&amp;article_id=' . $this->article_id . '&amp;mode=edit&amp;slice_id=' . $RE_CONTS[$I_ID] . '&amp;clang=' . $this->clang . '&amp;ctype=' . $this->ctype . '%s#slice' . $RE_CONTS[$I_ID];
                            $listElements = array();
                            $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;function=edit') . '" class="rex-clr-grn">' . $I18N->msg('edit') . ' <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                            $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;function=delete&amp;save=1') . '" class="rex-clr-red" onclick="return confirm(\'' . $I18N->msg('delete') . ' ?\')">' . $I18N->msg('delete') . ' <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                            if ($REX_USER->hasPerm('moveSlice[]')) {
                                $moveUp = $I18N->msg('move_slice_up');
                                $moveDown = $I18N->msg('move_slice_down');
                                // upd stamp übergeben, da sonst ein block nicht mehrfach hintereindander verschoben werden kann
                                // (Links wären sonst gleich und der Browser lässt das klicken auf den gleichen Link nicht zu)
                                $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;upd=' . time() . '&amp;function=moveup') . '" title="' . $moveUp . '"><img src="media/file_up.gif" width="16" height="16" alt="' . $moveUp . '" /> <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                                $listElements[] = '<a href="' . sprintf($sliceUrl, '&amp;upd=' . time() . '&amp;function=movedown') . '" title="' . $moveDown . '"><img src="media/file_down.gif" width="16" height="16" alt="' . $moveDown . '" /> <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></a>';
                            }
                            // ----- EXTENSION POINT
                            $listElements = rex_register_extension_point('ART_SLICE_MENU', $listElements, array('article_id' => $this->article_id, 'clang' => $this->clang, 'ctype' => $RE_CONTS_CTYPE[$I_ID], 'module_id' => $RE_MODUL_ID[$I_ID], 'slice_id' => $RE_CONTS[$I_ID]));
                            $mne = $msg . '
			       	<div class="rex-cnt-editmode-slc">
                <p class="rex-flLeft">' . htmlspecialchars($RE_MODUL_NAME[$I_ID]) . '</p>
                <ul class="rex-flRight" id="rex-slc-mnu">
              ';
                            foreach ($listElements as $listElement) {
                                $mne .= '<li>' . $listElement . '</li>';
                            }
                            $mne .= '</ul></div>';
                            $slice_content .= $mne;
                            if ($this->function == "edit" && $this->slice_id == $RE_CONTS[$I_ID]) {
                                // **************** Aktueller Slice
                                // ----- PRE VIEW ACTION [EDIT]
                                $REX_ACTION = array();
                                // nach klick auf den übernehmen button,
                                // die POST werte übernehmen
                                if (rex_var::isEditEvent()) {
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $REX_ACTION = $obj->getACRequestValues($REX_ACTION);
                                    }
                                } else {
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $REX_ACTION = $obj->getACDatabaseValues($REX_ACTION, $this->CONT);
                                    }
                                }
                                // TODO: PreviewActions gibts nur im EditMode...?
                                if ($this->function == 'edit') {
                                    $modebit = '2';
                                } elseif ($this->function == 'delete') {
                                    $modebit = '4';
                                } else {
                                    $modebit = '1';
                                }
                                // pre-action and add
                                $ga = new rex_sql();
                                $ga->debugsql = 0;
                                $ga->setQuery('SELECT preview FROM ' . $REX['TABLE_PREFIX'] . 'module_action ma,' . $REX['TABLE_PREFIX'] . 'action a WHERE preview != "" AND ma.action_id=a.id AND module_id=' . $RE_MODUL_ID[$I_ID] . ' AND ((a.previewmode & ' . $modebit . ') = ' . $modebit . ')');
                                for ($t = 0; $t < $ga->getRows(); $t++) {
                                    $iaction = $ga->getValue('preview');
                                    // ****************** VARIABLEN ERSETZEN
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $iaction = $obj->getACOutput($REX_ACTION, $iaction);
                                    }
                                    eval('?>' . $iaction);
                                    // ****************** SPEICHERN FALLS NOETIG
                                    foreach ($REX['VARIABLES'] as $obj) {
                                        $obj->setACValues($this->CONT, $REX_ACTION);
                                    }
                                    $ga->next();
                                }
                                // ----- / PRE VIEW ACTION
                                $slice_content .= $this->editSlice($RE_CONTS[$I_ID], $RE_MODUL_IN[$I_ID], $RE_CONTS_CTYPE[$I_ID], $RE_MODUL_ID[$I_ID]);
                            } else {
                                // Modulinhalt ausgeben
                                $slice_content .= '
                <!-- *** OUTPUT OF MODULE-OUTPUT - START *** -->
                <div class="rex-cnt-slc-otp"><div class="rex-cnt-slc-otp2">
                  ' . $RE_MODUL_OUT[$I_ID] . '
                </div></div>
                <!-- *** OUTPUT OF MODULE-OUTPUT - END *** -->
                ';
                                $slice_content = $this->replaceVars($this->CONT, $slice_content);
                            }
                        } else {
                            // ----- hat keine rechte an diesem modul
                            $mne = '
			  	<div class="rex-cnt-editmode-slc">
                <p class="rex-flLeft" id="slice' . $RE_CONTS[$I_ID] . '">' . $RE_MODUL_NAME[$I_ID] . '</p>
                <ul class="rex-flRight">
                  <li>' . $I18N->msg('no_editing_rights') . ' <span class="rex-hide">' . $RE_MODUL_NAME[$I_ID] . '</span></li>
                </ul>
				  </div>';
                            $slice_content .= $mne . $RE_MODUL_OUT[$I_ID];
                            $slice_content = $this->replaceVars($this->CONT, $slice_content);
                        }
                    } else {
                        // ----- wenn mode nicht edit
                        if ($this->getSlice) {
                            while (list($k, $v) = each($RE_CONTS)) {
                                $I_ID = $k;
                            }
                        }
                        $slice_content .= $RE_MODUL_OUT[$I_ID];
                        $slice_content = $this->replaceVars($this->CONT, $slice_content);
                    }
                    // --------------- ENDE EINZELNER SLICE
                    // --------------- EP: SLICE_SHOW
                    $slice_content = rex_register_extension_point('SLICE_SHOW', $slice_content, array('article_id' => $this->article_id, 'clang' => $this->clang, 'ctype' => $RE_CONTS_CTYPE[$I_ID], 'module_id' => $RE_MODUL_ID[$I_ID], 'slice_id' => $RE_CONTS[$I_ID], 'function' => $this->function, 'function_slice_id' => $this->slice_id));
                    // ---------- slice in ausgabe speichern wenn ctype richtig
                    if ($this->ctype == -1 or $this->ctype == $RE_CONTS_CTYPE[$I_ID]) {
                        $this->article_content .= $slice_content;
                        // last content type slice id
                        $LCTSL_ID = $RE_CONTS[$I_ID];
                    }
                    // ----- zwischenstand: ctype .. wenn ctype neu dann if
                    if ($this->mode != "edit" && isset($RE_CONTS_CTYPE[$RE_CONTS[$I_ID]]) && $RE_CONTS_CTYPE[$I_ID] != $RE_CONTS_CTYPE[$RE_CONTS[$I_ID]] && $RE_CONTS_CTYPE[$RE_CONTS[$I_ID]] != "") {
                        $this->article_content .= "<?php } if(\$this->ctype == '" . $RE_CONTS_CTYPE[$RE_CONTS[$I_ID]] . "' || \$this->ctype == '-1'){ ?>";
                    }
                    // zum nachsten slice
                    $I_ID = $RE_CONTS[$I_ID];
                    $PRE_ID = $I_ID;
                }
                // ----- end: ctype unterscheidung
                if ($this->mode != "edit" && $i > 0) {
                    $this->article_content .= "<?php } ?>";
                }
                // ----- add module im edit mode
                if ($this->mode == "edit") {
                    $form_url = 'index.php';
                    if ($this->setanker) {
                        $form_url .= '#addslice';
                    }
                    if ($this->function == "add" && $this->slice_id == $LCTSL_ID) {
                        $slice_content = $this->addSlice($LCTSL_ID, $module_id);
                    } else {
                        // ----- BLOCKAUSWAHL - SELECT
                        $MODULESELECT->setId("module_id" . $LCTSL_ID);
                        // $slice_content = $add_select_box;
                        $slice_content = '
            <form action="' . $form_url . '" method="get">
              <fieldset>
                <legend class="rex-lgnd"><span class="rex-hide">' . $I18N->msg("add_block") . '</span></legend>
                <input type="hidden" name="article_id" value="' . $this->article_id . '" />
                <input type="hidden" name="page" value="content" />
                <input type="hidden" name="mode" value="' . $this->mode . '" />
                <input type="hidden" name="slice_id" value="' . $LCTSL_ID . '" />
                <input type="hidden" name="function" value="add" />
                <input type="hidden" name="clang" value="' . $this->clang . '" />
                <input type="hidden" name="ctype" value="' . $this->ctype . '" />

                <p class="rex-slct">
                  ' . $MODULESELECT->get() . '
                  <noscript><input type="submit" class="rex-sbmt" name="btn_add" value="' . $I18N->msg("add_block") . '" /></noscript>
                </p>

              </fieldset>
            </form>';
                    }
                    $this->article_content .= $slice_content;
                }
                // -------------------------- schreibe content
                if ($this->mode == "generate" || $this->viasql) {
                    echo $this->replaceLinks($this->article_content);
                } else {
                    eval("?>" . $this->article_content);
                }
            } else {
                echo $I18N->msg('no_article_available');
            }
        }
        // ----- end: article caching
        $CONTENT = ob_get_contents();
        ob_end_clean();
        return $CONTENT;
    }
Beispiel #21
0
 /**
  * Parses all REX_VARs in the given content.
  *
  * @param string $content     Content
  * @param int    $env         Environment
  * @param string $context     Context
  * @param mixed  $contextData Context data
  *
  * @return string
  */
 public static function parse($content, $env = null, $context = null, $contextData = null)
 {
     if (($env & self::ENV_INPUT) != self::ENV_INPUT) {
         $env = $env | self::ENV_OUTPUT;
     }
     self::$env = $env;
     self::$context = $context;
     self::$contextData = $contextData;
     self::$variableIndex = 0;
     $tokens = token_get_all($content);
     $countTokens = count($tokens);
     $content = '';
     for ($i = 0; $i < $countTokens; ++$i) {
         $token = $tokens[$i];
         if (is_string($token)) {
             $content .= $token;
             continue;
         }
         if (!in_array($token[0], [T_INLINE_HTML, T_CONSTANT_ENCAPSED_STRING, T_STRING, T_START_HEREDOC])) {
             $content .= $token[1];
             continue;
         }
         $add = $token[1];
         switch ($token[0]) {
             case T_INLINE_HTML:
                 $format = '<?= %s@@@INLINE_HTML_REPLACEMENT_END@@@';
                 $add = self::replaceVars($add, $format);
                 $add = preg_replace_callback('/@@@INLINE_HTML_REPLACEMENT_END@@@(\\r?\\n?)/', function (array $match) {
                     return $match[1] ? ', "' . addcslashes($match[1], "\r\n") . '" ?>' . $match[1] : ' ?>';
                 }, $add);
                 break;
             case T_CONSTANT_ENCAPSED_STRING:
                 $format = $token[1][0] == '"' ? '" . %s . "' : "' . %s . '";
                 $add = self::replaceVars($add, $format, false, $token[1][0]);
                 $start = substr($add, 0, 5);
                 $end = substr($add, -5);
                 if ($start == '"" . ' || $start == "'' . ") {
                     $add = substr($add, 5);
                 }
                 if ($end == ' . ""' || $end == " . ''") {
                     $add = substr($add, 0, -5);
                 }
                 break;
             case T_STRING:
                 while (isset($tokens[++$i]) && (is_string($tokens[$i]) && in_array($tokens[$i], ['=', '[', ']']) || in_array($tokens[$i][0], [T_WHITESPACE, T_STRING, T_CONSTANT_ENCAPSED_STRING, T_LNUMBER, T_ISSET]))) {
                     $add .= is_string($tokens[$i]) ? $tokens[$i] : $tokens[$i][1];
                 }
                 --$i;
                 $add = self::replaceVars($add);
                 break;
             case T_START_HEREDOC:
                 while (isset($tokens[++$i]) && (is_string($tokens[$i]) || $tokens[$i][0] != T_END_HEREDOC)) {
                     $add .= is_string($tokens[$i]) ? $tokens[$i] : $tokens[$i][1];
                 }
                 --$i;
                 if (preg_match("/'(.*)'/", $token[1], $match)) {
                     // nowdoc
                     $format = "\n" . $match[1] . "\n. %s . <<<'" . $match[1] . "'\n";
                     $add = self::replaceVars($add, $format);
                 } else {
                     // heredoc
                     $add = self::replaceVars($add, '{%s}', true);
                 }
                 break;
         }
         $content .= $add;
     }
     return $content;
 }