-
- $ar = token_get_all(file_get_contents( $tmpl->currentTemplate ));
- foreach( $ar as $i=> $tok) {
- if (!is_array($tok) || $tok[0] != T_CONSTANT_ENCAPSED_STRING) {
- continue;
- }
- if ($i < 2) {
- continue;
- }
- if (is_array($ar[$i-1]) || $ar[$i-1] != '(') {
- continue;
- }
- if (!is_array($ar[$i-2]) || $ar[$i-2][1] != '_') {
- continue;
- }
- $ct = $tok[1][0];
- $words[] = str_replace('\\'. $ct, $ct, trim($tok[1] , $ct));
-
+
+ switch($filetype) {
+ case "php":
+ $ar = token_get_all(file_get_contents( $tmpl->currentTemplate ));
+ foreach( $ar as $i=> $tok) {
+ if (!is_array($tok) || $tok[0] != T_CONSTANT_ENCAPSED_STRING) {
+ continue;
+ }
+ if ($i < 2) {
+ continue;
+ }
+ if (is_array($ar[$i-1]) || $ar[$i-1] != '(') {
+ continue;
+ }
+ if (!is_array($ar[$i-2]) || $ar[$i-2][1] != '_') {
+ continue;
+ }
+ $ct = $tok[1][0];
+ $words[] = str_replace('\\'. $ct, $ct, trim($tok[1] , $ct));
+
+ }
+ break;
+ case "js":
+ $fc = file_get_contents( $tmpl->currentTemplate );
+
+ preg_match_all('/\._\("([^"]+)"\)/', $fc, $outd);
+ $words = $outd[1];
+
+ preg_match_all('/\._\(\'([^\']+)\'\)/', $fc, $outs);
+
+ // ?? seriously adding two arrays?
+ $words = array_diff(array_merge($words, $outs[1]), array_intersect($words, $outs[1]));
+ break;
+ case "xml":
+ $words = $pgdata['words'];
+ break;