forked from skryvets/Wordpress-Bootstrap-Dictionary-Theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dictionaries-exp.php
70 lines (67 loc) · 2.31 KB
/
dictionaries-exp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php /* Template Name: Dictionaries Page */ ?>
<?php get_header(); ?>
<?php
function str_split_unicode( $str, $l = 0 ) {
if ( $l > 0 ) {
$ret = array();
$len = mb_strlen( $str, "UTF-8" );
for ( $i = 0; $i < $len; $i += $l ) {
$ret[] = mb_substr( $str, $i, $l, "UTF-8" );
}
return $ret;
}
return preg_split( "//u", $str, - 1, PREG_SPLIT_NO_EMPTY );
}
?>
<?php
$belarussian_alphabet = array( 'А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'І', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ў', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Ы', 'Ь', 'Э', 'Ю', 'Я' );
?>
<div class="container">
<div class="row main-container">
<?php get_search_form(); ?>
<div class="main-content">
<div class="col-md-9">
<?php get_template_part( 'navigation' ) ?>
<div class="middle-content">
<?php
$letters = array();
query_posts( 'posts_per_page=500&order=asc' );
if ( have_posts() ) : while ( have_posts() ) : the_post();
$current_title = the_title( '', '', false );
$title_arr = str_split_unicode( $current_title );
for ( $i = 0; $i <= sizeof( $belarussian_alphabet ); $i ++ ) {
if ( strcmp( $title_arr[0], $belarussian_alphabet[ $i ] ) == 0 ) {
echo 'Found matching on ' . $belarussian_alphabet[ $i ] . ' in ' . $current_title;
echo "<br>";
if ( ! in_array( $belarussian_alphabet[ $i ], $letters ) ) {
array_push( $letters, $belarussian_alphabet[ $i ] );
}
}
}
endwhile;
endif;
// print_r( $current_title );
// print_r(mb_strlen($current_title));
echo "<br>";
$is_active = false;
for ( $i = 0; $i <= sizeof( $belarussian_alphabet ); $i ++ ) {
for ( $j = 0; $j <= sizeof( $letters ) - 1; $j ++ ) {
if ( strcmp( $belarussian_alphabet[ $i ], $letters[ $j ] ) == 0 ) {
$is_active = true;
}
}
if ( $is_active == true ) {
?><a href="#" class="active" style="color:red;"><?php echo $belarussian_alphabet[ $i ] ?></a><?php
$i = $i + 1;
}
?><a><?php echo $belarussian_alphabet[ $i ] ?></a><?php
$is_active = false;
}
?>
</div>
</div>
<?php get_sidebar(); ?>
</div><!--.main-content-->
</div><!--.main-container-->
</div>
<?php get_footer(); ?>