function _outline_designer_settings in Outline Designer 6
Same name and namespace in other branches
- 7 outline_designer.module \_outline_designer_settings()
Implementation of hook_settings().
2 string references to '_outline_designer_settings'
- outline_child_pages_form_alter in outline_child_pages/
outline_child_pages.module - Implementation of hook_form_alter(). Adds a radio select to choose between a link or a tab.
- outline_designer_menu in ./
outline_designer.module - Implementation of hook_menu().
File
- ./
outline_designer.module, line 299 - Massive usability improvement for quickly structuring / creating content.
Code
function _outline_designer_settings($form_state) {
// build out a list of the packaged icons
$icons = array(
'add_content',
'change_type',
'close',
'delete',
'duplicate',
'edit',
'folder',
'link',
'node',
'page',
'rename',
'save',
'settings',
'story',
'view',
);
$packaged_icons = '<label>' . t('Default Icon set') . ':</label>';
foreach ($icons as $title) {
$packaged_icons .= '<img src="' . base_path() . drupal_get_path('module', 'outline_designer') . '/images/' . $title . '.png" title="' . $title . '" alt="' . $title . '" hspace="2px" />';
}
// add in archived icon set on a separate row
$packaged_icons .= '<br/><label>' . t('Additional icon') . ':</label>';
foreach ($icons as $title) {
$packaged_icons .= '<img src="' . base_path() . drupal_get_path('module', 'outline_designer') . '/images/additional_icons/' . $title . '.png" title="' . $title . '" alt="' . $title . '" hspace="2px" />';
}
// create it juuuust incase and make sure it's writable
$dir = file_create_path(file_directory_path() . '/outline_designer');
file_check_directory($dir, 1);
if ($handle = opendir('./' . file_directory_path() . '/outline_designer')) {
while (FALSE !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$uploaded_icons .= '<img src="' . base_path() . file_directory_path() . '/outline_designer/' . $file . '" title="' . $file . '" alt="' . $file . '" hspace="2px" />';
}
}
closedir($handle);
}
// collapse default state
$form["ui"] = array(
'#type' => 'fieldset',
'#title' => t('User interface'),
'#collapsed' => FALSE,
'#collapsible' => TRUE,
);
$form["ui"]["outline_designer_theme"] = array(
'#type' => 'select',
'#title' => t('Menu theme'),
'#default_value' => variable_get('outline_designer_theme', 'vista'),
'#options' => array(
'vista' => 'Vista',
'xp' => 'XP',
'human' => 'Human',
'osx' => 'OS X',
),
'#description' => 'Theme for the outline designer menu system',
'#required' => TRUE,
);
// collapse default state
$form["ui"]["outline_designer_collapse_toggle"] = array(
'#type' => 'checkbox',
'#title' => t('Collapse nested content by default?'),
'#default_value' => variable_get('outline_designer_collapse_toggle', 1),
'#description' => 'This is helpful when working with large book structures.',
'#required' => FALSE,
);
// context menu settings
$form["context_menu"] = array(
'#type' => 'fieldset',
'#title' => t('Context menu'),
'#collapsed' => FALSE,
'#collapsible' => TRUE,
'#description' => 'The selected items will appear in the Outline Designer context menu, depending on the user\'s roles. Users with several roles will cumulate the roles settings.<br />WARNING: only roles with permission \'administer book outlines\' or group admins (if outline_designer_og is activated) will be able to utilize these settings.',
'#theme' => 'outline_designer_context_menu_items_matrix',
);
$roles = user_roles(TRUE);
$menu_items = array(
'nid' => t('Node id'),
'add_content' => t('Add content'),
'rename' => t('Rename'),
'edit' => t('Edit'),
'view' => t('View'),
'delete' => t('Delete'),
'duplicate' => t('Duplicate'),
'change_type' => t('Change Type'),
);
$saved_unchecked_items = variable_get('outline_designer_context_menu_exclusion_matrix', array());
// create a checkbox for each menu item for each role
foreach ($menu_items as $item_name => $item_desc) {
foreach ($roles as $rid => $role) {
// if the checkbox is present in the 'outline_designer_context_menu_exclusion_matrix' variable,
// then we need to uncheck it (e.g. assign FALSE to #default_value)
$default_value = isset($saved_unchecked_items[$rid][$item_name]['unchecked']) ? FALSE : TRUE;
$form["context_menu"]["checkboxes"][$item_name]["outline_designer_context_menu_" . $item_name . "_" . $rid] = array(
'#name' => 'outline_designer_context_menu_' . $item_name . '_' . $rid,
'#type' => 'checkbox',
'#title' => $item_desc,
'#default_value' => $default_value,
'#return_value' => array(
'item_name' => $item_name,
'rid' => $rid,
),
);
}
}
// icons
$form["packaged_icons"] = array(
'#type' => 'fieldset',
'#title' => t('Packaged icons'),
'#collapsed' => FALSE,
'#collapsible' => TRUE,
);
$form["packaged_icons"]["packaged"] = array(
'#type' => 'markup',
'#title' => 'packaged',
'#value' => $packaged_icons,
);
$form["uploaded_icons"] = array(
'#type' => 'fieldset',
'#title' => t('Uploaded Icons'),
'#collapsed' => FALSE,
'#collapsible' => TRUE,
);
$form["uploaded_icons"]["uploaded"] = array(
'#type' => 'markup',
'#value' => $uploaded_icons,
);
$result = db_query("SELECT type, name FROM {node_type}");
$types_ary = variable_get('book_allowed_types', array(
'page',
));
while ($value = db_fetch_array($result)) {
// only show types that are allowed
if (in_array($value['type'], $types_ary)) {
// create a textfield incase they want to enter an icon that way
$form["outline_designer_" . $value['type']] = array(
'#type' => 'fieldset',
'#title' => '<img src="' . base_path() . variable_get("outline_designer_" . $value['type'] . "_icon", drupal_get_path('module', 'outline_designer') . "/images/page.png") . '" style="display:inline !important" /> ' . $value['name'],
'#collapsed' => TRUE,
'#collapsible' => TRUE,
'#description' => t("This icon will be associated to the content type in book outlines. The icon must be 16x16, unless an <a href=@toolkit>image toolkit</a> is installed, and in jpg, gif or png format.", array(
'@toolkit' => url('admin/settings/image-toolkit'),
)),
);
$form["outline_designer_" . $value['type']]["outline_designer_" . $value['type'] . "_icon_link"] = array(
'#type' => 'textfield',
'#title' => t("Icon Path"),
'#default_value' => variable_get("outline_designer_" . $value['type'] . "_icon", drupal_get_path('module', 'outline_designer') . "/images/page.png"),
'#required' => FALSE,
);
// Create a upload field for each content type so icons can be added for them
$form["outline_designer_" . $value['type']]["outline_designer_" . $value['type'] . "_icon"] = array(
'#type' => 'file',
'#size' => '10',
'#title' => t("Upload Icon"),
'#required' => FALSE,
);
}
}
$form['#attributes'] = array(
'enctype' => "multipart/form-data",
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}