function apachesolr_confgen_parse_properties in Apache Solr Config Generator 7
Same name and namespace in other branches
- 6 apachesolr_confgen.admin.inc \apachesolr_confgen_parse_properties()
Parse Java properties file.
"Is this source free for commercial and non commercial use?" "Yes, you can copy and paste it. I am glad that it helped someone out."
Parameters
$txtProperties:
Return value
array
See also
http://blog.rafaelsanches.com/2009/08/05/reading-java-style-properties-f...
1 call to apachesolr_confgen_parse_properties()
- apachesolr_confgen_form_validate in ./
apachesolr_confgen.admin.inc - Implements hook_form_validate().
File
- ./
apachesolr_confgen.admin.inc, line 160 - Schema generator
Code
function apachesolr_confgen_parse_properties($txtProperties) {
$result = array();
$lines = explode("\n", $txtProperties);
$key = '';
$isWaitingOtherLine = FALSE;
$value = '';
foreach ($lines as $i => $line) {
if (empty($line) || !$isWaitingOtherLine && strpos($line, '#') === 0) {
continue;
}
if (!$isWaitingOtherLine) {
$key = substr($line, 0, strpos($line, '='));
$value = substr($line, strpos($line, '=') + 1, strlen($line));
}
else {
$value .= $line;
}
/* Check if ends with single '\' */
if (strrpos($value, "\\") === strlen($value) - strlen("\\")) {
$value = substr($value, 0, strlen($value) - 1) . "\n";
$isWaitingOtherLine = TRUE;
}
else {
$isWaitingOtherLine = FALSE;
}
$result[$key] = $value;
unset($lines[$i]);
}
return $result;
}