1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 20:57:26 +02:00

Fix RSS atom link. Improved default styling on linkwords. e107::url() can now generate full or absolute urls. Sef-URL generation no longer strips numbers from titles.

This commit is contained in:
Cameron
2015-04-08 00:16:03 -07:00
parent d128b52576
commit 605d4078ce
4 changed files with 27 additions and 16 deletions

View File

@@ -4280,10 +4280,10 @@ class eHelper
public static function title2sef($title, $type = null) public static function title2sef($title, $type = null)
{ {
$title = str_replace(array("&",",","(",")"),'',$title); $title = str_replace(array("&",",","(",")"),'',$title);
$title = preg_replace('/[^\w\pL\s.]/u', '', strip_tags(e107::getParser()->toHTML($title, TRUE))); $title = preg_replace('/[^\w\d\pL\s.]/u', '', strip_tags(e107::getParser()->toHTML($title, TRUE)));
$title = trim(preg_replace('/[\s]+/', ' ', str_replace('_', ' ', $title))); $title = trim(preg_replace('/[\s]+/', ' ', str_replace('_', ' ', $title)));
$words = str_word_count($title,1); $words = str_word_count($title,1, '12345678990');
$limited = array_slice($words, 0, 14); // Limit number of words to 14. - any more and it ain't friendly. $limited = array_slice($words, 0, 14); // Limit number of words to 14. - any more and it ain't friendly.

View File

@@ -2604,23 +2604,32 @@ class e107
} }
/** /**
* Experimental static (easy) sef-url creation method (works with e_url.php @see /index.php) * Static (easy) sef-url creation method (works with e_url.php @see /index.php)
* @param string $plugin * @param string $plugin
* @param $key * @param $key
* @param array $row * @param array $row
* @param string $mode abs | full
* @return string * @return string
*/ */
public static function url($plugin='',$key, $row=array()) public static function url($plugin='',$key, $row=array(), $mode='abs')
{ {
$tmp = e107::getAddonConfig('e_url'); $tmp = e107::getAddonConfig('e_url');
$tp = e107::getParser(); $tp = e107::getParser();
if(varset($tmp[$plugin][$key]['sef'])) if(varset($tmp[$plugin][$key]['sef']))
{ {
if(deftrue('e_MOD_REWRITE')) // Search-Engine-Friendly URL if(deftrue('e_MOD_REWRITE')) // Search-Engine-Friendly URLs active.
{ {
$rawUrl = $tp->simpleParse($tmp[$plugin][$key]['sef'], $row); $rawUrl = $tp->simpleParse($tmp[$plugin][$key]['sef'], $row);
return e_HTTP.$rawUrl;
if($mode == 'full')
{
return SITEURL.$rawUrl;
}
else
{
return e_HTTP.$rawUrl;
}
} }
else // Legacy URL. else // Legacy URL.
{ {
@@ -2637,7 +2646,7 @@ class e107
} }
$urlTemplate = str_replace($srch,$repl,$tmp[$plugin][$key]['redirect']); $urlTemplate = str_replace($srch,$repl,$tmp[$plugin][$key]['redirect']);
$urlTemplate = $tp->replaceConstants($urlTemplate,'abs'); $urlTemplate = $tp->replaceConstants($urlTemplate, $mode);
$legacyUrl = $tp->simpleParse($urlTemplate, $row); $legacyUrl = $tp->simpleParse($urlTemplate, $row);
return $legacyUrl; return $legacyUrl;

View File

@@ -1,4 +1,5 @@
a.lw-tip { cursor: help } a.lw-tip { cursor: help; text-decoration-style:dotted }
a.lw-link { cursor: pointer; text-decoration-style:solid }

View File

@@ -77,7 +77,7 @@ elseif (e_QUERY)
// List available rss feeds // List available rss feeds
if (!$rss_type) if (!empty($rss_type))
{ // Display list of all feeds { // Display list of all feeds
require_once(HEADERF); require_once(HEADERF);
// require_once(e_PLUGIN.'rss_menu/rss_template.php'); Already loaded // require_once(e_PLUGIN.'rss_menu/rss_template.php'); Already loaded
@@ -217,6 +217,7 @@ class rssCreate
case 'news' : case 'news' :
case 1: case 1:
$path = e_PLUGIN."news/e_rss.php"; $path = e_PLUGIN."news/e_rss.php";
$this->contentType = "news";
break;; break;;
case 2: case 2:
$path=''; $path='';
@@ -287,7 +288,7 @@ class rssCreate
$path = e_PLUGIN."forum/e_rss.php"; $path = e_PLUGIN."forum/e_rss.php";
break; break;
case download: case 'download':
case 12: case 12:
$path = e_PLUGIN."download/e_rss.php"; $path = e_PLUGIN."download/e_rss.php";
break; break;
@@ -437,7 +438,7 @@ class rssCreate
$sitebutton = (strstr(SITEBUTTON, "http:") ? SITEBUTTON : SITEURL.str_replace("../", "", SITEBUTTON)); $sitebutton = (strstr(SITEBUTTON, "http:") ? SITEBUTTON : SITEURL.str_replace("../", "", SITEBUTTON));
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?"."> echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">
<!-- generator=\"e107\" --> <!-- generator=\"e107\" -->
<!-- content type=\"".$this -> contentType."\" --> <!-- content type=\"".$this->contentType."\" -->
<rss {$rss_namespace} version=\"2.0\" <rss {$rss_namespace} version=\"2.0\"
xmlns:content=\"http://purl.org/rss/1.0/modules/content/\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"
xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:atom=\"http://www.w3.org/2005/Atom\"
@@ -452,7 +453,8 @@ class rssCreate
echo $tp->toHtml($rss_custom_channel,FALSE)."\n"; // must not convert to CDATA. echo $tp->toHtml($rss_custom_channel,FALSE)."\n"; // must not convert to CDATA.
echo "<language>".CORE_LC.(defined("CORE_LC2") ? "-".CORE_LC2 : "")."</language> echo "
<language>".CORE_LC.(defined("CORE_LC2") ? "-".CORE_LC2 : "")."</language>
<copyright>".$tp->toRss(SITEDISCLAIMER)."</copyright> <copyright>".$tp->toRss(SITEDISCLAIMER)."</copyright>
<managingEditor>".$this->nospam($pref['siteadminemail'])." (".$pref['siteadmin'].")</managingEditor> <managingEditor>".$this->nospam($pref['siteadminemail'])." (".$pref['siteadmin'].")</managingEditor>
<webMaster>".$this->nospam($pref['siteadminemail'])." (".$pref['siteadmin'].")</webMaster> <webMaster>".$this->nospam($pref['siteadminemail'])." (".$pref['siteadmin'].")</webMaster>
@@ -462,9 +464,8 @@ class rssCreate
<generator>e107 (http://e107.org)</generator> <generator>e107 (http://e107.org)</generator>
<sy:updatePeriod>hourly</sy:updatePeriod> <sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency> <sy:updateFrequency>1</sy:updateFrequency>
<ttl>60</ttl>\n"; <ttl>60</ttl>
<atom:link href=\"".e107::url('rss_menu','atom', array('rss_url'=>$this->contentType, 'id'=>$this->topicid),'full')."\" rel=\"self\" type=\"application/rss+xml\" />\n";
echo "<atom:link href=\"".e_SELF."?".$content_type.".4.".$this->topicid."\" rel=\"self\" type=\"application/rss+xml\" />\n";
if (trim(SITEBUTTON)) if (trim(SITEBUTTON))
{ {
@@ -645,7 +646,7 @@ class rssCreate
echo " echo "
<uri>http://e107.org/</uri>\n <uri>http://e107.org/</uri>\n
</author>\n </author>\n
<link rel='self' href='".SITEURLBASE.e_PLUGIN_ABS.'rss_menu/'.e_PAGE.'?'.e_QUERY."' />\n"; <link rel='self' href='".e107::url('rss_menu','atom', array('rss_url'=>$this->contentType, 'id'=>$this->topicid),'full')."' />\n";
// Optional // Optional
include(e_ADMIN."ver.php"); include(e_ADMIN."ver.php");