function pm_menu_admin in Drupal PM (Project Management) 7.3
Generates a table of recommended modules.
File
- includes/
pm.menu.inc, line 49 - Drupal Pm Menu Admin settings.
Code
function pm_menu_admin($form, $form_state, $type) {
$menu_items = pm_menu_get_links($type);
$message = NULL;
switch ($type) {
case 'page':
$message = t('This menu will be displayed on your site as a page at path !path', array(
'!path' => l('pm', 'pm'),
));
break;
case 'block':
$message = t('This menu can be positioned anywhere on your site as a block. Configure positioning using !link', array(
'!link' => l('this block configuration page', 'admin/structure/block/manage/pm/pm_menu/configure'),
));
break;
}
if ($message) {
$form['message'] = array(
'#type' => 'markup',
'#markup' => $message,
);
}
$form['type'] = array(
'#type' => 'value',
'#value' => $type,
);
$form['items'] = array(
'#tree' => TRUE,
'#theme' => 'pm_menu_entry_table',
);
if (isset($form_state['values']['add_new_item'])) {
$menu_items[] = array(
'title' => '',
'path' => '',
'icon' => '',
'status' => TRUE,
'delete' => FALSE,
'weight' => 10000,
'extra_link' => '',
'custom' => TRUE,
'id' => NULL,
);
}
$table =& $form['items'];
$icon_picker = module_exists('fontawesome_iconpicker') ? 'fontawesome_iconpicker_textfield' : 'textfield';
// Loop through the activites and add them to the form.
if (!empty($menu_items)) {
foreach ($menu_items as $key => $item) {
$table[$key]['#menu_item'] = (array) $item;
$table[$key]['custom'] = array(
'#type' => 'value',
'#value' => $item['custom'],
);
$table[$key]['id'] = array(
'#type' => 'value',
'#value' => $item['id'],
);
$table[$key]['title'] = array(
'#type' => 'textfield',
'#size' => '20',
'#default_value' => check_plain($item['title']),
'#disabled' => !$item['custom'],
'#attributes' => array(
'placeholder' => t('Title'),
),
);
$table[$key]['path'] = array(
'#type' => 'textfield',
'#size' => '20',
'#default_value' => $item['path'],
'#disabled' => !$item['custom'],
'#attributes' => array(
'placeholder' => t('Main Link'),
),
);
$table[$key]['extra_link'] = array(
'#type' => 'textfield',
'#size' => '20',
'#default_value' => $item['extra_link'],
'#access' => $item['custom'],
'#attributes' => array(
'placeholder' => t('Sub link (add item)'),
),
);
$table[$key]['icon'] = array(
'#type' => $icon_picker,
'#size' => '15',
'#default_value' => $item['icon'],
'#disabled' => !$item['custom'],
);
// The weight (this is for the tabledrag we'll add in the theme function
$table[$key]['weight'] = array(
'#type' => 'textfield',
'#size' => 2,
'#delta' => 10,
'#default_value' => $item['weight'],
);
// Is this activity enabled?
$table[$key]['status'] = array(
'#type' => 'checkbox',
'#default_value' => $item['status'] ? TRUE : FALSE,
);
// Is this activity enabled?
$table[$key]['delete'] = array(
'#type' => 'checkbox',
'#default_value' => FALSE,
'#access' => $item['custom'],
);
}
}
module_load_include('inc', 'pm', 'includes/pm.icon');
$form['icon'] = array(
'#type' => 'fieldset',
'#title' => t('Icons'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$icon_table = _pm_icon_list_as_table();
if (module_exists('fontawesome')) {
$fa_module_status = 'The <em>Font Awesome</em> module is <span class="admin-enabled">enabled</span>.';
if (($library = libraries_detect('fontawesome')) && !empty($library['installed'])) {
$form['icon']['fontawesome']['#markup'] = t('Fontawesome is enabled, you may use the icon classes available at !link', array(
'!link' => l('http://fortawesome.github.io/', 'http://fortawesome.github.io/Font-Awesome/icons/'),
));
}
else {
$form['icon']['fontawesome']['#markup'] = t('Fontawesome is enabled, but fontawesome library is missing. You will have to install the library to use the icon classes available at !link', array(
'!link' => l('http://fortawesome.github.io/', 'http://fortawesome.github.io/Font-Awesome/icons/'),
));
}
}
else {
$form['icon']['fontawesome']['#markup'] = t('If you install fontawesome module and the library, you may use the icon classes available at !link', array(
'!link' => l('http://fortawesome.github.io/', 'http://fortawesome.github.io/Font-Awesome/icons/'),
));
}
$form['icon']['table']['#markup'] = drupal_render($icon_table);
$form['actions']['add'] = array(
'#type' => 'submit',
'#value' => t('Add New item'),
'#name' => 'add_new_item',
'#submit' => array(
'pm_menu_admin_add_new',
),
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}