Browse Source

Merge pull request #45 from bwoodhead/6.x

Coding standards
pull/46/merge
Ben Woodhead 13 years ago
parent
commit
3ecaf9f392
  1. 6
      BatchIngest.inc
  2. 8
      CollectionClass.inc
  3. 6
      CollectionManagement.inc
  4. 16
      CollectionPolicy.inc
  5. 54
      ContentModel.inc
  6. 4
      ObjectHelper.inc
  7. 4
      XMLDatastream.inc
  8. 2
      api/fedora_collection.inc
  9. 2
      api/fedora_export.inc
  10. 6
      api/fedora_item.inc
  11. 6
      api/fedora_utils.inc
  12. 2
      fedora_repository.module
  13. 8
      formClass.inc
  14. 4
      plugins/qt_viewer.inc

6
BatchIngest.inc

@ -38,7 +38,7 @@ function batch_creation_form(&$form_state, $collection_pid, $content_models) {
'#title' => "Choose content model to be associated with objects ingested",
'#type' => 'select',
'#options' => $cm_options,
'#required' => true,
'#required' => TRUE,
'#description' => t("Content models describe the behaviours of objects with which they are associated."),
);
$form['indicator']['file-location'] = array(
@ -251,14 +251,14 @@ function batch_create_dc_from_mods($mods_xml) {
*/
function recursive_directory_delete($dir) {
if (!file_exists($dir))
return true;
return TRUE;
if (!is_dir($dir))
return unlink($dir);
foreach (scandir($dir) as $item) {
if ($item == '.' || $item == '..')
continue;
if (!recursive_directory_delete($dir . DIRECTORY_SEPARATOR . $item))
return false;
return FALSE;
}
return rmdir($dir);
}

8
CollectionClass.inc

@ -524,11 +524,11 @@ class CollectionClass {
$show_batch_tab = FALSE;
}
if (!$show_ingest_tab) {
$view_selected = true;
$view_selected = TRUE;
}
if(!$collection_items){
$view_selected = false;
$add_selected = true;
$view_selected = FALSE;
$add_selected = TRUE;
}
$view_selected = !$show_ingest_tab;
@ -554,7 +554,7 @@ class CollectionClass {
'#title' => t('Manage This Collection'),
// This will be the content of the tab.
'#content' => drupal_get_form('collection_management_form', $this->pid, $content_models),
'#selected' => false,
'#selected' => FALSE,
);
}
if ($show_batch_tab && user_access('create batch process')) {

6
CollectionManagement.inc

@ -10,8 +10,8 @@
function collection_management_form(&$form_state, $this_collection_pid, $content_models) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$restricted = FALSE;
if (variable_get('fedora_namespace_restriction_enforced', true)) {
$restricted = true;
if (variable_get('fedora_namespace_restriction_enforced', TRUE)) {
$restricted = TRUE;
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:');
$namespaces = explode(':', $allowed_string);
foreach ($namespaces as $namespace) {
@ -35,7 +35,7 @@ function collection_management_form(&$form_state, $this_collection_pid, $content
}
}
if (!empty($cm_options)) {
$show_delete = true;
$show_delete = TRUE;
}

16
CollectionPolicy.inc

@ -64,7 +64,7 @@ class CollectionPolicy extends XMLDatastream {
/**
* Ingests a new Collection Policy datastream to the specified
* PID with the DSID specified. The file should be a valid collection
* policy XML. Returns false on failure.
* policy XML. Returns FALSE on failure.
*
* @param string $pid
* @param string $name
@ -92,7 +92,7 @@ class CollectionPolicy extends XMLDatastream {
/**
* Ingests a new Collection Policy datastream to the specified
* PID with the DSID specified. Clones the collection policy from the
* source collection pid. Returns false on failure.
* source collection pid. Returns FALSE on failure.
*
* @param string $pid
* @param string $name
@ -122,7 +122,7 @@ class CollectionPolicy extends XMLDatastream {
/**
* Ingests a new minimum Collection Policy datastream to the specified
* PID with the DSID specified. Initializes the policy with the specified values.
* Returns false on failure
* Returns FALSE on failure
*
* @param string $pid
* @param string $name
@ -234,7 +234,7 @@ class CollectionPolicy extends XMLDatastream {
$termEl = $newDom->createElement('term', $term->value);
$termEl->setAttribute('field', $term->field);
if (strval($sXml->search_terms->default) == $term->field) {
$termEl->setAttribute('default', 'true');
$termEl->setAttribute('default', 'TRUE');
}
$search_termsEl->appendChild($termEl);
}
@ -321,7 +321,7 @@ class CollectionPolicy extends XMLDatastream {
/**
* Sets the path to the staging area to use for this
* collection. If specified path is blank (or false) it will
* collection. If specified path is blank (or FALSE) it will
* remove the staging are path element from the collection policy.
*
* @param string $path
@ -435,7 +435,7 @@ class CollectionPolicy extends XMLDatastream {
$terms = $this->xml->getElementsByTagName('search_terms')->item(0)->getElementsByTagName('term');
for ($i = 0; $i < $terms->length; $i++) {
$default = $terms->item($i)->attributes->getNamedItem('default');
$default = ($default !== NULL) ? (strtolower($default->nodeValue) == 'true') : FALSE;
$default = ($default !== NULL) ? (strtolower($default->nodeValue) == 'TRUE') : FALSE;
$ret[] = ($asArray) ? array('value' => $terms->item($i)->nodeValue,
'field' => $terms->item($i)->getAttribute('field'),
'default' => $default) : $terms->item($i)->nodeValue;
@ -540,7 +540,7 @@ class CollectionPolicy extends XMLDatastream {
if ($terms->item($i)->attributes->getNamedItem('default') !== NULL) {
$terms->item($i)->removeAttribute('default');
}
$found->setAttribute('default', 'true');
$found->setAttribute('default', 'TRUE');
$ret = TRUE;
}
}
@ -550,7 +550,7 @@ class CollectionPolicy extends XMLDatastream {
/**
* Removes the specified content model from the collection policy. This will only
* prevent future ingests of the removed model to the collection. $cm should be
* a valid ContentModel object. Returns false on failure or when the CM was not found in
* a valid ContentModel object. Returns FALSE on failure or when the CM was not found in
* the collection policy.
*
* @param ContentModel $cm

54
ContentModel.inc

@ -34,7 +34,7 @@ class ContentModel extends XMLDatastream {
/**
* Constructs a ContentModel object from a Fedora item
* by getting the first content model from the hasModel relationship.
* Returns false on failure.
* Returns FALSE on failure.
* @param string $pid
* @return ContentModel $cm
*/
@ -57,7 +57,7 @@ class ContentModel extends XMLDatastream {
/**
* Ingests a Content Model from a file to the specified pid/dsid .
* Returns false on failure.
* Returns FALSE on failure.
*
* @param string $pid
* @param string $name
@ -84,7 +84,7 @@ class ContentModel extends XMLDatastream {
/**
* Ingests a Content Model from an existing model to the specified pid/dsid .
* Returns false on failure.
* Returns FALSE on failure.
*
* @param string $pid
* @param string $name
@ -113,7 +113,7 @@ class ContentModel extends XMLDatastream {
/**
* Ingests a minimum Content Model to the specified pid/dsid.
* Returns false on failure.
* Returns FALSE on failure.
*
* @param string $pid
* @param string $name
@ -153,8 +153,8 @@ class ContentModel extends XMLDatastream {
$ingestFormEl = $newDom->createElement('ingest_form');
$ingestFormEl->setAttribute('dsid', $ingestFormDsid);
$ingestFormEl->setAttribute('page', $ingestFormPage);
if ($ingestFormHideChooser == 'true') {
$ingestFormEl->setAttribute('hide_file_chooser', 'true');
if ($ingestFormHideChooser == 'TRUE') {
$ingestFormEl->setAttribute('hide_file_chooser', 'TRUE');
}
$builderEl = $newDom->createElement('form_builder_method');
@ -186,7 +186,7 @@ class ContentModel extends XMLDatastream {
* If DSID is specified it will use that datastream as the model, otherwise it will
* use the default (usually ISLANDORACM). PID_NAMESPACE and name can also be initialized
* from the collection policy.
* Returns false on failure.
* Returns FALSE on failure.
*
* NOTE: $name will be overwritten with the content model name found in the datastream
* when the model is first validated.\
@ -344,7 +344,7 @@ class ContentModel extends XMLDatastream {
$ingest_formEl->setAttribute('dsid', $sXml->ingest_form['dsid']);
$ingest_formEl->setAttribute('page', $sXml->ingest_form['page']);
if (isset($sXml->ingest_form['hide_file_chooser'])) {
$ingest_formEl->setAttribute('hide_file_chooser', (strtolower($sXml->ingest_form['hide_file_chooser']) == 'true') ? 'true' : 'false');
$ingest_formEl->setAttribute('hide_file_chooser', (strtolower($sXml->ingest_form['hide_file_chooser']) == 'TRUE') ? 'TRUE' : 'FALSE');
}
$form_builderEl = $newDom->createElement('form_builder_method');
@ -373,8 +373,8 @@ class ContentModel extends XMLDatastream {
$elEl->setAttribute('label', $element->label);
$elEl->setAttribute('name', $element->name);
$elEl->setAttribute('type', $element->type);
if (strtolower($element->required) == 'true') {
$elEl->setAttribute('required', 'true');
if (strtolower($element->required) == 'TRUE') {
$elEl->setAttribute('required', 'TRUE');
}
if (isset($element->description) && trim($element->description) != '') {
$descEl = $newDom->createElement('description', trim($element->description));
@ -453,7 +453,7 @@ class ContentModel extends XMLDatastream {
/**
* Gets the name of the ContentModel
* Returns false on failure.
* Returns FALSE on failure.
*
* @return String $name
*/
@ -539,7 +539,7 @@ class ContentModel extends XMLDatastream {
$element = array('name' => $elements->item($i)->getAttribute('name'),
'label' => $label,
'type' => $elements->item($i)->getAttribute('type'),
'required' => ($elements->item($i)->getAttribute('required') == 'true') ? TRUE : FALSE,
'required' => ($elements->item($i)->getAttribute('required') == 'TRUE') ? TRUE : FALSE,
'description' => $desc
);
@ -561,7 +561,7 @@ class ContentModel extends XMLDatastream {
$items = $params->item(0)->getElementsByTagName('parameter');
for ($j = 0; $j < $items->length; $j++) {
$value = $items->item($j)->nodeValue;
$list[$items->item($j)->getAttribute('name')] = (strtolower($value) == 'true' ? TRUE : (strtolower($value) == 'false' ? FALSE : $value));
$list[$items->item($j)->getAttribute('name')] = (strtolower($value) == 'TRUE' ? TRUE : (strtolower($value) == 'FALSE' ? FALSE : $value));
}
}
$element['parameters'] = $list;
@ -657,7 +657,7 @@ class ContentModel extends XMLDatastream {
/**
* Sets a parameter of an ingest form element. If the value of the element is FALSE the parameter
* will be removed entirely (if you want to store false as a value, then send the String "false").
* will be removed entirely (if you want to store FALSE as a value, then send the String "FALSE").
*
* @param String $elementName
* @param String $paramName
@ -786,7 +786,7 @@ class ContentModel extends XMLDatastream {
$found->setAttribute('name', $name);
$found->setAttribute('type', $type);
$found->setAttribute('required', $required ? 'true' : 'false');
$found->setAttribute('required', $required ? 'TRUE' : 'FALSE');
if (trim($label) != '' && trim($label) != trim($name)) {
$found->setAttribute('label', $label);
}
@ -838,7 +838,7 @@ class ContentModel extends XMLDatastream {
$elementEl = $this->xml->createElement('element');
$elementEl->setAttribute('name', $name);
$elementEl->setAttribute('type', $type);
$elementEl->setAttribute('required', $requiredi ? 'true' : 'false');
$elementEl->setAttribute('required', $requiredi ? 'TRUE' : 'FALSE');
if (trim($label) != '' && trim($label) != trim($name)) {
$elementEl->setAttribute('label', $label);
}
@ -1062,7 +1062,7 @@ class ContentModel extends XMLDatastream {
$ingest_form = $this->xml->getElementsByTagName('ingest_form')->item(0);
if (!empty($ingest_form)) {
if (strtolower($ingest_form->getAttribute('hide_file_chooser')) == 'true') {
if (strtolower($ingest_form->getAttribute('hide_file_chooser')) == 'TRUE') {
$form['indicator']['ingest-file-location']['#type'] = 'hidden';
}
}
@ -1464,7 +1464,7 @@ class ContentModel extends XMLDatastream {
$datastreams = $datastreams->item(0)->getElementsByTagName('datastream');
for ($i = 0; $i < $datastreams->length; $i++) {
$ds = $datastreams->item($i);
if ($ds->attributes->getNamedItem('display_in_fieldset') == NULL || strtolower($ds->getAttribute('display_in_fieldset')) != 'false') {
if ($ds->attributes->getNamedItem('display_in_fieldset') == NULL || strtolower($ds->getAttribute('display_in_fieldset')) != 'FALSE') {
$dispMethods = $ds->getElementsByTagName('display_method');
for ($j = 0; $j < $dispMethods->length; $j++) {
$method = $dispMethods->item($j);
@ -1592,7 +1592,7 @@ class ContentModel extends XMLDatastream {
'file' => $dispMethods->item($i)->getAttribute('file'),
'class' => $dispMethods->item($i)->getAttribute('class'),
'method' => $dispMethods->item($i)->getAttribute('method'),
'default' => ($dispMethods->item($i)->attributes->getNamedItem('default') !== NULL ? strtolower($dispMethods->item($i)->getAttribute('default')) == 'true' : FALSE));
'default' => ($dispMethods->item($i)->attributes->getNamedItem('default') !== NULL ? strtolower($dispMethods->item($i)->getAttribute('default')) == 'TRUE' : FALSE));
}
}
return $ret;
@ -1620,7 +1620,7 @@ class ContentModel extends XMLDatastream {
$dsEl = $this->xml->createElement('datastream');
$dsEl->setAttribute('dsid', $dsid);
if ($display_in_fieldset == TRUE) {
$dsEl->setAttribute('display_in_fieldset', 'true');
$dsEl->setAttribute('display_in_fieldset', 'TRUE');
}
$datastreamsEl->appendChild($dsEl);
$ret = TRUE;
@ -1652,7 +1652,7 @@ class ContentModel extends XMLDatastream {
public function displayInFieldset($dsid) {
$ret = FALSE;
if (self::valid_dsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) {
$ret = strtolower($ds->getAttribute('display_in_fieldset')) == 'true';
$ret = strtolower($ds->getAttribute('display_in_fieldset')) == 'TRUE';
}
return $ret;
}
@ -1671,7 +1671,7 @@ class ContentModel extends XMLDatastream {
$ret = TRUE;
}
elseif ($value == TRUE) {
$ds->setAttribute('display_in_fieldset', 'true');
$ds->setAttribute('display_in_fieldset', 'TRUE');
$ret = TRUE;
}
}
@ -1710,7 +1710,7 @@ class ContentModel extends XMLDatastream {
}
}
$found->setAttribute('default', 'true');
$found->setAttribute('default', 'TRUE');
$ret = TRUE;
}
}
@ -2112,8 +2112,8 @@ class ContentModel extends XMLDatastream {
$ingest_formEl = $this->xml->getElementsByTagName('ingest_form')->item(0);
$ret = array('dsid' => $ingest_formEl->getAttribute('dsid'),
'page' => $ingest_formEl->getAttribute('page'),
'hide_file_chooser' => strtolower($ingest_formEl->getAttribute('hide_file_chooser')) == 'true',
'redirect' => strtolower($ingest_formEl->getAttribute('redirect')) == 'false' ? FALSE : TRUE);
'hide_file_chooser' => strtolower($ingest_formEl->getAttribute('hide_file_chooser')) == 'TRUE',
'redirect' => strtolower($ingest_formEl->getAttribute('redirect')) == 'FALSE' ? FALSE : TRUE);
}
return $ret;
}
@ -2133,13 +2133,13 @@ class ContentModel extends XMLDatastream {
$ingest_formEl->setAttribute('dsid', $dsid);
$ingest_formEl->setAttribute('page', $page);
if (!$redirect) {
$ingest_formEl->setAttribute('redirect', 'false');
$ingest_formEl->setAttribute('redirect', 'FALSE');
}
else {
$ingest_formEl->removeAttribute('redirect');
}
if ($hide_file_chooser) {
$ingest_formEl->setAttribute('hide_file_chooser', 'true');
$ingest_formEl->setAttribute('hide_file_chooser', 'TRUE');
}
else {
$ingest_formEl->removeAttribute('hide_file_chooser');

4
ObjectHelper.inc

@ -835,7 +835,7 @@ class ObjectHelper {
and $o <mulgara:is> <info:fedora/' . $pid . '>';
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
$url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query=";
$url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query=";
$content = do_curl($url . htmlentities(urlencode($query_string)));
$rows = explode("\n", $content);
@ -869,7 +869,7 @@ class ObjectHelper {
$query_string = substr($query_string, 0, -3) . ' )';
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
$url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query=";
$url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query=";
$url .= htmlentities(urlencode($query_string));
$content = $this->doCurl($url);

4
XMLDatastream.inc

@ -102,7 +102,7 @@ abstract class XMLDatastream {
* @return XMLDatastream $cm
*/
public function __construct($xmlStr, $pid = NULL, $dsid = NULL) {
libxml_use_internal_errors(true);
libxml_use_internal_errors(TRUE);
$this->pid = $pid;
$this->dsid = $dsid;
@ -253,7 +253,7 @@ abstract class XMLDatastream {
/**
* Gets the history of the datastream from fedora.
* Returns false on failure.
* Returns FALSE on failure.
*
* @return string[] $ret
*/

2
api/fedora_collection.inc

@ -41,7 +41,7 @@ function export_collection($collection_pid, $relationship = 'isMemberOfCollectio
fwrite($file, $item_foxml);
fclose($file);
}
if (system("cd $container;zip -r $collection_pid.zip $collection_pid/* >/dev/NULL") == 0) {
if (system("cd $container;zip -r $collection_pid.zip $collection_pid/* >/dev/null") == 0) {
header("Content-type: application/zip");
header('Content-Disposition: attachment; filename="' . $collection_pid . '.zip' . '"');
$fh = fopen($container . '/' . $collection_pid . '.zip', 'r');

2
api/fedora_export.inc

@ -170,7 +170,7 @@ function export_foxml_for_pid($pid, $dir, $paths, &$log, $format = FOXML_11, $re
}
foreach ($xpath->('METS:FLocat[@xlink:href]', $content_node) as $floc) {
$floc->setAttribute('xlink:href', url($paths[$ds_id], array('absolute' => true)));
$floc->setAttribute('xlink:href', url($paths[$ds_id], array('absolute' => TRUE)));
}
`}
*/

6
api/fedora_item.inc

@ -297,14 +297,14 @@ class Fedora_Item {
$i++;
$url = variable_get('fedora_base_url', 'http://localhost:8080/fedora');
if ($cursor == 0) {
$url .= "/objects?query=$field~$pattern&pid=true&title=true&resultFormat=xml&maxResults=$max_results";
$url .= "/objects?query=$field~$pattern&pid=TRUE&title=TRUE&resultFormat=xml&maxResults=$max_results";
}
else {
$url .= "/objects?pid=true&title=truesessionToken=$session_token&resultFormat=xml&maxResults=$max_results";
$url .= "/objects?pid=TRUE&title=TRUEsessionToken=$session_token&resultFormat=xml&maxResults=$max_results";
}
if (count($resultFields) > 0) {
$url .= '&' . join('=true&', $resultFields) . '=true';
$url .= '&' . join('=TRUE&', $resultFields) . '=TRUE';
}
$resultxml = do_curl($url);

6
api/fedora_utils.inc

@ -241,7 +241,7 @@ function get_collections_as_option_array() {
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title';
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
$url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query=";
$url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query=";
$content = do_curl($url . htmlentities(urlencode($query)));
$list = explode("\n", $content);
array_shift($list);
@ -267,7 +267,7 @@ function get_collections_as_option_array() {
function get_content_models_as_option_array() {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$restricted = variable_get('fedora_namespace_restriction_enforced', true);
$restricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:');
$namespaces = explode(':', $allowed_string);
foreach ($namespaces as $namespace) {
@ -283,7 +283,7 @@ function get_content_models_as_option_array() {
order by $title';
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
$url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query=";
$url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query=";
$content = do_curl($url . htmlentities(urlencode($query)));
$list = explode("\n", $content);
array_shift($list);

2
fedora_repository.module

@ -990,7 +990,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
// Add a 'manage object' tab for all objects, where detailed list of content is shown.
$obj = new FedoraObjectDetailedContent($pid);
$object_details = $obj->showFieldSets();
if ($object_details['fedora_object_details']['#selected'] == true){
if ($object_details['fedora_object_details']['#selected'] == TRUE){
foreach($cmodels_tabs as $cmodel_tab){
if (is_array($cmodel_tab)){
$cmodel_tab['#selected'] = FALSE;

8
formClass.inc

@ -306,8 +306,8 @@ class formClass {
'#type' => 'fieldset',
'#title' => t('Advanced configuration options'),
'#description' => t('Advanced configuration. Under normal circumstances these will not be touched'),
'#collapsible' => true,
'#collapsed' => true,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['advanced']['fedora_object_display_title'] = array(
'#type' => 'select',
@ -587,7 +587,7 @@ class formClass {
$form = new IngestObjectMetadataForm();
return $form->create($collection_pid, $collection_label, $form_state);
} catch (Exception $e) {
$form_state['storage']['xml'] = false; // An error occured revert back to the QDC Form.
$form_state['storage']['xml'] = FALSE; // An error occured revert back to the QDC Form.
}
}
return $this->createQDCIngestForm($collection_pid, $collection_label, $form_state);
@ -810,7 +810,7 @@ class formClass {
$form = new EditObjectMetadataForm($form_state);
return $form->create($pid, $client, $form_state);
} catch (Exception $e) {
$form_state['storage']['xml'] = false; // An error occured revert back to the QDC Form.
$form_state['storage']['xml'] = FALSE; // An error occured revert back to the QDC Form.
}
}
return $this->createQDCEditForm($pid, $dsid, $client, $form_state);

4
plugins/qt_viewer.inc

@ -99,7 +99,7 @@ class ShowQtStreamsInFieldSets {
}
/**
* Is download enabled. It always returns false. ???
* Is download enabled. It always returns FALSE. ???
* @return FALSE
*/
function enableDownload() {
@ -147,7 +147,7 @@ class ShowQtStreamsInFieldSets {
}
$src = base_path() . 'fedora/repository/' . $this->pid . '/' . $media->ID . '/MOV.mov';
$qtparams = '';
$qtparams .= "'autostart', '" . ($pframe !== FALSE ? 'true' : 'false') . "', ";
$qtparams .= "'autostart', '" . ($pframe !== FALSE ? 'TRUE' : 'FALSE') . "', ";
$init = <<<EOD
$(function() {
src = "$src";

Loading…
Cancel
Save