diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php
index df910f0d3..cff6ff0f9 100644
--- a/e107_handlers/e_parse_class.php
+++ b/e107_handlers/e_parse_class.php
@@ -1314,25 +1314,31 @@ class e_parse extends e_parser
public function text_truncate($text, $len = 200, $more = ' ... ')
{
// Always valid
+
if($this->ustrlen($text) <= $len)
{
return $text;
}
+
+ $text = html_entity_decode($text,ENT_QUOTES,'utf-8');
+
+ return mb_strimwidth($text, 0, $len, $more);
- $ret = $this->usubstr($text, 0, $len);
+ // $ret = $this->usubstr($text, 0, $len);
// search for possible broken html entities
// - if an & is in the last 8 chars, removing it and whatever follows shouldn't hurt
// it should work for any characters encoding
-
- // FIXME - INVESTIGATE this one, switch to utf8 aware methods
+
+/*
+
$leftAmp = $this->ustrrpos($this->usubstr($ret, -8), '&');
if($leftAmp)
{
$ret = $this->usubstr($ret, 0, $this->ustrlen($ret) - 8 + $leftAmp);
}
- return $ret.$more;
+ return $ret.$more;*/
}
diff --git a/e107_plugins/newsfeed/newsfeed_functions.php b/e107_plugins/newsfeed/newsfeed_functions.php
index 5132fbd86..6d3b0d562 100644
--- a/e107_plugins/newsfeed/newsfeed_functions.php
+++ b/e107_plugins/newsfeed/newsfeed_functions.php
@@ -29,10 +29,10 @@ if (!e107::isInstalled('newsfeed'))
return;
}
-define('NEWSFEED_LIST_CACHE_TAG', 'nomd5_newsfeeds');
-define('NEWSFEED_NEWS_CACHE_TAG', 'nomd5_newsfeeds_news_');
+define('NEWSFEED_LIST_CACHE_TAG', 'newsfeeds'.e_LAN."_");
+define('NEWSFEED_NEWS_CACHE_TAG', 'newsfeeds_news_'.e_LAN."_");
-define('NEWSFEED_DEBUG', FALSE);
+define('NEWSFEED_DEBUG', false);
class newsfeedClass
@@ -56,7 +56,7 @@ class newsfeedClass
$this->lastProcessed = 0;
$this->truncateCount = 150; // Set a pref for these two later
$this->truncateMore = '...';
- $this->useCache = e107::getCache()->UserCacheActive; // Have our own local copy - should be faster to access
+ $this->useCache = true; // e107::getCache()->UserCacheActive; // Have our own local copy - should be faster to access
}
// Ensures the feed list is loaded - uses cache if available
@@ -94,10 +94,12 @@ class newsfeedClass
if (!empty($row['newsfeed_data']))
{
$this->newsList[$nfID]['newsfeed_data'] = $row['newsfeed_data']; // Pull out the actual news - might as well since we're here
- $this->newsList[$nfID]['newsfeed_timestamp'] = $row['newsfeed_timestamp'];
+
unset($row['newsfeed_data']); // Don't keep this in memory twice!
}
+
+ $this->newsList[$nfID]['newsfeed_timestamp'] = $row['newsfeed_timestamp'];
$this->feedList[$nfID] = $row; // Put the rest into the feed data
}
@@ -126,18 +128,32 @@ class newsfeedClass
return FALSE;
}
- if(empty($this->newsList[$feedID]['newsfeed_timestamp']) || empty($this->newsList[$feedID]['newsfeed_data']) || strpos($this->newsList[$feedID]['newsfeed_data'],'MagpieRSS')) //BC Fix to update newsfeed_data from v1 to v2 spec.
+ $maxAge = ($this->feedList[$feedID]['newsfeed_updateint']/60);
+
+ if($maxAge < 1){ $maxAge = 1; }
+
+ // e107::getDebug()->log("NewsFeed #".$feedID." MaxAge: ".$maxAge);
+
+ $cachedData = e107::getCache()->retrieve(NEWSFEED_NEWS_CACHE_TAG.$feedID,$maxAge, true);
+
+ if(empty($this->newsList[$feedID]['newsfeed_timestamp']) || empty($cachedData) || strpos($this->newsList[$feedID]['newsfeed_data'],'MagpieRSS')) //BC Fix to update newsfeed_data from v1 to v2 spec.
{
$force = true;
+ // e107::getDebug()->log("NewsFeed Force");
}
- if($force) // No data already in memory
+ if($cachedData !== false && $force === false)
+ {
+ // e107::getDebug()->log("NewsFeed Cache Used");
+ $this->newsList[$feedID]['newsfeed_data'] = $cachedData;
+ }
+
+ if ($force === true) // Need to re-read from source - either no cached data yet, or cache expired
{
- if ($force || !($this->newsList[$feedID]['newsfeed_data'] = e107::getCache()->retrieve(NEWSFEED_NEWS_CACHE_TAG.$feedID, $this->feedList[$feedID]['newsfeed_updateint']/60)))
- { // Need to re-read from source - either no cached data yet, or cache expired
if (NEWSFEED_DEBUG)
{
+ e107::getDebug()->log("NewsFeed Update: Item #".$feedID." ".NEWSFEED_NEWS_CACHE_TAG);
e107::getLog()->e_log_event(10,debug_backtrace(),"DEBUG","Newsfeed update","Refresh item: ".$feedID,FALSE,LOG_TO_ROLLING);
}
@@ -208,21 +224,24 @@ class newsfeedClass
if ($this->useCache)
{
- e107::getCache()->set(NEWSFEED_NEWS_CACHE_TAG.$feedID, $serializedArray);
- }
- else
- {
- $dbData['newsfeed_data'] = $serializedArray;
- $dbData['newsfeed_timestamp'] = $now;
+ // e107::getDebug()->log("Saving Cache");
+ e107::getCache()->set(NEWSFEED_NEWS_CACHE_TAG.$feedID, $serializedArray, true);
}
+
+ $dbData['newsfeed_data'] = $serializedArray;
+ $dbData['newsfeed_timestamp'] = $now;
+
if (count($dbData)) // Only write the feed data to DB if not using cache. Write description if changed
{
$dbData['WHERE'] = "newsfeed_id=".$feedID;
+
+
if(FALSE === $sql->update('newsfeed', $dbData))
{
+ // e107::getDebug()->log("NewsFeed DB Update Failed");
if (NEWSFEED_DEBUG) echo NFLAN_48."
".var_dump($dbData);
}
}
@@ -233,7 +252,6 @@ class newsfeedClass
if (NEWSFEED_DEBUG) echo $xml -> error;
return FALSE;
}
- }
}
return e107::unserialize($this->newsList[$feedID]['newsfeed_data']);