1
0
Fork 0

Rename App Methods

- renamed a lot of App methods to CamelCase
- replaced direct public variables with get-/set-Methods
This commit is contained in:
Philipp Holzer 2018-10-09 19:58:58 +02:00
commit 5a02e39a65
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
94 changed files with 481 additions and 338 deletions

View file

@ -475,8 +475,8 @@ function admin_page_contactblock(App $a)
$total = DBA::count('contact', $condition);
$a->set_pager_total($total);
$a->set_pager_itemspage(30);
$a->setPagerTotal($total);
$a->setPagerItemsPage(30);
$statement = DBA::select('contact', [], $condition, ['limit' => [$a->pager['start'], $a->pager['itemspage']]]);
@ -866,15 +866,15 @@ function admin_page_summary(App $a)
// Legacy config file warning
if (file_exists('.htconfig.php')) {
$showwarning = true;
$warningtext[] = L10n::t('Friendica\'s configuration now is stored in config/local.ini.php, please copy config/local-sample.ini.php and move your config from <code>.htconfig.php</code>. See <a href="%s">the Config help page</a> for help with the transition.', $a->get_baseurl() . '/help/Config');
$warningtext[] = L10n::t('Friendica\'s configuration now is stored in config/local.ini.php, please copy config/local-sample.ini.php and move your config from <code>.htconfig.php</code>. See <a href="%s">the Config help page</a> for help with the transition.', $a->getBaseURL() . '/help/Config');
}
// Check server vitality
if (!admin_page_server_vital()) {
$showwarning = true;
$well_known = $a->get_baseurl() . '/.well-known/host-meta';
$well_known = $a->getBaseURL() . '/.well-known/host-meta';
$warningtext[] = L10n::t('<a href="%s">%s</a> is not reachable on your system. This is a severe configuration issue that prevents server to server communication. See <a href="%s">the installation page</a> for help.',
$well_known, $well_known, $a->get_baseurl() . '/help/Install');
$well_known, $well_known, $a->getBaseURL() . '/help/Install');
}
$r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`");
@ -1012,7 +1012,7 @@ function admin_page_site_post(App $a)
// update config
Config::set('system', 'hostname', parse_url($new_url, PHP_URL_HOST));
Config::set('system', 'url', $new_url);
$a->set_baseurl($new_url);
$a->setBaseURL($new_url);
// send relocate
$users = q("SELECT `uid` FROM `user` WHERE `account_removed` = 0 AND `account_expired` = 0");
@ -1124,7 +1124,7 @@ function admin_page_site_post(App $a)
Worker::add(PRIORITY_LOW, 'Directory');
}
if ($a->get_path() != "") {
if ($a->getURLpath() != "") {
$diaspora_enabled = false;
}
if ($ssl_policy != intval(Config::get('system', 'ssl_policy'))) {
@ -1261,7 +1261,7 @@ function admin_page_site_post(App $a)
Config::set('system', 'dbclean-expire-unclaimed', $dbclean_unclaimed);
if ($itemcache != '') {
$itemcache = App::realpath($itemcache);
$itemcache = App::getRealPath($itemcache);
}
Config::set('system', 'itemcache', $itemcache);
@ -1269,13 +1269,13 @@ function admin_page_site_post(App $a)
Config::set('system', 'max_comments', $max_comments);
if ($temppath != '') {
$temppath = App::realpath($temppath);
$temppath = App::getRealPath($temppath);
}
Config::set('system', 'temppath', $temppath);
if ($basepath != '') {
$basepath = App::realpath($basepath);
$basepath = App::getRealPath($basepath);
}
Config::set('system', 'basepath', $basepath);
@ -1419,9 +1419,9 @@ function admin_page_site(App $a)
];
if (empty(Config::get('config', 'hostname'))) {
Config::set('config', 'hostname', $a->get_hostname());
Config::set('config', 'hostname', $a->getHostName());
}
$diaspora_able = ($a->get_path() == "");
$diaspora_able = ($a->getURLpath() == "");
$optimize_max_tablesize = Config::get('system', 'optimize_max_tablesize', -1);
@ -1801,8 +1801,8 @@ function admin_page_users(App $a)
/* get users */
$total = q("SELECT COUNT(*) AS `total` FROM `user` WHERE 1");
if (count($total)) {
$a->set_pager_total($total[0]['total']);
$a->set_pager_itemspage(100);
$a->setPagerTotal($total[0]['total']);
$a->setPagerItemsPage(100);
}
/* ordering */

View file

@ -46,7 +46,7 @@ function allfriends_content(App $a)
$total = GContact::countAllFriends(local_user(), $cid);
$a->set_pager_total($total);
$a->setPagerTotal($total);
$r = GContact::allFriends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
if (!DBA::isResult($r)) {

View file

@ -88,7 +88,7 @@ function common_content(App $a)
}
if ($t > 0) {
$a->set_pager_total($t);
$a->setPagerTotal($t);
} else {
notice(L10n::t('No contacts in common.') . EOL);
return $o;

View file

@ -153,7 +153,7 @@ function community_content(App $a, $update = 0)
$itemspage_network = $a->force_max_items;
}
$a->set_pager_itemspage($itemspage_network);
$a->setPagerItemsPage($itemspage_network);
$r = community_getitems($a->pager['start'], $a->pager['itemspage'], $content, $accounttype);

View file

@ -793,7 +793,7 @@ function contacts_content(App $a, $update = 0)
intval($_SESSION['uid'])
);
if (DBA::isResult($r)) {
$a->set_pager_total($r[0]['total']);
$a->setPagerTotal($r[0]['total']);
$total = $r[0]['total'];
}

View file

@ -451,10 +451,10 @@ function dfrn_request_post(App $a)
// Diaspora needs the uri in the format user@domain.tld
// Diaspora will support the remote subscription in a future version
if ($network == Protocol::DIASPORA) {
$uri = $nickname . '@' . $a->get_hostname();
$uri = $nickname . '@' . $a->getHostName();
if ($a->get_path()) {
$uri .= '/' . $a->get_path();
if ($a->getURLpath()) {
$uri .= '/' . $a->getURLpath();
}
$uri = urlencode($uri);
@ -609,7 +609,7 @@ function dfrn_request_content(App $a)
} elseif (x($_GET, 'address') && ($_GET['address'] != "")) {
$myaddr = $_GET['address'];
} elseif (local_user()) {
if (strlen($a->urlpath)) {
if (strlen($a->getURLpath())) {
$myaddr = System::baseUrl() . '/profile/' . $a->user['nickname'];
} else {
$myaddr = $a->user['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);

View file

@ -16,7 +16,7 @@ use Friendica\Util\Proxy as ProxyUtils;
function directory_init(App $a)
{
$a->set_pager_itemspage(60);
$a->setPagerItemsPage(60);
if (local_user()) {
$a->page['aside'] .= Widget::findPeople();
@ -87,7 +87,7 @@ function directory_content(App $a)
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` $sql_extra");
if (DBA::isResult($cnt)) {
$a->set_pager_total($cnt['total']);
$a->setPagerTotal($cnt['total']);
}
$order = " ORDER BY `name` ASC ";

