You are here

biblio.contributor.controller.inc in Bibliography Module 7.2

Same filename and directory in other branches
  1. 7.3 includes/biblio.contributor.controller.inc

File

includes/biblio.contributor.controller.inc
View source
<?php

/**
 * Contributor class.
 */
class BiblioContributor extends Entity {
  protected function defaultLabel() {
    $wrapper = entity_metadata_wrapper('biblio_contributor', $this);
    return $wrapper->biblio_contributor_name
      ->value();
  }
  public function label() {
    $label = $this
      ->defaultLabel();
    return $label;
  }
  protected function defaultUri() {
    return array(
      'path' => 'biblio/contributor/' . $this
        ->identifier(),
    );
  }

}

/**
 * Contributor controller class
 */
class BiblioContributorController extends EntityAPIController {

  /**
   * Creates default property values for our entity object
   *
   * @global type $user
   * @param array $values
   * @return array
   */
  public function create(array $values = array()) {
    global $user;
    if (!isset($values['type'])) {
      throw new Exception('Attempted to create a Biblio contributor without a type');
    }
    $default_values = array(
      'cid' => '',
      'title' => '',
      'description' => '',
      'created' => REQUEST_TIME,
      'changed' => REQUEST_TIME,
      'uid' => $user->uid,
      'md5' => '',
    );
    $values = array_merge($default_values, $values);
    $contributor = parent::create($values);
    return $contributor;
  }
  public function buildContent($entity, $view_mode = 'full', $langcode = NULL, $content = array()) {
    $wrapper = entity_metadata_wrapper('biblio_contributor', $entity);
    $content['author'] = array(
      '#markup' => t('Created by: !author', array(
        '!author' => $wrapper->uid->name
          ->value(array(
          'sanitize' => TRUE,
        )),
      )),
    );

    // Make Description and Status themed like default fields.
    $content['description'] = array(
      '#theme' => 'field',
      '#weight' => 0,
      '#title' => t('Description'),
      '#access' => TRUE,
      '#label_display' => 'above',
      '#view_mode' => 'full',
      '#language' => LANGUAGE_NONE,
      '#field_name' => 'field_fake_description',
      '#field_type' => 'text',
      '#entity_type' => 'biblio_contributor',
      '#bundle' => $entity->type,
      '#items' => array(
        array(
          'value' => $entity->description,
        ),
      ),
      '#formatter' => 'text_default',
      0 => array(
        '#markup' => check_plain($entity->description),
      ),
    );
    return parent::buildContent($entity, $view_mode, $langcode, $content);
  }

}

Classes

Namesort descending Description
BiblioContributor Contributor class.
BiblioContributorController Contributor controller class