# script_grav_desc()
sub script_grav_desc
{
return "Grav";
}
sub script_grav_uses
{
return ( "php" );
}
sub script_grav_longdesc
{
return "";
}
# script_grav_versions()
sub script_grav_versions
{
return ( "1.6.21" );
}
# script_grav_depends(&domain, version)
sub script_grav_depends
{
local ($d, $ver, $sinfo, $phpver) = @_;
local @rv;
# Check for PHP 7.1.3+
local $phpv = &get_php_version($phpver || 5, $d);
if (!$phpv) {
push(@rv, "Could not work out exact PHP version");
}
elsif (&compare_versions($phpv, "7.1.3") < 0) {
push(@rv, "Grav requires PHP version 7.1.3 or later");
}
return @rv;
}
sub script_grav_php_vers
{
local ($d, $ver) = @_;
return ( 5 );
}
sub script_ajaxplorer_php_modules
{
return ( "mbstring", "dom", "xml", "curl" );
}
# script_grav_params(&domain, version, &upgrade-info)
# Returns HTML for table rows for options for installing PHP-NUKE
sub script_grav_params
{
local ($d, $ver, $upgrade) = @_;
local $rv;
local $hdir = &public_html_dir($d, 1);
if ($upgrade) {
# Options are fixed when upgrading
local $dir = $upgrade->{'opts'}->{'dir'};
$dir =~ s/^$d->{'home'}\///;
$rv .= &ui_table_row("Install directory", $dir);
}
else {
# Show editable install options
$rv .= &ui_table_row("Install sub-directory under $hdir",
&ui_opt_textbox("dir", &substitute_scriptname_template("grav", $d), 30, "At top level"));
}
return $rv;
}
# script_grav_parse(&domain, version, &in, &upgrade-info)
# Returns either a hash ref of parsed options, or an error string
sub script_grav_parse
{
local ($d, $ver, $in, $upgrade) = @_;
if ($upgrade) {
# Options are always the same
return $upgrade->{'opts'};
}
else {
local $hdir = &public_html_dir($d, 0);
$in{'dir_def'} || $in{'dir'} =~ /\S/ && $in{'dir'} !~ /\.\./ ||
return "Missing or invalid installation directory";
local $dir = $in{'dir_def'} ? $hdir : "$hdir/$in{'dir'}";
return { 'dir' => $dir,
'path' => "/$in{'dir'}", };
}
}
# script_grav_check(&domain, version, &opts, &upgrade-info)
# Returns an error message if a required option is missing or invalid
sub script_grav_check
{
local ($d, $ver, $opts, $upgrade) = @_;
$opts->{'dir'} =~ /^\// || return "Missing or invalid install directory";
if (-r "$opts->{'dir'}/index.php") {
return "Grav appears to be already installed in the selected directory";
}
return undef;
}
# script_grav_files(&domain, version, &opts, &upgrade-info)
# Returns a list of files needed by Twiki, each of which is a hash ref
# containing a name, filename and URL
sub script_grav_files
{
local ($d, $ver, $opts, $upgrade) = @_;
local @files = ( { 'name' => "source",
'file' => "grav-admin-v${ver}.zip",
'url' => "https://getgrav.org/download/core/grav-admin/$ver" } );
return @files;
}
sub script_grav_commands
{
return ("unzip");
}
# script_grav_install(&domain, version, &opts, &files, &upgrade-info,
# [user, pass])
# Actually installs PhpWiki, and returns either 1 and an informational
# message, or 0 and an error
sub script_grav_install
{
local ($d, $version, $opts, $files, $upgrade, $domuser, $dompass) = @_;
local ($out, $ex);
# Extract tar file to temp dir and copy to target
local $temp = &transname();
local $err = &extract_script_archive($files->{'source'}, $temp, $d,
$opts->{'dir'}, "grav-admin");
$err && return (0, "Failed to extract source : $err");
local $url = &script_path_url($d, $opts);
local $rp = $opts->{'dir'};
$rp =~ s/^$d->{'home'}\///;
return (1, "Initial Grav installation complete. Go to $url to complete the installation process", "Under $rp", $url);
}
# script_grav_uninstall(&domain, version, &opts)
# Un-installs an Grav installation, by deleting the directory and database.
# Returns 1 on success and a message, or 0 on failure and an error
sub script_grav_uninstall
{
local ($d, $version, $opts) = @_;
# Remove the contents of the target directory
local $derr = &delete_script_install_directory($d, $opts);
return (0, $derr) if ($derr);
return (1, "Grav directory deleted.");
}
# script_grav_latest(version)
# Returns a URL and regular expression or callback func to get the version
sub script_grav_latest
{
local ($ver) = @_;
return ( "https://getgrav.org/downloads",
"Current Version: ([0-9\\.]+)" );
}
sub script_grav_site
{
return "https://getgrav.org/";
}
1;