View source
<?php
class Biblio extends Entity {
protected function defaultLabel() {
$wrapper = entity_metadata_wrapper('biblio', $this);
return $wrapper->biblio_title
->value();
}
protected function defaultUri() {
return array(
'path' => 'biblio/' . $this
->identifier(),
);
}
}
class BiblioController extends EntityAPIController {
public function create(array $sent_values = array()) {
global $user;
$values = array(
'bid' => '',
'publication_type' => $sent_values['publication_type'],
'created' => REQUEST_TIME,
'changed' => '',
'uid' => $user->uid,
);
$values += $sent_values;
return parent::create($values);
}
public function buildContent($entity, $view_mode = 'full', $langcode = NULL, $content = array()) {
$wrapper = entity_metadata_wrapper('biblio', $entity);
$content['author'] = array(
'#markup' => t('Created by: !author', array(
'!author' => $wrapper->uid->name
->value(array(
'sanitize' => TRUE,
)),
)),
);
$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);
}
}