PHP code example of yakamara / redaxo_yrewrite

1. Go to this page and download the library: Download yakamara/redaxo_yrewrite library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yakamara / redaxo_yrewrite example snippets


$seo = new rex_yrewrite_seo();
echo $seo->getTags();

rex_extension::register('YREWRITE_SEO_TAGS', function(rex_extension_point $ep) {
    $tags = $ep->getSubject();
    
    // title-Tag ändern
    $title = rex_escape('Ein geänderter Titel');
    $tags['title'] = '<title>'.$title.'</title>';
    $tags['og:title'] = '<meta property="og:title" content="'.$title.'">';
    $tags['twitter:title'] = '<meta name="twitter:title" content="'.$title.'">';
    
    // favicon-Tags hinzufügen
    $tags['favicon'] = '
            <link rel="apple-touch-icon" sizes="180x180" href="/assets/favicon/apple-touch-icon.png">
            <link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon/favicon-32x32.png">
            <link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon/favicon-16x16.png">
            <link rel="manifest" href="/assets/favicon/site.webmanifest">
            <link rel="mask-icon" href="/assets/favicon/safari-pinned-tab.svg" color="#5bbad5">
            <link rel="shortcut icon" href="/assets/favicon/favicon.ico">
            <meta name="msapplication-TileColor" content="#ffffff">
            <meta name="msapplication-config" content="/assets/favicon/browserconfig.xml">
            <meta name="theme-color" content="#ffffff">';
    $ep->setSubject($tags);
});



if (rex_addon::get(\'yrewrite\')->isAvailable()) {
    rex_yrewrite::setScheme(new eigene_rewrite_class());
}


class rex_yrewrite_scheme_mysuffix extends rex_yrewrite_scheme
{
    protected $suffix = \'.html\';
}


class rex_yrewrite_scheme_mysuffix extends rex_yrewrite_scheme
{
    protected $suffix = Null;
}


class rex_yrewrite_scheme_gh extends rex_yrewrite_scheme
{
    protected $suffix = \'/\';

    public function getRedirection(rex_article $art, rex_yrewrite_domain $domain)
    {

        if ($art->isStartArticle() && ($cats = $art->getCategory()->getChildren(true))) {
            return $cats[0];
        }

        return false;
    }
}


class rex_yrewrite_scheme_gh extends rex_yrewrite_scheme
{
    protected $suffix = \'/\';

    public function getRedirection(rex_article $art, rex_yrewrite_domain $domain)
    {

        if ($art->isStartArticle() && ($cats = $art->getCategory()->getChildren(true)) && !rex_article_slice::getFirstSliceForCtype(1, $art->getId(), rex_clang::getCurrentId())) {
            return $cats[0];
        }

    return false;
    }
}


class translate_url_with_sprog extends rex_yrewrite_scheme
{

    public function appendCategory($path, rex_category $cat, rex_yrewrite_domain $domain)
    {
        return $path;
    }

    public function appendArticle($path, rex_article $art, rex_yrewrite_domain $domain)
    {
        return $path . \'/\' . $this->normalize(sprogdown($art->getName(), $art->getClangId()), $art->getClangId()) . \'/\';
    }
}


class translate_url_with_sprog extends rex_yrewrite_scheme
{
    public function appendCategory($path, rex_category $cat, rex_yrewrite_domain $domain)
    {
        return $path . \'/\' . $this->normalize(sprogdown($cat->getName(), $cat->getClangId()), $cat->getClangId());
    }
}

    $yrewrite = new rex_yrewrite;
    // dump($yrewrite); // optional alle Eigenschaften und Methoden anzeigen

init()
getScheme()
setScheme(rex_yrewrite_scheme $scheme)
addDomain(rex_yrewrite_domain $domain)
addAliasDomain($from_domain, $to_domain_id, $clang_start = 0)
getDomains()
getDomainByName($name)
getDomainById($id)
getDefaultDomain()
getCurrentDomain()
getFullUrlByArticleId($id, $clang = null, array $parameters = [], $separator = \'&amp;\')
getDomainByArticleId($aid, $clang = null)
getArticleIdByUrl($domain, $url)
isDomainStartArticle($aid, $clang = null)
isDomainMountpoint($aid, $clang = null)
getPathsByDomain($domain)
prepare()
rewrite($params = [], $yparams = [], $fullpath = false)
generatePathFile($params)
checkUrl($url)
generateConfig()
readConfig()
readPathFile()
copyHtaccess()
isHttps()
deleteCache()
getFullPath($link = \'\')
getHost()

$seo = new rex_yrewrite_seo();
dump($seo); // optional alle Eigenschaften und Methoden anzeigen

$nav = rex_navigation::factory();
echo $nav->get(rex_yrewrite::getCurrentDomain()->getMountId(), 1, TRUE, TRUE);

$domains = array_filter(rex_sql::factory()->setDebug(0)->query(\'SELECT * FROM rex_yrewrite_domain\')
foreach($domains as $domain) {
    dump($domain);
}



class rex_project_rewrite_scheme extends rex_yrewrite_scheme
{
    /**
     * @param string $string
     * @param int $clang
     *
     * @return string
     */
    public function normalize($string, $clang = 1)
    {
        $string = str_replace(
            ['&'],
            ['und'],
            $string
        );

        // Id 2 = ungarisch
        if ($clang == 2) {
            $string = str_replace(
                ['ő', 'ű'],
                ['oe', 'ue'],
                $string
            );
        }
        return parent::normalize($string, $clang);
    }
}