-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* XML OBJ editing form. | ||
*/ | ||
|
||
/** | ||
* Retrives the XML edit form. | ||
* | ||
* @param AbstractObject $object | ||
* The Islandora object. | ||
* | ||
* @return array | ||
* The form array. | ||
*/ | ||
function islandora_solution_pack_xml_edit_xml(AbstractObject $object) { | ||
return drupal_get_form('islandora_solution_pack_xml_edit_xml_form', $object); | ||
} | ||
|
||
/** | ||
* Form callback. | ||
*/ | ||
function islandora_solution_pack_xml_edit_xml_form($form, &$form_state, AbstractObject $object) { | ||
$xml = $object['OBJ']->content; | ||
return array( | ||
'xml' => array( | ||
'#title' => t('XML OBJ datastream content'), | ||
'#type' => 'textarea', | ||
'#rows' => 20, | ||
'#description' => t('Edit your XML here. Note that no validation or well-formedness checking is performed on this content.'), | ||
'#default_value' => $xml, | ||
), | ||
'object' => array( | ||
'#type' => 'value', | ||
'#value' => $object->id, | ||
), | ||
'submit' => array( | ||
'#type' => 'submit', | ||
'#value' => t('Save'), | ||
), | ||
); | ||
} | ||
|
||
/** | ||
* From submit function. | ||
*/ | ||
function islandora_solution_pack_xml_edit_xml_form_submit($form, &$form_state) { | ||
$object = islandora_object_load($form_state['values']['object']); | ||
if (!$object['OBJ']) { | ||
$xml = $object->constructDatastream('OBJ', 'M'); | ||
$xml->mimetype = 'application/xml'; | ||
$xml->label = 'XML content'; | ||
} | ||
else { | ||
$xml = $object['OBJ']; | ||
} | ||
$xml->setContentFromString($form_state['values']['xml']); | ||
$object->ingestDatastream($xml); | ||
drupal_set_message(t("XML updated for !object.", array('!object' => $object->id))); | ||
drupal_goto("islandora/object/{$object->id}/manage/datastreams"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters