Replace deprecated string-bases Model\FileTag calls with array-based ones
This commit is contained in:
parent
6de3449cae
commit
0fadc7730c
|
@ -8,10 +8,8 @@ use Friendica\Content\Smilies;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
|
||||||
use Friendica\Model\FileTag;
|
use Friendica\Model\FileTag;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
use Friendica\Util\XML;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn user/group ACLs stored as angle bracketed text into arrays
|
* Turn user/group ACLs stored as angle bracketed text into arrays
|
||||||
|
@ -186,21 +184,17 @@ function get_cats_and_terms($item)
|
||||||
{
|
{
|
||||||
$categories = [];
|
$categories = [];
|
||||||
$folders = [];
|
$folders = [];
|
||||||
|
|
||||||
$matches = [];
|
|
||||||
$first = true;
|
$first = true;
|
||||||
$cnt = preg_match_all('/<(.*?)>/', $item['file'], $matches, PREG_SET_ORDER);
|
|
||||||
if ($cnt) {
|
foreach (FileTag::fileToArray($item['file'], 'category') as $savedFolderName) {
|
||||||
foreach ($matches as $mtch) {
|
$categories[] = [
|
||||||
$categories[] = [
|
'name' => $savedFolderName,
|
||||||
'name' => XML::escape(FileTag::decode($mtch[1])),
|
'url' => "#",
|
||||||
'url' => "#",
|
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&cat=' . rawurlencode($savedFolderName) : ""),
|
||||||
'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . XML::escape(FileTag::decode($mtch[1])):""),
|
'first' => $first,
|
||||||
'first' => $first,
|
'last' => false
|
||||||
'last' => false
|
];
|
||||||
];
|
$first = false;
|
||||||
$first = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($categories)) {
|
if (count($categories)) {
|
||||||
|
@ -208,20 +202,15 @@ function get_cats_and_terms($item)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (local_user() == $item['uid']) {
|
if (local_user() == $item['uid']) {
|
||||||
$matches = [];
|
foreach (FileTag::fileToArray($item['file']) as $savedFolderName) {
|
||||||
$first = true;
|
$folders[] = [
|
||||||
$cnt = preg_match_all('/\[(.*?)\]/', $item['file'], $matches, PREG_SET_ORDER);
|
'name' => $savedFolderName,
|
||||||
if ($cnt) {
|
'url' => "#",
|
||||||
foreach ($matches as $mtch) {
|
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . rawurlencode($savedFolderName) : ""),
|
||||||
$folders[] = [
|
'first' => $first,
|
||||||
'name' => XML::escape(FileTag::decode($mtch[1])),
|
'last' => false
|
||||||
'url' => "#",
|
];
|
||||||
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . XML::escape(FileTag::decode($mtch[1])) : ""),
|
$first = false;
|
||||||
'first' => $first,
|
|
||||||
'last' => false
|
|
||||||
];
|
|
||||||
$first = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
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
|
// 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
|
// 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 = FileTag::listToFile(trim(defaults($_REQUEST, 'category', '')), 'category');
|
||||||
$categories_new = $categories;
|
$categories_new = $categories;
|
||||||
|
|
||||||
if (!empty($filedas))
|
if (!empty($filedas)) {
|
||||||
{
|
|
||||||
// append the fileas stuff to the new categories list
|
// append the fileas stuff to the new categories list
|
||||||
$categories .= FileTag::listToFile($filedas, 'file');
|
$categories .= FileTag::arrayToFile($filedas);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get contact info for poster
|
// get contact info for poster
|
||||||
|
|
|
@ -256,7 +256,7 @@ class Widget
|
||||||
* @param string $baseurl baseurl
|
* @param string $baseurl baseurl
|
||||||
* @param string $selected optional, default empty
|
* @param string $selected optional, default empty
|
||||||
* @return string|void
|
* @return string|void
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function fileAs($baseurl, $selected = '')
|
public static function fileAs($baseurl, $selected = '')
|
||||||
{
|
{
|
||||||
|
@ -269,15 +269,9 @@ class Widget
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$matches = [];
|
$terms = [];
|
||||||
$terms = array();
|
foreach (FileTag::fileToArray($saved) as $savedFolderName) {
|
||||||
$cnt = preg_match_all('/\[(.*?)\]/', $saved, $matches, PREG_SET_ORDER);
|
$terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
|
||||||
if ($cnt) {
|
|
||||||
foreach ($matches as $mtch)
|
|
||||||
{
|
|
||||||
$unescaped = XML::escape(FileTag::decode($mtch[1]));
|
|
||||||
$terms[] = ['ref' => $unescaped, 'name' => $unescaped];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::filter(
|
return self::filter(
|
||||||
|
@ -312,15 +306,9 @@ class Widget
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$matches = [];
|
|
||||||
$terms = array();
|
$terms = array();
|
||||||
$cnt = preg_match_all('/<(.*?)>/', $saved, $matches, PREG_SET_ORDER);
|
foreach (FileTag::fileToArray($saved, 'category') as $savedFolderName) {
|
||||||
|
$terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
|
||||||
if ($cnt) {
|
|
||||||
foreach ($matches as $mtch) {
|
|
||||||
$unescaped = XML::escape(FileTag::decode($mtch[1]));
|
|
||||||
$terms[] = ['ref' => $unescaped, 'name' => $unescaped];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::filter(
|
return self::filter(
|
||||||
|
|
|
@ -41,8 +41,7 @@ class SaveTag extends BaseModule
|
||||||
|
|
||||||
// return filer dialog
|
// return filer dialog
|
||||||
$filetags = PConfig::get(local_user(), 'system', 'filetags');
|
$filetags = PConfig::get(local_user(), 'system', 'filetags');
|
||||||
$filetags = Model\FileTag::fileToList($filetags, 'file');
|
$filetags = Model\FileTag::fileToArray($filetags);
|
||||||
$filetags = explode(",", $filetags);
|
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
|
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
|
||||||
echo Renderer::replaceMacros($tpl, [
|
echo Renderer::replaceMacros($tpl, [
|
||||||
|
|
Loading…
Reference in a new issue