public function getFieldCollectionItem($create = FALSE)
 {
     if (isset($this->field_collection_item)) {
         return $this->field_collection_item;
     } elseif (isset($this->value)) {
         // By default always load the default revision, so caches get used.
         $field_collection_item = field_collection_item_load($this->value);
         if ($field_collection_item !== NULL && $field_collection_item->getRevisionId() != $this->revision_id) {
             // A non-default revision is a referenced, so load this one.
             $field_collection_item = field_collection_item_revision_load($this->revision_id);
         }
         return $field_collection_item;
     } elseif ($create) {
         $field_collection_item = entity_create('field_collection_item', array('field_name' => $this->getFieldDefinition()->getName()));
         // TODO: Uncomment or delete
         /*
         $field_collection_item->setHostEntity($this->getEntity(), FALSE);
         */
         return $field_collection_item;
     }
     return FALSE;
 }
        ?>
</h3>
			<?php 
    }
    ?>
				<ul>
				<?php 
    foreach ($anchors->field_anchorlink['und'] as $anchor) {
        print '<li><a href="#' . $anchor['link'] . '">' . $anchor['title'] . '</a></li>';
    }
    ?>
				</ul>			
			<?php 
    $elinks_area = array();
    foreach ($cchunk->field_externallinkslist['und'] as $ind => $eblock) {
        $elinks_area[$ind] = field_collection_item_load($eblock['value']);
    }
    if (!empty($elinks_area)) {
        foreach ($elinks_area as $elinks_block) {
            print '<h3>' . $elinks_block->field_externallinkslisttitle['und']['0']['value'] . '</h3>';
            print '<ul>';
            foreach ($elinks_block->field_externallink['und'] as $key => $external_link) {
                print '<li><a href="' . $external_link['url'] . '">' . $external_link['title'] . '</a></li>';
            }
            print '</ul>';
        }
    }
    ?>

			</div>
		</div>
?>
/images/act_banner_Arrow.png"></a>
      <a class="right btn btn-primary right_slide" href="#carousel-example-generic" data-slide="next"><img src="<?php 
echo $base_url . '/' . path_to_theme();
?>
/images/act_banner_Arrow_rgt.png"></a>
    </div>
    <div class="col-lg-12 col-md-12 col-sm-12 padding_none">
      <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
        <!-- Wrapper for slides -->
        <div class="carousel-inner">
