MDL-42671 EditPDF: Disable EditPDF is zlib is not available

Also put a warning on the admin page if this is the case.
This commit is contained in:
Damyon Wiese 2013-11-05 23:30:28 +08:00
parent 61bac37cf1
commit 237f484188
4 changed files with 80 additions and 2 deletions

View file

@ -8553,3 +8553,68 @@ class admin_setting_configmultiselect_modules extends admin_setting_configmultis
return true;
}
}
/**
* Admin setting to show if a php extension is enabled or not.
*
* @copyright 2013 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class admin_setting_php_extension_enabled extends admin_setting {
/** @var string The name of the extension to check for */
private $extension;
/**
* Calls parent::__construct with specific arguments
*/
public function __construct($name, $visiblename, $description, $extension) {
$this->extension = $extension;
$this->nosave = true;
parent::__construct($name, $visiblename, $description, '');
}
/**
* Always returns true, does nothing
*
* @return true
*/
public function get_setting() {
return true;
}
/**
* Always returns true, does nothing
*
* @return true
*/
public function get_defaultsetting() {
return true;
}
/**
* Always returns '', does not write anything
*
* @return string Always returns ''
*/
public function write_setting($data) {
// Do not write any setting.
return '';
}
/**
* Outputs the html for this setting.
* @return string Returns an XHTML string
*/
public function output_html($data, $query='') {
global $OUTPUT;
$o = '';
if (!extension_loaded($this->extension)) {
$warning = $OUTPUT->pix_icon('i/warning', '', '', array('role' => 'presentation')) . ' ' . $this->description;
$o .= format_admin_setting($this, $this->visiblename, $warning);
}
return $o;
}
}