diff --git a/cookienotice/README b/cookienotice/README index 74edd44a..247f53b1 100644 --- a/cookienotice/README +++ b/cookienotice/README @@ -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 +Author: Peter Liebetrau diff --git a/cookienotice/cookienotice.php b/cookienotice/cookienotice.php index 376de1ad..097f3c25 100644 --- a/cookienotice/cookienotice.php +++ b/cookienotice/cookienotice.php @@ -5,70 +5,49 @@ * Description: Configure, show and handle a simple cookie notice * Version: 1.0 * Author: Peter Liebetrau - * */ -use Friendica\Core\Hook; + +use Friendica\App; use Friendica\Core\Config; +use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Renderer; /** * cookienotice_install * registers hooks - * + * * @return void */ 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('Configure your cookie usage notice. 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.')); } } @@ -102,16 +79,16 @@ function cookienotice_addon_settings_post(\Friendica\App $a, &$b) * cookienotice_page_content_top * page_content_top hook * adds css and scripts to the 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); @@ -121,18 +98,18 @@ function cookienotice_page_content_top(\Friendica\App $a, &$b) * cookienotice_page_end * 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')); + $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, diff --git a/cookienotice/templates/admin.tpl b/cookienotice/templates/admin.tpl new file mode 100644 index 00000000..b64b0377 --- /dev/null +++ b/cookienotice/templates/admin.tpl @@ -0,0 +1,6 @@ +

{{$description nofilter}}

+{{include file="field_textarea.tpl" field=$text}} +{{include file="field_input.tpl" field=$oktext}} +
+ +
diff --git a/cookienotice/templates/settings.tpl b/cookienotice/templates/settings.tpl deleted file mode 100644 index 99489b9c..00000000 --- a/cookienotice/templates/settings.tpl +++ /dev/null @@ -1,15 +0,0 @@ - -

{{$title}}

-
- -
diff --git a/fortunate/README b/fortunate/README deleted file mode 100644 index 8297cf41..00000000 --- a/fortunate/README +++ /dev/null @@ -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. \ No newline at end of file diff --git a/fortunate/cookie.php b/fortunate/cookie.php deleted file mode 100644 index 3022776c..00000000 --- a/fortunate/cookie.php +++ /dev/null @@ -1,349 +0,0 @@ -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) ? "
[{$x['category']}]
" : ""); - } - 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 '
' . $result->num_rows . ' matching quotations.
'; - - - $res = @$db->query("SELECT DISTINCT ( `category` ) FROM `fortune` - $typesql - $adultsql - $lengthsql - $langsql - $patsql - $regexsql "); - if($res->num_rows) { - echo '
Matching Databases:
'; - while($x = $res->fetch_array(MYSQL_ASSOC)) - echo $x['category'].'
'; - - } - else - echo '
No matching databases using those search parameters - please refine your options.
'; - - -} - - -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
. - // 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"], - - ["&", - "<", - ">", - """, - "", - "        ", - "", - "
"], - $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 .= ''; - while($s[$x] == "\010") - $x ++; - $out .= substr($s,$x,$len); - $out .= ''; - $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 .= ''.$s[$x]; - $strike = true; - } - else { - if($strike) - $out .= ''; - $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>)\*/',"\\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); - - diff --git a/fortunate/fortunate.css b/fortunate/fortunate.css deleted file mode 100644 index 61813b7d..00000000 --- a/fortunate/fortunate.css +++ /dev/null @@ -1,7 +0,0 @@ -.fortunate { - margin-top: 25px; - margin-left: 100px; - margin-bottom: 25px; - color: #000088; - font-size: 14px; -} \ No newline at end of file diff --git a/fortunate/fortunate.php b/fortunate/fortunate.php deleted file mode 100644 index 939cbb4b..00000000 --- a/fortunate/fortunate.php +++ /dev/null @@ -1,39 +0,0 @@ - - * 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'] .= '' . "\r\n"; - - if (FORTUNATE_SERVER != 'hostname.com') { - $s = Network::fetchUrl('http://' . FORTUNATE_SERVER . '/cookie.php?numlines=2&equal=1&rand=' . mt_rand()); - $b .= '
' . $s . '
'; - } -} diff --git a/fortunate/fortunemod.sql.gz b/fortunate/fortunemod.sql.gz deleted file mode 100644 index 2ce0e557..00000000 Binary files a/fortunate/fortunemod.sql.gz and /dev/null differ diff --git a/fortunate/lang/C/messages.po b/fortunate/lang/C/messages.po deleted file mode 100644 index e69de29b..00000000 diff --git a/forumdirectory/forumdirectory.php b/forumdirectory/forumdirectory.php index 7879d47d..46a4b3cf 100644 --- a/forumdirectory/forumdirectory.php +++ b/forumdirectory/forumdirectory.php @@ -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 { diff --git a/geonames/README.md b/geonames/README.md index 443ddf3f..16b85b37 100644 --- a/geonames/README.md +++ b/geonames/README.md @@ -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. \ No newline at end of file +Also visit https://geonames.org/manageaccount and enable access to the free web services. diff --git a/geonames/geonames.php b/geonames/geonames.php index 1ce6dbfa..cc0420f4 100644 --- a/geonames/geonames.php +++ b/geonames/geonames.php @@ -4,202 +4,148 @@ * Description: Use Geonames service to resolve nearest populated location for given latitude, longitude * Version: 1.0 * Author: Mike Macgirvin - * - * - * 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']); + $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'] .= '' . "\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 .= '
'; - $s .= '

