This repository was archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathScriptoAdapterDrupal.php
More file actions
102 lines (82 loc) · 2.48 KB
/
ScriptoAdapterDrupal.php
File metadata and controls
102 lines (82 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
require_once 'Scripto/Adapter/Interface.php';
class ScriptoAdapterDrupal implements Scripto_Adapter_Interface {
public function documentExists($documentId) {
// Verify that the node exists.
$node = node_load($documentId);
if (!$node) {
return false;
}
return true;
}
public function documentPageExists($documentId, $pageId) {
// Verify that the node exists.
$node = node_load($documentId);
if (!$node) {
return false;
}
// Verify that the file exists.
$file = file_load($pageId);
if (!$file) {
return false;
}
// Verify that the file belongs to the specified node.
$sql = "
SELECT *
FROM {file_usage}
WHERE fid = :fid
AND module = :module
AND type = :type
AND id = :id";
$result = db_query($sql, array(':fid' => $file->fid, ':module' => 'file',
':type' => 'node', ':id' => $node->nid));
if (!$result->fetchAll()) {
return false;
}
return true;
}
public function getDocumentPages($documentId) {
$node = node_load($documentId);
$pages = array();
foreach (_scripto_get_pages($node) as $page) {
$pages[$page['fid']] = $page['filename'];
}
return $pages;
}
public function getDocumentPageFileUrl($documentId, $pageId) {
$file = file_load($pageId);
return file_create_url($file->uri);
}
public function getDocumentFirstPageId($documentId) {
return;
}
public function getDocumentTitle($documentId) {
$node = node_load($documentId);
return $node->title;
}
public function getDocumentPageName($documentId, $pageId) {
$file = file_load($pageId);
return $file->filename;
}
public function documentTranscriptionIsImported($documentId) {
return false;
}
public function documentPageTranscriptionIsImported($documentId, $pageId) {
return false;
}
public function importDocumentPageTranscription($documentId, $pageId, $text) {
return false;
}
public function importDocumentTranscription($documentId, $text) {
$node = node_load($documentId);
$text = Scripto::removeNewPPLimitReports($text);
// Build the long_text field structure, in full HTML so no markup is
// filtered out.
$node->scripto_transcription[$node->language][0] = array(
'value' => $text,
'format' => 'full_html',
);
// Update the node with the new text.
field_attach_update('node', $node);
}
}