protected function _toSequenceString(array $ids)
{
if (empty($ids)) {
return '';
}
$in = $ids;
sort($in, SORT_NUMERIC);
$first = $last = array_shift($in);
$i = count($in) - 1;
$out = array();
reset($in);
while (list($key, $val) = each($in)) {
if ($last + 1 == $val) {
$last = $val;
}
if ($i == $key || $last != $val) {
if ($last == $first) {
$out[] = $first;
if ($i == $key) {
$out[] = $val;
}
} else {
$out[] = $first . ':' . $last;
if ($i == $key && $last != $val) {
$out[] = $val;
}
}
$first = $last = $val;
}
}
return empty($out) ? $first : implode(',', $out);
}