public
Description: Git mirror of the CMS Made Simple 2.0 rewrite
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsmadesimple-2-0.git
cmsmadesimple-2-0 / scripts / findtranslatetags.php
100644 57 lines (50 sloc) 1.569 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
 
function searchdir ( $path , $maxdepth = -1 , $mode = "FULL" , $d = 0 )
{
   if ( substr ( $path , strlen ( $path ) - 1 ) != '/' ) { $path .= '/' ; }
   $dirlist = array () ;
   if ( $mode != "FILES" ) { $dirlist[] = $path ; }
   if ( $handle = opendir ( $path ) )
   {
       while ( false !== ( $file = readdir ( $handle ) ) )
       {
           if ( $file != '.' && $file != '..' )
           {
               $file = $path . $file ;
               if ( ! is_dir ( $file ) ) { if ( $mode != "DIRS" ) { $dirlist[] = $file ; } }
               elseif ( $d >=0 && ($d < $maxdepth || $maxdepth < 0) )
               {
                   $result = searchdir ( $file . '/' , $maxdepth , $mode , $d + 1 ) ;
                   $dirlist = array_merge ( $dirlist , $result ) ;
               }
       }
       }
       closedir ( $handle ) ;
   }
   if ( $d == 0 ) { natcasesort ( $dirlist ) ; }
   return ( $dirlist ) ;
}
 
include('../lib/cmsms.api.php');
 
$dir = "../install/";
$arDirTree = searchdir($dir, -1, 'FILES');
$strings = array();
foreach ($arDirTree as $onefile)
{
  if (endswith($onefile, '.tpl') || endswith($onefile, '.php'))
  {
    $file = file_get_contents($onefile);
    preg_match_all("/_\(['\"]?(.+?)['\"]?\)/", $file, $matches);
    if (empty($matches[1]))
      preg_match_all("/\{translate\}(.+?)\{\/translate\}/", $file, $matches);
 
    if (isset($matches[1]) && is_array($matches[1]))
    {
      foreach ($matches[1] as $onestring)
      {
        if (!in_array($onestring, $strings, TRUE))
          $strings[] = $onestring;
      }
    }
  }
}
 
var_dump($strings);
 
?>