mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-12-22 18:30:19 +00:00
Merge remote-tracking branch 'upstream/2019.06-rc' into false-positive
This commit is contained in:
commit
02fdb7c654
27 changed files with 152 additions and 779 deletions
|
@ -2,6 +2,8 @@ Cookie Notice
|
|||
|
||||
For server admins only.
|
||||
|
||||
Configure, show and handle a simple cookie usage notice. This absolute annoying but eventually necessary notification about the usage of cookies. This kind of things you klick ok on but don't read.
|
||||
Configure, show and handle a simple cookie usage notice.
|
||||
This absolute annoying but eventually necessary notification about the usage of cookies.
|
||||
This kind of things you click ok on but don't read.
|
||||
|
||||
Author: Peter liebetrau <https://socivitas.com/profile/peerteer>
|
||||
Author: Peter Liebetrau <https://socivitas.com/profile/peerteer>
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
* Description: Configure, show and handle a simple cookie notice
|
||||
* Version: 1.0
|
||||
* Author: Peter Liebetrau <https://socivitas/profile/peerteer>
|
||||
*
|
||||
*/
|
||||
use Friendica\Core\Hook;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
|
||||
|
@ -22,53 +23,31 @@ function cookienotice_install()
|
|||
{
|
||||
Hook::register('page_content_top', __FILE__, 'cookienotice_page_content_top');
|
||||
Hook::register('page_end', __FILE__, 'cookienotice_page_end');
|
||||
Hook::register('addon_settings', __FILE__, 'cookienotice_addon_settings');
|
||||
Hook::register('addon_settings_post', __FILE__, 'cookienotice_addon_settings_post');
|
||||
}
|
||||
|
||||
/**
|
||||
* cookienotice_uninstall
|
||||
* unregisters hooks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function cookienotice_uninstall()
|
||||
{
|
||||
Hook::unregister('page_content_top', __FILE__, 'cookienotice_page_content_top');
|
||||
Hook::unregister('page_end', __FILE__, 'cookienotice_page_end');
|
||||
Hook::unregister('addon_settings', __FILE__, 'cookienotice_addon_settings');
|
||||
Hook::unregister('addon_settings_post', __FILE__, 'cookienotice_addon_settings_post');
|
||||
}
|
||||
|
||||
/**
|
||||
* cookienotice_addon_settings
|
||||
* addon_settings hook
|
||||
* cookienotice_addon_admin
|
||||
* creates the admins config panel
|
||||
*
|
||||
* @param \Friendica\App $a
|
||||
* @param App $a
|
||||
* @param string $s The existing config panel html so far
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function cookienotice_addon_settings(\Friendica\App $a, &$s)
|
||||
function cookienotice_addon_admin(App $a, &$s)
|
||||
{
|
||||
if (!is_site_admin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Add our stylesheet to the page so we can make our settings look nice */
|
||||
$stylesheetPath = 'addon/cookienotice/cookienotice.css';
|
||||
$a->registerStylesheet($stylesheetPath);
|
||||
|
||||
$text = Config::get('cookienotice', 'text', L10n::t('This website uses cookies. If you continue browsing this website, you agree to the usage of cookies.'));
|
||||
$oktext = Config::get('cookienotice', 'oktext', L10n::t('OK'));
|
||||
|
||||
$t = Renderer::getMarkupTemplate("settings.tpl", "addon/cookienotice/");
|
||||
$t = Renderer::getMarkupTemplate('admin.tpl', __DIR__);
|
||||
$s .= Renderer::replaceMacros($t, [
|
||||
'$title' => L10n::t('"cookienotice" Settings'),
|
||||
'$description' => L10n::t('<b>Configure your cookie usage notice.</b> It should just be a notice, saying that the website uses cookies. It is shown as long as a user didnt confirm clicking the OK button.'),
|
||||
'$text' => ['cookienotice-text', L10n::t('Cookie Usage Notice'), $text, L10n::t('The cookie usage notice')],
|
||||
'$oktext' => ['cookienotice-oktext', L10n::t('OK Button Text'), $oktext, L10n::t('The OK Button text')],
|
||||
'$text' => ['cookienotice-text', L10n::t('Cookie Usage Notice'), $text],
|
||||
'$oktext' => ['cookienotice-oktext', L10n::t('OK Button Text'), $oktext],
|
||||
'$submit' => L10n::t('Save Settings')
|
||||
]);
|
||||
|
||||
|
@ -76,16 +55,14 @@ function cookienotice_addon_settings(\Friendica\App $a, &$s)
|
|||
}
|
||||
|
||||
/**
|
||||
* cookienotice_addon_settings_post
|
||||
* addon_settings_post hook
|
||||
* cookienotice_addon_admin_post
|
||||
* handles the post request from the admin panel
|
||||
*
|
||||
* @param \Friendica\App $a
|
||||
* @param string $b
|
||||
* @param App $a
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function cookienotice_addon_settings_post(\Friendica\App $a, &$b)
|
||||
function cookienotice_addon_admin_post(App $a)
|
||||
{
|
||||
if (!is_site_admin()) {
|
||||
return;
|
||||
|
@ -94,7 +71,7 @@ function cookienotice_addon_settings_post(\Friendica\App $a, &$b)
|
|||
if ($_POST['cookienotice-submit']) {
|
||||
Config::set('cookienotice', 'text', trim(strip_tags($_POST['cookienotice-text'])));
|
||||
Config::set('cookienotice', 'oktext', trim(strip_tags($_POST['cookienotice-oktext'])));
|
||||
info(L10n::t('cookienotice Settings saved.') . EOL);
|
||||
info(L10n::t('cookienotice Settings saved.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,15 +80,15 @@ function cookienotice_addon_settings_post(\Friendica\App $a, &$b)
|
|||
* page_content_top hook
|
||||
* adds css and scripts to the <head> section of the html
|
||||
*
|
||||
* @param \Friendica\App $a
|
||||
* @param string $b unnused - the header html incl. nav
|
||||
* @param App $a
|
||||
* @param string $b unused - the header html incl. nav
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function cookienotice_page_content_top(\Friendica\App $a, &$b)
|
||||
function cookienotice_page_content_top(App $a, &$b)
|
||||
{
|
||||
$stylesheetPath = 'addon/cookienotice/cookienotice.css';
|
||||
$footerscriptPath = 'addon/cookienotice/cookienotice.js';
|
||||
$stylesheetPath = __DIR__ . '/cookienotice.css';
|
||||
$footerscriptPath = __DIR__ . '/cookienotice.js';
|
||||
|
||||
$a->registerStylesheet($stylesheetPath);
|
||||
$a->registerFooterScript($footerscriptPath);
|
||||
|
@ -122,17 +99,17 @@ function cookienotice_page_content_top(\Friendica\App $a, &$b)
|
|||
* page_end hook
|
||||
* ads our cookienotice box to the end of the html
|
||||
*
|
||||
* @param \Friendica\App $a
|
||||
* @param App $a
|
||||
* @param string $b the page html
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function cookienotice_page_end(\Friendica\App $a, &$b)
|
||||
function cookienotice_page_end(App $a, &$b)
|
||||
{
|
||||
$text = (string)Config::get('cookienotice', 'text', L10n::t('This website uses cookies to recognize revisiting and logged in users. You accept the usage of these cookies by continue browsing this website.'));
|
||||
$oktext = (string)Config::get('cookienotice', 'oktext', L10n::t('OK'));
|
||||
|
||||
$page_end_tpl = Renderer::getMarkupTemplate("cookienotice.tpl", "addon/cookienotice/");
|
||||
$page_end_tpl = Renderer::getMarkupTemplate('cookienotice.tpl', __DIR__);
|
||||
|
||||
$page_end = Renderer::replaceMacros($page_end_tpl, [
|
||||
'$text' => $text,
|
||||
|
|
6
cookienotice/templates/admin.tpl
Normal file
6
cookienotice/templates/admin.tpl
Normal file
|
@ -0,0 +1,6 @@
|
|||
<p>{{$description nofilter}}</p>
|
||||
{{include file="field_textarea.tpl" field=$text}}
|
||||
{{include file="field_input.tpl" field=$oktext}}
|
||||
<div class="settings-submit-wrapper" >
|
||||
<input type="submit" id="cookienotice-submit" name="cookienotice-submit" class="settings-submit" value="{{$submit}}" />
|
||||
</div>
|
|
@ -1,15 +0,0 @@
|
|||
<span id="settings_cookienotice_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_cookienotice_expanded'); openClose('settings_cookienotice_inflated');">
|
||||
<h3>{{$title}}</h3>
|
||||
</span>
|
||||
<div id="settings_cookienotice_expanded" class="settings-block" style="display: none;">
|
||||
<span class="fakelink" onclick="openClose('settings_cookienotice_expanded'); openClose('settings_cookienotice_inflated');">
|
||||
<h3>{{$title}}</h3>
|
||||
</span>
|
||||
<p>{{$description nofilter}}</p>
|
||||
{{include file="field_textarea.tpl" field=$text}}
|
||||
{{include file="field_input.tpl" field=$oktext}}
|
||||
<div class="settings-submit-wrapper" >
|
||||
<input type="submit" id="cookienotice-submit" name="cookienotice-submit" class="settings-submit" value="{{$submit}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
|
@ -1,7 +0,0 @@
|
|||
This addon requires a fortune server. You may use the DB supplied here to create one.
|
||||
|
||||
gunzip the fortunate.sql.gz and import into your database.
|
||||
Copy cookie.php to the top level Friendica directory.
|
||||
Edit fortunate.php and change FORTUNATE_SERVER definition to your hostname. Change the http in that file to https if your server doesn't support http.
|
||||
|
||||
Many additional options are available if you examine cookie.php - a clever developer can provide a settings page to tailor this to one's liking. Also several languages are supported, and it would be convenient to set this to the current Friendica language if that is amongst those supported.
|
|
@ -1,349 +0,0 @@
|
|||
<?php
|
||||
|
||||
set_time_limit(0);
|
||||
error_reporting(0);
|
||||
require(".htconfig.php");
|
||||
$db = @new mysqli($db_host,$db_user,$db_pass,$db_data);
|
||||
|
||||
header( "Content-type: text/html; charset=utf-8");
|
||||
header( "Last-Modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" );
|
||||
header( "Expires: " . gmdate( "D, j M Y H:i:s", time() ) . " GMT" );
|
||||
header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
|
||||
header( "Cache-Control: post-check=0, pre-check=0", FALSE );
|
||||
header( "Pragma: no-cache" ); // HTTP/1.0
|
||||
|
||||
$lang = 'en';
|
||||
|
||||
$offensive = $_GET['off'];
|
||||
if($offensive == 'o')
|
||||
$adult = 2;
|
||||
elseif($offensive == 'a')
|
||||
$adult = 1;
|
||||
else
|
||||
$adult = 0;
|
||||
|
||||
$length = (($_GET['length']) ? intval($_GET['length']) : 0);
|
||||
$numlines = ((intval($_GET['numlines'])) ? intval($_GET['numlines']) : 0);
|
||||
$cat = (($_GET['cat'] == '1') ? 1 : 0);
|
||||
$equal = (($_GET['equal'] == '1') ? 1 : 0);
|
||||
$stats = (($_GET['stats'] == '1') ? 1 : 0);
|
||||
|
||||
if(strlen($_GET['lang']))
|
||||
$lang = @$db->real_escape_string($_GET['lang']);
|
||||
|
||||
if(strlen($_GET['pattern']))
|
||||
$pattern = @$db->real_escape_string(urldecode($_GET['pattern']));
|
||||
|
||||
if(strlen($_GET['regex']))
|
||||
$regex = @$db->real_escape_string(urldecode($_GET['regex']));
|
||||
|
||||
if(strlen($_GET['db']))
|
||||
$table = @$db->real_escape_string(urldecode($_GET['db']));
|
||||
else
|
||||
$table = '';
|
||||
|
||||
if($length < 0)
|
||||
$length = 0;
|
||||
if($numlines < 0)
|
||||
$numlines = 0;
|
||||
|
||||
function do_query($table,$length,$numlines,$adult,$cat,$limit,$lang,$pattern,$regex,$equal) {
|
||||
global $db;
|
||||
$rnd = mt_rand();
|
||||
$r = [];
|
||||
|
||||
$typesql = (($table) ? " WHERE `category` = '$table' " : " WHERE 1 ");
|
||||
$lengthsql = (($length) ? " AND LENGTH(`text`) < $length " : "" );
|
||||
|
||||
if($adult == 2)
|
||||
$adultsql = " AND offensive = 1 ";
|
||||
elseif($adult == 1)
|
||||
$adultsql = "";
|
||||
else
|
||||
$adultsql = " AND offensive = 0 ";
|
||||
|
||||
|
||||
if($numlines)
|
||||
$lengthsql .=
|
||||
" AND (LENGTH(`text`) - LENGTH(REPLACE(`text`,\"\n\",\"\"))) <= $numlines ";
|
||||
|
||||
$langsql = " AND lang = '$lang' ";
|
||||
|
||||
$patsql = '';
|
||||
if(strlen($pattern))
|
||||
$patsql = " AND MATCH text AGAINST ('$pattern' IN BOOLEAN MODE) ";
|
||||
|
||||
$regexsql = '';
|
||||
if(strlen($regex))
|
||||
$regexsql = " AND text REGEXP '$regex' ";
|
||||
|
||||
$eqsql = '';
|
||||
|
||||
if($equal) {
|
||||
$catsavail = [];
|
||||
$res = @$db->query("SELECT DISTINCT ( `category` ) FROM `fortune`
|
||||
$typesql
|
||||
$adultsql
|
||||
$lengthsql
|
||||
$langsql
|
||||
$patsql
|
||||
$regexsql ");
|
||||
if($res->num_rows) {
|
||||
while($x = $res->fetch_array(MYSQL_ASSOC))
|
||||
$catsavail[] = $x['category'];
|
||||
|
||||
$eqsql = " AND `category` = '"
|
||||
. $catsavail[mt_rand(0,$res->num_rows - 1)] . "' ";
|
||||
}
|
||||
}
|
||||
|
||||
$result = @$db->query("SELECT `text`, `category` FROM `fortune`
|
||||
$typesql
|
||||
$adultsql
|
||||
$lengthsql
|
||||
$langsql
|
||||
$patsql
|
||||
$regexsql
|
||||
$eqsql
|
||||
ORDER BY RAND($rnd)
|
||||
LIMIT $limit");
|
||||
|
||||
if($result->num_rows) {
|
||||
while($x = $result->fetch_array(MYSQL_ASSOC))
|
||||
$r[] = fortune_to_html($x['text'])
|
||||
.(($cat) ? "<br />[{$x['category']}]<br />" : "");
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
||||
function do_stats($table,$length,$numlines,$adult,$cat,$limit,$lang,$pattern,$regex,$equal) {
|
||||
global $db;
|
||||
$rnd = mt_rand();
|
||||
$r = [];
|
||||
|
||||
$typesql = (($table) ? " WHERE `category` = '$table' " : " WHERE 1 ");
|
||||
$lengthsql = (($length) ? " AND LENGTH(`text`) < $length " : "" );
|
||||
|
||||
if($adult == 2)
|
||||
$adultsql = " AND offensive = 1 ";
|
||||
elseif($adult == 1)
|
||||
$adultsql = "";
|
||||
else
|
||||
$adultsql = " AND offensive = 0 ";
|
||||
|
||||
|
||||
if($numlines)
|
||||
$lengthsql .=
|
||||
" AND (LENGTH(`text`) - LENGTH(REPLACE(`text`,\"\n\",\"\"))) <= $numlines ";
|
||||
|
||||
$langsql = " AND lang = '$lang' ";
|
||||
|
||||
$patsql = '';
|
||||
if(strlen($pattern))
|
||||
$patsql = " AND MATCH text AGAINST ('$pattern' IN BOOLEAN MODE) ";
|
||||
|
||||
$regexsql = '';
|
||||
if(strlen($regex))
|
||||
$regexsql = " AND text REGEXP '$regex' ";
|
||||
|
||||
$eqsql = '';
|
||||
|
||||
$result = @$db->query("SELECT `text`, `category` FROM `fortune`
|
||||
$typesql
|
||||
$adultsql
|
||||
$lengthsql
|
||||
$langsql
|
||||
$patsql
|
||||
$regexsql
|
||||
$eqsql");
|
||||
|
||||
|
||||
echo '<br />' . $result->num_rows . ' matching quotations.<br />';
|
||||
|
||||
|
||||
$res = @$db->query("SELECT DISTINCT ( `category` ) FROM `fortune`
|
||||
$typesql
|
||||
$adultsql
|
||||
$lengthsql
|
||||
$langsql
|
||||
$patsql
|
||||
$regexsql ");
|
||||
if($res->num_rows) {
|
||||
echo '<br />Matching Databases:<br />';
|
||||
while($x = $res->fetch_array(MYSQL_ASSOC))
|
||||
echo $x['category'].'<br />';
|
||||
|
||||
}
|
||||
else
|
||||
echo '<br />No matching databases using those search parameters - please refine your options.<br />';
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function fortune_to_html($s) {
|
||||
|
||||
// First pass - escape all the HTML entities, and while we're at it
|
||||
// get rid of any MS-DOS end-of-line characters and expand tabs to
|
||||
// 8 non-breaking spaces, and translate linefeeds to <br />.
|
||||
// We also get rid of ^G which used to sound the terminal beep or bell
|
||||
// on ASCII terminals and were humourous in some fortunes.
|
||||
// We could map these to autoplay a short sound file but browser support
|
||||
// is still sketchy and then there's the issue of where to locate the
|
||||
// URL, and a lot of people find autoplay sounds downright annoying.
|
||||
// So for now, just remove them.
|
||||
|
||||
$s = str_replace(
|
||||
["&",
|
||||
"<",
|
||||
">",
|
||||
'"',
|
||||
"\007",
|
||||
"\t",
|
||||
"\r",
|
||||
"\n"],
|
||||
|
||||
["&",
|
||||
"<",
|
||||
">",
|
||||
""",
|
||||
"",
|
||||
" ",
|
||||
"",
|
||||
"<br />"],
|
||||
$s);
|
||||
// Replace pseudo diacritics
|
||||
// These were used to produce accented characters. For instance an accented
|
||||
// e would have been encoded by '^He - the backspace moving the cursor
|
||||
// backward so both the single quote and the e would appear in the same
|
||||
// character position. Umlauts were quite clever - they used a double quote
|
||||
// as the accent mark over a normal character.
|
||||
|
||||
$s = preg_replace("/'\010([a-zA-Z])/","&\\1acute;",$s);
|
||||
$s = preg_replace("/\"\010([a-zA-Z])/","&\\1uml;",$s);
|
||||
$s = preg_replace("/\`\010([a-zA-Z])/","&\\1grave;",$s);
|
||||
$s = preg_replace("/\^\010([a-zA-Z])/","&\\1circ;",$s);
|
||||
$s = preg_replace("/\~\010([a-zA-Z])/","&\\1tilde;",$s);
|
||||
|
||||
// Ignore multiple underlines for the same character. These were
|
||||
// most useful when sent to a line printer back in the day as it
|
||||
// would type over the same character a number of times making it
|
||||
// much darker (e.g. bold). I think there are only one or two
|
||||
// instances of this in the current (2008) fortune cookie database.
|
||||
|
||||
$s = preg_replace("/(_\010)+/","_\010",$s);
|
||||
// Map the characters which sit underneath a backspace.
|
||||
// If you can come up with a regex to do all of the following
|
||||
// madness - be my guest.
|
||||
// It's not as simple as you think. We need to take something
|
||||
// that has been backspaced over an arbitrary number of times
|
||||
// and wrap a forward looking matching number of characters in
|
||||
// HTML, whilst deciding if it's intended as an underline or
|
||||
// strikeout sequence.
|
||||
|
||||
// Essentially we produce a string of '1' and '0' characters
|
||||
// the same length as the source text.
|
||||
// Any position which is marked '1' has been backspaced over.
|
||||
|
||||
$cursor = 0;
|
||||
$dst = $s;
|
||||
$bs_found = false;
|
||||
for($x = 0; $x < strlen($s); $x ++) {
|
||||
if($s[$x] == "\010" && $cursor) {
|
||||
$bs_found = true;
|
||||
$cursor --;
|
||||
$dst[$cursor] = '1';
|
||||
$dst[$x] = '0';
|
||||
$continue;
|
||||
}
|
||||
else {
|
||||
if($bs_found) {
|
||||
$bs_found = false;
|
||||
$cursor = $x;
|
||||
}
|
||||
$dst[$cursor] = '0';
|
||||
$cursor ++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$out = '';
|
||||
$strike = false;
|
||||
$bold = false;
|
||||
|
||||
// Underline sequence, convert to bold to avoid confusion with links.
|
||||
// These were generally used for emphasis so it's a reasonable choice.
|
||||
// Please note that this logic will fail if there is an underline sequence
|
||||
// and also a strikeout sequence in the same fortune.
|
||||
|
||||
if(strstr($s,"_\010")) {
|
||||
$len = 0;
|
||||
for($x = 0; $x < strlen($s); $x ++) {
|
||||
if($dst[$x] == '1') {
|
||||
$len ++;
|
||||
$bold = true;
|
||||
}
|
||||
else {
|
||||
if($bold) {
|
||||
$out .= '<strong>';
|
||||
while($s[$x] == "\010")
|
||||
$x ++;
|
||||
$out .= substr($s,$x,$len);
|
||||
$out .= '</strong>';
|
||||
$x = $x + $len - 1;
|
||||
$len = 0;
|
||||
$bold = false;
|
||||
}
|
||||
else
|
||||
$out .= $s[$x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// These aren't seen very often these days - simulation of
|
||||
// backspace/replace. You could occasionally see the original text
|
||||
// on slower terminals before it got replaced. Once modems reached
|
||||
// 4800/9600 baud in the late 70's and early 80's the effect was
|
||||
// mostly lost - but if you find a really old fortune file you might
|
||||
// encounter a few of these.
|
||||
|
||||
else {
|
||||
for($x = 0; $x < strlen($s); $x ++) {
|
||||
if($dst[$x] == '1') {
|
||||
if($strike)
|
||||
$out .= $s[$x];
|
||||
else
|
||||
$out .= '<strike>'.$s[$x];
|
||||
$strike = true;
|
||||
}
|
||||
else {
|
||||
if($strike)
|
||||
$out .= '</strike>';
|
||||
$strike = false;
|
||||
$out .= $s[$x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Many of the underline sequences are also wrapped in asterisks,
|
||||
// which was yet another way of marking ASCII as 'bold'.
|
||||
// So if it's an underline sequence, and there are asterisks
|
||||
// on both ends, strip the asterisks as we've already emboldened the text.
|
||||
|
||||
$out = preg_replace('/\*(<strong>[^<]*<\/strong>)\*/',"\\1",$out);
|
||||
|
||||
// Finally, remove the backspace characters which we don't need anymore.
|
||||
|
||||
return str_replace("\010","",$out);
|
||||
}
|
||||
|
||||
$result1 = do_query($table,$length,$numlines,$adult,$cat,1,$lang,$pattern,$regex,$equal);
|
||||
|
||||
if(count($result1))
|
||||
echo $result1[0];
|
||||
|
||||
if($stats)
|
||||
do_stats($table,$length,$numlines,$adult,$cat,1,$lang,$pattern,$regex,$equal);
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
.fortunate {
|
||||
margin-top: 25px;
|
||||
margin-left: 100px;
|
||||
margin-bottom: 25px;
|
||||
color: #000088;
|
||||
font-size: 14px;
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Name: Fortunate
|
||||
* Description: Add a random fortune cookie at the bottom of every pages. [Requires manual confguration.]
|
||||
* Version: 1.0
|
||||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||
* Status: Unsupported
|
||||
*/
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Util\Network;
|
||||
|
||||
// IMPORTANT: SET THIS to your fortunate server
|
||||
|
||||
define('FORTUNATE_SERVER', 'hostname.com');
|
||||
|
||||
function fortunate_install()
|
||||
{
|
||||
Hook::register('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
|
||||
if (FORTUNATE_SERVER == 'hostname.com' && is_site_admin()) {
|
||||
notice('Fortunate addon requires configuration. See README');
|
||||
}
|
||||
}
|
||||
|
||||
function fortunate_uninstall()
|
||||
{
|
||||
Hook::unregister('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
|
||||
}
|
||||
|
||||
|
||||
function fortunate_fetch(&$a, &$b)
|
||||
{
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
|
||||
. $a->getBaseURL() . '/addon/fortunate/fortunate.css' . '" media="all" />' . "\r\n";
|
||||
|
||||
if (FORTUNATE_SERVER != 'hostname.com') {
|
||||
$s = Network::fetchUrl('http://' . FORTUNATE_SERVER . '/cookie.php?numlines=2&equal=1&rand=' . mt_rand());
|
||||
$b .= '<div class="fortunate">' . $s . '</div>';
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -13,13 +13,10 @@ use Friendica\Content\Widget;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\Temporal;
|
||||
|
||||
include_once 'mod/directory.php';
|
||||
|
||||
|
@ -136,7 +133,7 @@ function forumdirectory_content(App $a)
|
|||
}
|
||||
|
||||
while ($rr = DBA::fetch($r)) {
|
||||
$entries[] = format_directory_entry($rr, $photo);
|
||||
$entries[] = Friendica\Module\Directory::formatEntry($rr, $photo);
|
||||
}
|
||||
DBA::close($r);
|
||||
} else {
|
||||
|
|
|
@ -3,14 +3,14 @@ Geonames Addon
|
|||
|
||||
Authors Mike Macgirvin.
|
||||
|
||||
Use Geonames service to resolve nearest populated location for given latitude, longitude.
|
||||
Use [Geonames service](https://www.geonames.org) to resolve nearest populated location for given latitude, longitude.
|
||||
|
||||
## Installation
|
||||
|
||||
Pre-requisite: Register a username at geonames.org and set in `config/addon.config.php`
|
||||
Pre-requisite: Register a username at https://www.geonames.org/login and set it in `config/addon.config.php`
|
||||
|
||||
'geonames' => [
|
||||
'username' => 'your_username'
|
||||
],
|
||||
|
||||
Also visit http://geonames.org/manageaccount and enable access to the free web services.
|
||||
Also visit https://geonames.org/manageaccount and enable access to the free web services.
|
||||
|
|
|
@ -4,202 +4,148 @@
|
|||
* Description: Use Geonames service to resolve nearest populated location for given latitude, longitude
|
||||
* Version: 1.0
|
||||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||
*
|
||||
*
|
||||
* Pre-requisite: Register a username at geonames.org
|
||||
* and set in config/addon.config.php
|
||||
*
|
||||
* [geonames]
|
||||
* username = your_username
|
||||
*
|
||||
* Also visit http://geonames.org/manageaccount and enable access to the free web services
|
||||
*
|
||||
* When addon is installed, the system calls the addon
|
||||
* name_install() function, located in 'addon/name/name.php',
|
||||
* where 'name' is the name of the addon.
|
||||
* If the addon is removed from the configuration list, the
|
||||
* system will call the name_uninstall() function.
|
||||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Util\Config\ConfigFileLoader;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
function geonames_install() {
|
||||
function geonames_install()
|
||||
{
|
||||
Hook::register('load_config', __FILE__, 'geonames_load_config');
|
||||
|
||||
Hook::register('load_config', 'addon/geonames/geonames.php', 'geonames_load_config');
|
||||
|
||||
/**
|
||||
*
|
||||
* Our addon will attach in three places.
|
||||
/* Our addon will attach in three places.
|
||||
* The first is just prior to storing a local post.
|
||||
*
|
||||
*/
|
||||
|
||||
Hook::register('post_local', 'addon/geonames/geonames.php', 'geonames_post_hook');
|
||||
Hook::register('post_local', __FILE__, 'geonames_post_hook');
|
||||
|
||||
/**
|
||||
*
|
||||
* Then we'll attach into the addon settings page, and also the
|
||||
/* Then we'll attach into the addon settings page, and also the
|
||||
* settings post hook so that we can create and update
|
||||
* user preferences.
|
||||
*
|
||||
*/
|
||||
|
||||
Hook::register('addon_settings', 'addon/geonames/geonames.php', 'geonames_addon_admin');
|
||||
Hook::register('addon_settings_post', 'addon/geonames/geonames.php', 'geonames_addon_admin_post');
|
||||
|
||||
Logger::log("installed geonames");
|
||||
Hook::register('addon_settings', __FILE__, 'geonames_addon_settings');
|
||||
Hook::register('addon_settings_post', __FILE__, 'geonames_addon_settings_post');
|
||||
}
|
||||
|
||||
|
||||
function geonames_uninstall() {
|
||||
|
||||
/**
|
||||
*
|
||||
* uninstall unregisters any hooks created with register_hook
|
||||
* during install. It may also delete configuration settings
|
||||
* and any other cleanup.
|
||||
*
|
||||
*/
|
||||
|
||||
Hook::unregister('load_config', 'addon/geonames/geonames.php', 'geonames_load_config');
|
||||
Hook::unregister('post_local', 'addon/geonames/geonames.php', 'geonames_post_hook');
|
||||
Hook::unregister('addon_settings', 'addon/geonames/geonames.php', 'geonames_addon_admin');
|
||||
Hook::unregister('addon_settings_post', 'addon/geonames/geonames.php', 'geonames_addon_admin_post');
|
||||
|
||||
|
||||
Logger::log("removed geonames");
|
||||
}
|
||||
|
||||
function geonames_load_config(\Friendica\App $a, ConfigFileLoader $loader)
|
||||
function geonames_load_config(App $a, ConfigFileLoader $loader)
|
||||
{
|
||||
$a->getConfigCache()->load($loader->loadAddonConfig('geonames'));
|
||||
}
|
||||
|
||||
function geonames_post_hook($a, &$item) {
|
||||
|
||||
/**
|
||||
*
|
||||
* An item was posted on the local system.
|
||||
function geonames_post_hook(App $a, array &$item)
|
||||
{
|
||||
/* An item was posted on the local system.
|
||||
* We are going to look for specific items:
|
||||
* - A status post by a profile owner
|
||||
* - The profile owner must have allowed our addon
|
||||
*
|
||||
*/
|
||||
|
||||
Logger::log('geonames invoked');
|
||||
|
||||
if(! local_user()) /* non-zero if this is a logged in user of this system */
|
||||
if (!local_user()) { /* non-zero if this is a logged in user of this system */
|
||||
return;
|
||||
}
|
||||
|
||||
if(local_user() != $item['uid']) /* Does this person own the post? */
|
||||
if (local_user() != $item['uid']) { /* Does this person own the post? */
|
||||
return;
|
||||
}
|
||||
|
||||
if($item['parent']) /* If the item has a parent, this is a comment or something else, not a status post. */
|
||||
if ($item['parent']) { /* If the item has a parent, this is a comment or something else, not a status post. */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Retrieve our personal config setting */
|
||||
|
||||
$geo_account = Config::get('geonames', 'username');
|
||||
$active = PConfig::get(local_user(), 'geonames', 'enable');
|
||||
|
||||
if((! $geo_account) || (! $active))
|
||||
if (!$geo_account || !$active) {
|
||||
return;
|
||||
}
|
||||
|
||||
if((! $item['coord']) || ($item['location']))
|
||||
if (!$item['coord'] || $item['location']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$coords = explode(' ', $item['coord']);
|
||||
|
||||
/**
|
||||
*
|
||||
* OK, we're allowed to do our stuff.
|
||||
*
|
||||
*/
|
||||
/* OK, we're allowed to do our stuff. */
|
||||
|
||||
$s = Network::fetchUrl('http://api.geonames.org/findNearbyPlaceName?lat=' . $coords[0] . '&lng=' . $coords[1] . '&username=' . $geo_account);
|
||||
|
||||
if(! $s)
|
||||
if (!$s) {
|
||||
return;
|
||||
}
|
||||
|
||||
$xml = XML::parseString($s);
|
||||
|
||||
if($xml->geoname->name && $xml->geoname->countryName)
|
||||
if ($xml->geoname->name && $xml->geoname->countryName) {
|
||||
$item['location'] = $xml->geoname->name . ', ' . $xml->geoname->countryName;
|
||||
}
|
||||
|
||||
|
||||
// Logger::log('geonames : ' . print_r($xml,true), Logger::DATA);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Callback from the settings post function.
|
||||
* $post contains the $_POST array.
|
||||
* We will make sure we've got a valid user account
|
||||
* and if so set our configuration setting for this person.
|
||||
*
|
||||
* @param App $a
|
||||
* @param array $post The $_POST array
|
||||
*/
|
||||
|
||||
function geonames_addon_admin_post($a,$post) {
|
||||
if(! local_user() || empty($_POST['geonames-submit']))
|
||||
function geonames_addon_settings_post(App $a, array $post)
|
||||
{
|
||||
if (!local_user() || empty($_POST['geonames-submit'])) {
|
||||
return;
|
||||
PConfig::set(local_user(),'geonames','enable',intval($_POST['geonames']));
|
||||
|
||||
info(L10n::t('Geonames settings updated.') . EOL);
|
||||
}
|
||||
|
||||
PConfig::set(local_user(), 'geonames', 'enable', intval($_POST['geonames-enable']));
|
||||
|
||||
info(L10n::t('Geonames settings updated.'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Called from the Addon Setting form.
|
||||
* Add our own settings info to the page.
|
||||
*
|
||||
* @param App $a
|
||||
* @param string $s
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function geonames_addon_admin(&$a,&$s) {
|
||||
|
||||
if(! local_user())
|
||||
function geonames_addon_settings(App $a, &$s)
|
||||
{
|
||||
if (!local_user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$geo_account = Config::get('geonames', 'username');
|
||||
|
||||
if(! $geo_account)
|
||||
if (!$geo_account) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Add our stylesheet to the page so we can make our settings look nice */
|
||||
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->getBaseURL() . '/addon/geonames/geonames.css' . '" media="all" />' . "\r\n";
|
||||
$stylesheetPath = __DIR__ . '/geonames.css';
|
||||
$a->registerStylesheet($stylesheetPath);
|
||||
|
||||
/* Get the current state of our config variable */
|
||||
$enabled = intval(PConfig::get(local_user(), 'geonames', 'enable'));
|
||||
|
||||
$enabled = PConfig::get(local_user(),'geonames','enable');
|
||||
|
||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
||||
|
||||
/* Add some HTML to the existing form */
|
||||
|
||||
$s .= '<div class="settings-block">';
|
||||
$s .= '<h3>' . L10n::t('Geonames Settings') . '</h3>';
|
||||
$s .= '<div id="geonames-enable-wrapper">';
|
||||
$s .= '<label id="geonames-enable-label" for="geonames-checkbox">' . L10n::t('Enable Geonames Addon') . '</label>';
|
||||
$s .= '<input id="geonames-checkbox" type="checkbox" name="geonames" value="1" ' . $checked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
/* provide a submit button */
|
||||
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="geonames-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
|
||||
|
||||
$t = Renderer::getMarkupTemplate('settings.tpl', __DIR__);
|
||||
$s .= Renderer::replaceMacros($t, [
|
||||
'$title' => L10n::t('Geonames Settings'),
|
||||
'$description' => L10n::t('Replace numerical coordinates by the nearest populated location name in your posts.'),
|
||||
'$enable' => ['geonames-enable', L10n::t('Enable Geonames Addon'), $enabled],
|
||||
'$submit' => L10n::t('Save Settings')
|
||||
]);
|
||||
}
|
||||
|
|
14
geonames/templates/settings.tpl
Normal file
14
geonames/templates/settings.tpl
Normal file
|
@ -0,0 +1,14 @@
|
|||
<span id="settings_geonames_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_geonames_expanded'); openClose('settings_geonames_inflated');">
|
||||
<h3>{{$title}}</h3>
|
||||
</span>
|
||||
<div id="settings_geonames_expanded" class="settings-block" style="display: none;">
|
||||
<span class="fakelink" onclick="openClose('settings_geonames_expanded'); openClose('settings_geonames_inflated');">
|
||||
<h3>{{$title}}</h3>
|
||||
</span>
|
||||
<p>{{$description nofilter}}</p>
|
||||
{{include file="field_checkbox.tpl" field=$enable}}
|
||||
<div class="settings-submit-wrapper" >
|
||||
<input type="submit" id="geonames-submit" name="geonames-submit" class="settings-submit" value="{{$submit}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
|
@ -254,7 +254,7 @@ function mailstream_subject($item) {
|
|||
return L10n::t("Friendica Item");
|
||||
}
|
||||
|
||||
function mailstream_send($a, $message_id, $item, $user) {
|
||||
function mailstream_send(\Friendica\App $a, $message_id, $item, $user) {
|
||||
if (!$item['visible']) {
|
||||
return;
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ function mailstream_send($a, $message_id, $item, $user) {
|
|||
$mail->CharSet = 'utf-8';
|
||||
$template = Renderer::getMarkupTemplate('mail.tpl', 'addon/mailstream/');
|
||||
$item['body'] = BBCode::convert($item['body']);
|
||||
$item['url'] = $a->getBaseURL() . '/display/' . $user['nickname'] . '/' . $item['id'];
|
||||
$item['url'] = $a->getBaseURL() . '/display/' . $item['guid'];
|
||||
$mail->Body = Renderer::replaceMacros($template, [
|
||||
'$upstream' => L10n::t('Upstream'),
|
||||
'$local' => L10n::t('Local'),
|
||||
|
|
|
@ -8,49 +8,31 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
|
||||
function pageheader_install() {
|
||||
Hook::register('page_content_top', 'addon/pageheader/pageheader.php', 'pageheader_fetch');
|
||||
Hook::register('addon_settings', 'addon/pageheader/pageheader.php', 'pageheader_addon_settings');
|
||||
Hook::register('addon_settings_post', 'addon/pageheader/pageheader.php', 'pageheader_addon_settings_post');
|
||||
|
||||
Hook::register('page_content_top', __FILE__, 'pageheader_fetch');
|
||||
}
|
||||
|
||||
|
||||
function pageheader_uninstall() {
|
||||
Hook::unregister('page_content_top', 'addon/pageheader/pageheader.php', 'pageheader_fetch');
|
||||
Hook::unregister('addon_settings', 'addon/pageheader/pageheader.php', 'pageheader_addon_settings');
|
||||
Hook::unregister('addon_settings_post', 'addon/pageheader/pageheader.php', 'pageheader_addon_settings_post');
|
||||
|
||||
// hook moved, uninstall the old one if still there.
|
||||
Hook::unregister('page_header', 'addon/pageheader/pageheader.php', 'pageheader_fetch');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function pageheader_addon_settings(&$a,&$s) {
|
||||
|
||||
|
||||
if(! is_site_admin())
|
||||
function pageheader_addon_admin(App &$a, &$s)
|
||||
{
|
||||
if(! is_site_admin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Add our stylesheet to the page so we can make our settings look nice */
|
||||
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->getBaseURL() . '/addon/pageheader/pageheader.css' . '" media="all" />' . "\r\n";
|
||||
|
||||
$stylesheetPath = __DIR__ . '/pageheader.css';
|
||||
$a->registerStylesheet($stylesheetPath);
|
||||
|
||||
$words = Config::get('pageheader','text');
|
||||
if(! $words)
|
||||
$words = '';
|
||||
|
||||
$t = Renderer::getMarkupTemplate("settings.tpl", "addon/pageheader/");
|
||||
$t = Renderer::getMarkupTemplate('admin.tpl', __DIR__);
|
||||
$s .= Renderer::replaceMacros($t, [
|
||||
'$title' => L10n::t('"pageheader" Settings'),
|
||||
'$phwords' => ['pageheader-words', L10n::t('Message'), $words, L10n::t('Message to display on every page on this server (or put a pageheader.html file in your docroot)')],
|
||||
|
@ -58,35 +40,34 @@ function pageheader_addon_settings(&$a,&$s) {
|
|||
]);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
function pageheader_addon_settings_post(&$a, &$b) {
|
||||
|
||||
if(!is_site_admin())
|
||||
function pageheader_addon_admin_post(App $a)
|
||||
{
|
||||
if(!is_site_admin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!empty($_POST['pageheader-submit'])) {
|
||||
if (isset($_POST['pageheader-words'])) {
|
||||
Config::set('pageheader', 'text', trim(strip_tags($_POST['pageheader-words'])));
|
||||
}
|
||||
info(L10n::t('pageheader Settings saved.') . EOL);
|
||||
info(L10n::t('pageheader Settings saved.'));
|
||||
}
|
||||
}
|
||||
|
||||
function pageheader_fetch($a,&$b) {
|
||||
|
||||
function pageheader_fetch(App $a, &$b)
|
||||
{
|
||||
if(file_exists('pageheader.html')){
|
||||
$s = file_get_contents('pageheader.html');
|
||||
} else {
|
||||
$s = Config::get('pageheader', 'text');
|
||||
}
|
||||
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
|
||||
. $a->getBaseURL() . '/addon/pageheader/pageheader.css' . '" media="all" />' . "\r\n";
|
||||
$stylesheetPath = __DIR__ .'/pageheader.css';
|
||||
$a->registerStylesheet($stylesheetPath);
|
||||
|
||||
if(! $s)
|
||||
$s = '';
|
||||
if ($s != '')
|
||||
if ($s) {
|
||||
$b .= '<div class="pageheader">' . $s . '</div>';
|
||||
}
|
||||
}
|
||||
|
|
5
pageheader/templates/admin.tpl
Normal file
5
pageheader/templates/admin.tpl
Normal file
|
@ -0,0 +1,5 @@
|
|||
{{include file="field_textarea.tpl" field=$phwords}}
|
||||
|
||||
<div class="settings-submit-wrapper" >
|
||||
<input type="submit" id="pageheader-submit" name="pageheader-submit" class="settings-submit" value="{{$submit}}" />
|
||||
</div>
|
|
@ -1,14 +0,0 @@
|
|||
<span id="settings_pageheader_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_pageheader_expanded'); openClose('settings_pageheader_inflated');">
|
||||
<h3>{{$title}}</h3>
|
||||
</span>
|
||||
<div id="settings_pageheader_expanded" class="settings-block" style="display: none;">
|
||||
<span class="fakelink" onclick="openClose('settings_pageheader_expanded'); openClose('settings_pageheader_inflated');">
|
||||
<h3>{{$title}}</h3>
|
||||
</span>
|
||||
{{include file="field_textarea.tpl" field=$phwords}}
|
||||
|
||||
<div class="settings-submit-wrapper" >
|
||||
<input type="submit" id="pageheader-submit" name="pageheader-submit" class="settings-submit" value="{{$submit}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
|
@ -1,11 +0,0 @@
|
|||
Pledgie
|
||||
|
||||
Allows administrators to add a Pledgie-Donation Button to all their friendica pages.
|
||||
This could be useful f.e. for public nodes that want to raise some money for server
|
||||
maintenance costs.
|
||||
|
||||
Usage:
|
||||
Add the campaign number of your pledgie campaign in the first field. To find out the campaign number,
|
||||
go to your Pledgie campaign webpage. The campaign number is the number at the end of the URL.
|
||||
|
||||
Add a describtion of your campaign in the second field.
|
|
@ -1,28 +0,0 @@
|
|||
#pledgie-label {
|
||||
float: left;
|
||||
width: 300px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#pledgie-campaign {
|
||||
float: left;
|
||||
margin-top: 10px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
#pledgie-describe {
|
||||
float: left;
|
||||
margin-top: 10px;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
#pledgie-submit {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.pledgie {
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
margin-top: 25px;
|
||||
font-size: 20px;
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Name: Pledgie
|
||||
* Description: Show link to a pledgie account for donating
|
||||
* Version: 1.1
|
||||
* Author: tony baldwin <tony@free-haven.org>
|
||||
* Hauke Altmann <https://snarl.de/profile/tugelblend>
|
||||
*
|
||||
*/
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
|
||||
function pledgie_install() {
|
||||
Hook::register('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active');
|
||||
Hook::register('addon_settings', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings');
|
||||
Hook::register('addon_settings_post', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings_post');
|
||||
}
|
||||
|
||||
function pledgie_uninstall() {
|
||||
Hook::unregister('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active');
|
||||
Hook::unregister('addon_settings', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings');
|
||||
Hook::unregister('addon_settings_post', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings_post');
|
||||
}
|
||||
|
||||
function pledgie_addon_settings(&$a,&$s) {
|
||||
|
||||
if(! is_site_admin())
|
||||
return;
|
||||
|
||||
/* Add our stylesheet to the page so we can make our settings look nice */
|
||||
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->getBaseURL() . '/addon/pledgie/pledgie.css' . '" media="all" />' . "\r\n";
|
||||
|
||||
$campaign = Config::get('pledgie-campaign','text');
|
||||
$describe = Config::get('pledgie-describe','text');
|
||||
|
||||
if(! $campaign)
|
||||
$campaign = '';
|
||||
|
||||
if(! describe)
|
||||
$describe = '';
|
||||
|
||||
$s .= '<div class="settings-block">';
|
||||
$s .= '<h3>' . L10n::t('"pledgie" Settings') . '</h3>';
|
||||
$s .= '<div id="pledgie-wrapper">';
|
||||
$s .= '<label id="pledgie-label" for="pledgie-campaign">' . L10n::t('Pledgie campaign number to use for donations') . ' </label>';
|
||||
$s .= '<input id="pledgie-campaign" type="text" name="pledgie-campaign" value="' . $campaign . '">';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
$s .= '<div id="pledgie-wrapper">';
|
||||
$s .= '<label id="pledgie-label" for="pledgie-describe">' . L10n::t('Description of the Pledgie campaign') . ' </label>';
|
||||
$s .= '<input id="pledgie-describe" type="text" name="pledgie-describe" value="' . $describe . '">';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pledgie-submit" name="pledgie-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function pledgie_addon_settings_post(&$a,&$b) {
|
||||
|
||||
if(! is_site_admin())
|
||||
return;
|
||||
|
||||
if($_POST['pledgie-submit']) {
|
||||
Config::set('pledgie-describe','text',trim(strip_tags($_POST['pledgie-describe'])));
|
||||
Config::set('pledgie-campaign','text',trim(strip_tags($_POST['pledgie-campaign'])));
|
||||
info(L10n::t('pledgie Settings saved.') . EOL);
|
||||
}
|
||||
}
|
||||
|
||||
function pledgie_active(&$a,&$b) {
|
||||
$campaign = Config::get('pledgie-campaign','text');
|
||||
$describe = Config::get('pledgie-describe','text');
|
||||
$b .= '<div style="position: fixed; padding:5px; border-style:dotted; border-width:1px; background-color: white; line-height: 1; bottom: 5px; left: 20px; z-index: 1000; width: 150px; font-size: 12px;">';
|
||||
$b .= $describe . '<br/><a href="https://pledgie.com/campaigns/';
|
||||
$b .= $campaign;
|
||||
$b .= '"><img alt="Click here to lend your support to: ' . $describe . '!" src="https://pledgie.com/campaigns/';
|
||||
$b .= $campaign;
|
||||
$b .= '.png?skin_name=chrome" border="0" target="_blank" /></a></div>';
|
||||
}
|
|
@ -735,7 +735,7 @@ function statusnet_prepare_body(App $a, &$b)
|
|||
}
|
||||
|
||||
$item = $b["item"];
|
||||
$item["plink"] = $a->getBaseURL() . "/display/" . $a->user["nickname"] . "/" . $item["parent"];
|
||||
$item["plink"] = $a->getBaseURL() . "/display/" . $item["guid"];
|
||||
|
||||
$condition = ['uri' => $item["thr-parent"], 'uid' => local_user()];
|
||||
$orig_post = Item::selectFirst(['author-link', 'uri'], $condition);
|
||||
|
|
|
@ -814,7 +814,7 @@ function twitter_prepare_body(App $a, array &$b)
|
|||
if ($b["preview"]) {
|
||||
$max_char = 280;
|
||||
$item = $b["item"];
|
||||
$item["plink"] = $a->getBaseURL() . "/display/" . $a->user["nickname"] . "/" . $item["parent"];
|
||||
$item["plink"] = $a->getBaseURL() . "/display/" . $item["guid"];
|
||||
|
||||
$condition = ['uri' => $item["thr-parent"], 'uid' => local_user()];
|
||||
$orig_post = Item::selectFirst(['author-link'], $condition);
|
||||
|
|
|
@ -62,8 +62,6 @@ function like_widget_content(&$a, $conf){
|
|||
|
||||
'$dislike' => $dislikes,
|
||||
'$strdislike'=> L10n::tt("%d person doesn't like this", "%d people don't like this", $dislikes),
|
||||
|
||||
'$baseurl' => $a->getBaseURL(),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
|
|
@ -62,7 +62,6 @@ function widgets_settings(&$a,&$o) {
|
|||
$t = Renderer::getMarkupTemplate("settings.tpl", "addon/widgets/");
|
||||
$o .= Renderer::replaceMacros($t, [
|
||||
'$submit' => L10n::t('Generate new key'),
|
||||
'$baseurl' => $a->getBaseURL(),
|
||||
'$title' => "Widgets",
|
||||
'$label' => L10n::t('Widgets key'),
|
||||
'$key' => $key,
|
||||
|
|
|
@ -29,11 +29,11 @@
|
|||
use Friendica\App;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Authentication;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\User;
|
||||
|
@ -473,7 +473,7 @@ function windowsphonepush_login(App $a)
|
|||
die('This api requires login');
|
||||
}
|
||||
|
||||
Authentication::setAuthenticatedSessionForUser($record);
|
||||
Session::setAuthenticatedForUser($a, $record);
|
||||
$_SESSION["allow_api"] = true;
|
||||
Hook::callAll('logged_in', $a->user);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue