function superfish_menu_settings_validate in Superfish 6
Implements hook_validate().
File
- ./
superfish.admin.inc, line 78 - Functions that are only called on the admin pages.
Code
function superfish_menu_settings_validate($form, &$form_state) {
$error = array();
// Removing blank lines and white spaces.
$sf_library = preg_replace("/(^[\r\n]*|[\r\n]+)[\\s\t]*[\r\n]+/", "\n", trim($form_state['values']['superfish_slp']));
if (empty($sf_library)) {
form_set_error('superfish_slp', t('<strong>Path to Superfish library</strong> field cannot be empty. Please try the below list:') . '<br /><pre>' . superfish_library_path() . '</pre>');
}
else {
// Trimming blank lines and such.
$sf_library = explode("\n", $sf_library);
// Crystal clear.
foreach ($sf_library as $s) {
if (!file_exists($s)) {
$error[] = $s;
}
}
if (!empty($error)) {
$error_message = '';
if (count($error) > 1) {
foreach ($error as $e) {
$error_message .= '<li>' . $e . '</li>';
}
$error_message = t('Files not found') . ': <ul>' . $error_message . '</ul>';
}
else {
$error_message = t('File not found') . ': ' . $error[0];
}
form_set_error('superfish_slp', $error_message);
}
}
}