mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-22 04:03:41 +00:00
Code standards
This commit is contained in:
parent
2580c636d0
commit
e30188f143
1 changed files with 36 additions and 34 deletions
|
@ -14,15 +14,17 @@ use Friendica\Core\Logger;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\Protocol;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
|
|
||||||
function opmlexport_install() {
|
function opmlexport_install()
|
||||||
Hook::register("addon_settings", __FILE__, "opmlexport_addon_settings");
|
{
|
||||||
Hook::register("addon_settings_post", __FILE__, "opmlexport_addon_settings_post");
|
Hook::register('addon_settings', __FILE__, 'opmlexport_addon_settings');
|
||||||
Logger::log("installed opmlexport Addon");
|
Hook::register('addon_settings_post', __FILE__, 'opmlexport_addon_settings_post');
|
||||||
|
Logger::log('installed opmlexport Addon');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function opmlexport(App $a) {
|
|
||||||
$stmt = DBA::p("SELECT *
|
$stmt = DBA::p("SELECT *
|
||||||
FROM `contact`
|
FROM `contact`
|
||||||
WHERE `uid` = ?
|
WHERE `uid` = ?
|
||||||
|
@ -34,21 +36,22 @@ function opmlexport(App $a) {
|
||||||
[local_user(), "feed"]
|
[local_user(), "feed"]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function opmlexport(App $a)
|
||||||
|
{
|
||||||
|
|
||||||
$xml = new \DOMDocument( "1.0", "utf-8" );
|
$xml = new \DOMDocument( '1.0', 'utf-8' );
|
||||||
$opml = $xml->createElement("opml");
|
$opml = $xml->createElement('opml');
|
||||||
$head = $xml->createElement("head");
|
$head = $xml->createElement('head');
|
||||||
$body = $xml->createElement("body");
|
$body = $xml->createElement('body');
|
||||||
$outline = $xml->createElement("outline");
|
$outline = $xml->createElement('outline');
|
||||||
$outline->setAttribute("title", $a->user['username'] . "'s RSS/Atom contacts");
|
$outline->setAttribute('title', $a->user['username'] . '\'s RSS/Atom contacts');
|
||||||
$outline->setAttribute("text", $a->user['username'] . "'s RSS/Atom contacts");
|
$outline->setAttribute('text', $a->user['username'] . '\'s RSS/Atom contacts');
|
||||||
|
|
||||||
while ($c = DBA::fetch($stmt)) {
|
while ($c = DBA::fetch($stmt)) {
|
||||||
$entry = $xml->createElement("outline");
|
$entry = $xml->createElement('outline');
|
||||||
$entry->setAttribute("title", $c["name"]);
|
$entry->setAttribute('title', $c['name']);
|
||||||
$entry->setAttribute("text", $c["name"]);
|
$entry->setAttribute('text', $c['name']);
|
||||||
$entry->setAttribute("xmlUrl", $c["url"]);
|
$entry->setAttribute('xmlUrl', $c['url']);
|
||||||
// $entry->setAttribute("htmlUrl", $c[""]);
|
|
||||||
$outline->appendChild($entry);
|
$outline->appendChild($entry);
|
||||||
}
|
}
|
||||||
DBA::close($stmt);
|
DBA::close($stmt);
|
||||||
|
@ -57,33 +60,32 @@ function opmlexport(App $a) {
|
||||||
$opml->appendChild($head);
|
$opml->appendChild($head);
|
||||||
$opml->appendChild($body);
|
$opml->appendChild($body);
|
||||||
$xml->appendChild($opml);
|
$xml->appendChild($opml);
|
||||||
header("Content-Type: text/x-opml");
|
header('Content-Type: text/x-opml');
|
||||||
header("Content-Disposition: attachment; filename=feeds.opml");
|
header('Content-Disposition: attachment; filename=feeds.opml');
|
||||||
$xml->formatOutput = true;
|
$xml->formatOutput = true;
|
||||||
echo $xml->saveXML();
|
echo $xml->saveXML();
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function opmlexport_addon_settings(App $a, &$s) {
|
function opmlexport_addon_settings(App $a, &$s)
|
||||||
if (!local_user()) {
|
{
|
||||||
return;
|
if (!local_user()) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/opmlexport/');
|
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/opmlexport/');
|
||||||
$s .= Renderer::replaceMacros($t, [
|
$s .= Renderer::replaceMacros($t, [
|
||||||
'$title' => DI::l10n()->t('OPML Export'),
|
'$title' => DI::l10n()->t('OPML Export'),
|
||||||
'$submit' => DI::l10n()->t('Export RSS/Atom contacts'),
|
'$submit' => DI::l10n()->t('Export RSS/Atom contacts'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function opmlexport_addon_settings_post(App $a, &$b)
|
function opmlexport_addon_settings_post(App $a, &$b)
|
||||||
{
|
{
|
||||||
if (!local_user() || empty($_POST['opmlexport-submit'])) {
|
if (!local_user() || empty($_POST['opmlexport-submit'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
opmlexport($a);
|
opmlexport($a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue