fixed location

This commit is contained in:
xdrm-brackets 2017-09-15 13:42:59 +02:00
parent 5dae2ef258
commit 62cb7facea
1 changed files with 7 additions and 4 deletions

View File

@ -70,7 +70,7 @@
} }
/* (5) Manage if empty */ /* (5) Manage if empty */
if( count($lines) < 2 ) if( count($lines) < 3 )
throw new \Exception("Nothing read"); throw new \Exception("Nothing read");
} }
@ -83,10 +83,10 @@
$title = $lines[0]; $title = $lines[0];
/* (2) Get last non-empty line */ /* (2) Get last non-empty line */
for( $i = count($lines)-1 ; $i > 0 ; $i-- ){ for( $i = 2 ; $i < count($lines) ; $i++ ){
// Amphi ... // // Amphi ... //
if( preg_match('@^a[nm]([bp][hln])?[ir] ?(.+)$@i', $lines[$i], $m) ) // 'amphi A', 'amphi 600 droit' if( preg_match('@^a[nm](?:[bp][hln])?[ir] ?(.+)$@i', $lines[$i], $m) ) // 'amphi A', 'amphi 600 droit'
return [ $title, "Amphi ${m[1]}" ]; return [ $title, "Amphi ${m[1]}" ];
@ -94,12 +94,15 @@
if( preg_match('@^[S|5] ?(\d+)@i', $lines[$i], $m) ) // 'S10', 'S22' if( preg_match('@^[S|5] ?(\d+)@i', $lines[$i], $m) ) // 'S10', 'S22'
return [ $title, "S. ${m[1]}" ]; return [ $title, "S. ${m[1]}" ];
// If not 'Cours', 'CTD', 'TD', 'TP' //
if( preg_match('@^(co[hu][trn][s5]|t[dp|c[mn]|ct[dp])@i', $lines[$i]) )
continue;
} }
} }
return [ $title, null ]; return [ $title, $lines[2] ];
} }