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; }
<?php rex_yrewrite::setScheme(new one_level_no_suffix());
} else { $showlist = false; $fragment = new rex_fragment(); $fragment->setVar('class', 'edit', false); $fragment->setVar('title', $this->i18n('edit_domain')); $fragment->setVar('body', $form, false); echo $fragment->parse('core/page/section.php'); } } else { if ($func == 'add') { $yform->setActionField('db', [rex::getTable('yrewrite_domain')]); $yform->setObjectparams('submit_btn_label', rex_i18n::msg('add')); $form = $yform->getForm(); if ($yform->objparams['actions_executed']) { echo rex_view::success($this->i18n('domain_added')); rex_yrewrite::deleteCache(); } else { $showlist = false; $fragment = new rex_fragment(); $fragment->setVar('class', 'edit', false); $fragment->setVar('title', $this->i18n('add_domain')); $fragment->setVar('body', $form, false); echo $fragment->parse('core/page/section.php'); } } } } if ($showlist) { $sql = 'SELECT * FROM ' . rex::getTable('yrewrite_domain') . ' where alias_domain <> ""'; $list = rex_list::factory($sql, 100); $list->setColumnFormat('id', 'Id');
<p>' . rex_i18n::rawMsg('yrewrite_info_seo_text') . ' <br /><br />' . highlight_string('<?php $seo = new rex_yrewrite_seo(); echo $seo->getTitleTag(); echo $seo->getDescriptionTag(); echo $seo->getRobotsTag(); echo $seo->getHreflangTags(); ?>', true) . ' </p> '; $fragment = new rex_fragment(); $fragment->setVar('title', $this->i18n('setup')); $fragment->setVar('body', $content, false); echo $fragment->parse('core/page/section.php'); $domains = []; foreach (rex_yrewrite::getDomains() as $name => $domain) { if ($name != 'default') { $domains[] = '<tr><td><a href="' . $domain->getUrl() . '">' . htmlspecialchars($name) . '</a></td><td><a href="' . $domain->getUrl() . 'sitemap.xml">sitemap.xml</a></td><td><a href="' . $domain->getUrl() . 'robots.txt">robots.txt</a></td></tr>'; } } $tables = '<table class="table table-hover"> <tr> <th>Domain</th><th>Sitemap</th><th>robots.txt</th></tr> ' . implode('', $domains) . ' </table>'; $fragment = new rex_fragment(); $fragment->setVar('title', $this->i18n('info_sitemaprobots')); $fragment->setVar('content', $tables, false); echo $fragment->parse('core/page/section.php');
public function sendSitemap($domain = '') { if ($domain == '') { $domain = rex_yrewrite::getHost(); } $sitemap = []; if (isset(rex_yrewrite::$domainsByName[$domain])) { $domain = rex_yrewrite::$domainsByName[$domain]; $domain_article_id = $domain->getStartId(); $paths = 0; if ($dai = rex_article::get($domain_article_id)) { $paths = count($dai->getParentTree()); } foreach (rex_yrewrite::$paths['paths'][$domain->getName()] as $article_id => $path) { foreach ($domain->getClangs() as $clang_id) { if (($article = rex_article::get($article_id, $clang_id)) && self::checkArticlePerm($article) && ($article->getValue('yrewrite_index') == 1 || $article->isOnline() && $article->getValue('yrewrite_index') == 0)) { $changefreq = $article->getValue('yrewrite_changefreq'); if (!in_array($changefreq, self::$changefreq)) { $changefreq = self::$changefreq_default; } $priority = $article->getValue('yrewrite_priority'); if (!in_array($priority, self::$priority)) { $article_paths = count($article->getParentTree()); $prio = $article_paths - $paths - 1; if ($prio < 0) { $prio = 0; } if (isset(self::$priority[$prio])) { $priority = self::$priority[$prio]; } else { $priority = self::$priority_default; } } $sitemap[] = "\n" . '<url>' . "\n" . '<loc>' . rex_yrewrite::getFullPath($path[$clang_id]) . '</loc>' . "\n" . '<lastmod>' . date(DATE_W3C, $article->getValue('updatedate')) . '</lastmod>' . "\n" . '<changefreq>' . $changefreq . '</changefreq>' . "\n" . '<priority>' . $priority . '</priority>' . "\n" . '</url>'; } } } } header('Content-Type: application/xml'); $content = '<?xml version="1.0" encoding="UTF-8"?>'; $content .= "\n" . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; $content .= implode("\n", $sitemap); $content .= "\n" . '</urlset>'; echo $content; exit; }
<?php /** * YREWRITE Addon. * * @author jan.kristinus@yakamara.de * * @package redaxo\yrewrite * * @var rex_addon $this */ $func = rex_request('func', 'string'); if ($func != '') { if ($func == 'htaccess') { rex_yrewrite::copyHtaccess(); echo rex_view::success($this->i18n('htaccess_hasbeenset')); } } $content = ' <h3>' . $this->i18n('htaccess_set') . '</h3> <p>' . rex_i18n::rawMsg('yrewrite_htaccess_info') . '</p> <p><a class="btn btn-primary" href="' . rex_url::currentBackendPage(['func' => 'htaccess']) . '">' . $this->i18n('yrewrite_htaccess_set') . '</a></p> <h3>' . $this->i18n('info_headline') . '</h3> <p>' . rex_i18n::rawMsg('yrewrite_info_text') . '</p> <h3>' . $this->i18n('info_seo') . '</h3> <p>' . rex_i18n::rawMsg('yrewrite_info_seo_text') . ' <br /><br />' . highlight_string('<?php
}, 'params' => [], 'message' => rex_i18n::msg('yrewrite_warning_chars')]); $yform->setValidateField('customfunction', ['name' => 'yrewrite_url', 'function' => function ($func, $yrewrite_url, $params, $field) { $return = ($a = rex_yrewrite::getArticleIdByUrl($params["domain"], $yrewrite_url)) && (key($a) != $params["article_id"] || current($a) != $params["clang"]); if ($return && $yrewrite_url != "") { $field->setElement("message", rex_i18n::msg('yrewrite_warning_urlexists', key($a))); } else { $return = false; } return $return; }, 'params' => ['article_id' => $article_id, "domain" => $domain, "clang" => $clang], 'message' => rex_i18n::msg('yrewrite_warning_urlexists')]); $yform->setActionField('db', [rex::getTable('article'), 'id=' . $article_id . ' and clang_id=' . $clang]); $yform->setObjectparams('submit_btn_label', $addon->i18n('update_url')); $form = $yform->getForm(); if ($yform->objparams['actions_executed']) { $form = rex_view::success($addon->i18n('urlupdated')) . $form; rex_yrewrite::generatePathFile(['id' => $article_id, 'clang' => $clang, 'extension_point' => 'ART_UPDATED']); rex_article_cache::delete($article_id, $clang); } else { } echo '<section id="rex-page-sidebar-yrewrite-url" data-pjax-container="#rex-page-sidebar-yrewrite-url" data-pjax-no-history="1">' . $form . '</section>'; $selector_preview = '#yform-yrewrite-url-yrewrite_url p.help-block'; $selector_url = '#yform-yrewrite-url-yrewrite_url input'; echo ' <script type="text/javascript"> jQuery(document).ready(function() { jQuery("' . $selector_url . '").keyup(function() { updateCustomUrlPreview(); });
$params = $ep->getParams(); $params['subject'] = $ep->getSubject(); $params['extension_point'] = $ep->getName(); rex_yrewrite::generatePathFile($params); }); } } //rex_extension::register('ALL_GENERATED', 'rex_yrewrite::init'); rex_extension::register('URL_REWRITE', function (rex_extension_point $ep) { $params = $ep->getParams(); $params['subject'] = $ep->getSubject(); return rex_yrewrite::rewrite($params); }); // get ARTICLE_ID from URL if (!rex::isBackend()) { rex_yrewrite::prepare(); } if (rex::isBackend()) { rex_extension::register('STRUCTURE_CONTENT_SIDEBAR', function (rex_extension_point $ep) { $params = $ep->getParams(); $subject = $ep->getSubject(); $panel = (include rex_path::addon('yrewrite', 'pages/content.yrewrite_url.php')); $fragment = new rex_fragment(); $fragment->setVar('title', '<i class="rex-icon rex-icon-info"></i> ' . rex_i18n::msg('yrewrite_rewriter'), false); $fragment->setVar('body', $panel, false); $fragment->setVar('article_id', $params["article_id"], false); $fragment->setVar('collapse', true); $fragment->setVar('collapsed', false); $content = $fragment->parse('core/page/section.php'); return $subject . $content; });
public static function readPathFile() { if (!file_exists(self::$pathfile)) { self::generatePathFile([]); } self::$paths = rex_file::getCache(self::$pathfile); }