Commit 65cf9643 authored by Dainis Abols's avatar Dainis Abols
Browse files

Fixed new file relation issues

v4.2.2
parent 003af661
...@@ -17,6 +17,7 @@ use Lu\LuNas\Sort; ...@@ -17,6 +17,7 @@ use Lu\LuNas\Sort;
//use TYPO3\CMS\Backend\View\BackendTemplateView; //use TYPO3\CMS\Backend\View\BackendTemplateView;
use TYPO3\CMS\Core\FormProtection\FormProtectionFactory; use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Resource\FileRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface; use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
...@@ -295,12 +296,18 @@ class FrontController extends ActionController ...@@ -295,12 +296,18 @@ class FrontController extends ActionController
// Get related // Get related
$related = $documentsModel->getRelated(); $related = $documentsModel->getRelated();
// Get document files
$fileLv = $this->getFileReferences($uid, 'filename_lv');
$fileEn = $this->getFileReferences($uid, 'filename_en');
// Assign data to view // Assign data to view
$this->view->assign('document', $document); $this->view->assign('document', $document);
$this->view->assign('self', $this->uriBuilder->setArguments(['tx_lunas_pi1[controller]' => 'Front'])->setAddQueryString(true)->build()); $this->view->assign('self', $this->uriBuilder->setArguments(['tx_lunas_pi1[controller]' => 'Front'])->setAddQueryString(true)->build());
$this->view->assign('related', $related); $this->view->assign('related', $related);
$this->view->assign('upload_folder', '/uploads/lu_nas/'); $this->view->assign('upload_folder', '/uploads/lu_nas/');
$this->view->assign('back_url', parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH)); $this->view->assign('back_url', parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH));
$this->view->assign('file_lv', $fileLv);
$this->view->assign('file_en', $fileEn);
} }
/** /**
...@@ -336,4 +343,19 @@ class FrontController extends ActionController ...@@ -336,4 +343,19 @@ class FrontController extends ActionController
return '&moduleToken='.$token; return '&moduleToken='.$token;
} }
} }
/**
* Get document file from UID
*
* @param $uid
*
* @return \TYPO3\CMS\Core\Resource\FileReference
*/
private function getFileReferences($uid, $tableField)
{
$personTable = GeneralUtility::makeInstance(Document::class)->getTableName();
$fileRepository = GeneralUtility::makeInstance(FileRepository::class);
return $fileRepository->findByRelation($personTable, $tableField, $uid);
}
} }
...@@ -54,18 +54,18 @@ ...@@ -54,18 +54,18 @@
</f:if> </f:if>
<!-- LV File download --> <!-- LV File download -->
<f:if condition="{document.filename_lv}"> <f:if condition="{file_lv.0.originalFile.name}">
<tr> <tr>
<td></td> <td></td>
<td><a target="_blank" href="{upload_folder}{document.filename_lv}"><f:translate key="form.download" /></a></td> <td><a target="_blank" href="{upload_folder}{file_lv.0.originalFile.name}"><f:translate key="form.download" /></a></td>
</tr> </tr>
</f:if> </f:if>
<!-- EN File download --> <!-- EN File download -->
<f:if condition="{document.filename_en}"> <f:if condition="{file_en.0.originalFile.name}">
<tr> <tr>
<td></td> <td></td>
<td><a target="_blank" href="{upload_folder}{document.filename_en}"><f:translate key="form.download" /></a></td> <td><a target="_blank" href="{upload_folder}{file_en.0.originalFile.name}"><f:translate key="form.download" /></a></td>
</tr> </tr>
</f:if> </f:if>
......
{ {
"name": "luitd/lu-nas", "name": "luitd/lu-nas",
"version": "4.2.1", "version": "4.2.2",
"description": "Latvijas Universitātes Normatīvo Aktu sistēmas TYPO3 spraudnis", "description": "Latvijas Universitātes Normatīvo Aktu sistēmas TYPO3 spraudnis",
"type": "typo3-cms-extension", "type": "typo3-cms-extension",
"keywords": [ "keywords": [
......
...@@ -9,7 +9,7 @@ $EM_CONF[$_EXTKEY] = [ ...@@ -9,7 +9,7 @@ $EM_CONF[$_EXTKEY] = [
'author_email' => 'dainis.abols@lu.lv', 'author_email' => 'dainis.abols@lu.lv',
'state' => 'stable', 'state' => 'stable',
'clearCacheOnLoad' => true, 'clearCacheOnLoad' => true,
'version' => '4.2.1', 'version' => '4.2.2',
'constraints' => [ 'constraints' => [
'depends' => [ 'depends' => [
'typo3' => '9.5.0-10.9.99', 'typo3' => '9.5.0-10.9.99',
......
...@@ -4,12 +4,12 @@ TYPO3 Extension for Regulations (NAS) ...@@ -4,12 +4,12 @@ TYPO3 Extension for Regulations (NAS)
## Version ## Version
4.2.1 4.2.2
## Dependecies ## Dependecies
TYPO3 v8+ (TYPO3 v9 Ready) TYPO3 v8+ (TYPO3 v9 Ready)
## Author ## Author
Dainis Abols <dainis.abols@lu.lv> Dainis Abols <dainis.abols@lu.lv>
...@@ -22,7 +22,7 @@ Dainis Abols <dainis.abols@lu.lv> ...@@ -22,7 +22,7 @@ Dainis Abols <dainis.abols@lu.lv>
* user_nas_connected_docs > tx_lunas_domain_model_related * user_nas_connected_docs > tx_lunas_domain_model_related
- id > uid - id > uid
* user_nas_document > tx_lunas_domain_model_document * user_nas_document > tx_lunas_domain_model_document
- id > uid - id > uid
- pid `NEW` - pid `NEW`
...@@ -45,7 +45,7 @@ Dainis Abols <dainis.abols@lu.lv> ...@@ -45,7 +45,7 @@ Dainis Abols <dainis.abols@lu.lv>
* user_nas_document_rikojuma_dokum > tx_lunas_domain_model_ordertype * user_nas_document_rikojuma_dokum > tx_lunas_domain_model_ordertype
- id > uid - id > uid
- pid `NEW` - pid `NEW`
* user_nas_document_status > tx_lunas_domain_model_status * user_nas_document_status > tx_lunas_domain_model_status
- id > uid - id > uid
- pid `NEW` - pid `NEW`
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment