Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Maarch
archivesCourrier
Commits
14206a74
Commit
14206a74
authored
Aug 29, 2017
by
Cyril Vazquez
Browse files
Add bundle dir
parent
a0f92d8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
bundle/archivesCourrier/Controller/Content.php
0 → 100644
View file @
14206a74
<?php
/*
* Copyright (C) 2015 Maarch
*
* This file is part of bundle ArchivesCourrier
*
* Bundle ArchivesCourrier is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bundle ArchivesCourrier is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bundle ArchivesCourrier. If not, see <http://www.gnu.org/licenses/>.
*/
namespace
ext\archivesCourrier\bundle\archivesCourrier\Controller
;
/**
* Content controller
*
* @author Cyril Vazquez <cyril.vazquez@maarch.org>
*/
class
content
extends
\
ext\archivesPubliques\bundle\archivesPubliques\Controller\Content
implements
\
bundle\recordsManagement\Controller\archiveDescriptionInterface
{
/**
* Recherche d'un contenu d'archive
* @param string $query
* @param bool $hasParent
* @param date $sentDateFrom
* @param date $sentDateTo
* @param string $originatorOrgRegNumber
*
* @return Array Array of archive description
*/
public
function
find
(
$query
=
null
,
$hasParent
=
false
,
$sentDateFrom
=
null
,
$sentDateTo
=
null
,
$originatorOrgRegNumber
=
null
)
{
$queryParts
=
array
();
$queryParams
=
array
();
$currentDate
=
\
laabs
::
newDate
();
$currentDateString
=
$currentDate
->
format
(
'Y-m-d'
);
$queryParts
[
'accessRule'
]
=
$this
->
getAccessRuleAssert
();
if
(
$query
)
{
$tokens
=
\
laabs\explode
(
' '
,
$text
);
foreach
(
$tokens
as
$i
=>
$token
)
{
$tokens
[
$i
]
=
$token
.
':*'
;
}
$queryParts
[
'term'
]
=
"<?SQL text @@ to_tsquery('"
.
implode
(
' & '
,
$tokens
)
.
"') ?>"
;
}
// content description
if
(
$sentDateFrom
&&
$sentDateTo
)
{
$queryParams
[
'sentDateFrom'
]
=
$sentDateFrom
;
$queryParams
[
'sentDateTo'
]
=
$sentDateTo
;
$queryParts
[
'date'
]
=
"sentDateTo >= :sentDateFrom AND sentDateFrom <= :sentDateTo"
;
}
elseif
(
$sentDateFrom
)
{
$queryParams
[
'sentDateFrom'
]
=
$sentDateFrom
;
$queryParts
[
'date'
]
=
"sentDateFrom >= :sentDateFrom"
;
}
elseif
(
$sentDateTo
)
{
$queryParams
[
'sentDateTo'
]
=
$sentDateTo
;
$queryParts
[
'date'
]
=
"sentDateTo <= :sentDateTo"
;
}
if
(
$originatorOrgRegNumber
)
{
$queryParams
[
'originatorOrgRegNumber'
]
=
$originatorOrgRegNumber
;
$queryParts
[
'originatorOrgRegNumber'
]
=
"originatorOrgRegNumber = :originatorOrgRegNumber"
;
}
if
(
$hasParent
===
true
)
{
$queryParts
[
'hasParent'
]
=
"parentArchiveId!=null"
;
}
if
(
$hasParent
===
false
)
{
$queryParts
[
'hasParent'
]
=
"parentArchiveId=null"
;
}
$queryString
=
\
laabs\implode
(
' AND '
,
$queryParts
);
$contents
=
$this
->
sdoFactory
->
find
(
"archivesPubliques/archiveDescription"
,
$queryString
,
$queryParams
,
'>depositDate'
,
0
,
100
);
return
$contents
;
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment