/** * @param int $clang * @param rex_yrewrite_domain $domain * * @return string */ public function getClang($clang, rex_yrewrite_domain $domain) { if (count($domain->getClangs()) <= 1) { return ''; } return '/' . $this->normalize(rex_clang::get($clang)->getName(), $clang); }
public static function getFieldParams() { $options = array_map(function (rex_clang $clang) { return $clang->getName(); }, rex_clang::getAll()); return ['label' => rex_i18n::msg('clangs'), 'all_label' => rex_i18n::msg('all_clangs'), 'options' => $options]; }
/** * Gibt eine Url zu einem Artikel zurück. * * @param int|null $id * @param int|null $clang SprachId des Artikels * @param array $params Array von Parametern * @param string $separator * * @return string * * @package redaxo\structure */ function rex_getUrl($id = null, $clang = null, array $params = [], $separator = '&') { $id = (int) $id; $clang = (int) $clang; // ----- get id if ($id == 0) { $id = rex::getProperty('article_id'); } // ----- get clang // Wenn eine rexExtension vorhanden ist, immer die clang mitgeben! // Die rexExtension muss selbst entscheiden was sie damit macht if (!rex_clang::exists($clang) && (rex_clang::count() > 1 || rex_extension::isRegistered('URL_REWRITE'))) { $clang = rex_clang::getCurrentId(); } // ----- EXTENSION POINT $url = rex_extension::registerPoint(new rex_extension_point('URL_REWRITE', '', ['id' => $id, 'clang' => $clang, 'params' => $params, 'separator' => $separator])); if ($url == '') { if (rex_clang::count() > 1) { $clang = $separator . 'clang=' . $clang; } else { $clang = ''; } $params = rex_string::buildQuery($params, $separator); $params = $params ? $separator . $params : ''; $url = rex_url::frontendController() . '?article_id=' . $id . $clang . $params; } return $url; }
public function setClang($value) { if (!rex_clang::exists($value)) { $value = rex_clang::getCurrentId(); } $this->clang = $value; }
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; }
/** * Gibt eine Url zu einem Artikel zurück. * * @param string $_id * @param int|string $_clang SprachId des Artikels * @param array|string $_params Array von Parametern * @param bool $escape Flag whether the argument separator "&" should be escaped (&) * * @return string * * @package redaxo\structure */ function rex_getUrl($_id = '', $_clang = '', $_params = '', $escape = true) { $id = (int) $_id; $clang = (int) $_clang; // ----- get id if ($id == 0) { $id = rex::getProperty('article_id'); } // ----- get clang // Wenn eine rexExtension vorhanden ist, immer die clang mitgeben! // Die rexExtension muss selbst entscheiden was sie damit macht if ($_clang === '' && (rex_clang::count() > 1 || rex_extension::isRegistered('URL_REWRITE'))) { $clang = rex_clang::getCurrentId(); } // ----- get params $param_string = rex_param_string($_params, $escape ? '&' : '&'); $name = 'NoName'; if ($id != 0) { $ooa = rex_article::get($id, $clang); if ($ooa) { $name = rex_parse_article_name($ooa->getName()); } } // ----- EXTENSION POINT $url = rex_extension::registerPoint(new rex_extension_point('URL_REWRITE', '', ['id' => $id, 'name' => $name, 'clang' => $clang, 'params' => $param_string, 'escape' => $escape])); if ($url == '') { $_clang = ''; if (rex_clang::count() > 1) { $_clang .= ($escape ? '&' : '&') . 'clang=' . $clang; } $url = rex_url::frontendController() . '?article_id=' . $id . $_clang . $param_string; } return $url; }
public static function getArticle($id, $ctype = -1, $clang = null) { if ($clang === null) { $clang = rex_clang::getCurrentId(); } $article = new rex_article_content($id, $clang); return $article->getArticle($ctype); }
/** * Deletes the cache. * * @package redaxo\core */ function rex_delete_cache() { // close logger, so the logfile can also be deleted rex_logger::close(); $finder = rex_finder::factory(rex_path::cache())->recursive()->childFirst()->ignoreFiles(['.htaccess', '.redaxo'], false)->ignoreSystemStuff(false); rex_dir::deleteIterator($finder); rex_clang::reset(); // ----- EXTENSION POINT return rex_extension::registerPoint(new rex_extension_point('CACHE_DELETED', rex_i18n::msg('delete_cache_message'))); }
public static function getCategoryValue($id, $field, $clang = null) { if ($clang === null) { $clang = rex_clang::getCurrentId(); } $cat = rex_category::get($id, $clang); if ($cat) { return htmlspecialchars($cat->getValue($field)); } }
public function __construct($name, $mountId, $startId, $notfoundId, array $clangs = null, $startClang = 1, $title = '', $description = '', $robots = '') { $this->name = $name; $this->mountId = $mountId; $this->startId = $startId; $this->notfoundId = $notfoundId; $this->clangs = is_null($clangs) ? rex_clang::getAllIds() : $clangs; $this->startClang = $startClang; $this->title = $title; $this->description = $description; $this->robots = $robots; }
public function __construct($article_id = 0, $clang = null) { if ($article_id == 0) { $article_id = rex_article::getCurrentId(); } if (is_null($clang)) { $clang = rex_clang::getCurrentId(); } if ($article = rex_article::get($article_id, $clang)) { $this->article = $article; $this->domain = rex_yrewrite::getDomainByArticleId($article_id, $clang); } }
public function __construct($name, $scheme, $path, $mountId, $startId, $notfoundId, array $clangs = null, $startClang = 1, $title = '', $description = '', $robots = '') { $this->name = $name; $this->path = $path; $scheme = $scheme ?: (rex_yrewrite::isHttps() ? 'https' : 'http'); $this->url = $scheme . '://' . $name . $path; $this->mountId = $mountId; $this->startId = $startId; $this->notfoundId = $notfoundId; $this->clangs = is_null($clangs) ? rex_clang::getAllIds() : $clangs; $this->startClang = $startClang; $this->title = $title; $this->description = $description; $this->robots = $robots; }
/** * Löscht eine Clang. * * @param int $id Zu löschende ClangId * * @throws rex_exception */ public static function deleteCLang($id) { $startClang = rex_clang::getStartId(); if ($id == $startClang) { throw new rex_functional_exception(rex_i18n::msg('clang_error_startidcanotbedeleted', $startClang)); } if (!rex_clang::exists($id)) { throw new rex_functional_exception(rex_i18n::msg('clang_error_idcanotbedeleted', $id)); } $clang = rex_clang::get($id); $del = rex_sql::factory(); $del->setQuery('delete from ' . rex::getTablePrefix() . 'clang where id=?', [$id]); rex_sql_util::organizePriorities(rex::getTable('clang'), 'priority', '', 'priority'); rex_delete_cache(); // ----- EXTENSION POINT rex_extension::registerPoint(new rex_extension_point('CLANG_DELETED', '', ['id' => $clang->getId(), 'name' => $clang->getName(), 'clang' => $clang])); }
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 .= '&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; }
public static function clangAdded(\rex_extension_point $ep) { $firstLang = \rex_sql::factory(); $firstLang->setQuery('SELECT * FROM ' . \rex::getTable('sprog_wildcard') . ' WHERE clang_id=?', [\rex_clang::getStartId()]); $fields = $firstLang->getFieldnames(); $newLang = \rex_sql::factory(); $newLang->setDebug(false); foreach ($firstLang as $firstLangEntry) { $newLang->setTable(\rex::getTable('sprog_wildcard')); foreach ($fields as $key => $value) { if ($value == 'pid') { echo ''; } elseif ($value == 'clang_id') { $newLang->setValue('clang_id', $ep->getParam('clang')->getId()); } else { $newLang->setValue($value, $firstLangEntry->getValue($value)); } } $newLang->insert(); } }
/** * Speichert das Formular. * * Übernimmt die Werte aus den FormElementen in die Datenbank. * * Gibt true zurück wenn alles ok war, false bei einem allgemeinen Fehler, * einen String mit einer Fehlermeldung oder den von der Datenbank gelieferten ErrorCode. * * @return bool */ protected function save() { $sql = rex_sql::factory(); $sql->setDebug($this->debug); $sql->setTable($this->tableName); $values = []; foreach ($this->getSaveElements() as $fieldsetName => $fieldsetElements) { foreach ($fieldsetElements as $element) { // read-only-fields nicht speichern if (strpos($element->getAttribute('class'), 'form-control-static') !== false) { continue; } $fieldName = $element->getFieldName(); $fieldValue = $element->getSaveValue(); // Callback, um die Values vor dem Speichern noch beeinflussen zu können $fieldValue = $this->preSave($fieldsetName, $fieldName, $fieldValue, $sql); $values[$fieldName] = $fieldValue; } } try { if ($this->isEditMode()) { $sql->setValues($values); $sql->setWhere($this->whereCondition); $sql->update(); } else { if (count($this->languageSupport)) { foreach (rex_clang::getAllIds() as $clang_id) { $sql->setTable($this->tableName); $sql->addGlobalCreateFields(); $sql->addGlobalUpdateFields(); if (!isset($id)) { $id = $sql->setNewId($this->languageSupport['id']); } else { $sql->setValue($this->languageSupport['id'], $id); } $sql->setValue($this->languageSupport['clang'], $clang_id); $sql->setValues($values); $sql->insert(); } } else { $sql->setValues($values); $sql->insert(); } } $saved = true; } catch (rex_sql_exception $e) { $saved = false; } // ----- EXTENSION POINT if ($saved) { $saved = rex_extension::registerPoint(new rex_extension_point('REX_FORM_SAVED', $saved, ['form' => $this, 'sql' => $sql])); } else { $saved = $sql->getErrno(); } return $saved; }
/** * @param int $parentId * @param string $listType * @param bool $ignoreOfflines * @param int $clang * * @return static[] */ protected static function getChildElements($parentId, $listType, $ignoreOfflines = false, $clang = null) { $parentId = (int) $parentId; // for $parentId=0 root elements will be returned, so abort here for $parentId<0 only if (0 > $parentId) { return []; } if (!$clang) { $clang = rex_clang::getCurrentId(); } $class = get_called_class(); return static::getInstanceList([$parentId, $listType], function ($id) use($class, $ignoreOfflines, $clang) { if ($instance = $class::get($id, $clang)) { return !$ignoreOfflines || $instance->isOnline() ? $instance : null; } return null; }, function ($parentId, $listType) { $listFile = rex_path::addonCache('structure', $parentId . '.' . $listType); if (!file_exists($listFile)) { rex_article_cache::generateLists($parentId); } return rex_file::getCache($listFile); }); }
* * @var rex_addon $this */ $showlist = true; $data_id = rex_request('data_id', 'int', 0); $func = rex_request('func', 'string'); if ($func != '') { $yform = new rex_yform(); // $yform->setDebug(TRUE); $yform->setHiddenField('page', 'yrewrite/alias_domains'); $yform->setHiddenField('func', $func); $yform->setHiddenField('save', '1'); $yform->setObjectparams('main_table', rex::getTable('yrewrite_domain')); $yform->setValueField('text', ['domain', $this->i18n('alias_domain_refersto')]); $yform->setValueField('select_sql', ['alias_domain', $this->i18n('domain_willbereferdto') . '', 'select domain as id,domain as name from ' . rex::getTable('yrewrite_domain') . ' where alias_domain = ""']); if (rex_clang::count() > 1) { $yform->setValueField('select_sql', ['clang_start', $this->i18n('clang_start'), 'select id,name from ' . rex::getTable('clang') . ' order by id']); } $yform->setValidateField('empty', ['domain', $this->i18n('no_domain_defined')]); $yform->setValidateField('empty', ['alias_domain', $this->i18n('no_domain_defined')]); $yform->setValidateField('unique', ['domain', $this->i18n('domain_already_defined')]); if ($func == 'delete') { $d = rex_sql::factory(); $d->setQuery('delete from ' . rex::getTable('yrewrite_domain') . ' where id=' . $data_id); echo rex_view::success($this->i18n('domain_deleted')); rex_yrewrite::deleteCache(); } elseif ($func == 'edit') { $yform->setHiddenField('data_id', $data_id); $yform->setActionField('db', [rex::getTable('yrewrite_domain'), 'id=' . $data_id]); $yform->setObjectparams('main_id', $data_id); $yform->setObjectparams('main_where', "id={$data_id}");
/** * Resets the intern cache of this class. */ public static function reset() { self::$cacheLoaded = false; self::$clangs = []; }
/** * Verschieben einer Kategorie in eine andere. * * @param int $from_cat KategorieId der Kategorie, die verschoben werden soll (Quelle) * @param int $to_cat KategorieId der Kategorie, IN die verschoben werden soll (Ziel) * * @return bool TRUE bei Erfolg, sonst FALSE */ public static function moveCategory($from_cat, $to_cat) { $from_cat = (int) $from_cat; $to_cat = (int) $to_cat; if ($from_cat == $to_cat) { // kann nicht in gleiche kategroie kopiert werden return false; } else { // kategorien vorhanden ? // ist die zielkategorie im pfad der quellkategeorie ? $fcat = rex_sql::factory(); $fcat->setQuery('select * from ' . rex::getTablePrefix() . 'article where startarticle=1 and id=? and clang_id=?', [$from_cat, rex_clang::getStartId()]); $tcat = rex_sql::factory(); $tcat->setQuery('select * from ' . rex::getTablePrefix() . 'article where startarticle=1 and id=? and clang_id=?', [$to_cat, rex_clang::getStartId()]); if ($fcat->getRows() != 1 or $tcat->getRows() != 1 && $to_cat != 0) { // eine der kategorien existiert nicht return false; } else { if ($to_cat > 0) { $tcats = explode('|', $tcat->getValue('path')); if (in_array($from_cat, $tcats)) { // zielkategorie ist in quellkategorie -> nicht verschiebbar return false; } } // ----- folgende cats regenerate $RC = []; $RC[$fcat->getValue('parent_id')] = 1; $RC[$from_cat] = 1; $RC[$to_cat] = 1; if ($to_cat > 0) { $to_path = $tcat->getValue('path') . $to_cat . '|'; } else { $to_path = '|'; } $from_path = $fcat->getValue('path') . $from_cat . '|'; $gcats = rex_sql::factory(); // $gcats->setDebug(); $gcats->setQuery('select * from ' . rex::getTablePrefix() . 'article where path like ? and clang_id=?', [$from_path . '%', rex_clang::getStartId()]); $up = rex_sql::factory(); // $up->setDebug(); for ($i = 0; $i < $gcats->getRows(); ++$i) { // make update $new_path = $to_path . $from_cat . '|' . str_replace($from_path, '', $gcats->getValue('path')); $icid = $gcats->getValue('id'); // path aendern und speichern $up->setTable(rex::getTablePrefix() . 'article'); $up->setWhere("id={$icid}"); $up->setValue('path', $new_path); $up->update(); // cat in gen eintragen $RC[$icid] = 1; $gcats->next(); } // ----- clang holen, max catprio holen und entsprechen updaten $gmax = rex_sql::factory(); $up = rex_sql::factory(); // $up->setDebug(); foreach (rex_clang::getAllIds() as $clang) { $gmax->setQuery('select max(catpriority) from ' . rex::getTablePrefix() . "article where parent_id={$to_cat} and clang_id=" . $clang); $catpriority = (int) $gmax->getValue('max(catpriority)'); $up->setTable(rex::getTablePrefix() . 'article'); $up->setWhere("id={$from_cat} and clang_id={$clang} "); $up->setValue('path', $to_path); $up->setValue('parent_id', $to_cat); $up->setValue('catpriority', $catpriority + 1); $up->update(); } // ----- generiere artikel neu - ohne neue inhaltsgenerierung foreach ($RC as $id => $key) { rex_article_cache::delete($id); } foreach (rex_clang::getAllIds() as $clang) { self::newCatPrio($fcat->getValue('parent_id'), $clang, 0, 1); } } } return true; }
$list->setColumnLabel('mount_id', $this->i18n('mount_id')); $list->setColumnLabel('start_id', $this->i18n('start_id')); $list->setColumnLabel('notfound_id', $this->i18n('notfound_id')); if (rex_clang::count() > 0) { $list->setColumnLabel('clangs', $this->i18n('clangs')); $list->setColumnFormat('clangs', 'custom', function ($params) { $clangs = $params['subject']; if ($clangs == '') { $return = $this->i18n('alllangs'); } else { $return = []; foreach (explode(',', $clangs) as $clang) { $return[] = rex_clang::get($clang)->getName(); } if (count($return) > 1) { $return = implode(',', $return) . '<br />' . $this->i18n('clang_start') . ': ' . rex_clang::get($params['list']->getValue('clang_start'))->getName(); } else { $return = implode(',', $return); } } return $return; }); $list->removeColumn('clang_start'); } $list->addColumn(rex_i18n::msg('function'), '<i class="rex-icon rex-icon-edit"></i> ' . rex_i18n::msg('edit')); $list->setColumnLayout(rex_i18n::msg('function'), ['<th class="rex-table-action" colspan="2">###VALUE###</th>', '<td class="rex-table-action">###VALUE###</td>']); $list->setColumnParams(rex_i18n::msg('function'), ['data_id' => '###id###', 'func' => 'edit', 'start' => rex_request('start', 'string')]); $list->addColumn(rex_i18n::msg('delete'), '<i class="rex-icon rex-icon-delete"></i> ' . rex_i18n::msg('delete')); $list->setColumnLayout(rex_i18n::msg('delete'), ['', '<td class="rex-table-action">###VALUE###</td>']); $list->setColumnParams(rex_i18n::msg('delete'), ['data_id' => '###id###', 'func' => 'delete']); $list->addLinkAttribute(rex_i18n::msg('delete'), 'onclick', 'return confirm(\' id=###id### ' . rex_i18n::msg('delete') . ' ?\')');
$lang_a = new rex_select(); $lang_a->setId('clang_a'); $lang_a->setName('clang_a'); $lang_a->setSize('1'); $lang_a->setAttribute('class', 'form-control'); foreach ($clang_perm as $key) { $val = rex_i18n::translate(rex_clang::get($key)->getName()); $lang_a->addOption($val, $key); } $lang_b = new rex_select(); $lang_b->setId('clang_b'); $lang_b->setName('clang_b'); $lang_b->setSize('1'); $lang_b->setAttribute('class', 'form-control'); foreach ($clang_perm as $key) { $val = rex_i18n::translate(rex_clang::get($key)->getName()); $lang_b->addOption($val, $key); } $lang_a->setSelected(rex_request('clang_a', 'int', null)); $lang_b->setSelected(rex_request('clang_b', 'int', null)); $panel = '<fieldset>'; $grid = []; $formElements = []; $n = []; $n['label'] = '<label for="clang_a">' . rex_i18n::msg('content_contentoflang') . '</label>'; $n['field'] = $lang_a->get(); $formElements[] = $n; $fragment = new rex_fragment(); $fragment->setVar('group', true); $fragment->setVar('elements', $formElements, false); $grid[] = $fragment->parse('core/form/form.php');
/** * Generiert den Artikel-Cache des Artikelinhalts. * * @param int $article_id Id des zu generierenden Artikels * @param int $clang ClangId des Artikels * * @return bool TRUE bei Erfolg, FALSE wenn eine ungütlige article_id übergeben wird, sonst eine Fehlermeldung */ public static function generateArticleContent($article_id, $clang = null) { foreach (rex_clang::getAllIds() as $_clang) { if ($clang !== null && $clang != $_clang) { continue; } $CONT = new rex_article_content_base(); $CONT->setCLang($_clang); $CONT->setEval(false); // Content nicht ausführen, damit in Cachedatei gespeichert werden kann if (!$CONT->setArticleId($article_id)) { return false; } // --------------------------------------------------- Artikelcontent speichern $article_content_file = rex_path::addonCache('structure', "{$article_id}.{$_clang}.content"); $article_content = $CONT->getArticle(); // ----- EXTENSION POINT $article_content = rex_extension::registerPoint(new rex_extension_point('GENERATE_FILTER', $article_content, ['id' => $article_id, 'clang' => $_clang, 'article' => $CONT])); if (rex_file::put($article_content_file, $article_content) === false) { return rex_i18n::msg('article_could_not_be_generated') . ' ' . rex_i18n::msg('check_rights_in_directory') . rex_path::addonCache('structure'); } } return true; }
require_once rex_path::core('functions/function_rex_other.php'); // ----------------- VERSION rex::setProperty('version', '5.0.0-alpha7'); $cacheFile = rex_path::cache('config.yml.cache'); $configFile = rex_path::data('config.yml'); if (file_exists($cacheFile) && file_exists($configFile) && filemtime($cacheFile) >= filemtime($configFile)) { $config = rex_file::getCache($cacheFile); } else { $config = array_merge(rex_file::getConfig(rex_path::core('default.config.yml')), rex_file::getConfig($configFile)); rex_file::putCache($cacheFile, $config); } foreach ($config as $key => $value) { if (in_array($key, ['fileperm', 'dirperm'])) { $value = octdec($value); } rex::setProperty($key, $value); } date_default_timezone_set(rex::getProperty('timezone', 'Europe/Berlin')); if (!rex::isSetup()) { rex_error_handler::register(); } // ----------------- REX PERMS rex_complex_perm::register('clang', 'rex_clang_perm'); // ----- SET CLANG if (!rex::isSetup()) { rex_clang::setCurrentId(rex_request('clang', 'int', rex_clang::getStartId())); } if (isset($REX['LOAD_PAGE']) && $REX['LOAD_PAGE']) { unset($REX); require rex_path::core(rex::isBackend() ? 'backend.php' : 'frontend.php'); }
//ggf wiederanzeige des add forms, falls ungueltige id uebermittelt $content .= ' <tr class="mark"> <td class="rex-table-icon"><i class="rex-icon rex-icon-language"></i></td> <td class="rex-table-id" data-title="' . rex_i18n::msg('id') . '">–</td> <td data-title="' . rex_i18n::msg('clang_code') . '"><input class="form-control" type="text" id="rex-form-clang-code" name="clang_code" value="' . htmlspecialchars($clang_code) . '" autofocus /></td> <td data-title="' . rex_i18n::msg('clang_name') . '"><input class="form-control" type="text" id="rex-form-clang-name" name="clang_name" value="' . htmlspecialchars($clang_name) . '" /></td> <td class="rex-table-priority" data-title="' . rex_i18n::msg('clang_priority') . '"><input class="form-control" type="text" id="rex-form-clang-prio" name="clang_prio" value="' . ($clang_prio ?: rex_clang::count() + 1) . '" /></td> <td class="rex-table-action" colspan="2"><button class="btn btn-save" type="submit" name="add_clang_save"' . rex::getAccesskey(rex_i18n::msg('clang_add'), 'save') . ' value="1">' . rex_i18n::msg('clang_add') . '</button></td> </tr> '; } foreach (rex_clang::getAll() as $lang_id => $lang) { $add_td = '<td class="rex-table-id" data-title="' . rex_i18n::msg('id') . '">' . $lang_id . '</td>'; $delLink = rex_i18n::msg('delete'); if ($lang_id == rex_clang::getStartId()) { $delLink = '<span class="text-muted"><i class="rex-icon rex-icon-delete"></i> ' . $delLink . '</span>'; } else { $delLink = '<a href="' . rex_url::currentBackendPage(['func' => 'deleteclang', 'clang_id' => $lang_id]) . '" data-confirm="' . rex_i18n::msg('delete') . ' ?"><i class="rex-icon rex-icon-delete"></i> ' . $delLink . '</a>'; } // Edit form if ($func == 'editclang' && $clang_id == $lang_id) { $content .= ' <tr class="mark"> <td class="rex-table-icon"><i class="rex-icon rex-icon-language"></i></td> ' . $add_td . ' <td data-title="' . rex_i18n::msg('clang_code') . '"><input class="form-control" type="text" id="rex-form-clang-code" name="clang_code" value="' . htmlspecialchars($lang->getCode()) . '" autofocus /></td> <td data-title="' . rex_i18n::msg('clang_name') . '"><input class="form-control" type="text" id="rex-form-clang-name" name="clang_name" value="' . htmlspecialchars($lang->getName()) . '" /></td> <td class="rex-table-priority" data-title="' . rex_i18n::msg('clang_priority') . '"><input class="form-control" type="text" id="rex-form-clang-prio" name="clang_prio" value="' . htmlspecialchars($lang->getPriority()) . '" /></td> <td class="rex-table-action" colspan="2"><button class="btn btn-save" type="submit" name="edit_clang_save"' . rex::getAccesskey(rex_i18n::msg('clang_update'), 'save') . ' value="1">' . rex_i18n::msg('clang_update') . '</button></td> </tr>';
/** * 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'); }
$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>'; } }); }
$value = $values[$nummer]; $zaehler = $zaehler + 1; $outback .= '<div class="bereichswrapper"><h2>Bereich ' . $zaehler . '</h2>' . PHP_EOL; /**** * * Link * ****/ $link = ''; $linkanfang = ''; $linkende = ''; $outback_link = ''; if ($value['link_intern'] or $value['link_extern'] != '') { $outback_link .= '<h3>Link</h3>' . PHP_EOL; if ($value['link_intern'] != 0) { $linkanfang = '<a href="' . rex_geturl($value['link_intern'], rex_clang::getCurrentId()) . '">'; $article = rex_article::get($value['link_intern']); $name = $article->getName(); $outback_link .= ' <div class="form-group"> <label class="col-sm-3 control-label">Link intern</label> <div class="col-sm-9"> <a href="index.php?page=content&article_id=' . $value['link_intern'] . '&mode=edit">' . $name . ' (ID = ' . $value['link_intern'] . ')</a> </div> </div>' . PHP_EOL; } if ($value['link_extern'] != '') { $linkanfang = '<a class="extern" href="' . $value['link_extern'] . '">'; $outback_link .= ' <div class="form-group"> <label class="col-sm-3 control-label">Link extern</label>
if ($function == 'delete') { $del = rex_sql::factory(); $del->setQuery('SELECT ' . rex::getTablePrefix() . 'article_slice.article_id, ' . rex::getTablePrefix() . 'article_slice.clang_id, ' . rex::getTablePrefix() . 'article_slice.ctype_id, ' . rex::getTablePrefix() . 'module.name FROM ' . rex::getTablePrefix() . 'article_slice LEFT JOIN ' . rex::getTablePrefix() . 'module ON ' . rex::getTablePrefix() . 'article_slice.module_id=' . rex::getTablePrefix() . 'module.id WHERE ' . rex::getTablePrefix() . "article_slice.module_id='{$module_id}' GROUP BY " . rex::getTablePrefix() . 'article_slice.article_id'); if ($del->getRows() > 0) { $module_in_use_message = ''; $modulname = htmlspecialchars($del->getValue(rex::getTablePrefix() . 'module.name')); for ($i = 0; $i < $del->getRows(); ++$i) { $aid = $del->getValue(rex::getTablePrefix() . 'article_slice.article_id'); $clang_id = $del->getValue(rex::getTablePrefix() . 'article_slice.clang_id'); $ctype = $del->getValue(rex::getTablePrefix() . 'article_slice.ctype_id'); $OOArt = rex_article::get($aid, $clang_id); $label = $OOArt->getName() . ' [' . $aid . ']'; if (rex_clang::count() > 1) { $label = '(' . rex_i18n::translate(rex_clang::get($clang_id)->getName()) . ') ' . $label; } $module_in_use_message .= '<li><a href="' . rex_url::backendPage('content', ['article_id' => $aid, 'clang' => $clang_id, 'ctype' => $ctype]) . '">' . htmlspecialchars($label) . '</a></li>'; $del->next(); } $error = rex_i18n::msg('module_cannot_be_deleted', $modulname); if ($module_in_use_message != '') { $error .= '<ul>' . $module_in_use_message . '</ul>'; } } else { $del->setQuery('DELETE FROM ' . rex::getTablePrefix() . "module WHERE id='{$module_id}'"); if ($del->getRows() > 0) { $del->setQuery('DELETE FROM ' . rex::getTablePrefix() . "module_action WHERE module_id='{$module_id}'"); $success = rex_i18n::msg('module_deleted'); } else { $error = rex_i18n::msg('module_not_found');
if (!rex::isBackend()) { \rex_extension::register('OUTPUT_FILTER', '\\Sprog\\Extension::replaceWildcards'); } if (rex::isBackend() && rex::getUser()) { \rex_extension::register('CLANG_ADDED', '\\Sprog\\Extension::clangAdded'); \rex_extension::register('CLANG_DELETED', '\\Sprog\\Extension::clangDeleted'); rex_extension::register('PAGES_PREPARED', function () { if (rex::getUser()->isAdmin()) { if (\rex_be_controller::getCurrentPage() == 'sprog/settings') { $func = rex_request('func', 'string'); if ($func == 'update') { \rex_config::set('sprog', 'wildcard_clang_switch', rex_request('clang_switch', 'bool')); } } } if (rex::getUser()->isAdmin() || rex::getUser()->hasPerm('sprog[wildcard]')) { $page = \rex_be_controller::getPageObject('sprog/wildcard'); if (Wildcard::isClangSwitchMode()) { $clang_id = str_replace('clang', '', rex_be_controller::getCurrentPagePart(3)); $page->setSubPath(rex_path::addon('sprog', 'pages/wildcard.clang_switch.php')); foreach (\rex_clang::getAll() as $id => $clang) { if (rex::getUser()->getComplexPerm('clang')->hasPerm($id)) { $page->addSubpage((new rex_be_page('clang' . $id, $clang->getName()))->setSubPath(rex_path::addon('sprog', 'pages/wildcard.clang_switch.php'))->setIsActive($id == $clang_id)); } } } else { $page->setSubPath(rex_path::addon('sprog', 'pages/wildcard.clang_all.php')); } } }); }