Replace deprecated string-bases Model\FileTag calls with array-based ones
This commit is contained in:
parent
6de3449cae
commit
0fadc7730c
4 changed files with 30 additions and 56 deletions
|
@ -8,10 +8,8 @@ use Friendica\Content\Smilies;
|
|||
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
|
||||
|
@ -186,44 +184,35 @@ function get_cats_and_terms($item)
|
|||
{
|
||||
$categories = [];
|
||||
$folders = [];
|
||||
|
||||
$matches = [];
|
||||
$first = true;
|
||||
$cnt = preg_match_all('/<(.*?)>/', $item['file'], $matches, PREG_SET_ORDER);
|
||||
if ($cnt) {
|
||||
foreach ($matches as $mtch) {
|
||||
|
||||
foreach (FileTag::fileToArray($item['file'], 'category') as $savedFolderName) {
|
||||
$categories[] = [
|
||||
'name' => XML::escape(FileTag::decode($mtch[1])),
|
||||
'name' => $savedFolderName,
|
||||
'url' => "#",
|
||||
'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . XML::escape(FileTag::decode($mtch[1])):""),
|
||||
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&cat=' . rawurlencode($savedFolderName) : ""),
|
||||
'first' => $first,
|
||||
'last' => false
|
||||
];
|
||||
$first = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($categories)) {
|
||||
$categories[count($categories) - 1]['last'] = true;
|
||||
}
|
||||
|
||||
if (local_user() == $item['uid']) {
|
||||
$matches = [];
|
||||
$first = true;
|
||||
$cnt = preg_match_all('/\[(.*?)\]/', $item['file'], $matches, PREG_SET_ORDER);
|
||||
if ($cnt) {
|
||||
foreach ($matches as $mtch) {
|
||||
foreach (FileTag::fileToArray($item['file']) as $savedFolderName) {
|
||||
$folders[] = [
|
||||
'name' => XML::escape(FileTag::decode($mtch[1])),
|
||||
'name' => $savedFolderName,
|
||||
'url' => "#",
|
||||
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . XML::escape(FileTag::decode($mtch[1])) : ""),
|
||||
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . rawurlencode($savedFolderName) : ""),
|
||||
'first' => $first,
|
||||
'last' => false
|
||||
];
|
||||
$first = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($folders)) {
|
||||
$folders[count($folders) - 1]['last'] = true;
|
||||
|
|
10
mod/item.php
10
mod/item.php
|
@ -327,10 +327,9 @@ function item_post(App $a) {
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -338,10 +337,9 @@ function item_post(App $a) {
|
|||
$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
|
||||
|
|
|
@ -256,7 +256,7 @@ class Widget
|
|||
* @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 = '')
|
||||
{
|
||||
|
@ -269,15 +269,9 @@ class Widget
|
|||
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(
|
||||
|
@ -312,15 +306,9 @@ class Widget
|
|||
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(
|
||||
|
|
|
@ -41,8 +41,7 @@ class SaveTag extends BaseModule
|
|||
|
||||
// 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, [
|
||||
|
|
Loading…
Reference in a new issue