本文整理汇总了PHP中admin_setting_configtext::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP admin_setting_configtext::validate方法的具体用法?PHP admin_setting_configtext::validate怎么用?PHP admin_setting_configtext::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类admin_setting_configtext
的用法示例。
在下文中一共展示了admin_setting_configtext::validate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate($data)
{
global $PAGE;
// Don't force the plugin to be fully set up when installing.
if ($PAGE->pagelayout === 'maintenance' && strlen($data) === 0) {
return true;
}
return parent::validate($data);
}
示例2: validate
/**
* Validate data.
*
* @param string $data
* @return mixed True on success, else error message
*/
public function validate($data)
{
$result = parent::validate($data);
if ($result !== true) {
return $result;
}
if ((int) $data < 1) {
return get_string('awaittimeerror', 'realtimequiz');
}
return true;
}
示例3: validate
/**
* Validate data.
*
* This ensures that key ID is specified if URL is provided
*
* @param string $data
* @return mixed True on success, else error message.
*/
public function validate($data)
{
$result = parent::validate($data);
if ($result !== true) {
return $result;
}
$url = get_config('filter_cloudfront_signurl', 'distributionurl');
if ($url != '' && empty($data)) {
return get_string('errornokeyid', 'filter_cloudfront_signurl');
}
return true;
}
示例4: validate
/**
* Validate data before storage
* @param string data
* @return mixed true if ok string if error found
*/
public function validate($data)
{
$validated = parent::validate($data);
// Pass parent validation first.
if ($validated == true) {
$matches = preg_match($this->regex, $data);
if ($matches === false) {
$validated = 'preg_match() error.';
} else {
if ($matches == 0) {
$validated = '\'' . $data . '\'' . $this->error;
}
}
}
return $validated;
}
示例5: validate
/**
* Validate data before storage
* @param string data
* @return mixed true if ok string if error found
*/
public function validate($data)
{
$validated = parent::validate($data);
// Pass parent validation first.
if ($validated == true) {
if ($data < $this->lower) {
$validated = get_string('asconfigintlower', 'theme_essential', array('value' => $data, 'lower' => $this->lower));
} else {
if ($data > $this->upper) {
$validated = get_string('asconfigintupper', 'theme_essential', array('value' => $data, 'upper' => $this->upper));
} else {
$validated = true;
}
}
}
return $validated;
}
示例6: validate
/**
* Validate data.
*
* This ensures that unix socket setting is correct and ClamAV is running.
*
* @param string $data
* @return mixed True on success, else error message.
*/
public function validate($data)
{
$result = parent::validate($data);
if ($result !== true) {
return $result;
}
$runningmethod = get_config('antivirus_clamav', 'runningmethod');
if ($runningmethod === 'unixsocket') {
$socket = stream_socket_client('unix://' . $data, $errno, $errstr, ANTIVIRUS_CLAMAV_SOCKET_TIMEOUT);
if (!$socket) {
return get_string('errorcantopensocket', 'antivirus_clamav', "{$errstr} ({$errno})");
} else {
// Send PING query to ClamAV socket to check its running state.
fwrite($socket, "nPING\n");
$response = stream_get_line($socket, 4);
fclose($socket);
if ($response !== 'PONG') {
return get_string('errorclamavnoresponse', 'antivirus_clamav');
}
}
}
return true;
}
示例7: validate
/**
* Validate data before storage
*
* @param string $data data
* @return mixed true if ok string if error found
*/
public function validate($data)
{
$parentvalidation = parent::validate($data);
if ($parentvalidation === true) {
if ($this->maxlength > 0) {
// Max length check.
$length = core_text::strlen($data);
if ($length > $this->maxlength) {
return get_string('maximumchars', 'moodle', $this->maxlength);
}
return true;
} else {
return true;
// No max length check needed.
}
} else {
return $parentvalidation;
}
}
示例8: validate
/**
* Validate data.
*
* This ensures that license key is specified for any hosting mode.
*
* @param string $data
* @return mixed True on success, else error message.
*/
public function validate($data)
{
$result = parent::validate($data);
if ($result !== true) {
return $result;
}
if (empty($data)) {
return get_string('errornolicensekey', 'filter_jwplayer');
}
return true;
}
示例9: validate
/**
* Validate data.
*
* This ensures that account token is specified if cloud-hosted player is
* selected.
*
* @param string $data
* @return mixed True on success, else error message.
*/
public function validate($data)
{
$result = parent::validate($data);
if ($result !== true) {
return $result;
}
$hostingmethod = get_config('filter_jwplayer', 'hostingmethod');
if ($hostingmethod === 'cloud' && empty($data)) {
return get_string('errornoaccounttoken', 'filter_jwplayer');
}
return true;
}