public function testSfCutString_三点リーダ付加指定がない場合_付加されない()
 {
     $input = 'hello, world';
     $this->expected = 'hello';
     $this->actual = SC_Utils::sfCutString($input, 5, true, false);
     $this->verify();
 }
Ejemplo n.º 2
0
 function sfGetFileList($dir)
 {
     $arrFileList = array();
     $arrDirList = array();
     if (is_dir($dir)) {
         if ($dh = opendir($dir)) {
             $cnt = 0;
             // 行末の/を取り除く
             while (($file = readdir($dh)) !== false) {
                 $arrDir[] = $file;
             }
             $dir = ereg_replace("/\$", "", $dir);
             // アルファベットと数字でソート
             natcasesort($arrDir);
             foreach ($arrDir as $file) {
                 // ./ と ../を除くファイルのみを取得
                 if ($file != "." && $file != "..") {
                     $path = $dir . "/" . $file;
                     // SELECT内の見た目を整えるため指定文字数で切る
                     $file_name = SC_Utils::sfCutString($file, FILE_NAME_LEN);
                     $file_size = SC_Utils::sfCutString(SC_Utils::sfGetDirSize($path), FILE_NAME_LEN);
                     $file_time = date("Y/m/d", filemtime($path));
                     // ディレクトリとファイルで格納配列を変える
                     if (is_dir($path)) {
                         $arrDirList[$cnt]['file_name'] = $file;
                         $arrDirList[$cnt]['file_path'] = $path;
                         $arrDirList[$cnt]['file_size'] = $file_size;
                         $arrDirList[$cnt]['file_time'] = $file_time;
                         $arrDirList[$cnt]['is_dir'] = true;
                     } else {
                         $arrFileList[$cnt]['file_name'] = $file;
                         $arrFileList[$cnt]['file_path'] = $path;
                         $arrFileList[$cnt]['file_size'] = $file_size;
                         $arrFileList[$cnt]['file_time'] = $file_time;
                         $arrFileList[$cnt]['is_dir'] = false;
                     }
                     $cnt++;
                 }
             }
             closedir($dh);
         }
     }
     // フォルダを先頭にしてマージ
     return array_merge($arrDirList, $arrFileList);
 }