Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class CmdiTemplateBuilder
private static function noTemplatesFound()
{
return [
// '#markup' => '<strong>No templates available for this block</strong><br /><br />',
# no templates found
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ class CmdiTemplateData
}
}

// if (count($options) > 0) {
// $options = [0 => '- select template -'] + $options;
// }

return $options;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CmdiTemplateLoader

$copy = $block['element'];
$metadata = $copy['#flat_cmdi_metadata'];

$copy['flat_cmdi_templates'] = CmdiTemplateManager::build($metadata['component_id'], $metadata['profile'], $metadata['tree']);
$copy['#panel_actions'] = CmdiTemplateManager::buildActions($metadata['profile'], $metadata['component_id'], $metadata['tree']);

Expand All @@ -54,6 +55,25 @@ class CmdiTemplateLoader
$block = static::getLoadedBlock($loadable['id']);

if (false !== $block) {
// $tree = array_merge(['template_container', 'elements'], $loadable['cmdi_tree']);
// dfb($loadable);
// dfb($tree);
// dfb($form_state['pressedButtons']);
if (isset($form_state['pressedButtons'])) {

# when block gets loaded, we need to reset the pressedButtons state
# back to null to prevent FormBuilder from rebuilding previous form states
$tree = array_merge(['template_container', 'elements'], $loadable['cmdi_tree']);
// dfb($tree);
// dfb($form_state['input']['template_container']);
// dfb($form_state['input']['template_container']['elements']['Contributors']);
// dfb($form_state['values']['template_container']);
// dfb($form_state['values']['template_container']['elements']['Contributors']);
// drupal_array_set_nested_value($form_state['pressedButtons'], $tree, null);
// dfb($form_state['pressedButtons']);
drupal_array_set_nested_value($form_state['pressedButtons'], $tree, []);
}

static::loadElement($elements, $loadable['cmdi_tree'], $block);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ class CmdiTemplateManager
{
public static function alter(&$form, &$form_state)
{
// if (isset($form_state['pressedButtons'])) {
// dfb('------- PRESSED BUTTONS ------ ');
// dfb($form_state['pressedButtons']);
// dfb('------- PRESSED BUTTONS ------ ');
// }
$form['flat_modal'] = CmdiModalBuilder::build();

if (!isset($form_state['loaded_cmdi_templates'])) {
Expand All @@ -24,7 +29,7 @@ class CmdiTemplateManager
static::rebuild($form['template_container']['elements'], $cmdi_tree, $profile, $component_id);
}

$saved = static::saveLoaded($form_state);
$saved = static::saveLoaded($form_state);
$loaded = static::load($form['template_container']['elements'], $form_state);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class CmdiTemplateSaver
return null;
}

// dfb($this->form_state['pressedButtons']);
// dfb($tree);

return json_encode([

'tree' => $tree,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ abstract class FormComponent
{
$formComponentFields = array_keys($this->formComponent);
$cmdiTemplateFields = array_filter($formComponentFields, function($field) {
// return $field !== 'add' && $field !== 'remove';
return $field !== 'wut';
return $field !== 'flat_cmdi_templates' || $field !== '#panel_actions';
});

$this->formComponent['#cmdi_template_fields'] = $cmdiTemplateFields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public function triggerServlet($sipId, $to=NULL, $namespace = NULL, $parentFid =
curl_setopt($ch, CURLOPT_URL, $config['url'] . $sipId . $query);
curl_setopt($ch, CURLOPT_PORT, $config['port']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "flat:sword");
curl_setopt($ch, CURLOPT_PUT, 1);

$val = curl_exec($ch);
Expand Down Expand Up @@ -93,7 +94,8 @@ public function doGetRequest($sipId, $code_only=FALSE)
curl_setopt($ch, CURLOPT_URL, $config['url'] . $sipId);
curl_setopt($ch, CURLOPT_PORT, $config['port']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "flat:sword");

$val = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function flat_bundle_action_form_validate_validate($form, &$form_state){
$has_cmdi = has_cmdi($nid);
$valid_xml = is_valid_xml($nid, $has_cmdi);
//$good_name = has_correct_filename($nid); filename here not relevant, only in SIP that is offered to doorkeeper
$file_exists = bundle_file_exists($nid);
$file_exists = bundle_file_exists($nid);
$user_has_permissions = user_has_permissions($nid);
$max_files_exceeded = bundle_max_files_exceeded($nid);
$max_file_size_exceeded = bundle_max_file_size_exceeded($nid);
Expand Down Expand Up @@ -334,11 +334,11 @@ function flat_bundle_action_form_validate_validate($form, &$form_state){
$errors[] = t('The selected folder contains files that have a disallowed file extension: !invalid_file_extensions_list. See the deposit manual for allowed file types and extensions.', ['!invalid_file_extensions_list' => $invalid_file_extensions_list]);
}

if ($has_flat_uri){
if (isset($has_flat_uri) && $has_flat_uri){
$errors[] = t('Your uploaded CMDI file contains references to files that are already in the archive. To use this CMDI file for a different set of files, use the "upload CMDI file as template" option, see deposit manual.');
}

if ($files_mismatch) {
if (isset($files_mismatch) && $files_mismatch) {
$files_mismatch_list = implode(", ", $files_mismatch);
$errors[] = t('There is a mismatch between the files listed in your uploaded CMDI file and the files you provided in the selected folder. Missing file(s): !files_mismatch_list. In case you wish to use this CMDI file for a different set of files, use the "upload CMDI file as template" option, see deposit manual.', ['!files_mismatch_list' => $files_mismatch_list]);
}
Expand Down Expand Up @@ -375,7 +375,7 @@ function flat_bundle_action_form_submit($form, &$form_state)
case 'Edit metadata for bundle':
$url = array('node/' . $node->nid . '/edit_cmdi');
$form_state['redirect'] = $url;
break;
break;


case 'Validate bundle':
Expand Down