PDF rausgenommen

This commit is contained in:
aschwarz
2023-01-23 11:03:31 +01:00
parent 82d562a322
commit a6523903eb
28078 changed files with 4247552 additions and 2 deletions

View File

@ -0,0 +1,102 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\RssWidget;
use Piwik\Cache;
use Piwik\Http;
/**
*
*/
class RssRenderer
{
protected $url = null;
protected $count = 3;
protected $showDescription = false;
protected $showContent = false;
/**
* @var Cache\Lazy
*/
private $cache;
public function __construct($url)
{
$this->url = $url;
$this->cache = Cache::getLazyCache();
}
public function showDescription($bool)
{
$this->showDescription = $bool;
}
public function showContent($bool)
{
$this->showContent = $bool;
}
public function setCountPosts($count)
{
$this->count = $count;
}
public function get()
{
$cacheId = 'RSS_' . md5($this->url);
$output = $this->cache->fetch($cacheId);
if (!$output) {
try {
$content = Http::fetchRemoteFile($this->url);
$rss = simplexml_load_string($content);
} catch (\Exception $e) {
throw new \Exception("Error while importing feed: {$e->getMessage()}\n");
}
$output = '<div style="padding:10px 15px;"><ul class="rss">';
$i = 0;
$items = array();
if (!empty($rss->channel->item)) {
$items = $rss->channel->item;
}
foreach ($items as $post) {
$title = $post->title;
$date = @strftime("%B %e, %Y", strtotime($post->pubDate));
$link = $post->link;
$output .= '<li><a class="rss-title" title="" target="_blank" rel="noreferrer noopener" href="' . htmlspecialchars($link, ENT_COMPAT, 'UTF-8') . '">' . $title . '</a>' .
'<span class="rss-date">' . $date . '</span>';
if ($this->showDescription) {
$output .= '<div class="rss-description">' . $this->addTargetBlankAndNoReferrerToLinks($post->description) . '</div>';
}
if ($this->showContent) {
$output .= '<div class="rss-content">' . $this->addTargetBlankAndNoReferrerToLinks($post->content) . '</div>';
}
$output .= '</li>';
if (++$i == $this->count) {
break;
}
}
$output .= '</ul></div>';
$this->cache->save($cacheId, $output, 60 * 60 * 24);
}
return $output;
}
private function addTargetBlankAndNoReferrerToLinks($content)
{
return str_replace('<a ', '<a target="_blank" rel="noreferrer noopener"', $content);
}
}

View File

@ -0,0 +1,54 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\RssWidget;
use Piwik\Plugins\RssWidget\Widgets\RssChangelog;
use Piwik\Plugins\RssWidget\Widgets\RssPiwik;
use Piwik\SettingsPiwik;
use Piwik\Widget\WidgetsList;
/**
*
*/
class RssWidget extends \Piwik\Plugin
{
/**
* @see \Piwik\Plugin::registerEvents
*/
public function registerEvents()
{
return array(
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'Request.getRenamedModuleAndAction' => 'renameExampleRssWidgetModule',
'Widget.filterWidgets' => 'filterWidgets'
);
}
public function getStylesheetFiles(&$stylesheets)
{
$stylesheets[] = "plugins/RssWidget/stylesheets/rss.less";
}
public function renameExampleRssWidgetModule(&$module, &$action)
{
if ($module == 'ExampleRssWidget') {
$module = 'RssWidget';
}
}
/**
* @param WidgetsList $list
*/
public function filterWidgets($list)
{
if (!SettingsPiwik::isInternetEnabled()) {
$list->remove(RssChangelog::getCategory(), RssChangelog::getName());
$list->remove(RssPiwik::getCategory(), RssPiwik::getName());
}
}
}

View File

@ -0,0 +1,60 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\RssWidget\Widgets;
use Piwik\Piwik;
use Piwik\Widget\WidgetConfig;
use Piwik\Plugins\RssWidget\RssRenderer;
class RssChangelog extends \Piwik\Widget\Widget
{
public static function getCategory()
{
return 'About Matomo';
}
public static function getName()
{
return 'Matomo Changelog';
}
public static function configure(WidgetConfig $config)
{
$config->setCategoryId(self::getCategory());
$config->setName(self::getName());
}
private function getFeed($URL) {
$rss = new RssRenderer($URL);
$rss->setCountPosts(1);
$rss->showDescription(true);
$rss->showContent(false);
return $rss->get();
}
public function render()
{
try {
return $this->getFeed('https://matomo.org/changelog/feed');
} catch (\Exception $e) {
return $this->error($e);
}
}
/**
* @param \Exception $e
* @return string
*/
private function error($e)
{
return '<div class="pk-emptyDataTable">'
. Piwik::translate('General_ErrorRequest', array('', ''))
. ' - ' . $e->getMessage() . '</div>';
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\RssWidget\Widgets;
use Piwik\Piwik;
use Piwik\Widget\WidgetConfig;
use Piwik\Plugins\RssWidget\RssRenderer;
class RssPiwik extends \Piwik\Widget\Widget
{
public static function getCategory()
{
return 'About Matomo';
}
public static function getName()
{
return 'Matomo.org Blog';
}
public static function configure(WidgetConfig $config)
{
$config->setCategoryId(self::getCategory());
$config->setName(self::getName());
}
private function getFeed($URL){
$rss = new RssRenderer($URL);
$rss->showDescription(true);
return $rss->get();
}
public function render()
{
try {
return $this->getFeed('https://matomo.org/feed/');
} catch (\Exception $e) {
return $this->error($e);
}
}
/**
* @param \Exception $e
* @return string
*/
private function error($e)
{
return '<div class="pk-emptyDataTable">'
. Piwik::translate('General_ErrorRequest', array('', ''))
. ' - ' . $e->getMessage() . '</div>';
}
}

View File

@ -0,0 +1,15 @@
{
"name": "RssWidget",
"description": "Matomo Platform showcase: how to create a new widget that displays a user submitted RSS feed.",
"version": "1.0",
"keywords": ["example", "feed", "widget"],
"homepage": "https://matomo.org",
"license": "GPL v3+",
"authors": [
{
"name": "Matomo",
"email": "hello@matomo.org",
"homepage": "https://matomo.org"
}
]
}

View File

@ -0,0 +1,42 @@
.rss ul {
list-style: none outside none;
padding: 0;
}
.rss li {
line-height: 140%;
margin: 0.5em 0 1em;
}
.rss-title, .rss-date {
float: left;
font-size: 14px;
line-height: 140%;
}
.rss-title {
color: #2583AD;
margin: 0 0.5em 0.2em 0;
font-weight: bold;
}
.rss-date {
color: #999999;
margin: 0;
}
.rss-content, .rss-description {
clear: both;
line-height: 1.5em;
font-size: 13px;
color: #333333;
.screen-reader-text {
display: none;
}
}
/* hide changing blog post title and date in UI test */
.uiTest .rss-title, .uiTest .rss-date {
visibility:hidden;
}