| | 611 | =head2 numify |
|---|
| | 612 | |
|---|
| | 613 | Adds commas to a number. Converting "12345" into "12,345" for instance. |
|---|
| | 614 | The argument for the numify attribute is the separator character to use |
|---|
| | 615 | (ie, "," or "."); "," is the default. |
|---|
| | 616 | |
|---|
| | 617 | =cut |
|---|
| | 618 | |
|---|
| | 619 | sub _fltr_numify { |
|---|
| | 620 | my ($str, $arg, $ctx) = @_; |
|---|
| | 621 | $arg = ',' if (!defined $arg) || ($arg eq '1'); |
|---|
| | 622 | $str =~ s/(^[â+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1$arg/g; |
|---|
| | 623 | return $str; |
|---|
| | 624 | } |
|---|
| | 625 | |
|---|
| | 626 | ########################################################################### |
|---|
| | 627 | |
|---|
| 1111 | | $replace =~ s!\\\\(\d+)!\$$1!g; # for php, \\1 is how you write $1 |
|---|
| 1112 | | if ($global) { |
|---|
| 1113 | | $str =~ s/$re/$replace/g; |
|---|
| 1114 | | my @matches = ($&, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20); |
|---|
| 1115 | | $str =~ s/\$(\d+)/$matches[$1]/g; |
|---|
| 1116 | | } else { |
|---|
| 1117 | | $str =~ s/$re/$replace/; |
|---|
| 1118 | | my @matches = ($&, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20); |
|---|
| 1119 | | $str =~ s/\$(\d+)/$matches[$1]/g; |
|---|
| | 1129 | $replace =~ s!\\\\(\d+)!\$1!g; # for php, \\1 is how you write $1 |
|---|
| | 1130 | $replace =~ s!/!\\/!g; |
|---|
| | 1131 | eval '$str =~ s/$re/' . $replace . '/' . ($global ? 'g' : ''); |
|---|
| | 1132 | if ($@) { |
|---|
| | 1133 | return $ctx->error("Invalid regular expression: $@"); |
|---|
| 12032 | | my @args = ( |
|---|
| 12033 | | { blog_id => $cat->blog_id, |
|---|
| 12034 | | status => MT::Entry::RELEASE() }, |
|---|
| 12035 | | { 'join' => [ 'MT::Placement', 'entry_id', |
|---|
| 12036 | | { category_id => $cat->id } ], |
|---|
| 12037 | | 'sort' => 'authored_on', |
|---|
| 12038 | | direction => 'descend', }); |
|---|
| 12039 | | $ctx->{__stash}{category_count} = $entry_class->count(@args); |
|---|
| | 12057 | $ctx->{__stash}{category_count} = $counts{$cat->id}; |
|---|