Browse Source

Merge remote branch 'dgi/islandora_form_builder' into islandora_form_builder

pull/105/head
Nigel Banks 14 years ago
parent
commit
7a9dd3d383
  1. 1
      ContentModel.inc
  2. 29
      api/fedora_utils.inc

1
ContentModel.inc

@ -2038,6 +2038,7 @@ class ContentModel extends XMLDatastream {
if (!$this->validate()) { if (!$this->validate()) {
return FALSE; return FALSE;
} }
$names = FALSE;
$result = $this->xpath->query('//cm:forms/cm:form/@name'); // Select the name attribute of all forms. $result = $this->xpath->query('//cm:forms/cm:form/@name'); // Select the name attribute of all forms.
for($i = 0; $i < $result->length; $i++) { for($i = 0; $i < $result->length; $i++) {
$attribute = $result->item($i); $attribute = $result->item($i);

29
api/fedora_utils.inc

@ -85,20 +85,41 @@ function fix_encoding($in_str) {
} }
} }
function validPid($pid) { function validPid($pid) {
$valid = FALSE; $valid = FALSE;
if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) { if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) {
$valid = TRUE; $valid = TRUE;
} }
return $valid; return $valid;
} }
function validDsid($dsid) { function validDsid($dsid) {
$valid = FALSE; $valid = FALSE;
if (strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) { if (strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) {
$valid = TRUE; $valid = TRUE;
} }
return $valid; return $valid;
} }
function fixDsid($dsid) {
$new_dsid = trim($dsid);
$find = '/[^a-zA-Z0-9\.\_\-]/';
$replace = '';
$new_dsid = preg_replace($find, $replace, $new_dsid);
if( strlen($new_dsid) > 63 )
$new_dsid = substr($new_dsid, -63);
if( preg_match('/^[^a-zA-Z]/', $dsid ) )
$new_dsid = 'x' . $new_dsid;
if( strlen($new_dsid) == 0 )
$new_dsid = 'item' . rand(1, 100);
return $new_dsid;
}

Loading…
Cancel
Save