Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable27] Add Option to Open Files Directly from Search Results #258

Open
wants to merge 3 commits into
base: stable27
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions js/admin.elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var files_elements = {
files_pdf: null,
files_image: null,
files_audio: null,
files_open_result_directly: null,

init: function () {
files_elements.files_div = $('#files');
Expand All @@ -54,6 +55,7 @@ var files_elements = {
files_elements.files_pdf = $('#files_pdf');
files_elements.files_image = $('#files_image');
files_elements.files_audio = $('#files_audio');
files_elements.files_open_result_directly = $('#files_open_result_directly');

files_elements.files_local.on('change', files_elements.updateSettings);
files_elements.files_external.on('change', files_elements.updateSettings);
Expand All @@ -65,6 +67,7 @@ var files_elements = {
files_elements.files_pdf.on('change', files_elements.updateSettings);
files_elements.files_image.on('change', files_elements.updateSettings);
files_elements.files_audio.on('change', files_elements.updateSettings);
files_elements.files_open_result_directly.on('change', files_elements.updateSettings);
},


Expand Down
4 changes: 3 additions & 1 deletion js/admin.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var files_settings = {
files_elements.files_pdf.prop('checked', (result.files_pdf === '1'));
files_elements.files_image.prop('checked', (result.files_image === '1'));
files_elements.files_audio.prop('checked', (result.files_audio === '1'));
files_elements.files_open_result_directly.prop('checked', (result.files_open_result_directly === '1'));

fts_admin_settings.tagSettingsAsSaved(files_elements.files_div);
},
Expand All @@ -71,7 +72,8 @@ var files_settings = {
files_office: (files_elements.files_office.is(':checked')) ? 1 : 0,
files_pdf: (files_elements.files_pdf.is(':checked')) ? 1 : 0,
files_image: (files_elements.files_image.is(':checked')) ? 1 : 0,
files_audio: (files_elements.files_audio.is(':checked')) ? 1 : 0
files_audio: (files_elements.files_audio.is(':checked')) ? 1 : 0,
files_open_result_directly: (files_elements.files_open_result_directly.is(':checked')) ? 1 : 0
};
$.ajax({
method: 'POST',
Expand Down
5 changes: 4 additions & 1 deletion l10n/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ OC.L10N.register(
"Extract PDF" : "PDF indizieren",
"Index the content of PDF files." : "Den Inhalt von PDF-Dateien indizieren.",
"Extract Office" : "Office-Dateien indizieren",
"Index the content of office files." : "Den Inhalt von Office-Dateien indizieren."
"Index the content of office files." : "Den Inhalt von Office-Dateien indizieren.",
"Results": "Ergebnisse",
"Open Files": "Dateien öffnen",
"Directly from search results.": "Direkt aus den Suchergebnissen."
},
"nplurals=2; plural=(n != 1);");
5 changes: 4 additions & 1 deletion l10n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"Extract PDF" : "PDF indizieren",
"Index the content of PDF files." : "Den Inhalt von PDF-Dateien indizieren.",
"Extract Office" : "Office-Dateien indizieren",
"Index the content of office files." : "Den Inhalt von Office-Dateien indizieren."
"Index the content of office files." : "Den Inhalt von Office-Dateien indizieren.",
"Results": "Ergebnisse",
"Open Files": "Dateien öffnen",
"Directly from search results.": "Direkt aus den Suchergebnissen."
},"pluralForm" :"nplurals=2; plural=(n != 1);"
}
5 changes: 4 additions & 1 deletion l10n/de_DE.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ OC.L10N.register(
"Extract PDF" : "PDF extrahieren",
"Index the content of PDF files." : "Den Inhalt von PDF-Dateien indizieren.",
"Extract Office" : "Office-Dateien extrahieren",
"Index the content of office files." : "Den Inhalt von Office-Dateien indizieren."
"Index the content of office files." : "Den Inhalt von Office-Dateien indizieren.",
"Results": "Ergebnisse",
"Open Files": "Dateien öffnen",
"Directly from search results.": "Direkt aus den Suchergebnissen."
},
"nplurals=2; plural=(n != 1);");
5 changes: 4 additions & 1 deletion l10n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"Extract PDF" : "PDF extrahieren",
"Index the content of PDF files." : "Den Inhalt von PDF-Dateien indizieren.",
"Extract Office" : "Office-Dateien extrahieren",
"Index the content of office files." : "Den Inhalt von Office-Dateien indizieren."
"Index the content of office files." : "Den Inhalt von Office-Dateien indizieren.",
"Results": "Ergebnisse",
"Open Files": "Dateien öffnen",
"Directly from search results.": "Direkt aus den Suchergebnissen."
},"pluralForm" :"nplurals=2; plural=(n != 1);"
}
4 changes: 3 additions & 1 deletion lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ConfigService {
public const FILES_IMAGE = 'files_image';
public const FILES_AUDIO = 'files_audio';
public const FILES_CHUNK_SIZE = 'files_chunk_size';
public const FILES_OPEN_RESULT_DIRECTLY = 'files_open_result_directly';

public $defaults = [
self::FILES_LOCAL => '1',
Expand All @@ -68,7 +69,8 @@ class ConfigService {
self::FILES_OFFICE => '1',
self::FILES_IMAGE => '0',
self::FILES_AUDIO => '0',
self::FILES_CHUNK_SIZE => FilesService::CHUNK_TREE_SIZE
self::FILES_CHUNK_SIZE => FilesService::CHUNK_TREE_SIZE,
self::FILES_OPEN_RESULT_DIRECTLY => '0'
];


Expand Down
11 changes: 8 additions & 3 deletions lib/Service/SearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,14 @@ private function setDocumentLinkFile(FilesDocument $document, string $dir, strin
return;
}

$document->setLink(
$this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'scrollto' => $filename])
);

if ($this->configService->getAppValue(ConfigService::FILES_OPEN_RESULT_DIRECTLY) !== '1') {
$link = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'scrollto' => $filename]);
} else {
$link = $this->urlGenerator->linkToRoute('files.View.showFile', ['fileid' => $document->getId()]);
}

$document->setLink($link);
}


Expand Down
16 changes: 15 additions & 1 deletion templates/settings.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@
-->

</div>
</div>

<h3 class="hsub"><?php p($l->t('Results')); ?></h3>
<div class="div-table">
<div class="div-table-row">
<div class="div-table-col div-table-col-left">
<span class="leftcol"><?php p($l->t('Open Files')); ?>:</span>
<br/>
<em><?php p($l->t('Directly from search results.')); ?></em>
</div>
<div class="div-table-col">
<input type="checkbox" id="files_open_result_directly" value="1"/>
</div>
</div>
</div>

</div>
</div>
Loading