public function testFindFiles()
 {
     $this->createTempFiles();
     $path = $this->path;
     $filesFound = find_files($path, 0, '*');
     $this->assertSame(7, count($filesFound));
     $jsFilesFound = find_js_files($path);
     $this->assertSame(2, count($jsFilesFound));
     $htmlFilesFound = find_html_files($path);
     $this->assertSame(2, count($htmlFilesFound));
     $phpFilesFound = find_php_files($path);
     $this->assertSame(2, count($phpFilesFound));
     // Including subdirectories
     $filesFound = find_files($path, 0, '*', true);
     $this->assertSame(10, count($filesFound));
     $jsFilesFound = find_js_files($path, true);
     $this->assertSame(3, count($jsFilesFound));
     $htmlFilesFound = find_html_files($path, true);
     $this->assertSame(3, count($htmlFilesFound));
     $phpFilesFound = find_php_files($path, true);
     $this->assertSame(3, count($phpFilesFound));
     $this->assertInternalType('array', find_templates());
     $this->removeTempFiles();
 }
Beispiel #2
0
 $template = @$_POST['template'];
 $files = array();
 $r = explode("\n", $_POST['files']);
 foreach ($r as $f) {
     $f = trim($f);
     if (!empty($f)) {
         if (!file_exists($f)) {
             $f = _ROOT . $f;
         }
         if (file_exists($f)) {
             if (is_file($f)) {
                 if (preg_match('~\\.html\\.php$~s', $f)) {
                     $files[] = $f;
                 }
             } else {
                 $r2 = find_templates($f);
                 if (!empty($r2)) {
                     $files = array_merge($files, $r2);
                 }
             }
         }
     }
 }
 if (empty($files)) {
     echo 'no file template is found!';
 } else {
     $header = array('<label><input type="checkbox" onclick="$(\'.fls\').prop(\'checked\', this.checked);" checked="checked"> Files</label>', '<label><input type="checkbox" onclick="$(\'.ovwt\').prop(\'checked\', this.checked);"> Overwrite</label>');
     $data = array();
     $forms = '';
     foreach ($files as $i => $file) {
         $f = preg_replace('~^' . preg_quote(_ROOT, '~') . '~s', '', $file);