public static function regenerateArticle($slice_id = false, $clang = false, $module_id = false) { if (!$slice_id) { $slice_id = rex_get('slice_id'); } if (!$article_id) { $article_id = rex_get('article_id'); } if (!$clang) { $clang = rex_get('clang'); } if (!$module_id) { $module_id = rex_get('module_id'); } if (!$ctype) { $ctype = rex_get('ctype'); } $newsql = rex_sql::factory(); $action = new rex_article_action($module_id, $function, $newsql); $action->setRequestValues(); $action->exec(rex_article_action::PRESAVE); // ----- artikel neu generieren $EA = rex_sql::factory(); $EA->setTable(rex::getTablePrefix() . 'article'); $EA->setWhere(['id' => $article_id, 'clang_id' => $clang]); $EA->addGlobalUpdateFields(); $EA->update(); rex_article_cache::delete($article_id, $clang); rex_extension::registerPoint(new rex_extension_point('ART_CONTENT_UPDATED', '', ['id' => $article_id, 'clang' => $clang])); // ----- POST SAVE ACTION [ADD/EDIT/DELETE] $action->exec(rex_article_action::POSTSAVE); if ($messages = $action->getMessages()) { $info .= '<br />' . implode('<br />', $messages); } if (rex_post('btn_save', 'string')) { $function = ''; } }
protected function addSlice($sliceId, $moduleIdToAdd) { $MOD = rex_sql::factory(); $MOD->setQuery('SELECT * FROM ' . rex::getTablePrefix() . 'module WHERE id="' . $moduleIdToAdd . '"'); if ($MOD->getRows() != 1) { $slice_content = rex_view::warning(rex_i18n::msg('module_doesnt_exist')); } else { $initDataSql = rex_sql::factory(); // ----- PRE VIEW ACTION [ADD] $action = new rex_article_action($moduleIdToAdd, 'add', $initDataSql); $action->setRequestValues(); $action->exec(rex_article_action::PREVIEW); // ----- / PRE VIEW ACTION $moduleInput = $this->replaceVars($initDataSql, $MOD->getValue('input')); $moduleInput = $this->getStreamOutput('module/' . $moduleIdToAdd . '/input', $moduleInput); $msg = ''; if ($this->warning != '') { $msg .= rex_view::warning($this->warning); } if ($this->info != '') { $msg .= rex_view::success($this->info); } $formElements = []; $n = []; $n['field'] = '<a class="btn btn-abort" href="' . rex_url::currentBackendPage(['article_id' => $this->article_id, 'slice_id' => $sliceId, 'clang' => $this->clang, 'ctype' => $this->ctype]) . '#slice' . $sliceId . '">' . 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('add_block'), 'save') . '>' . rex_i18n::msg('add_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('add_block') . '</legend> <input type="hidden" name="function" value="add" /> <input type="hidden" name="module_id" value="' . $moduleIdToAdd . '" /> <input type="hidden" name="save" value="1" /> <div class="rex-slice-input"> ' . $moduleInput . ' </div> </fieldset> '; $fragment = new rex_fragment(); $fragment->setVar('before', $msg, false); $fragment->setVar('class', 'add', false); $fragment->setVar('title', rex_i18n::msg('module') . ': ' . rex_i18n::translate($MOD->getValue('name')), 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-add" id="slice' . $sliceId . '"> <form action="' . rex_url::currentBackendPage(['article_id' => $this->article_id, 'slice_id' => $sliceId, 'clang' => $this->clang, 'ctype' => $this->ctype]) . '#slice' . $sliceId . '" method="post" id="REX_FORM" enctype="multipart/form-data"> ' . $slice_content . ' </form> <script type="text/javascript"> <!-- jQuery(function($) { $(":input:visible:enabled:not([readonly]):first", $("#REX_FORM")).focus(); }); //--> </script> </li> '; } return $slice_content; }
if ($function != 'delete' && !rex_template::hasModule($template_attributes, $ctype, $module_id)) { $global_warning = rex_i18n::msg('no_rights_to_this_function'); $slice_id = ''; $function = ''; } elseif (!rex::getUser()->getComplexPerm('modules')->hasPerm($module_id)) { // ----- RECHTE AM MODUL: NEIN $global_warning = rex_i18n::msg('no_rights_to_this_function'); $slice_id = ''; $function = ''; } else { // ----- RECHTE AM MODUL: JA // *********************** daten einlesen $newsql = rex_sql::factory(); // $newsql->setDebug(); // ----- PRE SAVE ACTION [ADD/EDIT/DELETE] $action = new rex_article_action($module_id, $function, $newsql); $action->setRequestValues(); $action->exec(rex_article_action::PRESAVE); $action_message = implode('<br />', $action->getMessages()); // ----- / PRE SAVE ACTION // Werte werden aus den REX_ACTIONS übernommen wenn SAVE=true if (!$action->getSave()) { // ----- DONT SAVE/UPDATE SLICE if ($action_message != '') { $warning = $action_message; } elseif ($function == 'delete') { $warning = rex_i18n::msg('slice_deleted_error'); } else { $warning = rex_i18n::msg('slice_saved_error'); } } else {