View source
<?php
ctools_include('plugins');
module_load_include('inc', 'eck', 'eck.classes');
module_load_include('inc', 'eck', 'eck.entity_type');
module_load_include('inc', 'eck', 'eck.bundle');
module_load_include('inc', 'eck', 'eck.entity');
module_load_include('inc', 'eck', 'eck.default_properties');
module_load_include('inc', 'eck', 'eck.property_type');
module_load_include('inc', 'eck', 'eck.properties');
module_load_include('inc', 'eck', 'eck.property_behavior');
module_load_include('inc', 'eck', 'eck.permissions');
module_load_include('inc', 'eck', 'eck.schema');
module_load_include('inc', 'eck', 'includes/eck.references_dialog');
function eckentity_load($id, $type) {
try {
$entity = entity_load_single($type, $id);
} catch (Exception $ex) {
drupal_not_found();
exit;
}
return $entity;
}
function eck_views_api() {
return array(
'api' => '3',
'path' => drupal_get_path('module', 'eck') . '/views',
);
}
function eck_flush_caches() {
eck_get_property_types(NULL, TRUE);
eck_property_info_widget_types(NULL, TRUE);
EntityType::loadAll(NULL, TRUE);
Bundle::loadAll(NULL, TRUE);
}
function eck_modules_enabled($modules) {
$reset_caches = FALSE;
foreach ($modules as $module) {
if (module_hook($module, 'eck_property_widget_info') || module_hook($module, 'eck_property_types')) {
eck_flush_caches();
break;
}
}
}
function eck_modules_disabled($modules) {
$reset_caches = FALSE;
foreach ($modules as $module) {
if (module_hook($module, 'eck_property_widget_info') || module_hook($module, 'eck_property_types')) {
eck_flush_caches();
break;
}
}
}
function eck_eck_default_properties() {
$default_properties = array();
$default_properties['title'] = array(
'label' => "Title",
'type' => "text",
'behavior' => 'title',
);
$default_properties['uid'] = array(
'label' => "Author",
'type' => "integer",
'behavior' => 'author',
);
$default_properties['created'] = array(
'label' => "Created",
'type' => "integer",
'behavior' => 'created',
);
$default_properties['changed'] = array(
'label' => "Changed",
'type' => "integer",
'behavior' => 'changed',
);
$default_properties['language'] = array(
'label' => "Entity language",
'type' => "language",
'behavior' => 'language',
);
if (module_exists('uuid')) {
$default_properties['uuid'] = array(
'label' => "UUID",
'type' => "text",
'behavior' => 'uuid',
);
}
return $default_properties;
}
function eck_ctools_plugin_directory($owner, $plugin_type) {
if ($owner == 'eck' && $plugin_type == 'property_behavior') {
return 'plugins/' . $plugin_type;
}
}
function eck_ctools_plugin_type() {
return array(
'property_behavior' => array(),
);
}
function eck__entity__label($entity) {
$hook_names = array(
"eck_entity_label",
"eck_entity_{$entity->entityType()}_label",
"eck_entity_{$entity->entityType()}_{$entity->bundle()}_label",
);
foreach ($hook_names as $hook_name) {
$new_label = module_invoke_all($hook_name, $entity, $entity->id);
$empty = empty($new_label);
if (!$empty) {
break;
}
}
if (!$empty) {
return $new_label[0];
}
else {
return $entity->id;
}
}
function eck__entity__uri($entity) {
$ids = entity_extract_ids($entity
->entityType(), $entity);
module_load_include('inc', 'eck', 'eck.entity');
$crud_info = get_bundle_crud_info($entity
->entityType(), $entity
->bundle());
$view_path = str_replace('%eckentity', $ids[0], $crud_info['view']['path']);
return array(
'path' => $view_path,
);
}
function eck_schema_alter(&$schema) {
if (db_table_exists('eck_entity_type')) {
foreach (EntityType::loadAll() as $entity_type) {
$schema = array_merge($schema, array(
"eck_{$entity_type->name}" => eck__entity_type__schema($entity_type),
));
$vars = array(
'entity_type' => $entity_type,
'schema' => $schema,
);
$vars = eck_property_behavior_invoke_plugin_alter($entity_type, 'schema', $vars);
if (array_key_exists('schema', $vars) && isset($vars['schema'])) {
$schema = array_merge($schema, $vars['schema']);
}
}
}
}
function entity_table($entities, $select = FALSE) {
module_load_include('inc', 'eck', 'eck.entity');
$crud_info = NULL;
$rows = array();
$header = array(
t('Name'),
array(
'data' => t('Operations'),
'colspan' => '1',
),
);
$info = NULL;
foreach ($entities as $entity) {
$info = array();
$entity_type = $entity
->entityType();
$bundle = $entity
->bundle();
$id = $entity->id;
if ($crud_info == NULL) {
$crud_info = get_bundle_crud_info($entity_type, $bundle);
}
$allowed_operations = '';
$destination = drupal_get_destination();
if (eck_access('update', 'entity', $entity)) {
$edit_path = str_replace('%', $id, $crud_info['edit']['path']);
$allowed_operations = l(t('edit'), $edit_path, array(
'query' => $destination,
));
}
if (eck_access('delete', 'entity', $entity)) {
$delete_path = str_replace('%', $id, $crud_info['delete']['path']);
$allowed_operations .= ($allowed_operations ? '<br />' : '') . l(t('delete'), $delete_path, array(
'query' => $destination,
));
}
$uri = entity_uri($entity_type, $entity);
if (eck_access("view", "entity", $entity)) {
$row = array(
l(entity_label($entity_type, $entity), $uri['path'], $uri['options']),
);
}
else {
$row = array(
entity_label($entity_type, $entity),
);
}
$row[] = array(
'data' => $allowed_operations,
);
$info['entity'] = $entity;
drupal_alter("entity_{$entity_type}_{$bundle}_tr", $row, $info);
$info['bundle'] = $bundle;
drupal_alter("entity_{$entity_type}_tr", $row, $info);
$info['entity_type'] = $entity_type;
drupal_alter("entity_tr", $row, $info);
$rows[$id] = $row;
}
if ($info) {
unset($info['entity']);
drupal_alter("entity_th", $header, $info);
unset($info['entity_type']);
drupal_alter("entity_{$entity_type}_th", $header, $info);
unset($info['bundle']);
drupal_alter("entity_{$entity_type}_{$bundle}_th", $header, $info);
}
if ($select) {
if (!isset($entity_type)) {
return array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
);
}
else {
return drupal_get_form("entity_table_select_{$entity_type}_{$bundle}", $entity_type, $bundle, $header, $rows);
}
}
else {
return array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
);
}
}
function eck_entity_info() {
module_load_include('inc', 'eck', 'eck.entity_type');
$info = array();
foreach (EntityType::loadAll() as $entity_type) {
$info = array_merge($info, eck__entity_type__info($entity_type));
}
return $info;
}
function eck_entity_info_alter(&$info) {
foreach (EntityType::loadAll() as $entity_type) {
$entity_type_info = $info[$entity_type->name];
$entity_type_info = eck_property_behavior_invoke_plugin_alter($entity_type, 'entity_info', $entity_type_info);
if ($entity_type_info) {
$info[$entity_type->name] = $entity_type_info;
}
}
}
function eck_field_extra_fields() {
$extra = array();
foreach (EntityType::loadAll() as $entity_type) {
foreach (Bundle::loadByEntityType($entity_type) as $bundle) {
foreach ($entity_type->properties as $property_name => $property_info) {
if (!empty($bundle->config['extra_fields'][$property_name]['form'])) {
$extra[$entity_type->name][$bundle->name]['form'][$property_name] = array(
'label' => $bundle->config['extra_fields'][$property_name]['form']['label'],
'description' => t('Entity property: %type', array(
'%type' => $property_info['type'],
)),
'weight' => 0,
);
}
if (!empty($bundle->config['extra_fields'][$property_name]['display'])) {
$extra[$entity_type->name][$bundle->name]['display'][$property_name] = array(
'label' => $bundle->config['extra_fields'][$property_name]['display']['label'],
'description' => t('Entity property: %type', array(
'%type' => $property_info['type'],
)),
'weight' => 0,
);
}
}
}
}
return $extra;
}
function entity_type_load($entity_type_name) {
return EntityType::loadByName($entity_type_name);
}
function bundle_load($entity_type_name, $bundle_name) {
return Bundle::loadByMachineName("{$entity_type_name}_{$bundle_name}");
}
function _eck_fake_exists() {
return FALSE;
}
function eck_entity_property_info() {
module_load_include('inc', 'entity', 'entity.info');
$info = array();
foreach (EntityType::loadAll() as $entity_type) {
$properties = $entity_type->properties;
$stuff = entity_metadata_convert_schema("eck_{$entity_type->name}");
foreach ($stuff as $key => $property) {
if (isset($properties[$key])) {
$property['label'] = $properties[$key]['label'];
}
$property['setter callback'] = "entity_property_verbatim_set";
$property['getter callback'] = 'entity_property_verbatim_get';
$property['description'] = $property['label'];
drupal_alter("entity_property_{$key}_info", $property);
drupal_alter("entity_property_{$entity_type->name}_{$key}_info", $property);
if ($key == 'type') {
$property['label'] = t('!entity_type type', array(
'!entity_type' => $entity_type->name,
));
$property['type'] = 'token';
$property['description'] = t('The type of this :entity_type entity.', array(
':entity_type' => $entity_type->name,
));
$property['options list'] = 'EntityDefaultMetadataController::bundleOptionsList';
$property['required'] = TRUE;
}
$stuff[$key] = $property;
}
$info[$entity_type->name]['properties'] = $stuff;
}
return $info;
}
function eck_entity_property_info_alter(&$info) {
foreach (EntityType::loadAll() as $entity_type) {
$entity_property_info = $info[$entity_type->name];
$entity_property_info = eck_property_behavior_invoke_plugin_alter($entity_type, 'property_info', $entity_property_info);
foreach ($entity_type->properties as $property => $stuff) {
foreach (array(
'setter',
'getter',
'validation',
) as $function_name) {
if (eck_property_behavior_implements($entity_type, $property, $function_name)) {
$entity_property_info['properties'][$property]["{$function_name} callback"] = "eck_property_behavior_{$function_name}";
}
}
}
if ($entity_property_info) {
$info[$entity_type->name] = $entity_property_info;
}
}
}
function eck_get_property_label($name) {
$info = hook_eck_property_info();
return $info[$name]['label'];
}
function eck_features_api() {
return array(
'eck_entity_type' => array(
'name' => t('Entity Types'),
'feature_source' => TRUE,
'file' => drupal_get_path('module', 'eck') . '/eck.features.inc',
'default_hook' => 'eck_entity_type_info',
),
'eck_bundle' => array(
'name' => t('Bundles'),
'feature_source' => TRUE,
'file' => drupal_get_path('module', 'eck') . '/eck.features.inc',
'default_hook' => 'eck_bundle_info',
),
);
}
function eck_menu() {
$menu = array();
module_load_include('inc', 'eck', 'eck.entity_type');
$menu = array_merge(eck__entity_type__menu(), $menu);
return $menu;
}
function eck__multiple_access_check($perms, $b_own = FALSE, $account = NULL) {
if (!isset($account)) {
$account = $GLOBALS['user'];
}
foreach ($perms as $perm) {
if (user_access($perm, $account)) {
return TRUE;
}
}
if (!$b_own) {
return FALSE;
}
foreach ($perms as $perm) {
if (user_access($perm . ' own', $account)) {
return TRUE;
}
}
return FALSE;
}
function eck_forms($form_id, $args) {
$forms = array();
if (strpos($form_id, 'entity_table_select_') === 0) {
$forms[$form_id] = array(
'callback' => 'entity_table_select',
);
}
elseif (strpos($form_id, 'eck__entity__form_') === 0) {
$forms[$form_id] = array(
'callback' => 'eck__entity__form',
);
}
return $forms;
}
function entity_table_select($form, &$state, $entity_type, $bundle, $header, $rows) {
$form['entity_type'] = array(
'#type' => 'value',
'#value' => $entity_type,
);
$form['bundle'] = array(
'#type' => 'value',
'#value' => $bundle,
);
$form['entity_table'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $rows,
);
return $form;
}
function eck_property_widget_type_options($property_type = NULL, $by_label = FALSE) {
$options =& drupal_static(__FUNCTION__);
if (!isset($options)) {
$options = array();
$property_types = eck_get_property_types();
foreach (eck_property_info_widget_types() as $name => $widget_type) {
foreach ($widget_type['property types'] as $widget_property_type) {
if (isset($property_types[$widget_property_type])) {
$options[$widget_property_type][$name] = $widget_type['label'];
}
}
}
}
if (isset($property_type)) {
return !empty($options[$property_type]) ? $options[$property_type] : array();
}
if ($by_label) {
$property_types = eck_get_property_types();
$options_by_label = array();
foreach ($options as $property_type => $widgets) {
$options_by_label[$property_types[$property_type]['label']] = $widgets;
}
return $options_by_label;
}
return $options;
}
function eck_property_info_widget_types($widget_type = NULL, $reset = FALSE) {
global $language;
static $widget_types;
$langcode = $language->language;
if ($reset) {
$widget_types = NULL;
cache_clear_all('property_widget_types:', 'cache_eck', TRUE);
}
if (!isset($widget_types)) {
if ($cached = cache_get("property_widget_types:{$langcode}", 'cache_eck')) {
$widget_types = $cached->data;
}
else {
$widget_types = array();
foreach (module_implements('eck_property_widget_info') as $module) {
$module_widget_types = (array) module_invoke($module, 'eck_property_widget_info');
foreach ($module_widget_types as $name => $widget_info) {
$widget_info += array(
'type' => $name,
'label' => t("@name", array(
'@name' => $name,
)),
'settings' => array(),
'property types' => array(),
'file' => FALSE,
'file type' => 'inc',
'description' => '',
'value callback' => '',
);
$widget_types[$name] = $widget_info;
$widget_types[$name]['module'] = $module;
}
}
drupal_alter('eck_property_widget_info', $widget_types);
uasort($widget_types, 'drupal_sort_weight');
cache_set("property_widget_types:{$langcode}", $widget_types, 'cache_eck');
}
}
if (isset($widget_type) && isset($widget_types[$widget_type])) {
return $widget_types[$widget_type];
}
return $widget_types;
}
function eck_eck_property_widget_info() {
$widget_types = array(
'text' => array(
'label' => t('Text'),
'settings' => array(
'size' => 60,
'max_length' => 255,
),
'property types' => array(
'text',
'integer',
'positive_integer',
'decimal',
'blob',
'datetime',
'uuid',
),
'file' => 'eck.property_widgets',
),
'options' => array(
'label' => t('Options'),
'settings' => array(
'options' => '',
),
'property types' => array(
'text',
'integer',
'positive_integer',
'decimal',
),
'file' => 'eck.property_widgets',
),
'language_toggle' => array(
'label' => t('Language toggle'),
'property types' => array(
'language',
),
'file' => 'eck.property_widgets',
),
);
return $widget_types;
}
function eck_form_field_ui_field_overview_form_alter(&$form, &$form_state) {
if (array_key_exists($form['#entity_type'], eck_entity_info())) {
$entity_type = entity_type_load($form['#entity_type']);
$bundle = bundle_load($form['#entity_type'], $form['#bundle']);
$admin_path = _field_ui_bundle_admin_path($bundle->entity_type, $bundle->name);
$max_weight = field_info_max_weight($form['#entity_type'], $form['#bundle'], 'form');
$widget_types = eck_property_info_widget_types();
$widget_type_options = eck_property_widget_type_options(NULL, TRUE);
$properties = array();
$extra_fields = !empty($bundle->config['extra_fields']) && is_array($bundle->config['extra_fields']) ? $bundle->config['extra_fields'] : array();
foreach ($entity_type->properties as $property => $info) {
if (empty($extra_fields[$property]['form'])) {
$properties[$property] = $info;
}
else {
$admin_property_path = $admin_path . '/properties/' . $property;
unset($form['fields'][$property]['type']['#cell_attributes']);
unset($form['fields'][$property]['edit']);
unset($form['fields'][$property]['delete']);
$key = $extra_fields[$property]['form']['widget']['type'];
$table_elements = array(
'widget_type' => array(
'#type' => 'link',
'#title' => t("@widget_label", array(
"@widget_label" => $widget_types[$key]['label'],
)),
'#href' => $admin_property_path . '/widget-type',
'#options' => array(
'attributes' => array(
'title' => t('Change widget type.'),
),
),
),
'edit' => array(
'#type' => 'link',
'#title' => t('edit'),
'#href' => $admin_property_path,
'#options' => array(
'attributes' => array(
'title' => t('Edit property management settings.'),
),
),
),
'delete' => array(
'#type' => 'link',
'#title' => t('remove'),
'#href' => $admin_property_path . '/remove',
'#options' => array(
'attributes' => array(
'title' => t('Remove management of this property.'),
),
),
),
);
$form['fields'][$property] += $table_elements;
}
}
if ($properties && $widget_type_options) {
$properties_options = array();
foreach ($properties as $property => $info) {
$text = t('@type: @label (@property)', array(
'@type' => $info['type'],
'@label' => $info['label'],
'@property' => $property,
));
$properties_options[$property] = truncate_utf8($text, 80, FALSE, TRUE);
}
asort($properties_options);
$name = '_eck_add_extra_field';
$form['fields'][$name] = array(
'#attributes' => array(
'class' => array(
'draggable',
'tabledrag-leaf',
'add-new',
),
),
'#row_type' => 'add_new_field',
'#region_callback' => 'field_ui_field_overview_row_region',
'label' => array(
'#type' => 'textfield',
'#title' => t('Extra field label'),
'#title_display' => 'invisible',
'#size' => 15,
'#description' => t('Label'),
'#attributes' => array(
'class' => array(
'label-textfield',
),
),
'#prefix' => '<div class="label-input"><div class="add-new-placeholder">' . t('Manage a property') . '</div>',
'#suffix' => '</div>',
),
'weight' => array(
'#type' => 'textfield',
'#default_value' => $max_weight + 3,
'#size' => 3,
'#title_display' => 'invisible',
'#title' => t('Weight for added field'),
'#attributes' => array(
'class' => array(
'field-weight',
),
),
'#prefix' => '<div class="add-new-placeholder"> </div>',
),
'parent_wrapper' => array(
'parent' => array(
'#type' => 'select',
'#title' => t('Parent for extra field'),
'#title_display' => 'invisible',
'#options' => $form['fields']['#parent_options'],
'#empty_value' => '',
'#attributes' => array(
'class' => array(
'field-parent',
),
),
'#prefix' => '<div class="add-new-placeholder"> </div>',
'#parents' => array(
'fields',
$name,
'parent',
),
),
'hidden_name' => array(
'#type' => 'hidden',
'#default_value' => $name,
'#attributes' => array(
'class' => array(
'field-name',
),
),
),
),
'field_name' => array(
'#type' => 'select',
'#title' => t('Extra field'),
'#title_display' => 'invisible',
'#options' => $properties_options,
'#empty_option' => t('- Select a property -'),
'#description' => t('Existing entity property to manage.'),
'#attributes' => array(
'class' => array(
'eck-property-type-select',
),
),
'#cell_attributes' => array(
'colspan' => 2,
),
'#prefix' => '<div class="add-new-placeholder"> </div>',
),
'widget_type' => array(
'#type' => 'select',
'#title' => t('Widget for managed property'),
'#title_display' => 'invisible',
'#options' => $widget_type_options,
'#empty_option' => t('- Select a widget -'),
'#description' => t('Form element to edit the property data.'),
'#attributes' => array(
'class' => array(
'eck-widget-type-select',
),
),
'#cell_attributes' => array(
'colspan' => 3,
),
'#prefix' => '<div class="add-new-placeholder"> </div>',
),
);
$form['#validate'][] = 'eck_form_field_ui_field_overview_form_validate';
$form['#submit'][] = 'eck_form_field_ui_field_overview_form_submit';
$form['#attached']['js'][] = drupal_get_path('module', 'eck') . '/eck.field_ui.js';
$js_properties = array();
foreach ($properties as $property => $info) {
$js_properties[$property] = array(
'label' => $info['label'],
'type' => $info['type'],
);
}
$form['#attached']['js'][] = array(
'type' => 'setting',
'data' => array(
'eckProperties' => $js_properties,
'eckPropertyWidgetTypes' => eck_property_widget_type_options(),
),
);
}
}
}
function eck_form_field_ui_field_overview_form_validate($form, &$form_state) {
if (isset($form_state['values']['fields']['_eck_add_extra_field'])) {
$extra_field = $form_state['values']['fields']['_eck_add_extra_field'];
$array = array(
$extra_field['label'],
$extra_field['field_name'],
$extra_field['widget_type'],
);
if (array_filter($array)) {
if (!$extra_field['label']) {
form_set_error('fields][_eck_add_extra_field][label', t('Add property as extra field: you need to provide a label.'));
}
if (!$extra_field['field_name']) {
form_set_error('fields][_eck_add_extra_field][field_name', t('Add property as extra field: you need to select a field.'));
}
$entity_type = entity_type_load($form['#entity_type']);
if (!isset($entity_type->properties[$extra_field['field_name']])) {
form_set_error('fields][_eck_add_extra_field][field_name', t('Add property as extra field: invalid property for this bundle.'));
}
if (!$extra_field['widget_type']) {
form_set_error('fields][_eck_add_extra_field][widget_type', t('Add property as extra field: you need to select a widget.'));
}
elseif ($extra_field['field_name'] && ($existing_field = field_info_field($extra_field['field_name']))) {
$entity_type = entity_type_load($form['#entity_type']);
$widget_types = eck_property_widget_type_options($entity_type->properties[$extra_field['field_name']]['type']);
if (!isset($widget_types[$extra_field['widget_type']])) {
form_set_error('fields][_eck_add_extra_field][widget_type', t('Add property as extra field: invalid widget.'));
}
}
}
}
}
function eck_form_field_ui_field_overview_form_submit($form, &$form_state) {
if (isset($form_state['values']['fields']['_eck_add_extra_field'])) {
$extra_field_settings = $form_state['values']['fields']['_eck_add_extra_field'];
$array = array(
$extra_field_settings['label'],
$extra_field_settings['field_name'],
$extra_field_settings['widget_type'],
);
if (array_filter($array)) {
$entity_type = entity_type_load($form['#entity_type']);
$bundle = bundle_load($form['#entity_type'], $form['#bundle']);
$property_name = $extra_field_settings['field_name'];
$config = !empty($bundle->config) ? $bundle->config : array();
$widget_info = eck_property_info_widget_types($extra_field_settings['widget_type']);
$extra_field = array(
'label' => $extra_field_settings['label'],
'description' => $widget_info['description'],
'widget' => array(
'type' => $extra_field_settings['widget_type'],
'settings' => $widget_info['settings'],
),
);
if ($default_function = eck_property_behavior_implements($entity_type, $property_name, 'default_value')) {
$extra_field['default_value_function'] = $default_function;
}
$schema = eck_get_property_type_schema($entity_type->properties[$property_name]['type']);
$extra_field['default_value'] = $schema['default'];
$config['extra_fields'][$property_name]['form'] = $extra_field;
$bundle->config = $config;
$bundle
->save();
Bundle::loadAll(NULL, TRUE);
}
}
}
function eck_entity_presave($entity, $entity_type) {
$entity_type = EntityType::loadByName($entity_type);
if ($entity_type) {
eck_property_behavior_invoke_plugin($entity_type, 'entity_save', array(
'entity' => $entity,
));
}
}
function eck_entity_delete($entity, $entity_type) {
$entity_type = EntityType::loadByName($entity_type);
if ($entity_type) {
eck_property_behavior_invoke_plugin($entity_type, 'entity_delete', array(
'entity' => $entity,
));
}
}
function eck_entity_view_alter(&$build) {
$entity_types = EntityType::loadAll();
$this_entity_type = $build['#entity_type'];
foreach ($entity_types as $et) {
if ($et->name == $this_entity_type) {
$entity = $build['#entity'];
$this_bundle = $entity
->bundle();
$build['#contextual_links']['eck'] = array(
"{$this_entity_type}/{$this_bundle}",
array(
$entity->id,
),
);
}
}
}
function eck_alphabetical_cmp($a, $b) {
return strcasecmp($a->name, $b->name);
}
function eck_eck_property_types() {
$property_types = array();
$property_types['decimal'] = array(
'label' => t("Decimal"),
'class' => "DecimalPropertyType",
);
$property_types['integer'] = array(
'label' => t("Integer"),
'class' => "IntegerPropertyType",
);
$property_types['text'] = array(
'label' => t("Text"),
'class' => "TextPropertyType",
);
$property_types['fixed_size_text'] = array(
'label' => t("Fixed Size Text"),
'class' => "FixedSizeTextPropertyType",
);
$property_types['long_text'] = array(
'label' => t("Long Text"),
'class' => "LongTextPropertyType",
);
$property_types['blob'] = array(
'label' => t("Blob"),
'class' => "BlobPropertyType",
);
$property_types['datetime'] = array(
'label' => t("Date/Time"),
'class' => "DatetimePropertyType",
);
$property_types['language'] = array(
'label' => t("Language"),
'class' => "LanguagePropertyType",
);
$property_types['uuid'] = array(
'label' => t("UUID"),
'class' => "UUIDPropertyType",
);
$property_types['positive_integer'] = array(
'label' => t("Positive Integer"),
'class' => "PositiveIntegerPropertyType",
);
return $property_types;
}
function eck_init() {
global $_eck_entity_types_cache;
global $_eck_bundles_cache;
$_eck_entity_types_cache = new ECKCache("entity_types");
$_eck_bundles_cache = new ECKCache("bundles");
if (variable_get("eck_clear_caches", FALSE)) {
variable_set("eck_clear_caches", FALSE);
eck_clean_up();
}
}
function eck_clean_up() {
drupal_get_schema(NULL, TRUE);
entity_info_cache_clear();
entity_flush_caches();
menu_rebuild();
}
function eck_system_info_alter(&$info, $file, $type) {
if ($type == "module" && array_key_exists("name", $info) && $info['name'] == "Entity Construction Kit") {
$done = FALSE;
$entity_types = EntityType::loadAll();
if (!empty($entity_types)) {
$info['required'] = TRUE;
$info['explanation'] = "Entity types created by ECK are still present in the system.";
$done = TRUE;
}
if (!$done) {
$query = db_select("system", "s");
$query
->fields('s', array(
'schema_version',
));
$query
->condition('s.name', 'eck_entitycache', '=');
$query
->condition('s.type', 'module', '=');
$result = $query
->execute();
foreach ($result as $row) {
$schema_version = $row->schema_version;
if ($schema_version == 0) {
$info['required'] = TRUE;
$info['explanation'] = "ECK EntityCache must be uninstalled before you can disable/uninstall ECK";
}
}
}
}
}