Remove PicoTools
This commit is contained in:
parent
e6e6db71f8
commit
b74b8dd784
@ -20,6 +20,7 @@ Features
|
|||||||
- Keyboard shortcuts (pressing '?' displays a pop-up listing the shortcuts; pressing 'q' closes it)
|
- Keyboard shortcuts (pressing '?' displays a pop-up listing the shortcuts; pressing 'q' closes it)
|
||||||
- Basic bookmarks
|
- Basic bookmarks
|
||||||
- Translated in English, French, German, Italian, Czech, Spanish, Portuguese and Simplified Chinese
|
- Translated in English, French, German, Italian, Czech, Spanish, Portuguese and Simplified Chinese
|
||||||
|
- RTL language support
|
||||||
- Themes support
|
- Themes support
|
||||||
- Alternative login with a Google Account or Mozilla Persona
|
- Alternative login with a Google Account or Mozilla Persona
|
||||||
- **Full article download for feeds that display only a summary** (website scraper based on Xpath rules)
|
- **Full article download for feeds that display only a summary** (website scraper based on Xpath rules)
|
||||||
@ -98,7 +99,6 @@ Libraries used
|
|||||||
|
|
||||||
- [PicoFeed](https://github.com/fguillot/picoFeed)
|
- [PicoFeed](https://github.com/fguillot/picoFeed)
|
||||||
- [PicoFarad](https://github.com/fguillot/picoFarad)
|
- [PicoFarad](https://github.com/fguillot/picoFarad)
|
||||||
- [PicoTools](https://github.com/fguillot/picoTools)
|
|
||||||
- [PicoDb](https://github.com/fguillot/picoDb)
|
- [PicoDb](https://github.com/fguillot/picoDb)
|
||||||
- [SimpleValidator](https://github.com/fguillot/simpleValidator)
|
- [SimpleValidator](https://github.com/fguillot/simpleValidator)
|
||||||
- [PHP 5.5 password backport](https://github.com/ircmaxell/password_compat)
|
- [PHP 5.5 password backport](https://github.com/ircmaxell/password_compat)
|
||||||
|
2
assets/js/all.min.js
vendored
2
assets/js/all.min.js
vendored
@ -6,7 +6,7 @@ a);b&&(b.innerHTML="");if(b=document.getElementById("last-checked-feed-"+a))b.in
|
|||||||
function(b){b=e.indexOf(b.feed_id);0<=b&&e.splice(b,1);0==a.length&&0==e.length&&(clearInterval(d),clearInterval(f),window.location.href="?action=unread")})}},100)}}}();
|
function(b){b=e.indexOf(b.feed_id);0<=b&&e.splice(b,1);0==a.length&&0==e.length&&(clearInterval(d),clearInterval(f),window.location.href="?action=unread")})}},100)}}}();
|
||||||
Miniflux.Item=function(){function d(b){var a=document.getElementById("item-"+b);a||(a=document.getElementById("current-item"),a.getAttribute("data-item-id")!=b&&(a=!1));return a}function c(b){if((b=document.getElementById("bookmark-"+b))&&b.getAttribute("data-reverse-label")){var a=b.innerHTML;b.innerHTML=b.getAttribute("data-reverse-label");b.setAttribute("data-reverse-label",a)}}function a(b){if(b=document.getElementById("status-"+b)){var a=b.innerHTML;b.innerHTML=b.getAttribute("data-reverse-label");
|
Miniflux.Item=function(){function d(b){var a=document.getElementById("item-"+b);a||(a=document.getElementById("current-item"),a.getAttribute("data-item-id")!=b&&(a=!1));return a}function c(b){if((b=document.getElementById("bookmark-"+b))&&b.getAttribute("data-reverse-label")){var a=b.innerHTML;b.innerHTML=b.getAttribute("data-reverse-label");b.setAttribute("data-reverse-label",a)}}function a(b){if(b=document.getElementById("status-"+b)){var a=b.innerHTML;b.innerHTML=b.getAttribute("data-reverse-label");
|
||||||
b.setAttribute("data-reverse-label",a)}}function e(b){"mouse"!=Miniflux.Event.lastEventType&&Miniflux.Nav.SelectNextItem();b.parentNode.removeChild(b);if(b=document.getElementById("page-counter"))counter=parseInt(b.textContent.trim(),10)-1,0==counter?window.location="?action=unread":(b.textContent=counter+" ",document.title="miniflux ("+counter+")",document.getElementById("nav-counter").textContent="("+counter+")")}function f(b){var c=new XMLHttpRequest;c.onload=function(){if(Miniflux.Nav.IsListing()){var c=
|
b.setAttribute("data-reverse-label",a)}}function e(b){"mouse"!=Miniflux.Event.lastEventType&&Miniflux.Nav.SelectNextItem();b.parentNode.removeChild(b);if(b=document.getElementById("page-counter"))counter=parseInt(b.textContent.trim(),10)-1,0==counter?window.location="?action=unread":(b.textContent=counter+" ",document.title="miniflux ("+counter+")",document.getElementById("nav-counter").textContent="("+counter+")")}function f(b){var c=new XMLHttpRequest;c.onload=function(){if(Miniflux.Nav.IsListing()){var c=
|
||||||
d(b);if(c)if(c.getAttribute("data-hide"))e(c);else{c.setAttribute("data-item-status","read");a(b);if(c=document.getElementById("show-"+b)){c.className="read";var g=document.createElement("span");g.id="read-icon-"+b;g.appendChild(document.createTextNode("\u2611 "));c.parentNode.insertBefore(g,c)}(c=document.getElementById("status-"+b))&&c.setAttribute("data-action","mark-unread")}}};c.open("POST","?action=mark-item-read&id="+b,!0);c.send()}function h(b){var c=new XMLHttpRequest;c.onload=function(){if(Miniflux.Nav.IsListing()){var c=
|
d(b);if(c)if(c.getAttribute("data-hide"))e(c);else{c.setAttribute("data-item-status","read");a(b);if(c=document.getElementById("show-"+b)){c.className="read";var g=document.createElement("span");g.id="read-icon-"+b;g.appendChild(document.createTextNode("\u2714 "));c.parentNode.insertBefore(g,c)}(c=document.getElementById("status-"+b))&&c.setAttribute("data-action","mark-unread")}}};c.open("POST","?action=mark-item-read&id="+b,!0);c.send()}function h(b){var c=new XMLHttpRequest;c.onload=function(){if(Miniflux.Nav.IsListing()){var c=
|
||||||
d(b);if(c)if(c.getAttribute("data-hide"))e(c);else{c.setAttribute("data-item-status","unread");a(b);if(c=document.getElementById("show-"+b))c.className="";(c=document.getElementById("read-icon-"+b))&&c.parentNode.removeChild(c);(c=document.getElementById("status-"+b))&&c.setAttribute("data-action","mark-read")}}};c.open("POST","?action=mark-item-unread&id="+b,!0);c.send()}function l(b,a){var e=b.getAttribute("data-item-id"),d=new XMLHttpRequest;d.onload=function(){b.setAttribute("data-item-bookmark",
|
d(b);if(c)if(c.getAttribute("data-hide"))e(c);else{c.setAttribute("data-item-status","unread");a(b);if(c=document.getElementById("show-"+b))c.className="";(c=document.getElementById("read-icon-"+b))&&c.parentNode.removeChild(c);(c=document.getElementById("status-"+b))&&c.setAttribute("data-action","mark-read")}}};c.open("POST","?action=mark-item-unread&id="+b,!0);c.send()}function l(b,a){var e=b.getAttribute("data-item-id"),d=new XMLHttpRequest;d.onload=function(){b.setAttribute("data-item-bookmark",
|
||||||
a);if(a)if(Miniflux.Nav.IsListing()){if(f=document.getElementById("show-"+e)){var d=document.createElement("span");d.id="bookmark-icon-"+e;d.appendChild(document.createTextNode("\u2605 "));f.parentNode.insertBefore(d,f)}c(e)}else{var f=document.getElementById("bookmark-"+e);f&&(f.innerHTML="\u2605")}else if(Miniflux.Nav.IsListing())(d=document.getElementById("bookmark-icon-"+e))&&d.parentNode.removeChild(d),c(e);else if(d=document.getElementById("bookmark-"+e))d.innerHTML="\u2606"};d.open("POST",
|
a);if(a)if(Miniflux.Nav.IsListing()){if(f=document.getElementById("show-"+e)){var d=document.createElement("span");d.id="bookmark-icon-"+e;d.appendChild(document.createTextNode("\u2605 "));f.parentNode.insertBefore(d,f)}c(e)}else{var f=document.getElementById("bookmark-"+e);f&&(f.innerHTML="\u2605")}else if(Miniflux.Nav.IsListing())(d=document.getElementById("bookmark-icon-"+e))&&d.parentNode.removeChild(d),c(e);else if(d=document.getElementById("bookmark-"+e))d.innerHTML="\u2606"};d.open("POST",
|
||||||
"?action=bookmark&id="+e+"&value="+a,!0);d.send()}return{Get:d,MarkAsRead:f,MarkAsUnread:h,SwitchBookmark:function(b){"1"==b.getAttribute("data-item-bookmark")?l(b,0):l(b,1)},SwitchStatus:function(b){var a=b.getAttribute("data-item-id");b=b.getAttribute("data-item-status");"read"==b?h(a):"unread"==b&&f(a)},ChangeStatus:function(b,a){switch(a){case "read":f(b);break;case "unread":h(b)}},Show:function(b){(b=document.getElementById("show-"+b))&&b.click()},OpenOriginal:function(b){var a=document.getElementById("original-"+
|
"?action=bookmark&id="+e+"&value="+a,!0);d.send()}return{Get:d,MarkAsRead:f,MarkAsUnread:h,SwitchBookmark:function(b){"1"==b.getAttribute("data-item-bookmark")?l(b,0):l(b,1)},SwitchStatus:function(b){var a=b.getAttribute("data-item-id");b=b.getAttribute("data-item-status");"read"==b?h(a):"unread"==b&&f(a)},ChangeStatus:function(b,a){switch(a){case "read":f(b);break;case "unread":h(b)}},Show:function(b){(b=document.getElementById("show-"+b))&&b.click()},OpenOriginal:function(b){var a=document.getElementById("original-"+
|
||||||
|
@ -93,7 +93,7 @@ Miniflux.Item = (function() {
|
|||||||
|
|
||||||
var icon = document.createElement("span");
|
var icon = document.createElement("span");
|
||||||
icon.id = "read-icon-" + item_id;
|
icon.id = "read-icon-" + item_id;
|
||||||
icon.appendChild(document.createTextNode("☑ "));
|
icon.appendChild(document.createTextNode("✔ "));
|
||||||
link.parentNode.insertBefore(icon, link);
|
link.parentNode.insertBefore(icon, link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require __DIR__.'/check_setup.php';
|
require __DIR__.'/check_setup.php';
|
||||||
require __DIR__.'/vendor/PicoTools/Translator.php';
|
require __DIR__.'/lib/Translator.php';
|
||||||
require __DIR__.'/vendor/PicoDb/Database.php';
|
require __DIR__.'/vendor/PicoDb/Database.php';
|
||||||
require __DIR__.'/vendor/PicoFeed/Client.php';
|
require __DIR__.'/vendor/PicoFeed/Client.php';
|
||||||
require __DIR__.'/vendor/PicoFeed/Parser.php';
|
require __DIR__.'/vendor/PicoFeed/Parser.php';
|
||||||
|
@ -6,7 +6,7 @@ use PicoFarad\Router;
|
|||||||
use PicoFarad\Response;
|
use PicoFarad\Response;
|
||||||
use PicoFarad\Request;
|
use PicoFarad\Request;
|
||||||
use PicoFarad\Session;
|
use PicoFarad\Session;
|
||||||
use PicoTools\Template;
|
use PicoFarad\Template;
|
||||||
|
|
||||||
// Ajax call to add or remove a bookmark
|
// Ajax call to add or remove a bookmark
|
||||||
Router\post_action('bookmark', function() {
|
Router\post_action('bookmark', function() {
|
||||||
|
@ -4,7 +4,7 @@ use PicoFarad\Router;
|
|||||||
use PicoFarad\Response;
|
use PicoFarad\Response;
|
||||||
use PicoFarad\Request;
|
use PicoFarad\Request;
|
||||||
use PicoFarad\Session;
|
use PicoFarad\Session;
|
||||||
use PicoTools\Template;
|
use PicoFarad\Template;
|
||||||
|
|
||||||
// Called before each action
|
// Called before each action
|
||||||
Router\before(function($action) {
|
Router\before(function($action) {
|
||||||
@ -19,7 +19,7 @@ Router\before(function($action) {
|
|||||||
|
|
||||||
// Load translations
|
// Load translations
|
||||||
$language = Model\Config\get('language') ?: 'en_US';
|
$language = Model\Config\get('language') ?: 'en_US';
|
||||||
if ($language !== 'en_US') PicoTools\Translator\load($language);
|
if ($language !== 'en_US') \Translator\load($language);
|
||||||
|
|
||||||
// Set timezone
|
// Set timezone
|
||||||
date_default_timezone_set(Model\Config\get('timezone') ?: 'UTC');
|
date_default_timezone_set(Model\Config\get('timezone') ?: 'UTC');
|
||||||
|
@ -4,7 +4,7 @@ use PicoFarad\Router;
|
|||||||
use PicoFarad\Response;
|
use PicoFarad\Response;
|
||||||
use PicoFarad\Request;
|
use PicoFarad\Request;
|
||||||
use PicoFarad\Session;
|
use PicoFarad\Session;
|
||||||
use PicoTools\Template;
|
use PicoFarad\Template;
|
||||||
use PicoDb\Database;
|
use PicoDb\Database;
|
||||||
|
|
||||||
// Re-generate tokens
|
// Re-generate tokens
|
||||||
|
@ -4,7 +4,7 @@ use PicoFarad\Router;
|
|||||||
use PicoFarad\Response;
|
use PicoFarad\Response;
|
||||||
use PicoFarad\Request;
|
use PicoFarad\Request;
|
||||||
use PicoFarad\Session;
|
use PicoFarad\Session;
|
||||||
use PicoTools\Template;
|
use PicoFarad\Template;
|
||||||
|
|
||||||
// Flush console messages
|
// Flush console messages
|
||||||
Router\get_action('flush-console', function() {
|
Router\get_action('flush-console', function() {
|
||||||
|
@ -4,7 +4,7 @@ use PicoFarad\Router;
|
|||||||
use PicoFarad\Response;
|
use PicoFarad\Response;
|
||||||
use PicoFarad\Request;
|
use PicoFarad\Request;
|
||||||
use PicoFarad\Session;
|
use PicoFarad\Session;
|
||||||
use PicoTools\Template;
|
use PicoFarad\Template;
|
||||||
|
|
||||||
// Refresh all feeds, used when Javascript is disabled
|
// Refresh all feeds, used when Javascript is disabled
|
||||||
Router\get_action('refresh-all', function() {
|
Router\get_action('refresh-all', function() {
|
||||||
|
@ -4,7 +4,7 @@ use PicoFarad\Router;
|
|||||||
use PicoFarad\Response;
|
use PicoFarad\Response;
|
||||||
use PicoFarad\Request;
|
use PicoFarad\Request;
|
||||||
use PicoFarad\Session;
|
use PicoFarad\Session;
|
||||||
use PicoTools\Template;
|
use PicoFarad\Template;
|
||||||
|
|
||||||
// Display history page
|
// Display history page
|
||||||
Router\get_action('history', function() {
|
Router\get_action('history', function() {
|
||||||
|
@ -4,7 +4,7 @@ use PicoFarad\Router;
|
|||||||
use PicoFarad\Response;
|
use PicoFarad\Response;
|
||||||
use PicoFarad\Request;
|
use PicoFarad\Request;
|
||||||
use PicoFarad\Session;
|
use PicoFarad\Session;
|
||||||
use PicoTools\Template;
|
use PicoFarad\Template;
|
||||||
|
|
||||||
// Display unread items
|
// Display unread items
|
||||||
Router\get_action('unread', function() {
|
Router\get_action('unread', function() {
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/../lib/AuthProvider.php';
|
||||||
|
|
||||||
use PicoFarad\Router;
|
use PicoFarad\Router;
|
||||||
use PicoFarad\Response;
|
use PicoFarad\Response;
|
||||||
use PicoFarad\Request;
|
use PicoFarad\Request;
|
||||||
use PicoFarad\Session;
|
use PicoFarad\Session;
|
||||||
use PicoTools\Template;
|
use PicoFarad\Template;
|
||||||
|
|
||||||
// Logout and destroy session
|
// Logout and destroy session
|
||||||
Router\get_action('logout', function() {
|
Router\get_action('logout', function() {
|
||||||
@ -45,15 +47,12 @@ Router\post_action('login', function() {
|
|||||||
// Link to a Google Account (redirect)
|
// Link to a Google Account (redirect)
|
||||||
Router\get_action('google-redirect-link', function() {
|
Router\get_action('google-redirect-link', function() {
|
||||||
|
|
||||||
require 'vendor/PicoTools/AuthProvider.php';
|
|
||||||
Response\Redirect(AuthProvider\google_get_url(Helper\get_current_base_url(), '?action=google-link'));
|
Response\Redirect(AuthProvider\google_get_url(Helper\get_current_base_url(), '?action=google-link'));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Link to a Google Account (association)
|
// Link to a Google Account (association)
|
||||||
Router\get_action('google-link', function() {
|
Router\get_action('google-link', function() {
|
||||||
|
|
||||||
require 'vendor/PicoTools/AuthProvider.php';
|
|
||||||
|
|
||||||
list($valid, $token) = AuthProvider\google_validate();
|
list($valid, $token) = AuthProvider\google_validate();
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
@ -70,15 +69,12 @@ Router\get_action('google-link', function() {
|
|||||||
// Authenticate with a Google Account (redirect)
|
// Authenticate with a Google Account (redirect)
|
||||||
Router\get_action('google-redirect-auth', function() {
|
Router\get_action('google-redirect-auth', function() {
|
||||||
|
|
||||||
require 'vendor/PicoTools/AuthProvider.php';
|
|
||||||
Response\Redirect(AuthProvider\google_get_url(Helper\get_current_base_url(), '?action=google-auth'));
|
Response\Redirect(AuthProvider\google_get_url(Helper\get_current_base_url(), '?action=google-auth'));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Authenticate with a Google Account (callback url)
|
// Authenticate with a Google Account (callback url)
|
||||||
Router\get_action('google-auth', function() {
|
Router\get_action('google-auth', function() {
|
||||||
|
|
||||||
require 'vendor/PicoTools/AuthProvider.php';
|
|
||||||
|
|
||||||
list($valid, $token) = AuthProvider\google_validate();
|
list($valid, $token) = AuthProvider\google_validate();
|
||||||
|
|
||||||
if ($valid && $token === Model\Config\get('auth_google_token')) {
|
if ($valid && $token === Model\Config\get('auth_google_token')) {
|
||||||
@ -104,8 +100,6 @@ Router\get_action('google-auth', function() {
|
|||||||
// Authenticate with a Mozilla Persona (ajax check)
|
// Authenticate with a Mozilla Persona (ajax check)
|
||||||
Router\post_action('mozilla-auth', function() {
|
Router\post_action('mozilla-auth', function() {
|
||||||
|
|
||||||
require 'vendor/PicoTools/AuthProvider.php';
|
|
||||||
|
|
||||||
list($valid, $token) = AuthProvider\mozilla_validate(Request\param('token'));
|
list($valid, $token) = AuthProvider\mozilla_validate(Request\param('token'));
|
||||||
|
|
||||||
if ($valid && $token === Model\Config\get('auth_mozilla_token')) {
|
if ($valid && $token === Model\Config\get('auth_mozilla_token')) {
|
||||||
@ -125,8 +119,6 @@ Router\post_action('mozilla-auth', function() {
|
|||||||
// Link Miniflux to a Mozilla Account (ajax check)
|
// Link Miniflux to a Mozilla Account (ajax check)
|
||||||
Router\post_action('mozilla-link', function() {
|
Router\post_action('mozilla-link', function() {
|
||||||
|
|
||||||
require 'vendor/PicoTools/AuthProvider.php';
|
|
||||||
|
|
||||||
list($valid, $token) = AuthProvider\mozilla_validate(Request\param('token'));
|
list($valid, $token) = AuthProvider\mozilla_validate(Request\param('token'));
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require __DIR__.'/common.php';
|
require __DIR__.'/common.php';
|
||||||
require __DIR__.'/vendor/PicoTools/Template.php';
|
require __DIR__.'/vendor/PicoFarad/Template.php';
|
||||||
require __DIR__.'/vendor/PicoFarad/Response.php';
|
require __DIR__.'/vendor/PicoFarad/Response.php';
|
||||||
require __DIR__.'/vendor/PicoFarad/Request.php';
|
require __DIR__.'/vendor/PicoFarad/Request.php';
|
||||||
require __DIR__.'/vendor/PicoFarad/Session.php';
|
require __DIR__.'/vendor/PicoFarad/Session.php';
|
||||||
require __DIR__.'/vendor/PicoFarad/Router.php';
|
require __DIR__.'/vendor/PicoFarad/Router.php';
|
||||||
require __DIR__.'/helpers.php';
|
require __DIR__.'/lib/helpers.php';
|
||||||
|
|
||||||
use PicoFarad\Router;
|
use PicoFarad\Router;
|
||||||
use PicoFarad\Response;
|
use PicoFarad\Response;
|
||||||
|
1
lib/.htaccess
Normal file
1
lib/.htaccess
Normal file
@ -0,0 +1 @@
|
|||||||
|
Deny from all
|
@ -1,15 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
namespace Translator {
|
||||||
* This file is part of PicoTools.
|
|
||||||
*
|
|
||||||
* (c) Frédéric Guillot http://fredericguillot.com
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace PicoTools\Translator {
|
|
||||||
|
|
||||||
const PATH = 'locales/';
|
const PATH = 'locales/';
|
||||||
|
|
||||||
@ -137,26 +128,25 @@ namespace PicoTools\Translator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
function tne() {
|
function tne() {
|
||||||
return call_user_func_array('\PicoTools\Translator\translate_no_escaping', func_get_args());
|
return call_user_func_array('\Translator\translate_no_escaping', func_get_args());
|
||||||
}
|
}
|
||||||
|
|
||||||
function t() {
|
function t() {
|
||||||
return call_user_func_array('\PicoTools\Translator\translate', func_get_args());
|
return call_user_func_array('\Translator\translate', func_get_args());
|
||||||
}
|
}
|
||||||
|
|
||||||
function c() {
|
function c() {
|
||||||
return call_user_func_array('\PicoTools\Translator\currency', func_get_args());
|
return call_user_func_array('\Translator\currency', func_get_args());
|
||||||
}
|
}
|
||||||
|
|
||||||
function n() {
|
function n() {
|
||||||
return call_user_func_array('\PicoTools\Translator\number', func_get_args());
|
return call_user_func_array('\Translator\number', func_get_args());
|
||||||
}
|
}
|
||||||
|
|
||||||
function dt() {
|
function dt() {
|
||||||
return call_user_func_array('\PicoTools\Translator\datetime', func_get_args());
|
return call_user_func_array('\Translator\datetime', func_get_args());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -268,7 +268,7 @@ function save(array $values)
|
|||||||
$_SESSION['config'] = $values;
|
$_SESSION['config'] = $values;
|
||||||
|
|
||||||
// Reload translations for flash session message
|
// Reload translations for flash session message
|
||||||
\PicoTools\Translator\load($values['language']);
|
\Translator\load($values['language']);
|
||||||
|
|
||||||
// If the user does not want content of feeds, remove it in previous ones
|
// If the user does not want content of feeds, remove it in previous ones
|
||||||
if (isset($values['nocontent']) && (bool) $values['nocontent']) {
|
if (isset($values['nocontent']) && (bool) $values['nocontent']) {
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
<section class="items" id="listing">
|
<section class="items" id="listing">
|
||||||
<?php foreach ($items as $item): ?>
|
<?php foreach ($items as $item): ?>
|
||||||
<?= \PicoTools\Template\load('item', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'hide' => false)) ?>
|
<?= \PicoFarad\Template\load('item', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'hide' => false)) ?>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|
||||||
<?= \PicoTools\Template\load('paging', array('menu' => $menu, 'nb_items' => $nb_items, 'items_per_page' => $items_per_page, 'offset' => $offset, 'order' => $order, 'direction' => $direction)) ?>
|
<?= \PicoFarad\Template\load('paging', array('menu' => $menu, 'nb_items' => $nb_items, 'items_per_page' => $items_per_page, 'offset' => $offset, 'order' => $order, 'direction' => $direction)) ?>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
@ -87,7 +87,7 @@
|
|||||||
<li><a href="?action=download-db"><?= t('Download the entire database') ?></a> <?= t('(Gzip compressed Sqlite file)') ?></li>
|
<li><a href="?action=download-db"><?= t('Download the entire database') ?></a> <?= t('(Gzip compressed Sqlite file)') ?></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<?= \PicoTools\Template\load('keyboard_shortcuts') ?>
|
<?= \PicoFarad\Template\load('keyboard_shortcuts') ?>
|
||||||
<div class="alert alert-normal">
|
<div class="alert alert-normal">
|
||||||
<h3><?= t('About') ?></h3>
|
<h3><?= t('About') ?></h3>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -18,14 +18,14 @@
|
|||||||
|
|
||||||
<section class="items" id="listing">
|
<section class="items" id="listing">
|
||||||
<?php foreach ($items as $item): ?>
|
<?php foreach ($items as $item): ?>
|
||||||
<?= \PicoTools\Template\load('item', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'hide' => false)) ?>
|
<?= \PicoFarad\Template\load('item', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'hide' => false)) ?>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|
||||||
<div id="bottom-menu">
|
<div id="bottom-menu">
|
||||||
<a href="?action=mark-feed-as-read&feed_id=<?= $feed['id'] ?>" data-action="mark-feed-read" data-feed-id="<?= $feed['id'] ?>"><?= t('mark all as read') ?></a>
|
<a href="?action=mark-feed-as-read&feed_id=<?= $feed['id'] ?>" data-action="mark-feed-read" data-feed-id="<?= $feed['id'] ?>"><?= t('mark all as read') ?></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?= \PicoTools\Template\load('paging', array('menu' => $menu, 'nb_items' => $nb_items, 'items_per_page' => $items_per_page, 'offset' => $offset, 'order' => $order, 'direction' => $direction, 'feed_id' => $feed['id'])) ?>
|
<?= \PicoFarad\Template\load('paging', array('menu' => $menu, 'nb_items' => $nb_items, 'items_per_page' => $items_per_page, 'offset' => $offset, 'order' => $order, 'direction' => $direction, 'feed_id' => $feed['id'])) ?>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
@ -15,10 +15,10 @@
|
|||||||
|
|
||||||
<section class="items" id="listing">
|
<section class="items" id="listing">
|
||||||
<?php foreach ($items as $item): ?>
|
<?php foreach ($items as $item): ?>
|
||||||
<?= \PicoTools\Template\load('item', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'hide' => true)) ?>
|
<?= \PicoFarad\Template\load('item', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'hide' => true)) ?>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|
||||||
<?= \PicoTools\Template\load('paging', array('menu' => $menu, 'nb_items' => $nb_items, 'items_per_page' => $items_per_page, 'offset' => $offset, 'order' => $order, 'direction' => $direction)) ?>
|
<?= \PicoFarad\Template\load('paging', array('menu' => $menu, 'nb_items' => $nb_items, 'items_per_page' => $items_per_page, 'offset' => $offset, 'order' => $order, 'direction' => $direction)) ?>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
<a href="<?= $item['enclosure'] ?>" rel="noreferrer" target="_blank"><?= t('media') ?></a>
|
<a href="<?= $item['enclosure'] ?>" rel="noreferrer" target="_blank"><?= t('media') ?></a>
|
||||||
</li>
|
</li>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?= \PicoTools\Template\load('bookmark_links', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'source' => '')) ?>
|
<?= \PicoFarad\Template\load('bookmark_links', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'source' => '')) ?>
|
||||||
<?= \PicoTools\Template\load('status_links', array('item' => $item, 'redirect' => $menu, 'offset' => $offset)) ?>
|
<?= \PicoFarad\Template\load('status_links', array('item' => $item, 'redirect' => $menu, 'offset' => $offset)) ?>
|
||||||
</ul>
|
</ul>
|
||||||
</article>
|
</article>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<h2><?= t('Help') ?></h2>
|
<h2><?= t('Help') ?></h2>
|
||||||
</div>
|
</div>
|
||||||
<section>
|
<section>
|
||||||
<?= \PicoTools\Template\load('keyboard_shortcuts') ?>
|
<?= \PicoFarad\Template\load('keyboard_shortcuts') ?>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
</body>
|
</body>
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
|
|
||||||
<section class="items" id="listing">
|
<section class="items" id="listing">
|
||||||
<?php foreach ($items as $item): ?>
|
<?php foreach ($items as $item): ?>
|
||||||
<?= \PicoTools\Template\load('item', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'hide' => true)) ?>
|
<?= \PicoFarad\Template\load('item', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'hide' => true)) ?>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|
||||||
<div id="bottom-menu">
|
<div id="bottom-menu">
|
||||||
<a href="?action=mark-as-read" data-action="mark-all-read"><?= t('mark all as read') ?></a>
|
<a href="?action=mark-as-read" data-action="mark-all-read"><?= t('mark all as read') ?></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?= \PicoTools\Template\load('paging', array('menu' => $menu, 'nb_items' => $nb_items, 'items_per_page' => $items_per_page, 'offset' => $offset, 'order' => $order, 'direction' => $direction)) ?>
|
<?= \PicoFarad\Template\load('paging', array('menu' => $menu, 'nb_items' => $nb_items, 'items_per_page' => $items_per_page, 'offset' => $offset, 'order' => $order, 'direction' => $direction)) ?>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
4
vendor/PicoFarad/Response.php
vendored
4
vendor/PicoFarad/Response.php
vendored
@ -17,7 +17,9 @@ function content_type($mimetype)
|
|||||||
|
|
||||||
function status($status_code)
|
function status($status_code)
|
||||||
{
|
{
|
||||||
if (strpos(php_sapi_name(), 'apache') !== false) {
|
$sapi_name = php_sapi_name();
|
||||||
|
|
||||||
|
if (strpos($sapi_name, 'apache') !== false || $sapi_name === 'cli-server') {
|
||||||
header('HTTP/1.0 '.$status_code);
|
header('HTTP/1.0 '.$status_code);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
6
vendor/PicoFarad/Router.php
vendored
6
vendor/PicoFarad/Router.php
vendored
@ -104,12 +104,10 @@ function find_route($method, $route, \Closure $callback)
|
|||||||
{
|
{
|
||||||
if ($_SERVER['REQUEST_METHOD'] === $method) {
|
if ($_SERVER['REQUEST_METHOD'] === $method) {
|
||||||
|
|
||||||
if ($_SERVER['QUERY_STRING']) {
|
if (! empty($_SERVER['QUERY_STRING'])) {
|
||||||
|
|
||||||
$url = substr($_SERVER['REQUEST_URI'], 0, -(strlen($_SERVER['QUERY_STRING']) + 1));
|
$url = substr($_SERVER['REQUEST_URI'], 0, -(strlen($_SERVER['QUERY_STRING']) + 1));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
$url = $_SERVER['REQUEST_URI'];
|
$url = $_SERVER['REQUEST_URI'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +115,7 @@ function find_route($method, $route, \Closure $callback)
|
|||||||
|
|
||||||
if (url_match($route, $url, $params)) {
|
if (url_match($route, $url, $params)) {
|
||||||
|
|
||||||
before($handler);
|
before($route);
|
||||||
\call_user_func_array($callback, $params);
|
\call_user_func_array($callback, $params);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
namespace PicoFarad\Template;
|
||||||
* This file is part of PicoTools.
|
|
||||||
*
|
|
||||||
* (c) Frédéric Guillot http://fredericguillot.com
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace PicoTools\Template;
|
|
||||||
|
|
||||||
const PATH = 'templates/';
|
const PATH = 'templates/';
|
||||||
|
|
||||||
|
|
||||||
// Template\load('template_name', ['bla' => 'value']);
|
// Template\load('template_name', ['bla' => 'value']);
|
||||||
function load()
|
function load()
|
||||||
{
|
{
|
||||||
if (func_num_args() < 1 || func_num_args() > 2) {
|
if (func_num_args() < 1 || func_num_args() > 2) {
|
||||||
|
|
||||||
die('Invalid template arguments');
|
die('Invalid template arguments');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! file_exists(PATH.func_get_arg(0).'.php')) {
|
if (! file_exists(PATH.func_get_arg(0).'.php')) {
|
||||||
|
|
||||||
die('Unable to load the template: "'.func_get_arg(0).'"');
|
die('Unable to load the template: "'.func_get_arg(0).'"');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (func_num_args() === 2) {
|
if (func_num_args() === 2) {
|
||||||
|
|
||||||
if (! is_array(func_get_arg(1))) {
|
if (! is_array(func_get_arg(1))) {
|
||||||
|
|
||||||
die('Template variables must be an array');
|
die('Template variables must be an array');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,9 +25,7 @@ function load()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
include PATH.func_get_arg(0).'.php';
|
include PATH.func_get_arg(0).'.php';
|
||||||
|
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
}
|
}
|
||||||
|
|
175
vendor/PicoTools/Command.php
vendored
175
vendor/PicoTools/Command.php
vendored
@ -1,175 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of picoTools.
|
|
||||||
*
|
|
||||||
* (c) Frédéric Guillot http://fredericguillot.com
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace PicoTools;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute an external command
|
|
||||||
*
|
|
||||||
* @author Frédéric Guillot
|
|
||||||
*/
|
|
||||||
class Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Command line
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $cmd_line = '';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Command stdout
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $cmd_stdout = '';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Command stderr
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $cmd_sdterr = '';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Command environements variables
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $cmd_env = array();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Command working directory
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $cmd_dir = null;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Command return value
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var integer
|
|
||||||
*/
|
|
||||||
private $cmd_return = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param string $command Command line
|
|
||||||
*/
|
|
||||||
public function __construct($command)
|
|
||||||
{
|
|
||||||
$this->cmd_line = $command;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the command
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public function execute()
|
|
||||||
{
|
|
||||||
$process = proc_open(
|
|
||||||
$this->cmd_line,
|
|
||||||
array(
|
|
||||||
0 => array('pipe', 'r'),
|
|
||||||
1 => array('pipe', 'w'),
|
|
||||||
2 => array('pipe', 'w')
|
|
||||||
),
|
|
||||||
$pipes,
|
|
||||||
$this->cmd_dir,
|
|
||||||
$this->cmd_env
|
|
||||||
);
|
|
||||||
|
|
||||||
if (is_resource($process)) {
|
|
||||||
|
|
||||||
$this->cmd_stdout = stream_get_contents($pipes[1]);
|
|
||||||
$this->cmd_stderr = stream_get_contents($pipes[2]);
|
|
||||||
$this->cmd_return = proc_close($process);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set working directory
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param string $dir Working directory
|
|
||||||
*/
|
|
||||||
public function setDir($dir)
|
|
||||||
{
|
|
||||||
$this->cmd_dir = $dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set command env variables
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param array $env Environnement variables
|
|
||||||
*/
|
|
||||||
public function setEnv(array $env)
|
|
||||||
{
|
|
||||||
$this->cmd_env = $env;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the return value
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return integer Return value
|
|
||||||
*/
|
|
||||||
public function getReturnValue()
|
|
||||||
{
|
|
||||||
return $this->cmd_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get stdout
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return string stdout
|
|
||||||
*/
|
|
||||||
public function getStdout()
|
|
||||||
{
|
|
||||||
return $this->cmd_stdout;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get stderr
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return string stderr
|
|
||||||
*/
|
|
||||||
public function getStderr()
|
|
||||||
{
|
|
||||||
return $this->cmd_stderr;
|
|
||||||
}
|
|
||||||
}
|
|
97
vendor/PicoTools/Config.php
vendored
97
vendor/PicoTools/Config.php
vendored
@ -1,97 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of PicoTools.
|
|
||||||
*
|
|
||||||
* (c) Frédéric Guillot http://fredericguillot.com
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace PicoTools;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle configuration parameters
|
|
||||||
*
|
|
||||||
* @author Frédéric Guillot
|
|
||||||
*/
|
|
||||||
class Config
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Container
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @static
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $container = array();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a new configuration parameter
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @static
|
|
||||||
* @param string $name Parameter name
|
|
||||||
* @param string $value Parameter value
|
|
||||||
*/
|
|
||||||
public static function set($name, $value)
|
|
||||||
{
|
|
||||||
self::$container[$name] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch a parameter value
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @static
|
|
||||||
* @param string $name Parameter name
|
|
||||||
* @param string $defaultValue Default parameter value
|
|
||||||
*/
|
|
||||||
public static function get($name, $defaultValue = null)
|
|
||||||
{
|
|
||||||
return isset(self::$container[$name]) ? self::$container[$name] : $defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load a PHP config file
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
public static function load($env = null)
|
|
||||||
{
|
|
||||||
if ($env !== null) {
|
|
||||||
|
|
||||||
$filename = 'config/'.$env.'.php';
|
|
||||||
|
|
||||||
if (file_exists($filename)) {
|
|
||||||
|
|
||||||
require $filename;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
throw new \RuntimeException('Unable to load the config file: '.$filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
if (file_exists('config/prod.php')) {
|
|
||||||
|
|
||||||
require 'config/prod.php';
|
|
||||||
}
|
|
||||||
else if (file_exists('config/dev.php')) {
|
|
||||||
|
|
||||||
require 'config/dev.php';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
throw new \RuntimeException('No config file loaded.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
49
vendor/PicoTools/Dependency_Injection.php
vendored
49
vendor/PicoTools/Dependency_Injection.php
vendored
@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of PicoTools.
|
|
||||||
*
|
|
||||||
* (c) Frédéric Guillot http://fredericguillot.com
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace PicoTools;
|
|
||||||
|
|
||||||
|
|
||||||
function singleton($name)
|
|
||||||
{
|
|
||||||
static $instance = array();
|
|
||||||
|
|
||||||
if (! isset($instance[$name])) {
|
|
||||||
|
|
||||||
$callback = container($name);
|
|
||||||
|
|
||||||
if (! is_callable($callback)) {
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$instance[$name] = $callback();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $instance[$name];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function container($name, $value = null)
|
|
||||||
{
|
|
||||||
static $container = array();
|
|
||||||
|
|
||||||
if (null !== $value) {
|
|
||||||
|
|
||||||
$container[$name] = $value;
|
|
||||||
}
|
|
||||||
else if (isset($container[$name])) {
|
|
||||||
|
|
||||||
return $container[$name];
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
240
vendor/PicoTools/Helper.php
vendored
240
vendor/PicoTools/Helper.php
vendored
@ -1,240 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Helper;
|
|
||||||
|
|
||||||
function get_current_base_url()
|
|
||||||
{
|
|
||||||
$url = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
|
|
||||||
$url .= $_SERVER['SERVER_NAME'];
|
|
||||||
$url .= $_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443 ? '' : ':'.$_SERVER['SERVER_PORT'];
|
|
||||||
$url .= dirname($_SERVER['PHP_SELF']) !== '/' ? dirname($_SERVER['PHP_SELF']).'/' : '/';
|
|
||||||
|
|
||||||
return $url;
|
|
||||||
}
|
|
||||||
|
|
||||||
function escape($value)
|
|
||||||
{
|
|
||||||
return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function flash($html)
|
|
||||||
{
|
|
||||||
$data = '';
|
|
||||||
|
|
||||||
if (isset($_SESSION['flash_message'])) {
|
|
||||||
$data = sprintf($html, escape($_SESSION['flash_message']));
|
|
||||||
unset($_SESSION['flash_message']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
function flash_error($html)
|
|
||||||
{
|
|
||||||
$data = '';
|
|
||||||
|
|
||||||
if (isset($_SESSION['flash_error_message'])) {
|
|
||||||
$data = sprintf($html, escape($_SESSION['flash_error_message']));
|
|
||||||
unset($_SESSION['flash_error_message']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
function format_bytes($size, $precision = 2)
|
|
||||||
{
|
|
||||||
$base = log($size) / log(1024);
|
|
||||||
$suffixes = array('', 'k', 'M', 'G', 'T');
|
|
||||||
|
|
||||||
return round(pow(1024, $base - floor($base)), $precision).$suffixes[floor($base)];
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_host_from_url($url)
|
|
||||||
{
|
|
||||||
return escape(parse_url($url, PHP_URL_HOST)) ?: $url;
|
|
||||||
}
|
|
||||||
|
|
||||||
function summary($value, $min_length = 5, $max_length = 120, $end = '[...]')
|
|
||||||
{
|
|
||||||
$length = strlen($value);
|
|
||||||
|
|
||||||
if ($length > $max_length) {
|
|
||||||
return substr($value, 0, strpos($value, ' ', $max_length)).' '.$end;
|
|
||||||
}
|
|
||||||
else if ($length < $min_length) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
function in_list($id, array $listing)
|
|
||||||
{
|
|
||||||
if (isset($listing[$id])) {
|
|
||||||
return escape($listing[$id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return '?';
|
|
||||||
}
|
|
||||||
|
|
||||||
function relative_time($timestamp, $fallback_date_format = '%e %B %Y %k:%M')
|
|
||||||
{
|
|
||||||
$diff = time() - $timestamp;
|
|
||||||
|
|
||||||
if ($diff < 60) return \t('%d second'.($diff > 1 ? 's' : '').' ago', $diff);
|
|
||||||
|
|
||||||
$diff = floor($diff / 60);
|
|
||||||
if ($diff < 60) return \t('%d minute'.($diff > 1 ? 's' : '').' ago', $diff);
|
|
||||||
|
|
||||||
$diff = floor($diff / 60);
|
|
||||||
if ($diff < 24) return \t('%d hour'.($diff > 1 ? 's' : '').' ago', $diff);
|
|
||||||
|
|
||||||
$diff = floor($diff / 24);
|
|
||||||
if ($diff < 7) return \t('%d day'.($diff > 1 ? 's' : '').' ago', $diff);
|
|
||||||
|
|
||||||
$diff = floor($diff / 7);
|
|
||||||
if ($diff < 4) return \t('%d week'.($diff > 1 ? 's' : '').' ago', $diff);
|
|
||||||
|
|
||||||
$diff = floor($diff / 4);
|
|
||||||
if ($diff < 12) return \t('%d month'.($diff > 1 ? 's' : '').' ago', $diff);
|
|
||||||
|
|
||||||
return \dt($fallback_date_format, $timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
function error_class(array $errors, $name)
|
|
||||||
{
|
|
||||||
return ! isset($errors[$name]) ? '' : ' form-error';
|
|
||||||
}
|
|
||||||
|
|
||||||
function error_list(array $errors, $name)
|
|
||||||
{
|
|
||||||
$html = '';
|
|
||||||
|
|
||||||
if (isset($errors[$name])) {
|
|
||||||
|
|
||||||
$html .= '<ul class="form-errors">';
|
|
||||||
|
|
||||||
foreach ($errors[$name] as $error) {
|
|
||||||
$html .= '<li>'.escape($error).'</li>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$html .= '</ul>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_value($values, $name)
|
|
||||||
{
|
|
||||||
if (isset($values->$name)) {
|
|
||||||
return 'value="'.escape($values->$name).'"';
|
|
||||||
}
|
|
||||||
|
|
||||||
return isset($values[$name]) ? 'value="'.escape($values[$name]).'"' : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_hidden($name, $values = array())
|
|
||||||
{
|
|
||||||
return '<input type="hidden" name="'.$name.'" id="form-'.$name.'" '.form_value($values, $name).'/>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_default_select($name, array $options, $values = array(), array $errors = array(), $class = '')
|
|
||||||
{
|
|
||||||
$options = array('' => '?') + $options;
|
|
||||||
return form_select($name, $options, $values, $errors, $class);
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_select($name, array $options, $values = array(), array $errors = array(), $class = '')
|
|
||||||
{
|
|
||||||
$html = '<select name="'.$name.'" id="form-'.$name.'" class="'.$class.'">';
|
|
||||||
|
|
||||||
foreach ($options as $id => $value) {
|
|
||||||
|
|
||||||
$html .= '<option value="'.escape($id).'"';
|
|
||||||
|
|
||||||
if (isset($values->$name) && $id == $values->$name) $html .= ' selected="selected"';
|
|
||||||
if (isset($values[$name]) && $id == $values[$name]) $html .= ' selected="selected"';
|
|
||||||
|
|
||||||
$html .= '>'.escape($value).'</option>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$html .= '</select>';
|
|
||||||
$html .= error_list($errors, $name);
|
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_radios($name, array $options, array $values = array())
|
|
||||||
{
|
|
||||||
$html = '';
|
|
||||||
|
|
||||||
foreach ($options as $value => $label) {
|
|
||||||
$html .= form_radio($name, $label, $value, isset($values[$name]) && $values[$name] == $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_radio($name, $label, $value, $selected = false, $class = '')
|
|
||||||
{
|
|
||||||
return '<label><input type="radio" name="'.$name.'" class="'.$class.'" value="'.escape($value).'" '.($selected ? 'selected="selected"' : '').'>'.escape($label).'</label>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_checkbox($name, $label, $value, $checked = false, $class = '')
|
|
||||||
{
|
|
||||||
return '<label><input type="checkbox" name="'.$name.'" class="'.$class.'" value="'.escape($value).'" '.($checked ? 'checked="checked"' : '').'> '.escape($label).'</label>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_label($label, $name, $class = '')
|
|
||||||
{
|
|
||||||
return '<label for="form-'.$name.'" class="'.$class.'">'.escape($label).'</label>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_textarea($name, $values = array(), array $errors = array(), array $attributes = array(), $class = '')
|
|
||||||
{
|
|
||||||
$class .= error_class($errors, $name);
|
|
||||||
|
|
||||||
$html = '<textarea name="'.$name.'" id="form-'.$name.'" class="'.$class.'" ';
|
|
||||||
$html .= implode(' ', $attributes).'>';
|
|
||||||
$html .= isset($values->$name) ? escape($values->$name) : isset($values[$name]) ? $values[$name] : '';
|
|
||||||
$html .= '</textarea>';
|
|
||||||
$html .= error_list($errors, $name);
|
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_input($type, $name, $values = array(), array $errors = array(), array $attributes = array(), $class = '')
|
|
||||||
{
|
|
||||||
$class .= error_class($errors, $name);
|
|
||||||
|
|
||||||
$html = '<input type="'.$type.'" name="'.$name.'" id="form-'.$name.'" '.form_value($values, $name).' class="'.$class.'" ';
|
|
||||||
$html .= implode(' ', $attributes).'/>';
|
|
||||||
$html .= error_list($errors, $name);
|
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_text($name, $values = array(), array $errors = array(), array $attributes = array(), $class = '')
|
|
||||||
{
|
|
||||||
return form_input('text', $name, $values, $errors, $attributes, $class);
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_password($name, $values = array(), array $errors = array(), array $attributes = array(), $class = '')
|
|
||||||
{
|
|
||||||
return form_input('password', $name, $values, $errors, $attributes, $class);
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_email($name, $values = array(), array $errors = array(), array $attributes = array(), $class = '')
|
|
||||||
{
|
|
||||||
return form_input('email', $name, $values, $errors, $attributes, $class);
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_date($name, $values = array(), array $errors = array(), array $attributes = array(), $class = '')
|
|
||||||
{
|
|
||||||
return form_input('date', $name, $values, $errors, $attributes, $class);
|
|
||||||
}
|
|
||||||
|
|
||||||
function form_number($name, $values = array(), array $errors = array(), array $attributes = array(), $class = '')
|
|
||||||
{
|
|
||||||
return form_input('number', $name, $values, $errors, $attributes, $class);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user