Fix page assembly

This commit is contained in:
Matthew Exon 2020-10-21 16:25:51 +01:00 committed by Matthew Exon
parent b9c08ad651
commit 697241c42a

View file

@ -835,6 +835,9 @@ function retriever_content($a) {
} }
if ($a->argv[1]) { if ($a->argv[1]) {
$retriever_rule = get_retriever_rule($a->argv[1], local_user(), false); $retriever_rule = get_retriever_rule($a->argv[1], local_user(), false);
if (!$retriever_rule) {
$retriever_rule = ['id' => 0, 'data' => ['enable' => 0, 'modurl' => '', 'pattern' => '', 'replace' => '', 'images' => 0, 'storecookies' => 0, 'cookiedata' => '', 'customxslt' => '', 'include' => '', 'exclude' => '']];
}
if (!empty($_POST["id"])) { if (!empty($_POST["id"])) {
$retriever_rule = get_retriever_rule($a->argv[1], local_user(), true); $retriever_rule = get_retriever_rule($a->argv[1], local_user(), true);
@ -873,31 +876,31 @@ function retriever_content($a) {
} }
$template = Renderer::getMarkupTemplate('/rule-config.tpl', 'addon/retriever/'); $template = Renderer::getMarkupTemplate('/rule-config.tpl', 'addon/retriever/');
$a->page['content'] .= Renderer::replaceMacros($template, array( DI::page()['content'] .= Renderer::replaceMacros($template, array(
'$enable' => array( '$enable' => array(
'retriever_enable', 'retriever_enable',
DI::l10n()->t('Enabled'), DI::l10n()->t('Enabled'),
array_key_exists('enable', $retriever_rule['data']) ? $retriever_rule['data']['enable'] : ""), $retriever_rule['data']['enable']),
'$modurl' => array( '$modurl' => array(
'retriever_modurl', 'retriever_modurl',
DI::l10n()->t('Modify URL'), DI::l10n()->t('Modify URL'),
array_key_exists('modurl', $retriever_rule['data']) ? $retriever_rule['data']['modurl'] : "", $retriever_rule['data']['modurl'],
DI::l10n()->t("Modify each article's URL with regular expressions before retrieving.")), DI::l10n()->t("Modify each article's URL with regular expressions before retrieving.")),
'$pattern' => array( '$pattern' => array(
'retriever_pattern', 'retriever_pattern',
DI::l10n()->t('URL Pattern'), DI::l10n()->t('URL Pattern'),
array_key_exists('pattern', $retriever_rule['data']) ? $retriever_rule['data']['pattern'] : "", $retriever_rule['data']['pattern'],
DI::l10n()->t('Regular expression matching part of the URL to replace')), DI::l10n()->t('Regular expression matching part of the URL to replace')),
'$replace' => array( '$replace' => array(
'retriever_replace', 'retriever_replace',
DI::l10n()->t('URL Replace'), DI::l10n()->t('URL Replace'),
array_key_exists('replace', $retriever_rule['data']) ? $retriever_rule['data']['replace'] : "", $retriever_rule['data']['replace'],
DI::l10n()->t('Text to replace matching part of above regular expression')), DI::l10n()->t('Text to replace matching part of above regular expression')),
'$allow_images' => DI::config()->get('retriever', 'allow_images'), '$allow_images' => DI::config()->get('retriever', 'allow_images'),
'$images' => array( '$images' => array(
'retriever_images', 'retriever_images',
DI::l10n()->t('Download Images'), DI::l10n()->t('Download Images'),
array_key_exists('images', $retriever_rule['data']) ? $retriever_rule['data']['images'] : ""), $retriever_rule['data']['images']),
'$retrospective' => array( '$retrospective' => array(
'retriever_retrospective', 'retriever_retrospective',
DI::l10n()->t('Retrospectively Apply'), DI::l10n()->t('Retrospectively Apply'),
@ -906,17 +909,17 @@ function retriever_content($a) {
'storecookies' => array( 'storecookies' => array(
'retriever_storecookies', 'retriever_storecookies',
DI::l10n()->t('Store cookies'), DI::l10n()->t('Store cookies'),
array_key_exists('storecookies', $retriever_rule['data']) ? $retriever_rule['data']['storecookies'] : "", $retriever_rule['data']['storecookies'],
DI::l10n()->t("Preserve cookie data across fetches.")), DI::l10n()->t("Preserve cookie data across fetches.")),
'$cookiedata' => array( '$cookiedata' => array(
'retriever_cookiedata', 'retriever_cookiedata',
DI::l10n()->t('Cookie Data'), DI::l10n()->t('Cookie Data'),
array_key_exists('cookiedata', $retriever_rule['data']) ? $retriever_rule['data']['cookiedata'] : "", $retriever_rule['data']['cookiedata'],
DI::l10n()->t("Latest cookie data for this feed. Netscape cookie file format.")), DI::l10n()->t("Latest cookie data for this feed. Netscape cookie file format.")),
'$customxslt' => array( '$customxslt' => array(
'retriever_customxslt', 'retriever_customxslt',
DI::l10n()->t('Custom XSLT'), DI::l10n()->t('Custom XSLT'),
array_key_exists('customxslt', $retriever_rule['data']) ? $retriever_rule['data']['customxslt'] : "", $retriever_rule['data']['customxslt'],
DI::l10n()->t("When standard rules aren't enough, apply custom XSLT to the article")), DI::l10n()->t("When standard rules aren't enough, apply custom XSLT to the article")),
'$title' => DI::l10n()->t('Retrieve Feed Content'), '$title' => DI::l10n()->t('Retrieve Feed Content'),
'$help' => DI::baseUrl()->get(true) . '/retriever/help', '$help' => DI::baseUrl()->get(true) . '/retriever/help',