Skip to content

Commit aa5d6c3

Browse files
committed
changes by skifter - attachments
1 parent 4551af6 commit aa5d6c3

File tree

1 file changed

+44
-36
lines changed

1 file changed

+44
-36
lines changed

plugins/mm/os2web_edoc_esdh_mm.inc

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,10 @@ function _os2web_edoc_esdh_mm_import_meeting_agenda(&$meeting, $agenda_xml) {
165165
'title' => $meeting['committee'],
166166
);
167167
// Import all agenda items.
168-
#error_log(print_r($agenda_xml, 1));
169168
$agenda_bullet = $agenda_xml;
170-
#error_log(print_r($agenda_xml, 1));
171169
foreach ($agenda_bullet->MeetingAgendaItem as $agenda_item) {
172-
#error_log(print_r($agenda_item, 1));
173170
if (($item = _os2web_edoc_esdh_mm_import_meeting_agenda_item($meeting, $agenda_item)) !== FALSE) {
174171
$agenda['items'][] = $item;
175-
## error_log(print_r($agenda_item, 1));
176172
}
177173
}
178174
// Apply defaults, just in case we missed something.
@@ -199,10 +195,10 @@ function _os2web_edoc_esdh_mm_import_meeting_agenda_item($meeting, $xml) {
199195
$xml_item['number'] = (int) $xml->AgendaItemNumber;
200196
$xml_item['pdf'] = (string) $xml->PDFDocument;
201197
$xml_item_document = $xml->Document;
198+
$xml_item_bullet = $xml_item_document->Attachments;
202199
$xml_item['name'] = (string) $xml_item_document->NeutralTitle;
203200
$xml_item['document_type'] = (string) $xml_item_document->PublishingType;
204201

205-
#error_log(print_r($meeting, 1));
206202
$item = array(
207203
'id' => $xml_item['number'],
208204
'title' => 'Punkt ' . $xml_item['number'] . ' ' . $xml_item['name'],
@@ -216,42 +212,54 @@ function _os2web_edoc_esdh_mm_import_meeting_agenda_item($meeting, $xml) {
216212
'title' => $xml_item['name'],
217213
),
218214
);
219-
error_log(print_r($item, 1));
220215

221216
// Deny closed content.
222217
if ($item['access'] === 'SKAL PUBLICERES') {
223-
// Process attachments.
224-
// foreach ($xml->xpath("table[@name='bullet']") as $bullet_xml) {
225-
// if (($bullet = _os2web_edoc_esdh_import_bullet($info, $bullet_xml)) !== FALSE) {
226-
// if (is_int($bullet['sort']) && $bullet['sort'] > 0) {
227-
// $item['bullets'][$bullet['sort'] - 1] = $bullet;
228-
// }
229-
// else {
230-
// $item['bullets'][] = $bullet;
231-
// }
232-
// }
233-
// }
234-
// Process attachments.
235-
#error_log(print_r($xml_item_document->Attachments, 1 ));
236-
foreach ($xml_item_document->Attachments as $enclosures) {
237-
#error_log(print_r($enclosure, 1 ));
238-
foreach ($enclosures->Attachment as $enclosure) {
239-
#error_log(print_r($enclosure, 1 ));
240-
$enclosure_item['filename_in'] = (string) $enclosure->PDFDocument;
241-
$enclosure_item['access'] = (string) $enclosure->PublishingType;
242-
if (strlen($enclosure_item['filename_in']) > 0 && $enclosure_item['access'] === 'SKAL PUBLICERES') {
243-
$item['enclosures'][] = array(
244-
'uri' => implode('/', array(
245-
trim($meeting['uri'], "/"),
246-
$enclosure_item['filename_in'])),
247-
'title' => trim((string) $enclosure->NeutralTitle),
248-
'access' => TRUE,
218+
// Process bullets.
219+
foreach ($xml_item_bullet->Attachment as $bullet_xml) {
220+
error_log("***********************");
221+
$bullet_title = (string) $bullet_xml->NeutralTitle;
222+
$bullet_body = (string) $bullet_xml->FullText;
223+
$bullet_access = $bullet_xml->PublishingType;
224+
error_log("access " . $bullet_access . "Titel: " . $bullet_title);
225+
if (empty($bullet_body)) {
226+
$bullet_body = "Intet indhold";
227+
}
228+
else {
229+
if($bullet_access == 'SKAL PUBLICERES') {
230+
}
231+
else {
232+
$bullet_body = "Dette er et lukket punkt. Du kan læse selve indstillingen" . $bullet_xml['access'];
233+
}
234+
}
235+
if (!empty($bullet_title)) {
236+
$item['bullets'][] = array(
237+
'title' => (string) $bullet_title,
238+
'body' => (string) $bullet_body,
249239
);
250240
}
251-
}
252-
}
241+
242+
# error_log(print_r($item, 1));
243+
// Process enclsures.
244+
# foreach ($xml_item_document->Attachment as $enclosures) {
245+
foreach ($xml_item_bullet->Attachment as $enclosure) {
246+
$enclosure_item['filename_in'] = (string) $enclosure->PDFDocument;
247+
$enclosure_item['access'] = (string) $enclosure->PublishingType;
248+
#error_log(print_r($enclosure,1));
249+
if (strlen($enclosure_item['filename_in']) > 0 && $enclosure_item['access'] == 'SKAL PUBLICERES') {
250+
$item['enclosures'][] = array(
251+
'uri' => implode('/', array(
252+
trim($meeting['uri'], "/"),
253+
$enclosure_item['filename_in'])),
254+
'title' => trim((string) $enclosure->Title),
255+
'access' => TRUE,
256+
);
257+
}
258+
}
259+
#error_log(print_r($item['enclosures'],1));
260+
# }
261+
}
253262
}
254-
#error_log(print_r($item, 1));
255263
$item += os2web_esdh_provider_default_item();
256264
return $item;
257265
}
@@ -303,7 +311,7 @@ function _os2web_edoc_esdh_mm_order_addenums($drush = FALSE) {
303311
return;
304312
}
305313
$nodes = $nodes_result['node'];
306-
error_log(print_r($nodes, 1));
314+
#error_log(print_r($nodes, 1));
307315
// Load necessary fields into the node object.
308316
$fields = field_info_instances('node', 'meeting');
309317
field_attach_load('node', $nodes, FIELD_LOAD_CURRENT, array('field_id' => $fields['field_os2web_meetings_addendum']['field_id']));

0 commit comments

Comments
 (0)