Normalize helper functions
This commit is contained in:
parent
892fb517ae
commit
fa1ddb486a
@ -6,7 +6,7 @@ if (file_exists(__DIR__.'/config.php')) {
|
|||||||
require __DIR__.'/config.php';
|
require __DIR__.'/config.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
defined('APP_VERSION') or define('APP_VERSION', Helper\parseAppVersion('$Format:%d$','$Format:%H$'));
|
defined('APP_VERSION') or define('APP_VERSION', Helper\parse_app_version('$Format:%d$','$Format:%H$'));
|
||||||
defined('HTTP_TIMEOUT') or define('HTTP_TIMEOUT', 20);
|
defined('HTTP_TIMEOUT') or define('HTTP_TIMEOUT', 20);
|
||||||
|
|
||||||
defined('BASE_URL_DIRECTORY') or define('BASE_URL_DIRECTORY', dirname($_SERVER['PHP_SELF']));
|
defined('BASE_URL_DIRECTORY') or define('BASE_URL_DIRECTORY', dirname($_SERVER['PHP_SELF']));
|
||||||
|
@ -10,7 +10,7 @@ function isSecureConnection()
|
|||||||
/*
|
/*
|
||||||
* get Version number from git archive output
|
* get Version number from git archive output
|
||||||
*/
|
*/
|
||||||
function parseAppVersion($refnames, $commithash)
|
function parse_app_version($refnames, $commithash)
|
||||||
{
|
{
|
||||||
$version = 'master';
|
$version = 'master';
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ function favicon(array $favicons, $feed_id)
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function isRTL(array $item)
|
function is_rtl(array $item)
|
||||||
{
|
{
|
||||||
return ! empty($item['rtl']) || \PicoFeed\Parser\Parser::isLanguageRTL($item['language']);
|
return ! empty($item['rtl']) || \PicoFeed\Parser\Parser::isLanguageRTL($item['language']);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ use PicoFeed\Logging\Logger;
|
|||||||
|
|
||||||
function addProxyToLink($link)
|
function addProxyToLink($link)
|
||||||
{
|
{
|
||||||
if (Helper\isSecureConnection() && strpos($link, 'http:') === 0) {
|
if (Helper\is_secure_connection() && strpos($link, 'http:') === 0) {
|
||||||
$link = '?action=proxy&url='.rawurlencode($link);
|
$link = '?action=proxy&url='.rawurlencode($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ function addProxyToTags($html, $website, $proxy_images, $cloak_referrer)
|
|||||||
{
|
{
|
||||||
if ($html === '' // no content, no proxy
|
if ($html === '' // no content, no proxy
|
||||||
|| (! $cloak_referrer && ! $proxy_images) // neither cloaking nor proxing enabled
|
|| (! $cloak_referrer && ! $proxy_images) // neither cloaking nor proxing enabled
|
||||||
|| (! $cloak_referrer && $proxy_images && ! Helper\isSecureConnection())) { // only proxy enabled, but not connected via HTTPS
|
|| (! $cloak_referrer && $proxy_images && ! Helper\is_secure_connection())) { // only proxy enabled, but not connected via HTTPS
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ function addProxyToTags($html, $website, $proxy_images, $cloak_referrer)
|
|||||||
// they do not trigger mixed content warnings.
|
// they do not trigger mixed content warnings.
|
||||||
$config->setFilterImageProxyProtocol('http');
|
$config->setFilterImageProxyProtocol('http');
|
||||||
}
|
}
|
||||||
elseif (! $proxy_images && $cloak_referrer && Helper\isSecureConnection()) {
|
elseif (! $proxy_images && $cloak_referrer && Helper\is_secure_connection()) {
|
||||||
// cloaking mode only: if a request from a HTTPS connection to a HTTP
|
// cloaking mode only: if a request from a HTTPS connection to a HTTP
|
||||||
// connection is made, the referrer will be omitted by the browser.
|
// connection is made, the referrer will be omitted by the browser.
|
||||||
// Only the referrer for HTTPS to HTTPs requests needs to be cloaked.
|
// Only the referrer for HTTPS to HTTPs requests needs to be cloaked.
|
||||||
|
@ -266,7 +266,7 @@ function write_cookie($token, $sequence, $expiration)
|
|||||||
$expiration,
|
$expiration,
|
||||||
BASE_URL_DIRECTORY,
|
BASE_URL_DIRECTORY,
|
||||||
null,
|
null,
|
||||||
\Helper\isSecureConnection(),
|
\Helper\is_secure_connection(),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ function delete_cookie()
|
|||||||
time() - 3600,
|
time() - 3600,
|
||||||
BASE_URL_DIRECTORY,
|
BASE_URL_DIRECTORY,
|
||||||
null,
|
null,
|
||||||
\Helper\isSecureConnection(),
|
\Helper\is_secure_connection(),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
data-item-bookmark="<?= $item['bookmark'] ?>"
|
data-item-bookmark="<?= $item['bookmark'] ?>"
|
||||||
<?= $hide ? 'data-hide="true"' : '' ?>
|
<?= $hide ? 'data-hide="true"' : '' ?>
|
||||||
>
|
>
|
||||||
<h2 <?= Helper\isRTL($item) ? 'dir="rtl"' : 'dir="ltr"' ?>>
|
<h2 <?= Helper\is_rtl($item) ? 'dir="rtl"' : 'dir="ltr"' ?>>
|
||||||
<span class="bookmark-icon"></span>
|
<span class="bookmark-icon"></span>
|
||||||
<span class="read-icon"></span>
|
<span class="read-icon"></span>
|
||||||
<?= Helper\favicon($favicons, $item['feed_id']) ?>
|
<?= Helper\favicon($favicons, $item['feed_id']) ?>
|
||||||
@ -16,11 +16,11 @@
|
|||||||
><?= Helper\escape($item['title']) ?></a>
|
><?= Helper\escape($item['title']) ?></a>
|
||||||
</h2>
|
</h2>
|
||||||
<?php if ($display_mode === 'full'): ?>
|
<?php if ($display_mode === 'full'): ?>
|
||||||
<div class="preview" <?= Helper\isRTL($item) ? 'dir="rtl"' : 'dir="ltr"' ?>>
|
<div class="preview" <?= Helper\is_rtl($item) ? 'dir="rtl"' : 'dir="ltr"' ?>>
|
||||||
<?= $item['content'] ?>
|
<?= $item['content'] ?>
|
||||||
</div>
|
</div>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<p class="preview" <?= Helper\isRTL($item) ? 'dir="rtl"' : 'dir="ltr"' ?>>
|
<p class="preview" <?= Helper\is_rtl($item) ? 'dir="rtl"' : 'dir="ltr"' ?>>
|
||||||
<?= Helper\escape(Helper\summary(strip_tags($item['content']), 50, 300)) ?>
|
<?= Helper\escape(Helper\summary(strip_tags($item['content']), 50, 300)) ?>
|
||||||
</p>
|
</p>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<h1 <?= Helper\isRTL($item + array('rtl' => $feed['rtl'])) ? 'dir="rtl"' : 'dir="ltr"' ?>>
|
<h1 <?= Helper\is_rtl($item + array('rtl' => $feed['rtl'])) ? 'dir="rtl"' : 'dir="ltr"' ?>>
|
||||||
<a href="<?= $item['url'] ?>" rel="noreferrer" target="_blank" class="original"><?= Helper\escape($item['title']) ?></a>
|
<a href="<?= $item['url'] ?>" rel="noreferrer" target="_blank" class="original"><?= Helper\escape($item['title']) ?></a>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
@ -64,7 +64,7 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div id="item-content" <?= Helper\isRTL($item + array('rtl' => $feed['rtl'])) ? 'dir="rtl"' : 'dir="ltr"' ?>>
|
<div id="item-content" <?= Helper\is_rtl($item + array('rtl' => $feed['rtl'])) ? 'dir="rtl"' : 'dir="ltr"' ?>>
|
||||||
|
|
||||||
<?php if ($item['enclosure']): ?>
|
<?php if ($item['enclosure']): ?>
|
||||||
<?php if (strpos($item['enclosure_type'], 'audio') !== false): ?>
|
<?php if (strpos($item['enclosure_type'], 'audio') !== false): ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user