public function delete($reason = null, $archivename = null)
{
$data = array('title' => 'File:' . $this->filename, 'token' => $this->edittoken);
// Set options from arguments
if (!is_null($reason)) {
$data['reason'] = $reason;
}
if (!is_null($archivename)) {
$data['oldimage'] = $archivename;
}
$r = $this->wikimate->delete($data);
// The delete query
// Check if it worked
if (isset($r['delete'])) {
if (is_null($archivename)) {
$this->exists = false;
// The file was deleted altogether
}
$this->error = null;
// Reset the error status
return true;
}
$this->error = $r['error'];
// Return error response
return false;
}