1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @package org.openpsa.documents |
4
|
|
|
* @author Nemein Oy http://www.nemein.com/ |
5
|
|
|
* @copyright Nemein Oy http://www.nemein.com/ |
6
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
use midcom\datamanager\datamanager; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* OpenPSA document management system |
13
|
|
|
* |
14
|
|
|
* @package org.openpsa.documents |
15
|
|
|
*/ |
16
|
|
|
class org_openpsa_documents_interface extends midcom_baseclasses_components_interface |
17
|
|
|
implements midcom_services_permalinks_resolver |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Prepare the indexer client |
21
|
|
|
*/ |
22
|
|
|
public function _on_reindex($topic, midcom_helper_configuration $config, midcom_services_indexer $indexer) |
23
|
|
|
{ |
24
|
|
|
$qb_documents = org_openpsa_documents_document_dba::new_query_builder(); |
25
|
|
|
$qb_documents->add_constraint('topic', '=', $topic->id); |
26
|
|
|
$qb_documents->add_constraint('nextVersion', '=', 0); |
27
|
|
|
$dm_documents = datamanager::from_schemadb($config->get('schemadb_document')); |
|
|
|
|
28
|
|
|
|
29
|
|
|
$qb_directories = org_openpsa_documents_directory::new_query_builder(); |
30
|
|
|
$qb_directories->add_constraint('up', '=', $topic->id); |
31
|
|
|
$qb_directories->add_constraint('component', '=', $this->_component); |
32
|
|
|
$dm_directories = datamanager::from_schemadb($config->get('schemadb_directory')); |
33
|
|
|
|
34
|
|
|
$indexer = new org_openpsa_documents_midcom_indexer($topic, $indexer); |
35
|
|
|
$indexer->add_query('documents', $qb_documents, $dm_documents); |
36
|
|
|
$indexer->add_query('directories', $qb_directories, $dm_directories); |
37
|
|
|
|
38
|
|
|
return $indexer; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function resolve_object_link(midcom_db_topic $topic, midcom_core_dbaobject $object) : ?string |
42
|
|
|
{ |
43
|
|
|
if ( $object instanceof org_openpsa_documents_document_dba |
44
|
|
|
&& $object->topic == $topic->id) { |
45
|
|
|
return "document/{$object->guid}/"; |
46
|
|
|
} |
47
|
|
|
return null; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|