use Friendica\Content\Text\BBCode;
use Friendica\Core\Protocol;
use Friendica\Model\Contact;
-
use Friendica\Model\FileTag;
use Friendica\Util\Strings;
-use Friendica\Util\XML;
/**
* Turn user/group ACLs stored as angle bracketed text into arrays
{
$categories = [];
$folders = [];
-
- $matches = [];
$first = true;
- $cnt = preg_match_all('/<(.*?)>/', $item['file'], $matches, PREG_SET_ORDER);
- if ($cnt) {
- foreach ($matches as $mtch) {
- $categories[] = [
- 'name' => XML::escape(FileTag::decode($mtch[1])),
- 'url' => "#",
- 'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . XML::escape(FileTag::decode($mtch[1])):""),
- 'first' => $first,
- 'last' => false
- ];
- $first = false;
- }
+
+ foreach (FileTag::fileToArray($item['file'], 'category') as $savedFolderName) {
+ $categories[] = [
+ 'name' => $savedFolderName,
+ 'url' => "#",
+ 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&cat=' . rawurlencode($savedFolderName) : ""),
+ 'first' => $first,
+ 'last' => false
+ ];
+ $first = false;
}
if (count($categories)) {
}
if (local_user() == $item['uid']) {
- $matches = [];
- $first = true;
- $cnt = preg_match_all('/\[(.*?)\]/', $item['file'], $matches, PREG_SET_ORDER);
- if ($cnt) {
- foreach ($matches as $mtch) {
- $folders[] = [
- 'name' => XML::escape(FileTag::decode($mtch[1])),
- 'url' => "#",
- 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . XML::escape(FileTag::decode($mtch[1])) : ""),
- 'first' => $first,
- 'last' => false
- ];
- $first = false;
- }
+ foreach (FileTag::fileToArray($item['file']) as $savedFolderName) {
+ $folders[] = [
+ 'name' => $savedFolderName,
+ 'url' => "#",
+ 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . rawurlencode($savedFolderName) : ""),
+ 'first' => $first,
+ 'last' => false
+ ];
+ $first = false;
}
}
}
}
- if (!empty($categories))
- {
+ if (!empty($categories)) {
// get the "fileas" tags for this post
- $filedas = FileTag::fileToList($categories, 'file');
+ $filedas = FileTag::fileToArray($categories);
}
// save old and new categories, so we can determine what needs to be deleted from pconfig
$categories = FileTag::listToFile(trim(defaults($_REQUEST, 'category', '')), 'category');
$categories_new = $categories;
- if (!empty($filedas))
- {
+ if (!empty($filedas)) {
// append the fileas stuff to the new categories list
- $categories .= FileTag::listToFile($filedas, 'file');
+ $categories .= FileTag::arrayToFile($filedas);
}
// get contact info for poster
* @param string $baseurl baseurl
* @param string $selected optional, default empty
* @return string|void
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \Exception
*/
public static function fileAs($baseurl, $selected = '')
{
return;
}
- $matches = [];
- $terms = array();
- $cnt = preg_match_all('/\[(.*?)\]/', $saved, $matches, PREG_SET_ORDER);
- if ($cnt) {
- foreach ($matches as $mtch)
- {
- $unescaped = XML::escape(FileTag::decode($mtch[1]));
- $terms[] = ['ref' => $unescaped, 'name' => $unescaped];
- }
+ $terms = [];
+ foreach (FileTag::fileToArray($saved) as $savedFolderName) {
+ $terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
}
return self::filter(
return;
}
- $matches = [];
$terms = array();
- $cnt = preg_match_all('/<(.*?)>/', $saved, $matches, PREG_SET_ORDER);
-
- if ($cnt) {
- foreach ($matches as $mtch) {
- $unescaped = XML::escape(FileTag::decode($mtch[1]));
- $terms[] = ['ref' => $unescaped, 'name' => $unescaped];
- }
+ foreach (FileTag::fileToArray($saved, 'category') as $savedFolderName) {
+ $terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
}
return self::filter(
// return filer dialog
$filetags = PConfig::get(local_user(), 'system', 'filetags');
- $filetags = Model\FileTag::fileToList($filetags, 'file');
- $filetags = explode(",", $filetags);
+ $filetags = Model\FileTag::fileToArray($filetags);
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
echo Renderer::replaceMacros($tpl, [