View file

@ -188,8 +188,8 @@ function dirfind_content(App $a, $prefix = "") {
}
if ($j->total) {
$a->set_pager_total($j->total);
$a->set_pager_itemspage($j->items_page);
$a->setPagerTotal($j->total);
$a->setPagerItemsPage($j->items_page);
}
if (!empty($j->results)) {

View file

@ -365,7 +365,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
$title = trim(HTML::toPlaintext(BBCode::convert($item["title"], false), 0, true));
$author_name = $item["author-name"];
$image = $a->remove_baseurl($item["author-avatar"]);
$image = $a->removeBaseURL($item["author-avatar"]);
if ($title == "") {
$title = $author_name;

View file

@ -50,7 +50,7 @@ function hcard_init(App $a)
$a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->urlpath) ? '/' . $a->urlpath : ''));
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->getHostName() . (($a->getURLpath()) ? '/' . $a->getURLpath() : ''));
$a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);

View file

@ -38,8 +38,8 @@ function home_content(App $a) {
$customhome = false;
$defaultheader = '<h1>' . (Config::get('config', 'sitename') ? L10n::t('Welcome to %s', Config::get('config', 'sitename')) : '') . '</h1>';
$homefilepath = $a->basepath . "/home.html";
$cssfilepath = $a->basepath . "/home.css";
$homefilepath = $a->getBasePath() . "/home.html";
$cssfilepath = $a->getBasePath() . "/home.css";
if (file_exists($homefilepath)) {
$customhome = $homefilepath;
if (file_exists($cssfilepath)) {

View file

@ -23,7 +23,7 @@ function hostxrd_init(App $a)
$tpl = get_markup_template('xrd_host.tpl');
echo replace_macros($tpl, [
'$zhost' => $a->get_hostname(),
'$zhost' => $a->getHostName(),
'$zroot' => System::baseUrl(),
'$domain' => System::baseUrl(),
'$bigkey' => Salmon::salmonKey(Config::get('system', 'site_pubkey'))]

View file

@ -67,8 +67,8 @@ function match_content(App $a)
$j = json_decode($x);
if ($j->total) {
$a->set_pager_total($j->total);
$a->set_pager_itemspage($j->items_page);
$a->setPagerTotal($j->total);
$a->setPagerItemsPage($j->items_page);
}
if (count($j->results)) {

View file

@ -279,7 +279,7 @@ function message_content(App $a)
);
if (DBA::isResult($r)) {
$a->set_pager_total($r[0]['total']);
$a->setPagerTotal($r[0]['total']);
}
$r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']);

View file

@ -302,7 +302,7 @@ function networkPager($a, $update)
$itemspage_network = $a->force_max_items;
}
$a->set_pager_itemspage($itemspage_network);
$a->setPagerItemsPage($itemspage_network);
return sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
}
@ -721,7 +721,7 @@ function networkThreadedView(App $a, $update, $parent)
if ($last_received != '') {
$last_date = $last_received;
$sql_range .= sprintf(" AND $sql_table.`received` < '%s'", DBA::escape($last_received));
$a->set_pager_page(1);
$a->setPagerPage(1);
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
}
break;
@ -729,7 +729,7 @@ function networkThreadedView(App $a, $update, $parent)
if ($last_commented != '') {
$last_date = $last_commented;
$sql_range .= sprintf(" AND $sql_table.`commented` < '%s'", DBA::escape($last_commented));
$a->set_pager_page(1);
$a->setPagerPage(1);
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
}
break;
@ -737,14 +737,14 @@ function networkThreadedView(App $a, $update, $parent)
if ($last_created != '') {
$last_date = $last_created;
$sql_range .= sprintf(" AND $sql_table.`created` < '%s'", DBA::escape($last_created));
$a->set_pager_page(1);
$a->setPagerPage(1);
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
}
break;
case 'id':
if (($last_id > 0) && ($sql_table == '`thread`')) {
$sql_range .= sprintf(" AND $sql_table.`iid` < '%s'", DBA::escape($last_id));
$a->set_pager_page(1);
$a->setPagerPage(1);
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
}
break;

View file

@ -215,7 +215,7 @@ function nodeinfo_cron() {
logger('local_comments: ' . $local_comments, LOGGER_DEBUG);
// Now trying to register
$url = 'http://the-federation.info/register/'.$a->get_hostname();
$url = 'http://the-federation.info/register/'.$a->getHostName();
logger('registering url: '.$url, LOGGER_DEBUG);
$ret = Network::fetchUrl($url);
logger('registering answer: '.$ret, LOGGER_DEBUG);

View file

@ -61,7 +61,7 @@ function notes_content(App $a, $update = false)
$condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
'wall' => false, 'contact-id'=> $a->contact['id']];
$a->set_pager_itemspage(40);
$a->setPagerItemsPage(40);
$params = ['order' => ['created' => true],
'limit' => [$a->pager['start'], $a->pager['itemspage']]];

View file

@ -120,7 +120,7 @@ function notifications_content(App $a)
}
// Set the pager
$a->set_pager_itemspage($perpage);
$a->setPagerItemsPage($perpage);
// Add additional informations (needed for json output)
$notifs['items_page'] = $a->pager['itemspage'];

View file

@ -27,7 +27,7 @@ function notify_init(App $a)
$nm->setSeen($note);
// The friendica client has problems with the GUID. this is some workaround
if ($a->is_friendica_app()) {
if ($a->isFriendicaApp()) {
require_once("include/items.php");
$urldata = parse_url($note['link']);
$guid = basename($urldata["path"]);

View file

@ -19,7 +19,7 @@ function openid_content(App $a) {
if((x($_GET,'openid_mode')) && (x($_SESSION,'openid'))) {
$openid = new LightOpenID($a->get_hostname());
$openid = new LightOpenID($a->getHostName());
if($openid->validate()) {

View file

@ -11,7 +11,7 @@ function opensearch_content(App $a) {
$o = replace_macros($tpl, [
'$baseurl' => System::baseUrl(),
'$nodename' => $a->get_hostname(),
'$nodename' => $a->getHostName(),
]);
echo $o;

View file

@ -192,7 +192,7 @@ function photo_init(App $a)
// If the photo is public and there is an existing photo directory store the photo there
if ($public and $file != '') {
// If the photo path isn't there, try to create it
$basepath = $a->get_basepath();
$basepath = $a->getBasePath();
if (!is_dir($basepath . "/photo")) {
if (is_writable($basepath)) {
mkdir($basepath . "/photo");

View file

@ -1143,8 +1143,8 @@ function photos_content(App $a)
DBA::escape($album)
);
if (DBA::isResult($r)) {
$a->set_pager_total(count($r));
$a->set_pager_itemspage(20);
$a->setPagerTotal(count($r));
$a->setPagerItemsPage(20);
}
/// @TODO I have seen this many times, maybe generalize it script-wide and encapsulate it?
@ -1393,7 +1393,7 @@ function photos_content(App $a)
$link_item = Item::selectFirst([], ['id' => $linked_items[0]['id']]);
$condition = ["`parent` = ? AND `parent` != `id`", $link_item['parent']];
$a->set_pager_total(DBA::count('item', $condition));
$a->setPagerTotal(DBA::count('item', $condition));
$params = ['order' => ['id'], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
$result = Item::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params);
@ -1655,8 +1655,8 @@ function photos_content(App $a)
);
if (DBA::isResult($r)) {
$a->set_pager_total(count($r));
$a->set_pager_itemspage(20);
$a->setPagerTotal(count($r));
$a->setPagerItemsPage(20);
}
$r = q("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,

View file

@ -350,7 +350,7 @@ function ping_init(App $a)
$regularnotifications = (!empty($_GET['uid']) && !empty($_GET['_']));
foreach ($notifs as $notif) {
if ($a->is_friendica_app() || !$regularnotifications) {
if ($a->isFriendicaApp() || !$regularnotifications) {
$notif['message'] = str_replace("{0}", $notif['name'], $notif['message']);
}

View file

@ -91,7 +91,7 @@ function profile_init(App $a)
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . $which . '/" title="' . L10n::t('%s\'s posts', $a->profile['username']) . '"/>' . "\r\n";
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . $which . '/comments" title="' . L10n::t('%s\'s comments', $a->profile['username']) . '"/>' . "\r\n";
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . $which . '/activity" title="' . L10n::t('%s\'s timeline', $a->profile['username']) . '"/>' . "\r\n";
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . ($a->urlpath ? '/' . $a->urlpath : ''));
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->getHostName() . ($a->getURLpath() ? '/' . $a->getURLpath() : ''));
$a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
@ -307,7 +307,7 @@ function profile_content(App $a, $update = 0)
$itemspage_network = $a->force_max_items;
}
$a->set_pager_itemspage($itemspage_network);
$a->setPagerItemsPage($itemspage_network);
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));

View file

@ -667,7 +667,7 @@ function profiles_content(App $a) {
$profiles = '';
foreach ($r as $rr) {
$profiles .= replace_macros($tpl, [
'$photo' => $a->remove_baseurl($rr['thumb']),
'$photo' => $a->removeBaseURL($rr['thumb']),
'$id' => $rr['id'],
'$alt' => L10n::t('Profile Image'),
'$profile_name' => $rr['profile-name'],

View file

@ -105,7 +105,7 @@ function pubsubhubbub_init(App $a) {
// Social/StatusNet doesn't honour it (yet)
$body = Network::fetchUrl($hub_callback . "?" . $params);
$ret = $a->get_curl_code();
$ret = Network::getCurl()->getCode();
// give up if the HTTP return code wasn't a success (2xx)
if ($ret < 200 || $ret > 299) {

View file

@ -57,7 +57,7 @@ function redir_init(App $a) {
}
if (remote_user()) {
$host = substr(System::baseUrl() . ($a->urlpath ? '/' . $a->urlpath : ''), strpos(System::baseUrl(), '://') + 3);
$host = substr(System::baseUrl() . ($a->getURLpath() ? '/' . $a->getURLpath() : ''), strpos(System::baseUrl(), '://') + 3);
$remotehost = substr($contact['addr'], strpos($contact['addr'], '@') + 1);
// On a local instance we have to check if the local user has already authenticated

View file

@ -274,7 +274,7 @@ function register_content(App $a)
'$passwords' => $passwords,
'$password1' => ['password1', L10n::t('New Password:'), '', L10n::t('Leave empty for an auto generated password.')],
'$password2' => ['confirm', L10n::t('Confirm:'), '', ''],
'$nickdesc' => L10n::t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be \'<strong>nickname@%s</strong>\'.', $a->get_hostname()),
'$nickdesc' => L10n::t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be \'<strong>nickname@%s</strong>\'.', $a->getHostName()),
'$nicklabel' => L10n::t('Choose a nickname: '),
'$photo' => $photo,
'$publish' => $profile_publish,
@ -283,7 +283,7 @@ function register_content(App $a)
'$email' => $email,
'$nickname' => $nickname,
'$license' => $license,
'$sitename' => $a->get_hostname(),
'$sitename' => $a->getHostName(),
'$importh' => L10n::t('Import'),
'$importt' => L10n::t('Import your profile to this friendica instance'),
'$showtoslink' => Config::get('system', 'tosdisplay'),

View file

@ -547,7 +547,7 @@ function settings_post(App $a)
if ($openid != $a->user['openid'] || (strlen($openid) && (!strlen($openidserver)))) {
if (Network::isUrlValid($openid)) {
logger('updating openidserver');
$open_id_obj = new LightOpenID($a->get_hostname());
$open_id_obj = new LightOpenID($a->getHostName());
$open_id_obj->identity = $openid;
$openidserver = $open_id_obj->discover($open_id_obj->identity);
} else {
@ -1136,8 +1136,8 @@ function settings_content(App $a)
$tpl_addr = get_markup_template('settings/nick_set.tpl');
$prof_addr = replace_macros($tpl_addr,[
'$desc' => L10n::t("Your Identity Address is <strong>'%s'</strong> or '%s'.", $nickname . '@' . $a->get_hostname() . $a->get_path(), System::baseUrl() . '/profile/' . $nickname),
'$basepath' => $a->get_hostname()
'$desc' => L10n::t("Your Identity Address is <strong>'%s'</strong> or '%s'.", $nickname . '@' . $a->getHostName() . $a->getURLpath(), System::baseUrl() . '/profile/' . $nickname),
'$basepath' => $a->getHostName()
]);
$stpl = get_markup_template('settings/settings.tpl');

View file

@ -341,8 +341,8 @@ function videos_content(App $a)
);
if (DBA::isResult($r)) {
$a->set_pager_total(count($r));
$a->set_pager_itemspage(20);
$a->setPagerTotal(count($r));
$a->setPagerItemsPage(20);
}
$r = q("SELECT hash, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`created`) AS `created`,

View file

@ -71,7 +71,7 @@ function viewcontacts_content(App $a)
DBA::escape(Protocol::OSTATUS)
);
if (DBA::isResult($r)) {
$a->set_pager_total($r[0]['total']);
$a->setPagerTotal($r[0]['total']);
}
$r = q("SELECT * FROM `contact`

View file

@ -55,9 +55,9 @@ function xrd_init(App $a)
$alias = str_replace('/profile/', '/~', $profile_url);
$addr = 'acct:'.$user['nickname'].'@'.$a->get_hostname();
if ($a->get_path()) {
$addr .= '/'.$a->get_path();
$addr = 'acct:'.$user['nickname'].'@'.$a->getHostName();
if ($a->getURLpath()) {
$addr .= '/'.$a->getURLpath();
}
if ($mode == 'xml') {