' . L10n::t('Geonames Settings') . '

'; - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - /* provide a submit button */ - - $s .= '
'; - + $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') + ]); } diff --git a/geonames/templates/settings.tpl b/geonames/templates/settings.tpl new file mode 100644 index 00000000..05897b6a --- /dev/null +++ b/geonames/templates/settings.tpl @@ -0,0 +1,14 @@ + +

{{$title}}

+
+ +
\ No newline at end of file diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index 4f86e704..99574f6d 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -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'), diff --git a/pageheader/pageheader.php b/pageheader/pageheader.php index 922f557c..fd07fc1d 100644 --- a/pageheader/pageheader.php +++ b/pageheader/pageheader.php @@ -8,85 +8,66 @@ * */ +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'] .= '' . "\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)')], - '$submit' => L10n::t('Save Settings') + '$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)')], + '$submit' => L10n::t('Save Settings') ]); 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'] .= '' . "\r\n"; + $stylesheetPath = __DIR__ .'/pageheader.css'; + $a->registerStylesheet($stylesheetPath); - if(! $s) - $s = ''; - if ($s != '') + if ($s) { $b .= ''; + } } diff --git a/pageheader/templates/admin.tpl b/pageheader/templates/admin.tpl new file mode 100644 index 00000000..498a9273 --- /dev/null +++ b/pageheader/templates/admin.tpl @@ -0,0 +1,5 @@ +{{include file="field_textarea.tpl" field=$phwords}} + +
+ +
diff --git a/pageheader/templates/settings.tpl b/pageheader/templates/settings.tpl deleted file mode 100644 index db1a4093..00000000 --- a/pageheader/templates/settings.tpl +++ /dev/null @@ -1,14 +0,0 @@ - -

{{$title}}

-
- -
diff --git a/pledgie/README b/pledgie/README deleted file mode 100644 index bcc7fe07..00000000 --- a/pledgie/README +++ /dev/null @@ -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. \ No newline at end of file diff --git a/pledgie/lang/C/messages.po b/pledgie/lang/C/messages.po deleted file mode 100644 index e69de29b..00000000 diff --git a/pledgie/pledgie.css b/pledgie/pledgie.css deleted file mode 100644 index 5195871c..00000000 --- a/pledgie/pledgie.css +++ /dev/null @@ -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; -} diff --git a/pledgie/pledgie.php b/pledgie/pledgie.php deleted file mode 100644 index 8a4378bc..00000000 --- a/pledgie/pledgie.php +++ /dev/null @@ -1,82 +0,0 @@ - - * Hauke Altmann - * - */ -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'] .= '' . "\r\n"; - - $campaign = Config::get('pledgie-campaign','text'); - $describe = Config::get('pledgie-describe','text'); - - if(! $campaign) - $campaign = ''; - - if(! describe) - $describe = ''; - - $s .= '
'; - $s .= '

' . L10n::t('"pledgie" Settings') . '

'; - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - $s .= '
'; - - 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 .= '
'; - $b .= $describe . '
Click here to lend your support to: ' . $describe .  '!
'; -} diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index ab4cceb7..5638a799 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -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); diff --git a/twitter/twitter.php b/twitter/twitter.php index f6d5912d..166c99ef 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -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); diff --git a/widgets/widget_like.php b/widgets/widget_like.php index 56ad1e5b..1fcc96b9 100644 --- a/widgets/widget_like.php +++ b/widgets/widget_like.php @@ -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; diff --git a/widgets/widgets.php b/widgets/widgets.php index 31bd0308..5c075964 100644 --- a/widgets/widgets.php +++ b/widgets/widgets.php @@ -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, diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index 65fcc357..30c6cf60 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -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); }