! -> Note
$ -> Affected files
+06-Jan-2010 Janusz Dobrowolski
+# Check on existence of locale.inc added to avoid blank pages when the file is broken.
+$ /includes/session.inc
+! Changed reference incrementation algorithm to preserve both number prefix and postfix.
+$ /includes/references.inc
+
04-Jan-2010 Joe Hunt
! Making the stretch parameter = 1 on default print pdf all over
Improved layout on documents.
function increment($reference)
{
// New method done by Pete. So f.i. WA036 will increment to WA037 and so on.
- // If $reference is trailed by digits, and digits only,
- // extract them and add 1, then put the alpha prefix back on
+ // If $reference contains at least one group of digits,
+ // extract first didgits group and add 1, then put all together.
// NB. preg_match returns 1 if the regex matches completely
// also $result[0] holds entire string, 1 the first captured, 2 the 2nd etc.
- if (preg_match('/^(.*?)(\d+)$/', $reference, $result) == 1)
+ //
+ if (preg_match('/^(\D*?)(\d+)(.*)/', $reference, $result) == 1)
{
- $dig_count = strlen($result[2]); // How many digits? eg. 0003 = 4
- $fmt = '%0' . $dig_count . 'd'; // Make a format string - leading zeroes
- $nextval = $result[1] . sprintf($fmt, intval($result[2] + 1)); // Add one on, and put prefix back on
- return $nextval;
+ list($all, $prefix, $number, $postfix) = $result;
+ $dig_count = strlen($number); // How many digits? eg. 0003 = 4
+ $fmt = '%0' . $dig_count . 'd'; // Make a format string - leading zeroes
+ $nextval = sprintf($fmt, intval($number + 1)); // Add one on, and put prefix back on
+
+ return $prefix.$nextval.$postfix;
}
else
return $reference;
$_SESSION['language']->set_language($_SESSION['language']->code);
// include $Hooks object if locale file exists
-if(@include_once($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc"))
+if (file_exists($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc"))
{
+ include_once($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc");
$Hooks = new Hooks();
}