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&article_id=' . $this->article_id . '&mode=edit&slice_id=' . $RE_CONTS[$I_ID] . '&clang=' . $this->clang . '&ctype=' . $this->ctype . '%s#slice' . $RE_CONTS[$I_ID]; $listElements = array(); $listElements[] = '<a href="' . sprintf($sliceUrl, '&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, '&function=delete&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, '&upd=' . time() . '&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, '&upd=' . time() . '&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; }
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&article_id=' . $this->article_id . '&mode=edit&slice_id=' . $RE_CONTS[$I_ID] . '&clang=' . $this->clang . '&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, '&function=edit') . '" class="rex-tx3">' . $I18N->msg('edit') . ' <span>' . $RE_MODUL_NAME[$I_ID] . '</span></a>'; } $listElements[] = '<a href="' . sprintf($sliceUrl, '&function=delete&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, '&upd=' . time() . '&function=moveup') . '" title="' . $moveUp . '" class="rex-slice-move-up"><span>' . $RE_MODUL_NAME[$I_ID] . '</span></a>'; $listElements[] = '<a href="' . sprintf($sliceUrl, '&upd=' . time() . '&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; }