Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rss head #135

Closed
wants to merge 7 commits into from
Closed
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
36 changes: 17 additions & 19 deletions core/lib/class.plx.utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -669,28 +669,26 @@ public static function httpEncoding() {
* @param base url du site qui sera rajoutée devant les liens relatifs
* @param html chaine de caractères à convertir
* @return string chaine de caractères modifiée
* @author Stephane F., Amaury Graillat
* @author Stephane F., Amaury Graillat, J.P. Pourrez
**/
public static function rel2abs($base, $html) {

// on protège les liens de type (href|src)="//" en doublant le caractère =
$html = preg_replace('@(href|src)=(["\']\/\/)@i', '\1==\2', $html);
// url des plugins
$html = preg_replace('@\<([^>]*) (href|src)=(["\'])[\.]/plugins@i', '<$1 $2=$3'.$base.'plugins', $html);
// generate server-only replacement for root-relative URLs
$server = preg_replace('@^([^:]+)://([^/]+)(/|$).*@', '\1://\2/', $base);
// on repare les liens ne commençant que part #
$get = plxUtils::getGets();
$html = preg_replace('@\<([^>]*) (href|src)=(["\'])#@i', '<\1 \2=\3'.$get.'#', $html);
// replace root-relative URLs
$html = preg_replace('@\<([^>]*) (href|src)=(["\']).?/@i', '<\1 \2=\3'.$server, $html);
// replace base-relative URLs
$html = preg_replace('@\<([^>]*) (href|src)=(["\'])([^:"]*|[^:"]*:[^/"][^"]*)(["\'])@i', '<\1 \2=\3'.$base.'\4\5', $html);
// unreplace fully qualified URLs with proto: that were wrongly added $base
$html = preg_replace('@\<([^>]*) (href|src)=(["\'])'.$base.'([a-zA-Z0-9]*):@i', '<\1 \2=\3\4:', $html);
// on rétablit les liens de type (href|src)="//" en remplaçant les caractères == par =
$html = preg_replace('@(href|src)==@i', '\1=', $html);
return $html;
if (substr($base, -1) != '/')
$base .= '/';
// on protège tous les liens externes au site,
// et on transforme tous les liens relatifs en absolus.
// on ajoute le hostname si nécessaire
$mask = '=<<>>=';
$patterns = array('/(href|src)=("|\')([a-z0-9]+):\/\//i', '/(href|src)=("|\')([^\/])/i');
$replaces = array('\1'.$mask.'\2\3://', '\1=\2'.$base.'\3');
if (preg_match('/^[a-z]+:\/\//i', $base)) {
$patterns[] = '/(href|src)=("|\')\/([^\/])/i';
$replaces[] = '\1=\2'.$base.'\3';
}
$result = preg_replace($patterns, $replaces, $html);
// on retire la protection des liens externes. Expressions régulières lentes et inutiles !!
$result = str_replace($mask, '=', $result);
return $result;

}

Expand Down
14 changes: 14 additions & 0 deletions themes/defaut/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,21 @@
<link rel="stylesheet" href="<?php $plxShow->template(); ?>/css/theme.css" media="screen"/>
<?php $plxShow->templateCss() ?>
<?php $plxShow->pluginsCss() ?>
<?php
if ($plxShow->plxMotor->mode == 'categorie') {
$categorie = $plxShow->catId();
$id = str_pad($categorie, 3, '0', STR_PAD_LEFT); ?>
<link rel="alternate" type="application/rss+xml" title="<?php $plxShow->lang('ARTICLES_RSS_FEEDS'); echo ' - '.$plxShow->getlang('CATEGORIES').': '; $plxShow->catName() ?>" href="<?php $plxShow->urlRewrite('feed.php?rss/categorie'.$categorie.'/'.$plxShow->plxMotor->aCats[$id]['url']); ?>" />
<?php
} else if ($plxShow->plxMotor->mode == 'tags') {
$tag = plxUtils::strCheck($plxShow->plxMotor->cible); ?>
<link rel="alternate" type="application/rss+xml" title="<?php $plxShow->lang('ARTICLES_RSS_FEEDS'); echo ' - '.$plxShow->getlang('TAGS').' : '; $plxShow->tagName(); ?>" href="<?php $plxShow->urlRewrite('feed.php?rss/tag/'.plxUtils::strCheck($tag)) ?>" />
<?php
} else { ?>
<link rel="alternate" type="application/rss+xml" title="<?php $plxShow->lang('ARTICLES_RSS_FEEDS') ?>" href="<?php $plxShow->urlRewrite('feed.php?rss') ?>" />
<?php
}
?>
<link rel="alternate" type="application/rss+xml" title="<?php $plxShow->lang('COMMENTS_RSS_FEEDS') ?>" href="<?php $plxShow->urlRewrite('feed.php?rss/commentaires') ?>" />
</head>

Expand Down