Skip to content

Commit

Permalink
#48 Show aggregated rights table and graph on sample page
Browse files Browse the repository at this point in the history
  • Loading branch information
BBGuy committed Oct 31, 2014
1 parent edfd30f commit 0802736
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 17 deletions.
11 changes: 7 additions & 4 deletions sites/all/modules/custom/kendra_e/kendra_e.module
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,16 @@ function kendra_e_resolve_asset_rights($asset, $start, $end, &$rt_split) {
// work on the extracted data.
_kendra_e_collect_asset_rights($rights, $asset, $start, $end);


if (!isset($rights['contributions'])) {
return array();
}

// 2. Collect the percentage from the collected rights array.
// Adds to rights array:
// ['contributions'][nid]['percentage']
if (isset($rights['contributions'])) {
// Calcolate percentages.
_kendra_e_calc_asset_rights_percentage($rights['contributions']);
}
// Calcolate percentages.
_kendra_e_calc_asset_rights_percentage($rights['contributions']);

// Validate the rights split
_kendra_e_validate_rights_split($rights['contributions'], $rt_split);
Expand Down
45 changes: 32 additions & 13 deletions sites/all/modules/custom/kendra_wf/kendra_wf.module
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,24 @@ function kendra_wf_get_current_aggregated_rights_table($form, &$form_state) {
if ($asset->type == 'asset') {

$qp = drupal_get_query_parameters();

if (isset($qp['range'])) {
// If we have a range in the url use it
$range = array (
'start' => $qp['range']['value'],
'end' => $qp['range']['value2'],
);
// Remove the range used on the sample page.
unset($qp['range']);
}
else {
// Set the range to the complete asset.
$range = array (
'start' => 0,
'end' => 100,
);
}

if (empty($qp)) {
// Default.
$rt_split = array (
Expand Down Expand Up @@ -293,7 +311,7 @@ function kendra_wf_get_current_aggregated_rights_table($form, &$form_state) {
// Resolve the rights for the asset.
// This will return an array with the rights information and if needed will
// Adjust the $rt_split.
$resolved_asset_rights = kendra_e_resolve_asset_rights($asset, 0, 100, $rt_split);
$resolved_asset_rights = kendra_e_resolve_asset_rights($asset, $range['start'], $range['end'], $rt_split);
//print_r($resolved_asset_rights);


Expand All @@ -312,19 +330,20 @@ function kendra_wf_get_current_aggregated_rights_table($form, &$form_state) {
$splits = array();
$header = array('Artist', 'Contribution', 'Percent');
$rows = array();
foreach ($resolved_asset_rights['combined'] as $key => $legal_entity) {
// Graph.
$splits[] = array(
$key . ' (' . implode(', ', $legal_entity['roles']) . ')',
$legal_entity['percentage'],
);
// Table.
$rows[] = array(
'data' => array($key, implode(', ', $legal_entity['roles']), $legal_entity['percentage']),
'class' => array('split-row'),
);
if (isset($resolved_asset_rights['combined'])) {
foreach ($resolved_asset_rights['combined'] as $key => $legal_entity) {
// Graph.
$splits[] = array(
$key . ' (' . implode(', ', $legal_entity['roles']) . ')',
$legal_entity['percentage'],
);
// Table.
$rows[] = array(
'data' => array($key, implode(', ', $legal_entity['roles']), $legal_entity['percentage']),
'class' => array('split-row'),
);
}
}

// Theme the chart
$entities_chart = theme('entities_split', array(
'id' => 'legal-entities-split-' . $nid,
Expand Down

0 comments on commit 0802736

Please sign in to comment.