mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-04-04 14:43:32 -04:00
Sharing optimization
Change the storage and display of sharings to improve the time needed to generate the page. Instead of looking for a default value when displaying the sharing links, they are added during the configuration.
This commit is contained in:
@@ -193,7 +193,9 @@ class FreshRSS_Configuration {
|
||||
if (!is_array($value)) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists('url', $value)) {
|
||||
|
||||
// Verify URL and add default value when needed
|
||||
if (array_key_exists('url', $value) && $value['url'] !== null) {
|
||||
$is_url = (
|
||||
filter_var ($value['url'], FILTER_VALIDATE_URL) ||
|
||||
(version_compare(PHP_VERSION, '5.3.3', '<') &&
|
||||
@@ -203,10 +205,15 @@ class FreshRSS_Configuration {
|
||||
if (!$is_url) {
|
||||
continue;
|
||||
}
|
||||
if (!array_key_exists('name', $value) || strcmp($value['name'], '') === 0) {
|
||||
$value['name'] = $value['type'];
|
||||
}
|
||||
} else {
|
||||
$value['url'] = null;
|
||||
}
|
||||
|
||||
// Add a default name
|
||||
if (!array_key_exists('name', $value) || strcmp($value['name'], '') === 0) {
|
||||
$value['name'] = $value['type'];
|
||||
}
|
||||
|
||||
$this->data['sharing'][] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
class FreshRSS_Share {
|
||||
|
||||
static public function generateUrl($options, $selected, $link, $title) {
|
||||
if (!array_key_exists('url', $selected)) {
|
||||
$selected['url'] = '';
|
||||
}
|
||||
$share = $options[$selected['type']];
|
||||
$matches = array(
|
||||
'~URL~',
|
||||
|
||||
@@ -138,7 +138,7 @@ if (!empty($this->entries)) {
|
||||
<?php foreach ($sharing as $share) :?>
|
||||
<li class="item share">
|
||||
<a target="_blank" href="<?php echo FreshRSS_Share::generateUrl($this->conf->shares, $share, $item->link(), $item->title() . ' . ' . $feed->name())?>">
|
||||
<?php echo array_key_exists('name', $share) ? $share['name'] : Minz_Translate::t ($share['type']);?>
|
||||
<?php echo Minz_Translate::t ($share['name']);?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach;?>
|
||||
|
||||
Reference in New Issue
Block a user