diff --git a/fieldable_panels_panes.info.inc b/fieldable_panels_panes.info.inc
index b9d080b..0a5efbb 100644
--- a/fieldable_panels_panes.info.inc
+++ b/fieldable_panels_panes.info.inc
@@ -79,18 +79,6 @@ function fieldable_panels_panes_entity_property_info() {
'description' => t('Whether or not this entity title will link to another page.'),
'type' => 'boolean',
) + $default_properties;
- $properties['path'] = array(
- 'label' => t('Path'),
- 'description' => t('The path the title should link to, uses alias if one available.'),
- 'getter callback' => 'fieldable_panels_panes_metadata_fpp_get_properties',
- 'type' => 'uri',
- ) + $default_properties;
- $properties['path_raw'] = array(
- 'label' => t('Path raw'),
- 'description' => t('The path the title should link to, excluding the alias.'),
- 'schema field' => 'path',
- 'type' => 'uri',
- ) + $default_properties;
$properties['reusable'] = array(
'label' => t('Reusable?'),
'description' => t('Whether or not this entity will appear in the Add Content dialog.'),
diff --git a/fieldable_panels_panes.install b/fieldable_panels_panes.install
index 9bfc67d..db47c6a 100644
--- a/fieldable_panels_panes.install
+++ b/fieldable_panels_panes.install
@@ -17,8 +17,25 @@ function fieldable_panels_panes_install() {
$item->title = t('Panels Pane');
ctools_export_crud_save('fieldable_panels_pane_type', $item);
}
+
+ // Create the path field instance.
+ _fieldable_panels_panes_create_field_path();
}
+/**
+ * Loops over the instances and add the path field instance.
+ */
+function _fieldable_panels_panes_create_field_path() {
+ if (!function_exists('fieldable_panels_panes_add_path_instance')) {
+ // We make sure that the function is loaded.
+ module_load_include('module', 'fieldable_panels_panes');
+ }
+ // Create the instances.
+ $entity_info = entity_get_info('fieldable_panels_pane');
+ foreach ($entity_info['bundles'] as $bundle => $info) {
+ fieldable_panels_panes_add_path_instance($bundle);
+ }
+}
/**
* Implements hook_uninstall().
@@ -41,187 +58,182 @@ function fieldable_panels_panes_schema() {
$schema['fieldable_panels_panes'] = array(
'description' => 'Entity table for panel pane content with fields.',
- 'fields' => array(
- 'fpid' => array(
+ 'fields' => array(
+ 'fpid' => array(
'description' => 'The primary identifier for the entity.',
- 'type' => 'serial',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
),
- 'vid' => array(
+ 'vid' => array(
'description' => 'The current version in use for this entity.',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0,
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
),
- 'bundle' => array(
+ 'bundle' => array(
'description' => 'The bundle of the entity.',
- 'type' => 'varchar',
- 'length' => 255,
+ 'type' => 'varchar',
+ 'length' => 255,
),
- 'title' => array(
+ 'title' => array(
'description' => 'The title of the entity.',
- 'type' => 'varchar',
- 'length' => 255,
+ 'type' => 'varchar',
+ 'length' => 255,
),
- 'link' => array(
+ 'link' => array(
'description' => 'Whether or not this entity title will link to another page.',
- 'type' => 'int',
- 'size' => 'tiny',
- ),
- 'path' => array(
- 'description' => 'The path the title should link to.',
- 'type' => 'varchar',
- 'length' => 255,
+ 'type' => 'int',
+ 'size' => 'tiny',
),
- 'reusable' => array(
+ 'reusable' => array(
'description' => 'Whether or not this entity will appear in the Add Content dialog.',
- 'type' => 'int',
- 'size' => 'tiny',
+ 'type' => 'int',
+ 'size' => 'tiny',
),
- 'admin_title' => array(
+ 'admin_title' => array(
'description' => 'The title as it will appear in the Add Content dialog.',
- 'type' => 'varchar',
- 'length' => 255,
+ 'type' => 'varchar',
+ 'length' => 255,
),
'admin_description' => array(
'description' => 'The description it will appear in the Add Content dialog with.',
- 'type' => 'text',
+ 'type' => 'text',
),
- 'category' => array(
+ 'category' => array(
'description' => 'The category under which it will appear in the Add Content dialog.',
- 'type' => 'text',
+ 'type' => 'text',
),
- 'view_access' => array(
- 'type' => 'text',
- 'size' => 'big',
- 'description' => 'Access rules to describe if the user has view access to this entity.',
- 'serialize' => TRUE,
+ 'view_access' => array(
+ 'type' => 'text',
+ 'size' => 'big',
+ 'description' => 'Access rules to describe if the user has view access to this entity.',
+ 'serialize' => TRUE,
'object default' => array(),
),
- 'edit_access' => array(
- 'type' => 'text',
- 'size' => 'big',
- 'description' => 'Access rules to describe if the user has view access to this entity.',
- 'serialize' => TRUE,
+ 'edit_access' => array(
+ 'type' => 'text',
+ 'size' => 'big',
+ 'description' => 'Access rules to describe if the user has view access to this entity.',
+ 'serialize' => TRUE,
'object default' => array(),
),
- 'created' => array(
+ 'created' => array(
'description' => 'The Unix timestamp when the entity was created.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
),
- 'changed' => array(
+ 'changed' => array(
'description' => 'The Unix timestamp when the entity was most recently saved.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'uuid' => array(
- 'type' => 'char',
- 'length' => 36,
- 'default' => '',
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'uuid' => array(
+ 'type' => 'char',
+ 'length' => 36,
+ 'default' => '',
'description' => 'The Universally Unique Identifier.',
),
- 'language' => array(
+ 'language' => array(
'description' => 'The {languages}.language of this entity.',
- 'type' => 'varchar',
- 'length' => 12,
- 'not null' => TRUE,
- 'default' => '',
+ 'type' => 'varchar',
+ 'length' => 12,
+ 'not null' => TRUE,
+ 'default' => '',
),
),
'primary key' => array('fpid'),
- 'indexes' => array(
+ 'indexes' => array(
'reusable' => array('reusable'),
),
);
$schema['fieldable_panels_panes_revision'] = array(
'description' => 'Entity revision table for panel pane content with fields.',
- 'fields' => array(
- 'fpid' => array(
+ 'fields' => array(
+ 'fpid' => array(
'description' => 'The id this revision belongs to',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0,
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
),
- 'vid' => array(
+ 'vid' => array(
'description' => 'The primary identifier for this version.',
- 'type' => 'serial',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
),
'timestamp' => array(
'description' => 'The Unix timestamp when the revision was most recently saved.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
),
- 'uid' => array(
+ 'uid' => array(
'description' => 'The author of the revision.',
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0,
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
),
- 'title' => array(
+ 'title' => array(
'description' => 'The title of the entity.',
- 'type' => 'varchar',
- 'length' => 255,
+ 'type' => 'varchar',
+ 'length' => 255,
),
- 'log' => array(
+ 'log' => array(
'description' => t('A log message associated with the revision.'),
- 'type' => 'text',
- 'size' => 'big',
+ 'type' => 'text',
+ 'size' => 'big',
),
- 'vuuid' => array(
- 'type' => 'char',
- 'length' => 36,
- 'default' => '',
+ 'vuuid' => array(
+ 'type' => 'char',
+ 'length' => 36,
+ 'default' => '',
'description' => 'The Universally Unique Identifier.',
),
),
'primary key' => array('vid'),
- 'indexes' => array(
+ 'indexes' => array(
'fpid' => array('fpid', 'vid'),
),
);
$schema['fieldable_panels_pane_type'] = array(
'description' => 'Entity bundle table for panel pane content.',
- 'fields' => array(
- 'name' => array(
+ 'fields' => array(
+ 'name' => array(
'description' => 'The machine-readable name of this type.',
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- ),
- 'title' => array(
- 'description' => 'The human-readable name of this type.',
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'title' => array(
+ 'description' => 'The human-readable name of this type.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
'translatable' => TRUE,
),
'description' => array(
'description' => 'A brief description of this type.',
- 'type' => 'text',
- 'size' => 'big',
- 'not null' => TRUE,
+ 'type' => 'text',
+ 'size' => 'big',
+ 'not null' => TRUE,
),
),
- 'export' => array(
- 'admin_title' => 'title',
+ 'export' => array(
+ 'admin_title' => 'title',
'admin_description' => 'description',
- 'api' => array(
- 'owner' => 'fieldable_panels_panes',
- 'api' => 'fieldable_panels_pane_type',
+ 'api' => array(
+ 'owner' => 'fieldable_panels_panes',
+ 'api' => 'fieldable_panels_pane_type',
'minimum_version' => 1,
'current_version' => 1,
),
@@ -229,9 +241,9 @@ function fieldable_panels_panes_schema() {
'primary key' => array('name'),
);
-
// Optional cache table for entitycache support.
- $schema['cache_entity_fieldable_panels_pane'] = drupal_get_schema_unprocessed('system', 'cache');
+ $schema['cache_entity_fieldable_panels_pane'] = drupal_get_schema_unprocessed('system',
+ 'cache');
$schema['cache_entity_fieldable_panels_pane']['description'] = 'Cache table used to store fieldable_panels_pane entity records.';
return $schema;
@@ -244,12 +256,22 @@ function fieldable_panels_panes_update_7101(&$sandbox) {
// Make sure to add UUID field
if (!db_field_exists('fieldable_panels_panes', 'uuid')) {
- db_add_field('fieldable_panels_panes', 'uuid', array('type' => 'char', 'length' => 36, 'default' => '', 'description' => 'The Universally Unique Identifier.'));
+ db_add_field('fieldable_panels_panes', 'uuid', array(
+ 'type' => 'char',
+ 'length' => 36,
+ 'default' => '',
+ 'description' => 'The Universally Unique Identifier.'
+ ));
}
// Make sure to add VUUID field
if (!db_field_exists('fieldable_panels_panes_revision', 'vuuid')) {
- db_add_field('fieldable_panels_panes_revision', 'vuuid', array('type' => 'char', 'length' => 36, 'default' => '', 'description' => 'The Universally Unique Identifier.'));
+ db_add_field('fieldable_panels_panes_revision', 'vuuid', array(
+ 'type' => 'char',
+ 'length' => 36,
+ 'default' => '',
+ 'description' => 'The Universally Unique Identifier.'
+ ));
}
}
@@ -273,7 +295,7 @@ function fieldable_panels_panes_update_7103(&$sandbox) {
return t('Theme registry cache has been cleared.');
}
-/*
+/**
* Update menu paths.
*/
function fieldable_panels_panes_update_7104(&$sandbox) {
@@ -286,8 +308,16 @@ function fieldable_panels_panes_update_7104(&$sandbox) {
* Add support to link pane titles to paths.
*/
function fieldable_panels_panes_update_7105() {
- db_add_field('fieldable_panels_panes', 'link', array('type' => 'int', 'size' => 'tiny', 'description' => 'Whether or not this entity title will link to another page.'));
- db_add_field('fieldable_panels_panes', 'path', array('type' => 'varchar', 'length' => 255, 'description' => 'The path the title should link to.'));
+ db_add_field('fieldable_panels_panes', 'link', array(
+ 'type' => 'int',
+ 'size' => 'tiny',
+ 'description' => 'Whether or not this entity title will link to another page.'
+ ));
+ db_add_field('fieldable_panels_panes', 'path', array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'description' => 'The path the title should link to.'
+ ));
}
/**
@@ -298,10 +328,10 @@ function fieldable_panels_panes_update_7106() {
if (!db_field_exists('fieldable_panels_panes', 'language')) {
db_add_field('fieldable_panels_panes', 'language', array(
'description' => 'The {languages}.language of this entity.',
- 'type' => 'varchar',
- 'length' => 12,
- 'not null' => TRUE,
- 'default' => '',
+ 'type' => 'varchar',
+ 'length' => 12,
+ 'not null' => TRUE,
+ 'default' => '',
));
}
}
@@ -329,35 +359,35 @@ function fieldable_panels_panes_update_7108() {
// be directly used during hook_update_N.
$schema['fieldable_panels_pane_type'] = array(
'description' => 'Entity bundle table for panel pane content.',
- 'fields' => array(
- 'name' => array(
+ 'fields' => array(
+ 'name' => array(
'description' => 'The machine-readable name of this type.',
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- ),
- 'title' => array(
- 'description' => 'The human-readable name of this type.',
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'title' => array(
+ 'description' => 'The human-readable name of this type.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
'translatable' => TRUE,
),
'description' => array(
'description' => 'A brief description of this type.',
- 'type' => 'text',
- 'size' => 'big',
- 'not null' => TRUE,
+ 'type' => 'text',
+ 'size' => 'big',
+ 'not null' => TRUE,
),
),
- 'export' => array(
- 'admin_title' => 'title',
+ 'export' => array(
+ 'admin_title' => 'title',
'admin_description' => 'description',
- 'api' => array(
- 'owner' => 'fieldable_panels_panes',
- 'api' => 'fieldable_panels_pane_type',
+ 'api' => array(
+ 'owner' => 'fieldable_panels_panes',
+ 'api' => 'fieldable_panels_pane_type',
'minimum_version' => 1,
'current_version' => 1,
),
@@ -365,14 +395,14 @@ function fieldable_panels_panes_update_7108() {
'primary key' => array('name'),
);
-
// Add the new table for storing bundles.
- db_create_table('fieldable_panels_pane_type', $schema['fieldable_panels_pane_type']);
+ db_create_table('fieldable_panels_pane_type',
+ $schema['fieldable_panels_pane_type']);
// Store possible existing bundles provided by other modules.
$bundles = array();
$entity_info = entity_get_info('fieldable_panels_pane');
-
+
// No bundles defined. This could happen if the module was updated and cache
// cleared before update was run as entity info's cache will no longer
// contain the old default.
@@ -380,11 +410,11 @@ function fieldable_panels_panes_update_7108() {
if (empty($entity_info['bundles'])) {
$entity_info['bundles'] = array(
'fieldable_panels_pane' => array(
- 'label' => $t('Panels pane'),
+ 'label' => $t('Panels pane'),
),
);
}
-
+
foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
$bundles[] = $bundle_info['label'];
@@ -395,7 +425,10 @@ function fieldable_panels_panes_update_7108() {
}
if (!empty($bundles)) {
- $messages[] = format_plural(count($bundles), 'Added existing bundle %bundle_names to database.', 'Added existing bundles %bundle_names to database.', array('%bundle_names' => implode(', ', $bundles)));
+ $messages[] = format_plural(count($bundles),
+ 'Added existing bundle %bundle_names to database.',
+ 'Added existing bundles %bundle_names to database.',
+ array('%bundle_names' => implode(', ', $bundles)));
}
return implode('
', $messages);
@@ -407,9 +440,65 @@ function fieldable_panels_panes_update_7108() {
function fieldable_panels_panes_update_7109() {
db_change_field('fieldable_panels_pane_type', 'name', 'name', array(
'description' => 'The machine-readable name of this type.',
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
));
}
+
+/**
+ * Create the path FAPI field.
+ */
+function fieldable_panels_panes_update_7110() {
+ _fieldable_panels_panes_create_field_path();
+}
+
+/**
+ * Migrate the path to a FAPI field.
+ */
+function fieldable_panels_panes_update_7111(&$sandbox) {
+ if (!isset($sandbox['progress'])) {
+ $sandbox['progress'] = 0;
+ $sandbox['current_id'] = 0;
+ $sandbox['max'] = db_query('SELECT COUNT(DISTINCT fpid) FROM {fieldable_panels_panes}')->fetchField() -
+ 1;
+ }
+ // Migrate all path data into the field.
+ $query = db_select('fieldable_panels_panes', 'f');
+
+ $query->condition('f.fpid', $sandbox['current_id'], '>')
+ ->condition('f.path', '', '<>')
+ ->fields('f', array('fpid', 'path'))
+ ->orderBy('f.fpid', 'ASC')
+ ->range(0, 50);
+
+ $results = $query->execute();
+
+ if ($results->rowCount() > 0) {
+ foreach ($results as $result) {
+ $entity = fieldable_panels_panes_load($result->fpid);
+ // The default is to enable this field but NOT to make it translatable
+ // as not every one will use that. So we can only set the default value
+ // of LANGUAGE_NONE (und).
+ if (isset($entity->bundle)) {
+ $entity->fieldable_panels_panes_path[LANGUAGE_NONE][0]['value'] = $result->path;
+ fieldable_panels_panes_save($entity);
+ }
+ $sandbox['current_id'] = $entity->fpid;
+ $sandbox['progress']++;
+ }
+ $sandbox['#finished'] = empty($sandbox['max']) ? TRUE :
+ ($sandbox['progress'] / $sandbox['max']);
+ }
+ else {
+ $sandbox['#finished'] = TRUE;
+ }
+}
+
+/**
+ * Remove the path property from the entity.
+ */
+function fieldable_panels_panes_update_7112() {
+ db_drop_field('fieldable_panels_panes', 'path');
+}
diff --git a/fieldable_panels_panes.module b/fieldable_panels_panes.module
index e96881a..e1c0578 100644
--- a/fieldable_panels_panes.module
+++ b/fieldable_panels_panes.module
@@ -757,11 +757,17 @@ function template_preprocess_fieldable_panels_pane(&$vars) {
* Add a class for our bundle to the normal panels pane theme.
*/
function fieldable_panels_panes_preprocess_panels_pane(&$vars) {
+ global $language;
if ($vars['pane']->type == 'fieldable_panels_pane') {
if (!empty($vars['content']['#fieldable_panels_pane']) && is_object($vars['content']['#fieldable_panels_pane'])) {
$entity = $vars['content']['#fieldable_panels_pane'];
+ $items = field_get_items('fieldable_panels_pane', $entity, 'fieldable_panels_panes_path', $language->language);
if (!empty($entity->link) && !empty($vars['title'])) {
- $vars['title'] = l($vars['title'], $entity->path);
+ $vars['title'] = l($vars['title'], $items[0]['value']);
+ }
+ if ($entity->link && !empty($vars['content']['title_field'])) {
+ $vars['content']['title_field'][0]['#markup'] = l($vars['content']['title_field'][0]['#markup'],
+ $items[0]['value'], array('html' => TRUE));
}
ctools_include('cleanstring');
$vars['classes_array'][] = 'pane-bundle-' . ctools_cleanstring($entity->bundle, array('lower case' => TRUE));
@@ -1002,18 +1008,6 @@ function fieldable_panels_panes_entity_edit_form($form, &$form_state) {
'#description' => t('Check here to make the title link to another page.'),
);
- $form['link']['path'] = array(
- '#type' => 'textfield',
- '#title' => t('Path'),
- '#description' => t('The path for this link. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page.', array('%front' => '', '%add-node' => 'node/add', '%drupal' => 'http://drupal.org')),
- '#states' => array(
- 'visible' => array(
- ':input[name="link"]' => array('checked' => TRUE),
- ),
- ),
- '#default_value' => $entity->path,
- );
-
$form['additional_settings'] = array(
'#type' => 'vertical_tabs',
'#weight' => 99,
@@ -1129,6 +1123,14 @@ function fieldable_panels_panes_entity_edit_form($form, &$form_state) {
}
field_attach_form('fieldable_panels_pane', $entity, $form, $form_state, $language);
+ // Shift the fieldable_panels_panes_path into the link fold and make it
+ // dependent on link.
+ $form['fieldable_panels_panes_path']['#states'] = array(
+ 'visible' => array(
+ ':input#edit-link' => array('checked' => TRUE),
+ ),
+ );
+
if (!empty($form_state['add submit'])) {
$form['actions'] = array(
'#type' => 'actions',
@@ -1147,7 +1149,37 @@ function fieldable_panels_panes_entity_edit_form($form, &$form_state) {
* Validate callback for the pane entity.
*/
function fieldable_panels_panes_entity_edit_form_validate($form, &$form_state) {
- field_attach_form_validate('fieldable_panels_pane', $form_state['entity'], $form, $form_state);
+ $entity = $form_state['entity'];
+
+ field_attach_form_validate('fieldable_panels_pane', $entity, $form,
+ $form_state);
+ if ($form_state['values']['link']) {
+ $language = NULL;
+ if (function_exists('entity_language')) {
+ // entity_language() was added in Drupal 7.15.
+ $language = entity_language('fieldable_panels_pane', $entity);
+ }
+
+ if (isset($form_state['values']['fieldable_panels_panes_path'][$language][0]['value']) &&
+ !empty($form_state['values']['fieldable_panels_panes_path'][$language][0]['value'])
+ ) {
+ $raw_path = $form_state['values']['fieldable_panels_panes_path'][$language][0]['value'];
+ // Check that the link exists
+ $source = valid_url($raw_path, TRUE);
+ if (!$source) {
+ $normal_path = drupal_get_normal_path($raw_path);
+ $source = drupal_valid_path($normal_path);
+ }
+ if (!$source) {
+ form_set_error('fieldable_panels_panes_path',
+ t('The path or url does not exist.'));
+ }
+ }
+ else {
+ form_set_error('fieldable_panels_panes_path',
+ t('You have selected that the title links to a path. Please enter a valid path or url, or unselect "Make title a link".'));
+ }
+ }
}
/**
@@ -1159,7 +1191,6 @@ function fieldable_panels_panes_entity_edit_form_submit($form, &$form_state) {
// Copy hardcoded fields.
$entity->title = $form_state['values']['title'];
$entity->link = $form_state['values']['link'];
- $entity->path = $form_state['values']['path'];
$entity->language = $form_state['values']['language'];
$entity->reusable = $form_state['values']['reusable'];
$entity->category = $form_state['values']['category'];
@@ -1257,3 +1288,56 @@ function fieldable_panels_panes_entity_uri_callback($entity) {
'options' => array(),
);
}
+
+/**
+ * Adds a fieldable_panels_panes_path field to a fieldable_panels_panes type.
+ *
+ * @param string $bundle
+ * A fieldable_panels_panes bundle name.
+ *
+ * @return array
+ */
+function fieldable_panels_panes_add_path_instance($bundle) {
+ // Add or remove the path field, as needed.
+ $field = field_info_field('fieldable_panels_panes_path');
+ if (empty($field)) {
+ $field = array(
+ 'field_name' => 'fieldable_panels_panes_path',
+ 'cadinality' => 1,
+ 'type' => 'text',
+ 'locked' => TRUE,
+ );
+ $field = field_create_field($field);
+ }
+
+ $instance = field_info_instance('fieldable_panels_pane',
+ 'fieldable_panels_panes_path', $bundle);
+ if (empty($instance)) {
+ // During installation, the t() function is unavailable, so we use get_t()
+ // to store the name of the translation function.
+ $t = get_t();
+
+ $instance = array(
+ 'field_name' => 'fieldable_panels_panes_path',
+ 'entity_type' => 'fieldable_panels_pane',
+ 'bundle' => $bundle,
+ 'label' => $t('Path'),
+ 'description' => $t('The path the title should link to.'),
+ 'required' => FALSE,
+ 'widget' => array(
+ 'type' => 'fieldable_panels_panes_path',
+ ),
+ 'display' => array(
+ 'default' => array(
+ 'label' => 'hidden',
+ 'type' => 'hidden',
+ ),
+ ),
+ 'settings' => array(
+ 'text_processing' => 0,
+ ),
+ );
+ $instance = field_create_instance($instance);
+ }
+ return $instance;
+}
diff --git a/includes/PanelsPaneController.class.php b/includes/PanelsPaneController.class.php
index 6f3b5ad..7dd566c 100644
--- a/includes/PanelsPaneController.class.php
+++ b/includes/PanelsPaneController.class.php
@@ -335,7 +335,6 @@ class PanelsPaneController extends DrupalDefaultEntityController {
'bundle' => 'fieldable_panels_pane',
'title' => '',
'link' => '',
- 'path' => '',
'reusable' => FALSE,
'admin_title' => '',
'admin_description' => '',
diff --git a/includes/fieldable_panels_pane.migrate.inc b/includes/fieldable_panels_pane.migrate.inc
index a7c9682..4787b49 100644
--- a/includes/fieldable_panels_pane.migrate.inc
+++ b/includes/fieldable_panels_pane.migrate.inc
@@ -68,7 +68,6 @@ class MigrateDestinationFieldablePanelsPanes extends MigrateDestinationEntity {
$fields['bundle'] = t('The bundle of the entity.');
$fields['title'] = t('The title of the entity.');
$fields['link'] = t('Whether or not this entity title will link to another page.');
- $fields['path'] = t('The path the title should link to.');
$fields['reusable'] = t('Whether or not this entity will appear in the Add Content dialog.');
$fields['admin_title'] = t('The title it will appear in the Add Content dialog as.');
$fields['admin_description'] = t('The description it will appear in the Add Content dialog with.');
diff --git a/plugins/export_ui/fieldable_panels_pane.class.php b/plugins/export_ui/fieldable_panels_pane.class.php
index 39ddad5..78020a4 100644
--- a/plugins/export_ui/fieldable_panels_pane.class.php
+++ b/plugins/export_ui/fieldable_panels_pane.class.php
@@ -74,6 +74,10 @@ class fieldable_panels_pane extends ctools_export_ui {
function edit_save_form($form_state) {
parent::edit_save_form($form_state);
+ $item = &$form_state['item'];
+
+ fieldable_panels_panes_add_path_instance($item->{'name'});
+
entity_info_cache_clear();
menu_rebuild();