code cleanup

This commit is contained in:
redmatrix 2016-05-24 20:49:23 -07:00
parent f9a295a236
commit 80f2ba640e
30 changed files with 29 additions and 585 deletions

View file

@ -1197,7 +1197,6 @@ class App {
* @return App
*/
function get_app() {
global $a;
return $a;
}
@ -1247,7 +1246,6 @@ function system_unavailable() {
function clean_urls() {
global $a;
// if(App::$config['system']['clean_urls'])
return true;
@ -1255,8 +1253,6 @@ function clean_urls() {
}
function z_path() {
global $a;
$base = z_root();
if(! clean_urls())
$base .= '/?q=';
@ -1272,7 +1268,6 @@ function z_path() {
* @return string
*/
function z_root() {
global $a;
return App::get_baseurl();
}
@ -1604,7 +1599,6 @@ function fix_system_urls($oldurl, $newurl) {
// returns the complete html for inserting into the page
function login($register = false, $form_id = 'main-login', $hiddens=false) {
$a = get_app();
$o = '';
$reg = false;
$reglink = get_config('system', 'register_link');
@ -1674,9 +1668,7 @@ function goaway($s) {
}
function shutdown() {
global $db;
if(is_object($db) && $db->connected)
$db->close();
}
/**
@ -1766,7 +1758,6 @@ function remote_user() {
* @param string $s Text to display
*/
function notice($s) {
$a = get_app();
if(! x($_SESSION, 'sysmsg')) $_SESSION['sysmsg'] = array();
// ignore duplicated error messages which haven't yet been displayed
@ -1790,7 +1781,6 @@ function notice($s) {
* @param string $s Text to display
*/
function info($s) {
$a = get_app();
if(! x($_SESSION, 'sysmsg_info')) $_SESSION['sysmsg_info'] = array();
if(App::$interactive)
$_SESSION['sysmsg_info'][] = $s;
@ -1891,7 +1881,6 @@ function is_windows() {
*/
function is_site_admin() {
$a = get_app();
if($_SESSION['delegate'])
return false;
@ -1912,7 +1901,7 @@ function is_site_admin() {
* @return bool true if user is a developer
*/
function is_developer() {
$a = get_app();
if((intval($_SESSION['authenticated']))
&& (is_array(App::$account))
&& (App::$account['account_roles'] & ACCOUNT_ROLE_DEVELOPER))
@ -1923,7 +1912,6 @@ function is_developer() {
function load_contact_links($uid) {
$a = get_app();
$ret = array();
@ -2241,7 +2229,6 @@ function appdirpath() {
* @param string $icon
*/
function head_set_icon($icon) {
global $a;
App::$data['pageicon'] = $icon;
// logger('head_set_icon: ' . $icon);
@ -2253,7 +2240,6 @@ function head_set_icon($icon) {
* @return string absolut path to pageicon
*/
function head_get_icon() {
global $a;
$icon = App::$data['pageicon'];
if(! strpos($icon, '://'))
@ -2319,7 +2305,7 @@ function z_get_temp_dir() {
}
function z_check_cert() {
$a = get_app();
if(strpos(z_root(),'https://') !== false) {
$x = z_fetch_url(z_root() . '/siteinfo/json');
if(! $x['success']) {
@ -2340,8 +2326,6 @@ function z_check_cert() {
*/
function cert_bad_email() {
$a = get_app();
$email_tpl = get_intltext_template("cert_bad_eml.tpl");
$email_msg = replace_macros($email_tpl, array(
'$sitename' => App::$config['system']['sitename'],
@ -2380,8 +2364,6 @@ function check_cron_broken() {
return;
}
$a = get_app();
$email_tpl = get_intltext_template("cron_bad_eml.tpl");
$email_msg = replace_macros($email_tpl, array(
'$sitename' => App::$config['system']['sitename'],

View file

@ -26,9 +26,6 @@
[zrl=[baseurl]/help/git_for_non_developers]Git per a No-Desenvolupadors[/zrl]
[zrl=[baseurl]/help/dev_beginner]Manual pas-a-pas per a desenvolupadors principiants[/zrl]
[h3]Preguntes Més Freqüents (FAQ) Per Desenvolupadors[/h3]
[zrl=[baseurl]/help/faq_developers]FAQ Per Desenvoupadors[/zrl]
[h3]Recursos Externs[/h3]
[url=https://zothub.com/channel/one]Development Channel[/url]
[url=https://federated.social/channel/postgres]Postgres-specific $Projectname Admin Support Channel[/url]

View file

@ -25,9 +25,6 @@
[zrl=[baseurl]/help/git_for_non_developers]Git für Nicht-Entwickler[/zrl]
[zrl=[baseurl]/help/dev_beginner]Schritt-für-Schritt-Einführung für neue Entwickler[/zrl]
[h3]Häufig gestellte Fragen für Entwickler[/h3]
[zrl=[baseurl]/help/faq_developers]FAQ für Entwickler[/zrl]
[h3]Externe Ressourcen[/h3]
[url=https://zothub.com/channel/one]Entwickler-Kanal[/url]
[url=https://federated.social/channel/postgres]Postgres-spezifischer Admin-Support-Kanal[/url]

View file

@ -26,9 +26,6 @@
[zrl=[baseurl]/help/git_for_non_developers]Git for Non-Developers[/zrl]
[zrl=[baseurl]/help/dev_beginner]Step-for-step manual for beginning developers[/zrl]
[h3]Frequently Asked Questions For Developers[/h3]
[zrl=[baseurl]/help/faq_developers]FAQ For Developers[/zrl]
[h3]External Resources[/h3]
[url=https://zothub.com/channel/one]Development Channel[/url]
[url=https://federated.social/channel/postgres]Postgres-specific $Projectname Admin Support Channel[/url]

View file

@ -12,10 +12,6 @@ Returns authenticated numeric channel_id if authenticated and connected to a cha
Returns authenticated string hash of Red global identifier, if authenticated via remote auth, or an empty string.
[b]get_app()[/b]
Returns the global app structure ($a).
[b]App::get_observer()[/b]
returns an xchan structure representing the current viewer if authenticated (locally or remotely).

File diff suppressed because one or more lines are too long

View file

@ -67,9 +67,6 @@ Zot är en fantastisk ny kommunikationsprotokoll uppfunnit speciellt för $Proje
[zrl=[baseurl]/help/git_for_non_developers]Git for Non-Developers[/zrl]
[zrl=[baseurl]/help/dev_beginner]Sep-for-step manual for beginning developers[/zrl]
[h3]FAQ för utvecklare[/h3]
[zrl=[baseurl]/help/faq_developers]FAQ For Developers[/zrl]
[h3]Externa resurser[/h3]
[zrl=[baseurl]/help/external-resource-links]External Resource Links[/zrl]
[url=https://github.com/friendica/red]Main Website[/url]

View file

@ -6,7 +6,6 @@ require_once('include/follow.php');
require_once('include/photo/photo_driver.php');
function import_diaspora($data) {
$a = get_app();
$account = App::get_account();
if(! $account)

View file

@ -656,7 +656,8 @@ function account_service_class_allows($aid, $property, $usage = false) {
* @todo Should we merge this with account_service_class_fetch()?
*/
function service_class_fetch($uid, $property) {
$a = get_app();
if($uid == local_channel()) {
$service_class = App::$account['account_service_class'];
}

View file

@ -11,8 +11,6 @@ require_once("include/PermissionDescription.php");
function group_select($selname,$selclass,$preselected = false,$size = 4) {
$a = get_app();
$o = '';
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n";
@ -51,7 +49,6 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
/* MicMee 20130114 function contact_selector no longer in use, sql table contact does no longer exist
function contact_selector($selname, $selclass, $preselected = false, $options) {
$a = get_app();
$mutual = false;
$networks = null;
@ -157,7 +154,6 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false, $tabindex = null) {
$a = get_app();
$o = '';

View file

@ -1,7 +1,6 @@
<?php /** @file */
function profile_activity($changed, $value) {
$a = get_app();
if(! local_channel() || ! is_array($changed) || ! count($changed))
return;

View file

@ -451,8 +451,6 @@ require_once('include/api_auth.php');
*/
function api_apply_template($templatename, $type, $data){
$a = get_app();
switch($type){
case "atom":
case "rss":
@ -1904,7 +1902,6 @@ require_once('include/api_auth.php');
//logger('api_format_items: ' . print_r($user_info,true));
$a = get_app();
$ret = array();
if(! $r)

View file

@ -479,8 +479,6 @@ function unescape_underscores_in_links($m) {
function format_event_diaspora($ev) {
$a = get_app();
if(! ((is_array($ev)) && count($ev)))
return '';

View file

@ -275,7 +275,6 @@ function bb_location($match) {
* @return string HTML iframe with content of $match[1]
*/
function bb_iframe($match) {
$a = get_app();
$sandbox = ((strpos($match[1], App::get_hostname())) ? ' sandbox="allow-scripts" ' : '');
@ -449,8 +448,6 @@ function bb_sanitize_style($input) {
function bb_observer($Text) {
$a = get_app();
$observer = App::get_observer();
if ((strpos($Text,'[/observer]') !== false) || (strpos($Text,'[/rpost]') !== false)) {

View file

@ -80,7 +80,6 @@ function load_config($family) {
* @return mixed Return value or false on error or if not set
*/
function get_config($family, $key) {
global $a;
if((! array_key_exists($family, App::$config)) || (! array_key_exists('config_loaded', App::$config[$family])))
load_config($family);
@ -135,7 +134,6 @@ function get_config_from_storage($family, $key) {
* Return the set value, or false if the database update failed
*/
function set_config($family, $key, $value) {
global $a;
// manage array value
$dbvalue = ((is_array($value)) ? serialize($value) : $value);
@ -180,7 +178,7 @@ function set_config($family, $key, $value) {
* @return mixed
*/
function del_config($family, $key) {
global $a;
$ret = false;
if(array_key_exists($family, App::$config) && array_key_exists($key, App::$config[$family]))
@ -204,7 +202,6 @@ function del_config($family, $key) {
* @return void|false Nothing or false if $uid is false
*/
function load_pconfig($uid) {
global $a;
if($uid === false)
return false;
@ -249,7 +246,6 @@ function load_pconfig($uid) {
*/
function get_pconfig($uid, $family, $key, $instore = false) {
// logger('include/config.php: get_pconfig() deprecated instore param used', LOGGER_DEBUG);
global $a;
if($uid === false)
return false;
@ -285,7 +281,6 @@ function get_pconfig($uid, $family, $key, $instore = false) {
* @return mixed Stored $value or false
*/
function set_pconfig($uid, $family, $key, $value) {
global $a;
// this catches subtle errors where this function has been called
// with local_channel() when not logged in (which returns false)
@ -372,7 +367,7 @@ function set_pconfig($uid, $family, $key, $value) {
* @return mixed
*/
function del_pconfig($uid, $family, $key) {
global $a;
$ret = false;
if (x(App::$config[$uid][$family], $key))
@ -398,7 +393,6 @@ function del_pconfig($uid, $family, $key) {
* @return void|false Returns false if xchan is not set
*/
function load_xconfig($xchan) {
global $a;
if(! $xchan)
return false;
@ -441,7 +435,6 @@ function load_xconfig($xchan) {
* @return mixed Stored $value or false if it does not exist
*/
function get_xconfig($xchan, $family, $key) {
global $a;
if(! $xchan)
return false;
@ -477,7 +470,6 @@ function get_xconfig($xchan, $family, $key) {
* @return mixed Stored $value or false
*/
function set_xconfig($xchan, $family, $key, $value) {
global $a;
// manage array value
$dbvalue = ((is_array($value)) ? serialize($value) : $value);
@ -530,7 +522,7 @@ function set_xconfig($xchan, $family, $key, $value) {
* @return mixed
*/
function del_xconfig($xchan, $family, $key) {
global $a;
$ret = false;
if(x(App::$config[$xchan][$family], $key))

View file

@ -72,8 +72,6 @@ function channelx_by_n($id) {
function vcard_from_xchan($xchan, $observer = null, $mode = '') {
$a = get_app();
if(! $xchan) {
if(App::$poi) {
$xchan = App::$poi;
@ -267,7 +265,7 @@ function channel_remove($channel_id, $local = true, $unset_session=false) {
if(! $channel_id)
return;
$a = get_app();
logger('Removing channel: ' . $channel_id);
logger('channel_remove: local only: ' . intval($local));

View file

@ -858,8 +858,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
function best_link_url($item) {
$a = get_app();
$best_url = '';
$sparkle = false;
@ -888,7 +886,7 @@ function best_link_url($item) {
function item_photo_menu($item){
$a = get_app();
$contact = null;
$ssl_state = false;
@ -1408,7 +1406,7 @@ function render_location_default($item) {
function prepare_page($item) {
$a = get_app();
$naked = 1;
// $naked = ((get_pconfig($item['uid'],'system','nakedpage')) ? 1 : 0);
$observer = App::get_observer();
@ -1442,7 +1440,7 @@ function prepare_page($item) {
function network_tabs() {
$a = get_app();
$no_active='';
$starred_active = '';
$new_active = '';

View file

@ -119,7 +119,6 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
* @return string
*/
function dob($dob) {
$a = get_app();
list($year, $month, $day) = sscanf($dob, '%4d-%2d-%2d');
$f = get_config('system', 'birthday_input_format');

View file

@ -17,7 +17,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
$result = array('success' => false,'message' => '');
$a = get_app();
$is_red = false;
$is_http = ((strpos($url,'://') !== false) ? true : false);

View file

@ -24,8 +24,6 @@ function find_doc_file($s) {
function search_doc_files($s) {
$a = get_app();
$itemspage = get_pconfig(local_channel(),'system','itemspage');
\App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));

View file

@ -82,13 +82,11 @@ function get_best_language() {
if($arr['preferred'] !== 'unset')
return $arr['preferred'];
$a = get_app();
return ((isset(App::$config['system']['language'])) ? App::$config['system']['language'] : 'en');
}
function push_lang($language) {
global $a;
App::$langsave = App::$language;
@ -104,7 +102,6 @@ function push_lang($language) {
}
function pop_lang() {
global $a;
if(App::$language === App::$langsave)
return;
@ -124,7 +121,6 @@ function pop_lang() {
* @param boolean $install (optional) default false
*/
function load_translation_table($lang, $install = false) {
global $a;
App::$strings = array();
@ -170,7 +166,6 @@ function load_translation_table($lang, $install = false) {
*
*/
function t($s, $ctx = '') {
global $a;
$cs = $ctx ? '__ctx:' . $ctx . '__ ' . $s : $s;
if (x(App::$strings, $cs)) {
@ -205,7 +200,6 @@ function translate_projectname($s) {
* @return string
*/
function tt($singular, $plural, $count, $ctx = ''){
$a = get_app();
$cs = $ctx ? "__ctx:" . $ctx . "__ " . $singular : $singular;
if (x(App::$strings,$cs)) {

View file

@ -595,8 +595,6 @@ function parse_xml_string($s,$strict = true) {
function scale_external_images($s, $include_link = true, $scale_replace = false) {
$a = get_app();
// Picture addresses can contain special characters
$s = htmlspecialchars_decode($s, ENT_COMPAT);
@ -1618,8 +1616,6 @@ function fetch_xrd_links($url) {
function scrape_vcard($url) {
$a = get_app();
$ret = array();
logger('scrape_vcard: url=' . $url);
@ -1699,8 +1695,6 @@ function scrape_vcard($url) {
function scrape_feed($url) {
$a = get_app();
$ret = array();
$level = 0;
$x = z_fetch_url($url,false,$level,array('novalidate' => true));
@ -1938,9 +1932,6 @@ function do_delivery($deliveries) {
function get_site_info() {
global $db;
global $a;
$register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
$directory_mode = Array('DIRECTORY_MODE_NORMAL', 'DIRECTORY_MODE_PRIMARY', 'DIRECTORY_MODE_SECONDARY', 256 => 'DIRECTORY_MODE_STANDALONE');

View file

@ -227,7 +227,7 @@ function oembed_fetch_url($embedurl){
}
function oembed_format_object($j){
$a = get_app();
$embedurl = $j->embedurl;
// logger('format: ' . print_r($j,true));

View file

@ -521,7 +521,7 @@ function guess_image_type($filename, $headers = '') {
logger('Photo: guess_image_type: '.$filename . ($headers?' from curl headers':''), LOGGER_DEBUG);
$type = null;
if ($headers) {
$a = get_app();
$hdrs=array();
$h = explode("\n",$headers);
foreach ($h as $l) {
@ -580,8 +580,6 @@ function guess_image_type($filename, $headers = '') {
function import_xchan_photo($photo,$xchan,$thing = false) {
$a = get_app();
$flags = (($thing) ? PHOTO_THING : PHOTO_XCHAN);
$album = (($thing) ? 'Things' : 'Contact Photos');
@ -703,8 +701,6 @@ function import_xchan_photo($photo,$xchan,$thing = false) {
function import_channel_photo($photo,$type,$aid,$uid) {
$a = get_app();
logger('import_channel_photo: importing channel photo for ' . $uid, LOGGER_DEBUG);
$hash = photo_new_resource();

View file

@ -19,8 +19,6 @@ require_once('include/text.php');
*/
function photo_upload($channel, $observer, $args) {
$a = get_app();
$ret = array('success' => false);
$channel_id = $channel['channel_id'];
$account_id = $channel['channel_account_id'];

View file

@ -500,7 +500,7 @@ function get_theme_info($theme){
* @return string
*/
function get_theme_screenshot($theme) {
$a = get_app();
$exts = array('.png', '.jpg');
foreach($exts as $ext) {
if(file_exists('view/theme/' . $theme . '/img/screenshot' . $ext))
@ -521,7 +521,7 @@ function head_add_css($src, $media = 'screen') {
}
function head_remove_css($src, $media = 'screen') {
$a = get_app();
$index = array_search(array($src, $media), App::$css_sources);
if ($index !== false)
unset(App::$css_sources[$index]);
@ -592,7 +592,7 @@ function head_add_js($src) {
}
function head_remove_js($src) {
$a = get_app();
$index = array_search($src, App::$js_sources);
if($index !== false)
unset(App::$js_sources[$index]);
@ -633,7 +633,6 @@ function format_js_if_exists($source) {
function theme_include($file, $root = '') {
$a = get_app();
// Make sure $root ends with a slash / if it's not blank
if($root !== '' && $root[strlen($root)-1] !== '/')
@ -671,7 +670,7 @@ function theme_include($file, $root = '') {
function get_intltext_template($s, $root = '') {
$a = get_app();
$t = App::template_engine();
$template = $t->get_intltext_template($s, $root);
@ -680,7 +679,7 @@ function get_intltext_template($s, $root = '') {
function get_markup_template($s, $root = '') {
$a = get_app();
$t = App::template_engine();
$template = $t->get_markup_template($s, $root);
return $template;

View file

@ -20,7 +20,6 @@ define('RANDOM_STRING_TEXT', 0x01 );
* @return string substituted string
*/
function replace_macros($s, $r) {
$a = get_app();
$arr = array('template' => $s, 'params' => $r);
call_hooks('replace_macros', $arr);
@ -96,7 +95,6 @@ function z_input_filter($channel_id,$s,$type = 'text/bbcode') {
if($type == 'application/x-pdl')
return escape_tags($s);
$a = get_app();
if(App::$is_sys) {
return $s;
}
@ -653,11 +651,10 @@ function log_priority_str($priority) {
* @param int $level A log level.
*/
function dlogger($msg, $level = 0) {
// turn off logger in install mode
global $a;
global $db;
if((App::$module == 'install') || (! (DBA::$dba && DBA::$dba->connected)))
// turn off logger in install mode
if(App::$module == 'setup')
return;
$debugging = get_config('system','debugging');
@ -815,7 +812,6 @@ function get_mentions($item,$tags) {
function contact_block() {
$o = '';
$a = get_app();
if(! App::$profile['uid'])
return;
@ -928,7 +924,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
function search($s,$id='search-box',$url='/search',$save = false) {
$a = get_app();
return replace_macros(get_markup_template('searchbox.tpl'),array(
'$s' => $s,
'$id' => $id,
@ -1073,7 +1069,7 @@ function get_mood_verbs() {
// Function to list all smilies, both internal and from addons
// Returns array with keys 'texts' and 'icons'
function list_smilies() {
$a = get_app();
$texts = array(
'&lt;3',
'&lt;/3',
@ -1106,10 +1102,8 @@ function list_smilies() {
':coffee',
':facepalm',
':like',
':dislike',
'red#matrix',
'red#',
'r#'
':dislike'
);
$icons = array(
@ -1145,9 +1139,6 @@ function list_smilies() {
'<img class="smiley" src="' . z_root() . '/images/smiley-facepalm.gif" alt=":facepalm" />',
'<img class="smiley" src="' . z_root() . '/images/like.gif" alt=":like" />',
'<img class="smiley" src="' . z_root() . '/images/dislike.gif" alt=":dislike" />',
'<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . z_root() . '/images/rm-32.png" alt="' . urlencode('red#matrix') . '" />matrix</strong></a>',
'<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . z_root() . '/images/rm-32.png" alt="' . urlencode('red#') . '" />matrix</strong></a>',
'<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . z_root() . '/images/rm-32.png" alt="r#" />matrix</strong></a>'
);
@ -1218,7 +1209,7 @@ function smile_unshield($m) {
* @param array $x
*/
function preg_heart($x) {
$a = get_app();
if (strlen($x[1]) == 1)
return $x[0];
@ -1491,7 +1482,6 @@ function format_event($jobject) {
}
function prepare_body(&$item,$attach = false) {
require_once('include/channel.php');
call_hooks('prepare_body_init', $item);
@ -1721,7 +1711,6 @@ function feed_hublinks() {
/* return atom link elements for salmon endpoints */
function feed_salmonlinks($nick) {
$a = get_app();
$salmon = '<link rel="salmon" href="' . xmlify(z_root() . '/salmon/' . $nick) . '" />' . "\n" ;
@ -1789,7 +1778,7 @@ function mimetype_select($channel_id, $current = 'text/bbcode') {
'application/x-pdl'
);
$a = get_app();
if(App::$is_sys) {
$x[] = 'application/x-php';
}
@ -1822,7 +1811,6 @@ function mimetype_select($channel_id, $current = 'text/bbcode') {
function lang_selector() {
global $a;
$langs = glob('view/*/hstrings.php');

View file

@ -771,7 +771,6 @@ function widget_eventstools($arr) {
}
function widget_design_tools($arr) {
$a = get_app();
// mod menu doesn't load a profile. For any modules which load a profile, check it.
// otherwise local_channel() is sufficient for permissions.

View file

@ -2944,8 +2944,6 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
if(UNO)
return;
$a = get_app();
logger('build_sync_packet');
if($packet)
@ -3932,8 +3930,6 @@ function zotinfo($arr) {
$ret['site']['admin'] = get_config('system','admin_email');
$a = get_app();
$visible_plugins = array();
if(is_array(App::$plugins) && count(App::$plugins)) {
$r = q("select * from addon where hidden = 0");

View file

@ -13,7 +13,7 @@
<id>{{$feed_id}}</id>
<title>{{$feed_title}}</title>
<generator uri="http://getzot.com" version="{{$version}}">{{$red}}</generator>
<generator uri="http://hubzilla.org" version="{{$version}}">{{$red}}</generator>
<link rel="license" href="http://creativecommons.org/licenses/by/3.0/" />
<link rel="alternate" type="text/html" href="{{$profile_page}}" />
{{if $hub}}