function demo_set_info in Demonstration site (Sandbox / Snapshot) 7
Same name and namespace in other branches
- 8 demo.module \demo_set_info()
- 5 demo.admin.inc \demo_set_info()
- 6 demo.admin.inc \demo_set_info()
1 call to demo_set_info()
- _demo_dump in ./
demo.admin.inc - Create a new snapshot.
File
- ./
demo.admin.inc, line 560 - Demonstration Site administrative pages.
Code
function demo_set_info($values = NULL) {
if (isset($values['filename']) && is_array($values)) {
// Check for valid filename.
if (!preg_match('/^[-_\\.a-zA-Z0-9]+$/', $values['filename'])) {
drupal_set_message(t('Invalid filename. It must only contain alphanumeric characters, dots, dashes and underscores. Other characters, including spaces, are not allowed.'), 'error');
return FALSE;
}
if (!empty($values['description'])) {
// parse_ini_file() doesn't allow certain characters in description.
$s = array(
"\r\n",
"\r",
"\n",
'"',
);
$r = array(
' ',
' ',
' ',
"'",
);
$values['description'] = str_replace($s, $r, $values['description']);
}
else {
// If new description is empty, try to use previous description.
$old_file = demo_get_fileconfig($values['filename']);
$old_description = demo_get_info($old_file['infofile'], 'description');
if (!empty($old_description)) {
$values['description'] = $old_description;
}
}
// Set values.
$infos = array();
$infos['filename'] = $values['filename'];
$infos['description'] = '"' . $values['description'] . '"';
$infos['modules'] = implode(' ', module_list());
$infos['version'] = DEMO_DUMP_VERSION;
// Write information to .info file.
$fileconfig = demo_get_fileconfig($values['filename']);
$infofile = fopen($fileconfig['infofile'], 'w');
foreach ($infos as $key => $info) {
fwrite($infofile, $key . ' = ' . $info . "\n");
}
fclose($infofile);
return $infos;
}
}