Browse Source

Coding standards

7.x-2.x
Daniel Lamb 9 years ago
parent
commit
b7d2a0e047
  1. 16
      islandora_basic_image/islandora_basic_image.module
  2. 12
      islandora_collection/islandora_collection.module
  3. 12
      islandora_medium_size_service/include/islandora_medium_size_service.inc
  4. 20
      islandora_tn_service/include/islandora_tn_service.inc

16
islandora_basic_image/islandora_basic_image.module

@ -71,7 +71,15 @@ function islandora_basic_image_form_islandora_basic_image_node_form_alter(&$form
}
}
function islandora_basic_image_add_parent_uuid($form, &$form_state) {
/**
* Custom submit handler to pass along parent uuid.
*
* @param array $form
* Drupal form.
* @param array $form_state
* Drupal form state.
*/
function islandora_basic_image_add_parent_uuid(array $form, array &$form_state) {
$node = $form_state['node'];
$node->parent_collection = "";
if (isset($form_state['parent_collection']['#value'])) {
@ -91,6 +99,9 @@ function islandora_basic_image_rdf_mapping() {
return islandora_get_default_rdf_mapping(ISLANDORA_BASIC_IMAGE_CONTENT_TYPE, $rdf_types);
}
/**
* Implements hook_node_postinsert().
*/
function islandora_basic_image_node_postinsert($node) {
if (isset($_SERVER['HTTP_IGNORE_HOOKS']) && strcmp(strtolower($_SERVER['HTTP_IGNORE_HOOKS']), "true") == 0) {
return;
@ -136,6 +147,9 @@ function islandora_basic_image_node_postinsert($node) {
$response = httprl_send_request();
}
/**
* Implements hook_node_postupdate().
*/
function islandora_basic_image_node_postupdate($node) {
if (isset($_SERVER['HTTP_IGNORE_HOOKS']) && strcmp(strtolower($_SERVER['HTTP_IGNORE_HOOKS']), "true") == 0) {
return;

12
islandora_collection/islandora_collection.module

@ -74,7 +74,15 @@ function islandora_collection_form_islandora_collection_node_form_alter(&$form,
}
}
function islandora_collection_add_parent_uuid($form, &$form_state) {
/**
* Custom submit handler to pass along parent uuid.
*
* @param array $form
* Drupal form.
* @param array $form_state
* Drupal form state.
*/
function islandora_collection_add_parent_uuid(array $form, array &$form_state) {
$node = $form_state['node'];
$node->parent_collection = "";
if (isset($form_state['parent_collection']['#value'])) {
@ -108,7 +116,6 @@ function islandora_collection_node_postinsert($node) {
}
$parent_collection = $node->parent_collection;
dd("PARENT UUID: $parent_collection");
$nodes = entity_uuid_load('node', array($node->uuid));
// Exit early if the node never was successfully inserted in the database.
@ -118,7 +125,6 @@ function islandora_collection_node_postinsert($node) {
$node = array_pop($nodes);
$url = "http://127.0.0.1:8181/islandora/rest/collection/$parent_collection";
dd("REQUEST URL: $url");
// Don't forget the trailing slash.
httprl_request($url,

12
islandora_medium_size_service/include/islandora_medium_size_service.inc

@ -11,10 +11,10 @@
* @param array $args
* JSON encoded arguments.
*
* @return string
* @return string
* Response message.
*/
function islandora_medium_size_service_create($args) {
function islandora_medium_size_service_create(array $args) {
$uuid = $args['uuid'];
$tn_b64 = $args['file'];
$mimetype = $args['mimetype'];
@ -22,21 +22,21 @@ function islandora_medium_size_service_create($args) {
$extension = $exploded[1];
$entities = entity_uuid_load('node', array($uuid));
if (empty($entities)) {
return "Could not add medium sized image because there is no entity identified by $uuid";
return "Could not add medium sized image because there is no entity identified by $uuid";
}
$node = array_pop($entities);
$file = file_save_data(base64_decode($tn_b64), "public://" . $uuid . "_MEDIUM_SIZE." . $extension, FILE_EXISTS_REPLACE);
$node->field_medium_size[LANGUAGE_NONE][] = array(
'fid' => $file->fid,
'alt' => "Medium sized image for node $uuid",
'title' => "Medium sized image for node $uuid",
);
$node->field_tn[LANGUAGE_NONE][] = array(
$node->field_tn[LANGUAGE_NONE][] = array(
'fid' => $file->fid,
'width' => 100,
'height' => 100,

20
islandora_tn_service/include/islandora_tn_service.inc

@ -8,15 +8,13 @@
/**
* The POST callback for the TN service.
*
* @param string $type
* Entity type to which the RDF mapping belongs.
* @param string $bundle
* Bundle to which the RDF mapping belongs.
* @param array $args
* JSON decoded function arguments.
*
* @return array
* The RDF mapping.
* @return string
* Message.
*/
function islandora_tn_service_create($args) {
function islandora_tn_service_create(array $args) {
$uuid = $args['uuid'];
$tn_b64 = $args['file'];
$mimetype = $args['mimetype'];
@ -24,15 +22,15 @@ function islandora_tn_service_create($args) {
$extension = $exploded[1];
$entities = entity_uuid_load('node', array($uuid));
if (empty($entities)) {
return "Could not add thumbnail because there is no entity identified by $uuid";
return "Could not add thumbnail because there is no entity identified by $uuid";
}
$node = array_pop($entities);
$file = file_save_data(base64_decode($tn_b64), "public://" . $uuid . "_TN." . $extension, FILE_EXISTS_REPLACE);
$node->field_tn[LANGUAGE_NONE][] = array(
'fid' => $file->fid,
'width' => 100,
@ -40,7 +38,7 @@ function islandora_tn_service_create($args) {
'alt' => "Thumbnail for node $uuid",
'title' => "Thumbnail for node $uuid",
);
node_save($node);
return "Successfully added thumbnail to node $uuid";

Loading…
Cancel
Save