<?php 
if (isset($current_node->field_carousels['und'])) {
    $echo = '<div class="item active"><div class="row">';
    foreach ($current_node->field_carousels['und'] as $key => $value) {
        $collection_obj = field_collection_item_load($value['value']);
        $i++;
        //$the_node = node_load($value);
        $echo .= '<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 padding_none">
              <div class="col-item">
                <a href="' . $collection_obj->field_image_quad_1_link['und'][0]['value'] . '">
                <img src="' . image_style_url('carousal', $collection_obj->field_image['und'][0]['uri']) . '">
                <div class="blog_list_overlay_con blog_list_overlay_con2 text-center">
                  <div class="blog_list_inner">
                    <h3 class="h1_seo_trip">' . $collection_obj->field_section_1_white_title['und'][0]['value'] . '</h3>
                    <h3 class="h2_seo_trip">' . $collection_obj->field_white_large_text['und'][0]['value'] . '</h3>
                  </div>
                </div>
                </a>
              </div>
            </div>';
Exemple #4
0
function create_logos($n)
{
    $output = "";
    foreach ($n->field_bottom_logos['und'] as $field) {
        $field_id = $field['value'];
        $collection = field_collection_item_load($field_id);
        if (count($collection->field_logo_link)) {
            $output .= "<a href='" . $collection->field_logo_link['und'][0]['value'] . "'>";
        }
        if (count($collection->field_logo)) {
            $output .= "<img src='" . file_create_url($collection->field_logo['und'][0]['uri']) . "' />";
        }
        if (count($collection->field_logo_link)) {
            $output .= "</a>";
        }
    }
    return $output;
}
 * - $is_admin: Flags true when the current user is an administrator.
 *
 * Field variables: for each field instance attached to the node a corresponding
 * variable is defined, e.g. $node->body becomes $body. When needing to access
 * a field's raw values, developers/themers are strongly encouraged to use these
 * variables. Otherwise they will have to explicitly specify the desired field
 * language, e.g. $node->body['en'], thus overriding any language negotiation
 * rule that was previously applied.
 *
 * @see template_preprocess()
 * @see template_preprocess_node()
 * @see template_process()
 */
if (!$logged_in) {
    if ($node->field_sources) {
        $source = field_collection_item_load($node->field_sources[LANGUAGE_NONE][0]['value']);
        if ($source->field_url) {
            //dpm("Location: ".$source->field_url[LANGUAGE_NONE][0]['display_url']);
            drupal_add_http_header("Location", $source->field_url[LANGUAGE_NONE][0]['display_url']);
        }
    }
}
?>

<article<?php 
print $attributes;
?>
>
  <?php 
if (!empty($title_prefix) || !empty($title_suffix) || !$page) {
    ?>
 /**
  * Make sure the basic UI and access checks are working.
  */
 public function testBasicUI()
 {
     $node = $this->drupalCreateNode(array('type' => 'article'));
     // Login with new user that has no privileges.
     $user = $this->drupalCreateUser(array('access content'));
     $this->drupalLogin($user);
     // Make sure access is denied.
     $path = "field_collection_item/add/field_test_collection/node/{$node->id()}";
     $this->drupalGet($path);
     $this->assertText(t('Access denied'), 'Access has been denied.');
     // Login with new user that has basic edit rights.
     $user_privileged = $this->drupalCreateUser(array('access content', 'edit any article content'));
     $this->drupalLogin($user_privileged);
     // Test field collection item add form.
     $this->drupalGet('admin/structure/types/manage/article/display');
     $this->drupalGet("node/{$node->id()}");
     $this->assertLinkByHref($path, 0, 'Add link is shown.');
     $this->drupalGet($path);
     $this->assertText(t($this->inner_field_definition['label']), 'Add form is shown.');
     $edit = array("{$this->inner_field_name}[0][value]" => rand());
     $this->drupalPostForm(NULL, $edit, t('Save'));
     $this->assertText(t('Successfully added a @field.', array('@field' => $this->field_collection_name)), 'Field collection saved.');
     $this->assertText($edit["{$this->inner_field_name}[0][value]"], 'Added field value is shown.');
     $field_collection_item = field_collection_item_load(1);
     // Test field collection item edit form.
     $edit["{$this->inner_field_name}[0][value]"] = rand();
     $this->drupalPostForm('field_collection_item/1/edit', $edit, t('Save'));
     $this->assertText(t('Successfully edited @field.', array('@field' => $field_collection_item->label())), 'Field collection saved.');
     $this->assertText($edit["{$this->inner_field_name}[0][value]"], 'Field collection has been edited.');
     $this->drupalGet('field_collection_item/1');
     $this->assertText($edit["{$this->inner_field_name}[0][value]"], 'Field collection can be viewed.');
     /*
       // Add further 3 items, so we have reached 4 == maxium cardinality.
       $this->drupalPostForm('field_collection_item/1/edit', $edit, t('Save'));
       $this->drupalPostForm('field_collection_item/1/edit', $edit, t('Save'));
       $this->drupalPostForm('field_collection_item/1/edit', $edit, t('Save'));
     
       // Make sure adding doesn't work any more as we have restricted cardinality
       // to 1.
       $this->drupalGet($path);
       $this->assertText(t('Too many items.'),
                         'Maxium cardinality has been reached.');
     
       $this->drupalPost('field-collection/field-test-collection/1/delete', array(), t('Delete'));
       $this->drupalGet($path);
       // Add form is shown again.
       $this->assertText(t('Test text field'), 'Field collection item has been deleted.');
     
       // Test the viewing a revision. There should be no links to change it.
       $vid = $node->vid;
       $node = node_load($node->nid, NULL, TRUE);
       $node->revision = TRUE;
       node_save($node);
     
       $this->drupalGet("node/$node->nid/revisions/$vid/view");
       $this->assertResponse(403, 'Access to view revision denied');
       // Login in as admin and try again.
       $user = $this->drupalCreateUser(array('administer nodes', 'bypass node access'));
       $this->drupalLogin($user);
       $this->drupalGet("node/$node->nid/revisions/$vid/view");
       $this->assertNoResponse(403, 'Access to view revision granted');
     
       $this->assertNoLinkByHref($path, 'No links on revision view.');
       $this->assertNoLinkByHref('field-collection/field-test-collection/2/edit', 'No links on revision view.');
       $this->assertNoLinkByHref('field-collection/field-test-collection/2/delete', 'No links on revision view.');
     
       $this->drupalGet("node/$node->nid/revisions");
     */
 }
function create_slideshow($n)
{
    $output = "";
    $output .= "<div id='top-slideshow'><div class='slides_container'>";
    for ($c = 0; $c < count($n->field_top_slideshow['und']); $c++) {
        $output .= "<div class='slide'>";
        $field_id = $n->field_top_slideshow['und'][$c]['value'];
        $collection = field_collection_item_load($field_id);
        if (count($collection->field_slide_image)) {
            $output .= "<img src='" . file_create_url($collection->field_slide_image['und'][0]['uri']) . "' />";
        }
        $output .= "</div>";
    }
    $output .= "</div>";
    $output .= "<a href='#' class='prev'><img src='" . base_path() . path_to_theme() . "/img/arrow_prev.png' width='17' height='55' alt='Arrow Prev'></a>";
    $output .= "<a href='#' class='next'><img src='" . base_path() . path_to_theme() . "/img/arrow_next.png' width='17' height='55' alt='Arrow Next'></a>";
    $output .= "</div>";
    return $output;
}
/**
 * Loads a drupal field collection in a single function call
 *
 * @author Arika Prime
 * @param string $fieldCollectionName drupal field collection machine name
 * @param object $node is teh node object - leave null for current node.
 * @return mixed[] The value of the field collection. This will return value in the order that they are entered in Drupal Admin
 */
function mos_getFieldCollectionValue($fieldCollectionName, $node = null)
{
    $node = mos_node($node);
    $valueArray = array();
    $fieldCollection = field_get_items('node', $node, $fieldCollectionName);
    if (!empty($fieldCollection)) {
        foreach ($fieldCollection as $fieldCollectionKey => $fieldCollectionValue) {
            $field = field_view_value('node', $node, $fieldCollectionName, $fieldCollectionValue);
            $fieldName = array();
            // Parse array to pull out the field labels of the fields within the field collection
            $fieldCollectionItemIndex = $fieldCollectionKey + 1;
            foreach ($field['entity']['field_collection_item'] as $id => $fieldCollection) {
                foreach ($fieldCollection as $key => $value) {
                    if (!preg_match("/\\#/", $key)) {
                        $fieldName[] = $key;
                    }
                }
                // load the field collection item entity
                $fieldCollectionItem = field_collection_item_load($id);
                // wrap the entity and make it easier to get the values of fields
                $fieldWrapper = entity_metadata_wrapper('field_collection_item', $fieldCollectionItem);
                // store values in array which will be returned at end of function
                foreach ($fieldName as $index => $name) {
                    $valueArray[$fieldCollectionKey][$name] = $fieldWrapper->{$name}->value();
                }
            }
        }
    }
    return $valueArray;
}
Exemple #9
0
function valhalla_bs_vol_election_info($node)
{
    $output = '';
    if ($field = field_get_items('node', $node, 'field_electioninfo')) {
        foreach ($field as $data) {
            $fc = field_collection_item_load($data['value']);
            // Election.
            if ($field = field_get_items('field_collection_item', $fc, 'field_election')) {
                if ($field[0]['entity']) {
                    $_node = $field[0]['entity'];
                    $election = $_node->title;
                }
            }
            // Polling station.
            if ($field = field_get_items('field_collection_item', $fc, 'field_vlnt_station')) {
                if ($field[0]['entity']) {
                    $_node = $field[0]['entity'];
                    $polling_station = l($_node->title, 'volunteers/station/' . $_node->nid);
                }
            }
            // Post role.
            if ($field = field_get_items('field_collection_item', $fc, 'field_post_role')) {
                if ($field[0]['entity']) {
                    $_node = $field[0]['entity'];
                    $role_title = $_node->title;
                    if ($field = field_get_items('node', $_node, 'field_description')) {
                        $role_description = $field[0]['value'];
                    }
                }
            }
            // Party.
            if ($field = field_get_items('field_collection_item', $fc, 'field_post_party')) {
                if ($field[0]['entity']) {
                    $_term = $field[0]['entity'];
                    $party = $_term->name;
                }
            }
            // Status.
            $rsvp = '';
            if ($field = field_get_items('field_collection_item', $fc, 'field_rsvp')) {
                $rsvp_map = array(0 => 'Ikke svaret', 1 => 'Ja', 2 => 'Nej', 3 => 'Aldrig');
                $rsvp = $rsvp_map[$field[0]['value']];
            }
            $rsvp_comment = '';
            if ($field = field_get_items('field_collection_item', $fc, 'field_rsvp_comment')) {
                $rsvp_comment = $field[0]['value'];
            }
            if ($field = field_get_items('field_collection_item', $fc, 'field_token')) {
                $rsvp_link = l(t('(skift status)'), 'volunteers/rsvp/' . $field[0]['value']);
            }
            $output .= '
        <h3>' . $election . '</h3>
        <table class="table">
          </tr>
            <td>Valgsted:</td>
            <td>' . $polling_station . '</td>
          </tr>
          </tr>
            <td>Rolle:</td>
            <td>' . $role_title . ' / ' . $role_description . '</td>
          </tr>
          </tr>
            <td>Parti:</td>
            <td>' . $party . '</td>
          </tr>
          </tr>
            <td>Status:</td>
            <td>' . $rsvp . ' ' . $rsvp_link . '</td>
          </tr>
          </tr>
            <td>Status kommentar:</td>
            <td><i>' . $rsvp_comment . '</i></td>
          </tr>
        </table>
        <br /><br />
        ';
        }
    }
    return $output;
}
/**
 * Creates a simple text rows array from a field collections, to be used in a
 * field_preprocess function.
 *
 * @param $vars
 *   An array of variables to pass to the theme template.
 *
 * @param $field_name
 *   The name of the field being altered.
 *
 * @param $field_array
 *   Array of fields to be turned into rows in the field collection.
 */
function rows_from_field_collection(&$vars, $field_name, $field_array)
{
    $vars['rows'] = array();
    foreach ($vars['element']['#items'] as $key => $item) {
        $entity_id = $item['value'];
        $entity = field_collection_item_load($entity_id);
        $wrapper = entity_metadata_wrapper('field_collection_item', $entity);
        $row = array();
        foreach ($field_array as $field) {
            $row[$field] = field_view_field('field_collection_item', $entity, $field, 'full');
        }
        $vars['rows'][] = $row;
    }
}
function snowpilot_snowpit_graph_header_write($node, $format = 'jpg')
{
    // also add user account info to this:
    $user_account = user_load($node->uid);
    $snowpit_unit_prefs = snowpilot_unit_prefs_get($node, 'node');
    $pit_depth = _snowpilot_find_pit_depth($node);
    // Image Variables
    $width = 994;
    $height = 840;
    //imageloadfont()
    // Create GD Image
    $img = imagecreatetruecolor($width, $height);
    // Assign some colors
    $black = imagecolorallocate($img, 0, 0, 0);
    $white = imagecolorallocate($img, 255, 255, 255);
    $purple_layer = imagecolorallocate($img, 154, 153, 213);
    $red_layer = imagecolorallocate($img, 178, 36, 35);
    $blue_outline = imagecolorallocate($img, 15, 8, 166);
    $pink_problem = imagecolorallocate($img, 254, 240, 240);
    // Set background color to white
    imagefill($img, 0, 0, $white);
    $label_font = '/sites/all/libraries/fonts/Arial.ttf';
    $value_font = '/sites/all/libraries/fonts/Arial Bold.ttf';
    $snowsymbols_font = '/sites/all/libraries/fonts/ArialMT28.ttf';
    // Label Y axis and draw horizontal lines
    imagettftext($img, 11, 0, 14, 17, $black, $value_font, $node->title);
    // Location information
    if (isset($node->field_loaction['und'][0]['tid'])) {
        $term_obj_region = taxonomy_term_load($node->field_loaction['und'][0]['tid']);
        imagettftext($img, 11, 0, 14, 53, $black, $value_font, $term_obj_region->name);
        if (isset($node->field_loaction['und'][1]['tid'])) {
            $term_obj_region = taxonomy_term_load($node->field_loaction['und'][1]['tid']);
            imagettftext($img, 11, 0, 14, 35, $black, $value_font, $term_obj_region->name);
        }
    }
    $text_pos = imagettftext($img, 11, 0, 14, 71, $black, $label_font, 'Elevation: ');
    if (isset($node->field_elevation['und'])) {
        imagettftext($img, 11, 0, $text_pos[2], 71, $black, $value_font, $node->field_elevation['und'][0]['value'] . ' ' . $node->field_elevation_units['und'][0]['value']);
    }
    $text_pos = imagettftext($img, 11, 0, 14, 89, $black, $label_font, 'Aspect: ');
    if (isset($node->field_aspect['und'])) {
        $aspect = field_view_field('node', $node, 'field_aspect');
        imagettftext($img, 11, 0, $text_pos[2], 89, $black, $value_font, $aspect[0]['#markup']);
    }
    $text_pos = imagettftext($img, 11, 0, 14, 107, $black, $label_font, 'Specifics: ');
    $specifics = _generate_specifics_string($node);
    imagettftext($img, 9, 0, $text_pos[2], 107, $black, $value_font, $specifics);
    // Observer
    imagettftext($img, 11, 0, 183, 17, $black, $value_font, $user_account->field_first_name['und'][0]['value'] . " " . $user_account->field_last_name['und'][0]['value']);
    imagettftext($img, 11, 0, 183, 35, $black, $value_font, date('D M j H:i Y (T) ', strtotime($node->field_date_time['und'][0]['value'] . " " . $node->field_date_time['und'][0]['timezone_db'])));
    //Date / Time of observation
    $text_pos = imagettftext($img, 11, 0, 183, 53, $black, $label_font, "Co-ord: ");
    if ($snowpit_unit_prefs['field_coordinate_type'] != 'UTM') {
        if (isset($node->field_latitude['und']) && isset($node->field_longitude['und'])) {
            imagettftext($img, 11, 0, $text_pos[2], 53, $black, $value_font, number_format($node->field_latitude['und'][0]['value'], 5) . $node->field_latitude_type['und'][0]['value'] . ", " . number_format($node->field_longitude['und'][0]['value'], 5) . $node->field_longitude_type['und'][0]['value']);
        }
    } else {
        // Not Lat long, their preference is UTM
        if (isset($node->field_east['und']) && isset($node->field_north['und'])) {
            imagettftext($img, 11, 0, $text_pos[2], 53, $black, $value_font, $node->field_utm_zone['und'][0]['value'] . ' ' . $node->field_east['und'][0]['value'] . $node->field_longitude_type['und'][0]['value'] . ' ' . $node->field_north['und'][0]['value'] . $node->field_latitude_type['und'][0]['value']);
        }
    }
    $text_pos = imagettftext($img, 11, 0, 183, 71, $black, $label_font, "Slope Angle: ");
    if (isset($node->field_slope_angle['und'])) {
        $slope_angle = field_view_field('node', $node, 'field_slope_angle');
        imagettftext($img, 11, 0, $text_pos[2], 71, $black, $value_font, $slope_angle[0]['#markup']);
    }
    $text_pos = imagettftext($img, 11, 0, 183, 89, $black, $label_font, "Wind Loading: ");
    if (isset($node->field_wind_loading['und'])) {
        imagettftext($img, 11, 0, $text_pos[2], 89, $black, $value_font, $node->field_wind_loading['und'][0]['value']);
    }
    $text_pos = imagettftext($img, 11, 0, 429, 17, $black, $label_font, "Stability: ");
    if (isset($node->field_stability_on_similar_slope['und'])) {
        $similar_stability = field_view_field('node', $node, 'field_stability_on_similar_slope');
        imagettftext($img, 11, 0, $text_pos[2], 17, $black, $value_font, $similar_stability[0]['#markup']);
    }
    $text_pos = imagettftext($img, 11, 0, 429, 35, $black, $label_font, "Air Temperature: ");
    if (isset($node->field_air_temp['und'])) {
        $air_temp = field_view_field('node', $node, 'field_air_temp');
        imagettftext($img, 11, 0, $text_pos[2], 35, $black, $value_font, $air_temp[0]['#markup'] . "&#176;" . $snowpit_unit_prefs['field_temp_units']);
    }
    $text_pos = imagettftext($img, 11, 0, 429, 53, $black, $label_font, "Sky Cover: ");
    if (isset($node->field_sky_cover['und'])) {
        $sky_cover = field_view_field('node', $node, 'field_sky_cover');
        imagettftext($img, 11, 0, $text_pos[2], 53, $black, $value_font, html_entity_decode($sky_cover[0]['#markup']));
    }
    $text_pos = imagettftext($img, 11, 0, 429, 71, $black, $label_font, "Precipitation: ");
    if (isset($node->field_precipitation['und'])) {
        $precipitation = field_view_field('node', $node, 'field_precipitation');
        imagettftext($img, 11, 0, $text_pos[2], 71, $black, $value_font, $precipitation[0]['#markup']);
    }
    $text_pos = imagettftext($img, 11, 0, 429, 89, $black, $label_font, "Wind: ");
    if (isset($node->field_wind_direction['und'][0]['value'])) {
        $text_pos = imagettftext($img, 11, 0, $text_pos[2] + 4, 89, $black, $value_font, snowpilot_cardinal_wind_dir($node->field_wind_direction['und'][0]['value']));
    }
    if (isset($node->field_wind_speed['und'][0]['value'])) {
        $wind_speed = field_view_field('node', $node, 'field_wind_speed');
        imagettftext($img, 11, 0, $text_pos[2], 89, $black, $value_font, " " . $wind_speed[0]['#markup']);
    }
    imagettftext($img, 11, 0, 805, 17, $black, $label_font, 'Layer Notes');
    $textpos = imagettftext($img, 11, 0, 14, 779, $black, $label_font, 'Notes: ');
    if (isset($node->body['und'][0]) && $node->body['und'][0]['safe_value'] != '') {
        $notes_lines = _output_formatted_notes($node->body['und'][0]['safe_value'], $value_font);
        foreach ($notes_lines as $x => $line) {
            if ($x <= 3) {
                imagettftext($img, 9, 0, $textpos[2], 779 + $x * 19, $black, $value_font, $line);
            } else {
                imagettftext($img, 9, 0, 870, 779 + 3 * 19, $red_layer, $value_font, "[ ... more notes ]");
                break;
            }
        }
    }
    //  write stability tests column and comments
    //  TODO : expand into its own function
    $comment_count = 0;
    $textpos = array();
    if (isset($node->field_total_height_of_snowpack['und'][0]['value'])) {
        $textpos = imagettftext($img, 9, 0, 645, 17, $black, $value_font, 'HS' . $node->field_total_height_of_snowpack['und'][0]['value']);
        $comment_count = 1;
    }
    if (isset($node->field_surface_penetration['und']) && $node->field_surface_penetration['und'][0]['value'] == 'boot' && isset($node->field_boot_penetration_depth['und']) && $node->field_boot_penetration_depth['und'][0]['value'] != '') {
        $xpos = count($textpos) ? $textpos[2] + 5 : 645;
        imagettftext($img, 9, 0, $xpos, 17, $black, $value_font, 'PF' . $node->field_boot_penetration_depth['und'][0]['value']);
        $comment_count = 1;
    } elseif (isset($node->field_surface_penetration['und']) && isset($node->field_ski_penetration['und'][0]['value']) && $node->field_surface_penetration['und'][0]['value'] == 'ski' && $node->field_ski_penetration['und'][0]['value'] != '') {
        $xpos = count($textpos) ? $textpos[2] + 5 : 645;
        imagettftext($img, 9, 0, $xpos, 17, $black, $value_font, 'SP' . $node->field_ski_penetration['und'][0]['value']);
        $comment_count = 1;
    }
    if (isset($node->field_test['und'])) {
        $ids = array();
        foreach ($node->field_test['und'] as $test) {
            $ids[] = $test['value'];
        }
        $test_results = field_collection_item_load_multiple($ids);
        // Here we go ahead and set a value for no-release type test results: ECTX, CTN, etc
        foreach ($test_results as $test) {
            if (!isset($test->field_depth['und'][0]['value'])) {
                $test->field_depth['und'][0]['value'] = $snowpit_unit_prefs['field_depth_0_from'] == 'top' ? $pit_depth : 0;
            }
        }
        uasort($test_results, 'depth_val');
        //
        // reversing the order of the test results makes it work when outputting the Stability test results on the graph when measuring from top
        if ($snowpit_unit_prefs['field_depth_0_from'] == 'top') {
            $test_results = array_reverse($test_results);
        }
        $bak = _set_stability_test_pixel_depths($test_results, $pit_depth, $snowpit_unit_prefs['field_depth_0_from']);
        // this sets a $test->y_position = integer which is where the line and text should go in the column on the right
        imagettftext($img, 11, 0, 645, $comment_count * 18 + 17, $black, $label_font, 'Stability Test Notes');
        foreach ($test_results as $x => $test) {
            if (isset($test->field_stability_test_type['und'][0]['value']) && isset($test->y_position)) {
                if (isset($test->y_position)) {
                    // if this has been 'multipled' with another stb test, the y_position won't be set
                    imageline($img, 707, $test->y_position, 941, $test->y_position, $black);
                    imagettftext($img, 9, 0, 712, $test->y_position - 5, $black, $label_font, stability_test_score_shorthand($test, $snowpit_unit_prefs));
                }
                if (count($test->field_stability_comments)) {
                    if ($comment_count < 5) {
                        $test_depth = isset($test->field_depth['und'][0]['value']) ? $test->field_depth['und'][0]['value'] + 0 : 0;
                        imagettftext($img, 9, 0, 645, $comment_count * 13 + 35, $black, $value_font, $test_depth . ': ' . $test->field_stability_comments['und'][0]['safe_value']);
                        $comment_count++;
                    } else {
                        imagettftext($img, 7, 0, 645, $comment_count * 13 + 31, $red_layer, $label_font, '[ More Stability Test Notes ... ]');
                    }
                }
            }
        }
    }
    // end stability test column
    // write rho column info
    //
    if (isset($node->field_density_profile['und'])) {
        foreach ($node->field_density_profile['und'] as $x => $density_item) {
            $density = field_collection_item_load($density_item['value']);
            // this use of imageline will need to be updated to include some kind of cluster management
            imageline($img, 667, snowpit_graph_pixel_depth($density->field_depth['und'][0]['value'], $pit_depth, $snowpit_unit_prefs['field_depth_0_from']), 707, snowpit_graph_pixel_depth($density->field_depth['und'][0]['value'], $pit_depth, $snowpit_unit_prefs['field_depth_0_from']), $black);
            imagettftext($img, 8, 0, 671, snowpit_graph_pixel_depth($density->field_depth['und'][0]['value'], $pit_depth, $snowpit_unit_prefs['field_depth_0_from']) + 12, $black, $label_font, $density->field_density_top['und'][0]['value']);
        }
    }
    //
    //  Prep for the 2 Cycles through layers
    //
    if (isset($node->field_layer['und'])) {
        $ids = array();
        foreach ($node->field_layer['und'] as $lay) {
            $ids[] = $lay['value'];
        }
        $all_layers = field_collection_item_load_multiple($ids);
        foreach ($all_layers as $x => $layer) {
            if ($snowpit_unit_prefs['field_depth_0_from'] == 'top') {
                $layer->y_val_top = $y_val_top = round(snowpit_graph_pixel_depth($layer->field_bottom_depth['und'][0]['value'], $pit_depth, $snowpit_unit_prefs['field_depth_0_from']));
                $layer->y_val = $y_val = round(snowpit_graph_pixel_depth($layer->field_height['und'][0]['value'], $pit_depth, $snowpit_unit_prefs['field_depth_0_from']));
            } else {
                $layer->y_val = $y_val = round(snowpit_graph_pixel_depth($layer->field_bottom_depth['und'][0]['value'], $pit_depth, $snowpit_unit_prefs['field_depth_0_from']));
                $layer->y_val_top = $y_val_top = round(snowpit_graph_pixel_depth($layer->field_height['und'][0]['value'], $pit_depth, $snowpit_unit_prefs['field_depth_0_from']));
            }
        }
        $keyed_all_layers = $all_layers;
        snowpilot_layers_density_xlate($keyed_all_layers, $snowpit_unit_prefs);
        // this solo line goes across the top of the top layer. Could be programmed later if we decide to include the 'headspace' above the top of the pit
        imageline($img, 483, $keyed_all_layers[0]->y_val_top, 667, $keyed_all_layers[0]->y_val_top, $black);
        ///
        // IN this loop, we set the items in the 'density managed' column - grain types, sizes, moisture, etc.
        //
        $comment_counter = 0;
        foreach ($keyed_all_layers as $x => $layer) {
            imageline($img, 511, $layer->y_val_xlate, 667, $layer->y_val_xlate, $black);
            // 'density managed' column - grain types, sizes, moisture, etc.
            imageline($img, 483, $layer->y_val, 491, $layer->y_val, $black);
            // a little tick to start outthe angle transferred stuff
            imageline($img, 491, $layer->y_val, 511, $layer->y_val_xlate, $black);
            // the diagonal line connect
            // Calculate grain type image(s) for this layer
            $grain_type_image = '';
            if (isset($layer->field_grain_type['und'])) {
                $grain_type_image = isset($layer->field_grain_type['und'][1]['tid']) ? _tid2snowsymbols($layer->field_grain_type['und'][1]['tid']) : _tid2snowsymbols($layer->field_grain_type['und'][0]['tid']);
            }
            $secondary_grain_type = '';
            if (isset($layer->field_grain_type_secondary['und'])) {
                $secondary_grain_type_image = isset($layer->field_grain_type_secondary['und'][1]['tid']) ? _tid2snowsymbols($layer->field_grain_type_secondary['und'][1]['tid']) : _tid2snowsymbols($layer->field_grain_type_secondary['und'][0]['tid']);
                $secondary_grain_type = ' (' . $secondary_grain_type_image . ')';
            }
            //output grain symbols
            imagettftext($img, 10, 0, 525, ($layer->y_val_xlate - $layer->y_val_top_xlate) / 2 + $layer->y_val_top_xlate + 5, $black, $snowsymbols_font, $grain_type_image . $secondary_grain_type);
            // calculate grain size string
            $grain_size_string = isset($layer->field_grain_size['und']) ? $layer->field_grain_size['und'][0]['value'] : '';
            if ($layer->field_use_multiple_grain_size['und'][0]['value'] == '1' && isset($layer->field_grain_size_max['und'][0]['value'])) {
                $grain_size_string .= ' - ' . $layer->field_grain_size_max['und'][0]['value'];
            }
            // Ouptut grain sizes
            $textpos = imagettftext($img, 10, 0, 584, ($layer->y_val_xlate - $layer->y_val_top_xlate) / 2 + $layer->y_val_top_xlate + 5, $black, $label_font, $grain_size_string);
            // calculate & output layer moisture
            if (isset($layer->field_water_content['und'])) {
                $moisture = $layer->field_water_content['und'][0]['value'];
                imagettftext($img, 10, 0, $textpos[2] + 5, ($layer->y_val_xlate - $layer->y_val_top_xlate) / 2 + $layer->y_val_top_xlate + 5, $black, $label_font, $moisture);
            }
            // Output Layer comments
            $layer_bottom = $layer->field_bottom_depth['und'][0]['value'] + 0;
            $layer_top = $layer->field_height['und'][0]['value'] + 0;
            if (isset($layer->field_comments['und'])) {
                if ($comment_counter < 5) {
                    imagettftext($img, 9, 0, 805, $comment_counter * 13 + 35, $black, $value_font, $layer_bottom . '-' . $layer_top . ': ' . $layer->field_comments['und'][0]['safe_value']);
                    $comment_counter++;
                } else {
                    imagettftext($img, 7, 0, 805, $comment_counter * 13 + 31, $red_layer, $label_font, '[ More Layer Comments ... ]');
                }
            }
            // write density measurements that are from the 'Layers' tab into the rho column ( in addition to Densities )
            if (isset($layer->field_density_top['und'][0]['value'])) {
                imageline($img, 667, snowpit_graph_pixel_depth($layer->field_height['und'][0]['value'], $pit_depth, $snowpit_unit_prefs['field_depth_0_from']), 707, snowpit_graph_pixel_depth($layer->field_height['und'][0]['value'], $pit_depth, $snowpit_unit_prefs['field_depth_0_from']), $black);
                imagettftext($img, 8, 0, 669, snowpit_graph_pixel_depth($layer->field_height['und'][0]['value'], $pit_depth, $snowpit_unit_prefs['field_depth_0_from']) - 5, $black, $label_font, $layer->field_density_top['und'][0]['value']);
            }
            snowpilot_draw_layer_polygon($img, $layer, $purple_layer, TRUE, $snowpit_unit_prefs['hardnessScaling']);
            // the fill
            snowpilot_draw_layer_polygon($img, $layer, $blue_outline, FALSE, $snowpit_unit_prefs['hardnessScaling']);
            // the outline
            // this mark the layer if its a critical layer, and save some
            if ($layer->field_this_is_my_layer_of_greate['und'][0]['value'] == '1') {
                $x_redline = _h2pix($layer->field_hardness['und'][0]['value'], FALSE, $snowpit_unit_prefs['hardnessScaling']);
                $x_redline_bottom = _h2pix($layer->field_hardness['und'][0]['value'], FALSE, $snowpit_unit_prefs['hardnessScaling']);
                if (isset($layer->field_hardness2['und'][0]['value'])) {
                    $x_redline_bottom = _h2pix($layer->field_hardness2['und'][0]['value'], FALSE, $snowpit_unit_prefs['hardnessScaling']);
                }
                $y_redline_top = $layer->y_val_top;
                $y_redline_bottom = $layer->y_val;
                ///
                $concern_delta = $layer->item_id;
                if ($comment_counter < 5) {
                    imagettftext($img, 9, 0, 805, $comment_counter * 13 + 35, $black, $value_font, $layer_bottom . '-' . $layer_top . ": Problematic layer");
                    $comment_counter++;
                } elseif ($comment_counter == 5) {
                    imagettftext($img, 7, 0, 805, $comment_counter * 13 + 31, $red_layer, $label_font, '[ More Layer Comments ... ]');
                }
                $comment_counter++;
            }
        }
    }
    // now that we are done drawing all the layers, we can overprint the red layer of concern
    if (isset($concern_delta)) {
        $layer_part = isset($all_layers[$concern_delta]->field_concern['und'][0]['value']) ? $all_layers[$concern_delta]->field_concern['und'][0]['value'] : 'entire layer';
        switch ($layer_part) {
            case 'entire layer':
                //full-on red layer was too much; withdrawn for now; in favor of perhaps diagonal lines of red indicating layer of concern ( all layer ) in future
                //
                break;
            case 'top':
                imageline($img, $x_redline, $y_redline_top + 2, 446, $y_redline_top + 2, $red_layer);
                imageline($img, $x_redline, $y_redline_top + 1, 446, $y_redline_top + 1, $red_layer);
                break;
            case 'bottom':
                imageline($img, $x_redline_bottom, $y_redline_bottom - 2, 446, $y_redline_bottom - 2, $red_layer);
                imageline($img, $x_redline_bottom, $y_redline_bottom - 1, 446, $y_redline_bottom - 1, $red_layer);
                break;
        }
    }
    // Temperature Profile:
    // If we have temp profile readings,then we'll make the tick marks
    if (isset($node->field_temp_collection['und'])) {
        $ids = array();
        foreach ($node->field_temp_collection['und'] as $temp) {
            $ids[] = $temp['value'];
        }
        $all_temps = field_collection_item_load_multiple($ids);
        uasort($all_temps, 'depth_val');
        $min_temp = $snowpit_unit_prefs['field_temp_units'] == 'F' ? 12 : -8;
        $min_temp = _temp_profile_find_min_temp($all_temps, $min_temp) - 2;
        if ($snowpit_unit_prefs['field_temp_units'] == 'C') {
            $pixels_per_degree = 433 / $min_temp;
            $increment = $min_temp < -14 ? 2 : 1;
            $x = 0;
            while ($x >= $min_temp) {
                //  tickmarks
                imageline($img, 447 - $pixels_per_degree * $x, 132, 447 - $pixels_per_degree * $x, 140, $black);
                imagettftext($img, 9, 0, 441 - $pixels_per_degree * $x, 130, $black, $label_font, $x);
                $x = $x - $increment;
            }
        } else {
            /// Temperature units = 'F'
            $pixels_per_degree = 433 / $min_temp;
            $increment = $min_temp < 5 ? 2 : 1;
            $x = 32;
            while ($x >= $min_temp) {
                // tickmarks
                imageline($img, 447 - $pixels_per_degree * ($x - 32), 132, 447 - $pixels_per_degree * ($x - 32), 140, $black);
                imagettftext($img, 9, 0, 441 - $pixels_per_degree * ($x - 32), 130, $black, $label_font, $x);
                $x = $x - $increment;
            }
        }
        // end temp units toggle
        // draw points, and line, different $cx calculations for F or C
        $prev_x = 0;
        $prev_y = 0;
        foreach ($all_temps as $x => $temp) {
            $cx = $snowpit_unit_prefs['field_temp_units'] == 'C' ? 447 - $pixels_per_degree * $temp->field_temp_temp['und'][0]['value'] : 447 - $pixels_per_degree * ($temp->field_temp_temp['und'][0]['value'] - 32);
            //dsm($cx);
            if ($cx >= 14 && $cx <= 447) {
                // draw point
                imagefilledellipse($img, $cx, snowpit_graph_pixel_depth($temp->field_depth['und'][0]['value'], $pit_depth, $snowpit_unit_prefs['field_depth_0_from']), 6, 6, $red_layer);
                // draw line
                if ($prev_x <= 447 && $prev_x >= 14 && $prev_y) {
                    imageline($img, $cx, snowpit_graph_pixel_depth($temp->field_depth['und'][0]['value'], $pit_depth, $snowpit_unit_prefs['field_depth_0_from']), $prev_x, $prev_y, $red_layer);
                }
            }
            // save this point location to use to draw the next line
            $prev_x = $cx;
            $prev_y = snowpit_graph_pixel_depth($temp->field_depth['und'][0]['value'], $pit_depth, $snowpit_unit_prefs['field_depth_0_from']);
        }
    }
    // end of drawing the temperature profile
    // cycle through and make depth tick marks
    $x = 0;
    while ($x <= $pit_depth) {
        $y_val = round(snowpit_graph_pixel_depth($x, $pit_depth, $snowpit_unit_prefs['field_depth_0_from']));
        imageline($img, 660, $y_val, 667, $y_val, $black);
        imageline($img, 511, $y_val, 518, $y_val, $black);
        imageline($img, 14, $y_val, 22, $y_val, $black);
        imageline($img, 440, $y_val, 447, $y_val, $black);
        imagettftext($img, 10, 0, 456, $y_val + 5, $black, $label_font, $x);
        $x += 10;
    }
    // Now we make the 5cm tick marks
    $x = 5;
    while ($x <= $pit_depth) {
        $y_val = round(snowpit_graph_pixel_depth($x, $pit_depth, $snowpit_unit_prefs['field_depth_0_from']));
        imageline($img, 664, $y_val, 667, $y_val, $black);
        imageline($img, 511, $y_val, 515, $y_val, $black);
        imageline($img, 14, $y_val, 18, $y_val, $black);
        imageline($img, 443, $y_val, 447, $y_val, $black);
        //imagettftext($img, 10, 0, 638, round(snowpit_graph_pixel_depth($x, $node, 'bottom'))+5, $black, $label_font, $x );
        $x += 10;
    }
    //
    imagettftext($img, 10, 0, 742, 122, $black, $label_font, "Stability tests");
    imagettftext($img, 10, 0, 681, 118, $black, $label_font, "&#x3c1;");
    // Rho symbol for density
    imagettftext($img, 10, 0, 675, 135, $black, $label_font, _density_unit_fix($snowpit_unit_prefs['field_density_units']));
    // the rectabngle around stability and density columns
    imagerectangle($img, 667, 140, 941, 751, $black);
    // the rectangle around the layers hardness profile
    imagerectangle($img, 14, 140, 447, 751, $black);
    //the tickmarks for hardness across the bottom and top, and labels
    foreach (_h2pix(NULL, TRUE, $snowpit_unit_prefs['hardnessScaling']) as $hardness => $pixels) {
        if (substr($hardness, -1) != '+' && substr($hardness, -1) != '-') {
            imageline($img, $pixels, 140, $pixels, 156, $black);
            imageline($img, $pixels, 734, $pixels, 751, $black);
            imagettftext($img, 10, 0, $pixels - 5, 765, $black, $label_font, $hardness);
            //imagettftext($img, 10, 0, $pixels- 5, 172, $black, $label_font, $hardness);
        } else {
            // it is a + or - declaration, shorter ticks and no label
            imageline($img, $pixels, 140, $pixels, 145, $black);
            imageline($img, $pixels, 746, $pixels, 751, $black);
        }
    }
    imageline($img, 707, 140, 707, 751, $black);
    imageline($img, 483, 140, 667, 140, $black);
    // finish line across top
    imageline($img, 483, 751, 667, 751, $black);
    // finish line across bottom
    imageline($img, 483, 140, 483, 751, $black);
    // left edge, first vert line
    imageline($img, 511, 140, 511, 751, $black);
    // beginning of crystal form column
    imageline($img, 575, 135, 575, 751, $black);
    //beginning of crystal size column
    imagettftext($img, 10, 0, 554, 122, $black, $label_font, "Crystal");
    imagettftext($img, 10, 0, 516, 137, $black, $label_font, "Form");
    imagettftext($img, 10, 0, 580, 137, $black, $label_font, "Size (mm)");
    // Snowpilot water mark logo _100
    $sp_watermark = imagecreatefrompng(DRUPAL_ROOT . '/sites/all/themes/sp_theme/images/SnowPilot_Watermark_BlueOrange_100.png');
    imagecopy($img, $sp_watermark, 35, 170, 0, 0, 160, 99);
    imagedestroy($sp_watermark);
    // Output the png image
    $filename = 'graph-' . $node->nid;
    imagejpeg($img, DRUPAL_ROOT . '/sites/default/files/snowpit-profiles/' . $filename . '.jpg', 100);
    imagepng($img, DRUPAL_ROOT . '/sites/default/files/snowpit-profiles/' . $filename . '.png');
    snowpilot_snowpit_crop_layers_write($img, $node->nid);
    // Destroy GD image
    //imagedestroy($img);
    if ($format == 'jpg') {
        return $img;
    } else {
        return $img;
    }
}
$slide = array();
$style_name = 'slider_656x400_';
foreach ($items as $item) {
    $field_collection_item = $item['entity']['field_collection_item'];
    foreach ($field_collection_item as $field_item) {
        $field_imagen = '';
        $field_caption = '';
        $field_title = '';
        if ($field_item['#bundle'] == 'field_galeria') {
            //imagenes
            $field_imagen_galeria_object = $field_item['field_imagen_galeria'];
            $field_imagen_galeria = field_get_items('field_collection_item', $field_imagen_galeria_object['#object'], 'field_imagen_galeria');
            foreach ($field_imagen_galeria as $value) {
                $field_caption = '';
                $temp_entities = field_collection_item_load($value['value']);
                $field_galeria = $temp_entities->field_imagen;
                $url = image_style_url($style_name, $field_galeria['und'][0]['uri']);
                image_style_create_derivative($style_name, $field_galeria['und'][0]['uri'], $url);
                if ($field_galeria['und'][0]['alt'] != '') {
                    $field_caption = $field_galeria['und'][0]['alt'];
                }
                if ($field_galeria['und'][0]['title'] != '') {
                    $field_title = $field_galeria['und'][0]['title'];
                }
                if ($field_caption == '') {
                    array_push($slide, '<li><img src="' . $url . '" title="' . $field_title . '"/></li>');
                } else {
                    array_push($slide, '<li><img src="' . $url . '" alt="' . $field_caption . '" title="' . $field_title . '"/></li>');
                }
            }
Exemple #13
0
    // dpm($term);
    print '<h3><a href="#">' . $term->name . '</a></h3>';
    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'client')->propertyCondition('status', NODE_PUBLISHED)->fieldCondition('field_category', 'tid', $term->tid, '=')->addMetaData('account', user_load(1));
    // Run the query as user 1.
    $result = $query->execute();
    if (isset($result['node'])) {
        $nids = array_keys($result['node']);
        $clients = entity_load('node', $nids);
    }
    print '<div class="second-level">';
    $count = 0;
    foreach ($clients as $client) {
        // dpm($client);
        if (isset($client->field_client_quotes['und'])) {
            print '<h3 class="ui-parent">' . $client->title . '</h3>';
            print '<div class="ui-content">';
            foreach ($client->field_client_quotes['und'] as $client_quote) {
                $field_collection_item = field_collection_item_load($client_quote['value']);
                print '<div class="client-quote"><div class="field-content">"' . $field_collection_item->field_quote['und'][0]['value'] . '"</div></div>';
                print '<div class="client-quote-author"><div class="field_content">- ' . $field_collection_item->field_author['und'][0]['value'] . '</div></div>';
            }
            print '</div>';
        } else {
            print '<h3>' . $client->title . '</h3>';
        }
        $count++;
    }
    print '</div>';
}
print '</div>';
Exemple #14
0
 public static function setViales($tituloCaja, $primerNumeroVial, $ultimoNumeroVial)
 {
     $posicion = 1;
     $idCaja = bbiLab_getIdNodeByTitle($tituloCaja);
     for ($i = $primerNumeroVial; $i <= $ultimoNumeroVial; $i++) {
         $titulo = 'CA-AAA';
         $titulo = $titulo . $i;
         $vial = node_load(bbiLab_getIdNodeByTitle($titulo));
         //Eliminamos todas las colecciones de campo que tenia de antes
         foreach ($vial->field_vial_caja['und'] as $idCollection) {
             //Cargamos el nodo....
             $collection = field_collection_item_load($idCollection['value']);
             //Checkeamos que sea correcto
             if ($collection->item_id) {
                 entity_delete_multiple('field_collection_item', array($idCollection));
             }
         }
         //Le metemos que está pistoleteado
         if ($vial->type == 'vial') {
             $vial->field_vial_pistoleteado['und'][0]['value'] = 1;
             //borramos todas las collecciones vacias
             $vial->field_vial_caja['und'] = null;
             $vial->body = '';
             node_save($vial);
         }
         //Aquí creamos la colección de campos y la guardamos
         $values['field_name'] = 'field_vial_caja';
         $values["field_vial_caja_posicion"] = array(LANGUAGE_NONE => array(array('value' => $posicion)));
         $values["field_caja_fisica"] = array(LANGUAGE_NONE => array(array('target_id' => $idCaja)));
         //print_r($values);
         $field_collection_item = entity_create('field_collection_item', $values);
         $field_collection_item->setHostEntity('node', $vial);
         $field_collection_item->save();
         $posicion++;
     }
 }
Exemple #15
0
/**
 * Creates a simple text rows array from a field collections, to be used in a
 * field_preprocess function.
 *
 * @param $vars
 *   An array of variables to pass to the theme template.
 *
 * @param $field_name
 *   The name of the field being altered.
 *
 * @param $field_array
 *   Array of fields to be turned into rows in the field collection.
 */
function rows_from_field_collection(&$vars, $field_name, $field_array)
{
    $vars['rows'] = array();
    foreach ($vars['element']['#items'] as $key => $item) {
        $entity_id = $item['value'];
        $entity = field_collection_item_load($entity_id);
        $wrapper = entity_metadata_wrapper('field_collection_item', $entity);
        $row = array();
        foreach ($field_array as $field) {
            if (!empty($wrapper->{$field})) {
                $value = $wrapper->{$field}->value();
                if (!empty($value)) {
                    $row[$field] = $value;
                }
            }
        }
        $vars['rows'][] = $row;
    }
}
Exemple #16
0
/**
 * Implements hook_preprocess_node().
 */
function bvng_preprocess_node(&$variables)
{
    /* Add theme hook suggestion for nodes of taxonomy/term/%
     */
    if (isset($variables['requested_path'])) {
        if (strpos($variables['requested_path'], 'taxonomy/term') !== FALSE) {
            array_push($variables['theme_hook_suggestions'], 'node__taxonomy' . '__generic');
        }
    } elseif (isset($variables['current_path'])) {
    }
    /* Prepare the prev/next $node of the same content type.
     */
    if ($variables['node']) {
        switch ($variables['node']->type) {
            default:
                $next_node = node_load(prev_next_nid($variables['node']->nid, 'prev'));
        }
        $next_node = $next_node->status == 1 ? $next_node : NULL;
        // Only refer to published node.
        $variables['next_node'] = $next_node;
    }
    /* Prepare $cchunks, $anchors and $elinks for type "generictemplate"
     * @see http://drupal.stackexchange.com/questions/35355/accessing-a-field-collection
     */
    // Prepare $cchunks.
    if ($variables['node']->type == 'generictemplate' && !empty($variables['field_cchunk'])) {
        $fields_collection = field_get_items('node', $variables['node'], 'field_cchunk');
        $cchunks = array();
        foreach ($fields_collection as $idx => $data) {
            $cchunks[$idx] = field_collection_item_load($fields_collection[$idx]['value']);
        }
        $variables['cchunks'] = $cchunks;
        // Prepare title, content and sidebar for each chunk.
        $cchunks_title = array();
        $cchunks_content = array();
        $cchunks_sidebar = array();
        $anchors = array();
        $elinks = array();
        foreach ($variables['cchunks'] as $k => $cchunk) {
            $cchunks_title[$k] = _bvng_get_field_value('field_collection_item', $cchunk, 'field_title');
            $cchunks_content[$k] = _bvng_get_field_value('field_collection_item', $cchunk, 'field_sectioncontent');
            $sidebar_fields = array('anchors' => 'field_anchorlinkslist', 'elinks' => 'field_externallinkslist');
            foreach ($sidebar_fields as $var => $sidebar_field) {
                $field_links = array();
                $field_links[] = field_get_items('field_collection_item', $cchunk, $sidebar_field);
                foreach ($field_links as $i => $field_link) {
                    foreach ($field_link as $f_link) {
                        $cat_var =& ${$var};
                        $cat_var[$k][] = field_collection_item_load($f_link['value']);
                    }
                }
            }
            $cchunks_sidebar[$k] = '';
            if (!empty($anchors[$k])) {
                foreach ($anchors[$k] as $anchor) {
                    if ($anchor !== FALSE) {
                        $anchors_title = _bvng_get_field_value('field_collection_item', $anchor, 'field_anchorlinkslisttitle');
                        $anchors_links = _bvng_get_field_value('field_collection_item', $anchor, 'field_anchorlink');
                        $cchunks_sidebar[$k] .= '<h3>' . $anchors_title . '</h3>';
                        $cchunks_sidebar[$k] .= '<ul class="tags">';
                        foreach ($anchors_links as $anchors_link) {
                            $cchunks_sidebar[$k] .= '<li><a href="#' . $anchors_link['link'] . '">' . $anchors_link['title'] . '</a></li>';
                        }
                        $cchunks_sidebar[$k] .= '</ul>';
                    }
                }
            }
            if (!empty($elinks[$k])) {
                foreach ($elinks[$k] as $elink) {
                    if ($elink !== FALSE) {
                        $elinks_title = _bvng_get_field_value('field_collection_item', $elink, 'field_externallinkslisttitle');
                        $elinks_links = _bvng_get_field_value('field_collection_item', $elink, 'field_externallink');
                        $cchunks_sidebar[$k] .= '<h3>' . $elinks_title . '</h3>';
                        $cchunks_sidebar[$k] .= '<ul class="tags">';
                        foreach ($elinks_links as $elinks_link) {
                            $link = array('#theme' => 'link', '#text' => $elinks_link['title'], '#path' => $elinks_link['url'], '#options' => array('attributes' => $elinks_link['attributes']), '#prefix' => '<li>', '#suffix' => '</li>');
                            $cchunks_sidebar[$k] .= render($link);
                        }
                        $cchunks_sidebar[$k] .= '</ul>';
                    }
                }
            }
        }
        $variables['cchunks_title'] = $cchunks_title;
        $variables['cchunks_content'] = $cchunks_content;
        $variables['cchunks_sidebar'] = $cchunks_sidebar;
    }
    /* Get footer fields for data use articles.
     */
    $node_footer = _bvng_get_node_footer_content($variables['node']);
    $variables['node_footer'] = $node_footer;
    /* Get sidebar content
     */
    $sidebar = _bvng_get_sidebar_content($variables['nid'], $variables['vid']);
    $variables['sidebar'] = $sidebar;
    /* Build a combo value consisting of publisher and publishing date
     */
    if ($variables['node']->type == 'resource_ims' && !empty($variables['field_publishing_date']) && !empty($variables['field_publisher'])) {
        /*
         * fix me: It should have been done with "render()" so that we can make use of the format decided in "manage display"
         */
        $publishing_date = _bvng_get_field_value('node', $variables['node'], 'field_publishing_date');
        $publisher = _bvng_get_field_value('node', $variables['node'], 'field_publisher');
        // Friday, April 11, 2014
        $publishing_date = date('l, M d, Y', $publishing_date);
        $publisher_w_date = $publisher . ', ' . $publishing_date;
        $variables['publisher_w_date'] = '<div class="field field-name-field-publisher-w-date field-type-text-long field-label-above">
		<div class="field-label">Publisher&nbsp;</div>
		<div class="field-items">
		<div class="field-item even">' . $publisher_w_date . '</div></div></div>';
    }
    /* Process the date of event.
     */
    if ($variables['node']->type == 'event_ims') {
        $variables['event_date'] = _bvng_get_field_value('node', $variables['node'], 'field_dates');
    }
    /* Process menu_local_tasks()
     */
    global $user;
    // Bring the local tasks tab into node template.
    // @todo To investigate that this doesn't work for data use.
    $variables['tabs'] = menu_local_tabs();
    /* Determine what local task to show according to the role.
     * @todo To implement this using user_permission.
     */
    if (is_array($variables['tabs']['#primary'])) {
        foreach ($variables['tabs']['#primary'] as $key => $item) {
            // We don't need the view tab because we're already viewing it.
            switch ($item['#link']['title']) {
                case 'View':
                    unset($variables['tabs']['#primary'][$key]);
                    break;
                case 'Edit':
                    // Alter the 'edit' link to point to the node/%/edit
                    $variables['tabs']['#primary'][$key]['#link']['href'] = 'node/' . $variables['node']->nid . '/edit';
                    if (!in_array('Editors', $user->roles)) {
                        unset($variables['tabs']['#primary'][$key]);
                    }
                    break;
                case 'Devel':
                    // Alter the 'edit' link to point to the node/%/devel
                    $variables['tabs']['#primary'][$key]['#link']['href'] = 'node/' . $variables['node']->nid . '/devel';
                    if (!in_array('administrator', $user->roles)) {
                        unset($variables['tabs']['#primary'][$key]);
                    }
                    break;
            }
        }
    }
    /* Get also tagged
     */
    $variables['also_tagged'] = _bvng_get_also_tag_links($variables['node']);
    /* Prepare event location
     */
    if (isset($variables['node']->type) && $variables['node']->type == 'event_ims') {
        $markup_location = '';
        $city = _bvng_get_field_value('node', $variables['node'], 'field_city');
        $venuecountry = _bvng_get_field_value('node', $variables['node'], 'field_venuecountry');
        $markup_location .= $city == FALSE ? '' : $city;
        $markup_location .= $city == FALSE && $venuecountry == FALSE ? '' : ', ';
        $markup_location .= $venuecountry == FALSE ? '' : $venuecountry;
    }
    if (strlen($markup_location) !== 0) {
        $variables['event_location'] = $markup_location;
    }
}
    } elseif ($display_type == 'M') {
        echo '<li><a href="#0" data-date="' . date('j/m/y', $date) . '" class="' . $selected . '">' . date('F', $date) . '</a></li>';
    } else {
        echo '<li><a href="#0" data-date="' . date('j/m/y', $date) . '" class="' . $selected . '">&nbsp;</a></li>';
    }
}
?>
                    </ol>
                  </div>
                </div>
              </div>
              <div class="events-content">
                <ol>
                <?php 
foreach ($content['field_ucfs_schdul_date_n_detail']['#items'] as $key => $value) {
    $fc_item = field_collection_item_load($value['value']);
    $date = $fc_item->field_uc_schdul_date[LANGUAGE_NONE][0]['value'];
    $date = strtotime($date);
    $detail = $fc_item->field_uc_schdul_details[LANGUAGE_NONE][0]['value'];
    $display_type = $fc_item->field_uc_schdul_display_date[LANGUAGE_NONE][0]['value'];
    /**get the current date and hightlight the closest event ***/
    if ($recentdate == $date) {
        $selected = 'selected';
    } else {
        $selected = '';
    }
    echo '<li class="' . $selected . '" data-date="' . date('j/m/y', $date) . '">';
    if ($display_type == 'All') {
        echo '<em>' . date('M. d, Y', $date) . '</em>';
    } elseif ($display_type == 'MD') {
        echo '<em>' . date('M. d', $date) . '</em>';
    </a>
    <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
      <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
      <span class="sr-only">Next</span>
    </a>
</div>  
<?php 
    } elseif ($content["field_tipo_plantilla_html"]["#object"]->field_tipo_plantilla_html['und'][0]['value'] == '7') {
        ?>
  <div class="container-fluid l-btns">
    <div class="row">
      <?php 
        $nodes = array();
        foreach ($content["field_tipo_plantilla_html"]["#object"]->field_botones_linkeados as $key => $values) {
            foreach ($values as $key => $value) {
                $nodes[] = field_collection_item_load($value['value'], $reset = FALSE);
            }
            foreach ($nodes as $key => $value3) {
                $men = menu_link_load($value3->field_link_html['und'][0]['mlid']);
                ?>
          <div class="u-box col-lg-4 col-md-4 col-sm-6 col-xs-12">
            <div class="u-box-img">
              <img src="<?php 
                print_r(file_create_url($value3->field_imagen_linked['und'][0]['uri']));
                ?>
" alt="miller_lite_moments" />
            </div> 
            <?php 
                if (isset($value3->field_label_html['und'][0]['value'])) {
                    ?>