You are here

function _power_menu_form_overview_alter in Power Menu 7

Same name and namespace in other branches
  1. 6 power_menu.forms.inc \_power_menu_form_overview_alter()
1 call to _power_menu_form_overview_alter()
power_menu_form_menu_overview_form_alter in ./power_menu.module
Implements hook_form_ID_alter().

File

./power_menu.forms.inc, line 289
manipulation of the forms

Code

function _power_menu_form_overview_alter(&$form, &$form_state) {

  // finding properties that are predefined by the system in the properties folder
  $dir = dir(drupal_get_path('module', 'power_menu') . '/properties');
  $properties = array();
  while ($filename = $dir
    ->read()) {
    $file = $dir->path . '/' . $filename;
    if (filetype($file) == 'file') {
      include_once DRUPAL_ROOT . '/' . $file;
      $properties = array_merge($properties, module_invoke(str_replace(".inc", '', $filename), 'power_menu_properties'));
    }
  }
  $dir
    ->close();
  $module_properties = module_invoke_all('power_menu_properties');

  // Include all necessary files
  foreach ($module_properties as $property) {
    include_once DRUPAL_ROOT . '/' . $property['path'] . '/' . $property['file'];
  }
  $properties = array_merge($properties, $module_properties);
  cache_set('power_menu_properties', $properties, 'cache');

  // setting up properties
  $form['properties'] = array(
    '#type' => 'fieldset',
    '#title' => t('Properties'),
    '#weight' => -1,
    '#collapsed' => FALSE,
    '#collapsible' => TRUE,
    '#tree' => TRUE,
    '#description' => t("Properties can be inherited. If no property is set, it's going taketo display the property of the parent menu item."),
  );
  foreach ($properties as $prop) {
    $form['properties'][$prop['property_name']] = array(
      '#type' => isset($prop['type']) && $prop['type'] == 'textfield' ? $prop['type'] : 'textarea',
      // Only textfield and textarea are supported
      '#title' => $prop['property_name'],
      '#default_value' => $prop['property_load'](0, TRUE),
      '#description' => $prop['description'],
    );
    $form['#submit'][] = $prop['admin_submit'];
  }
}