*/
use Friendica\App;
-use Friendica\Content\Smilies;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Protocol;
use Friendica\Model\Contact;
use Friendica\Model\FileTag;
+use Friendica\Model\Group;
use Friendica\Util\Strings;
/**
function expand_acl($s) {
// turn string array of angle-bracketed elements into numeric array
// e.g. "<1><2><3>" => array(1,2,3);
- $ret = [];
+ preg_match_all('/<(' . Group::FOLLOWERS . '|'. Group::MUTUALS . '|[0-9]+)>/', $s, $matches, PREG_PATTERN_ORDER);
- if (strlen($s)) {
- $t = str_replace('<', '', $s);
- $a = explode('>', $t);
- foreach ($a as $aa) {
- if (intval($aa)) {
- $ret[] = intval($aa);
- }
- }
- }
- return $ret;
+ return $matches[1];
}
function sanitise_acl(&$item) {
if (intval($item)) {
$item = '<' . intval(Strings::escapeTags(trim($item))) . '>';
+ } elseif (in_array($item, [Group::FOLLOWERS, Group::MUTUALS])) {
+ $item = '<' . $item . '>';
} else {
unset($item);
}
}
if ((local_user() == $item['uid']) && ($item['private'] == 1) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == Protocol::DFRN)) {
- $img_url = 'redir?f=1&quiet=1&url=' . urlencode($mtch[1]) . '&conurl=' . urlencode($item['author-link']);
+ $img_url = 'redir/' . $item['contact-id'] . '?url=' . urlencode($mtch[1]);
$item['body'] = str_replace($mtch[0], '[img]' . $img_url . '[/img]', $item['body']);
}
}
* @brief Given a text string, convert from bbcode to html and add smilie icons.
*
* @param string $text String with bbcode.
- * @return string Formattet HTML.
+ * @return string Formatted HTML
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
-function prepare_text($text) {
- if (stristr($text, '[nosmile]')) {
- $s = BBCode::convert($text);
- } else {
- $s = Smilies::replace(BBCode::convert($text));
- }
-
+function prepare_text($text)
+{
+ $s = BBCode::convert($text);
return trim($s);
}
$folders = [];
$first = true;
- foreach (FileTag::fileToArray($item['file'], 'category') as $savedFolderName) {
+ foreach (FileTag::fileToArray($item['file'] ?? '', 'category') as $savedFolderName) {
$categories[] = [
'name' => $savedFolderName,
'url' => "#",
}
if (local_user() == $item['uid']) {
- foreach (FileTag::fileToArray($item['file']) as $savedFolderName) {
+ foreach (FileTag::fileToArray($item['file'] ?? '') as $savedFolderName) {
$folders[] = [
'name' => $savedFolderName,
'url' => "#",