示例#1
0
 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();
 }
示例#2
0
        if (count($oldssids)) {
            Database::get()->query('DELETE FROM ebook_subsection WHERE id IN (' . implode(', ', $oldssids) . ')');
        }
    }
    Session::Messages($langEBookSectionsModified, 'alert-success');
    redirect_to_home_page('modules/ebook/edit.php?course=' . $course_code . '&id=' . $ebook_id);
} else {
    $info = Database::get()->querySingle("SELECT * FROM `ebook` WHERE course_id = ?d AND id = ?d", $course_id, $ebook_id);

    if (!$info) {
        $tool_content .= "<div class='alert alert-warning'>$langNoEBook</div>";
    } else {
        $pageName = $langEBookEdit;
        $basedir = $webDir . '/courses/' . $course_code . '/ebook/' . $ebook_id;
        $k = 0;
        list($paths, $files, $file_ids, $id_map) = find_html_files();

        $sections = Database::get()->queryArray("SELECT id, public_id, title FROM ebook_section
                           WHERE ebook_id = ?d
                           ORDER BY CONVERT(public_id, UNSIGNED), public_id", $info->id);
        if ($sections){
            
            $sections_table = "<ul class='list-group'>";
            foreach ($sections as $section){
                $sections_table .=
                        "
                        <li class='list-group-item'>
                            ".q($section->public_id).".&nbsp;
                            ".q($section->title)."    
                        </li>
                        ";
示例#3
0
 /**
  * Find all application templates key path
  *
  * @return array
  */
 function find_templates()
 {
     if (!defined('BASE_PATH')) {
         define('BASE_PATH', realpath(__DIR__ . '/../../'));
     }
     $getTemplateKeyPath = function ($suffix) {
         $basePath = BASE_PATH . '/' . trim($suffix, '/') . '/';
         return array_map(function ($path) use($basePath) {
             return substr($path, strlen($basePath));
         }, find_html_files($basePath, true));
     };
     return array_merge($getTemplateKeyPath('/app/templates/'), $getTemplateKeyPath('/app/core-ui'));
 }