@@ -74,7 +74,7 @@ function os2web_cp_service_handler() {
74
74
function os2web_gf_service_handler($file_id) {
75
75
if ($url = variable_get('os2web_cp_service_cp_document_fileurl')) {
76
76
variable_set('os2web_cp_service_cp_document_fileurl', 'http://10.1.1.118/Traen%20Publishing%20File%20Service%20-%20Sydjurs.dk/Download.aspx');
77
-
77
+
78
78
$username = variable_get('os2web_cp_service_endpoint_user');
79
79
$password = variable_get('os2web_cp_service_endpoint_password');
80
80
if (!empty($username) && !empty($password)) {
@@ -912,8 +912,8 @@ function os2web_cp_service_schedule_document_pdf2html_conversion($file_id, $case
912
912
913
913
/**
914
914
* Cron implementation.
915
- * Goes through the enrties in database table,
916
- * downloads the documents as pdf,
915
+ * Goes through the enrties in database table,
916
+ * downloads the documents as pdf,
917
917
* and converts the documents from pdf to html and updates the case metadata field with the document contents.
918
918
*
919
919
* @return none
@@ -928,7 +928,7 @@ function os2web_cp_service_cron(){
928
928
while($record = $result->fetchAssoc()) {
929
929
_os2web_cp_service_document_download($record['file_id']);
930
930
}
931
-
931
+
932
932
//convert
933
933
$query = db_select('os2web_cp_service_documents_conversion', 'dc');
934
934
$query->fields('dc',array('file_id', 'filepath_pdf'))
@@ -938,7 +938,7 @@ function os2web_cp_service_cron(){
938
938
while($record = $result->fetchAssoc()) {
939
939
_os2web_cp_service_document_convert($record['file_id'], $record['filepath_pdf']);
940
940
}
941
-
941
+
942
942
//field updating
943
943
$query = db_select('os2web_cp_service_documents_conversion', 'dc');
944
944
$query->fields('dc',array('file_id', 'case_nid', 'filepath_pdf', 'filepath_html'))
@@ -964,18 +964,18 @@ function os2web_cp_service_cron(){
964
964
function _os2web_cp_service_document_download($file_id){
965
965
$url = $GLOBALS['base_url'] . '/?q=os2web/service/gf/v1/' . $file_id;//address of remote file
966
966
$tmpfname = tempnam(file_directory_temp(), "os2web_cp_document_");//path to where the file will be downloaded
967
-
967
+
968
968
$fp = fopen($tmpfname, 'w');
969
-
969
+
970
970
$ch = curl_init($url);
971
971
curl_setopt($ch, CURLOPT_FILE, $fp);
972
972
$data= curl_exec($ch);
973
-
973
+
974
974
//Check for 404 (file not found)
975
975
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
976
976
curl_close($ch);
977
977
fclose($fp);
978
-
978
+
979
979
if ($httpCode == 404) {
980
980
print_r('404');
981
981
db_update('os2web_cp_service_documents_conversion')
@@ -984,7 +984,7 @@ function _os2web_cp_service_document_download($file_id){
984
984
))
985
985
->condition('file_id', $file_id)
986
986
->execute();
987
- } else if ($httpCode == 200) {
987
+ } else if ($httpCode == 200) {
988
988
db_update('os2web_cp_service_documents_conversion')
989
989
->fields(array(
990
990
'filepath_pdf' => $tmpfname,
@@ -1068,7 +1068,7 @@ function _os2web_cp_service_update_case_metadata($file_id, $case_nid, $path_to_p
1068
1068
->execute();
1069
1069
} else {
1070
1070
$text = file_get_contents($path_to_html);
1071
-
1071
+
1072
1072
//html tags removing
1073
1073
$text = str_replace('<p> </p>', ' ', $text); //removing unneeded paragraphs
1074
1074
$text = preg_replace('#<style(.*?)>(.*?)</style>#is', ' ', $text);//removing style tags
@@ -1077,28 +1077,21 @@ function _os2web_cp_service_update_case_metadata($file_id, $case_nid, $path_to_p
1077
1077
$text = str_replace("\n\r", " ", $text);
1078
1078
$text = str_replace("\n", " ", $text);
1079
1079
$text = str_replace("\r", " ", $text);
1080
-
1081
- $search_metadata = $case_node->field_os2web_cp_service_searchmt['und'][0]['value'] . $text;
1080
+
1081
+ $search_metadata = $case_node->field_os2web_cp_service_searchmt['und'][0]['value'] . $text;
1082
1082
$case_node->field_os2web_cp_service_searchmt['und'][0]['value'] = $search_metadata;
1083
1083
node_save($case_node);
1084
-
1084
+
1085
1085
db_update('os2web_cp_service_documents_conversion')
1086
1086
->fields(array(
1087
1087
'status' => 'done',
1088
1088
))
1089
1089
->condition('file_id', $file_id)
1090
1090
->execute();
1091
-
1091
+
1092
1092
//tmp files cleanup
1093
1093
unlink($path_to_html);
1094
1094
unlink($path_to_pdf);
1095
1095
}
1096
1096
}
1097
1097
}
1098
-
1099
- /**
1100
- * Update method installing the module's database without a need to uninstall/install it.
1101
- */
1102
- function os2web_cp_service_update_7100(){
1103
- drupal_install_schema('os2web_cp_service');
1104
- }
0 commit comments