Drupal::Admin - screen scraping Perl API to some Drupal admin functions
use Drupal::Admin; my $admin = new Drupal::Admin(baseurl => 'http://localhost'); $admin->login(user => 'admin', password => 'lukeskywalker') $admin->offline; $admin->online; $admin->update; $admin->runcron; my $statusreport = $admin->status; my $status = $admin->enabletheme('garland, 0'); my $theme = $admin->defaulttheme('bluemarine');
Most of the methods in this class depend on English strings from the pages' value fields, because WWW:Mechanize doesn't use id fields as selectors. This module will most likely not work for sites that aren't in English.
Constructor takes required baseurl parameter (without a terminating slash).
Perform login to the site. Takes two required parameters, user and password. The user must have administrator privileges within drupal. Calls die() on error.
Take the site offline.
Bring the site online.
Runs the update.php script. Calls die() on error.
Returns a parsed status report. The returned data structure is of the form:
$report = { info => [], ok => [], warning => [], error => [] };
The elements of the arrays are Drupal::Admin::Status objects, which have the following read-only accessor methods:
info, ok, warning or error
info
ok
warning
error
Name of the status item
Status message
Additional comment (optional; warnings and errors usually have one)
Run the cron script once.
Enable/disable a theme. Takes theme name argument (as used in the form; this is generally a lowercase version of the user visible label), and optional boolean status argument. Returns current status.
Get/set default theme. Takes optional theme name argument. Returns current default theme. Note that setting a theme as default will automatically enable it.
Returns a Drupal::Admin::ModuleState object. See documentation in that module.
To install Drupal::Admin, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Drupal::Admin
CPAN shell
perl -MCPAN -e shell install Drupal::Admin
For more information on module installation, please visit the detailed CPAN module installation guide.