security update core+modules
This commit is contained in:
@@ -6,12 +6,16 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default controller for providing UI.
|
||||
* Default UI controller providing admin UI.
|
||||
*
|
||||
* This controller suites best for managing configuration entities.
|
||||
* For a controller suiting content entities, see EntityContentUIController.
|
||||
*/
|
||||
class EntityDefaultUIController {
|
||||
|
||||
protected $entityType;
|
||||
protected $entityInfo, $path;
|
||||
protected $id_count;
|
||||
|
||||
/**
|
||||
* Defines the number of entries to show per page in overview table.
|
||||
@@ -30,7 +34,8 @@ class EntityDefaultUIController {
|
||||
*/
|
||||
public function hook_menu() {
|
||||
$items = array();
|
||||
$id_count = count(explode('/', $this->path));
|
||||
// Set this on the object so classes that extend hook_menu() can use it.
|
||||
$this->id_count = count(explode('/', $this->path));
|
||||
$wildcard = isset($this->entityInfo['admin ui']['menu wildcard']) ? $this->entityInfo['admin ui']['menu wildcard'] : '%entity_object';
|
||||
$plural_label = isset($this->entityInfo['plural label']) ? $this->entityInfo['plural label'] : $this->entityInfo['label'] . 's';
|
||||
|
||||
@@ -60,12 +65,12 @@ class EntityDefaultUIController {
|
||||
$items[$this->path . '/manage/' . $wildcard] = array(
|
||||
'title' => 'Edit',
|
||||
'title callback' => 'entity_label',
|
||||
'title arguments' => array($this->entityType, $id_count + 1),
|
||||
'title arguments' => array($this->entityType, $this->id_count + 1),
|
||||
'page callback' => 'entity_ui_get_form',
|
||||
'page arguments' => array($this->entityType, $id_count + 1),
|
||||
'page arguments' => array($this->entityType, $this->id_count + 1),
|
||||
'load arguments' => array($this->entityType),
|
||||
'access callback' => 'entity_access',
|
||||
'access arguments' => array('update', $this->entityType, $id_count + 1),
|
||||
'access arguments' => array('update', $this->entityType, $this->id_count + 1),
|
||||
);
|
||||
$items[$this->path . '/manage/' . $wildcard . '/edit'] = array(
|
||||
'title' => 'Edit',
|
||||
@@ -77,7 +82,7 @@ class EntityDefaultUIController {
|
||||
$items[$this->path . '/manage/' . $wildcard . '/clone'] = array(
|
||||
'title' => 'Clone',
|
||||
'page callback' => 'entity_ui_get_form',
|
||||
'page arguments' => array($this->entityType, $id_count + 1, 'clone'),
|
||||
'page arguments' => array($this->entityType, $this->id_count + 1, 'clone'),
|
||||
'load arguments' => array($this->entityType),
|
||||
'access callback' => 'entity_access',
|
||||
'access arguments' => array('create', $this->entityType),
|
||||
@@ -85,10 +90,10 @@ class EntityDefaultUIController {
|
||||
// Menu item for operations like revert and delete.
|
||||
$items[$this->path . '/manage/' . $wildcard . '/%'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array($this->entityType . '_operation_form', $this->entityType, $id_count + 1, $id_count + 2),
|
||||
'page arguments' => array($this->entityType . '_operation_form', $this->entityType, $this->id_count + 1, $this->id_count + 2),
|
||||
'load arguments' => array($this->entityType),
|
||||
'access callback' => 'entity_access',
|
||||
'access arguments' => array('delete', $this->entityType, $id_count + 1),
|
||||
'access arguments' => array('delete', $this->entityType, $this->id_count + 1),
|
||||
'file' => 'includes/entity.ui.inc',
|
||||
);
|
||||
|
||||
@@ -492,6 +497,128 @@ class EntityDefaultUIController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UI controller providing UI for content entities.
|
||||
*
|
||||
* For a controller providing UI for bundleable content entities, see
|
||||
* EntityBundleableUIController.
|
||||
* For a controller providing admin UI for configuration entities, see
|
||||
* EntityDefaultUIController.
|
||||
*/
|
||||
class EntityContentUIController extends EntityDefaultUIController {
|
||||
|
||||
/**
|
||||
* Provides definitions for implementing hook_menu().
|
||||
*/
|
||||
public function hook_menu() {
|
||||
$items = parent::hook_menu();
|
||||
$wildcard = isset($this->entityInfo['admin ui']['menu wildcard']) ? $this->entityInfo['admin ui']['menu wildcard'] : '%entity_object';
|
||||
|
||||
// Unset the manage entity path, as the provided UI is for admin entities.
|
||||
unset($items[$this->path]);
|
||||
|
||||
$defaults = array(
|
||||
'file' => $this->entityInfo['admin ui']['file'],
|
||||
'file path' => isset($this->entityInfo['admin ui']['file path']) ? $this->entityInfo['admin ui']['file path'] : drupal_get_path('module', $this->entityInfo['module']),
|
||||
);
|
||||
|
||||
// Add view, edit and delete menu items for content entities.
|
||||
$items[$this->path . '/' . $wildcard] = array(
|
||||
'title callback' => 'entity_ui_get_page_title',
|
||||
'title arguments' => array('view', $this->entityType, $this->id_count),
|
||||
'page callback' => 'entity_ui_entity_page_view',
|
||||
'page arguments' => array($this->id_count),
|
||||
'load arguments' => array($this->entityType),
|
||||
'access callback' => 'entity_access',
|
||||
'access arguments' => array('view', $this->entityType, $this->id_count),
|
||||
) + $defaults;
|
||||
$items[$this->path . '/' . $wildcard . '/view'] = array(
|
||||
'title' => 'View',
|
||||
'type' => MENU_DEFAULT_LOCAL_TASK,
|
||||
'load arguments' => array($this->entityType),
|
||||
'weight' => -10,
|
||||
) + $defaults;
|
||||
$items[$this->path . '/' . $wildcard . '/edit'] = array(
|
||||
'page callback' => 'entity_ui_get_form',
|
||||
'page arguments' => array($this->entityType, $this->id_count),
|
||||
'load arguments' => array($this->entityType),
|
||||
'access callback' => 'entity_access',
|
||||
'access arguments' => array('edit', $this->entityType, $this->id_count),
|
||||
'title' => 'Edit',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
|
||||
) + $defaults;
|
||||
$items[$this->path . '/' . $wildcard . '/delete'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array($this->entityType . '_operation_form', $this->entityType, $this->id_count, 'delete'),
|
||||
'load arguments' => array($this->entityType),
|
||||
'access callback' => 'entity_access',
|
||||
'access arguments' => array('delete', $this->entityType, $this->id_count),
|
||||
'title' => 'Delete',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'context' => MENU_CONTEXT_INLINE,
|
||||
'file' => $this->entityInfo['admin ui']['file'],
|
||||
'file path' => isset($this->entityInfo['admin ui']['file path']) ? $this->entityInfo['admin ui']['file path'] : drupal_get_path('module', $this->entityInfo['module']),
|
||||
) + $defaults;
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation form submit callback.
|
||||
*/
|
||||
public function operationFormSubmit($form, &$form_state) {
|
||||
parent::operationFormSubmit($form, $form_state);
|
||||
// The manage entity path is unset for the content entity UI.
|
||||
$form_state['redirect'] = '<front>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UI controller providing UI for bundleable content entities.
|
||||
*
|
||||
* Adds a bundle selection page to the entity/add path, analogously to the
|
||||
* node/add path.
|
||||
*/
|
||||
class EntityBundleableUIController extends EntityContentUIController {
|
||||
|
||||
/**
|
||||
* Provides definitions for implementing hook_menu().
|
||||
*/
|
||||
public function hook_menu() {
|
||||
$items = parent::hook_menu();
|
||||
|
||||
// Extend the 'add' path.
|
||||
$items[$this->path . '/add'] = array(
|
||||
'title callback' => 'entity_ui_get_action_title',
|
||||
'title arguments' => array('add', $this->entityType),
|
||||
'page callback' => 'entity_ui_bundle_add_page',
|
||||
'page arguments' => array($this->entityType),
|
||||
'access callback' => 'entity_access',
|
||||
'access arguments' => array('create', $this->entityType),
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
);
|
||||
$items[$this->path . '/add/%'] = array(
|
||||
'title callback' => 'entity_ui_get_action_title',
|
||||
'title arguments' => array('add', $this->entityType, $this->id_count + 1),
|
||||
'page callback' => 'entity_ui_get_bundle_add_form',
|
||||
'page arguments' => array($this->entityType, $this->id_count + 1),
|
||||
'access callback' => 'entity_access',
|
||||
'access arguments' => array('create', $this->entityType),
|
||||
);
|
||||
|
||||
if (!empty($this->entityInfo['admin ui']['file'])) {
|
||||
// Add in the include file for the entity form.
|
||||
foreach (array('/add', '/add/%') as $path_end) {
|
||||
$items[$this->path . $path_end]['file'] = $this->entityInfo['admin ui']['file'];
|
||||
$items[$this->path . $path_end]['file path'] = isset($this->entityInfo['admin ui']['file path']) ? $this->entityInfo['admin ui']['file path'] : drupal_get_path('module', $this->entityInfo['module']);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Form builder function for the overview form.
|
||||
*
|
||||
@@ -597,39 +724,6 @@ function entity_ui_controller_form_submit($form, &$form_state) {
|
||||
entity_ui_controller($form_state['entity_type'])->$method($form, $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the page title for the passed operation.
|
||||
*/
|
||||
function entity_ui_get_page_title($op, $entity_type, $entity = NULL) {
|
||||
$label = entity_label($entity_type, $entity);
|
||||
switch ($op) {
|
||||
case 'edit':
|
||||
return t('Edit @label', array('@label' => $label));
|
||||
case 'clone':
|
||||
return t('Clone @label', array('@label' => $label));
|
||||
case 'revert':
|
||||
return t('Revert @label', array('@label' => $label));
|
||||
case 'delete':
|
||||
return t('Delete @label', array('@label' => $label));
|
||||
case 'export':
|
||||
return t('Export @label', array('@label' => $label));
|
||||
}
|
||||
return entity_ui_get_action_title($op, $entity_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the page/menu title for local action operations.
|
||||
*/
|
||||
function entity_ui_get_action_title($op, $entity_type) {
|
||||
$info = entity_get_info($entity_type);
|
||||
switch ($op) {
|
||||
case 'add':
|
||||
return t('Add @entity_type', array('@entity_type' => drupal_strtolower($info['label'])));
|
||||
case 'import':
|
||||
return t('Import @entity_type', array('@entity_type' => drupal_strtolower($info['label'])));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit builder for the main entity form, which extracts the form values and updates the entity.
|
||||
*
|
||||
@@ -670,3 +764,4 @@ function theme_entity_ui_overview_item($variables) {
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user