Skip to content

Instantly share code, notes, and snippets.

@gharlan
Created January 5, 2016 10:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save gharlan/a70704b1c309cb1281c1 to your computer and use it in GitHub Desktop.
Save gharlan/a70704b1c309cb1281c1 to your computer and use it in GitHub Desktop.
rex_yrewrite_scheme_gh
<?php
class rex_yrewrite_scheme_gh extends rex_yrewrite_scheme
{
protected $suffix = '/';
public function appendArticle($path, OOArticle $art)
{
if (
$art->isStartArticle() &&
!rex_yrewrite::isDomainMountpoint($art->getId()) &&
count(OOArticle::getArticlesOfCategory($art->getId(), true, $art->getClang())) <= 1
) {
return $path . '.html';
}
return $path . '/' . $this->normalize($art->getName()) . '.html';
}
public function getRedirection(OOArticle $art)
{
if (
$art->isStartArticle() &&
$cats = OOCategory::getChildrenById($art->getId(), true, $art->getClang())
) {
return $cats[0];
}
return false;
}
protected function normalize($string, $clang = 0)
{
return str_replace(' ', '-', mb_strtolower($string));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment