' . t('The Theme Editor provides a robust interface for making web bassed changes to all of a drupal sites theme files. It allows an admin to set varying levels of control over the editing ability as well.') . '
'; $output .= '' . t('Using Drupals permission system the Theme Editor allows each theme to have it\'s own editor permission. In addition there are also permissions for Adding, Deleting, and Editing files based on type. For example one user can have access to edit(but not add or delete) Garland .css, .txt &, .htm files, and another could have permission to Add, edit, and delete all files for Bluemarine and Marvin themes, but no permissions on Garland.') . '
'; return $output; } } /** * Implementation of hook_perm(). */ function theme_editor_perm() { $perm[] = 'access Theme Editor for all themes'; $perm[] = 'Add new files to themes'; $perm[] = 'Delete files from themes'; $perm[] = 'Edit theme .info files'; $perm[] = 'Edit PHP based files'; $perm[] = 'access Theme Editor for Default theme'; foreach (list_themes() as $theme) { $perm[] = 'use Theme Editor for '.$theme->info['name']; } return $perm; } /** * Implementation of hook_menu(). */ function theme_editor_menu() { $i=0; $items = array(); $items['theme_editor/js'] = array( 'page callback' => 'theme_editor_js', 'access arguments' => array('Add new files to themes'), 'type' => MENU_CALLBACK, 'file'=>'theme_editor.inc', ); $items['admin/settings/theme_editor'] = array( 'title' => 'Theme Editor', 'description' => 'Theme Editor settings.', 'page callback' => 'drupal_get_form', 'page arguments' => array('theme_editor_settings'), 'access arguments' => array('administer site configuration'), 'file'=>'theme_editor.inc', ); foreach (list_themes() as $theme) { if ($i==0) { $access_theme =_theme_editor_access($theme); if ($access_theme != false) { $items['admin/build/themes/editor/'. $theme->name] = array( 'title' => $theme->info['name'].' Editor', 'page callback'=> 'theme_editor_editor', 'page arguments' => array($theme), 'type' => MENU_DEFAULT_LOCAL_TASK, 'access callback' => '_theme_editor_access', 'access arguments' => array($theme), 'file'=>'theme_editor.inc', ); $items['admin/build/themes/editor'] = array( 'title' => 'Theme Editor', 'type' => MENU_LOCAL_TASK, 'page callback'=> 'theme_editor_editor', 'page arguments' => array($theme), 'access arguments' => array($theme), 'access callback' => '_theme_editor_access', 'file'=>'theme_editor.inc', ); $i=1; } else { $items['admin/build/themes/editor/'. $theme->name] = array( 'title' => $theme->info['name'].' Editor', 'page callback'=> 'theme_editor_editor', 'page arguments' => array($theme), 'type' => MENU_LOCAL_TASK, 'access callback' => '_theme_editor_access', 'access arguments' => array($theme), 'file'=>'theme_editor.inc', ); } } else { $items['admin/build/themes/editor/'. $theme->name] = array( 'title' => $theme->info['name'].' Editor', 'page callback'=> 'theme_editor_editor', 'page arguments' => array($theme), 'type' => MENU_LOCAL_TASK, 'access callback' => '_theme_editor_access', 'access arguments' => array($theme), 'file'=>'theme_editor.inc', ); } } return $items; } /** * Menu item access callback . */ function _theme_editor_access($theme) { if (!user_access('access Theme Editor for all themes')) { if (variable_get('theme_default', NULL) == $theme->name) { if (!user_access('access Theme Editor for Default theme')) { return user_access('use Theme Editor for '.$theme->info['name']); } else { return user_access('access Theme Editor for Default theme'); } } else { return user_access('use Theme Editor for '.$theme->info['name']); } } else { return user_access('access Theme Editor for all themes'); } }