Hook::callAll("parse_link", $arr);
-### mod/manage.php
+### src/Module/Delegation.php
Hook::callAll('home_init', $ret);
Hook::callAll("parse_link", $arr);
-### mod/manage.php
+### src/Module/Delegation.php
Hook::callAll('home_init', $ret);
// put the event parametes in an array so we can better transmit them
$event_params = [
- 'event_id' => intval(defaults($_GET, 'id', 0)),
+ 'event_id' => intval($_GET['id'] ?? 0),
'start' => $start,
'finish' => $finish,
'adjust_start' => $adjust_start,
$entry = [
'url' => Model\Contact::magicLink($common_friend['url']),
- 'itemurl' => defaults($contact_details, 'addr', $common_friend['url']),
+ 'itemurl' => ($contact_details['addr'] ?? '') ?: $common_friend['url'],
'name' => $contact_details['name'],
'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
'img_hover' => $contact_details['name'],
return;
}
- $name = defaults($_POST, 'name' , $contact['name']);
- $nick = defaults($_POST, 'nick' , '');
- $url = defaults($_POST, 'url' , '');
- $alias = defaults($_POST, 'alias' , '');
- $request = defaults($_POST, 'request' , '');
- $confirm = defaults($_POST, 'confirm' , '');
- $notify = defaults($_POST, 'notify' , '');
- $poll = defaults($_POST, 'poll' , '');
- $attag = defaults($_POST, 'attag' , '');
- $photo = defaults($_POST, 'photo' , '');
- $remote_self = defaults($_POST, 'remote_self', false);
+ $name = ($_POST['name'] ?? '') ?: $contact['name'];
+ $nick = $_POST['nick'] ?? '';
+ $url = $_POST['url'] ?? '';
+ $alias = $_POST['alias'] ?? '';
+ $request = $_POST['request'] ?? '';
+ $confirm = $_POST['confirm'] ?? '';
+ $notify = $_POST['notify'] ?? '';
+ $poll = $_POST['poll'] ?? '';
+ $attag = $_POST['attag'] ?? '';
+ $photo = $_POST['photo'] ?? '';
+ $remote_self = $_POST['remote_self'] ?? false;
$nurl = Strings::normaliseLink($url);
$r = DBA::update(
* since we are operating on behalf of our registered user to approve a friendship.
*/
if (empty($_POST['source_url'])) {
- $uid = defaults($handsfree, 'uid', local_user());
+ $uid = ($handsfree['uid'] ?? 0) ?: local_user();
if (!$uid) {
notice(L10n::t('Permission denied.') . EOL);
return;
$intro_id = $handsfree['intro_id'];
$duplex = $handsfree['duplex'];
$cid = 0;
- $hidden = intval(defaults($handsfree, 'hidden' , 0));
+ $hidden = intval($handsfree['hidden'] ?? 0);
} else {
- $dfrn_id = Strings::escapeTags(trim(defaults($_POST, 'dfrn_id' , '')));
- $intro_id = intval(defaults($_POST, 'intro_id' , 0));
- $duplex = intval(defaults($_POST, 'duplex' , 0));
- $cid = intval(defaults($_POST, 'contact_id', 0));
- $hidden = intval(defaults($_POST, 'hidden' , 0));
+ $dfrn_id = Strings::escapeTags(trim($_POST['dfrn_id'] ?? ''));
+ $intro_id = intval($_POST['intro_id'] ?? 0);
+ $duplex = intval($_POST['duplex'] ?? 0);
+ $cid = intval($_POST['contact_id'] ?? 0);
+ $hidden = intval($_POST['hidden'] ?? 0);
}
/*
*/
if (!empty($_POST['source_url'])) {
// We are processing an external confirmation to an introduction created by our user.
- $public_key = defaults($_POST, 'public_key', '');
- $dfrn_id = hex2bin(defaults($_POST, 'dfrn_id' , ''));
- $source_url = hex2bin(defaults($_POST, 'source_url', ''));
- $aes_key = defaults($_POST, 'aes_key' , '');
- $duplex = intval(defaults($_POST, 'duplex' , 0));
- $page = intval(defaults($_POST, 'page' , 0));
+ $public_key = $_POST['public_key'] ?? '';
+ $dfrn_id = hex2bin($_POST['dfrn_id'] ?? '');
+ $source_url = hex2bin($_POST['source_url'] ?? '');
+ $aes_key = $_POST['aes_key'] ?? '';
+ $duplex = intval($_POST['duplex'] ?? 0);
+ $page = intval($_POST['page'] ?? 0);
$forum = (($page == 1) ? 1 : 0);
$prv = (($page == 2) ? 1 : 0);
if (empty($_POST) || !empty($postdata)) {
$data = json_decode($postdata);
if (is_object($data)) {
- $nick = defaults($a->argv, 1, '');
+ $nick = $a->argv[1] ?? '';
$user = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (!DBA::isResult($user)) {
$dfrn_id = (!empty($_POST['dfrn_id']) ? Strings::escapeTags(trim($_POST['dfrn_id'])) : '');
$dfrn_version = (!empty($_POST['dfrn_version']) ? (float) $_POST['dfrn_version'] : 2.0);
$challenge = (!empty($_POST['challenge']) ? Strings::escapeTags(trim($_POST['challenge'])) : '');
- $data = defaults($_POST, 'data', '');
- $key = defaults($_POST, 'key', '');
+ $data = $_POST['data'] ?? '';
+ $key = $_POST['key'] ?? '';
$rino_remote = (!empty($_POST['rino']) ? intval($_POST['rino']) : 0);
$dissolve = (!empty($_POST['dissolve']) ? intval($_POST['dissolve']) : 0);
$perm = (!empty($_POST['perm']) ? Strings::escapeTags(trim($_POST['perm'])) : 'r');
{
Login::sessionAuth();
- $dfrn_id = defaults($_GET, 'dfrn_id' , '');
- $type = defaults($_GET, 'type' , 'data');
- $last_update = defaults($_GET, 'last_update' , '');
- $destination_url = defaults($_GET, 'destination_url', '');
- $challenge = defaults($_GET, 'challenge' , '');
- $sec = defaults($_GET, 'sec' , '');
- $dfrn_version = (float) defaults($_GET, 'dfrn_version' , 2.0);
+ $dfrn_id = $_GET['dfrn_id'] ?? '';
+ $type = ($_GET['type'] ?? '') ?: 'data';
+ $last_update = $_GET['last_update'] ?? '';
+ $destination_url = $_GET['destination_url'] ?? '';
+ $challenge = $_GET['challenge'] ?? '';
+ $sec = $_GET['sec'] ?? '';
+ $dfrn_version = floatval(($_GET['dfrn_version'] ?? 0.0) ?: 2.0);
$quiet = !empty($_GET['quiet']);
// Possibly it is an OStatus compatible server that requests a user feed
- $user_agent = defaults($_SERVER, 'HTTP_USER_AGENT', '');
+ $user_agent = $_SERVER['HTTP_USER_AGENT'] ?? '';
if (($a->argc > 1) && ($dfrn_id == '') && !strstr($user_agent, 'Friendica')) {
$nickname = $a->argv[1];
header("Content-type: application/atom+xml");
function dfrn_poll_post(App $a)
{
- $dfrn_id = defaults($_POST, 'dfrn_id' , '');
- $challenge = defaults($_POST, 'challenge', '');
- $url = defaults($_POST, 'url' , '');
- $sec = defaults($_POST, 'sec' , '');
- $ptype = defaults($_POST, 'type' , '');
- $perm = defaults($_POST, 'perm' , 'r');
- $dfrn_version = !empty($_POST['dfrn_version']) ? (float) $_POST['dfrn_version'] : 2.0;
+ $dfrn_id = $_POST['dfrn_id'] ?? '';
+ $challenge = $_POST['challenge'] ?? '';
+ $url = $_POST['url'] ?? '';
+ $sec = $_POST['sec'] ?? '';
+ $ptype = $_POST['type'] ?? '';
+ $perm = ($_POST['perm'] ?? '') ?: 'r';
+ $dfrn_version = floatval(($_GET['dfrn_version'] ?? 0.0) ?: 2.0);
if ($ptype === 'profile-check') {
if (strlen($challenge) && strlen($sec)) {
function dfrn_poll_content(App $a)
{
- $dfrn_id = defaults($_GET, 'dfrn_id' , '');
- $type = defaults($_GET, 'type' , 'data');
- $last_update = defaults($_GET, 'last_update' , '');
- $destination_url = defaults($_GET, 'destination_url', '');
- $sec = defaults($_GET, 'sec' , '');
- $dfrn_version = !empty($_GET['dfrn_version']) ? (float) $_GET['dfrn_version'] : 2.0;
+ $dfrn_id = $_GET['dfrn_id'] ?? '';
+ $type = ($_GET['type'] ?? '') ?: 'data';
+ $last_update = $_GET['last_update'] ?? '';
+ $destination_url = $_GET['destination_url'] ?? '';
+ $sec = $_GET['sec'] ?? '';
+ $dfrn_version = floatval(($_GET['dfrn_version'] ?? 0.0) ?: 2.0);
$quiet = !empty($_GET['quiet']);
$direction = -1;
if (local_user() && ($a->user['nickname'] == $a->argv[1]) && !empty($_POST['dfrn_url'])) {
$dfrn_url = Strings::escapeTags(trim($_POST['dfrn_url']));
$aes_allow = !empty($_POST['aes_allow']);
- $confirm_key = defaults($_POST, 'confirm_key', "");
+ $confirm_key = $_POST['confirm_key'] ?? '';
$hidden = (!empty($_POST['hidden-contact']) ? intval($_POST['hidden-contact']) : 0);
$contact_record = null;
$blocked = 1;
$r = q("SELECT `id`, `network` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `site-pubkey` = '%s' LIMIT 1",
intval(local_user()),
DBA::escape($dfrn_url),
- defaults($parms, 'key', '') // Potentially missing
+ $parms['key'] ?? '' // Potentially missing
);
if (DBA::isResult($r)) {
Group::addMember(User::getDefaultGroup(local_user(), $r[0]["network"]), $r[0]['id']);
intval($uid),
intval($contact_record['id']),
intval(!empty($_POST['knowyou'])),
- DBA::escape(Strings::escapeTags(trim(defaults($_POST, 'dfrn-request-message', '')))),
+ DBA::escape(Strings::escapeTags(trim($_POST['dfrn-request-message'] ?? ''))),
DBA::escape($hash),
DBA::escape(DateTimeFormat::utcNow())
);
$dfrn_url = Strings::escapeTags(trim(hex2bin($_GET['dfrn_url'])));
$aes_allow = !empty($_GET['aes_allow']);
- $confirm_key = defaults($_GET, 'confirm_key', "");
+ $confirm_key = $_GET['confirm_key'] ?? '';
// Checking fastlane for validity
if (!empty($_SESSION['fastlane']) && (Strings::normaliseLink($_SESSION["fastlane"]) == Strings::normaliseLink($dfrn_url))) {
if (isset($item_parent_uri)) {
$parent = Item::selectFirst(['uid'], ['uri' => $item_parent_uri, 'wall' => true]);
if (DBA::isResult($parent)) {
- $a->profile['uid'] = defaults($a->profile, 'uid', $parent['uid']);
- $a->profile['profile_uid'] = defaults($a->profile, 'profile_uid', $parent['uid']);
+ $a->profile['uid'] = ($a->profile['uid'] ?? 0) ?: $parent['uid'];
+ $a->profile['profile_uid'] = ($a->profile['profile_uid'] ?? 0) ?: $parent['uid'];
$is_remote_contact = Session::getRemoteContactID($a->profile['profile_uid']);
if ($is_remote_contact) {
$item_uid = $parent['uid'];
$cid = !empty($_POST['cid']) ? intval($_POST['cid']) : 0;
$uid = local_user();
- $start_text = Strings::escapeHtml(defaults($_REQUEST, 'start_text', ''));
- $finish_text = Strings::escapeHtml(defaults($_REQUEST, 'finish_text', ''));
+ $start_text = Strings::escapeHtml($_REQUEST['start_text'] ?? '');
+ $finish_text = Strings::escapeHtml($_REQUEST['finish_text'] ?? '');
- $adjust = intval(defaults($_POST, 'adjust', 0));
- $nofinish = intval(defaults($_POST, 'nofinish', 0));
+ $adjust = intval($_POST['adjust'] ?? 0);
+ $nofinish = intval($_POST['nofinish'] ?? 0);
// The default setting for the `private` field in event_store() is false, so mirror that
$private_event = false;
// and we'll waste a bunch of time responding to it. Time that
// could've been spent doing something else.
- $summary = trim(defaults($_POST, 'summary' , ''));
- $desc = trim(defaults($_POST, 'desc' , ''));
- $location = trim(defaults($_POST, 'location', ''));
+ $summary = trim($_POST['summary'] ?? '');
+ $desc = trim($_POST['desc'] ?? '');
+ $location = trim($_POST['location'] ?? '');
$type = 'event';
$params = [
$a->internalRedirect($onerror_path);
}
- $share = intval(defaults($_POST, 'share', 0));
+ $share = intval($_POST['share'] ?? 0);
$c = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
intval(local_user())
if ($share) {
- $str_group_allow = perms2str(defaults($_POST, 'group_allow' , ''));
- $str_contact_allow = perms2str(defaults($_POST, 'contact_allow', ''));
- $str_group_deny = perms2str(defaults($_POST, 'group_deny' , ''));
- $str_contact_deny = perms2str(defaults($_POST, 'contact_deny' , ''));
+ $str_group_allow = perms2str($_POST['group_allow'] ?? '');
+ $str_contact_allow = perms2str($_POST['contact_allow'] ?? '');
+ $str_group_deny = perms2str($_POST['group_deny'] ?? '');
+ $str_contact_deny = perms2str($_POST['contact_deny'] ?? '');
// Undo the pseudo-contact of self, since there are real contacts now
if (strpos($str_contact_allow, '<' . $self . '>') !== false) {
}
// Needed to match the correct template in a module that uses a different theme than the user/site/default
- $theme = Strings::sanitizeFilePathItem(defaults($_GET, 'theme', null));
+ $theme = Strings::sanitizeFilePathItem($_GET['theme'] ?? null);
if ($theme && is_file("view/theme/$theme/config.php")) {
$a->setCurrentTheme($theme);
}
$uid = local_user();
// Issue 4815: Silently removing a prefixing @
- $url = ltrim(Strings::escapeTags(trim(defaults($_REQUEST, 'url', ''))), '@!');
+ $url = ltrim(Strings::escapeTags(trim($_REQUEST['url'] ?? '')), '@!');
// Issue 6874: Allow remote following from Peertube
if (strpos($url, 'acct:') === 0) {
return;
}
- $note = Strings::escapeHtml(trim(defaults($_POST, 'note', '')));
+ $note = Strings::escapeHtml(trim($_POST['note'] ?? ''));
$fields = ['uid' => local_user(),'cid' => $contact_id, 'name' => $contact['name'],
'url' => $contact['url'], 'request' => $contact['request'],
}
if (!$blocked) {
- $keywords = defaults($a->profile, 'pub_keywords', '');
+ $keywords = $a->profile['pub_keywords'] ?? '';
$keywords = str_replace([',',' ',',,'], [' ',',',','], $keywords);
if (strlen($keywords)) {
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n";
function hovercard_content()
{
- $profileurl = defaults($_REQUEST, 'profileurl', '');
- $datatype = defaults($_REQUEST, 'datatype' , 'json');
+ $profileurl = $_REQUEST['profileurl'] ?? '';
+ $datatype = ($_REQUEST['datatype'] ?? '') ?: 'json';
// Get out if the system doesn't have public access allowed
if (intval(Config::get('system', 'block_public'))) {
if (strpos($profileurl, 'redir/') === 0) {
$cid = intval(substr($profileurl, 6));
$remote_contact = DBA::selectFirst('contact', ['nurl'], ['id' => $cid]);
- $profileurl = defaults($remote_contact, 'nurl', '');
+ $profileurl = $remote_contact['nurl'] ?? '';
}
$contact = [];
$profile = [
'name' => $contact['name'],
'nick' => $contact['nick'],
- 'addr' => defaults($contact, 'addr', $contact['url']),
+ 'addr' => ($contact['addr'] ?? '') ?: $contact['url'],
'thumb' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
'url' => Contact::magicLink($contact['url']),
'nurl' => $contact['nurl'], // We additionally store the nurl as identifier
}
// See if we've been passed a return path to redirect to
- $return_path = defaults($_REQUEST, 'return', '');
+ $return_path = $_REQUEST['return'] ?? '';
if ($return_path) {
$rand = '_=' . time();
if (strpos($return_path, '?')) {
Logger::log('postvars ' . print_r($_REQUEST, true), Logger::DATA);
- $api_source = defaults($_REQUEST, 'api_source', false);
+ $api_source = $_REQUEST['api_source'] ?? false;
$message_id = ((!empty($_REQUEST['message_id']) && $api_source) ? strip_tags($_REQUEST['message_id']) : '');
- $return_path = defaults($_REQUEST, 'return', '');
- $preview = intval(defaults($_REQUEST, 'preview', 0));
+ $return_path = $_REQUEST['return'] ?? '';
+ $preview = intval($_REQUEST['preview'] ?? 0);
/*
* Check for doubly-submitted posts, and reject duplicates
}
// Is this a reply to something?
- $toplevel_item_id = intval(defaults($_REQUEST, 'parent', 0));
- $thr_parent_uri = trim(defaults($_REQUEST, 'parent_uri', ''));
+ $toplevel_item_id = intval($_REQUEST['parent'] ?? 0);
+ $thr_parent_uri = trim($_REQUEST['parent_uri'] ?? '');
$thread_parent_id = 0;
$thread_parent_contact = null;
$parent_contact = null;
$objecttype = null;
- $profile_uid = defaults($_REQUEST, 'profile_uid', local_user());
- $posttype = defaults($_REQUEST, 'post_type', Item::PT_ARTICLE);
+ $profile_uid = ($_REQUEST['profile_uid'] ?? 0) ?: local_user();
+ $posttype = ($_REQUEST['post_type'] ?? '') ?: Item::PT_ARTICLE;
if ($toplevel_item_id || $thr_parent_uri) {
if ($toplevel_item_id) {
Logger::info('mod_item: item_post parent=' . $toplevel_item_id);
}
- $post_id = intval(defaults($_REQUEST, 'post_id', 0));
- $app = strip_tags(defaults($_REQUEST, 'source', ''));
- $extid = strip_tags(defaults($_REQUEST, 'extid', ''));
- $object = defaults($_REQUEST, 'object', '');
+ $post_id = intval($_REQUEST['post_id'] ?? 0);
+ $app = strip_tags($_REQUEST['source'] ?? '');
+ $extid = strip_tags($_REQUEST['extid'] ?? '');
+ $object = $_REQUEST['object'] ?? '';
// Don't use "defaults" here. It would turn 0 to 1
if (!isset($_REQUEST['wall'])) {
$categories = '';
$postopts = '';
$emailcc = '';
- $body = defaults($_REQUEST, 'body', '');
- $has_attachment = defaults($_REQUEST, 'has_attachment', 0);
+ $body = $_REQUEST['body'] ?? '';
+ $has_attachment = $_REQUEST['has_attachment'] ?? 0;
// If we have a speparate attachment, we need to add it to the body.
if (!empty($has_attachment)) {
- $attachment_type = defaults($_REQUEST, 'attachment_type', '');
- $attachment_title = defaults($_REQUEST, 'attachment_title', '');
- $attachment_text = defaults($_REQUEST, 'attachment_text', '');
+ $attachment_type = $_REQUEST['attachment_type'] ?? '';
+ $attachment_title = $_REQUEST['attachment_title'] ?? '';
+ $attachment_text = $_REQUEST['attachment_text'] ?? '';
- $attachment_url = hex2bin(defaults($_REQUEST, 'attachment_url', ''));
- $attachment_img_src = hex2bin(defaults($_REQUEST, 'attachment_img_src', ''));
+ $attachment_url = hex2bin($_REQUEST['attachment_url'] ?? '');
+ $attachment_img_src = hex2bin($_REQUEST['attachment_img_src'] ?? '');
- $attachment_img_width = defaults($_REQUEST, 'attachment_img_width', 0);
- $attachment_img_height = defaults($_REQUEST, 'attachment_img_height', 0);
+ $attachment_img_width = $_REQUEST['attachment_img_width'] ?? 0;
+ $attachment_img_height = $_REQUEST['attachment_img_height'] ?? 0;
$attachment = [
'type' => $attachment_type,
'title' => $attachment_title,
$body .= $att_bbcode;
}
+ // Convert links with empty descriptions to links without an explicit description
+ $body = preg_replace('(\[url=(.*?)\]\[\/url\])ism', '[url]$1[/url]', $body);
+
if (!empty($orig_post)) {
$str_group_allow = $orig_post['allow_gid'];
$str_contact_allow = $orig_post['allow_cid'];
$str_contact_deny = $user['deny_cid'];
} else {
// use the posted permissions
- $str_group_allow = perms2str(defaults($_REQUEST, 'group_allow', ''));
- $str_contact_allow = perms2str(defaults($_REQUEST, 'contact_allow', ''));
- $str_group_deny = perms2str(defaults($_REQUEST, 'group_deny', ''));
- $str_contact_deny = perms2str(defaults($_REQUEST, 'contact_deny', ''));
+ $str_group_allow = perms2str($_REQUEST['group_allow'] ?? '');
+ $str_contact_allow = perms2str($_REQUEST['contact_allow'] ?? '');
+ $str_group_deny = perms2str($_REQUEST['group_deny'] ?? '');
+ $str_contact_deny = perms2str($_REQUEST['contact_deny'] ?? '');
}
- $title = Strings::escapeTags(trim(defaults($_REQUEST, 'title' , '')));
- $location = Strings::escapeTags(trim(defaults($_REQUEST, 'location', '')));
- $coord = Strings::escapeTags(trim(defaults($_REQUEST, 'coord' , '')));
- $verb = Strings::escapeTags(trim(defaults($_REQUEST, 'verb' , '')));
- $emailcc = Strings::escapeTags(trim(defaults($_REQUEST, 'emailcc' , '')));
+ $title = Strings::escapeTags(trim($_REQUEST['title'] ?? ''));
+ $location = Strings::escapeTags(trim($_REQUEST['location'] ?? ''));
+ $coord = Strings::escapeTags(trim($_REQUEST['coord'] ?? ''));
+ $verb = Strings::escapeTags(trim($_REQUEST['verb'] ?? ''));
+ $emailcc = Strings::escapeTags(trim($_REQUEST['emailcc'] ?? ''));
$body = Strings::escapeHtml(trim($body));
- $network = Strings::escapeTags(trim(defaults($_REQUEST, 'network' , Protocol::DFRN)));
+ $network = Strings::escapeTags(trim(($_REQUEST['network'] ?? '') ?: Protocol::DFRN));
$guid = System::createUUID();
- $postopts = defaults($_REQUEST, 'postopts', '');
+ $postopts = $_REQUEST['postopts'] ?? '';
$private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0);
$wall = $toplevel_item['wall'];
}
- $pubmail_enabled = defaults($_REQUEST, 'pubmail_enable', false) && !$private;
+ $pubmail_enabled = ($_REQUEST['pubmail_enable'] ?? false) && !$private;
// if using the API, we won't see pubmail_enable - figure out if it should be set
if ($api_source && $profile_uid && $profile_uid == local_user() && !$private) {
// save old and new categories, so we can determine what needs to be deleted from pconfig
$categories_old = $categories;
- $categories = FileTag::listToFile(trim(defaults($_REQUEST, 'category', '')), 'category');
+ $categories = FileTag::listToFile(trim($_REQUEST['category'] ?? ''), 'category');
$categories_new = $categories;
if (!empty($filedas) && is_array($filedas)) {
$profile = $contact["url"];
$alias = $contact["alias"];
- $newname = defaults($contact, "name", $contact["nick"]);
+ $newname = ($contact["name"] ?? '') ?: $contact["nick"];
}
//if there is an url for this persons profile
+++ /dev/null
-<?php
-/**
- * @file mod/manage.php
- */
-
-use Friendica\App;
-use Friendica\Core\Hook;
-use Friendica\Core\L10n;
-use Friendica\Core\Renderer;
-use Friendica\Core\Session;
-use Friendica\Database\DBA;
-
-function manage_post(App $a) {
-
- if (!local_user()) {
- return;
- }
-
- $uid = local_user();
- $orig_record = $a->user;
-
- if(!empty($_SESSION['submanage'])) {
- $user = DBA::selectFirst('user', [], ['uid' => $_SESSION['submanage']]);
- if (DBA::isResult($user)) {
- $uid = intval($user['uid']);
- $orig_record = $user;
- }
- }
-
- $identity = (!empty($_POST['identity']) ? intval($_POST['identity']) : 0);
- if (!$identity) {
- return;
- }
-
- $limited_id = 0;
- $original_id = $uid;
-
- $manage = DBA::select('manage', ['mid'], ['uid' => $uid]);
- while ($m = DBA::fetch($manage)) {
- if ($identity == $m['mid']) {
- $limited_id = $m['mid'];
- break;
- }
- }
- DBA::close($manage);
-
- if ($limited_id) {
- $user = DBA::selectFirst('user', [], ['uid' => $limited_id]);
- } else {
- // Check if the target user is one of our children
- $user = DBA::selectFirst('user', [], ['uid' => $identity, 'parent-uid' => $orig_record['uid']]);
-
- // Check if the target user is one of our siblings
- if (!DBA::isResult($user) && ($orig_record['parent-uid'] != 0)) {
- $user = DBA::selectFirst('user', [], ['uid' => $identity, 'parent-uid' => $orig_record['parent-uid']]);
- }
-
- // Check if it's our parent
- if (!DBA::isResult($user) && ($orig_record['parent-uid'] != 0) && ($orig_record['parent-uid'] == $identity)) {
- $user = DBA::selectFirst('user', [], ['uid' => $identity]);
- }
-
- // Finally check if it's out own user
- if (!DBA::isResult($user) && ($orig_record['uid'] != 0) && ($orig_record['uid'] == $identity)) {
- $user = DBA::selectFirst('user', [], ['uid' => $identity]);
- }
-
- }
-
- if (!DBA::isResult($user)) {
- return;
- }
-
- Session::clear();
-
- Session::setAuthenticatedForUser($a, $user, true, true);
-
- if ($limited_id) {
- $_SESSION['submanage'] = $original_id;
- }
-
- $ret = [];
- Hook::callAll('home_init', $ret);
-
- $a->internalRedirect('profile/' . $a->user['nickname']);
- // NOTREACHED
-}
-
-function manage_content(App $a) {
-
- if (!local_user()) {
- notice(L10n::t('Permission denied.') . EOL);
- return;
- }
-
- if (!empty($_GET['identity'])) {
- $_POST['identity'] = $_GET['identity'];
- manage_post($a);
- return;
- }
-
- $identities = $a->identities;
-
- //getting additinal information for each identity
- foreach ($identities as $key => $id) {
- $thumb = DBA::selectFirst('contact', ['thumb'], ['uid' => $id['uid'] , 'self' => true]);
- if (!DBA::isResult($thumb)) {
- continue;
- }
-
- $identities[$key]['thumb'] = $thumb['thumb'];
-
- $identities[$key]['selected'] = ($id['nickname'] === $a->user['nickname']);
-
- $condition = ["`uid` = ? AND `msg` != '' AND NOT (`type` IN (?, ?)) AND NOT `seen`", $id['uid'], NOTIFY_INTRO, NOTIFY_MAIL];
- $params = ['distinct' => true, 'expression' => 'parent'];
- $notifications = DBA::count('notify', $condition, $params);
-
- $params = ['distinct' => true, 'expression' => 'convid'];
- $notifications += DBA::count('mail', ['uid' => $id['uid'], 'seen' => false], $params);
-
- $notifications += DBA::count('intro', ['blocked' => false, 'ignore' => false, 'uid' => $id['uid']]);
-
- $identities[$key]['notifications'] = $notifications;
- }
-
- $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('manage.tpl'), [
- '$title' => L10n::t('Manage Identities and/or Pages'),
- '$desc' => L10n::t('Toggle between different identities or community/group pages which share your account details or which you have been granted "manage" permissions'),
- '$choose' => L10n::t('Select an identity to manage: '),
- '$identities' => $identities,
- '$submit' => L10n::t('Submit'),
- ]);
-
- return $o;
-
-}
$msearch = json_decode($msearch_json);
- $start = defaults($_GET, 'start', 0);
+ $start = $_GET['start'] ?? 0;
$entries = [];
$paginate = '';
$entry = [
'url' => Contact::magicLink($profile->url),
- 'itemurl' => defaults($contact_details, 'addr', $profile->url),
+ 'itemurl' => $contact_details['addr'] ?? $profile->url,
'name' => $profile->name,
- 'details' => defaults($contact_details, 'location', ''),
- 'tags' => defaults($contact_details, 'keywords', ''),
- 'about' => defaults($contact_details, 'about', ''),
+ 'details' => $contact_details['location'] ?? '',
+ 'tags' => $contact_details['keywords'] ?? '',
+ 'about' => $contact_details['about'] ?? '',
'account_type' => Contact::getAccountType($contact_details),
'thumb' => ProxyUtils::proxifyUrl($profile->photo, false, ProxyUtils::SIZE_THUMB),
'conntxt' => L10n::t('Connect'),
'$prefill' => $prefill,
'$preid' => $preid,
'$subject' => L10n::t('Subject:'),
- '$subjtxt' => defaults($_REQUEST, 'subject', ''),
- '$text' => defaults($_REQUEST, 'body', ''),
+ '$subjtxt' => $_REQUEST['subject'] ?? '',
+ '$text' => $_REQUEST['body'] ?? '',
'$readonly' => '',
'$yourmessage'=> L10n::t('Your message:'),
'$select' => $select,
'$id' => $rr['id'],
'$from_name' => $participants,
'$from_url' => Contact::magicLink($rr['url']),
- '$from_addr' => defaults($contact, 'addr', ''),
+ '$from_addr' => $contact['addr'] ?? '',
'$sparkle' => ' sparkle',
'$from_photo' => ProxyUtils::proxifyUrl($from_photo, false, ProxyUtils::SIZE_THUMB),
'$subject' => $rr['title'],
function msearch_post(App $a)
{
- $search = defaults($_POST, 's', '');
- $perpage = intval(defaults($_POST, 'n', 80));
- $page = intval(defaults($_POST, 'p', 1));
+ $search = $_POST['s'] ?? '';
+ $perpage = intval(($_POST['n'] ?? 0) ?: 80);
+ $page = intval(($_POST['p'] ?? 0) ?: 1);
$startrec = ($page - 1) * $perpage;
$total = 0;
// fetch last used network view and redirect if needed
if (!$is_a_date_query) {
- $sel_nets = defaults($_GET, 'nets', '');
+ $sel_nets = $_GET['nets'] ?? '';
$sel_tabs = network_query_get_sel_tab($a);
$sel_groups = network_query_get_sel_group($a);
$last_sel_tabs = PConfig::get(local_user(), 'network.view', 'tab.selected');
$a->page['aside'] .= Group::sidebarWidget('network/0', 'network', 'standard', $group_id);
$a->page['aside'] .= ForumManager::widget(local_user(), $cid);
$a->page['aside'] .= Widget::postedByYear('network', local_user(), false);
- $a->page['aside'] .= Widget::networks('network', defaults($_GET, 'nets', '') );
+ $a->page['aside'] .= Widget::networks('network', $_GET['nets'] ?? '');
$a->page['aside'] .= Widget\SavedSearches::getHTML($a->query_string);
- $a->page['aside'] .= Widget::fileAs('network', defaults($_GET, 'file', '') );
+ $a->page['aside'] .= Widget::fileAs('network', $_GET['file'] ?? '');
}
/**
$o = '';
- $file = defaults($_GET, 'file', '');
+ $file = $_GET['file'] ?? '';
if (!$update && !$rawmode) {
$tabs = network_tabs($a);
$o = '';
- $cid = intval(defaults($_GET, 'cid' , 0));
- $star = intval(defaults($_GET, 'star' , 0));
- $bmark = intval(defaults($_GET, 'bmark', 0));
- $conv = intval(defaults($_GET, 'conv' , 0));
- $order = Strings::escapeTags(defaults($_GET, 'order', 'comment'));
- $nets = defaults($_GET, 'nets' , '');
+ $cid = intval($_GET['cid'] ?? 0);
+ $star = intval($_GET['star'] ?? 0);
+ $bmark = intval($_GET['bmark'] ?? 0);
+ $conv = intval($_GET['conv'] ?? 0);
+ $order = Strings::escapeTags(($_GET['order'] ?? '') ?: 'comment');
+ $nets = $_GET['nets'] ?? '';
$allowedCids = [];
if ($cid) {
$entries[0] = [
'id' => 'network',
'name' => $contact['name'],
- 'itemurl' => defaults($contact, 'addr', $contact['nurl']),
+ 'itemurl' => ($contact['addr'] ?? '') ?: $contact['nurl'],
'thumb' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
'details' => $contact['location'],
];
global $pager;
if (PConfig::get(local_user(), 'system', 'infinite_scroll')
- && defaults($_GET, 'mode', '') != 'minimal'
+ && ($_GET['mode'] ?? '') != 'minimal'
) {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
$htmlhead .= Renderer::replaceMacros($tpl, [
exit;
}
- $keywords = defaults($a->profile, 'pub_keywords', '');
+ $keywords = $a->profile['pub_keywords'] ?? '';
$keywords = str_replace(['#',',',' ',',,'], ['',' ',',',','], $keywords);
$keywords = explode(',', $keywords);
return Login::form();
}
- $page = defaults($_REQUEST, 'page', 1);
- $show = defaults($_REQUEST, 'show', 0);
+ $page = ($_REQUEST['page'] ?? 0) ?: 1;
+ $show = $_REQUEST['show'] ?? 0;
Nav::setSelected('notifications');
];
// Process the data for template creation
- if (defaults($notifs, 'ident', '') === 'introductions') {
+ if (($notifs['ident'] ?? '') == 'introductions') {
$sugg = Renderer::getMarkupTemplate('suggestions.tpl');
$tpl = Renderer::getMarkupTemplate('intros.tpl');
$vcard_widget = Renderer::replaceMacros($tpl, [
'$name' => $profile['name'],
'$photo' => $profile['photo'],
- '$addr' => defaults($profile, 'addr', ''),
+ '$addr' => $profile['addr'] ?? '',
'$account_type' => $account_type,
- '$pdesc' => defaults($profile, 'pdesc', ''),
+ '$pdesc' => $profile['pdesc'] ?? '',
]);
$albums = Photo::getAlbums($a->data['user']['uid']);
$visible = 0;
}
- $group_allow = defaults($_REQUEST, 'group_allow' , []);
- $contact_allow = defaults($_REQUEST, 'contact_allow', []);
- $group_deny = defaults($_REQUEST, 'group_deny' , []);
- $contact_deny = defaults($_REQUEST, 'contact_deny' , []);
+ $group_allow = $_REQUEST['group_allow'] ?? [];
+ $contact_allow = $_REQUEST['contact_allow'] ?? [];
+ $group_deny = $_REQUEST['group_deny'] ?? [];
+ $contact_deny = $_REQUEST['contact_deny'] ?? [];
$str_group_allow = perms2str(is_array($group_allow) ? $group_allow : explode(',', $group_allow));
$str_contact_allow = perms2str(is_array($contact_allow) ? $contact_allow : explode(',', $contact_allow));
notice(L10n::t('Image exceeds size limit of %s', ini_get('upload_max_filesize')) . EOL);
break;
case UPLOAD_ERR_FORM_SIZE:
- notice(L10n::t('Image exceeds size limit of %s', Strings::formatBytes(defaults($_REQUEST, 'MAX_FILE_SIZE', 0))) . EOL);
+ notice(L10n::t('Image exceeds size limit of %s', Strings::formatBytes($_REQUEST['MAX_FILE_SIZE'] ?? 0)) . EOL);
break;
case UPLOAD_ERR_PARTIAL:
notice(L10n::t('Image upload didn\'t complete, please try again') . EOL);
$pager = new Pager($a->query_string, 20);
/// @TODO I have seen this many times, maybe generalize it script-wide and encapsulate it?
- $order_field = defaults($_GET, 'order', '');
+ $order_field = $_GET['order'] ?? '';
if ($order_field === 'posted') {
$order = 'ASC';
} else {
* By now we hide it if someone wants to.
*/
if ($cmd === 'view' && !Config::get('system', 'no_count', false)) {
- $order_field = defaults($_GET, 'order', '');
+ $order_field = $_GET['order'] ?? '';
if ($order_field === 'posted') {
$order = 'ASC';
$system_mode = true;
}
- $format = defaults($_GET, 'format', 'json');
+ $format = ($_GET['format'] ?? '') ?: 'json';
$justme = false;
$global = false;
$contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 );
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
- $hub_mode = Strings::escapeTags(trim(defaults($_GET, 'hub_mode', '')));
- $hub_topic = Strings::escapeTags(trim(defaults($_GET, 'hub_topic', '')));
- $hub_challenge = Strings::escapeTags(trim(defaults($_GET, 'hub_challenge', '')));
- $hub_verify = Strings::escapeTags(trim(defaults($_GET, 'hub_verify_token', '')));
+ $hub_mode = Strings::escapeTags(trim($_GET['hub_mode'] ?? ''));
+ $hub_topic = Strings::escapeTags(trim($_GET['hub_topic'] ?? ''));
+ $hub_challenge = Strings::escapeTags(trim($_GET['hub_challenge'] ?? ''));
+ $hub_verify = Strings::escapeTags(trim($_GET['hub_verify_token'] ?? ''));
Logger::log('Subscription from ' . $_SERVER['REMOTE_ADDR'] . ' Mode: ' . $hub_mode . ' Nick: ' . $nick);
Logger::log('Data: ' . print_r($_GET,true), Logger::DATA);
function redir_init(App $a) {
- $url = defaults($_GET, 'url', '');
+ $url = $_GET['url'] ?? '';
$quiet = !empty($_GET['quiet']) ? '&quiet=1' : '';
if ($a->argc > 1 && intval($a->argv[1])) {
if (!Session::isAuthenticated() // Visitors (not logged in or not remotes) can't authenticate.
|| (!empty($a->contact['id']) && $a->contact['id'] == $cid)) // Local user is already authenticated.
{
- $a->redirect(defaults($url, $contact_url));
+ $a->redirect($url ?: $contact_url);
}
if ($contact['uid'] == 0 && local_user()) {
if (!empty($a->contact['id']) && $a->contact['id'] == $cid) {
// Local user is already authenticated.
- $target_url = defaults($url, $contact_url);
+ $target_url = $url ?: $contact_url;
Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG);
$a->redirect($target_url);
}
// contact.
if (($host == $remotehost) && (Session::getRemoteContactID(Session::get('visitor_visiting')) == Session::get('visitor_id'))) {
// Remote user is already authenticated.
- $target_url = defaults($url, $contact_url);
+ $target_url = $url ?: $contact_url;
Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG);
$a->redirect($target_url);
}
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest . $quiet);
}
- $url = defaults($url, $contact_url);
+ $url = $url ?: $contact_url;
}
// If we don't have a connected contact, redirect with
}
} else {
$contact_url = $contact['url'];
- $target_url = defaults($url, $contact_url);
+ $target_url = $url ?: $contact_url;
}
$basepath = Contact::getBasepath($contact_url);
$user,
Config::get('config', 'sitename'),
$a->getBaseUrl(),
- defaults($register, 'password', 'Sent in a previous email')
+ ($register['password'] ?? '') ?: 'Sent in a previous email'
);
L10n::popLang();
$theme = Strings::sanitizeFilePathItem($theme);
$a = \get_app();
- $base_theme = defaults($a->theme_info, 'extends');
+ $base_theme = $a->theme_info['extends'] ?? '';
if (file_exists("view/theme/$theme/config.php")) {
return "view/theme/$theme/config.php";
if (($a->argc > 2) && ($a->argv[1] === 'oauth') && ($a->argv[2] === 'edit'||($a->argv[2] === 'add')) && !empty($_POST['submit'])) {
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth');
- $name = defaults($_POST, 'name' , '');
- $key = defaults($_POST, 'key' , '');
- $secret = defaults($_POST, 'secret' , '');
- $redirect = defaults($_POST, 'redirect', '');
- $icon = defaults($_POST, 'icon' , '');
+ $name = $_POST['name'] ?? '';
+ $key = $_POST['key'] ?? '';
+ $secret = $_POST['secret'] ?? '';
+ $redirect = $_POST['redirect'] ?? '';
+ $icon = $_POST['icon'] ?? '';
if ($name == "" || $key == "" || $secret == "") {
notice(L10n::t("Missing some important data!"));
PConfig::set(local_user(), 'ostatus', 'default_group', $_POST['group-selection']);
PConfig::set(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']);
} elseif (!empty($_POST['imap-submit'])) {
-
- $mail_server = defaults($_POST, 'mail_server', '');
- $mail_port = defaults($_POST, 'mail_port', '');
- $mail_ssl = (!empty($_POST['mail_ssl']) ? strtolower(trim($_POST['mail_ssl'])) : '');
- $mail_user = defaults($_POST, 'mail_user', '');
- $mail_pass = (!empty($_POST['mail_pass']) ? trim($_POST['mail_pass']) : '');
- $mail_action = (!empty($_POST['mail_action']) ? trim($_POST['mail_action']) : '');
- $mail_movetofolder = (!empty($_POST['mail_movetofolder']) ? trim($_POST['mail_movetofolder']) : '');
- $mail_replyto = defaults($_POST, 'mail_replyto', '');
- $mail_pubmail = defaults($_POST, 'mail_pubmail', '');
-
-
- $mail_disabled = ((function_exists('imap_open') && (!Config::get('system', 'imap_disabled'))) ? 0 : 1);
- if (Config::get('system', 'dfrn_only')) {
- $mail_disabled = 1;
- }
-
- if (!$mail_disabled) {
+ $mail_server = $_POST['mail_server'] ?? '';
+ $mail_port = $_POST['mail_port'] ?? '';
+ $mail_ssl = strtolower(trim($_POST['mail_ssl'] ?? ''));
+ $mail_user = $_POST['mail_user'] ?? '';
+ $mail_pass = trim($_POST['mail_pass'] ?? '');
+ $mail_action = trim($_POST['mail_action'] ?? '');
+ $mail_movetofolder = trim($_POST['mail_movetofolder'] ?? '');
+ $mail_replyto = $_POST['mail_replyto'] ?? '';
+ $mail_pubmail = $_POST['mail_pubmail'] ?? '';
+
+ if (
+ !Config::get('system', 'dfrn_only')
+ && function_exists('imap_open')
+ && !Config::get('system', 'imap_disabled')
+ ) {
$failed = false;
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval(local_user())
}
$tags = [];
- foreach (defaults($_POST, 'tag', []) as $tag) {
+ foreach ($_POST['tag'] ?? [] as $tag) {
$tags[] = hex2bin(Strings::escapeTags(trim($tag)));
}
- $item_id = defaults($_POST,'item', 0);
+ $item_id = $_POST['item'] ?? 0;
update_tags($item_id, $tags);
info(L10n::t('Tag(s) removed') . EOL);
}
$uid = local_user();
- $url = Strings::escapeTags(trim(defaults($_REQUEST, 'url', '')));
+ $url = Strings::escapeTags(trim($_REQUEST['url'] ?? ''));
$condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
$uid, Contact::SHARING, Contact::FRIEND, Strings::normaliseLink($url),
$vcard_widget = Renderer::replaceMacros($tpl, [
'$name' => $profile['name'],
'$photo' => $profile['photo'],
- '$addr' => defaults($profile, 'addr', ''),
+ '$addr' => $profile['addr'] ?? '',
'$account_type' => $account_type,
- '$pdesc' => defaults($profile, 'pdesc', ''),
+ '$pdesc' => $profile['pdesc'] ?? '',
]);
// If not there, create 'aside' empty
'$subject' => L10n::t('Subject:'),
'$recipname' => $user['username'],
'$nickname' => $user['nickname'],
- '$subjtxt' => defaults($_REQUEST, 'subject', ''),
- '$text' => defaults($_REQUEST, 'body', ''),
+ '$subjtxt' => $_REQUEST['subject'] ?? '',
+ '$text' => $_REQUEST['body'] ?? '',
'$readonly' => '',
'$yourmessage'=> L10n::t('Your message:'),
'$parent' => '',
use Friendica\Core;
use Friendica\LegacyModule;
use Friendica\Module\Home;
-use Friendica\Module\PageNotFound;
+use Friendica\Module\HTTPException\MethodNotAllowed;
+use Friendica\Module\HTTPException\PageNotFound;
+use Friendica\Network\HTTPException\MethodNotAllowedException;
+use Friendica\Network\HTTPException\NotFoundException;
use Psr\Log\LoggerInterface;
/**
{
$printNotAllowedAddon = false;
+ $module_class = null;
/**
* ROUTING
*
* From the request URL, routing consists of obtaining the name of a BaseModule-extending class of which the
* post() and/or content() static methods can be respectively called to produce a data change or an output.
**/
- $module_class = $router->getModuleClass($args->getCommand());
-
- // Then we try addon-provided modules that we wrap in the LegacyModule class
- if (!$module_class && Core\Addon::isEnabled($this->module) && file_exists("addon/{$this->module}/{$this->module}.php")) {
- //Check if module is an app and if public access to apps is allowed or not
- $privateapps = $config->get('config', 'private_addons', false);
- if ((!local_user()) && Core\Hook::isAddonApp($this->module) && $privateapps) {
- $printNotAllowedAddon = true;
- } else {
- include_once "addon/{$this->module}/{$this->module}.php";
- if (function_exists($this->module . '_module')) {
- LegacyModule::setModuleFile("addon/{$this->module}/{$this->module}.php");
- $module_class = LegacyModule::class;
+ try {
+ $module_class = $router->getModuleClass($args->getCommand());
+ } catch (MethodNotAllowedException $e) {
+ $module_class = MethodNotAllowed::class;
+ } catch (NotFoundException $e) {
+ // Then we try addon-provided modules that we wrap in the LegacyModule class
+ if (Core\Addon::isEnabled($this->module) && file_exists("addon/{$this->module}/{$this->module}.php")) {
+ //Check if module is an app and if public access to apps is allowed or not
+ $privateapps = $config->get('config', 'private_addons', false);
+ if ((!local_user()) && Core\Hook::isAddonApp($this->module) && $privateapps) {
+ $printNotAllowedAddon = true;
+ } else {
+ include_once "addon/{$this->module}/{$this->module}.php";
+ if (function_exists($this->module . '_module')) {
+ LegacyModule::setModuleFile("addon/{$this->module}/{$this->module}.php");
+ $module_class = LegacyModule::class;
+ }
}
}
- }
- /* Finally, we look for a 'standard' program module in the 'mod' directory
- * We emulate a Module class through the LegacyModule class
- */
- if (!$module_class && file_exists("mod/{$this->module}.php")) {
- LegacyModule::setModuleFile("mod/{$this->module}.php");
- $module_class = LegacyModule::class;
- }
+ /* Finally, we look for a 'standard' program module in the 'mod' directory
+ * We emulate a Module class through the LegacyModule class
+ */
+ if (!$module_class && file_exists("mod/{$this->module}.php")) {
+ LegacyModule::setModuleFile("mod/{$this->module}.php");
+ $module_class = LegacyModule::class;
+ }
- $module_class = !isset($module_class) ? PageNotFound::class : $module_class;
+ $module_class = $module_class ?: PageNotFound::class;
+ }
return new Module($this->module, $module_class, $this->isBackend, $printNotAllowedAddon);
}
use FastRoute\RouteCollector;
use FastRoute\RouteParser\Std;
use Friendica\Core\Hook;
-use Friendica\Network\HTTPException\InternalServerErrorException;
+use Friendica\Core\L10n;
+use Friendica\Network\HTTPException;
/**
* Wrapper for FastRoute\Router
*
* @return self The router instance with the loaded routes
*
- * @throws InternalServerErrorException In case of invalid configs
+ * @throws HTTPException\InternalServerErrorException In case of invalid configs
*/
public function addRoutes(array $routes)
{
} elseif ($this->isRoute($config)) {
$routeCollector->addRoute($config[1], $route, $config[0]);
} else {
- throw new InternalServerErrorException("Wrong route config for route '" . print_r($route, true) . "'");
+ throw new HTTPException\InternalServerErrorException("Wrong route config for route '" . print_r($route, true) . "'");
}
}
} elseif ($this->isRoute($config)) {
$routeCollector->addRoute($config[1], $route, $config[0]);
}else {
- throw new InternalServerErrorException("Wrong route config for route '" . print_r($route, true) . "'");
+ throw new HTTPException\InternalServerErrorException("Wrong route config for route '" . print_r($route, true) . "'");
}
}
});
*
* @param string $cmd The path component of the request URL without the query string
*
- * @return string|null A Friendica\BaseModule-extending class name if a route rule matched
+ * @return string A Friendica\BaseModule-extending class name if a route rule matched
+ *
+ * @throws HTTPException\InternalServerErrorException
+ * @throws HTTPException\MethodNotAllowedException If a rule matched but the method didn't
+ * @throws HTTPException\NotFoundException If no rule matched
*/
public function getModuleClass($cmd)
{
$routeInfo = $dispatcher->dispatch($this->httpMethod, $cmd);
if ($routeInfo[0] === Dispatcher::FOUND) {
$moduleClass = $routeInfo[1];
+ } elseif ($routeInfo[0] === Dispatcher::METHOD_NOT_ALLOWED) {
+ throw new HTTPException\MethodNotAllowedException(L10n::t('Method not allowed for this module. Allowed method(s): %s', implode(', ', $routeInfo[1])));
+ } else {
+ throw new HTTPException\NotFoundException(L10n::t('Page not found.'));
}
return $moduleClass;
'directory' => null,
'settings' => null,
'contacts' => null,
- 'manage' => null,
+ 'delegation'=> null,
'events' => null,
'register' => null
];
$nav['messages']['new'] = ['message/new', L10n::t('New Message'), '', L10n::t('New Message')];
if (is_array($a->identities) && count($a->identities) > 1) {
- $nav['manage'] = ['manage', L10n::t('Manage'), '', L10n::t('Manage other pages')];
+ $nav['delegation'] = ['delegation', L10n::t('Delegation'), '', L10n::t('Manage other pages')];
}
- $nav['delegations'] = ['settings/delegation', L10n::t('Delegations'), '', L10n::t('Delegate Page Management')];
-
$nav['settings'] = ['settings', L10n::t('Settings'), '', L10n::t('Account settings')];
if (Feature::isEnabled(local_user(), 'multi_profiles')) {
*
* @param string $body Message body
* @return array
- * 'type' -> Message type ("link", "video", "photo")
+ * 'type' -> Message type ('link', 'video', 'photo')
* 'text' -> Text before the shared message
* 'after' -> Text after the shared message
* 'image' -> Preview image of the message
if (preg_match_all("(\[class=(.*?)\](.*?)\[\/class\])ism", $body, $attached, PREG_SET_ORDER)) {
foreach ($attached as $data) {
- if (!in_array($data[1], ["type-link", "type-video", "type-photo"])) {
+ if (!in_array($data[1], ['type-link', 'type-video', 'type-photo'])) {
continue;
}
- $post["type"] = substr($data[1], 5);
+ $post['type'] = substr($data[1], 5);
$pos = strpos($body, $data[0]);
if ($pos > 0) {
- $post["text"] = trim(substr($body, 0, $pos));
- $post["after"] = trim(substr($body, $pos + strlen($data[0])));
+ $post['text'] = trim(substr($body, 0, $pos));
+ $post['after'] = trim(substr($body, $pos + strlen($data[0])));
} else {
- $post["text"] = trim(str_replace($data[0], "", $body));
- $post["after"] = '';
+ $post['text'] = trim(str_replace($data[0], '', $body));
+ $post['after'] = '';
}
$attacheddata = $data[2];
if ($picturedata) {
if (($picturedata[0] >= 500) && ($picturedata[0] >= $picturedata[1])) {
- $post["image"] = $matches[1];
+ $post['image'] = $matches[1];
} else {
- $post["preview"] = $matches[1];
+ $post['preview'] = $matches[1];
}
}
}
if (preg_match("/\[bookmark\=(.*?)\](.*?)\[\/bookmark\]/ism", $attacheddata, $matches)) {
- $post["url"] = $matches[1];
- $post["title"] = $matches[2];
+ $post['url'] = $matches[1];
+ $post['title'] = $matches[2];
}
- if (!empty($post["url"]) && (in_array($post["type"], ["link", "video"]))
+ if (!empty($post['url']) && (in_array($post['type'], ['link', 'video']))
&& preg_match("/\[url\=(.*?)\](.*?)\[\/url\]/ism", $attacheddata, $matches)) {
- $post["url"] = $matches[1];
+ $post['url'] = $matches[1];
}
// Search for description
if (preg_match("/\[quote\](.*?)\[\/quote\]/ism", $attacheddata, $matches)) {
- $post["description"] = $matches[1];
+ $post['description'] = $matches[1];
}
}
}
*
* @param string $body Message body
* @return array
- * 'type' -> Message type ("link", "video", "photo")
+ * 'type' -> Message type ('link', 'video', 'photo')
* 'text' -> Text before the shared message
* 'after' -> Text after the shared message
* 'image' -> Preview image of the message
$attributes = $match[2];
- $data["text"] = trim($match[1]);
+ $data['text'] = trim($match[1]);
- $type = "";
+ $type = '';
preg_match("/type='(.*?)'/ism", $attributes, $matches);
if (!empty($matches[1])) {
$type = strtolower($matches[1]);
$type = strtolower($matches[1]);
}
- if ($type == "") {
+ if ($type == '') {
return [];
}
- if (!in_array($type, ["link", "audio", "photo", "video"])) {
+ if (!in_array($type, ['link', 'audio', 'photo', 'video'])) {
return [];
}
- if ($type != "") {
- $data["type"] = $type;
+ if ($type != '') {
+ $data['type'] = $type;
}
- $url = "";
+ $url = '';
preg_match("/url='(.*?)'/ism", $attributes, $matches);
if (!empty($matches[1])) {
$url = $matches[1];
$url = $matches[1];
}
- if ($url != "") {
- $data["url"] = html_entity_decode($url, ENT_QUOTES, 'UTF-8');
+ if ($url != '') {
+ $data['url'] = html_entity_decode($url, ENT_QUOTES, 'UTF-8');
}
- $title = "";
+ $title = '';
preg_match("/title='(.*?)'/ism", $attributes, $matches);
if (!empty($matches[1])) {
$title = $matches[1];
$title = $matches[1];
}
- if ($title != "") {
+ if ($title != '') {
$title = self::convert(html_entity_decode($title, ENT_QUOTES, 'UTF-8'), false, true);
$title = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
- $title = str_replace(["[", "]"], ["[", "]"], $title);
- $data["title"] = $title;
+ $title = str_replace(['[', ']'], ['[', ']'], $title);
+ $data['title'] = $title;
}
- $image = "";
+ $image = '';
preg_match("/image='(.*?)'/ism", $attributes, $matches);
if (!empty($matches[1])) {
$image = $matches[1];
$image = $matches[1];
}
- if ($image != "") {
- $data["image"] = html_entity_decode($image, ENT_QUOTES, 'UTF-8');
+ if ($image != '') {
+ $data['image'] = html_entity_decode($image, ENT_QUOTES, 'UTF-8');
}
- $preview = "";
+ $preview = '';
preg_match("/preview='(.*?)'/ism", $attributes, $matches);
if (!empty($matches[1])) {
$preview = $matches[1];
$preview = $matches[1];
}
- if ($preview != "") {
- $data["preview"] = html_entity_decode($preview, ENT_QUOTES, 'UTF-8');
+ if ($preview != '') {
+ $data['preview'] = html_entity_decode($preview, ENT_QUOTES, 'UTF-8');
}
- $data["description"] = trim($match[3]);
+ $data['description'] = trim($match[3]);
- $data["after"] = trim($match[4]);
+ $data['after'] = trim($match[4]);
return $data;
}
}
// if nothing is found, it maybe having an image.
- if (!isset($post["type"])) {
+ if (!isset($post['type'])) {
// Simplify image codes
$body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
$body = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", '[img]$1[/img]', $body);
- $post["text"] = $body;
+ $post['text'] = $body;
if (preg_match_all("(\[url=(.*?)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\])ism", $body, $pictures, PREG_SET_ORDER)) {
if ((count($pictures) == 1) && !$has_title) {
// Workaround:
// Sometimes photo posts to the own album are not detected at the start.
// So we seem to cannot use the cache for these cases. That's strange.
- if (($data["type"] != "photo") && strstr($pictures[0][1], "/photos/")) {
+ if (($data['type'] != 'photo') && strstr($pictures[0][1], "/photos/")) {
$data = ParseUrl::getSiteinfo($pictures[0][1], true);
}
- if ($data["type"] == "photo") {
- $post["type"] = "photo";
- if (isset($data["images"][0])) {
- $post["image"] = $data["images"][0]["src"];
- $post["url"] = $data["url"];
+ if ($data['type'] == 'photo') {
+ $post['type'] = 'photo';
+ if (isset($data['images'][0])) {
+ $post['image'] = $data['images'][0]['src'];
+ $post['url'] = $data['url'];
} else {
- $post["image"] = $data["url"];
+ $post['image'] = $data['url'];
}
- $post["preview"] = $pictures[0][2];
- $post["text"] = trim(str_replace($pictures[0][0], "", $body));
+ $post['preview'] = $pictures[0][2];
+ $post['text'] = trim(str_replace($pictures[0][0], '', $body));
} else {
$imgdata = Image::getInfoFromURL($pictures[0][1]);
- if ($imgdata && substr($imgdata["mime"], 0, 6) == "image/") {
- $post["type"] = "photo";
- $post["image"] = $pictures[0][1];
- $post["preview"] = $pictures[0][2];
- $post["text"] = trim(str_replace($pictures[0][0], "", $body));
+ if ($imgdata && substr($imgdata['mime'], 0, 6) == 'image/') {
+ $post['type'] = 'photo';
+ $post['image'] = $pictures[0][1];
+ $post['preview'] = $pictures[0][2];
+ $post['text'] = trim(str_replace($pictures[0][0], '', $body));
}
}
} elseif (count($pictures) > 0) {
- $post["type"] = "link";
- $post["url"] = $plink;
- $post["image"] = $pictures[0][2];
- $post["text"] = $body;
+ $post['type'] = 'link';
+ $post['url'] = $plink;
+ $post['image'] = $pictures[0][2];
+ $post['text'] = $body;
foreach ($pictures as $picture) {
- $post["text"] = trim(str_replace($picture[0], "", $post["text"]));
+ $post['text'] = trim(str_replace($picture[0], '', $post['text']));
}
}
} elseif (preg_match_all("(\[img\](.*?)\[\/img\])ism", $body, $pictures, PREG_SET_ORDER)) {
if ((count($pictures) == 1) && !$has_title) {
- $post["type"] = "photo";
- $post["image"] = $pictures[0][1];
- $post["text"] = str_replace($pictures[0][0], "", $body);
+ $post['type'] = 'photo';
+ $post['image'] = $pictures[0][1];
+ $post['text'] = str_replace($pictures[0][0], '', $body);
} elseif (count($pictures) > 0) {
- $post["type"] = "link";
- $post["url"] = $plink;
- $post["image"] = $pictures[0][1];
- $post["text"] = $body;
+ $post['type'] = 'link';
+ $post['url'] = $plink;
+ $post['image'] = $pictures[0][1];
+ $post['text'] = $body;
foreach ($pictures as $picture) {
- $post["text"] = trim(str_replace($picture[0], "", $post["text"]));
+ $post['text'] = trim(str_replace($picture[0], '', $post['text']));
}
}
}
// Test for the external links
- preg_match_all("(\[url\](.*?)\[\/url\])ism", $post["text"], $links1, PREG_SET_ORDER);
- preg_match_all("(\[url\=(.*?)\].*?\[\/url\])ism", $post["text"], $links2, PREG_SET_ORDER);
+ preg_match_all("(\[url\](.*?)\[\/url\])ism", $post['text'], $links1, PREG_SET_ORDER);
+ preg_match_all("(\[url\=(.*?)\].*?\[\/url\])ism", $post['text'], $links2, PREG_SET_ORDER);
$links = array_merge($links1, $links2);
// If there is only a single one, then use it.
// This should cover link posts via API.
- if ((count($links) == 1) && !isset($post["preview"]) && !$has_title) {
- $post["type"] = "link";
- $post["url"] = $links[0][1];
+ if ((count($links) == 1) && !isset($post['preview']) && !$has_title) {
+ $post['type'] = 'link';
+ $post['url'] = $links[0][1];
}
// Now count the number of external media links
- preg_match_all("(\[vimeo\](.*?)\[\/vimeo\])ism", $post["text"], $links1, PREG_SET_ORDER);
- preg_match_all("(\[youtube\\](.*?)\[\/youtube\\])ism", $post["text"], $links2, PREG_SET_ORDER);
- preg_match_all("(\[video\\](.*?)\[\/video\\])ism", $post["text"], $links3, PREG_SET_ORDER);
- preg_match_all("(\[audio\\](.*?)\[\/audio\\])ism", $post["text"], $links4, PREG_SET_ORDER);
+ preg_match_all("(\[vimeo\](.*?)\[\/vimeo\])ism", $post['text'], $links1, PREG_SET_ORDER);
+ preg_match_all("(\[youtube\\](.*?)\[\/youtube\\])ism", $post['text'], $links2, PREG_SET_ORDER);
+ preg_match_all("(\[video\\](.*?)\[\/video\\])ism", $post['text'], $links3, PREG_SET_ORDER);
+ preg_match_all("(\[audio\\](.*?)\[\/audio\\])ism", $post['text'], $links4, PREG_SET_ORDER);
// Add them to the other external links
$links = array_merge($links, $links1, $links2, $links3, $links4);
// Are there more than one?
if (count($links) > 1) {
// The post will be the type "text", which means a blog post
- unset($post["type"]);
- $post["url"] = $plink;
+ unset($post['type']);
+ $post['url'] = $plink;
}
- if (!isset($post["type"])) {
- $post["type"] = "text";
- $post["text"] = trim($body);
+ if (!isset($post['type'])) {
+ $post['type'] = "text";
+ $post['text'] = trim($body);
}
- } elseif (isset($post["url"]) && ($post["type"] == "video")) {
- $data = ParseUrl::getSiteinfoCached($post["url"], true);
+ } elseif (isset($post['url']) && ($post['type'] == 'video')) {
+ $data = ParseUrl::getSiteinfoCached($post['url'], true);
- if (isset($data["images"][0])) {
- $post["image"] = $data["images"][0]["src"];
+ if (isset($data['images'][0])) {
+ $post['image'] = $data['images'][0]['src'];
}
}
private static function convertAttachment($return, $simplehtml = false, $tryoembed = true)
{
$data = self::getAttachmentData($return);
- if (empty($data) || empty($data["url"])) {
+ if (empty($data) || empty($data['url'])) {
return $return;
}
- if (isset($data["title"])) {
- $data["title"] = strip_tags($data["title"]);
- $data["title"] = str_replace(["http://", "https://"], "", $data["title"]);
+ if (isset($data['title'])) {
+ $data['title'] = strip_tags($data['title']);
+ $data['title'] = str_replace(['http://', 'https://'], '', $data['title']);
} else {
- $data["title"] = null;
+ $data['title'] = null;
}
- if (((strpos($data["text"], "[img=") !== false) || (strpos($data["text"], "[img]") !== false) || Config::get('system', 'always_show_preview')) && !empty($data["image"])) {
- $data["preview"] = $data["image"];
- $data["image"] = "";
+ if (((strpos($data['text'], "[img=") !== false) || (strpos($data['text'], "[img]") !== false) || Config::get('system', 'always_show_preview')) && !empty($data['image'])) {
+ $data['preview'] = $data['image'];
+ $data['image'] = '';
}
$return = '';
if (in_array($simplehtml, [7, 9])) {
- $return = self::convertUrlForOStatus($data["url"]);
+ $return = self::convertUrlForActivityPub($data['url']);
} elseif (($simplehtml != 4) && ($simplehtml != 0)) {
- $return = sprintf('<a href="%s" target="_blank">%s</a><br>', $data["url"], $data["title"]);
+ $return = sprintf('<a href="%s" target="_blank">%s</a><br>', $data['url'], $data['title']);
} else {
try {
if ($tryoembed && OEmbed::isAllowedURL($data['url'])) {
throw new Exception('OEmbed is disabled for this attachment.');
}
} catch (Exception $e) {
- $data["title"] = defaults($data, 'title', $data['url']);
+ $data['title'] = defaults($data, 'title', $data['url']);
if ($simplehtml != 4) {
- $return = sprintf('<div class="type-%s">', $data["type"]);
+ $return = sprintf('<div class="type-%s">', $data['type']);
}
if (!empty($data['title']) && !empty($data['url'])) {
- if (!empty($data["image"]) && empty($data["text"]) && ($data["type"] == "photo")) {
- $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a>', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
+ if (!empty($data['image']) && empty($data['text']) && ($data['type'] == 'photo')) {
+ $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a>', $data['url'], self::proxyUrl($data['image'], $simplehtml), $data['title']);
} else {
- if (!empty($data["image"])) {
- $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
- } elseif (!empty($data["preview"])) {
- $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]);
+ if (!empty($data['image'])) {
+ $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $data['url'], self::proxyUrl($data['image'], $simplehtml), $data['title']);
+ } elseif (!empty($data['preview'])) {
+ $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $data['url'], self::proxyUrl($data['preview'], $simplehtml), $data['title']);
}
$return .= sprintf('<h4><a href="%s">%s</a></h4>', $data['url'], $data['title']);
}
}
- if (!empty($data["description"]) && $data["description"] != $data["title"]) {
+ if (!empty($data['description']) && $data['description'] != $data['title']) {
// Sanitize the HTML by converting it to BBCode
- $bbcode = HTML::toBBCode($data["description"]);
+ $bbcode = HTML::toBBCode($data['description']);
$return .= sprintf('<blockquote>%s</blockquote>', trim(self::convert($bbcode)));
}
if (!$data) {
return $Text;
} elseif ($nolink) {
- return $data["text"] . defaults($data, 'after', '');
+ return $data['text'] . defaults($data, 'after', '');
}
$title = htmlentities(defaults($data, 'title', ''), ENT_QUOTES, 'UTF-8', false);
- $text = htmlentities($data["text"], ENT_QUOTES, 'UTF-8', false);
- if ($plaintext || (($title != "") && strstr($text, $title))) {
- $data["title"] = $data["url"];
- } elseif (($text != "") && strstr($title, $text)) {
- $data["text"] = $data["title"];
- $data["title"] = $data["url"];
+ $text = htmlentities($data['text'], ENT_QUOTES, 'UTF-8', false);
+ if ($plaintext || (($title != '') && strstr($text, $title))) {
+ $data['title'] = $data['url'];
+ } elseif (($text != '') && strstr($title, $text)) {
+ $data['text'] = $data['title'];
+ $data['title'] = $data['url'];
}
- if (empty($data["text"]) && !empty($data["title"]) && empty($data["url"])) {
- return $data["title"] . $data["after"];
+ if (empty($data['text']) && !empty($data['title']) && empty($data['url'])) {
+ return $data['title'] . $data['after'];
}
// If the link already is included in the post, don't add it again
- if (!empty($data["url"]) && strpos($data["text"], $data["url"])) {
- return $data["text"] . $data["after"];
+ if (!empty($data['url']) && strpos($data['text'], $data['url'])) {
+ return $data['text'] . $data['after'];
}
- $text = $data["text"];
+ $text = $data['text'];
- if (!empty($data["url"]) && !empty($data["title"])) {
- $text .= "\n[url=" . $data["url"] . "]" . $data["title"] . "[/url]";
- } elseif (!empty($data["url"])) {
- $text .= "\n[url]" . $data["url"] . "[/url]";
+ if (!empty($data['url']) && !empty($data['title'])) {
+ $text .= "\n[url=" . $data['url'] . ']' . $data['title'] . '[/url]';
+ } elseif (!empty($data['url'])) {
+ $text .= "\n[url]" . $data['url'] . '[/url]';
}
- return $text . "\n" . $data["after"];
+ return $text . "\n" . $data['after'];
}
/**
* @param array $match Array with the matching values
* @return string reformatted link including HTML codes
*/
- private static function convertUrlForOStatusCallback($match)
+ private static function convertUrlForActivityPubCallback($match)
{
$url = $match[1];
return $match[0];
}
- return self::convertUrlForOStatus($url);
+ return self::convertUrlForActivityPub($url);
}
/**
- * @brief Converts [url] BBCodes in a format that looks fine on OStatus systems.
+ * @brief Converts [url] BBCodes in a format that looks fine on ActivityPub systems.
* @param string $url URL that is about to be reformatted
* @return string reformatted link including HTML codes
*/
- private static function convertUrlForOStatus($url)
+ private static function convertUrlForActivityPub($url)
+ {
+ $html = '<a href="%s" target="_blank">%s</a>';
+ return sprintf($html, $url, self::getStyledURL($url));
+ }
+
+ /**
+ * Converts an URL in a nicer format (without the scheme and possibly shortened)
+ * @param string $url URL that is about to be reformatted
+ * @return string reformatted link
+ */
+ private static function getStyledURL($url)
{
$parts = parse_url($url);
$scheme = $parts['scheme'] . '://';
$styled_url = substr($styled_url, 0, 30) . "…";
}
- $html = '<a href="%s" target="_blank">%s</a>';
-
- return sprintf($html, $url, $styled_url);
+ return $styled_url;
}
/*
$a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack());
- if (substr($curl_info["content_type"], 0, 6) == "image/") {
- $text = "[url=" . $match[1] . "]" . $match[1] . "[/url]";
+ if (substr($curl_info['content_type'], 0, 6) == 'image/') {
+ $text = "[url=" . $match[1] . ']' . $match[1] . "[/url]";
} else {
- $text = "[url=" . $match[2] . "]" . $match[2] . "[/url]";
+ $text = "[url=" . $match[2] . ']' . $match[2] . "[/url]";
// if its not a picture then look if its a page that contains a picture link
$body = Network::fetchUrl($match[1]);
}
}
- if (strtolower($attr["name"]) == "twitter:image") {
- $text = "[url=" . $attr["content"] . "]" . $attr["content"] . "[/url]";
+ if (strtolower($attr['name']) == 'twitter:image') {
+ $text = '[url=' . $attr['content'] . ']' . $attr['content'] . '[/url]';
}
}
}
private static function expandLinksCallback($match)
{
- if (($match[3] == "") || ($match[2] == $match[3]) || stristr($match[2], $match[3])) {
+ if (($match[3] == '') || ($match[2] == $match[3]) || stristr($match[2], $match[3])) {
return ($match[1] . "[url]" . $match[2] . "[/url]");
} else {
return ($match[1] . $match[3] . " [url]" . $match[2] . "[/url]");
$own_photo_url = preg_quote(Strings::normaliseLink($a->getBaseURL()) . '/photos/');
if (preg_match('|' . $own_photo_url . '.*?/image/|', Strings::normaliseLink($match[1]))) {
if (!empty($match[3])) {
- $text = "[img=" . str_replace('-1.', '-0.', $match[2]) . "]" . $match[3] . "[/img]";
+ $text = '[img=' . str_replace('-1.', '-0.', $match[2]) . ']' . $match[3] . '[/img]';
} else {
- $text = "[img]" . str_replace('-1.', '-0.', $match[2]) . "[/img]";
+ $text = '[img]' . str_replace('-1.', '-0.', $match[2]) . '[/img]';
}
return $text;
}
$a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack());
// if its a link to a picture then embed this picture
- if (substr($curl_info["content_type"], 0, 6) == "image/") {
- $text = "[img]" . $match[1] . "[/img]";
+ if (substr($curl_info['content_type'], 0, 6) == 'image/') {
+ $text = '[img]' . $match[1] . '[/img]';
} else {
if (!empty($match[3])) {
- $text = "[img=" . $match[2] . "]" . $match[3] . "[/img]";
+ $text = '[img=' . $match[2] . ']' . $match[3] . '[/img]';
} else {
- $text = "[img]" . $match[2] . "[/img]";
+ $text = '[img]' . $match[2] . '[/img]';
}
// if its not a picture then look if its a page that contains a picture link
}
}
- if (strtolower($attr["name"]) == "twitter:image") {
+ if (strtolower($attr['name']) == "twitter:image") {
if (!empty($match[3])) {
- $text = "[img=" . $attr["content"] . "]" . $match[3] . "[/img]";
+ $text = "[img=" . $attr['content'] . "]" . $match[3] . "[/img]";
} else {
- $text = "[img]" . $attr["content"] . "[/img]";
+ $text = "[img]" . $attr['content'] . "[/img]";
}
}
}
$text = str_replace($search, $replace, $text);
// removing multiplicated newlines
- if (Config::get("system", "remove_multiplicated_lines")) {
+ if (Config::get('system', 'remove_multiplicated_lines')) {
$search = ["\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n",
"\n[h1]", "[/h1]\n", "\n[h2]", "[/h2]\n", "\n[h3]", "[/h3]\n", "\n[h4]", "[/h4]\n", "\n[h5]", "[/h5]\n", "\n[h6]", "[/h6]\n"];
$replace = ["\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]", "\n[share ", "[/attachment]",
if (!$for_plaintext) {
if (in_array($simple_html, [7, 9])) {
- $text = preg_replace_callback("/\[url\](.*?)\[\/url\]/ism", 'self::convertUrlForOStatusCallback', $text);
- $text = preg_replace_callback("/\[url\=(.*?)\](.*?)\[\/url\]/ism", 'self::convertUrlForOStatusCallback', $text);
+ $text = preg_replace_callback("/\[url\](.*?)\[\/url\]/ism", 'self::convertUrlForActivityPubCallback', $text);
+ $text = preg_replace_callback("/\[url\=(.*?)\](.*?)\[\/url\]/ism", 'self::convertUrlForActivityPubCallback', $text);
}
} else {
$text = preg_replace("(\[url\](.*?)\[\/url\])ism", " $1 ", $text);
// Clean up the HTML by loading and saving the HTML with the DOM.
// Bad structured html can break a whole page.
// For performance reasons do it only with activated item cache or at export.
- if (!$try_oembed || (get_itemcachepath() != "")) {
+ if (!$try_oembed || (get_itemcachepath() != '')) {
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
$doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">';
$encoding = '<?xml encoding="UTF-8">';
- @$doc->loadHTML($encoding.$doctype."<html><body>".$text."</body></html>");
+ @$doc->loadHTML($encoding . $doctype . '<html><body>' . $text . '</body></html>');
$doc->encoding = 'UTF-8';
$text = $doc->saveHTML();
- $text = str_replace(["<html><body>", "</body></html>", $doctype, $encoding], ["", "", "", ""], $text);
+ $text = str_replace(['<html><body>', '</body></html>', $doctype, $encoding], ['', '', '', ''], $text);
$text = str_replace('<br></li>', '</li>', $text);
* @param string $addon The addon for which the abstract is meant for
* @return string The abstract
*/
- public static function getAbstract($text, $addon = "")
+ public static function getAbstract($text, $addon = '')
{
- $abstract = "";
+ $abstract = '';
$abstracts = [];
$addon = strtolower($addon);
$abstract = $abstracts[$addon];
}
- if ($abstract == "" && preg_match("/\[abstract\](.*?)\[\/abstract\]/ism", $text, $result)) {
+ if ($abstract == '' && preg_match("/\[abstract\](.*?)\[\/abstract\]/ism", $text, $result)) {
$abstract = $result[1];
}
// Add all tags that maybe were removed
if (preg_match_all("/#\[url\=([$url_search_string]*)\](.*?)\[\/url\]/ism", $original_text, $tags)) {
- $tagline = "";
+ $tagline = '';
foreach ($tags[2] as $tag) {
$tag = html_entity_decode($tag, ENT_QUOTES, 'UTF-8');
if (!strpos(html_entity_decode($text, ENT_QUOTES, 'UTF-8'), '#' . $tag)) {
// If a link is followed by a quote then there should be a newline before it
// Maybe we should make this newline at every time before a quote.
- $text = str_replace(["</a><blockquote>"], ["</a><br><blockquote>"], $text);
+ $text = str_replace(['</a><blockquote>'], ['</a><br><blockquote>'], $text);
$stamp1 = microtime(true);
'$save_label' => $save_label,
'$search_hint' => L10n::t('@name, !forum, #tags, content'),
'$mode' => $mode,
- '$return_url' => urlencode('search?q=' . $s),
+ '$return_url' => urlencode('search?q=' . urlencode($s)),
];
if (!$aside) {
self::TRACE => 'Trace',
self::DEBUG => 'Debug',
self::DATA => 'Data',
- self::ALL => 'All',
];
/**
*
* @param string $password
* @return bool
+ * @throws Exception
*/
public static function isPasswordExposed($password)
{
'cacheDirectory' => get_temppath() . '/password-exposed-cache/',
]);
- $PasswordExposedCHecker = new PasswordExposed\PasswordExposedChecker(null, $cache);
+ try {
+ $passwordExposedChecker = new PasswordExposed\PasswordExposedChecker(null, $cache);
+
+ return $passwordExposedChecker->passwordExposed($password) === PasswordExposed\PasswordStatus::EXPOSED;
+ } catch (\Exception $e) {
+ Logger::error('Password Exposed Exception: ' . $e->getMessage(), [
+ 'code' => $e->getCode(),
+ 'file' => $e->getFile(),
+ 'line' => $e->getLine(),
+ 'trace' => $e->getTraceAsString()
+ ]);
- return $PasswordExposedCHecker->passwordExposed($password) === PasswordExposed\PasswordStatus::EXPOSED;
+ return false;
+ }
}
/**
--- /dev/null
+<?php
+
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Core\Hook;
+use Friendica\Core\L10n;
+use Friendica\Core\Renderer;
+use Friendica\Core\Session;
+use Friendica\Database\DBA;
+use Friendica\Model\Contact;
+use Friendica\Model\User;
+use Friendica\Network\HTTPException\ForbiddenException;
+
+/**
+ * Switches current user between delegates/parent user
+ */
+class Delegation extends BaseModule
+{
+ public static function post()
+ {
+ if (!local_user()) {
+ return;
+ }
+
+ $uid = local_user();
+ $orig_record = self::getApp()->user;
+
+ if (Session::get('submanage')) {
+ $user = User::getById(Session::get('submanage'));
+ if (DBA::isResult($user)) {
+ $uid = intval($user['uid']);
+ $orig_record = $user;
+ }
+ }
+
+ $identity = intval($_POST['identity'] ?? 0);
+ if (!$identity) {
+ return;
+ }
+
+ $limited_id = 0;
+ $original_id = $uid;
+
+ $manages = DBA::selectToArray('manage', ['mid'], ['uid' => $uid]);
+ foreach ($manages as $manage) {
+ if ($identity == $manage['mid']) {
+ $limited_id = $manage['mid'];
+ break;
+ }
+ }
+
+ if ($limited_id) {
+ $user = User::getById($limited_id);
+ } else {
+ // Check if the target user is one of our children
+ $user = DBA::selectFirst('user', [], ['uid' => $identity, 'parent-uid' => $orig_record['uid']]);
+
+ // Check if the target user is one of our siblings
+ if (!DBA::isResult($user) && ($orig_record['parent-uid'] != 0)) {
+ $user = DBA::selectFirst('user', [], ['uid' => $identity, 'parent-uid' => $orig_record['parent-uid']]);
+ }
+
+ // Check if it's our parent or our own user
+ if (!DBA::isResult($user)
+ && (
+ $orig_record['parent-uid'] != 0 && $orig_record['parent-uid'] == $identity
+ ||
+ $orig_record['uid'] != 0 && $orig_record['uid'] == $identity
+ )
+ ) {
+ $user = User::getById($identity);
+ }
+ }
+
+ if (!DBA::isResult($user)) {
+ return;
+ }
+
+ Session::clear();
+
+ Session::setAuthenticatedForUser(self::getApp(), $user, true, true);
+
+ if ($limited_id) {
+ Session::set('submanage', $original_id);
+ }
+
+ $ret = [];
+ Hook::callAll('home_init', $ret);
+
+ self::getApp()->internalRedirect('profile/' . self::getApp()->user['nickname']);
+ // NOTREACHED
+ }
+
+ public static function content()
+ {
+ if (!local_user()) {
+ throw new ForbiddenException(L10n::t('Permission denied.'));
+ }
+
+ $identities = self::getApp()->identities;
+
+ //getting additinal information for each identity
+ foreach ($identities as $key => $identity) {
+ $thumb = Contact::selectFirst(['thumb'], ['uid' => $identity['uid'], 'self' => true]);
+ if (!DBA::isResult($thumb)) {
+ continue;
+ }
+
+ $identities[$key]['thumb'] = $thumb['thumb'];
+
+ $identities[$key]['selected'] = ($identity['nickname'] === self::getApp()->user['nickname']);
+
+ $condition = ["`uid` = ? AND `msg` != '' AND NOT (`type` IN (?, ?)) AND NOT `seen`", $identity['uid'], NOTIFY_INTRO, NOTIFY_MAIL];
+ $params = ['distinct' => true, 'expression' => 'parent'];
+ $notifications = DBA::count('notify', $condition, $params);
+
+ $params = ['distinct' => true, 'expression' => 'convid'];
+ $notifications += DBA::count('mail', ['uid' => $identity['uid'], 'seen' => false], $params);
+
+ $notifications += DBA::count('intro', ['blocked' => false, 'ignore' => false, 'uid' => $identity['uid']]);
+
+ $identities[$key]['notifications'] = $notifications;
+ }
+
+ $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('delegation.tpl'), [
+ '$title' => L10n::t('Manage Identities and/or Pages'),
+ '$desc' => L10n::t('Toggle between different identities or community/group pages which share your account details or which you have been granted "manage" permissions'),
+ '$choose' => L10n::t('Select an identity to manage: '),
+ '$identities' => $identities,
+ '$submit' => L10n::t('Submit'),
+ ]);
+
+ return $o;
+ }
+}
--- /dev/null
+<?php
+
+namespace Friendica\Module\HTTPException;
+
+use Friendica\BaseModule;
+use Friendica\Core\L10n;
+use Friendica\Network\HTTPException;
+
+class MethodNotAllowed extends BaseModule
+{
+ public static function content()
+ {
+ throw new HTTPException\MethodNotAllowedException(L10n::t('Method Not Allowed.'));
+ }
+}
--- /dev/null
+<?php
+
+namespace Friendica\Module\HTTPException;
+
+use Friendica\BaseModule;
+use Friendica\Core\L10n;
+use Friendica\Network\HTTPException;
+
+class PageNotFound extends BaseModule
+{
+ public static function content()
+ {
+ throw new HTTPException\NotFoundException(L10n::t('Page not found.'));
+ }
+}
+++ /dev/null
-<?php
-
-namespace Friendica\Module;
-
-use Friendica\BaseModule;
-use Friendica\Core\L10n;
-use Friendica\Network\HTTPException;
-
-class PageNotFound extends BaseModule
-{
- public static function content()
- {
- throw new HTTPException\NotFoundException(L10n::t('Page not found.'));
- }
-}
}
if (local_user()) {
- self::getApp()->page['aside'] .= Widget\SavedSearches::getHTML('search?q=' . $search, $search);
+ self::getApp()->page['aside'] .= Widget\SavedSearches::getHTML('search?q=' . urlencode($search), $search);
}
Nav::setSelected('search');
class Saved extends BaseModule
{
- public static function rawContent()
+ public static function init()
{
/** @var Arguments $args */
$args = self::getClass(Arguments::class);
$action = $args->get(2, 'none');
- $search = Strings::escapeTags(trim(rawurldecode($args->get(3, ''))));
+ $search = Strings::escapeTags(trim(rawurldecode($_GET['term'] ?? '')));
$return_url = $_GET['return_url'] ?? 'search?q=' . urlencode($search);
- if (local_user()) {
+ if (local_user() && $search) {
switch ($action) {
case 'add':
$fields = ['uid' => local_user(), 'term' => $search];
'/ignored' => [Module\Contact::class, [R::GET]],
],
'/credits' => [Module\Credits::class, [R::GET]],
+ '/delegation'=> [Module\Delegation::class, [R::GET, R::POST]],
'/dirfind' => [Module\Search\Directory::class, [R::GET]],
'/directory' => [Module\Directory::class, [R::GET]],
'/search' => [
'[/]' => [Module\Search\Index::class, [R::GET]],
'/acl' => [Module\Search\Acl::class, [R::GET, R::POST]],
- '/saved/add/{term}' => [Module\Search\Saved::class, [R::GET]],
- '/saved/remove/{term}' => [Module\Search\Saved::class, [R::GET]],
+ '/saved/add' => [Module\Search\Saved::class, [R::GET]],
+ '/saved/remove' => [Module\Search\Saved::class, [R::GET]],
],
'/settings' => [
use Friendica\App;
use Friendica\Core\Config\Configuration;
use Friendica\LegacyModule;
-use Friendica\Module\PageNotFound;
+use Friendica\Module\HTTPException\PageNotFound;
use Friendica\Module\WellKnown\HostMeta;
use Friendica\Test\DatabaseTest;
{
$module = new App\Module();
- $moduleNew = $module->determineModule(new App\Arguments(), []);
+ $moduleNew = $module->determineModule(new App\Arguments());
$this->assertNotSame($moduleNew, $module);
}
use Friendica\App\Router;
use Friendica\Module;
+use Friendica\Network\HTTPException\MethodNotAllowedException;
+use Friendica\Network\HTTPException\NotFoundException;
use PHPUnit\Framework\TestCase;
class RouterTest extends TestCase
{
public function testGetModuleClass()
{
- $router = new Router(['GET']);
+ $router = new Router(['REQUEST_METHOD' => Router::GET]);
$routeCollector = $router->getRouteCollector();
- $routeCollector->addRoute(['GET'], '/', 'IndexModuleClassName');
- $routeCollector->addRoute(['GET'], '/test', 'TestModuleClassName');
- $routeCollector->addRoute(['GET'], '/test/sub', 'TestSubModuleClassName');
- $routeCollector->addRoute(['GET'], '/optional[/option]', 'OptionalModuleClassName');
- $routeCollector->addRoute(['GET'], '/variable/{var}', 'VariableModuleClassName');
- $routeCollector->addRoute(['GET'], '/optionalvariable[/{option}]', 'OptionalVariableModuleClassName');
- $routeCollector->addRoute(['POST', 'PUT', 'PATCH', 'DELETE', 'HEAD'], '/unsupported', 'UnsupportedMethodModuleClassName');
+ $routeCollector->addRoute([Router::GET], '/', 'IndexModuleClassName');
+ $routeCollector->addRoute([Router::GET], '/test', 'TestModuleClassName');
+ $routeCollector->addRoute([Router::GET, Router::POST], '/testgetpost', 'TestGetPostModuleClassName');
+ $routeCollector->addRoute([Router::GET], '/test/sub', 'TestSubModuleClassName');
+ $routeCollector->addRoute([Router::GET], '/optional[/option]', 'OptionalModuleClassName');
+ $routeCollector->addRoute([Router::GET], '/variable/{var}', 'VariableModuleClassName');
+ $routeCollector->addRoute([Router::GET], '/optionalvariable[/{option}]', 'OptionalVariableModuleClassName');
$this->assertEquals('IndexModuleClassName', $router->getModuleClass('/'));
-
$this->assertEquals('TestModuleClassName', $router->getModuleClass('/test'));
- $this->assertNull($router->getModuleClass('/tes'));
-
+ $this->assertEquals('TestGetPostModuleClassName', $router->getModuleClass('/testgetpost'));
$this->assertEquals('TestSubModuleClassName', $router->getModuleClass('/test/sub'));
-
$this->assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional'));
$this->assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional/option'));
- $this->assertNull($router->getModuleClass('/optional/opt'));
-
$this->assertEquals('VariableModuleClassName', $router->getModuleClass('/variable/123abc'));
- $this->assertNull($router->getModuleClass('/variable'));
+ $this->assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable'));
+ $this->assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable/123abc'));
+ }
+ public function testPostModuleClass()
+ {
+ $router = new Router(['REQUEST_METHOD' => Router::POST]);
+
+ $routeCollector = $router->getRouteCollector();
+ $routeCollector->addRoute([Router::POST], '/', 'IndexModuleClassName');
+ $routeCollector->addRoute([Router::POST], '/test', 'TestModuleClassName');
+ $routeCollector->addRoute([Router::GET, Router::POST], '/testgetpost', 'TestGetPostModuleClassName');
+ $routeCollector->addRoute([Router::POST], '/test/sub', 'TestSubModuleClassName');
+ $routeCollector->addRoute([Router::POST], '/optional[/option]', 'OptionalModuleClassName');
+ $routeCollector->addRoute([Router::POST], '/variable/{var}', 'VariableModuleClassName');
+ $routeCollector->addRoute([Router::POST], '/optionalvariable[/{option}]', 'OptionalVariableModuleClassName');
+
+ $this->assertEquals('IndexModuleClassName', $router->getModuleClass('/'));
+ $this->assertEquals('TestModuleClassName', $router->getModuleClass('/test'));
+ $this->assertEquals('TestGetPostModuleClassName', $router->getModuleClass('/testgetpost'));
+ $this->assertEquals('TestSubModuleClassName', $router->getModuleClass('/test/sub'));
+ $this->assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional'));
+ $this->assertEquals('OptionalModuleClassName', $router->getModuleClass('/optional/option'));
+ $this->assertEquals('VariableModuleClassName', $router->getModuleClass('/variable/123abc'));
$this->assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable'));
$this->assertEquals('OptionalVariableModuleClassName', $router->getModuleClass('/optionalvariable/123abc'));
+ }
+
+ public function testGetModuleClassNotFound()
+ {
+ $this->expectException(NotFoundException::class);
+
+ $router = new Router(['REQUEST_METHOD' => Router::GET]);
+
+ $router->getModuleClass('/unsupported');
+ }
+
+ public function testGetModuleClassNotFoundTypo()
+ {
+ $this->expectException(NotFoundException::class);
+
+ $router = new Router(['REQUEST_METHOD' => Router::GET]);
+
+ $routeCollector = $router->getRouteCollector();
+ $routeCollector->addRoute([Router::GET], '/test', 'TestModuleClassName');
+
+ $router->getModuleClass('/tes');
+ }
+
+ public function testGetModuleClassNotFoundOptional()
+ {
+ $this->expectException(NotFoundException::class);
+
+ $router = new Router(['REQUEST_METHOD' => Router::GET]);
+
+ $routeCollector = $router->getRouteCollector();
+ $routeCollector->addRoute([Router::GET], '/optional[/option]', 'OptionalModuleClassName');
+
+ $router->getModuleClass('/optional/opt');
+ }
+
+ public function testGetModuleClassNotFoundVariable()
+ {
+ $this->expectException(NotFoundException::class);
+
+ $router = new Router(['REQUEST_METHOD' => Router::GET]);
+
+ $routeCollector = $router->getRouteCollector();
+ $routeCollector->addRoute([Router::GET], '/variable/{var}', 'VariableModuleClassName');
+
+ $router->getModuleClass('/variable');
+ }
+
+ public function testGetModuleClassMethodNotAllowed()
+ {
+ $this->expectException(MethodNotAllowedException::class);
+
+ $router = new Router(['REQUEST_METHOD' => Router::POST]);
+
+ $routeCollector = $router->getRouteCollector();
+ $routeCollector->addRoute([Router::GET], '/test', 'TestModuleClassName');
+
+ $router->getModuleClass('/test');
+ }
+
+ public function testPostModuleClassMethodNotAllowed()
+ {
+ $this->expectException(MethodNotAllowedException::class);
+
+ $router = new Router(['REQUEST_METHOD' => Router::GET]);
+
+ $routeCollector = $router->getRouteCollector();
+ $routeCollector->addRoute([Router::POST], '/test', 'TestModuleClassName');
- $this->assertNull($router->getModuleClass('/unsupported'));
+ $router->getModuleClass('/test');
}
public function dataRoutes()
$this->assertEquals(Module\Home::class, $router->getModuleClass('/'));
$this->assertEquals(Module\Friendica::class, $router->getModuleClass('/group/route'));
$this->assertEquals(Module\Xrd::class, $router->getModuleClass('/group2/group3/route'));
- $this->assertNull($router->getModuleClass('/post/it'));
$this->assertEquals(Module\Profile::class, $router->getModuleClass('/double'));
}
]))->addRoutes($routes);
// Don't find GET
- $this->assertNull($router->getModuleClass('/'));
- $this->assertNull($router->getModuleClass('/group/route'));
- $this->assertNull($router->getModuleClass('/group2/group3/route'));
$this->assertEquals(Module\NodeInfo::class, $router->getModuleClass('/post/it'));
$this->assertEquals(Module\Profile::class, $router->getModuleClass('/double'));
}
<div class="clear"></div>\
<hr class="previewseparator">';
var text;
- var urlRegex = /^(?:https?\:\/\/|\s)[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})(?:\/+[a-z0-9_.\:\;-]*)*(?:\?[\&\%\|\+a-z0-9_=,\.\:\;-]*)?(?:[\&\%\|\+&a-z0-9_=,\:\;\.-]*)(?:[\!\#\/\&\%\|\+a-z0-9_=,\:\;\.-]*)}*$/i;
var binurl;
var block = false;
var blockTitle = false;
var last_popup_button = null;
var lockLoadContent = false;
+const urlRegex = /^(?:https?:\/\/|\s)[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})(?:\/+[a-z0-9_.:;-]*)*(?:\?[&%|+a-z0-9_=,.:;-]*)?(?:[&%|+&a-z0-9_=,:;.-]*)(?:[!#\/&%|+a-z0-9_=,:;.-]*)}*$/i;
+
$(function() {
$.ajaxSetup({cache: false});
}
});
+/**
+ * Inserts a BBCode tag in the comment textarea identified by id
+ *
+ * @param {string} BBCode
+ * @param {int} id
+ * @returns {boolean}
+ */
+function insertFormatting(BBCode, id) {
+ let textarea = document.getElementById('comment-edit-text-' + id);
+
+ if (textarea.value === '') {
+ $(textarea)
+ .addClass("comment-edit-text-full")
+ .removeClass("comment-edit-text-empty");
+ closeMenu("comment-fake-form-" + id);
+ openMenu("item-comments-" + id);
+ }
+
+ insertBBCodeInTextarea(BBCode, textarea);
+
+ return true;
+}
+
+/**
+ * Inserts a BBCode tag in the provided textarea element, wrapping the currently selected text.
+ * For URL BBCode, it discriminates between link text and non-link text to determine where to insert the selected text.
+ *
+ * @param {string} BBCode
+ * @param {HTMLTextAreaElement} textarea
+ */
+function insertBBCodeInTextarea(BBCode, textarea) {
+ let selectionStart = textarea.selectionStart;
+ let selectionEnd = textarea.selectionEnd;
+ let selectedText = textarea.value.substring(selectionStart, selectionEnd);
+ let openingTag = '[' + BBCode + ']';
+ let closingTag = '[/' + BBCode + ']';
+ let cursorPosition = selectionStart + openingTag.length + selectedText.length;
+
+ if (BBCode === 'url') {
+ if (urlRegex.test(selectedText)) {
+ openingTag = '[' + BBCode + '=' + selectedText + ']';
+ selectedText = '';
+ cursorPosition = selectionStart + openingTag.length;
+ } else {
+ openingTag = '[' + BBCode + '=]';
+ cursorPosition = selectionStart + openingTag.length - 1;
+ }
+ }
+
+ textarea.value = textarea.value.substring(0, selectionStart) + openingTag + selectedText + closingTag + textarea.value.substring(selectionEnd, textarea.value.length);
+ textarea.setSelectionRange(cursorPosition, cursorPosition);
+ textarea.dispatchEvent(new Event('change'));
+ textarea.focus();
+}
+
function NavUpdate() {
if (!stopped) {
var pingCmd = 'ping?format=json' + ((localUser != 0) ? '&f=&uid=' + localUser : '');
--- /dev/null
+
+<h3>{{$title}}</h3>
+<div id="identity-delegation-desc">{{$desc nofilter}}</div>
+<div id="identity-delegation-choose">{{$choose}}</div>
+
+<div id="identity-selector-wrapper" role="menu">
+ <form action="delegation" method="post">
+
+ {{foreach $identities as $identity}}
+ <div class="itentity-match-wrapper {{if $identity.selected}}selected-identity{{/if}}" id="identity-match-{{$identity.uid}}">
+ <div class="identity-match-photo" id="identity-match-photo-{{$identity.uid}}">
+ <button type="submit" name="identity" value="{{$identity.uid}}" title="{{$identity.username}}">
+ <img src="{{$identity.thumb}}" alt="{{$identity.username}}" />
+ {{if $identity.notifications}}<span class="delegation-notify badge">{{$identity.notifications}}</span>{{/if}}
+ </button>
+ </div>
+
+ <div class="identity-match-break"></div>
+
+ <div class="identity-match-desc">
+ <div class="identity-match-name" id="identity-match-name-{{$identity.uid}}">
+ {{if $identity.selected}}
+ {{$identity.username}}
+ {{else}}
+ <button type="submit" name="identity" class="btn-link" value="{{$identity.uid}}">{{$identity.username}}</button>
+ {{/if}}
+ </div>
+ <div class="identity-match-details" id="identity-match-nick-{{$identity.uid}}">({{$identity.nickname}})</div>
+ </div>
+ <div class="identity-match-end"></div>
+ </div>
+ {{/foreach}}
+
+ <div class="identity-match-break"></div>
+
+ </form>
+</div>
+++ /dev/null
-
-<h3>{{$title}}</h3>
-<div id="identity-manage-desc">{{$desc nofilter}}</div>
-<div id="identity-manage-choose">{{$choose}}</div>
-
-<div id="identity-selector-wrapper" role="menu">
- <form action="manage" method="post" >
-
- {{foreach $identities as $id}}
- <div class="itentity-match-wrapper {{if $id.selected}}selected-identity{{/if}}" id="identity-match-{{$id.uid}}">
- <div class="identity-match-photo" id="identity-match-photo-{{$id.uid}}">
- <button name="identity" value="{{$id.uid}}" onclick="this.form.submit();" title="{{$id.username}}">
- <img src="{{$id.thumb}}" alt="{{$id.username}}" />
- {{if $id.notifications}}<span class="manage-notify badge">{{$id.notifications}}</span>{{/if}}
- </button>
- </div>
-
- <div class="identity-match-break"></div>
-
- <div class="identity-match-desc">
- <div class="identity-match-name" id="identity-match-name-{{$id.uid}}">
- {{if $id.selected}}{{$id.username}}{{else}}<a role="menuitem" href="manage?identity={{$id.uid}}">{{$id.username}}</a>{{/if}}
- </div>
- <div class="identity-match-details" id="identity-match-nick-{{$id.uid}}">({{$id.nickname}})</div>
- </div>
- <div class="identity-match-end"></div>
- </div>
- {{/foreach}}
-
- <div class="identity-match-break"></div>
-
- </form>
-</div>
- {{if $nav.manage}}<a id="nav-manage-link" class="nav-commlink {{$nav.manage.2}} {{$sel.manage}}" href="{{$nav.manage.0}}" title="{{$nav.manage.3}}">{{$nav.manage.1}}</a>{{/if}}
+ {{if $nav.delegation}}<a id="nav-delegation-link" class="nav-commlink {{$nav.delegation.2}} {{$sel.delegation}}" href="{{$nav.delegation.0}}" title="{{$nav.delegation.3}}">{{$nav.delegation.1}}</a>{{/if}}
{{if $nav.notifications}}
{{/if}}
<input type="submit" name="submit" id="search-submit" value="{{$search_label}}"/>
{{if $s}}
- <a href="search/saved/add/{{$q}}?return_url={{$return_url}}">{{$save_label}}</a>
+ <a href="search/saved/add?term={{$q}}&return_url={{$return_url}}">{{$save_label}}</a>
{{/if}}
{{/strip}}
</form>
<ul role="menu" id="saved-search-ul">
{{foreach $saved as $search}}
<li role="menuitem" class="saved-search-li clear">
- <a href="search/saved/remove/{{$search.encodedterm}}?return_url={{$return_url}}" title="{{$search.delete}}" onclick="return confirmDelete();" id="drop-saved-search-term-{{$search.id}}" class="iconspacer savedsearchdrop"></a>
+ <a href="search/saved/remove?term={{$search.encodedterm}}&return_url={{$return_url}}" title="{{$search.delete}}" onclick="return confirmDelete();" id="drop-saved-search-term-{{$search.id}}" class="iconspacer savedsearchdrop"></a>
<a href="search?q={{$search.encodedterm}}" id="saved-search-term-{{$search.id}}" class="savedsearchterm">{{$search.term}}</a>
</li>
{{/foreach}}
margin: 10px;
}
-#identity-manage-desc {
+#identity-delegation-desc {
margin-top:15px;
margin-bottom: 15px;
}
-#identity-manage-choose {
+#identity-delegation-choose {
margin-bottom: 15px;
}
}
/* notifications popup menu */
-.manage-notify {
+.delegation-notify {
font-size: 10px;
padding: 1px 3px;
top: 0px;
{{if $nav.contacts}}<a id="nav-contacts-link" class="nav-link {{$nav.contacts.2}}" href="{{$nav.contacts.0}}" title="{{$nav.contacts.3}}" >{{$nav.contacts.1}}</a>{{/if}}
- {{if $nav.manage}}<a id="nav-manage-link" class="nav-link {{$nav.manage.2}} {{$sel.manage}}" href="{{$nav.manage.0}}" title="{{$nav.manage.3}}">{{$nav.manage.1}}</a>{{/if}}
+ {{if $nav.delegation}}<a id="nav-delegation-link" class="nav-link {{$nav.delegation.2}} {{$sel.delegation}}" href="{{$nav.delegation.0}}" title="{{$nav.delegation.3}}">{{$nav.delegation.1}}</a>{{/if}}
</span>
<span id="nav-end"></span>
<span id="banner">{{$banner nofilter}}</span>
}
$a->page['htmlhead'] .= <<< EOT
<script>
-function insertFormatting(BBcode, id) {
- var tmpStr = $("#comment-edit-text-" + id).val();
- if (tmpStr == "") {
- $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
- $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
- openMenu("comment-edit-submit-wrapper-" + id);
- }
-
- textarea = document.getElementById("comment-edit-text-" +id);
- if (document.selection) {
- textarea.focus();
- selected = document.selection.createRange();
- selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
- } else if (textarea.selectionStart || textarea.selectionStart == "0") {
- var start = textarea.selectionStart;
- var end = textarea.selectionEnd;
- textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
- }
-
- return true;
-}
-
function cmtBbOpen(comment, id) {
if ($(comment).hasClass('comment-edit-text-full')) {
$(".comment-edit-bb-" + id).show();
.search-content-wrapper > .section-title-wrapper {
display: none;
}
-#navbar-button > #search-save-form > #search-save {
+#navbar-button > #search-save {
margin-top: 3px;
}
/* Section-Content-Wrapper */
.generic-page-wrapper, .profile_photo-content-wrapper, .videos-content-wrapper,
.suggest-content-wrapper, .common-content-wrapper, .help-content-wrapper,
.allfriends-content-wrapper, .match-content-wrapper, .dirfind-content-wrapper,
-.manage-content-wrapper, .notes-content-wrapper,
+.delegation-content-wrapper, .notes-content-wrapper,
.message-content-wrapper, .apps-content-wrapper,
#adminpage, .delegate-content-wrapper, .uexport-content-wrapper,
.dfrn_request-content-wrapper,
right: 10px;
}
- .generic-page-wrapper, .profile_photo-content-wrapper, .videos-content-wrapper, .suggest-content-wrapper, .common-content-wrapper, .help-content-wrapper, .allfriends-content-wrapper, .match-content-wrapper, .dirfind-content-wrapper, .directory-content-wrapper, .manage-content-wrapper, .notes-content-wrapper, .message-content-wrapper, .apps-content-wrapper, #adminpage, .delegate-content-wrapper, .uexport-content-wrapper, .dfrn_request-content-wrapper, .friendica-content-wrapper, .credits-content-wrapper, .nogroup-content-wrapper, .profperm-content-wrapper, .invite-content-wrapper, .tos-content-wrapper, .fsuggest-content-wrapper {
+ .generic-page-wrapper, .profile_photo-content-wrapper, .videos-content-wrapper, .suggest-content-wrapper, .common-content-wrapper, .help-content-wrapper, .allfriends-content-wrapper, .match-content-wrapper, .dirfind-content-wrapper, .directory-content-wrapper, .delegation-content-wrapper, .notes-content-wrapper, .message-content-wrapper, .apps-content-wrapper, #adminpage, .delegate-content-wrapper, .uexport-content-wrapper, .dfrn_request-content-wrapper, .friendica-content-wrapper, .credits-content-wrapper, .nogroup-content-wrapper, .profperm-content-wrapper, .invite-content-wrapper, .tos-content-wrapper, .fsuggest-content-wrapper {
border-radius: 0;
padding: 10px;
}
}
}
-
-function insertFormatting(BBcode, id) {
- var tmpStr = $("#comment-edit-text-" + id).val();
- if (tmpStr == '') {
- $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
- $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
- closeMenu("comment-fake-form-" + id);
- openMenu("item-comments-" + id);
- }
-
- textarea = document.getElementById("comment-edit-text-" + id);
- if (document.selection) {
- textarea.focus();
- selected = document.selection.createRange();
- selected.text = "[" + BBcode + "]" + selected.text + "[/" + BBcode + "]";
- } else if (textarea.selectionStart || textarea.selectionStart == "0") {
- var start = textarea.selectionStart;
- var end = textarea.selectionEnd;
- textarea.value = textarea.value.substring(0, start) + "[" + BBcode + "]" + textarea.value.substring(start, end) + "[/" + BBcode + "]" + textarea.value.substring(end, textarea.value.length);
- }
-
- $(textarea).trigger('change');
-
- return true;
-}
-
-function insertFormattingToPost(BBcode) {
+function insertFormattingToPost(BBCode) {
textarea = document.getElementById("profile-jot-text");
- if (document.selection) {
- textarea.focus();
- selected = document.selection.createRange();
- selected.text = "[" + BBcode + "]" + selected.text + "[/" + BBcode + "]";
- } else if (textarea.selectionStart || textarea.selectionStart == "0") {
- var start = textarea.selectionStart;
- var end = textarea.selectionEnd;
- textarea.value = textarea.value.substring(0, start) + "[" + BBcode + "]" + textarea.value.substring(start, end) + "[/" + BBcode + "]" + textarea.value.substring(end, textarea.value.length);
- }
- $(textarea).trigger('change');
+ insertBBCodeInTextarea(BBCode, textarea);
return true;
}
}
// move the "Save the search" button to the second navbar
- $(".search-content-wrapper #search-save-form ").appendTo("#topbar-second > .container > #navbar-button");
+ $(".search-content-wrapper #search-save").appendTo("#topbar-second > .container > #navbar-button");
// append the vcard-short-info to the second nav after passing the element
// with .fn (vcard username). Use scrollspy to get the scroll position.
<form class="navbar-form" role="search" method="get" action="{{$nav.search.0}}">
<!-- <img class="hidden-xs" src="{{$nav.userinfo.icon}}" alt="{{$nav.userinfo.name}}" style="max-width:33px; max-height:33px; min-width:33px; min-height:33px; width:33px; height:33px;"> -->
<div class="form-group form-group-search">
- <input accesskey="s" id="nav-search-input-field" class="form-control form-search" type="text" name="search" data-toggle="tooltip" title="{{$search_hint}}" placeholder="{{$nav.search.1}}">
+ <input accesskey="s" id="nav-search-input-field" class="form-control form-search" type="text" name="q" data-toggle="tooltip" title="{{$search_hint}}" placeholder="{{$nav.search.1}}">
<button class="btn btn-default btn-sm form-button-search" type="submit">{{$nav.search.1}}</button>
</div>
</form>
{{if $nav.contacts}}
<li role="presentation"><a role="menuitem" id="nav-menu-contacts-link" class="nav-link {{$nav.contacts.2}}" href="{{$nav.contacts.0}}" title="{{$nav.contacts.3}}"><i class="fa fa-users fa-fw" aria-hidden="true"></i> {{$nav.contacts.1}}</a><span id="intro-update-li" class="nav-intro-badge badge nav-notify"></span></li>
{{/if}}
- {{if $nav.manage}}
- <li role="presentation"><a role="menuitem" id="nav-manage-link" class="nav-commlink {{$nav.manage.2}} {{$sel.manage}}" href="{{$nav.manage.0}}" title="{{$nav.manage.3}}"><i class="fa fa-flag fa-fw" aria-hidden="true"></i> {{$nav.manage.1}}</a></li>
+ {{if $nav.delegation}}
+ <li role="presentation"><a role="menuitem" id="nav-delegation-link" class="nav-commlink {{$nav.delegation.2}} {{$sel.delegation}}" href="{{$nav.delegation.0}}" title="{{$nav.delegation.3}}"><i class="fa fa-flag fa-fw" aria-hidden="true"></i> {{$nav.delegation.1}}</a></li>
{{/if}}
<li role="presentation"><a role="menuitem" id="nav-directory-link" class="nav-link {{$nav.directory.2}}" href="{{$nav.directory.0}}" title="{{$nav.directory.3}}"><i class="fa fa-sitemap fa-fw" aria-hidden="true"></i>{{$nav.directory.1}}</a></li>
<li role="presentation" class="divider"></li>
{{if $nav.apps}}
- <li role="presentation"><a role="menuitem" id="nav-apps-link" class="nav-link {{$nav.apps.2}} {{$sel.manage}}" href="{{$nav.apps.0}}" title="{{$nav.apps.3}}" ><i class="fa fa-puzzle-piece fa-fw" aria-hidden="true"></i> {{$nav.apps.1}}</a>
+ <li role="presentation"><a role="menuitem" id="nav-apps-link" class="nav-link {{$nav.apps.2}}" href="{{$nav.apps.0}}" title="{{$nav.apps.3}}" ><i class="fa fa-puzzle-piece fa-fw" aria-hidden="true"></i> {{$nav.apps.1}}</a>
<li role="presentation" class="divider"></li>
{{/if}}
{{if $nav.help}}
{{if $nav.messages}}
<li role="presentation" class="list-group-item"><a role="menuitem" class="nav-link {{$nav.messages.2}} {{$sel.messages}}" href="{{$nav.messages.0}}" title="{{$nav.messages.3}}" ><i class="fa fa-envelope fa-fw" aria-hidden="true"></i> {{$nav.messages.1}}</a></li>
{{/if}}
- {{if $nav.manage}}
- <li role="presentation" class="list-group-item"><a role="menuitem" class="nav-commlink {{$nav.manage.2}} {{$sel.manage}}" href="{{$nav.manage.0}}" title="{{$nav.manage.3}}"><i class="fa fa-flag fa-fw" aria-hidden="true"></i> {{$nav.manage.1}}</a></li>
+ {{if $nav.delegation}}
+ <li role="presentation" class="list-group-item"><a role="menuitem" class="nav-commlink {{$nav.delegation.2}} {{$sel.delegation}}" href="{{$nav.delegation.0}}" title="{{$nav.delegation.3}}"><i class="fa fa-flag fa-fw" aria-hidden="true"></i> {{$nav.delegation.1}}</a></li>
{{/if}}
{{if $nav.settings}}
<li role="presentation" class="list-group-item"><a role="menuitem" class="nav-link {{$nav.settings.2}}" href="{{$nav.settings.0}}" title="{{$nav.settings.3}}"><i class="fa fa-cog fa-fw" aria-hidden="true"></i> {{$nav.settings.1}}</a></li>
<div class="col-md-8">
{{* The button to save searches *}}
{{if $s}}
- <a href="search/saved/add/{{$q}}?return_url={{$return_url}}" class="btn btn-primary btn-small pull-right">{{$save_label}}</a>
+ <a href="search/saved/add?term={{$q}}&return_url={{$return_url}}" class="btn btn-primary btn-small pull-right">{{$save_label}}</a>
{{/if}}
{{* The select popup menu to select what kind of results the user would like to search for *}}
</div>
{{if $s}}
- <form id="search-save-form" action="search/saved/add/{{$q}}" method="get">
- <input type="hidden" name="return_url" value="{{$return_url}}">
- <button class="btn btn-sm btn-main pull-right" type="submit" id="search-save" title="{{$save_label}}" aria-label="{{$save_label}}" value="{{$save_label}}" data-toggle="tooltip">
+ <a href="search/saved/add?term={{$q}}&return_url={{$return_url}}" class="btn btn-sm btn-main pull-right" id="search-save" title="{{$save_label}}" aria-label="{{$save_label}}" value="{{$save_label}}" data-toggle="tooltip">
{{if $mode == "tag"}}
- <i class="fa fa-plus fa-2x" aria-hidden="true"></i>
+ <i class="fa fa-plus fa-2x" aria-hidden="true"></i>
{{else}}
- <i class="fa fa-floppy-o fa-2x" aria-hidden="true"></i>
+ <i class="fa fa-floppy-o fa-2x" aria-hidden="true"></i>
{{/if}}
- <span class="sr-only">{{$save_label}}</span>
- </button>
- </form>
+ <span class="sr-only">{{$save_label}}</span>
+ </a>
{{/if}}
</div>
<ul role="menu" id="saved-search-ul">
{{foreach $saved as $search}}
<li role="menuitem" class="saved-search-li clear">
- <a href="search/saved/remove/{{$search.encodedterm}}?return_url={{$return_url}}" title="{{$search.delete}}" onclick="return confirmDelete();" id="drop-saved-search-term-{{$search.id}}" class="savedsearchdrop pull-right widget-action faded-icon">
+ <a href="search/saved/remove?term={{$search.encodedterm}}&return_url={{$return_url}}" title="{{$search.delete}}" onclick="return confirmDelete();" id="drop-saved-search-term-{{$search.id}}" class="savedsearchdrop pull-right widget-action faded-icon">
<i class="fa fa-trash" aria-hidden="true"></i>
</a>
<a href="search?q={{$search.encodedterm}}" id="saved-search-term-{{$search.id}}" class="savedsearchterm">{{$search.term}}</a>
.identity-match-photo {
position: relative;
}
-.identity-match-photo .manage-notify {
+.identity-match-photo .delegation-notify {
background-color: #19AEFF;
border-radius: 5px;
font-size: 10px;
.identity-match-photo {
position: relative;
}
-.identity-match-photo .manage-notify {
+.identity-match-photo .delegation-notify {
background-color: #19AEFF;
border-radius: 5px;
font-size: 10px;
});
});
-function insertFormatting(BBcode, id) {
- var tmpStr = $("#comment-edit-text-" + id).val();
- if (tmpStr == "") {
- $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
- $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
- openMenu("comment-edit-submit-wrapper-" + id);
- }
-
- textarea = document.getElementById("comment-edit-text-" +id);
- if (document.selection) {
- textarea.focus();
- selected = document.selection.createRange();
- selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
- } else if (textarea.selectionStart || textarea.selectionStart == "0") {
- var start = textarea.selectionStart;
- var end = textarea.selectionEnd;
- textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
- }
-
- return true;
-}
-
function showThread(id) {
$("#collapsed-comments-" + id).show()
$("#collapsed-comments-" + id + " .collapsed-comments").show()
.identity-match-photo {
position: relative;
}
-.identity-match-photo .manage-notify {
+.identity-match-photo .delegation-notify {
background-color: #19AEFF;
border-radius: 5px;
font-size: 10px;
/* manage page */
.identity-match-photo {
position: relative;
- .manage-notify {
+ .delegation-notify {
background-color: #19AEFF;
border-radius: 5px;
font-size: 10px;
<li id="nav-site-linkmenu" class="nav-menu-icon"><a href="#" rel="#nav-site-menu"><span class="icon s22 gear">Site</span></a>
<ul id="nav-site-menu" class="menu-popup">
- {{if $nav.manage}}<li><a class="{{$nav.manage.2}}" href="{{$nav.manage.0}}" title="{{$nav.manage.3}}">{{$nav.manage.1}}</a></li>{{/if}}
+ {{if $nav.delegation}}<li><a class="{{$nav.delegation.2}}" href="{{$nav.delegation.0}}" title="{{$nav.delegation.3}}">{{$nav.delegation.1}}</a></li>{{/if}}
{{if $nav.settings}}<li><a class="{{$nav.settings.2}}" href="{{$nav.settings.0}}" title="{{$nav.settings.3}}">{{$nav.settings.1}}</a></li>{{/if}}
{{if $nav.admin}}<li><a accesskey="a" class="{{$nav.admin.2}}" href="{{$nav.admin.0}}" title="{{$nav.admin.3}}" >{{$nav.admin.1}}</a></li>{{/if}}
{{foreach $saved as $search}}
<li class="tool {{if $search.selected}}selected{{/if}}">
<a href="search?q={{$search.encodedterm}}" class="label">{{$search.term}}</a>
- <a href="search/saved/remove/{{$search.encodedterm}}?return_url={{$return_url}}" class="action icon s10 delete" title="{{$search.delete}}" onclick="return confirmDelete();"></a>
+ <a href="search/saved/remove?term={{$search.encodedterm}}&return_url={{$return_url}}" class="action icon s10 delete" title="{{$search.delete}}" onclick="return confirmDelete();"></a>
</li>
{{/foreach}}
</ul>
}
/* notifications popup menu */
-.manage-notify {
+.delegation-notify {
font-size: 10px;
padding: 1px 3px;
top: 0px;
<script type="text/javascript" src="{{$baseurl}}/view/theme/smoothly/js/jquery.autogrow.textarea.js"></script>
<script type="text/javascript">
-$(document).ready(function() {
-
-});
function tautogrow(id) {
$("textarea#comment-edit-text-" + id).autogrow();
-};
-
-function insertFormatting(BBcode, id) {
- var tmpStr = $("#comment-edit-text-" + id).val();
- if (tmpStr == "") {
- $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
- $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
- openMenu("comment-edit-submit-wrapper-" + id);
- }
-
- textarea = document.getElementById("comment-edit-text-" + id);
- if (document.selection) {
- textarea.focus();
- selected = document.selection.createRange();
- selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
- } else if (textarea.selectionStart || textarea.selectionStart == "0") {
- var start = textarea.selectionStart;
- var end = textarea.selectionEnd;
- textarea.value = textarea.value.substring(0, start)
- + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]"
- + textarea.value.substring(end, textarea.value.length);
- }
-
- return true;
-}
-
-function cmtBbOpen(id) {
- $(".comment-edit-bb-" + id).show();
-}
-function cmtBbClose(id) {
- $(".comment-edit-bb-" + id).hide();
}
</script>
{{if $nav.profiles}}<li><a id="nav-profiles-link" class="nav-commlink nav-sep {{$nav.profiles.2}}" href="{{$nav.profiles.0}}">{{$nav.profiles.1}}</a></li>{{/if}}
{{if $nav.settings}}<li><a id="nav-settings-link" class="nav-commlink {{$nav.settings.2}}" href="{{$nav.settings.0}}">{{$nav.settings.1}}</a></li>{{/if}}
- {{if $nav.manage}}<li><a id="nav-manage-link" class="nav-commlink {{$nav.manage.2}}" href="{{$nav.manage.0}}">{{$nav.manage.1}}</a></li>{{/if}}
+ {{if $nav.delegation}}<li><a id="nav-delegation-link" class="nav-commlink {{$nav.delegation.2}}" href="{{$nav.delegation.0}}">{{$nav.delegation.1}}</a></li>{{/if}}
{{if $nav.admin}}<li><a id="nav-admin-link" class="nav-commlink {{$nav.admin.2}}" href="{{$nav.admin.0}}">{{$nav.admin.1}}</a></li>{{/if}}
$a->page['htmlhead'] .= <<< EOT
<script>
-function insertFormatting(BBcode, id) {
- var tmpStr = $("#comment-edit-text-" + id).val();
- if (tmpStr == "") {
- $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
- $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
- openMenu("comment-edit-submit-wrapper-" + id);
- }
-
- textarea = document.getElementById("comment-edit-text-" +id);
- if (document.selection) {
- textarea.focus();
- selected = document.selection.createRange();
- selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
- } else if (textarea.selectionStart || textarea.selectionStart == "0") {
- var start = textarea.selectionStart;
- var end = textarea.selectionEnd;
- textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
- }
-
- return true;
-}
-
function cmtBbOpen(id) {
$(".comment-edit-bb-" + id).show();
}
color: #000;
}
-.manage-notify {
+.delegation-notify {
background-color: #CB4437;
border-radius: 10px;
font: bold 11px/16px Arial;
color: #000;
}
-.manage-notify {
+.delegation-notify {
background-color: #CB4437;
border-radius: 10px;
font: bold 11px/16px Arial;
text-decoration: none;
}
-.manage-notify {
+.delegation-notify {
background-color: #F80;
-moz-border-radius: 5px 5px 5px 5px;
-webkit-border-radius: 5px 5px 5px 5px;
margin: 0px;
}
-#identity-manage-desc {
+#identity-delegation-desc {
margin-top:15px;
margin-bottom: 15px;
}
-#identity-manage-choose {
+#identity-delegation-choose {
margin-bottom: 15px;
}
{{if $nav.introductions}}<li role="menuitem"><a class="{{$nav.introductions.2}}" href="{{$nav.introductions.0}}" title="{{$nav.introductions.3}}" >{{$nav.introductions.1}}</a><span id="intro-update-li" class="nav-notify"></span></li>{{/if}}
{{if $nav.contacts}}<li role="menuitem"><a class="{{$nav.contacts.2}}" href="{{$nav.contacts.0}}" title="{{$nav.contacts.3}}" >{{$nav.contacts.1}}</a></li>{{/if}}
{{if $nav.messages}}<li role="menuitem"><a class="{{$nav.messages.2}}" href="{{$nav.messages.0}}" title="{{$nav.messages.3}}" >{{$nav.messages.1}} <span id="mail-update-li" class="nav-notify"></span></a></li>{{/if}}
- {{if $nav.manage}}<li role="menuitem"><a class="{{$nav.manage.2}}" href="{{$nav.manage.0}}" title="{{$nav.manage.3}}">{{$nav.manage.1}}</a></li>{{/if}}
+ {{if $nav.delegation}}<li role="menuitem"><a class="{{$nav.delegation.2}}" href="{{$nav.delegation.0}}" title="{{$nav.delegation.3}}">{{$nav.delegation.1}}</a></li>{{/if}}
{{if $nav.usermenu.1}}<li role="menuitem"><a class="{{$nav.usermenu.1.2}}" href="{{$nav.usermenu.1.0}}" title="{{$nav.usermenu.1.3}}">{{$nav.usermenu.1.1}}</a></li>{{/if}}
{{if $nav.settings}}<li role="menuitem"><a class="{{$nav.settings.2}}" href="{{$nav.settings.0}}" title="{{$nav.settings.3}}">{{$nav.settings.1}}</a></li>{{/if}}
{{if $nav.admin}}
$a->page['htmlhead'] .= <<< EOT
<link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
<script type="text/javascript">
-
-function insertFormatting(BBcode, id) {
- var tmpStr = $("#comment-edit-text-" + id).val();
- if (tmpStr == "") {
- $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
- $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
- openMenu("comment-edit-submit-wrapper-" + id);
- }
-
- textarea = document.getElementById("comment-edit-text-" +id);
- if (document.selection) {
- textarea.focus();
- selected = document.selection.createRange();
- selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
- } else if (textarea.selectionStart || textarea.selectionStart == "0") {
- var start = textarea.selectionStart;
- var end = textarea.selectionEnd;
- textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
- }
-
- return true;
-}
-
function showThread(id) {
$("#collapsed-comments-" + id).show()
$("#collapsed-comments-" + id + " .collapsed-comments").show()
// Hide the left menu bar
/// @TODO maybe move this static array out where it should belong?
- if (empty($a->page['aside']) && in_array($a->argv[0], ["community", "events", "help", "manage", "notifications",
+ if (empty($a->page['aside']) && in_array($a->argv[0], ["community", "events", "help", "delegation", "notifications",
"probe", "webfinger", "login", "invite", "credits"])) {
$a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
}