Facebook
From Funky Mockingjay, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 189
  1. <?php /**
  2.  * Template name: Zadania
  3.  */
  4.  
  5. get_header();
  6.  
  7. if( isset($_GET['Kategoriazadan']) ||
  8.                 isset($_GET['Typzadan']) ||
  9.                 isset($_GET['Poziom']) ||
  10.                 isset($_GET['Rokmatury']) ||
  11.                 isset($_GET['Typmatury']) ||
  12.                 isset($_GET['Miesiacmatury']) ||
  13.                 isset($_GET['tryb'])
  14.                 ) {
  15.  
  16. $zadanie = -1;
  17.                 }else {
  18.                     $zadanie = 2;
  19.                 }
  20.  
  21. ?>
  22.  
  23.  
  24.  
  25. <div class="col-lg-3 col-sidebar">
  26.  
  27.     <div class="certificate-sidebar_toggle"><i class="fa fa-database" aria-hidden="true"></i></div>
  28.     <div class="certificate-sticky">
  29.         <form action="<?php echo esc_url(get_pagenum_link(1)); ?>" method="get">
  30.             <div class="certificate-sticky_header">
  31.                 <div class="certificate-sidebar_close"></div><?php the_field('mobile-filters-title'); ?>:
  32.             </div>
  33.             <div class="certificate-sidebar">
  34.                 <div class="certificate-sidebar_button">
  35.                     <a class="btn-primary" href="<?php the_field('core-curriculum-title-url'); ?>"><?php the_field('core-curriculum-title-text'); ?></a>
  36.                 </div>
  37.                 <div class="certificate-sidebar_widget-group">
  38.                     <div class="certificate-sidebar_widget">
  39.                         <div class="certificate-search">
  40.                          <input name="szukaj" type="search" placeholder="Szukane wyrażenie">
  41.  
  42.                          <?php
  43.                         $q1 = new WP_Query( array(
  44.                             'post_type' => 'zadania',
  45.  
  46.                             's' => 'rurce'
  47.                         ));
  48.  
  49.                         $q2 = new WP_Query( array(
  50.                             'post_type' => 'zadania',
  51.                        
  52.                             '"s" => "rurce"' => array(
  53.                                 'relation' => 'OR',
  54.                                 array(
  55.                                 'key' => 'post_title',
  56.                                 'value' => 'rurce',
  57.                                 'compare' => 'LIKE'
  58.                                 ),
  59.                                 array(
  60.                                     'key' => 'post_content',
  61.                                     'value' => 'rurce',
  62.                                     'compare' => 'LIKE'
  63.                                 )
  64.                             )
  65.                         ));
  66.  
  67.                         $result = new WP_Query();
  68.                         $result->posts = array_unique( array_merge( $q1->posts, $q2->posts ), SORT_REGULAR );
  69.                         $result->post_count = count( $result->posts );
  70.  
  71.                          ?>
  72.                             <?php //echo do_shortcode('[wpbsearch]'); ?>
  73.                         </div>
  74.                     </div>
  75.                     <div class="certificate-sidebar_widget">
  76.                         <h3 class="certificate-sidebar_widget-title">Kategorie zadań</h3>
  77.                         <div class="certificate-filter">
  78.                            
  79.                                 <?php
  80.                                 $terms = get_terms(
  81.                                     array(
  82.                                         'taxonomy'   => 'kategorie_zadan_taxonomy',
  83.                                         'hide_empty' => false,
  84.                                     )
  85.                                 );
  86.                                    
  87.                                     if ( ! empty( $terms ) && is_array( $terms ) ) {
  88.                                         foreach ( $terms as $term ) {
  89.                                             if($term->parent == 0) {
  90.                                     ?>
  91.                                                 <div class="certificate-filter_group">
  92.                                                     <div class="certificate-filter_item">
  93.                                                 <?php
  94.                                                     foreach ( $terms as $term1 ) {
  95.                                                         if($term1->parent == $term->term_id) {
  96.                                                     ?>
  97.                                                     <div class="certificate-filter_toggle"></div>
  98.                                                 <?php
  99.                                                 break;
  100.                                                         }
  101.                                                     }
  102.                                                     ?>
  103.                                                         <input name="<?php echo "Kategoriazadan[]"; ?>" value="<?php echo $term->slug; ?>" class="check-control" type="checkbox" id="certificateFilter<?php echo $term->slug.get_the_ID(); ?>" <?php if( isset($_GET['Kategoriazadan'])&& strlen(array_search($term->slug,$_GET['Kategoriazadan'])) > 0) echo 'checked'; ?>>
  104.                                                         <label class="check-control-label" for="certificateFilter<?php echo $term->slug.get_the_ID(); ?>"><?php echo $term->name; ?></label>
  105.                                                     </div>
  106.                                                         <?php
  107.  
  108.                                                             $counter = 0;
  109.                                                             foreach ( $terms as $term1 ) {
  110.                                                                 if($term1->parent == $term->term_id) {
  111.                                                                     if($counter == 0){
  112.                                                                     ?>
  113.                                                                         <div class="certificate-filter_collapse">
  114.                                                                             <div class="certificate-filter_group-inner">
  115.                                                                     <?php
  116.                                                                     }
  117.                                                         ?>
  118.                                                                     <div class="certificate-filter_item">
  119.                                                                         <input name="<?php echo "Kategoriazadan[]"; ?>" value="<?php echo $term1->slug; ?>" class="check-control" type="checkbox" id="certificateFilter<?php echo $term1->slug.get_the_ID(); ?>" <?php if( isset($_GET['Kategoriazadan'])&& strlen(array_search($term->slug,$_GET['Kategoriazadan'])) > 0) echo 'checked'; ?>>
  120.                                                                         <label class="check-control-label" for="certificateFilter<?php echo $term1->slug.get_the_ID(); ?>"><?php echo $term1->name; ?></label>
  121.                                                                     </div>
  122.                                                         <?php  
  123.                                                                 $counter++;
  124.                                                                 }
  125.                                                             }
  126.                                                         if($counter > 0){
  127.                                                         ?>
  128.                                                                             </div>
  129.                                                                         </div>
  130.                                                         <?php
  131.                                                         }
  132.                                                         ?>
  133.                                                 </div>
  134.                                         <?php
  135.                                             }
  136.                                         }
  137.                                     }
  138.                                 ?>
  139.                         </div>
  140.                     </div>
  141.                     <div class="certificate-sidebar_widget">
  142.                         <h3 class="certificate-sidebar_widget-title">Typ zadań</h3>
  143.                         <div class="certificate-check">
  144.                             <?php
  145.                                 $terms = get_terms(
  146.                                     array(
  147.                                         'taxonomy'   => 'typ_zadan_taxonomy',
  148.                                         'hide_empty' => false,
  149.                                     )
  150.                                 );
  151.                                 if ( ! empty( $terms ) && is_array( $terms ) ) {
  152.                                     foreach ( $terms as $term ) {
  153.                                         ?>
  154.                                     <div class="certificate-check_item">
  155.                                         <input name="<?php echo "Typzadan[]"; ?>" value="<?php echo $term->slug; ?>" class="check-control" type="checkbox" id="certificateType<?php echo $term->slug.get_the_ID(); ?>" <?php if( isset($_GET['Typzadan'])&& strlen(array_search($term->slug,$_GET['Typzadan'])) > 0) echo 'checked'; ?>>
  156.                                         <label class="check-control-label" for="certificateType<?php echo $term->slug.get_the_ID(); ?>"><?php echo $term->name; ?></label>
  157.                                     </div>
  158.                                         <?php
  159.                                     }
  160.                                 }
  161.                             ?>
  162.                         </div>
  163.                     </div>
  164.                     <div class="certificate-sidebar_widget">
  165.                         <h3 class="certificate-sidebar_widget-title">Poziom</h3>
  166.                         <div class="certificate-check">
  167.                             <?php
  168.                                 $terms = get_terms(
  169.                                     array(
  170.                                         'taxonomy'   => 'poziom_taxonomy',
  171.                                         'hide_empty' => false,
  172.                                     )
  173.                                 );
  174.                                 if ( ! empty( $terms ) && is_array( $terms ) ) {
  175.                                     foreach ( $terms as $term ) {
  176.                                         ?>
  177.                                         <div class="certificate-check_item">
  178.                                             <input name="<?php echo "Poziom[]"; ?>" value="<?php echo $term->slug; ?>" class="check-control" type="checkbox" id="certificateLevel<?php echo $term->slug.get_the_ID(); ?>" <?php if( isset($_GET['Poziom'])&& strlen(array_search($term->slug,$_GET['Poziom'])) > 0) echo 'checked'; ?>>
  179.                                             <label class="check-control-label" for="certificateLevel<?php echo $term->slug.get_the_ID(); ?>"><?php echo $term->name; ?></label>
  180.                                         </div>
  181.                                         <?php
  182.                                     }
  183.                                 }
  184.                             ?>
  185.                         </div>
  186.                     </div>
  187.                     <div class="certificate-sidebar_widget">
  188.                         <h3 class="certificate-sidebar_widget-title">Typ matury</h3>
  189.                         <div class="certificate-check">
  190.                             <?php
  191.                                 $terms = get_terms(
  192.                                     array(
  193.                                         'taxonomy'   => 'typ_matury_taxonomy',
  194.                                         'hide_empty' => false,
  195.                                     )
  196.                                 );
  197.                                 if ( ! empty( $terms ) && is_array( $terms ) ) {
  198.                                     foreach ( $terms as $term ) {
  199.                                         ?>
  200.                                         <div class="certificate-check_item">
  201.                                             <input name="<?php echo "Typmatury[]"; ?>" value="<?php echo $term->slug; ?>" class="check-control" type="checkbox" id="certificate<?php echo $term->slug.get_the_ID(); ?>" <?php if( isset($_GET['Typmatury'])&& strlen(array_search($term->slug,$_GET['Typmatury'])) > 0) echo 'checked'; ?>>
  202.                                             <label class="check-control-label" for="certificate<?php echo $term->slug.get_the_ID(); ?>"><?php echo $term->name; ?></label>
  203.                                         </div>
  204.                                         <?php
  205.                                     }
  206.                                 }
  207.                             ?>
  208.                         </div>
  209.                     </div>
  210.                     <div class="certificate-sidebar_widget">
  211.                         <h3 class="certificate-sidebar_widget-title">Rok matury</h3>
  212.                         <div class="certificate-check-group">
  213.                             <div class="certificate-check check-all-wrapper certificate-check_double">
  214.                                 <?php
  215.                                     $terms = get_terms(
  216.                                         array(
  217.                                             'taxonomy'   => 'rok_matury_taxonomy',
  218.                                             'hide_empty' => false,
  219.                                         )
  220.                                     );
  221.                                     if ( ! empty( $terms ) && is_array( $terms ) ) {
  222.                                         foreach ( $terms as $term ) {
  223.                                             ?>
  224.                                         <div class="certificate-check_item">
  225.                                                 <input name="<?php echo "Rokmatury[]"; ?>" value="<?php echo $term->slug; ?>" class="check-control" type="checkbox" id="certificateYear<?php echo $term->slug.get_the_ID(); ?>" <?php if( isset($_GET['Rokmatury'])&& strlen(array_search($term->slug,$_GET['Rokmatury'])) > 0) echo 'checked'; ?>>
  226.                                                 <label class="check-control-label" for="certificateYear<?php echo $term->slug.get_the_ID(); ?>"><?php echo $term->name; ?></label>
  227.                                             </div>
  228.                                             <?php
  229.                                         }
  230.                                     }
  231.                                 ?>
  232.                             </div>
  233.                             <div class="certificate-check">
  234.                                 <div class="certificate-check_item">
  235.                                     <input  class="check-control check-all" type="checkbox" id="certificateSelect<?php echo $term->slug.get_the_ID(); ?>">
  236.                                     <label class="check-control-label check-all-label"
  237.                                         for="certificateSelect<?php echo $term->slug.get_the_ID(); ?>">Zaznacz wszystkie</label>
  238.                                 </div>
  239.                             </div>
  240.                         </div>
  241.                     </div>
  242.                     <div class="certificate-sidebar_widget">
  243.                         <h3 class="certificate-sidebar_widget-title">Miesiąc matury</h3>
  244.                         <div class="certificate-check">
  245.                             <?php
  246.                                 $terms = get_terms(
  247.                                     array(
  248.                                         'taxonomy'   => 'miesiac_matury_taxonomy',
  249.                                         'hide_empty' => false,
  250.                                     )
  251.                                 );
  252.                                 if ( ! empty( $terms ) && is_array( $terms ) ) {
  253.                                     foreach ( $terms as $term ) {
  254.                                         ?>
  255.                                     <div class="certificate-check_item">
  256.                                             <input name="<?php echo "Miesiacmatury[]"; ?>" value="<?php echo $term->slug; ?>" class="check-control" type="checkbox" id="certificateMonth<?php echo $term->slug.get_the_ID(); ?>" <?php if( isset($_GET['Miesiacmatury'])&& strlen(array_search($term->slug,$_GET['Miesiacmatury'])) > 0) echo 'checked'; ?>>
  257.                                             <label class="check-control-label" for="certificateMonth<?php echo $term->slug.get_the_ID(); ?>"><?php echo $term->name; ?></label>
  258.                                         </div>
  259.                                         <?php
  260.                                     }
  261.                                 }
  262.                             ?>
  263.                         </div>
  264.                     </div>
  265.                     <div class="certificate-sidebar_footer">
  266.                         <div class="certificate-sidebar_action">
  267.                             <div>
  268.                                 <input name="filtruj" class="btn-primary filter-btn" type="submit" value="Zastosuj" />
  269.                             </div>
  270.                             <div>
  271.                                 <input class="btn-primary btn-danger" type="button" value="Wyczyść" onclick="UncheckAll()" />                        
  272.                             </div>
  273.                         </div>
  274.                     </div>
  275.                 </div>
  276.             </div>
  277.         </form>
  278.     </div>
  279. </div>
  280. <div class="col-lg-6 col-md-8">
  281.     <div class="certificate-main">
  282.         <div class="certificate-main_header">
  283.             <h1 class="certificate-main_header-title"><?php the_field('excercises-title'); ?></h1>
  284.         </div>
  285.  
  286.         <?php
  287.         $paged = (get_query_var('paged')) ? get_query_var('paged') : 0;
  288.  
  289.         $wp_query = new WP_Query(          
  290.             array(
  291.                 'posts_per_page' => $zadanie,
  292.                 'post_type' => 'zadania',
  293.                 'paged' => $paged,
  294.                 'kategorie_zadan_taxonomy' => $_GET['Kategoriazadan'],
  295.                 'typ_zadan_taxonomy' => $_GET['Typzadan'],
  296.                 'poziom_taxonomy' => $_GET['Poziom'],
  297.                 'typ_matury_taxonomy' => $_GET['Typmatury'],
  298.                 'rok_matury_taxonomy' => $_GET['Rokmatury'],
  299.                 'miesiac_matury_taxonomy' => $_GET['Miesiacmatury'],
  300.                 'tax_query' => array(
  301.                     array(
  302.                         'taxonomy' => 'przedmiot_taxonomy',
  303.                         'field'    => 'slug',
  304.                         'terms'    => array( 'biologia' ),
  305.                         'operator' => 'IN'
  306.                     ),
  307.                 ),
  308.             )
  309.         )
  310.  
  311.         ?>
  312.         <div class="certificate-main_body">
  313.             <div class="certificate-main_actions">
  314.                 <div>
  315.                     <div class="certificate-main_summary">Znalezionych zadań: <strong><?php echo $wp_query->found_posts; ?></strong></div>
  316.                 </div>
  317.                 <div>
  318.                     <ul class="pager-primary certificate-main_pager">
  319.                         <div class="post-pagination">
  320.                             <?php if(show_posts_nav($wp_query)) : ?>
  321.                             <div class="excercises-items_pagination">
  322.                                 <?php excercises_pagination();  ?>
  323.                             </div>
  324.                             <?php endif; ?>
  325.                         </div>
  326.                     </ul>
  327.                 </div>
  328.             </div>
  329.             <?php if($wp_query->have_posts()) { ?>
  330.             <div class="certificate-main_browser">
  331.            
  332.             <?php
  333.                 if($paged == 0){
  334.                     $counter = $zadanie * $paged  + 1;
  335.                 } else {
  336.                     $counter = $zadanie * ($paged - 1) + 1;
  337.                 }
  338.  
  339.                     if(  $wp_query->have_posts()) {
  340.                         while(  $wp_query->have_posts()) {  $wp_query->the_post();
  341.  
  342.                             $kategorie = get_the_terms( $post->ID, 'kategorie_zadan_taxonomy');
  343.                             $typy_zadan = get_the_terms( $post->ID, 'typ_zadan_taxonomy');
  344.                             $poziom = get_the_terms( $post->ID, 'poziom_taxonomy');
  345.                             $typ_matury = get_the_terms( $post->ID, 'typ_matury_taxonomy');
  346.                             $rok = get_the_terms( $post->ID, 'rok_matury_taxonomy');
  347.                             $miesiac = get_the_terms( $post->ID, 'miesiac_matury_taxonomy');
  348.             ?>
  349.                             <article class="certificate-main_article">
  350.                                 <header class="certificate-main_article-header">
  351.                                     <div class="certificate-main_article-counter"><?php echo $counter; ?></div>
  352.                                     <h2><a href="<?php echo get_post_permalink(); ?>">Matura <?php echo $miesiac[0]->name." ".$rok[0]->name; ?>, Poziom <?php echo $poziom[0]->name." (".$typ_matury[0]->name.")"; ?><br>
  353.                                         <?php the_title(); ?></a></h2>
  354.                                 </header>
  355.                                 <ul class="certificate-main_article-cats">
  356.                             <?php
  357.                            
  358.                                 foreach($kategorie as $kategoria) { ?>
  359.                                     <li>
  360.                                         <form>
  361.                                             <input name="<?php echo "Kategoriazadan[]"; ?>" value="<?php echo $kategoria->name; ?>" type="submit" id="certificateFilter<?php echo $kategoria->slug.get_the_ID(); ?>" <?php if( isset($_GET['Kategoriazadan'])&& strlen(array_search($kategoria->slug,$_GET['Kategoriazadan'])) > 0) echo 'checked'; ?>>
  362.                                         </form>
  363.                                     </li>
  364.                                 <?php
  365.                                 }
  366.  
  367.                                 foreach($typy_zadan as $typ_zadan) { ?>
  368.                                     <li>
  369.                                         <form>
  370.                                             <input name="<?php echo "Typzadan[]"; ?>" value="<?php echo $typ_zadan->name; ?>" type="submit" id="certificateType<?php echo $typ_zadan->slug.get_the_ID(); ?>" <?php if( isset($_GET['Typzadan'])&& strlen(array_search($typ_zadan->slug,$_GET['Typzadan'])) > 0) echo 'checked'; ?>>
  371.                                         </form>
  372.                                     </li>
  373.                                 <?php
  374.                                 } ?>
  375.                                 </ul>
  376.                                 <div class="certificate-main_article-content">
  377.                                     <?php the_field('ex-description'); ?>
  378.                                     <figure>
  379.                                         <a data-fancybox href="<?php the_field('ex-img-photo'); ?>"><img
  380.                                                 src="<?php the_field('ex-img-photo'); ?>" /></a>
  381.                                     </figure>
  382.                                     <?php the_field('ex-content'); ?>
  383.                                 </div>
  384.                                 <div class="certificate-main_article-answer">
  385.                                     <div class="article-answer_header">
  386.                                         <div class="btn-primary article-answer_toggle">Pokaż rozwiązanie</div>
  387.                                     </div>
  388.                                     <div class="article-answer_collapse">
  389.                                         <div class="article-answer_content">
  390.                                         <?php the_field('ex-solution'); ?>
  391.                                         </div>
  392.                                     </div>
  393.                                 </div>
  394.                                 <div class="certificate-main_article-footer">
  395.                                     <div class="article-print_title">Drukuj zadanie:</div>
  396.                                     <ul class="certificate-main_article-print">
  397.                                         <li>
  398.                                             <a href="#" data-print="task">Zadanie</a>
  399.                                         </li>
  400.                                         <li>
  401.                                             <a href="#" data-print="solution">Rozwiązanie</a>
  402.                                         </li>
  403.                                         <li>
  404.                                             <a href="#" data-print="both">Zadanie + Rozwiązanie</a>
  405.                                         </li>
  406.                                     </ul>
  407.                                 </div>
  408.                                 <div class="certificate-main_article-check">
  409.                                     <input id="printCheck<?php echo $counter; ?>" type="checkbox" checked>
  410.                                     <label for="printCheck<?php echo $counter; ?>"></label>
  411.                                 </div>
  412.                             </article>
  413.                         <?php
  414.                         $counter++;
  415.                         }
  416.                     }
  417.                     ?>
  418.             </div>
  419.             <form methogd="get" class="print-btn-box">
  420.                 <input class="btn-primary print-btn" name="tryb" type="submit" value="Tryb drukowania">
  421.                 </form>
  422.             <div class="certificate-main_footer">
  423.                 <div class="certificate-main_footer-holder">
  424.                     <ul class="pager-primary">
  425.                         <div class="post-pagination">
  426.                             <?php if(show_posts_nav($wp_query)) : ?>
  427.                             <div class="excercises-items_pagination">
  428.                                 <?php excercises_pagination();  ?>
  429.                             </div>
  430.                             <?php endif; ?>
  431.                         </div>
  432.                     </ul>
  433.                 </div>
  434.                 <div class="print-primary">
  435.                     <div id="printSwitchTitle" class="print-primary_title">Drukuj wszystkie zadania:</div>
  436.                     <div class="print-primary_switch">
  437.                         <div class="print-switch">
  438.                             <input id="printSwitch" type="checkbox" checked>
  439.                             <label for="printSwitch"></label>
  440.                         </div>
  441.                     </div>
  442.                     <ul class="print-primary_list">
  443.                         <li>
  444.                             <a href="#" data-print="task">Zadania</a>
  445.                         </li>
  446.                         <li>
  447.                             <a href="#" data-print="solution">Rozwiązania</a>
  448.                         </li>
  449.                         <li>
  450.                             <a href="#" data-print="both">Zadania + Rozwiązania</a>
  451.                         </li>
  452.                     </ul>
  453.                 </div>
  454.             </div>
  455.             <?php
  456.  
  457.             }  else {
  458.                     ?>
  459.                 <div class="no-posts-info">
  460.                     <?php the_field('no-posts-info'); ?>
  461.                 </div>
  462.                   <?php
  463.                 }
  464.  
  465.             ?>
  466.         </div>
  467.     </div>
  468.     <?php echo '<pre>';
  469. print_r($q1);
  470. echo '</pre>'; ?>
  471. </div>
  472.  
  473.  
  474. <div class="col-lg-3 col-md-4">
  475.     <?php get_template_part('template-parts/sidebar'); ?>
  476. </div>
  477. <?php get_template_part('template-parts/newsletter'); ?>
  478. <?php get_footer();
  479.  
  480.  
  481.             if( isset($_GET['Kategoriazadan']) ||
  482.                 isset($_GET['Typzadan']) ||
  483.                 isset($_GET['Poziom']) ||
  484.                 isset($_GET['Rokmatury']) ||
  485.                 isset($_GET['Typmatury']) ||
  486.                 isset($_GET['Miesiacmatury'])||
  487.                 isset($_GET['tryb'])
  488.                 ) {
  489. ?>
  490.           <script> printAction(); </script>        
  491.   <?php              }
  492.             ?>
  493.        
  494.  
  495.