function test_natcasesort_filenames()
 {
     $filenames = array(2 => 'hoge/', 3 => 'hoge/hoge/moge', 5 => 'hoge/hoge', 6 => 'hogehoge', 7 => 'soge', 9 => 'hoge/hoge/hoge');
     sonots::natcasesort_filenames($filenames);
     $truth = array(2 => 'hoge/', 5 => 'hoge/hoge', 9 => 'hoge/hoge/hoge', 3 => 'hoge/hoge/moge', 6 => 'hogehoge', 7 => 'soge');
     $this->assertEqual($filenames, $truth);
 }
Ejemplo n.º 2
0
 /**
  * sort metapages by a meta
  *
  * @access public
  * @param string|null $meta meta name. 
  * @param boolean $reverse sort in reverse order
  * @version $Id: v 1.2 2008-06-10 07:23:17Z sonots $
  */
 function sort_by($meta, $reverse = false)
 {
     switch ($meta) {
         case 'name':
             $metas = $this->get_metas('relname');
             sonots::natcasesort_filenames($metas);
             break;
         case 'date':
             $metas = $this->get_metas('timestamp');
             arsort($metas, SORT_NUMERIC);
             break;
         case 'reading':
             $metas = $this->get_metas('reading');
             sonots::natcasesort_filenames($metas);
             break;
         case 'popular':
             $metas = $this->get_metas('popular');
             arsort($metas, SORT_NUMERIC);
             break;
         case 'title':
             $metas = $this->get_metas('title');
             $metas = array_map('make_link', $metas);
             $metas = array_map('strip_tags', $metas);
             $metas = array_map('trim', $metas);
             asort($metas, SORT_STRING);
             break;
         default:
             $metas = $this->get_metas($meta);
             asort($metas, SORT_STRING);
             break;
     }
     if ($reverse) {
         $metas = array_reverse($metas, true);
     }
     sonots::array_asort_key($this->metapages, $metas);
 }