Commit 0b9530af authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

[gh-437] Upgrade fieldable_panels_panes to 7.x-1.4

parent ed50378a
......@@ -12,7 +12,7 @@ function MYMODULE_entity_info_alter(&$entity_info) {
'pane icon' => '/path/to/custom/icon/for/this/pane.png',
'admin' => array(
'path' => 'admin/structure/fieldable-panels-panes/manage/%fieldable_panels_panes_type',
'bundle argument' => 5,
'bundle argument' => 4,
// Note that this has all _ replaced with - from the bundle name.
'real path' => 'admin/structure/fieldable-panels-panes/manage/my-bundle-name',
'access arguments' => array('administer fieldable panels panes'),
......@@ -20,7 +20,7 @@ function MYMODULE_entity_info_alter(&$entity_info) {
);
}
Fields are then added to your bundle as normal through the Manage Fields and
Fields are then added to your bundle as normal through the Manage Fields and
Display Fields tabs in the UI.
You can use this hook to rename or remove the default bundle but remember that
......
<div class="fieldable-panels-pane">
<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php print render($title_suffix); ?>
<?php print $fields; ?>
</div>
......@@ -4,9 +4,9 @@ package = "Panels"
core = "7.x"
dependencies[] = "panels"
dependencies[] = "views"
dependencies[] = "field_ui"
files[] = includes/PanelsPaneController.class.php
files[] = includes/translation.handler.fieldable_panels_pane.inc
files[] = plugins/views/fieldable_panels_panes_handler_argument_bundle.inc
files[] = plugins/views/fieldable_panels_panes_handler_field_bundle.inc
files[] = plugins/views/fieldable_panels_panes_handler_field_delete_entity.inc
......@@ -21,9 +21,9 @@ files[] = plugins/views/fieldable_panels_panes_handler_field_view_revision.inc
files[] = plugins/views/fieldable_panels_panes_handler_field_is_current.inc
files[] = plugins/views/fieldable_panels_panes_handler_field_make_current.inc
; Information added by drupal.org packaging script on 2012-08-18
version = "7.x-1.2"
; Information added by drupal.org packaging script on 2013-01-25
version = "7.x-1.4"
core = "7.x"
project = "fieldable_panels_panes"
datestamp = "1345319222"
datestamp = "1359155502"
......@@ -96,6 +96,13 @@ function fieldable_panels_panes_schema() {
'default' => '',
'description' => 'The Universally Unique Identifier.',
),
'language' => array(
'description' => 'The {languages}.language of this entity.',
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('fpid'),
'indexes' => array(
......@@ -210,3 +217,19 @@ 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.'));
}
/**
* Add language column.
*/
function fieldable_panels_panes_update_7106() {
// Make sure to add language field
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' => '',
));
}
}
......@@ -26,6 +26,7 @@ function fieldable_panels_panes_entity_info() {
'revision' => 'vid',
'bundle' => 'bundle',
'label' => 'admin_title',
'language' => 'language',
'uuid' => 'uuid',
'revision uuid' => 'vuuid',
),
......@@ -56,6 +57,38 @@ function fieldable_panels_panes_entity_info() {
'creation callback' => 'fieldable_panels_panes_create',
'access callback' => 'fieldable_panels_panes_access',
'save callback' => 'fieldable_panels_panes_save',
// Entity translation support
'translation' => array(
'entity_translation' => array(
'class' => 'EntityTranslationFieldablePanelsPaneHandler',
'base path' => 'admin/structure/fieldable-panels-panes/view/%fieldable_panels_panes',
'edit path' => 'admin/structure/fieldable-panels-panes/view/%fieldable_panels_panes/edit',
'path wildcard' => '%fieldable_panels_panes',
),
),
// Title module support
'field replacement' => array(
'title' => array(
'field' => array(
'type' => 'text',
'cardinality' => 1,
'translatable' => TRUE,
),
'instance' => array(
'label' => t('Title'),
'description' => t('A field replacing fieldable panel pane title.'),
'required' => FALSE,
'settings' => array(
'text_processing' => 0,
),
'widget' => array(
'weight' => -10,
),
),
),
),
),
);
}
......@@ -135,11 +168,12 @@ function fieldable_panels_panes_menu() {
$items['admin/structure/fieldable-panels-panes/view/%fieldable_panels_panes/edit'] = array(
'title' => 'Edit',
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'page callback' => 'fieldable_panels_panes_entity_edit_page',
'page arguments' => array(4),
'access callback' => 'fieldable_panels_panes_access',
'access arguments' => array('update', 4),
'weight' => -8,
'weight' => -9,
) + $base;
$items['admin/structure/fieldable-panels-panes/view/%fieldable_panels_panes/view-access'] = array(
......@@ -165,6 +199,7 @@ function fieldable_panels_panes_menu() {
$items['admin/structure/fieldable-panels-panes/view/%fieldable_panels_panes/delete'] = array(
'title' => 'Delete',
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'page callback' => 'drupal_get_form',
'page arguments' => array('fieldable_panels_panes_entity_delete_form', 4),
'access callback' => 'fieldable_panels_panes_access',
......@@ -206,6 +241,7 @@ function fieldable_panels_panes_menu() {
$items['admin/structure/fieldable-panels-panes/view/%fieldable_panels_panes/revision/%/edit'] = array(
'title' => 'Edit',
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'page callback' => 'fieldable_panels_panes_entity_edit_page',
'page arguments' => array(4),
'access callback' => 'fieldable_panels_panes_access',
......@@ -217,6 +253,7 @@ function fieldable_panels_panes_menu() {
$items['admin/structure/fieldable-panels-panes/view/%fieldable_panels_panes/revision/%/delete'] = array(
'title' => 'Delete',
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'page callback' => 'drupal_get_form',
'page arguments' => array('fieldable_panels_panes_entity_delete_revision_form', 4),
'access callback' => 'fieldable_panels_panes_access',
......@@ -227,7 +264,8 @@ function fieldable_panels_panes_menu() {
$items['admin/structure/fieldable-panels-panes/view/%fieldable_panels_panes/revision/%/make-current'] = array(
'title' => 'Make current',
'type' => MENU_CALLBACK,
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
'page callback' => 'fieldable_panels_panes_entity_make_current_page',
'page arguments' => array(4),
'access callback' => 'fieldable_panels_panes_access',
......@@ -281,12 +319,12 @@ function fieldable_panels_panes_menu() {
);
$items['admin/structure/fieldable-panels-panes/manage/%fieldable_panels_panes_type/add'] = array(
'title' => 'Add',
'title' => 'Add fieldable panel pane',
'page callback' => 'fieldable_panels_panes_entities_add_page',
'page arguments' => array(4),
'access callback' => 'fieldable_panels_panes_access',
'access arguments' => array('create', 5),
'type' => MENU_LOCAL_TASK,
'access arguments' => array('create', 4),
'type' => MENU_LOCAL_ACTION,
) + $base;
return $items;
......@@ -338,25 +376,29 @@ function fieldable_panels_panes_theme() {
* Implements hook_admin_menu_map().
*/
function fieldable_panels_panes_admin_menu_map() {
$map = array();
$bundles = array();
$info = entity_get_info('fieldable_panels_pane');
foreach ($info['bundles'] as $bundle_name => $bundle_info) {
$bundles[] = strtr($bundle_name, '_', '-');
if (isset($bundle_info['admin'])) {
$admin_path = $bundle_info['admin']['path'];
$fields = array();
foreach (field_info_instances('fieldable_panels_pane', $bundle_name) as $field) {
$fields[] = $field['field_name'];
// Add mapping for the individual fields if the Field UI module is enabled.
if (module_exists('field_ui')) {
if (isset($bundle_info['admin'])) {
$admin_path = $bundle_info['admin']['path'];
$fields = array();
foreach (field_info_instances('fieldable_panels_pane', $bundle_name) as $field) {
$fields[] = $field['field_name'];
}
$map["$admin_path/fields/%field_ui_menu"]['parent'] = "$admin_path/fields";
$map["$admin_path/fields/%field_ui_menu"]['arguments'][] = array(
'%fieldable_panels_panes_type' => array($bundle_name),
'%field_ui_menu' => $fields,
);
}
$map["$admin_path/fields/%field_ui_menu"]['parent'] = "$admin_path/fields";
$map["$admin_path/fields/%field_ui_menu"]['arguments'][] = array(
'%fieldable_panels_panes_type' => array($bundle_name),
'%field_ui_menu' => $fields,
);
}
}
......@@ -578,11 +620,12 @@ function template_preprocess_fieldable_panels_pane(&$vars) {
*/
function fieldable_panels_panes_preprocess_panels_pane(&$vars) {
if ($vars['pane']->type == 'fieldable_panels_pane') {
$entity = fieldable_panels_panes_load_entity($vars['pane']->subtype);
if ($entity->link && !empty($vars['title'])) {
$vars['title'] = l($vars['title'], $entity->path);
if ($entity = fieldable_panels_panes_load_entity($vars['pane']->subtype)) {
if ($entity->link && !empty($vars['title'])) {
$vars['title'] = l($vars['title'], $entity->path);
}
$vars['classes_array'][] = 'pane-bundle-' . ctools_cleanstring($entity->bundle, array('lower case' => TRUE));
}
$vars['classes_array'][] = 'pane-bundle-' . ctools_cleanstring($entity->bundle, array('lower case' => TRUE));
}
}
......@@ -680,6 +723,18 @@ function fieldable_panels_panes_view($entity, $view_mode = 'full', $langcode = N
return entity_get_controller('fieldable_panels_pane')->view($entity, $view_mode, $langcode);
}
/**
* Entity API callback to view a fieldable panel pane.
*
* This is essentially a duplicate of fieldable_panels_panes_view() but the
* function name has to match the entity type with is singular.
*
* @see entity_view()
*/
function fieldable_panels_pane_view($entity, $view_mode = 'full', $langcode) {
return entity_get_controller('fieldable_panels_pane')->view($entity, $view_mode, $langcode);
}
/**
* Callback to create a new entity.
*/
......@@ -761,6 +816,13 @@ function fieldable_panels_panes_get_base_context($entity = NULL) {
function fieldable_panels_panes_entity_edit_form($form, &$form_state) {
$entity = $form_state['entity'];
// Map these properties for entity translations.
$form['#entity_type'] = array(
'#type' => 'value',
'#value' => $entity->bundle,
);
$form_state['fieldable_panels_pane'] = $form_state['entity'];
// fixes a bug in wysiwyg
// oh wysiwyg. We need a better way to address this.
// drupal_add_css('sites/all/libraries/ckeditor/skins/kama/editor.css');
......@@ -772,6 +834,11 @@ function fieldable_panels_panes_entity_edit_form($form, &$form_state) {
'#weight' => -10,
);
$form['language'] = array(
'#type' => 'value',
'#value' => $entity->language,
);
// Make the other form items dependent upon it.
ctools_include('dependent');
ctools_add_js('dependent');
......@@ -859,7 +926,12 @@ function fieldable_panels_panes_entity_edit_form($form, &$form_state) {
'#default_value' => '',
);
field_attach_form('fieldable_panels_pane', $entity, $form, $form_state);
$language = NULL;
if (function_exists('entity_language')) {
// entity_language() was added in Drupal 7.15.
$language = entity_language('fieldable_panels_pane', $entity);
}
field_attach_form('fieldable_panels_pane', $entity, $form, $form_state, $language);
if (!empty($form_state['add submit'])) {
$form['actions'] = array(
......@@ -892,6 +964,7 @@ function fieldable_panels_panes_entity_edit_form_submit($form, &$form_state) {
$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'];
$entity->admin_title = $form_state['values']['admin_title'];
......@@ -911,3 +984,17 @@ function fieldable_panels_panes_entity_edit_form_submit($form, &$form_state) {
drupal_set_message(t('The entity has been saved.'));
}
}
/**
* Returns whether the current page is the preview view of the passed-in pane.
*
* @param object $pane
* A fieldable panel pane object.
*
* @return bool
* TRUE if this is a full pane page view, otherwise FALSE.
*/
function fieldable_panels_pane_is_page($pane) {
$page_page = menu_get_object('fieldable_panels_panes', 4);
return (!empty($page_page) ? $page_page->fpid == $pane->fpid : FALSE);
}
......@@ -126,8 +126,8 @@ class PanelsPaneController extends DrupalDefaultEntityController {
return $entity;
}
catch (Exception $e) {
$transaction->rollback('fieldable_panels_panes');
watchdog_exception('fieldable_panels_panes', $e);
$transaction->rollback();
watchdog_exception('fieldable_panels_pane', $e);
}
return FALSE;
......@@ -162,11 +162,19 @@ class PanelsPaneController extends DrupalDefaultEntityController {
}
public function view($entity, $view_mode = 'full', $langcode = NULL) {
// Allow modules to change the view mode.
$context = array(
'entity_type' => 'fieldable_panels_pane',
'entity' => $entity,
'langcode' => $langcode,
);
drupal_alter('entity_view_mode', $view_mode, $context);
// attach our fields and prepare the pane for rendering
field_attach_prepare_view('fieldable_panels_pane', array($entity->fpid => $entity), $view_mode, $langcode);
entity_prepare_view('fieldable_panels_pane', array($entity->fpid => $entity), $langcode);
$entity->content = field_attach_view('fieldable_panels_pane', $entity, $view_mode, $langcode);
$entity->content += array(
$build = field_attach_view('fieldable_panels_pane', $entity, $view_mode, $langcode);
$build += array(
'#fieldable_panels_pane' => $entity,
'#theme' => 'fieldable_panels_pane',
'#element' => $entity,
......@@ -174,10 +182,18 @@ class PanelsPaneController extends DrupalDefaultEntityController {
'#language' => $langcode,
);
// Add contextual links for this fieldable panel pane, except when the pane
// is already being displayed on its own page. Modules may alter this
// behavior (for example, to restrict contextual links to certain view
// modes) by implementing hook_fieldable_panels_pane_view_alter().
if (!empty($entity->fpid) && !($view_mode == 'full' && fieldable_panels_pane_is_page($entity))) {
$build['#contextual_links']['fieldable_panels_panes'] = array('admin/structure/fieldable-panels-panes/view', array($entity->fpid));
}
$entity_type = 'fieldable_panels_pane';
drupal_alter(array('fieldable_panels_pane_view', 'entity_view'), $entity->content, $entity_type);
drupal_alter(array('fieldable_panels_pane_view', 'entity_view'), $build, $entity_type);
return $entity->content;
return $build;
}
public function delete($fpids) {
......
......@@ -246,4 +246,3 @@ function fieldable_panels_panes_entity_make_current_page($entity) {
drupal_set_message(t('The revision has been made current.'));
drupal_goto("admin/structure/fieldable-panels-panes/view/$entity->fpid");
}
<?php
/**
* @file
* Fieldable panels pane translation handler for the translation module.
*/
/**
* Fieldable panels pane translation handler.
*/
class EntityTranslationFieldablePanelsPaneHandler extends EntityTranslationDefaultHandler {
public function __construct($entity_type, $entity_info, $entity) {
parent::__construct('fieldable_panels_pane', $entity_info, $entity);
}
/**
* @see EntityTranslationDefaultHandler::isRevision()
*/
public function isRevision() {
return !empty($this->entity->revision);
}
/**
* @see EntityTranslationDefaultHandler::getAccess()
*/
public function getAccess($op) {
return fieldable_panels_panes_access($op, $this->entity);
}
}
......@@ -79,16 +79,6 @@ function fieldable_panels_panes_fieldable_panels_pane_content_type_render($subty
$block->title = !empty($entity->title) ? filter_xss_admin($entity->title) : '';
}
$block->content = fieldable_panels_panes_view($entity, $view_mode);
if (fieldable_panels_panes_access('update', $entity)) {
$block->admin_links[] = array(
'title' => t('Edit pane'),
'alt' => t("Edit the values in this pane"),
'href' => "admin/structure/fieldable-panels-panes/view/$entity->fpid/edit",
'query' => drupal_get_destination(),
);
}
return $block;
}
}
......@@ -295,7 +285,8 @@ function fieldable_panels_panes_load_entity($subtype_name) {
function _fieldable_panels_panes_load_entity($subtype_name) {
list($type, $id) = explode(':', $subtype_name);
if ($type == 'uuid' && module_exists('uuid')) {
if ($content = entity_uuid_load('fieldable_panels_pane', array($id))) {
$ids = entity_get_id_by_uuid('fieldable_panels_pane', array($id));
if ($content = entity_load('fieldable_panels_pane', $ids)) {
$content = reset($content);
}
}
......
......@@ -10,7 +10,7 @@
function fieldable_panels_panes_views_default_views() {
$views = array();
$view = new view;
$view = new view();
$view->name = 'fieldable_pane_entities';
$view->description = 'Administrative view to show a list of fieldable pane entities and administer them.';
$view->tag = 'default';
......@@ -22,12 +22,17 @@ function fieldable_panels_panes_views_default_views() {
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '50';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['quantity'] = '9';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
'bundle' => 'bundle',
......@@ -100,17 +105,12 @@ function fieldable_panels_panes_views_default_views() {
'empty_column' => 0,
),
);
$handler->display->display_options['style_options']['override'] = 1;
$handler->display->display_options['style_options']['sticky'] = 0;
$handler->display->display_options['style_options']['empty_table'] = 0;
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['empty'] = FALSE;
$handler->display->display_options['empty']['area']['content'] = 'There are currently no entities of this type.';
$handler->display->display_options['empty']['area']['format'] = 'filtered_html';
$handler->display->display_options['empty']['area']['tokenize'] = 0;
/* Field: Fieldable pane: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'fieldable_panels_panes';
......@@ -148,10 +148,9 @@ function fieldable_panels_panes_views_default_views() {
$handler->display->display_options['arguments']['bundle']['table'] = 'fieldable_panels_panes';
$handler->display->display_options['arguments']['bundle']['field'] = 'bundle';
$handler->display->display_options['arguments']['bundle']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['bundle']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['bundle']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['bundle']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['bundle']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['bundle']['summary_options']['items_per_page'] = '50';
$translatables['fieldable_pane_entities'] = array(
t('Master'),
t('more'),
......@@ -163,6 +162,10 @@ function fieldable_panels_panes_views_default_views() {
t('Items per page'),
t('- All -'),
t('Offset'),
t('« first'),
t('‹ previous'),
t('next ›'),
t('last »'),
t('There are currently no entities of this type.'),
t('Title'),
t('Reusable'),
......@@ -176,7 +179,7 @@ function fieldable_panels_panes_views_default_views() {
);
$views['fieldable_pane_entities'] = $view;
$view = new view;
$view = new view();
$view->name = 'fieldable_pane_entity_revisions';
$view->description = 'Administrative view to show a list of revisions of a fieldable pane entity and administer them.';
$view->tag = 'default';
......@@ -188,12 +191,17 @@ function fieldable_panels_panes_views_default_views() {
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '50';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['quantity'] = '9';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
'log' => 'log',
......@@ -254,127 +262,41 @@ function fieldable_panels_panes_views_default_views() {
'empty_column' => 0,
),
);
$handler->display->display_options['style_options']['override'] = 1;
$handler->display->display_options['style_options']['sticky'] = 0;
$handler->display->display_options['style_options']['empty_table'] = 0;
/* Relationship: Fieldable pane (historical data): Author */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'fieldable_panels_panes_revision';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
$handler->display->display_options['relationships']['uid']['required'] = 0;
/* Field: Fieldable pane (historical data): Log message */
$handler->display->display_options['fields']['log']['id'] = 'log';
$handler->display->display_options['fields']['log']['table'] = 'fieldable_panels_panes_revision';
$handler->display->display_options['fields']['log']['field'] = 'log';
$handler->display->display_options['fields']['log']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['log']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['log']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['log']['alter']['external'] = 0;
$handler->display->display_options['fields']['log']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['log']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['log']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['log']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['log']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['log']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['log']['alter']['trim'] = 0;