Skip to content

Commit

Permalink
refactor(abstractitiltarget): remove obsolete code
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Aug 1, 2023
1 parent 55cfa80 commit de592b6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 26 deletions.
2 changes: 1 addition & 1 deletion inc/abstractfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function show(string $domain, bool $canEdit = true): string {

if ($this->isEditableField() && !empty($this->question->fields['description'])) {
$description = $this->question->fields['description'];
foreach (PluginFormcreatorCommon::getDocumentsFromTag($description) as $document) {
foreach (Toolbox::getDocumentsFromTag($description) as $document) {
$prefix = uniqid('', true);
$filename = $prefix . 'image_paste.' . pathinfo($document['filename'], PATHINFO_EXTENSION);
if (!copy(GLPI_DOC_DIR . '/' . $document['filepath'], GLPI_TMP_DIR . '/' . $filename)) {
Expand Down
4 changes: 1 addition & 3 deletions inc/abstractitiltarget.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2412,9 +2412,7 @@ protected function prepareUploadedFiles(array $data): array {
$data['_tag_filename'] = [];

// emulate file uploads of inline images
// TODO: replace PluginFormcreatorCommon::getDocumentsFromTag by Toolbox::getDocumentsFromTag
// when is merged https://github.com/glpi-project/glpi/pull/9335
foreach (PluginFormcreatorCommon::getDocumentsFromTag($data['content']) as $document) {
foreach (Toolbox::getDocumentsFromTag($data['content']) as $document) {
$prefix = uniqid('', true);
$filename = $prefix . 'image_paste.' . pathinfo($document['filename'], PATHINFO_EXTENSION);
if (!@copy(GLPI_DOC_DIR . '/' . $document['filepath'], GLPI_TMP_DIR . '/' . $filename)) {
Expand Down
22 changes: 0 additions & 22 deletions inc/common.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,28 +583,6 @@ public static function checkRegex($regex) {
return $isValid;
}

/**
* Find documents data matching the tags found in the string
* Tags are deduplicated
*
* @param string $content_text String to search tags from
*
* @return array data from documents having tags found
*/
public static function getDocumentsFromTag(string $content_text): array {
preg_match_all(
'/'.Document::getImageTag('(([a-z0-9]+|[\.\-]?)+)').'/',
$content_text,
$matches, PREG_PATTERN_ORDER
);
if (!isset($matches[1]) || count($matches[1]) == 0) {
return [];
}

$document = new Document();
return $document->find(['tag' => array_unique($matches[1])]);
}

/**
* find a document with a file attached, with respect of blacklisting
*
Expand Down

0 comments on commit de592b6

Please sign in to comment.