Skip to content

Commit

Permalink
MDL-12794 admin setting for file location; merged from MOODLE_19_STABLE
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jan 1, 2008
1 parent 3e47599 commit e9c0fa3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
51 changes: 32 additions & 19 deletions lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1788,25 +1788,25 @@ function output_html($data, $query='') {
}

/**
* Path to executable file
* Path to directory
*/
class admin_setting_configexecutable extends admin_setting_configtext {
class admin_setting_configfile extends admin_setting_configtext {
/**
* Constructor
* @param string $name of setting
* @param string $visiblename localised
* @param string $description long localised info
* @param string $defautpath default path
* @param string $defaultdirectory default directory location
*/
function admin_setting_configexecutable($name, $visiblename, $description, $defaultpath) {
parent::admin_setting_configtext($name, $visiblename, $description, $defaultpath, PARAM_RAW);
function admin_setting_configfile($name, $visiblename, $description, $defaultdirectory) {
parent::admin_setting_configtext($name, $visiblename, $description, $defaultdirectory, PARAM_RAW);
}

function output_html($data, $query='') {
$default = $this->get_defaultsetting();

if ($data) {
if (file_exists($data) and is_executable($data)) {
if (file_exists($data)) {
$executable = '<span class="pathok">&#x2714;</span>';
} else {
$executable = '<span class="patherror">&#x2718;</span>';
Expand All @@ -1816,26 +1816,39 @@ function output_html($data, $query='') {
}

return format_admin_setting($this, $this->visiblename,
'<div class="form-executable defaultsnext"><input type="text" id="'.$this->get_id().'" name="'.$this->get_full_name().'" value="'.s($data).'" />'.$executable.'</div>',
'<div class="form-file defaultsnext"><input type="text" id="'.$this->get_id().'" name="'.$this->get_full_name().'" value="'.s($data).'" />'.$executable.'</div>',
$this->description, true, '', $default, $query);
}
}

/**
* Path to directory
* Path to executable file
*/
class admin_setting_configdirectory extends admin_setting_configtext {
/**
* Constructor
* @param string $name of setting
* @param string $visiblename localised
* @param string $description long localised info
* @param string $defaultdirectory default directory location
*/
function admin_setting_configdirectory($name, $visiblename, $description, $defaultdirectory) {
parent::admin_setting_configtext($name, $visiblename, $description, $defaultdirectory, PARAM_RAW);
class admin_setting_configexecutable extends admin_setting_configfile {

function output_html($data, $query='') {
$default = $this->get_defaultsetting();

if ($data) {
if (file_exists($data) and is_executable($data)) {
$executable = '<span class="pathok">&#x2714;</span>';
} else {
$executable = '<span class="patherror">&#x2718;</span>';
}
} else {
$executable = '';
}

return format_admin_setting($this, $this->visiblename,
'<div class="form-file defaultsnext"><input type="text" id="'.$this->get_id().'" name="'.$this->get_full_name().'" value="'.s($data).'" />'.$executable.'</div>',
$this->description, true, '', $default, $query);
}
}

/**
* Path to directory
*/
class admin_setting_configdirectory extends admin_setting_configfile {
function output_html($data, $query='') {
$default = $this->get_defaultsetting();

Expand All @@ -1850,7 +1863,7 @@ function output_html($data, $query='') {
}

return format_admin_setting($this, $this->visiblename,
'<div class="form-directory defaultsnext"><input type="text" id="'.$this->get_id().'" name="'.$this->get_full_name().'" value="'.s($data).'" />'.$executable.'</div>',
'<div class="form-file defaultsnext"><input type="text" id="'.$this->get_id().'" name="'.$this->get_full_name().'" value="'.s($data).'" />'.$executable.'</div>',
$this->description, true, '', $default, $query);
}
}
Expand Down
3 changes: 1 addition & 2 deletions theme/standard/styles_layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -1062,8 +1062,7 @@ body#admin-modules table.generaltable td.c0
width: 5em;
}

#adminsettings .form-executable input,
#adminsettings .form-directory input {
#adminsettings .form-file input {
width: 30em;
}

Expand Down

0 comments on commit e9c0fa3

Please sign in to comment.