function template_preprocess_sharebar_buttons_table in ShareBar 8
Theme the administer buttons page.
File
- ./
sharebar.module, line 190 - Allows site owner to add share buttons on their website
Code
function template_preprocess_sharebar_buttons_table(&$variables) {
$add_url = Url::fromRoute('sharebar.add_button');
$variables['add_button'] = \Drupal::l(t('Add New Button'), $add_url);
$buttons = unserialize(\Drupal::config('sharebar.settings')
->get('sharebar_buttons'));
if (empty($buttons)) {
$buttons = unserialize(sharebar_buttons_def());
}
if (is_array($buttons) && count($buttons)) {
usort($buttons, "sharebar_cmp_up");
foreach ($buttons as $key => $value) {
$row = array();
$row[] = array(
'data' => $value->enabled ? t('Yes') : t('No'),
);
$row[] = array(
'data' => $value->name,
);
$row[] = array(
'data' => $value->big_button,
);
$row[] = array(
'data' => $value->small_button,
);
$row[] = array(
'data' => $value->weight,
);
$edit_url = Url::fromRoute('sharebar.edit_button', array(
'mname' => $value->name,
));
$del_url = Url::fromRoute('sharebar.del_button', array(
'mname' => $value->name,
));
$edit_url1 = \Drupal::l(t('Edit'), $edit_url);
$del_url1 = \Drupal::l(t('Delete'), $del_url);
$row[] = array(
'data' => $edit_url1,
);
$row[] = array(
'data' => $del_url1,
);
$rows[] = $row;
}
}
if (count($rows)) {
$header = array(
t('Enabled'),
t('Name'),
t('Big Button'),
t('Small Button'),
t('Weight'),
t('Edit'),
t('Delete'),
);
$table = array(
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => array(
'id' => 'sharebar-table',
),
);
$variables['out'] = drupal_render($table);
}
else {
$variables['out'] = '<b>' . t('No data') . '</b>';
}
}