if (($cm=ContentModel::loadFromModel($model_pid))!==FALSE)
{
if (!$cm->removeAuthListItem($elementName,$authValue) || !$cm->saveToFedora())
{
echo t('Error: Unable to remove authoritative list item <b>%value</b> in model <b>%m_pid</b>.',array('%value'=>$authValue,'%m_pid'=>$cm->pid));
} else
{
echo 'success:'. t('Successfully removed authoritative list item <b>%value</b> in model <b>%m_pid</b>.',array('%value'=>$authValue,'%m_pid'=>$cm->pid));
echo t('Error: Missing parameters to remove authoritative list item. Please try again.');
}
break;
case 'icm_model_inc_authlistitem':
if (count($params) == 4)
{
$model_pid = $params[1];
$elementName = $params[2];
$authValue = $params[3];
if (($cm=ContentModel::loadFromModel($model_pid))!==FALSE)
{
if (!$cm->incAuthListItem($elementName,$authValue) || !$cm->saveToFedora())
{
echo t('Error: Unable to increment authoritative list item <b>%value</b> in model <b>%m_pid</b>.',array('%value'=>$authValue,'%m_pid'=>$cm->pid));
} else
{
echo 'success:'. t('Successfully incremented authoritative list item <b>%value</b> in model <b>%m_pid</b>.',array('%value'=>$authValue,'%m_pid'=>$cm->pid));
echo t('Error: Missing parameters to increment authoritative list item. Please try again.');
}
break;
case 'icm_model_dec_authlistitem':
if (count($params) == 4)
{
$model_pid = $params[1];
$elementName = $params[2];
$authValue = $params[3];
if (($cm=ContentModel::loadFromModel($model_pid))!==FALSE)
{
if (!$cm->decAuthListItem($elementName,$authValue) || !$cm->saveToFedora())
{
echo t('Error: Unable to decrement authoritative list item <b>%value</b> in model <b>%m_pid</b>.',array('%value'=>$authValue,'%m_pid'=>$cm->pid));
} else
{
echo 'success:'. t('Successfully decremented authoritative list item <b>%value</b> in model <b>%m_pid</b>.',array('%value'=>$authValue,'%m_pid'=>$cm->pid));
echo t('Error: Missing parameters to decrement ingest form element. Please try again.');
}
break;
case 'icm_model_remove_dispmeth':
if (count($params) == 7)
{
$model_pid = $params[1];
$dsid = $params[2];
$module = $params[3];
$file = $params[4];
$class = $params[5];
$method = $params[6];
if (($cm=ContentModel::loadFromModel($model_pid))!==FALSE)
{
if (!$cm->removeDispMeth($dsid, $module, $file,$class,$method) || !$cm->saveToFedora())
{
echo t('Error: Unable to remove display method for datastream <b>%dsid</b> of model <b>%m_pid</b>.',array('%dsid'=>$dsid,'%m_pid'=>$cm->pid));
} else
{
echo 'success:'. t('Successfully remove display method for datastream <b>%dsid</b> of model <b>%m_pid</b>.',array('%dsid'=>$dsid, '%m_pid'=>$cm->pid));
echo t('Error: Missing parameters to remove display method of datastream.');
}
break;
case 'icm_model_default_dispmeth':
if (count($params) == 7)
{
$model_pid = $params[1];
$dsid = $params[2];
$module = $params[3];
$file = $params[4];
$class = $params[5];
$method = $params[6];
if (($cm=ContentModel::loadFromModel($model_pid))!==FALSE)
{
if (!$cm->setDefaultDispMeth($dsid,$module,$file,$class,$method) || !$cm->saveToFedora())
{
echo t('Error: Unable to set default display method for datastream <b>%dsid</b> of model <b>%m_pid</b>.',array('%dsid'=>$dsid,'%m_pid'=>$cm->pid));
} else
{
echo 'success:'. t('Successfully set default display method for datastream <b>%dsid</b> of model <b>%m_pid</b>.',array('%dsid'=>$dsid, '%m_pid'=>$cm->pid));
echo t('Error: Missing parameters for removal of application mimetype.');
}
break;
case 'icm_model_remove_appliesto':
if (count($params) == 4)
{
$model_pid = $params[1];
$rule_id = $params[2];
if (($cm=ContentModel::loadFromModel($model_pid))!==FALSE)
{
if (!$cm->removeAppliesTo($rule_id,$params[3] ) || !$cm->saveToFedora())
{
echo t('Error: Unable to remove application mimetype from <b>Rule %rule_id</b> in model <b>%m_pid</b>.',array('%rule_id'=>$rule_id,'%m_pid'=>$cm->pid));
} else
{
echo 'success:'. t('Successfully removed application mimetype from <b>Rule %rule_id</b> in model <b>%m_pid</b>.',array('%rule_id'=>$rule_id,'%m_pid'=>$cm->pid));
echo t('Error: Missing parameters for removal of ingest rule.');
}
break;
case 'icm_model_remove_ingestmethod':
if (count($params) == 7)
{
$model_pid = $params[1];
$rule_id = $params[2];
$module = $params[3];
$file = $params[4];
$class = $params[5];
$method = $params[6];
if (($cm=ContentModel::loadFromModel($model_pid))!==FALSE)
{
if (!$cm->removeIngestMethod($rule_id, $module, $file, $class, $method) || !$cm->saveToFedora())
{
echo t('Error: Unable to remove ingest method of <b>Rule %rule_id</b> in model <b>%m_pid</b>.',array('%rule_id'=>$rule_id,'%m_pid'=>$cm->pid));
} else
{
echo 'success:'. t('Successfully removed ingest method of <b>Rule %rule_id</b> in model <b>%m_pid</b>.',array('%rule_id'=>$rule_id,'%m_pid'=>$cm->pid));
echo t('Error: Missing parameters for removal of ingest method parameter.');
}
break;
case 'icm_model_remove_ingestelementparam':
if (count($params) == 4)
{
$model_pid = $params[1];
$element_name = $params[2];
$name = $params[3];
if (($cm=ContentModel::loadFromModel($model_pid))!==FALSE)
{
if (!$cm->setIngestFormElementParam($element_name, $name, FALSE) || !$cm->saveToFedora())
{
echo t('Error: Unable to remove parameter of element <b>%element</b> in model <b>%m_pid</b>.',array('%element'=>$element_name,'%m_pid'=>$cm->pid));
} else
{
echo 'success:'. t('Successfully removed parameter of element <b>%element</b> in model <b>%m_pid</b>.',array('%element'=>$element_name,'%m_pid'=>$cm->pid));
if (!$cp->removeModel($cm) || !$cp->saveToFedora())
{
echo t('Error: Unable to remove content model <b>%m_pid</b> from collection policy of <b>%c_pid</b>.',array('%m_pid'=>$cm->pid,'%c_pid'=>$cp->pid));
} else
{
echo 'success:'.t('Successfully removed content model <b>%m_pid</b> from collection policy of <b>%c_pid</b>.',array('%m_pid'=>$cm->pid,'%c_pid'=>$cp->pid));
if (($cp = CollectionPolicy::loadFromCollection(trim($c_pid)))!== FALSE)
{
$field=isset($params[2])?$params[2]:'';
if (trim($field) != '')
{
if (!$cp->setDefaultTerm(htmlentities($field)) || !$cp->saveToFedora())
{
echo t('Error: Unable to set default search term to <b>%field</b> in collection policy <b>%cp_id</b>.',array('%field'=>htmlentities($field),'%pc_pid'=>$cp->pid));
} else
{
echo 'success:'.t('Successfully set default search term <b>%field</b> in collection policy <b>%cp_id</b>.',array('%field'=>htmlentities($field),'%cp_pid'=>$cp->pid));
exit();
}
} else
{
echo t('Error: Unknown search term <b>%field</b> selected. Please try again.',array('%field'=>htmlentities($field)));
if (($cp = CollectionPolicy::loadFromCollection(trim($c_pid)))!== FALSE)
{
$field=isset($params[2])?$params[2]:'';
if (trim($field) != '')
{
if (!$cp->removeTerm(htmlentities($field)) || !$cp->saveToFedora())
{
echo t('Error: Unable to remove search term <b>%field</b> from collection policy <b>%cp_id</b>.',array('%field'=>htmlentities($field),'%c_pid'=>$cp->pid));
} else
{
echo 'success:'.t('Successfully removed search term <b>%field</b> from collection policy <b>%cp_id</b>.',array('%field'=>htmlentities($field),'%c_pid'=>$cp->pid));
exit();
}
} else
{
echo t('Error: Unknown search term <b>%field</b> selected for removal. Please try again.',array('%field'=>htmlentities($field)));
if (($cm = ContentModel::loadFromModel(trim($m_pid))) !== FALSE)
{
$type = isset($params[2])?trim($params[2]):'';
if ($type == '')
{
echo t('Error: You must specify a mimetype to remove. Please try again.');
} else
{
if ($cm->removeMimetype($type) && $cm->saveToFedora())
{
echo 'success:'.t('Successfully removed mime type <b>%type</b> from content model <b>%m_pid</b>.',array('%type'=>htmlentities($type),'%m_pid'=>htmlentities($m_pid)));
exit();
} else
{
echo t('Error: Unable to remove mime type <b>%type</b> from content model <b>%m_pid</b>. Please make sure that it isnt the only term left in the content model.',array('%type'=>htmlentities($type),'%m_pid'=>htmlentities($m_pid)));
if (trim($form_state['values']['addMime']['model_pid'])=='' || ($cm = ContentModel::loadFromModel(trim($form_state['values']['addMime']['model_pid']))) === FALSE)
{
form_set_error('',t('Error: Specified model could not be found.'));
} else if ($cm->addMimetype(trim($form_state['values']['addMime']['type'])) === FALSE || $cm->saveToFedora() === FALSE)
{
form_set_error('',t('Error: Unable to add mimetype to specified model. Please make sure that the mimetype is not already listed in the model.'));
} else
{
echo 'success:'.t('Successfully added mimetype <b>%mimetype</b> to model <b>%model_name</b>',array('%model_name'=>$cm->name,'%mimetype'=>trim($form_state['values']['addMime']['type'])));
exit();
}
}
function icm_model_add_mime(&$form_state,$params=null)
{
if (is_array($params) && isset($params[0]))
{
$model_pid = $params[0];
} else if (isset($form_state['post']['addMime']['model_pid']))
if ($cp->addModel($cm,trim($form_state['values']['form']['namespace'])) && $cp->saveToFedora())
{
echo 'success:'.t('Successfully added content model <b>%cm_pid%</b> to collection policy of <b>%cp_pid%</b>.',array('%cm_pid%'=>$cm->pid,'%cp_pid%'=>$cp->pid));
exit();
} else
{
form_set_error('form][model_pid',t('Error: Unable to add content model <b>%cm_pid%</b> to collection policy of <b>%cp_pid%</b>. Please make sure that the model is not already listed in the collection policy.',array('%cm_pid%'=>$cm->pid,'%cp_pid%'=>$cp->pid)));
}
} else
{
form_set_error('',t('Error: Unable to load specified content model or collection policy. Please try again.'));
}
}
}
function icm_collection_add_cmodel(&$form_state,$params=null)
{
if (is_array($params) && isset($params[0]))
{
$collection_pid = $params[0];
} else if (isset($form_state['post']['form']['collection_pid']))
if (trim($form_state['values']['form']['collection_pid'])=='' || ($cp = CollectionPolicy::loadFromCollection(trim($form_state['values']['form']['collection_pid']))) === FALSE)
{
form_set_error('',t('Error: Specified collection policy could not be found.'));
} else if ($cp->addTerm(trim($form_state['values']['form']['field']),trim($form_state['values']['form']['value'])) === FALSE || $cp->saveToFedora() === FALSE)
{
form_set_error('',t('Error: Unable to add search term to specified collection policy. Please make sure that the field is not already listed in the search terms.'));
} else
{
echo 'success:'.t('Successfully added term <b>%field</b> to collection policy <b>%cp_pid</b>',array('%cp_pid'=>$cp->pid,'%field'=>trim($form_state['values']['form']['field'])));
exit();
}
}
function icm_collection_add_term(&$form_state,$params=null)
{
if (is_array($params) && isset($params[0]))
{
$collection_pid = $params[0];
} else if (isset($form_state['post']['collection_pid']))
'#description' => 'If enabled, also purges versions of the datastream that are OLDER than the selected, effectively leaving only the selected version.'
echo 'success:'.t('Successfully added parameter to ingest method of <b>Rule %rule_id</b> for model <b>%model_pid</b>.',array('%rule_id'=>htmlentities($form_state['values']['form']['rule_id']),'%model_pid'=>$cm->pid));
exit();
} else
{
form_set_error('form][name',t('Error: Unable to add parameter to ingest method of <b>Rule %rule_id</b> for model <b>%model_pid</b>. Please make sure that the parameter is not already listed.',array('%rule_id'=>htmlentities($form_state['values']['form']['rule_id']),'%model_pid'=>$cm->pid)));
}
} else
{
form_set_error('',t('Error: Unable to load content model <b>%cm_pid</b>.',array('%cm_pid'=>htmlentities($form_state['values']['form']['model_pid']))));
}
}
function icm_model_add_ingestMethodParam(&$form_state,$params=null)
{
if (is_array($params))
{
$model_pid = $params[0];
$rule_id = $params[1];
$module = $params[2];
$file = $params[3];
$class = $params[4];
$method = $params[5];
} else
{
$model_pid = $form_state['post']['model_id'];
$rule_id = $form_state['post']['rule_id'];
$module = $form_state['post']['module'];
$file = $form_state['post']['file'];
$class = $form_state['post']['class'];
$method = $form_state['post']['method'];
}
$form['form'] = array(
'#type' => 'fieldset',
'#title' => t('Add Ingest Method Parameter to ingest <b>Rule %rule_id</b> of model <b>%model_pid</b>.',array('%rule_id'=>$rule_id,'%model_pid'=>$model_pid)),
'#tree' => TRUE,
);
$form['form']['module_label'] = array(
'#type'=> 'item',
'#title'=> t('Module'),
'#value' => $module
);
$form['form']['file_label'] = array(
'#type'=> 'item',
'#title'=> t('Filename'),
'#value' => $file
);
$form['form']['class_label'] = array(
'#type'=> 'item',
'#title'=> t('Class'),
'#value' => $class
);
$form['form']['method_label'] = array(
'#type'=> 'item',
'#title'=> t('Method'),
'#value' => $method
);
$form['form']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#size' => 30,
'#required' => TRUE,
'#description' => t('The name of the parameter to pass along to the ingest method above.'),
);
$form['form']['value'] = array(
'#type' => 'textfield',
'#title' => t('Value'),
'#size' => 30,
'#required' => TRUE,
'#description' => t('The value of the parameter to pass along to the ingest method above'),
echo 'success:'.t('Successfully added parameter to form element <b>%element_name</b> for model <b>%model_pid</b>.',array('%element_name'=>htmlentities($form_state['values']['form']['element_name']),'%model_pid'=>$cm->pid));
exit();
} else
{
form_set_error('form][name',t('Error: Unable to add parameter to form element <b>%element_name</b> for model <b>%model_pid</b>. Please make sure that the parameter is not already listed.',array('%element_name'=>htmlentities($form_state['values']['form']['element_name']),'%model_pid'=>$cm->pid)));
}
} else
{
form_set_error('',t('Error: Unable to load content model <b>%cm_pid</b>.',array('%cm_pid'=>htmlentities($form_state['values']['form']['model_pid']))));
}
}
function icm_model_add_ingestElementParam(&$form_state,$params=null)
'#title' => t('Add Ingest Form Element Parameter to element <b>%element_name</b> of model <b>%model_pid</b>.',array('%element_name'=>$element_name,'%model_pid'=>$model_pid)),
'#tree' => TRUE,
);
$form['form']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#size' => 30,
'#required' => TRUE,
'#description' => t('The name of the parameter to pass along to the form element above.'),
);
$form['form']['value'] = array(
'#type' => 'textarea',
'#title' => t('Value'),
'#size' => 30,
'#required' => TRUE,
'#description' => t('The value of the parameter to pass along to the form element above'),
if (($cm = ContentModel::loadFromModel($form_state['values']['form']['model_pid']))!==FALSE)
{
if ($cm->addIngestMethod($form_state['values']['form']['rule_id'],$module,$module,$file,$class,$method,$form_state['values']['form']['dsid'],$form_state['values']['form']['modified_files_ext']) && $cm->saveToFedora())
{
echo 'success:'.t('Successfully added ingest method to <b>Rule %rule_id</b> for model <b>%model_pid</b>.',array('%rule_id'=>htmlentities($form_state['values']['form']['rule_id']),'%model_pid'=>$cm->pid));
exit();
} else
{
form_set_error('form][name',t('Error: Unable to add ingest method to <b>Rule %rule_id</b> for model <b>%model_pid</b>.',array('%rule_id'=>htmlentities($form_state['values']['form']['rule_id']),'%model_pid'=>$cm->pid)));
}
} else
{
form_set_error('',t('Error: Unable to load content model <b>%cm_pid</b>.',array('%cm_pid'=>htmlentities($form_state['values']['form']['model_pid']))));
}
}
function icm_model_add_ingestMethod(&$form_state,$params=null)
if (($cm = ContentModel::loadFromModel($form_state['values']['form']['model_pid']))!==FALSE)
{
if ($cm->addAppliesTo($form_state['values']['form']['rule_id'],$form_state['values']['form']['appliesTo']) && $cm->saveToFedora())
{
echo 'success:'.t('Successfully added application mimetype to <b>Rule %rule_id</b> for model <b>%model_pid</b>.',array('%rule_id'=>htmlentities($form_state['values']['form']['rule_id']),'%model_pid'=>$cm->pid));
exit();
} else
{
form_set_error('form][name',t('Error: Unable to add application mimetype to <b>Rule %rule_id</b> for model <b>%model_pid</b>.',array('%rule_id'=>htmlentities($form_state['values']['form']['rule_id']),'%model_pid'=>$cm->pid)));
}
} else
{
form_set_error('',t('Error: Unable to load content model <b>%cm_pid</b>.',array('%cm_pid'=>htmlentities($form_state['values']['form']['model_pid']))));
}
}
function icm_model_add_appliesTo(&$form_state,$params=null)
'#title' => t('Add application mimetype to ingest <b>Rule %rule_id</b> of model <b>%model_pid</b>',array('%rule_id'=>$rule_id,'%model_pid'=>$model_pid)),
'#tree' => TRUE,
);
$form['form']['appliesTo'] = array(
'#type' => 'textfield',
'#title' => t('Applies To'),
'#size' => 30,
'#required' => TRUE,
'#description' => t('A content mimetype that this ingest rule will be applied to.'),
if (($cm = ContentModel::loadFromModel($form_state['values']['form']['model_pid']))!==FALSE)
{
if ($cm->addIngestRule($form_state['values']['form']['appliesTo'],$module,$file,$class,$method,$form_state['values']['form']['dsid'],$form_state['values']['form']['modified_files_ext']) && $cm->saveToFedora())
{
echo 'success:'.t('Successfully added ingest method to <b>Rule %rule_id</b> for model <b>%model_pid</b>.',array('%rule_id'=>htmlentities($form_state['values']['form']['rule_id']),'%model_pid'=>$cm->pid));
exit();
} else
{
form_set_error('form][name',t('Error: Unable to add ingest rule for model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid)));
}
} else
{
form_set_error('',t('Error: Unable to load content model <b>%cm_pid</b>.',array('%cm_pid'=>htmlentities($form_state['values']['form']['model_pid']))));
}
}
function icm_model_add_ingestRule(&$form_state,$params=null)
if (($cm = ContentModel::loadFromModel($form_state['values']['form']['model_pid']))!==FALSE)
{
if ($cm->addDs($form_state['values']['form']['dsid'],$form_state['values']['form']['display_in_fieldset']==1) && $cm->saveToFedora())
{
echo 'success:'.t('Successfully added datastream to model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid));
exit();
} else
{
form_set_error('form][name',t('Error: Unable to add datastream to model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid)));
}
} else
{
form_set_error('',t('Error: Unable to load content model <b>%cm_pid</b>.',array('%cm_pid'=>htmlentities($form_state['values']['form']['model_pid']))));
}
}
function icm_model_add_ds(&$form_state,$params=null)
if (($cm = ContentModel::loadFromModel($form_state['values']['form']['model_pid']))!==FALSE)
{
if ($cm->addDispMeth($form_state['values']['form']['dsid'],$module,$file,$class,$method) && $cm->saveToFedora())
{
echo 'success:'.t('Successfully added display method to datastream <b>%dsid</b> of model <b>%model_pid</b>.',array('%dsid'=>htmlentities($form_state['values']['form']['dsid']),'%model_pid'=>$cm->pid));
exit();
} else
{
form_set_error('form][name',t('Error: Unable to add display method to datastream <b>%dsid</b> of model <b>%model_pid</b>.',array('%dsid'=>htmlentities($form_state['values']['form']['dsid']),'%model_pid'=>$cm->pid)));
}
} else
{
form_set_error('',t('Error: Unable to load content model <b>%cm_pid</b>.',array('%cm_pid'=>htmlentities($form_state['values']['form']['model_pid']))));
}
}
function icm_model_add_dispmeth(&$form_state,$params=null)
if (empty($path) || !file_exists($path.'/'.$file))
{
form_set_error('form][filename',t('Error: Selected plugin file not found. Please try again.'));
} else
{
require_once ($path.'/'.$file);
if (!class_exists($class))
{
form_set_error('form][class',t('Error: Specified class does not exist in the plugin. Please try again.'));
} else
{
$obj = @new $class;
if (!method_exists($obj,$method))
{
form_set_error('form][method',t('Error: Specified builder method does not exist in the specified class/plugin. Please try again.'));
}
if (!method_exists($obj,$handler))
{
form_set_error('form][handler',t('Error: Specified handler method does not exist in the specified class/plugin. Please try again.'));
}
}
}
//only proceed if no errors have been found.
if (form_get_errors() !== NULL)
return;
if (($cm = ContentModel::loadFromModel($form_state['values']['form']['model_pid']))!==FALSE)
{
if ($cm->editIngestFormAttributes(htmlentities($form_state['values']['form']['dsid']),htmlentities($form_state['values']['form']['page']),$form_state['values']['form']['hide_file_chooser']==1,$form_state['values']['form']['redirect']==1)
echo 'success:'.t('Successfully updated ingest form of model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid));
exit();
} else
{
form_set_error('form][name',t('Error: Unable to update ingest form of model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid)));
}
} else
{
form_set_error('',t('Error: Unable to load content model <b>%cm_pid</b>.',array('%cm_pid'=>htmlentities($form_state['values']['form']['model_pid']))));
}
}
function icm_model_edit_ingestForm(&$form_state,$params=null)
if (empty($path) || !file_exists($path.'/'.$file))
{
form_set_error('form][filename',t('Error: Selected plugin file not found. Please try again.'));
} else
{
require_once ($path.'/'.$file);
if (!class_exists($class))
{
form_set_error('form][class',t('Error: Specified class does not exist in the plugin. Please try again.'));
} else
{
$obj = @new $class;
if (!method_exists($obj,$method))
{
form_set_error('form][method',t('Error: Specified builder method does not exist in the specified class/plugin. Please try again.'));
}
if (!method_exists($obj,$handler))
{
form_set_error('form][handler',t('Error: Specified handler method does not exist in the specified class/plugin. Please try again.'));
}
}
}
//only proceed if no errors have been found.
if (form_get_errors() !== NULL)
return;
if (($cm = ContentModel::loadFromModel($form_state['values']['form']['model_pid']))!==FALSE)
{
if ($cm->editIngestFormAttributes(htmlentities($form_state['values']['form']['dsid']),htmlentities($form_state['values']['form']['page']),$form_state['values']['form']['hide_file_chooser']==1,$form_state['values']['form']['redirect']==1)
echo 'success:'.t('Successfully updated ingest form of model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid));
exit();
} else
{
form_set_error('form][name',t('Error: Unable to update ingest form of model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid)));
}
} else
{
form_set_error('',t('Error: Unable to load content model <b>%cm_pid</b>.',array('%cm_pid'=>htmlentities($form_state['values']['form']['model_pid']))));
}
}
function icm_model_edit_adddsmeth(&$form_state,$params=null)
'#title' => t('Edit Add DataStream Method of model <b>%model_pid</b> datastream <b>%dsid</b>',array('%model_pid'=>$model_pid,'%dsid'=>$dsid)),
'#tree' => TRUE,
);
$form['form']['label'] = array('#value'=> t('This method will be called when a datastream is ingested into <b>%dsid</b>. The resulting file generated by the method is then ingested into the specified datastream.'));
if (($cm = ContentModel::loadFromModel($form_state['values']['form']['model_pid']))!==FALSE)
{
$elements = $cm->getIngestFormElements();
$found = false;
foreach ($elements as $el)
{
if ($el['name']==$form_state['values']['form']['name'])
{
$found=true;
break;
}
}
if ($found)
{
form_set_error('form][name',t('Error: The specified form element name is already listed in the ingest form. Please edit or delete the existing form element instead.'));
}
else if ($cm->addIngestFormElement(htmlentities($form_state['values']['form']['name']),
echo 'success:'.t('Successfully added ingest form element to model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid));
exit();
} else
{
form_set_error('form][name',t('Error: Unable to add ingest form element to model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid)));
}
} else
{
form_set_error('',t('Error: Unable to load content model <b>%cm_pid</b>.',array('%cm_pid'=>htmlentities($form_state['values']['form']['model_pid']))));
}
}
function icm_model_add_ingestFormElement(&$form_state,$params=null)
'#description'=> t('The type of form element to display.')
);
$form['form']['required'] = array(
'#type' => 'checkbox',
'#title' => t('Required'),
'#description' => t('If enabled, the form element will be required.'),
);
$form['form']['sticky'] = array(
'#type' => 'checkbox',
'#title' => t('Sticky'),
'#description' => t('If enabled, the entered value will be carried over to the next ingest.'),
);
$form['form']['autocomplete'] = array(
'#type' => 'textfield',
'#title' => t('Autocomplete Path'),
'#description' => t('Filled in, the field will suggest values from the current collection as the user types as listed by the specified drupal path. Only available for textfields.'),
);
$form['form']['description'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#size'=>30,
'#description' => t('A brief description that will appear next to the form element.'),
echo 'success:'.t('Successfully updated ingest form element to model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid));
exit();
} else
{
form_set_error('form][name',t('Error: Unable to updated ingest form element to model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid)));
}
} else
{
form_set_error('',t('Error: Unable to load content model <b>%cm_pid</b>.',array('%cm_pid'=>htmlentities($form_state['values']['form']['model_pid']))));
}
}
function icm_model_edit_ingestFormElement(&$form_state,$params=null)
'#description'=> t('The type of form element to display. <br/><b>Warning:</b> Changing the type from "Select" or "Radio" to anything else will cause any authoritative list to be permanently removed.')
);
$form['form']['required'] = array(
'#type' => 'checkbox',
'#title' => t('Required'),
'#default_value'=> $element['required']?1:0,
'#description' => t('If enabled, the form element will be required.'),
'#description' => t('Filled in, the field will suggest values from the current collection as the user types as listed by the specified drupal path. Only available for textfields.'),
);
$form['form']['description'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#default_value' => $element['description'],
'#description' => t('A brief description that will appear next to the form element.'),
if (($cm = ContentModel::loadFromModel($form_state['values']['form']['model_pid']))!==FALSE)
{
$elements = $cm->getIngestFormElements();
$found = false;
foreach ($elements as $el)
{
if ($el['name']==$form_state['values']['form']['name'])
{
$found=true;
break;
}
}
if (!$found)
{
form_set_error('form][name',t('Error: The specified form element was not found in the ingest form.'));
}
else if ($cm->addAuthListItem($form_state['values']['form']['name'],htmlentities($form_state['values']['form']['authValue']),htmlentities($form_state['values']['form']['authLabel']))
&& $cm->saveToFedora())
{
echo 'success:'.t('Successfully added authoritative list item to ingest form element to model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid));
exit();
} else
{
form_set_error('form][name',t('Error: Unable to add authoritative list item to ingest form of model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid)));
}
} else
{
form_set_error('',t('Error: Unable to load content model <b>%cm_pid</b>.',array('%cm_pid'=>htmlentities($form_state['values']['form']['model_pid']))));
}
}
function icm_model_add_authListItem(&$form_state,$params=null)
if (($cm = ContentModel::loadFromModel($model_pid))!==false)
{
$elements = $cm->getIngestFormElements();
$element = false;
foreach ($elements as $el)
{
if ($el['name'] == $name)
{
$element=$el;
break;
}
}
if ($element === false)
{
form_set_error('',t('Error: Specified ingest form element <b>"%name"</b> does not exist. Please try again.',array('%name'=>$name)));
} else
{
$form['form'] = array(
'#type' => 'fieldset',
'#title' => t('Add item to the authoritative list of element <b>"%name"</b> of ingest form for <b>%model_pid</b>',array('%name'=>$name,'%model_pid'=>$model_pid)),
'#tree' => TRUE,
);
$form['form']['nameDisp'] = array(
'#type' => 'item',
'#title' => t('Element Name'),
'#description' => t('The name of the form element.'),
'#value'=>$name
);
$form['form']['labelDisp'] = array(
'#type' => 'item',
'#title' => t('Element Label'),
'#value' => $element['label'],
'#description' => t('The label that will be displayed for the form element.'),
);
$form['form']['authValue'] = array(
'#type' => 'textfield',
'#title' => t('Value'),
'#size'=> 30,
'#required' => TRUE,
'#description' => t('Authoritative list value.'),
);
$form['form']['authLabel'] = array(
'#type' => 'textfield',
'#title' => t('Label'),
'#size'=> 30,
'#description' => t('Authoritative list label. If left blank the item\'s value will also be used as the label.'),
if (($cm = ContentModel::loadFromModel($form_state['values']['form']['model_pid']))!==FALSE)
{
if ($cm->updateEditMetadataMethod($module,$file,$class,$method,$handler,$form_state['values']['form']['dsid']) && $cm->saveToFedora())
{
echo 'success:'.t('Successfully updated edit metadata method to model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid));
exit();
} else
{
form_set_error('form][name',t('Error: Unable to update edit metadata method to model <b>%model_pid</b>.',array('%model_pid'=>$cm->pid)));
}
} else
{
form_set_error('',t('Error: Unable to load content model <b>%cm_pid</b>.',array('%cm_pid'=>htmlentities($form_state['values']['form']['model_pid']))));
}
}
function icm_model_update_editMetadataMethod(&$form_state,$params=null)
echo 'success:'.t('Successfully rolled back version of content model <b>%cm_pid</b>',array('%cm_pid'=>$cm->pid));
exit();
} else
{
form_set_error('',t('Error: Unable to roll back version. Check watchdog logs.'));
}
}
} else
{
form_set_error('',t('Error: Unable to load content model <b>%cm_pid</b>.',array('%cm_pid'=>htmlentities($form_state['values']['form']['model_pid']))));
}
}
function icm_model_rollback(&$form_state,$params=null)
'#description' => 'If enabled, also purges versions of the datastream that are OLDER than the selected, effectively leaving only the selected version.'
if (($cm = ContentModel::loadFromModel($model_pid))!==false)
{
$form['form']['warning'] = array('#value' => '<b>Warning:</b> Purging a content model will affect any objects and collections that reference the model. Once purged, the entire model will be permanently deleted.');
if (empty($path) || !file_exists($path.'/'.$file))
{
form_set_error('form][filename',t('Error: Selected plugin file not found. Please try again.'));
} else
{
require_once ($path.'/'.$file);
if (!class_exists($class))
{
form_set_error('form][class',t('Error: Specified class does not exist in the plugin. Please try again.'));
} else
{
$obj = @new $class;
if (!method_exists($obj,$method))
{
form_set_error('form][method',t('Error: Specified builder method does not exist in the specified class/plugin. Please try again.'));
}
if (!method_exists($obj,$handler))
{
form_set_error('form][handler',t('Error: Specified handler method does not exist in the specified class/plugin. Please try again.'));
}
}
}
}
break;
}
}
function icm_model_new(&$form_state,$params=null)
{
$form['#multistep']= TRUE;
$form['form'] = array(
'#type' => 'fieldset',
'#title' => t('Create/Install New Content Model'),
'#tree' => TRUE,
);
if (empty($form_state['storage']['step']))
{
// we are coming in without a step, so default to step 1
$form_state['storage']['step'] = 1;
}
switch ($form_state['storage']['step'])
{
case 1:
$form['form']['pid'] = array(
'#type' => 'textfield',
'#title' => t('Persistent Identifier'),
'#size' => 30,
'#required' => TRUE,
'#maxsize' => 64,
'#description' => t('The persistent identifier that will be used to identify the new content model. Make sure to choose a namespace that you will have access to from islandora.'),
);
$form['form']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#size' => 30,
'#required' => TRUE,
'#description' => t('A short human readable name for the content model.'),
);
$form['form']['initialize'] = array(
'#type' => 'select',
'#title' => t('Initialize Content Model'),
'#options' => array('blank'=>t('Start with a blank model'),
'model'=>t('Clone an existing installed model'),
'file'=>t('Load from a content model XML file')),
'#description' => t('Determines how the new content model is initialized.')
$form['form']['#description'] .= t('Please select an content model below that will be used as the base for this new content model. The model name will be updated to the value entered in the previous step.');
'#description' => t('The relative path of the file containing the desired content model datastream.'),
);
break;
case 'blank':
default:
$form['form']['#description'] .= t('The only additional required information that a model <b>must</b> have is the ingest form method/handler. Once the model has been added, please go in and add any additional mimetypes, datastreams and ingest rules and ingest form elements that are neccessary. ');
$form['form']['type'] = array(
'#type' => 'textfield',
'#title' => t('Mimetype'),
'#size' => 30,
'#required' => TRUE,
'#description' => t('A content mimetype that can be ingested using this model.'),
);
$form['form']['dsid'] = array(
'#type' => 'textfield',
'#title' => t('Datastream Identifier'),
'#size' => 30,
'#maxlength' => 64,
'#default_value'=>$attr['dsid'],
'#required' => TRUE,
'#description' => t('The datastream ID that stores the collected metadata from the form.'),
);
$form['form']['page'] = array(
'#type' => 'textfield',
'#title' => t('Page'),
'#size' => 3,
'#required' => TRUE,
'#default_value' => $attr['page'],
'#description' => t('??? not sure what this field is for. Cant find a reference to it, candidate for removal. '),
if (($cm = CollectionPolicy::loadFromCollection($cp_pid))!==false)
{
$form['form']['warning'] = array('#value' => '<b>Warning:</b> Purging a collection will orphan any objects contained in the collection. This can not be undone.');
if ($cp = CollectionPolicy::loadFromCollection($form_state['storage']['parent']) === FALSE)
{
form_set_error('',t('Error: Unable to load parent collection <b>%cp_pid</b>. Please try adding to a different collection or contact an administrator.',array('%cp_pid',$form_state['storage']['parent'])));
}
switch ($form_state['storage']['step'])
{
case 1:
if (!CollectionPolicy::validPid($form_state['values']['form']['pid']))
if ($form_state['values']['form']['model']['pid'] != $form_state['storage']['values'][1]['form']['pid'] && ($cm = ContentModel::loadFromModel($form_state['values']['form']['model']['pid'])) === FALSE)
{
form_set_error('form][model][pid', t('Error: Specified content model could not be loaded. Please choose a different model or contact an administrator.'));
}
if (!ContentModel::validPid($form_state['values']['form']['model']['namespace']))
if (!CollectionPolicy::validPid($form_state['values']['form']['collection_pid']) || ($cp = CollectionPolicy::loadFromCollection($form_state['values']['form']['collection_pid'])) === FALSE)
{
form_set_error('form][collection_pid', t('Error: Specified collection could not be loaded. Please choose a different collection or contact an administrator.'));
}
break;
}
break;
}
}
function icm_collection_new(&$form_state,$params=null)
{
$form['#multistep']= TRUE;
$form['form'] = array(
'#type' => 'fieldset',
'#title' => t('Create/Install New Collection'),
'#tree' => TRUE,
);
if (empty($form_state['storage']['step']))
{
// we are coming in without a step, so default to step 1
$form_state['storage']['step'] = 1;
$form_state['storage']['parent'] = $params[0];
}
switch ($form_state['storage']['step'])
{
case 1:
$form['form']['pid'] = array(
'#type' => 'textfield',
'#title' => t('Persistent Identifier'),
'#size' => 30,
'#required' => TRUE,
'#maxsize' => 64,
'#description' => t('The persistent identifier that will be used to identify the new collection. Make sure to choose a namespace that you will have access to from islandora.'),
);
$form['form']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#size' => 30,
'#required' => TRUE,
'#description' => t('A short human readable name for the collection.'),
);
$form['form']['initialize'] = array(
'#type' => 'select',
'#title' => t('Initialize Collection Policy'),
'#options' => array('blank'=>t('Start with a blank policy'),
'collection'=>t('Clone the policy from an existing collection'),
'file'=>t('Load from a collection policy XML file')),
'#description' => t('Determines how the new collection policy is initialized.')
$form['form']['#description'] .= t('Please select a collection below whose collection policy will be used as the basis for the new collection. The collections name will be updated to the value entered in the previous step.');
'#description' => t('The relative path of the file containing the desired collection policy datastream.'),
);
break;
case 'blank':
default:
$form['form']['#description'] .= t('The only additional required information that a collection <b>must</b> have is an allowed content model, relationship and default search term. Once the collection has been added, please go in and add any content models and search terms that are neccessary. ');
if (($cp = CollectionPolicy::loadFromCollection($collection_pid))!==FALSE)
{
$staging_area = $cp->getStagingArea(false);
if ($staging_area == false)
{
$staging_area = '';
}
$form['form']['relationship'] = array(
'#type' => 'textfield',
'#title' => t('Relationship'),
'#required' => TRUE,
'#default_value' => $cp->getRelationship(),
'#size' => 30,
'#maxSize' => 60,
'#description' => t('The relationship to use for members of this collection.'),
);
$form['form']['staging_area'] = array(
'#type'=> 'textfield',
'#title'=> t('Staging Area'),
'#default_value'=> $staging_area,
'#description' => t('The path to the staging area to use when ingesting files into this collection. If left blank, the staging area of the parent collection will be used. Please do not include a trailing slash.'),