Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,4 @@ yrewrite_settings_saved = Einstellungen gespeichert
yrewrite_unicode_urls = Unicode-Zeichen in URLs erlauben (Umlaute, chinesische/kyrillische Zeichen etc.)
yrewrite_hide_url_block = URL-Block verbergen
yrewrite_hide_seo_block = SEO-Block verbergen
yrewrite_allow_article_ids = Aufruf von article_id erlauben (Bsp. 1,2,3)
1 change: 1 addition & 0 deletions lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,4 @@ yrewrite_settings_saved = Settings updated
yrewrite_unicode_urls = Allow unicode chars in URLs (umlauts, chinese/cyrillic characters etc.)
yrewrite_hide_url_block = Hide URL-Block
yrewrite_hide_seo_block = Hide SEO-Block
yrewrite_allow_article_ids = Allow article_id parameter (1,2,3)
30 changes: 28 additions & 2 deletions lib/yrewrite/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static function processFormPost()
$addon->setConfig('unicode_urls', rex_post('yrewrite_unicode_urls', 'bool'));
$addon->setConfig('yrewrite_hide_url_block', rex_post('yrewrite_hide_url_block', 'bool'));
$addon->setConfig('yrewrite_hide_seo_block', rex_post('yrewrite_hide_seo_block', 'bool'));
$addon->setConfig('yrewrite_allow_article_ids', rex_post('yrewrite_allow_article_ids', 'string'));

rex_yrewrite::deleteCache();

Expand All @@ -46,6 +47,8 @@ public static function getForm()
{
$addon = self::getAddon();

$formElements = [];

// Checkboxes
$checkbox_elements = [
[
Expand All @@ -64,7 +67,27 @@ public static function getForm()

$fragment = new rex_fragment();
$fragment->setVar('elements', $checkbox_elements, false);
$checkboxes = $fragment->parse('core/form/checkbox.php');
$content = $fragment->parse('core/form/checkbox.php');

// Input Fields
$inputGroups = [];
$n = [];
$n['field'] = '<input class="form-control" type="text" id="yrewrite_allow_article_ids" name="yrewrite_allow_article_ids" value="' . $addon->getConfig('yrewrite_allow_article_ids') . '" />';
$n['left'] = $addon->i18n('yrewrite_allow_article_ids');
$inputGroups[] = $n;

$fragment = new rex_fragment();
$fragment->setVar('elements', $inputGroups, false);
$inputGroup = $fragment->parse('core/form/input_group.php');

$n = [];
$n['label'] = '';
$n['field'] = $inputGroup;
$formElements[] = $n;

$fragment = new rex_fragment();
$fragment->setVar('elements', $formElements, false);
$content .= $fragment->parse('core/form/form.php');

// Submit
$submit_elements = [
Expand All @@ -80,7 +103,7 @@ public static function getForm()
$fragment = new rex_fragment();
$fragment->setVar('class', 'edit');
$fragment->setVar('title', $addon->i18n('yrewrite_settings'));
$fragment->setVar('body', $checkboxes, false);
$fragment->setVar('body', $content, false);
$fragment->setVar('buttons', $submit, false);

return '
Expand All @@ -106,5 +129,8 @@ public static function install()
if (!$addon->hasConfig('yrewrite_hide_url_block')) {
$addon->setConfig('yrewrite_hide_url_block', false);
}
if (!$addon->hasConfig('yrewrite_allow_article_ids')) {
$addon->setConfig('yrewrite_allow_article_ids', '');
}
}
}
18 changes: 17 additions & 1 deletion lib/yrewrite/yrewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,12 @@ public static function getPathsByDomain($domain)

public static function prepare()
{
if (rex::isFrontend() && 'get' === rex_request_method() && !rex_get('rex-api-call') && $articleId = rex_get('article_id', 'int')) {
if (rex::isFrontend() && 'get' === rex_request_method() && !rex_get('rex-api-call') && $articleId = rex_get('article_id', 'int'))
{
if (self::allowArticleId($articleId)) {
return true;
}

$params = $_GET;
$article = rex_article::get((int) $params['article_id'], (int) $params['clang']);
if ($article instanceof rex_article) {
Expand Down Expand Up @@ -598,4 +603,15 @@ private static function getSubPath(): string

return rtrim($path, DIRECTORY_SEPARATOR) . '/';
}

protected static function allowArticleId($articleId)
{
$ids = explode(',', rex_addon::get('yrewrite')->getConfig('yrewrite_allow_article_ids'));

if (in_array($articleId, $ids)) {
return true;
}

return false;
}
}