Skip to content

Commit

Permalink
Issue #93: Use theme_label_machine_name on Paragraphs types overvie…
Browse files Browse the repository at this point in the history
…w page

Fixes #93
  • Loading branch information
laryn committed Oct 13, 2021
1 parent c825f0c commit 1a5ded4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 30 deletions.
32 changes: 6 additions & 26 deletions paragraphs.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ function paragraphs_admin_bundle_overview() {

$header = array(
t('Label'),
t('Description'),
t('Operations'),
);
$rows = array();
$operations = array();
foreach ($bundles as $bundle) {

$type_url_str = strtr($bundle->bundle, array('_' => '-'));
$row = array(theme('paragraphs_admin_overview', array('bundle' => $bundle)));
$row = array(theme('label_machine_name__paragraphs', array(
'label' => $bundle->label,
'machine_name' => $bundle->bundle,
)));
$row['description'] = $bundle->description;

if ($field_ui) {
// Manage fields.
Expand Down Expand Up @@ -78,31 +83,6 @@ function paragraphs_admin_bundle_overview() {
return $page;
}

/**
* Returns HTML for a paragraphs bundle description.
*
* @param array $variables
* An array with one item, containing the paragraphs bundle object.
* $variables['bundle'] is an object with the following properties:
* - name: The human-readable name of the bundle.
* - bundle: The machine name of the bundle.
* - label: The bundle's label when displayed in edit forms.
* - description: A text description of the bundle.
*
* @see paragraphs_admin_bundle_overview()
* @ingroup themeable
*/
function theme_paragraphs_admin_overview(array $variables) {
$bundle = $variables['bundle'];

$output = check_plain($bundle->name);
$output .= ($bundle->name != $bundle->label) ? ' [<em>' . check_plain($bundle->label) . '</em>]' : '';
$output .= ' <small>' . t('(Machine name: @bundle)', array('@bundle' => $bundle->bundle)) . '</small>';
$output .= !empty($bundle->description) ? '<div class="description">' . filter_xss_admin($bundle->description) . '</div>' : '';

return $output;
}

/**
* Form to create or edit an paragraphs bundle.
*
Expand Down
1 change: 1 addition & 0 deletions paragraphs.info
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ configure = admin/structure/paragraphs
stylesheets[all][] = css/paragraphs.css
dependencies[] = entity
dependencies[] = entity_plus (>=1.0.5)
dependencies[] = system (>=1.20.0)
4 changes: 0 additions & 4 deletions paragraphs.module
Original file line number Diff line number Diff line change
Expand Up @@ -1332,10 +1332,6 @@ function paragraphs_theme() {
'path' => backdrop_get_path('module', 'paragraphs') . '/theme',
'file' => 'paragraphs.theme.inc',
),
'paragraphs_admin_overview' => array(
'variables' => array('bundle' => NULL),
'file' => 'paragraphs.admin.inc',
),
);
}

Expand Down

0 comments on commit 1a5ded4

Please sign in to comment.