diff --git a/blackout/blackout.php b/blackout/blackout.php index 4fb824efa..2693db5a5 100644 --- a/blackout/blackout.php +++ b/blackout/blackout.php @@ -36,10 +36,10 @@ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -95,14 +95,14 @@ function blackout_plugin_admin(&$a, &$o) { $myurl = Config::get('blackout','url'); if (! is_string($myurl)) { $myurl = "http://www.example.com"; } $t = get_markup_template( "admin.tpl", "addon/blackout/" ); - - $o = replace_macros($t, array( - '$submit' => t('Save Settings'), - '$rurl' => array("rurl", "Redirect URL", $myurl, "all your visitors from the web will be redirected to this URL"), - '$startdate' => array("startdate", "Begin of the Blackout
(YYYY-MM-DD hh:mm)", $mystart, "format is YYYY year, MM month, DD day, hh hour and mm minute"), - '$enddate' => array("enddate", "End of the Blackout
(YYYY-MM-DD hh:mm)", $myend, ""), - )); + $o = replace_macros($t, [ + '$submit' => t('Save Settings'), + '$rurl' => ["rurl", "Redirect URL", $myurl, "all your visitors from the web will be redirected to this URL"], + '$startdate' => ["startdate", "Begin of the Blackout
(YYYY-MM-DD hh:mm)", $mystart, "format is YYYY year, MM month, DD day, hh hour and mm minute"], + '$enddate' => ["enddate", "End of the Blackout
(YYYY-MM-DD hh:mm)", $myend, ""], + + ]); $date1 = DateTime::createFromFormat('Y-m-d G:i', $mystart); $date2 = DateTime::createFromFormat('Y-m-d G:i', $myend); if ($date2 < $date1) { diff --git a/blockem/blockem.php b/blockem/blockem.php index d8855886c..2c91373f4 100644 --- a/blockem/blockem.php +++ b/blockem/blockem.php @@ -6,7 +6,7 @@ * Description: block people * Version: 1.0 * Author: Mike Macgirvin - * + * */ use Friendica\Core\PConfig; @@ -141,7 +141,7 @@ function blockem_prepare_body(&$a,&$b) { } if($found) { $rnd = random_string(8); - $b['html'] = ''; + $b['html'] = ''; } } @@ -218,7 +218,7 @@ function blockem_init(&$a) { } if(array_key_exists('unblock',$_GET) && $_GET['unblock']) { $arr = explode(',',$words); - $newarr = array(); + $newarr = []; if(count($arr)) { foreach($arr as $x) { diff --git a/buffer/buffer.php b/buffer/buffer.php index 932789da5..b90d90908 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -57,12 +57,12 @@ function buffer_content(&$a) { function buffer_plugin_admin(&$a, &$o){ $t = get_markup_template( "admin.tpl", "addon/buffer/" ); - $o = replace_macros($t, array( + $o = replace_macros($t, [ '$submit' => t('Save Settings'), // name, label, value, help, [extra values] - '$client_id' => array('client_id', t('Client ID'), Config::get('buffer', 'client_id' ), ''), - '$client_secret' => array('client_secret', t('Client Secret'), Config::get('buffer', 'client_secret' ), ''), - )); + '$client_id' => ['client_id', t('Client ID'), Config::get('buffer', 'client_id' ), ''], + '$client_secret' => ['client_secret', t('Client Secret'), Config::get('buffer', 'client_secret' ), ''], + ]); } function buffer_plugin_admin_post(&$a){ $client_id = ((x($_POST,'client_id')) ? notags(trim($_POST['client_id'])) : ''); @@ -369,7 +369,7 @@ function buffer_send(App $a, &$b) elseif ($profile->service == "google") $post["text"] .= html_entity_decode(" ", ENT_QUOTES, 'UTF-8'); // Send a special blank to identify the post through the "fromgplus" addon - $message = array(); + $message = []; $message["text"] = $post["text"]; $message["profile_ids[]"] = $profile->id; $message["shorten"] = false; diff --git a/buffer/bufferapp.php b/buffer/bufferapp.php index 7215175dc..a222b23ec 100644 --- a/buffer/bufferapp.php +++ b/buffer/bufferapp.php @@ -12,7 +12,7 @@ public $ok = false; - private $endpoints = array( + private $endpoints = [ '/user' => 'get', '/profiles' => 'get', @@ -37,9 +37,9 @@ '/info/configuration' => 'get', - ); + ]; - public $errors = array( + public $errors = [ 'invalid-endpoint' => 'The endpoint you supplied does not appear to be valid.', '403' => 'Permission denied.', @@ -77,7 +77,7 @@ '1042' => 'User did not save successfully.', '1050' => 'Client could not be found.', '1051' => 'No authorization to access client.', - ); + ]; function __construct($client_id = '', $client_secret = '', $callback_url = '', $access_token = '') { if ($client_id) $this->set_client_id($client_id); @@ -110,7 +110,7 @@ if (!$ok) return $this->error('invalid-endpoint'); } - if (!$data || !is_array($data)) $data = array(); + if (!$data || !is_array($data)) $data = []; $data['access_token'] = $this->access_token; $method = $this->endpoints[$done_endpoint]; //get() or post() @@ -130,17 +130,17 @@ } function error($error) { - return (object) array('error' => $this->errors[$error]); + return (object) ['error' => $this->errors[$error]]; } function create_access_token_url() { - $data = array( + $data = [ 'code' => $this->code, 'grant_type' => 'authorization_code', 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'redirect_uri' => $this->callback_url, - ); + ]; $obj = $this->post($this->access_token_url, $data); $this->access_token = $obj->access_token; @@ -150,15 +150,15 @@ function req($url = '', $data = '', $post = true) { if (!$url) return false; - if (!$data || !is_array($data)) $data = array(); + if (!$data || !is_array($data)) $data = []; - $options = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false); + $options = [CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false]; if ($post) { - $options += array( + $options += [ CURLOPT_POST => $post, CURLOPT_POSTFIELDS => $data - ); + ]; } else { $url .= '?' . http_build_query($data); } diff --git a/communityhome/communityhome.php b/communityhome/communityhome.php index 288bf7a85..7cfb3d234 100644 --- a/communityhome/communityhome.php +++ b/communityhome/communityhome.php @@ -62,27 +62,27 @@ function communityhome_home(&$a, &$o){ $a->page['htmlhead'] .= ''; if (!Config::get('communityhome','hidelogin')){ - $aside = array( + $aside = [ '$tab_1' => t('Login'), '$tab_2' => t('OpenID'), '$noOid' => Config::get('system','no_openid'), - ); + ]; // login form $aside['$login_title'] = t('Login'); $aside['$login_form'] = Login::form($a->query_string, $a->config['register_policy'] == REGISTER_CLOSED ? false : true); } else { - $aside = array( + $aside = [ //'$tab_1' => t('Login'), //'$tab_2' => t('OpenID'), //'$noOid' => Config::get('system','no_openid'), - ); + ]; } // last 12 users if (Config::get('communityhome','showlastusers')){ $aside['$lastusers_title'] = t('Latest users'); - $aside['$lastusers_items'] = array(); + $aside['$lastusers_items'] = []; $sql_extra = ""; $publish = (Config::get('system','publish_all') ? '' : " AND `publish` = 1 " ); $order = " ORDER BY `register_date` DESC "; @@ -99,12 +99,12 @@ function communityhome_home(&$a, &$o){ $photo = 'thumb'; foreach($r as $rr) { $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']); - $entry = replace_macros($tpl,array( + $entry = replace_macros($tpl,[ '$id' => $rr['id'], '$profile_link' => $profile_link, '$photo' => $a->get_cached_avatar_image($rr[$photo]), '$alt_text' => $rr['name'], - )); + ]); $aside['$lastusers_items'][] = $entry; } } @@ -127,17 +127,17 @@ function communityhome_home(&$a, &$o){ LIMIT 0,10"); if($r && count($r)) { $aside['$activeusers_title'] = t('Most active users'); - $aside['$activeusers_items'] = array(); + $aside['$activeusers_items'] = []; $photo = 'thumb'; foreach($r as $rr) { $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']); - $entry = replace_macros($tpl,array( + $entry = replace_macros($tpl,[ '$id' => $rr['id'], '$profile_link' => $profile_link, '$photo' => $rr[$photo], '$photo_user' => sprintf("%s (%s posts, %s contacts)",$rr['name'], ($rr['items']?$rr['items']:'0'), ($rr['contacts']?$rr['contacts']:'0')) - )); + ]); $aside['$activeusers_items'][] = $entry; } } @@ -145,7 +145,7 @@ function communityhome_home(&$a, &$o){ // last 12 photos if (Config::get('communityhome','showlastphotos')){ $aside['$photos_title'] = t('Latest photos'); - $aside['$photos_items'] = array(); + $aside['$photos_items'] = []; $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM (SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo` WHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s') @@ -169,13 +169,13 @@ function communityhome_home(&$a, &$o){ $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id']; $photo_url = $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] .'.jpg'; - $entry = replace_macros($tpl,array( + $entry = replace_macros($tpl,[ '$id' => $rr['id'], '$profile_link' => $photo_page, '$photo' => $photo_url, '$photo_user' => $rr['username'], '$photo_title' => $rr['desc'] - )); + ]); $aside['$photos_items'][] = $entry; } @@ -185,7 +185,7 @@ function communityhome_home(&$a, &$o){ // last 10 liked items if (Config::get('communityhome','showlastlike')){ $aside['$like_title'] = t('Latest likes'); - $aside['$like_items'] = array(); + $aside['$like_items'] = []; $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM (SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link` FROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1 @@ -215,7 +215,7 @@ function communityhome_home(&$a, &$o){ default: if ($rr['resource-id']){ $post_type = t('photo'); - $m=array(); preg_match("/\[url=([^]]*)\]/", $rr['body'], $m); + $m=[]; preg_match("/\[url=([^]]*)\]/", $rr['body'], $m); $rr['plink'] = $m[1]; } else { $post_type = t('status'); diff --git a/convert/convert.php b/convert/convert.php index 751316503..03b1e9d5a 100644 --- a/convert/convert.php +++ b/convert/convert.php @@ -15,7 +15,7 @@ function convert_uninstall() { } function convert_app_menu($a,&$b) { - $b['app_menu'][] = '
Units Conversion
'; + $b['app_menu'][] = '
Units Conversion
'; } @@ -30,7 +30,7 @@ function convert_module() {} function convert_content($app) { include("UnitConvertor.php"); - + class TP_Converter extends UnitConvertor { function TP_Converter($lang = "en") { @@ -39,7 +39,7 @@ include("UnitConvertor.php"); } else { $dec_point = '.'; $thousand_sep = ","; } - + $this->UnitConvertor($dec_point , $thousand_sep ); } // end func UnitConvertor @@ -47,24 +47,24 @@ include("UnitConvertor.php"); function find_base_unit($from,$to) { while (list($skey,$sval) = each($this->bases)) { if ($skey == $from || $to == $skey || in_array($to,$sval) || in_array($from,$sval)) { - return $skey; + return $skey; } } - return false; + return false; } function getTable($value, $from_unit, $to_unit, $precision) { - + if ($base_unit = $this->find_base_unit($from_unit,$to_unit)) { - - // A baseunit was found now lets convert from -> $base_unit - - $cell ['value'] = $this->convert($value, $from_unit, $base_unit, $precision)." ".$base_unit; + + // A baseunit was found now lets convert from -> $base_unit + + $cell ['value'] = $this->convert($value, $from_unit, $base_unit, $precision)." ".$base_unit; $cell ['class'] = ($base_unit == $from_unit || $base_unit == $to_unit) ? "framedred": ""; $cells[] = $cell; // We now have the base unit and value now lets produce the table; while (list($key,$val) = each($this->bases[$base_unit])) { - $cell ['value'] = $this->convert($value, $from_unit, $val, $precision)." ".$val; + $cell ['value'] = $this->convert($value, $from_unit, $val, $precision)." ".$val; $cell ['class'] = ($val == $from_unit || $val == $to_unit) ? "framedred": ""; $cells[] = $cell; } @@ -83,8 +83,8 @@ include("UnitConvertor.php"); } $string .= ""; return $string; - } - + } + } } @@ -92,16 +92,16 @@ include("UnitConvertor.php"); $conv = new TP_Converter('en'); -$conversions = array( - 'Temperature'=>array('base' =>'Celsius', - 'conv'=>array( - 'Fahrenheit'=>array('ratio'=>1.8, 'offset'=>32), - 'Kelvin'=>array('ratio'=>1, 'offset'=>273), +$conversions = [ + 'Temperature'=>['base' =>'Celsius', + 'conv'=>[ + 'Fahrenheit'=>['ratio'=>1.8, 'offset'=>32], + 'Kelvin'=>['ratio'=>1, 'offset'=>273], 'Reaumur'=>0.8 - ) - ), - 'Weight' => array('base' =>'kg', - 'conv'=>array( + ] + ], + 'Weight' => ['base' =>'kg', + 'conv'=>[ 'g'=>1000, 'mg'=>1000000, 't'=>0.001, @@ -109,13 +109,13 @@ $conversions = array( 'oz'=>35.274, 'lb'=>2.2046, 'cwt(UK)' => 0.019684, - 'cwt(US)' => 0.022046, + 'cwt(US)' => 0.022046, 'ton (US)' => 0.0011023, 'ton (UK)' => 0.0009842 - ) - ), - 'Distance' => array('base' =>'km', - 'conv'=>array( + ] + ], + 'Distance' => ['base' =>'km', + 'conv'=>[ 'm'=>1000, 'dm'=>10000, 'cm'=>100000, @@ -127,25 +127,25 @@ $conversions = array( 'yd'=>1093.6, 'furlong'=>4.970969537898672, 'fathom'=>546.8066491688539 - ) - ), - 'Area' => array('base' =>'km 2', - 'conv'=>array( + ] + ], + 'Area' => ['base' =>'km 2', + 'conv'=>[ 'ha'=>100, 'acre'=>247.105, 'm 2'=>pow(1000,2), 'dm 2'=>pow(10000,2), 'cm 2'=>pow(100000,2), - 'mm 2'=>pow(1000000,2), + 'mm 2'=>pow(1000000,2), 'mile 2'=>pow(0.62137,2), 'naut.miles 2'=>pow(0.53996,2), 'in 2'=>pow(39370,2), 'ft 2'=>pow(3280.8,2), 'yd 2'=>pow(1093.6,2), - ) - ), - 'Volume' => array('base' =>'m 3', - 'conv'=>array( + ] + ], + 'Volume' => ['base' =>'m 3', + 'conv'=>[ 'in 3'=>61023.6, 'ft 3'=>35.315, 'cm 3'=>pow(10,6), @@ -161,22 +161,22 @@ $conversions = array( 'fl oz' => 33814.02, 'tablespoon' => 67628.04, 'teaspoon' => 202884.1, - 'pt (UK)'=>1000/0.56826, + 'pt (UK)'=>1000/0.56826, 'barrel petroleum'=>1000/158.99, - 'Register Tons'=>2.832, + 'Register Tons'=>2.832, 'Ocean Tons'=>1.1327 - ) - ), - 'Speed' =>array('base' =>'kmph', - 'conv'=>array( + ] + ], + 'Speed' =>['base' =>'kmph', + 'conv'=>[ 'mps'=>0.0001726031, 'milesph'=>0.62137, 'knots'=>0.53996, 'mach STP'=>0.0008380431, 'c (warp)'=>9.265669e-10 - ) - ) -); + ] + ] +]; while (list($key,$val) = each($conversions)) { @@ -223,6 +223,6 @@ while (list($key,$val) = each($conversions)) { $o .= ''; $o .= ''; - + return $o; } diff --git a/curweather/curweather.php b/curweather/curweather.php index 6197c9617..7b8b89e3d 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -1,6 +1,6 @@ @@ -47,7 +47,7 @@ function getWeather( $loc, $units='metric', $lang='en', $appid='', $cachetime=0) } else { $desc = (string)$res->weather['value'].', '.(string)$res->clouds['name']; } - $r = array( + $r = [ 'city'=> (string) $res->city['name'][0], 'country' => (string) $res->city->country[0], 'lat' => (string) $res->city->coord['lat'], @@ -59,7 +59,7 @@ function getWeather( $loc, $units='metric', $lang='en', $appid='', $cachetime=0) 'wind' => (string)$res->wind->speed['name'].' ('.(string)$res->wind->speed['value'].$wunit.')', 'update' => (string)$res->lastupdate['value'], 'icon' => (string)$res->weather['icon'] - ); + ]; PConfig::set(local_user(), 'curweather', 'last', $now->getTimestamp()); Cache::set('curweather'.md5($url), serialize($r), CACHE_HOUR); return $r; @@ -111,7 +111,7 @@ function curweather_network_mod_init(&$fk_app,&$b) { if ($ok) { $t = get_markup_template("widget.tpl", "addon/curweather/" ); - $curweather = replace_macros ($t, array( + $curweather = replace_macros ($t, [ '$title' => t("Current Weather"), '$icon' => proxy_url('http://openweathermap.org/img/w/'.$res['icon'].'.png'), '$city' => $res['city'], @@ -119,20 +119,20 @@ function curweather_network_mod_init(&$fk_app,&$b) { '$lat' => $res['lat'], '$description' => $res['descripion'], '$temp' => $res['temperature'], - '$relhumidity' => array('caption'=>t('Relative Humidity'), 'val'=>$res['humidity']), - '$pressure' => array('caption'=>t('Pressure'), 'val'=>$res['pressure']), - '$wind' => array('caption'=>t('Wind'), 'val'=> $res['wind']), + '$relhumidity' => ['caption'=>t('Relative Humidity'), 'val'=>$res['humidity']], + '$pressure' => ['caption'=>t('Pressure'), 'val'=>$res['pressure']], + '$wind' => ['caption'=>t('Wind'), 'val'=> $res['wind']], '$lastupdate' => t('Last Updated').': '.$res['update'].'UTC', '$databy' => t('Data by'), '$showonmap' => t('Show on map') - )); + ]); } else { $t = get_markup_template('widget-error.tpl', 'addon/curweather/'); - $curweather = replace_macros( $t, array( + $curweather = replace_macros( $t, [ '$problem' => t('There was a problem accessing the weather data. But have a look'), '$rpt' => $rpt, '$atOWM' => t('at OpenWeatherMap') - )); + ]); } $fk_app->page['aside'] = $curweather.$fk_app->page['aside']; @@ -161,25 +161,25 @@ function curweather_plugin_settings(&$a,&$s) { $curweather_loc = PConfig::get(local_user(), 'curweather', 'curweather_loc'); $curweather_units = PConfig::get(local_user(), 'curweather', 'curweather_units'); $appid = Config::get('curweather','appid'); - if ($appid=="") { + if ($appid=="") { $noappidtext = t('No APPID found, please contact your admin to obtain one.'); } else { $noappidtext = ''; } $enable = intval(PConfig::get(local_user(),'curweather','curweather_enable')); $enable_checked = (($enable) ? ' checked="checked" ' : ''); - + // load template and replace the macros $t = get_markup_template("settings.tpl", "addon/curweather/" ); - $s = replace_macros ($t, array( - '$submit' => t('Save Settings'), + $s = replace_macros ($t, [ + '$submit' => t('Save Settings'), '$header' => t('Current Weather').' '.t('Settings'), '$noappidtext' => $noappidtext, '$info' => t('Enter either the name of your location or the zip code.'), - '$curweather_loc' => array( 'curweather_loc', t('Your Location'), $curweather_loc, t('Identifier of your location (name or zip code), e.g. Berlin,DE or 14476,DE.') ), - '$curweather_units' => array( 'curweather_units', t('Units'), $curweather_units, t('select if the temperature should be displayed in °C or °F'), array('metric'=>'°C', 'imperial'=>'°F')), - '$enabled' => array( 'curweather_enable', t('Show weather data'), $enable, '') - )); + '$curweather_loc' => [ 'curweather_loc', t('Your Location'), $curweather_loc, t('Identifier of your location (name or zip code), e.g. Berlin,DE or 14476,DE.') ], + '$curweather_units' => [ 'curweather_units', t('Units'), $curweather_units, t('select if the temperature should be displayed in °C or °F'), ['metric'=>'°C', 'imperial'=>'°F']], + '$enabled' => [ 'curweather_enable', t('Show weather data'), $enable, ''] + ]); return; } @@ -200,9 +200,9 @@ function curweather_plugin_admin (&$a, &$o) { $appid = Config::get('curweather','appid'); $cachetime = Config::get('curweather','cachetime'); $t = get_markup_template("admin.tpl", "addon/curweather/" ); - $o = replace_macros ($t, array( + $o = replace_macros ($t, [ '$submit' => t('Save Settings'), - '$cachetime' => array('cachetime', t('Caching Interval'), $cachetime, t('For how long should the weather data be cached? Choose according your OpenWeatherMap account type.'), array('0'=>t('no cache'), '300'=>'5 '.t('minutes'), '900'=>'15 '.t('minutes'), '1800'=>'30 '.t('minutes'), '3600'=>'60 '.t('minutes'))), - '$appid' => array('appid', t('Your APPID'), $appid, t('Your API key provided by OpenWeatherMap')) - )); + '$cachetime' => ['cachetime', t('Caching Interval'), $cachetime, t('For how long should the weather data be cached? Choose according your OpenWeatherMap account type.'), ['0'=>t('no cache'), '300'=>'5 '.t('minutes'), '900'=>'15 '.t('minutes'), '1800'=>'30 '.t('minutes'), '3600'=>'60 '.t('minutes')]], + '$appid' => ['appid', t('Your APPID'), $appid, t('Your API key provided by OpenWeatherMap')] + ]); } diff --git a/dav/friendica/calendar.friendica.fnk.php b/dav/friendica/calendar.friendica.fnk.php index 60dd9c6bd..b5d9082e2 100644 --- a/dav/friendica/calendar.friendica.fnk.php +++ b/dav/friendica/calendar.friendica.fnk.php @@ -16,13 +16,13 @@ define("CALDAV_NAMESPACE_PRIVATE", 1); define("CALDAV_FRIENDICA_MINE", "friendica-mine"); define("CALDAV_FRIENDICA_CONTACTS", "friendica-contacts"); -$GLOBALS["CALDAV_PRIVATE_SYSTEM_CALENDARS"] = array(CALDAV_FRIENDICA_MINE, CALDAV_FRIENDICA_CONTACTS); -$GLOBALS["CALDAV_PRIVATE_SYSTEM_BACKENDS"] = array("Sabre_CalDAV_Backend_Friendica"); +$GLOBALS["CALDAV_PRIVATE_SYSTEM_CALENDARS"] = [CALDAV_FRIENDICA_MINE, CALDAV_FRIENDICA_CONTACTS]; +$GLOBALS["CALDAV_PRIVATE_SYSTEM_BACKENDS"] = ["Sabre_CalDAV_Backend_Friendica"]; define("CARDDAV_NAMESPACE_PRIVATE", 1); define("CARDDAV_FRIENDICA_CONTACT", "friendica"); -$GLOBALS["CARDDAV_PRIVATE_SYSTEM_ADDRESSBOOKS"] = array(CARDDAV_FRIENDICA_CONTACT); -$GLOBALS["CARDDAV_PRIVATE_SYSTEM_BACKENDS"] = array("Sabre_CardDAV_Backend_Friendica"); +$GLOBALS["CARDDAV_PRIVATE_SYSTEM_ADDRESSBOOKS"] = [CARDDAV_FRIENDICA_CONTACT]; +$GLOBALS["CARDDAV_PRIVATE_SYSTEM_BACKENDS"] = ["Sabre_CardDAV_Backend_Friendica"]; $GLOBALS["CALDAV_ACL_PLUGIN_CLASS"] = "Sabre_DAVACL_Plugin_Friendica"; @@ -106,7 +106,7 @@ function dav_compat_principal2namespace($principalUri = "") if (strpos($principalUri, "principals/users/") !== 0) return null; $username = substr($principalUri, strlen("principals/users/")); - return array("namespace" => CALDAV_NAMESPACE_PRIVATE, "namespace_id" => dav_compat_username2id($username)); + return ["namespace" => CALDAV_NAMESPACE_PRIVATE, "namespace_id" => dav_compat_username2id($username)]; } @@ -200,13 +200,13 @@ function wdcal_calendar_factory_by_id($calendar_id) */ function wdcal_create_std_calendars_get_statements($user_id, $withcheck = true) { - $stms = array(); + $stms = []; $a = get_app(); - $uris = array( + $uris = [ 'private' => t("Private Calendar"), CALDAV_FRIENDICA_MINE => t("Friendica Events: Mine"), CALDAV_FRIENDICA_CONTACTS => t("Friendica Events: Contacts"), - ); + ]; foreach ($uris as $uri => $name) { $cals = q("SELECT * FROM %s%scalendars WHERE `namespace` = %d AND `namespace_id` = %d AND `uri` = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, IntVal($user_id), dbesc($uri)); @@ -242,12 +242,12 @@ function wdcal_create_std_calendars() */ function wdcal_create_std_addressbooks_get_statements($user_id, $withcheck = true) { - $stms = array(); + $stms = []; $a = get_app(); - $uris = array( + $uris = [ 'private' => t("Private Addresses"), CARDDAV_FRIENDICA_CONTACT => t("Friendica Contacts"), - ); + ]; foreach ($uris as $uri => $name) { $cals = q("SELECT * FROM %s%saddressbooks WHERE `namespace` = %d AND `namespace_id` = %d AND `uri` = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, IntVal($user_id), dbesc($uri)); diff --git a/dav/friendica/database-init.inc.php b/dav/friendica/database-init.inc.php index e172b44dc..d8ef96ebf 100644 --- a/dav/friendica/database-init.inc.php +++ b/dav/friendica/database-init.inc.php @@ -7,7 +7,7 @@ */ function dav_get_update_statements($from_version) { - $stms = array(); + $stms = []; if ($from_version == 1) { $stms[] = "ALTER TABLE `dav_calendarobjects` @@ -30,7 +30,7 @@ function dav_get_update_statements($from_version) `dav_locks` , `dav_notifications` ;"; - $stms = array_merge($stms, dav_get_create_statements(array("dav_calendarobjects"))); + $stms = array_merge($stms, dav_get_create_statements(["dav_calendarobjects"])); $user_ids = q("SELECT DISTINCT `uid` FROM %s%scalendars", CALDAV_SQL_DB, CALDAV_SQL_PREFIX); foreach ($user_ids as $user) $stms = array_merge($stms, wdcal_create_std_calendars_get_statements($user["uid"], false)); @@ -43,7 +43,7 @@ function dav_get_update_statements($from_version) } - if (in_array($from_version, array(1, 2))) { + if (in_array($from_version, [1, 2])) { $stms[] = "CREATE TABLE IF NOT EXISTS `dav_addressbooks` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `namespace` mediumint(9) NOT NULL, @@ -80,9 +80,9 @@ function dav_get_update_statements($from_version) * @param array $except * @return array */ -function dav_get_create_statements($except = array()) +function dav_get_create_statements($except = []) { - $arr = array(); + $arr = []; if (!in_array("dav_caldav_log", $except)) $arr[] = "CREATE TABLE IF NOT EXISTS `dav_caldav_log` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -240,7 +240,7 @@ function dav_check_tables() function dav_create_tables() { $stms = dav_get_create_statements(); - $errors = array(); + $errors = []; foreach ($stms as $st) { // @TODO Friendica-dependent dba::e($st); @@ -258,10 +258,10 @@ function dav_create_tables() function dav_upgrade_tables() { $ver = dav_check_tables(); - if (!in_array($ver, array(1, 2))) return array("Unknown error"); + if (!in_array($ver, [1, 2])) return ["Unknown error"]; $stms = dav_get_update_statements($ver); - $errors = array(); + $errors = []; foreach ($stms as $st) { // @TODO Friendica-dependent dba::e($st); diff --git a/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php b/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php index 0afc03bd7..169c5bcb5 100644 --- a/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php +++ b/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php @@ -124,7 +124,7 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual $summary = (($row["summary"]) ? $row["summary"] : substr(preg_replace("/\[[^\]]*\]/", "", $row["desc"]), 0, 100)); - return array( + return [ "jq_id" => $row["id"], "ev_id" => $row["id"], "summary" => escape_tags($summary), @@ -142,7 +142,7 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual "url_detail" => $base_path . "/events/event/" . $row["id"], "url_edit" => "", "special_type" => ($row["type"] == "birthday" ? "birthday" : ""), - ); + ]; } @@ -179,7 +179,7 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual if (is_numeric($date_to)) $sql_where .= " AND `start` <= '" . date("Y-m-d H:i:s", $date_to) . "'"; else $sql_where .= " AND `start` <= '" . dbesc($date_to) . "'"; } - $ret = array(); + $ret = []; $r = q("SELECT * FROM `event` WHERE `uid` = %d " . $sql_where . " ORDER BY `start`", IntVal($calendar["namespace_id"])); @@ -214,21 +214,21 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual public function getCalendarsForUser($principalUri) { $n = dav_compat_principal2namespace($principalUri); - if ($n["namespace"] != $this->getNamespace()) return array(); + if ($n["namespace"] != $this->getNamespace()) return []; $cals = q("SELECT * FROM %s%scalendars WHERE `namespace` = %d AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $this->getNamespace(), IntVal($n["namespace_id"])); - $ret = array(); + $ret = []; foreach ($cals as $cal) { if (!in_array($cal["uri"], $GLOBALS["CALDAV_PRIVATE_SYSTEM_CALENDARS"])) continue; - $dat = array( + $dat = [ "id" => $cal["id"], "uri" => $cal["uri"], "principaluri" => $principalUri, '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => $cal['ctag'] ? $cal['ctag'] : '0', - '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array("VEVENT")), + '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(["VEVENT"]), "calendar_class" => "Sabre_CalDAV_Calendar_Virtual", - ); + ]; foreach ($this->propertyMap as $key=> $field) $dat[$key] = $cal[$field]; $ret[] = $dat; diff --git a/dav/friendica/dav_carddav_backend_virtual_friendica.inc.php b/dav/friendica/dav_carddav_backend_virtual_friendica.inc.php index 3a06d042b..8d51022d2 100644 --- a/dav/friendica/dav_carddav_backend_virtual_friendica.inc.php +++ b/dav/friendica/dav_carddav_backend_virtual_friendica.inc.php @@ -46,13 +46,13 @@ class Sabre_CardDAV_Backend_Friendica extends Sabre_CardDAV_Backend_Virtual { $uid = dav_compat_principal2uid($principalUri); - $addressBooks = array(); + $addressBooks = []; $books = q("SELECT id, ctag FROM %s%saddressbooks WHERE `namespace` = %d AND `namespace_id` = %d AND `uri` = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CARDDAV_NAMESPACE_PRIVATE, IntVal($uid), dbesc(CARDDAV_FRIENDICA_CONTACT)); $ctag = $books[0]["ctag"]; - $addressBooks[] = array( + $addressBooks[] = [ 'id' => $books[0]["id"], 'uri' => "friendica", 'principaluri' => $principalUri, @@ -61,7 +61,7 @@ class Sabre_CardDAV_Backend_Friendica extends Sabre_CardDAV_Backend_Virtual '{http://calendarserver.org/ns/}getctag' => $ctag, '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' => new Sabre_CardDAV_Property_SupportedAddressData(), - ); + ]; return $addressBooks; @@ -76,7 +76,7 @@ class Sabre_CardDAV_Backend_Friendica extends Sabre_CardDAV_Backend_Virtual { $name = explode(" ", $contact["name"]); $first_name = $last_name = ""; - $middle_name = array(); + $middle_name = []; $num = count($name); for ($i = 0; $i < $num && $first_name == ""; $i++) if ($name[$i] != "") { $first_name = $name[$i]; @@ -114,14 +114,14 @@ class Sabre_CardDAV_Backend_Friendica extends Sabre_CardDAV_Backend_Virtual } $vcard = vcard_source_compile($vcarddata); - return array( + return [ "id" => $contact["id"], "carddata" => $vcard, "uri" => $contact["id"] . ".vcf", "lastmodified" => wdcal_mySql2PhpTime($vcarddata->last_update), "etag" => md5($vcard), "size" => strlen($vcard), - ); + ]; } diff --git a/dav/friendica/dav_friendica_auth.inc.php b/dav/friendica/dav_friendica_auth.inc.php index 9b42ab8a8..88b8cf01a 100644 --- a/dav/friendica/dav_friendica_auth.inc.php +++ b/dav/friendica/dav_friendica_auth.inc.php @@ -26,7 +26,7 @@ class Sabre_DAV_Auth_Backend_Std extends Sabre_DAV_Auth_Backend_AbstractBasic */ public function getUsers() { - return array($this->currentUser); + return [$this->currentUser]; } /** diff --git a/dav/friendica/dav_friendica_principal.inc.php b/dav/friendica/dav_friendica_principal.inc.php index 780bcd24b..d23619ec1 100644 --- a/dav/friendica/dav_friendica_principal.inc.php +++ b/dav/friendica/dav_friendica_principal.inc.php @@ -61,16 +61,16 @@ class Sabre_DAVACL_PrincipalBackend_Std implements Sabre_DAVACL_IPrincipalBacken { // This backend only support principals in one collection - if ($prefixPath !== $this->prefix) return array(); + if ($prefixPath !== $this->prefix) return []; - $users = array(); + $users = []; $r = q("SELECT `nickname` FROM `user` WHERE `nickname` = '%s'", escape_tags($this->authBackend->getCurrentUser()) ); foreach ($r as $t) { - $users[] = array( + $users[] = [ 'uri' => $this->prefix . '/' . strtolower($t['nickname']), '{DAV:}displayname' => $t['nickname'], - ); + ]; } return $users; @@ -94,24 +94,24 @@ class Sabre_DAVACL_PrincipalBackend_Std implements Sabre_DAVACL_IPrincipalBacken if ($prefixPath !== $this->prefix) return null; $r = q("SELECT `nickname` FROM `user` WHERE `nickname` = '%s'", escape_tags($userName) ); - if (count($r) == 0) return array(); + if (count($r) == 0) return []; - return array( + return [ 'uri' => $this->prefix . '/' . strtolower($r[0]['nickname']), '{DAV:}displayname' => $r[0]['nickname'], - ); + ]; } function getGroupMemberSet($principal) { - return array(); + return []; } function getGroupMembership($principal) { - return array(); + return []; } diff --git a/dav/friendica/layout.fnk.php b/dav/friendica/layout.fnk.php index 6e49aa92b..f384c50c3 100644 --- a/dav/friendica/layout.fnk.php +++ b/dav/friendica/layout.fnk.php @@ -91,7 +91,7 @@ function wdcal_import_user_ics($calendar_id) { /** @var Sabre\VObject\Component\VCalendar $vObject */ $vObject = Sabre\VObject\Reader::read($text); $comp = $vObject->getComponents(); - $imported = array(); + $imported = []; foreach ($comp as $c) try { /** @var Sabre\VObject\Component\VEvent $c */ $uid = $c->__get("UID")->value; @@ -171,18 +171,18 @@ function wdcal_import_user_ics($calendar_id) { * @param bool $show_nav * @return string */ -function wdcal_printCalendar($calendars, $calendars_selected, $data_feed_url, $view = "week", $theme = 0, $height_diff = 175, $readonly = false, $curr_day = "", $add_params = array(), $show_nav = true) +function wdcal_printCalendar($calendars, $calendars_selected, $data_feed_url, $view = "week", $theme = 0, $height_diff = 175, $readonly = false, $curr_day = "", $add_params = [], $show_nav = true) { $a = get_app(); $localization = wdcal_local::getInstanceByUser($a->user["uid"]); if (count($calendars_selected) == 0) foreach ($calendars as $c) { - $prop = $c->getProperties(array("id")); + $prop = $c->getProperties(["id"]); $calendars_selected[] = $prop["id"]; } - $opts = array( + $opts = [ "view" => $view, "theme" => $theme, "readonly" => $readonly, @@ -194,7 +194,7 @@ function wdcal_printCalendar($calendars, $calendars_selected, $data_feed_url, $v "date_format_dm3" => $localization->dateformat_js_dm3(), "date_format_full" => $localization->dateformat_datepicker_js(), "baseurl" => $a->get_baseurl() . "/dav/wdcal/", - ); + ]; $x = ' '; - + $upload_msg = t('Upload a file'); $drop_msg = t('Drop files here to upload'); $cancel = t('Cancel'); @@ -50,16 +50,16 @@ function js_upload_form(&$a,&$b) { $maximagesize = intval(Config::get('system','maximagesize')); $b['addon_text'] .= <<< EOT - -
-
'; @@ -399,7 +399,7 @@ function twitter_action(App $a, $uid, $pid, $action) $cb->setConsumerKey($ckey, $csecret); $cb->setToken($otoken, $osecret); - $post = array('id' => $pid); + $post = ['id' => $pid]; logger("twitter_action '" . $action . "' ID: " . $pid . " data: " . print_r($post, true), LOGGER_DATA); @@ -557,7 +557,7 @@ function twitter_post_hook(App $a, &$b) $cb->setConsumerKey($ckey, $csecret); $cb->setToken($otoken, $osecret); - $post = array('status' => $msg, 'media[]' => $tempfile); + $post = ['status' => $msg, 'media[]' => $tempfile]; if ($iscomment) { $post["in_reply_to_status_id"] = substr($orig_post["uri"], 9); @@ -604,7 +604,7 @@ function twitter_post_hook(App $a, &$b) } // ----------------- $url = 'statuses/update'; - $post = array('status' => $msg, 'weighted_character_count' => 'true'); + $post = ['status' => $msg, 'weighted_character_count' => 'true']; if ($iscomment) { $post["in_reply_to_status_id"] = substr($orig_post["uri"], 9); @@ -625,7 +625,7 @@ function twitter_post_hook(App $a, &$b) $a->contact = $r[0]["id"]; } - $s = serialize(array('url' => $url, 'item' => $b['id'], 'post' => $post)); + $s = serialize(['url' => $url, 'item' => $b['id'], 'post' => $post]); require_once 'include/queue_fn.php'; add_to_queue($a->contact, NETWORK_TWITTER, $s); notice(t('Twitter post failed. Queued for retry.') . EOL); @@ -653,12 +653,12 @@ function twitter_plugin_admin(App $a, &$o) { $t = get_markup_template("admin.tpl", "addon/twitter/"); - $o = replace_macros($t, array( + $o = replace_macros($t, [ '$submit' => t('Save Settings'), // name, label, value, help, [extra values] - '$consumerkey' => array('consumerkey', t('Consumer key'), Config::get('twitter', 'consumerkey'), ''), - '$consumersecret' => array('consumersecret', t('Consumer secret'), Config::get('twitter', 'consumersecret'), ''), - )); + '$consumerkey' => ['consumerkey', t('Consumer key'), Config::get('twitter', 'consumerkey'), ''], + '$consumersecret' => ['consumersecret', t('Consumer secret'), Config::get('twitter', 'consumersecret'), ''], + ]); } function twitter_cron(App $a, $b) @@ -737,9 +737,9 @@ function twitter_expire(App $a, $b) } if (method_exists('dba', 'delete')) { - $r = dba::select('item', array('id'), array('deleted' => true, 'network' => NETWORK_TWITTER)); + $r = dba::select('item', ['id'], ['deleted' => true, 'network' => NETWORK_TWITTER]); while ($row = dba::fetch($r)) { - dba::delete('item', array('id' => $row['id'])); + dba::delete('item', ['id' => $row['id']]); } dba::close($r); } else { @@ -825,13 +825,13 @@ function twitter_do_mirrorpost(App $a, $uid, $post) if (is_object($post->retweeted_status)) { // We don't support nested shares, so we mustn't show quotes as shares on retweets - $item = twitter_createpost($a, $uid, $post->retweeted_status, array('id' => 0), false, false, true); + $item = twitter_createpost($a, $uid, $post->retweeted_status, ['id' => 0], false, false, true); $datarray['body'] = "\n" . share_header($item['author-name'], $item['author-link'], $item['author-avatar'], "", $item['created'], $item['plink']); $datarray['body'] .= $item['body'] . '[/share]'; } else { - $item = twitter_createpost($a, $uid, $post, array('id' => 0), false, false, false); + $item = twitter_createpost($a, $uid, $post, ['id' => 0], false, false, false); $datarray['body'] = $item['body']; } @@ -873,7 +873,7 @@ function twitter_fetchtimeline(App $a, $uid) require_once 'library/twitteroauth.php'; $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret); - $parameters = array("exclude_replies" => true, "trim_user" => false, "contributor_details" => true, "include_rts" => true, "tweet_mode" => "extended"); + $parameters = ["exclude_replies" => true, "trim_user" => false, "contributor_details" => true, "include_rts" => true, "tweet_mode" => "extended"]; $first_time = ($lastid == ""); @@ -1004,11 +1004,11 @@ function twitter_fetch_contact($uid, $contact, $create_user) $avatar = twitter_fix_avatar($contact->profile_image_url_https); - GContact::update(array("url" => "https://twitter.com/" . $contact->screen_name, + GContact::update(["url" => "https://twitter.com/" . $contact->screen_name, "network" => NETWORK_TWITTER, "photo" => $avatar, "hide" => true, "name" => $contact->name, "nick" => $contact->screen_name, "location" => $contact->location, "about" => $contact->description, - "addr" => $contact->screen_name . "@twitter.com", "generation" => 2)); + "addr" => $contact->screen_name . "@twitter.com", "generation" => 2]); $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1", intval($uid), dbesc("twitter::" . $contact->id_str)); @@ -1149,7 +1149,7 @@ function twitter_fetchuser(App $a, $uid, $screen_name = "", $user_id = "") return; } - $parameters = array(); + $parameters = []; if ($screen_name != "") { $parameters["screen_name"] = $screen_name; @@ -1261,10 +1261,10 @@ function twitter_expand_entities(App $a, $body, $item, $no_tags = false, $pictur } if ($no_tags) { - return array("body" => $body, "tags" => "", "plain" => $plain); + return ["body" => $body, "tags" => "", "plain" => $plain]; } - $tags_arr = array(); + $tags_arr = []; foreach ($item->entities->hashtags AS $hashtag) { $url = "#[url=" . $a->get_baseurl() . "/search?tag=" . rawurlencode($hashtag->text) . "]" . $hashtag->text . "[/url]"; @@ -1319,7 +1319,7 @@ function twitter_expand_entities(App $a, $body, $item, $no_tags = false, $pictur $tags = implode($tags_arr, ","); } - return array("body" => $body, "tags" => $tags, "plain" => $plain); + return ["body" => $body, "tags" => $tags, "plain" => $plain]; } /** @@ -1351,7 +1351,7 @@ function twitter_media_entities($post, &$postarray) } // This is a pure media post, first search for all media urls - $media = array(); + $media = []; foreach ($post->extended_entities->media AS $medium) { switch ($medium->type) { case 'photo': @@ -1388,7 +1388,7 @@ function twitter_media_entities($post, &$postarray) function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_existing_contact, $noquote) { - $postarray = array(); + $postarray = []; $postarray['network'] = NETWORK_TWITTER; $postarray['gravity'] = 0; $postarray['uid'] = $uid; @@ -1404,7 +1404,7 @@ function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_exis if (count($r)) { logger("Item with extid " . $postarray['uri'] . " found.", LOGGER_DEBUG); - return array(); + return []; } $contactid = 0; @@ -1453,7 +1453,7 @@ function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_exis $postarray['owner-avatar'] = $r[0]["photo"]; } else { logger("No self contact for user " . $uid, LOGGER_DEBUG); - return array(); + return []; } } // Don't create accounts of people who just comment something @@ -1475,7 +1475,7 @@ function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_exis $contactid = $self['id']; } elseif ($contactid <= 0) { logger("Contact ID is zero or less than zero.", LOGGER_DEBUG); - return array(); + return []; } $postarray['contact-id'] = $contactid; @@ -1599,7 +1599,7 @@ function twitter_checknotification(App $a, $uid, $own_id, $top_item, $postarray) $conv_parent = $conv['parent']; - notification(array( + notification([ 'type' => NOTIFY_COMMENT, 'notify_flags' => $user[0]['notify-flags'], 'language' => $user[0]['language'], @@ -1614,7 +1614,7 @@ function twitter_checknotification(App $a, $uid, $own_id, $top_item, $postarray) 'verb' => ACTIVITY_POST, 'otype' => 'item', 'parent' => $conv_parent, - )); + ]); // only send one notification break; @@ -1626,10 +1626,10 @@ function twitter_fetchparentposts(App $a, $uid, $post, $connection, $self, $own_ { logger("twitter_fetchparentposts: Fetching for user " . $uid . " and post " . $post->id_str, LOGGER_DEBUG); - $posts = array(); + $posts = []; while ($post->in_reply_to_status_id_str != "") { - $parameters = array("trim_user" => false, "tweet_mode" => "extended", "id" => $post->in_reply_to_status_id_str); + $parameters = ["trim_user" => false, "tweet_mode" => "extended", "id" => $post->in_reply_to_status_id_str]; $post = $connection->get('statuses/show', $parameters); @@ -1725,7 +1725,7 @@ function twitter_fetchhometimeline(App $a, $uid) return; } - $parameters = array("exclude_replies" => false, "trim_user" => false, "contributor_details" => true, "include_rts" => true, "tweet_mode" => "extended"); + $parameters = ["exclude_replies" => false, "trim_user" => false, "contributor_details" => true, "include_rts" => true, "tweet_mode" => "extended"]; //$parameters["count"] = 200; // Fetching timeline $lastid = PConfig::get($uid, 'twitter', 'lasthometimelineid'); @@ -1857,7 +1857,7 @@ function twitter_fetchhometimeline(App $a, $uid) if (($item != 0) && !function_exists("check_item_notification")) { require_once 'include/enotify.php'; - notification(array( + notification([ 'type' => NOTIFY_TAGSELF, 'notify_flags' => $u[0]['notify-flags'], 'language' => $u[0]['language'], @@ -1872,7 +1872,7 @@ function twitter_fetchhometimeline(App $a, $uid) 'verb' => ACTIVITY_TAG, 'otype' => 'item', 'parent' => $parent_id - )); + ]); } } } diff --git a/viewsrc/viewsrc.php b/viewsrc/viewsrc.php index 687d92537..623ed89d8 100644 --- a/viewsrc/viewsrc.php +++ b/viewsrc/viewsrc.php @@ -6,7 +6,7 @@ * Description: Add "View Source" link to item context * Version: 1.0 * Author: Mike Macgirvin - * + * */ function viewsrc_install() { @@ -49,7 +49,7 @@ function viewsrc_item_photo_menu(&$a,&$b) { } else $item_id = $b['item']['id']; - $b['menu'] = array_merge( array( t('View Source') => $a->get_baseurl() . '/viewsrc/'. $item_id), $b['menu']); + $b['menu'] = array_merge( [ t('View Source') => $a->get_baseurl() . '/viewsrc/'. $item_id], $b['menu']); //if((! local_user()) || (local_user() != $b['item']['uid'])) // return; diff --git a/webrtc/webrtc.php b/webrtc/webrtc.php index 4ea17f471..1588847df 100644 --- a/webrtc/webrtc.php +++ b/webrtc/webrtc.php @@ -24,10 +24,10 @@ function webrtc_app_menu($a,&$b) { function webrtc_plugin_admin (&$a, &$o) { $t = get_markup_template( "admin.tpl", "addon/webrtc/" ); - $o = replace_macros( $t, array( + $o = replace_macros( $t, [ '$submit' => t('Save Settings'), - '$webrtcurl' => array('webrtcurl', t('WebRTC Base URL'), Config::get('webrtc','webrtcurl' ), t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .')), - )); + '$webrtcurl' => ['webrtcurl', t('WebRTC Base URL'), Config::get('webrtc','webrtcurl' ), t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .')], + ]); } function webrtc_plugin_admin_post (&$a) { $url = ((x($_POST, 'webrtcurl')) ? notags(trim($_POST['webrtcurl'])) : ''); diff --git a/widgets/widget_friendheader.php b/widgets/widget_friendheader.php index 20a84e253..f9a8aceca 100644 --- a/widgets/widget_friendheader.php +++ b/widgets/widget_friendheader.php @@ -8,17 +8,17 @@ function friendheader_widget_help() { } function friendheader_widget_args(){ - return Array(); + return []; } function friendheader_widget_size(){ - return Array('780px','140px'); + return ['780px','140px']; } function friendheader_widget_content(&$a, $conf){ - $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` + $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid` WHERE `user`.`uid` = %s AND `profile`.`is-default` = 1 LIMIT 1", intval($conf['uid']) @@ -34,10 +34,10 @@ function friendheader_widget_content(&$a, $conf){ .allcontact-link { float: right; margin: 0px; } .contact-block-content { clear:both; } .contact-block-div { display: block !important; float: left!important; width: 50px!important; height: 50px!important; margin: 2px!important;} - + "; $o .= _abs_url(contact_block()); $o .= "profile['nickname']."' target=new>". t('Get added to this list!') .""; - + return $o; } diff --git a/widgets/widget_friends.php b/widgets/widget_friends.php index 195667e89..25e201801 100644 --- a/widgets/widget_friends.php +++ b/widgets/widget_friends.php @@ -8,17 +8,17 @@ function friends_widget_help() { } function friends_widget_args(){ - return Array(); + return []; } function friends_widget_size(){ - return Array('100%','200px'); + return ['100%','200px']; } function friends_widget_content(&$a, $conf){ - $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` + $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid` WHERE `user`.`uid` = %s AND `profile`.`is-default` = 1 LIMIT 1", intval($conf['uid']) @@ -34,7 +34,7 @@ function friends_widget_content(&$a, $conf){ .allcontact-link { float: right; margin: 0px; } .contact-block-content { clear:both; } .contact-block-div { display: block !important; float: left!important; width: 50px!important; height: 50px!important; margin: 2px!important;} - + "; $o .= _abs_url(contact_block()); $o .= "profile['nickname']."'>". t('Connect on Friendica!') .""; diff --git a/widgets/widget_like.php b/widgets/widget_like.php index 8f356da97..a67f0bd8f 100644 --- a/widgets/widget_like.php +++ b/widgets/widget_like.php @@ -8,30 +8,30 @@ function like_widget_help() { } function like_widget_args(){ - return Array("KEY"); + return ["KEY"]; } function like_widget_size(){ - return Array('60px','20px'); + return ['60px','20px']; } function like_widget_content(&$a, $conf){ $args = explode(",",$_GET['a']); - - + + $baseq="SELECT COUNT(`item`.`id`) as `c`, `p`.`id` - FROM `item`, - (SELECT `i`.`id` FROM `item` as `i` WHERE + FROM `item`, + (SELECT `i`.`id` FROM `item` as `i` WHERE `i`.`visible` = 1 AND `i`.`deleted` = 0 - AND (( `i`.`wall` = 1 AND `i`.`allow_cid` = '' - AND `i`.`allow_gid` = '' - AND `i`.`deny_cid` = '' - AND `i`.`deny_gid` = '' ) + AND (( `i`.`wall` = 1 AND `i`.`allow_cid` = '' + AND `i`.`allow_gid` = '' + AND `i`.`deny_cid` = '' + AND `i`.`deny_gid` = '' ) OR `i`.`uid` = %d ) AND `i`.`body` LIKE '%%%s%%' LIMIT 1) as `p` WHERE `item`.`parent` = `p`.`id` "; - + // count likes $r = q( $baseq . "AND `item`.`verb` = 'http://activitystrea.ms/schema/1.0/like'", intval($conf['uid']), @@ -39,30 +39,30 @@ function like_widget_content(&$a, $conf){ ); $likes = $r[0]['c']; $iid = $r[0]['id']; - + // count dislikes $r = q( $baseq . "AND `item`.`verb` = 'http://purl.org/macgirvin/dfrn/1.0/dislike'", intval($conf['uid']), dbesc($args[0]) ); $dislikes = $r[0]['c']; - - + + require_once("include/conversation.php"); - + $o = ""; - + # $t = file_get_contents( dirname(__file__). "/widget_like.tpl" ); $t = get_markup_template("widget_like.tpl", "addon/widgets/"); - $o .= replace_macros($t, array( + $o .= replace_macros($t, [ '$like' => $likes, '$strlike' => sprintf( tt("%d person likes this", "%d people like this", $likes), $likes), - + '$dislike' => $dislikes, '$strdislike'=> sprintf( tt("%d person doesn't like this", "%d people don't like this", $dislikes), $dislikes), - + '$baseurl' => $a->get_baseurl(), - )); - + ]); + return $o; } diff --git a/widgets/widgets.php b/widgets/widgets.php index a232d9e6c..502278a27 100644 --- a/widgets/widgets.php +++ b/widgets/widgets.php @@ -9,12 +9,12 @@ use Friendica\Core\PConfig; function widgets_install() { - register_hook('plugin_settings', 'addon/widgets/widgets.php', 'widgets_settings'); + register_hook('plugin_settings', 'addon/widgets/widgets.php', 'widgets_settings'); register_hook('plugin_settings_post', 'addon/widgets/widgets.php', 'widgets_settings_post'); logger("installed widgets"); } function widgets_uninstall() { - unregister_hook('plugin_settings', 'addon/widgets/widgets.php', 'widgets_settings'); + unregister_hook('plugin_settings', 'addon/widgets/widgets.php', 'widgets_settings'); unregister_hook('plugin_settings_post', 'addon/widgets/widgets.php', 'widgets_settings_post'); } @@ -24,19 +24,19 @@ function widgets_settings_post(){ return; if (isset($_POST['widgets-submit'])){ PConfig::delete(local_user(), 'widgets', 'key'); - + } } function widgets_settings(&$a,&$o) { if(! local_user()) - return; - - + return; + + $key = PConfig::get(local_user(), 'widgets', 'key' ); if ($key=='') { $key = mt_rand(); PConfig::set(local_user(), 'widgets', 'key', $key); } - $widgets = array(); + $widgets = []; $d = dir(dirname(__file__)); while(false !== ($f = $d->read())) { if(substr($f,0,7)=="widget_") { @@ -44,17 +44,17 @@ function widgets_settings(&$a,&$o) { $w=$m[1]; if ($w!=""){ require_once($f); - $widgets[] = array($w, call_user_func($w."_widget_name")); + $widgets[] = [$w, call_user_func($w."_widget_name")]; } } } - - + + # $t = file_get_contents( dirname(__file__). "/settings.tpl" ); $t = get_markup_template("settings.tpl", "addon/widgets/"); - $o .= replace_macros($t, array( + $o .= replace_macros($t, [ '$submit' => t('Generate new key'), '$baseurl' => $a->get_baseurl(), '$title' => "Widgets", @@ -62,8 +62,8 @@ function widgets_settings(&$a,&$o) { '$key' => $key, '$widgets_h' => t('Widgets available'), '$widgets' => $widgets, - )); - + ]); + } function widgets_module() { @@ -77,7 +77,7 @@ function _abs_url($s){ function _randomAlphaNum($length){ return substr(str_shuffle(str_repeat('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',$length)),0,$length); -} +} function widgets_content(&$a) { @@ -93,12 +93,12 @@ function widgets_content(&$a) { if (!count($r)){ if($a->argv[2]=="cb"){header('HTTP/1.0 400 Bad Request'); killme();} return; - } - $conf = array(); + } + $conf = []; $conf['uid'] = $r[0]['uid']; foreach($r as $e) { $conf[$e['k']]=$e['v']; } - - $o = ""; + + $o = ""; $widgetfile =dirname(__file__)."/widget_".$a->argv[1].".php"; if (file_exists($widgetfile)){ @@ -106,8 +106,8 @@ function widgets_content(&$a) { } else { if($a->argv[2]=="cb"){header('HTTP/1.0 400 Bad Request'); killme();} return; - } - + } + @@ -115,10 +115,10 @@ function widgets_content(&$a) { if ($a->argv[2]=="cb"){ /*header('Access-Control-Allow-Origin: *');*/ $o .= call_user_func($a->argv[1].'_widget_content',$a, $conf); - + } else { - + if (isset($_GET['p']) && local_user()==$conf['uid'] ) { $o .= ""; $o .= "

Preview Widget

"; @@ -131,13 +131,13 @@ function widgets_content(&$a) { } else { header("content-type: application/x-javascript"); } - - - + + + $widget_size = call_user_func($a->argv[1].'_widget_size'); - + $script = file_get_contents(dirname(__file__)."/widgets.js"); - $o .= replace_macros($script, array( + $o .= replace_macros($script, [ '$entrypoint' => $a->get_baseurl()."/widgets/".$a->argv[1]."/cb/", '$key' => $conf['key'], '$widget_id' => 'f9a_'.$a->argv[1]."_"._randomAlphaNum(6), @@ -146,35 +146,35 @@ function widgets_content(&$a) { '$width' => $widget_size[0], '$height' => $widget_size[1], '$type' => $a->argv[1], - )); + ]); + - if (isset($_GET['p'])) { $wargs = call_user_func($a->argv[1].'_widget_args'); $jsargs = implode(",", $wargs); if ($jsargs!='') $jsargs = "&a=".$jsargs.""; - + $o .= "

Copy and paste this code

" - + .htmlspecialchars('') .""; - + return $o; - } - - } - + } + + } + echo $o; killme(); } - + ?> diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index ca615205f..66b23a7cc 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -247,10 +247,10 @@ function send_tile_update($device_url, $image_url, $count, $title, $priority = 1 " " . ""; - $result = send_push($device_url, array( + $result = send_push($device_url, [ 'X-WindowsPhone-Target: token', 'X-NotificationClass: ' . $priority, - ), $msg); + ], $msg); return $result; } @@ -269,10 +269,10 @@ function send_toast($device_url, $title, $message, $priority = 2) "" . ""; - $result = send_push($device_url, array( + $result = send_push($device_url, [ 'X-WindowsPhone-Target: toast', 'X-NotificationClass: ' . $priority, - ), $msg); + ], $msg); return $result; } @@ -284,11 +284,11 @@ function send_push($device_url, $headers, $msg) curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HEADER, true); - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers + array( + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers + [ 'Content-Type: text/xml', 'charset=utf-8', 'Accept: application/*', - ) + ] ); curl_setopt($ch, CURLOPT_POSTFIELDS, $msg); @@ -336,13 +336,13 @@ function windowsphonepush_content(App $a) case "update_settings": $ret = windowsphonepush_updatesettings($a); header("Content-Type: application/json; charset=utf-8"); - echo json_encode(array('status' => $ret)); + echo json_encode(['status' => $ret]); killme(); break; case "update_counterunseen": $ret = windowsphonepush_updatecounterunseen(); header("Content-Type: application/json; charset=utf-8"); - echo json_encode(array('status' => $ret)); + echo json_encode(['status' => $ret]); killme(); break; default: @@ -374,13 +374,13 @@ function windowsphonepush_showsettings() } header("Content-Type: application/json"); - echo json_encode(array('uid' => local_user(), + echo json_encode(['uid' => local_user(), 'enable' => $enable, 'device_url' => $device_url, 'senditemtext' => $senditemtext, 'lastpushid' => $lastpushid, 'counterunseen' => $counterunseen, - 'addonversion' => $addonversion)); + 'addonversion' => $addonversion]); } /* update_settings is used to transfer the device_url from WP device to the Friendica server diff --git a/wppost/wppost.php b/wppost/wppost.php index 323fcef0c..22032c90a 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -233,7 +233,7 @@ function wppost_send(&$a,&$b) { // Is it a link to an aricle, a video or a photo? if (isset($siteinfo["type"])) { - if (in_array($siteinfo["type"], array("link", "audio", "video", "photo"))) { + if (in_array($siteinfo["type"], ["link", "audio", "video", "photo"])) { $postentry = true; } } diff --git a/xmpp/xmpp.php b/xmpp/xmpp.php index d9335483a..ba8c27c7f 100644 --- a/xmpp/xmpp.php +++ b/xmpp/xmpp.php @@ -103,11 +103,11 @@ function xmpp_plugin_admin(App $a, &$o) { $t = get_markup_template("admin.tpl", "addon/xmpp/"); - $o = replace_macros($t, array( + $o = replace_macros($t, [ '$submit' => t('Save Settings'), - '$bosh_proxy' => array('bosh_proxy', t('Jabber BOSH host'), Config::get('xmpp', 'bosh_proxy'), ''), - '$central_userbase' => array('central_userbase', t('Use central userbase'), Config::get('xmpp', 'central_userbase'), t('If enabled, users will automatically login to an ejabberd server that has to be installed on this machine with synchronized credentials via the "auth_ejabberd.php" script.')), - )); + '$bosh_proxy' => ['bosh_proxy', t('Jabber BOSH host'), Config::get('xmpp', 'bosh_proxy'), ''], + '$central_userbase' => ['central_userbase', t('Use central userbase'), Config::get('xmpp', 'central_userbase'), t('If enabled, users will automatically login to an ejabberd server that has to be installed on this machine with synchronized credentials via the "auth_ejabberd.php" script.')], + ]); } function xmpp_plugin_admin_post() @@ -142,7 +142,7 @@ function xmpp_converse(App $a) return; } - if (in_array($a->query_string, array("admin/federation/"))) { + if (in_array($a->query_string, ["admin/federation/"])) { return; } @@ -176,7 +176,7 @@ function xmpp_converse(App $a) return; } - if (in_array($a->argv[0], array("manage", "logout"))) { + if (in_array($a->argv[0], ["manage", "logout"])) { $additional_commands = "converse.user.logout();\n"; } else { $additional_commands = "";