| 1 |
<?php |
| 2 |
|
| 3 |
function loading_page_get_screen_list() { |
| 4 |
$dir = LOADING_PAGE_PLUGIN_DIR . '/loading-screens'; |
| 5 |
$screens = array(); |
| 6 |
if ( file_exists( $dir ) ) { |
| 7 |
$d = dir( $dir ); |
| 8 |
while ( false !== ( $entry = $d->read() ) ) { |
| 9 |
if ( '.' !== $entry && '..' !== $entry && is_dir( $dir . '/' . $entry ) ) { |
| 10 |
$screen_dir = $dir . '/' . $entry . '/'; |
| 11 |
if ( file_exists( $screen_dir . 'config.ini' ) ) { |
| 12 |
$c = parse_ini_file( $screen_dir . 'config.ini', true ); |
| 13 |
if ( empty( $c ) ) { |
| 14 |
$c = parse_ini_string( file_get_contents( $screen_dir . 'config.ini' ), true ); |
| 15 |
} |
| 16 |
|
| 17 |
if ( ! empty( $c ) && ! empty( $c['script'] ) ) { |
| 18 |
$c['script'] = LOADING_PAGE_PLUGIN_URL . '/loading-screens/' . $entry . '/' . $c['script']; |
| 19 |
} |
| 20 |
|
| 21 |
if ( ! empty( $c ) && ! empty( $c['adminscript'] ) ) { |
| 22 |
$c['adminscript'] = LOADING_PAGE_PLUGIN_URL . '/loading-screens/' . $entry . '/' . $c['adminscript']; |
| 23 |
} |
| 24 |
|
| 25 |
if ( ! empty( $c ) && ! empty( $c['adminsection'] ) ) { |
| 26 |
$c['adminsection'] = LOADING_PAGE_PLUGIN_DIR . '/loading-screens/' . $entry . '/' . $c['adminsection']; |
| 27 |
} |
| 28 |
|
| 29 |
if ( ! empty( $c ) && ! empty( $c['style'] ) ) { |
| 30 |
$c['style'] = LOADING_PAGE_PLUGIN_URL . '/loading-screens/' . $entry . '/' . $c['style']; |
| 31 |
} |
| 32 |
|
| 33 |
$screens[] = $c; |
| 34 |
|
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
$d->close(); |
| 39 |
} |
| 40 |
|
| 41 |
return $screens; |
| 42 |
} |
| 43 |
|
| 44 |
function loading_page_get_screen( $id ) { |
| 45 |
$screens = loading_page_get_screen_list(); |
| 46 |
if ( ! empty( $screens ) ) { |
| 47 |
foreach ( $screens as $s ) { |
| 48 |
if ( $s['id'] == $id ) { |
| 49 |
return $s; |
| 50 |
} |
| 51 |
} |
| 52 |
return $screens[0]; |
| 53 |
} |
| 54 |
return false; |
| 55 |
} |
| 56 |
|