Exemple #1
0
 /**
  * Returns the diff as a string.
  *
  * @param	array $c the LCS
  * @param	array $x the original
  * @param	array $y the updated
  * @param	int $i
  * @param	int $j
  * @param	string $last
  * @param	boolean $change
  * @param	int $end_i
  * @param	int $end_j
  * @param	int $add_i
  * @param	int $add_j
  * @return	string
  */
 function print_diff($c, $x, $y, $i, $j, $last = '', $change = false, $end_i = 0, $end_j = 0, $add_i = 0, $add_j = 0)
 {
     $patch = '';
     if ($i >= 0 && $j >= 0 && $x[$i] == $y[$j]) {
         $patch .= print_diff($c, $x, $y, $i - 1, $j - 1);
         if ($last != '') {
             $i_text = $i + $add_i == $end_i + 1 ? $i + $add_i : $i + $add_i . ',' . ($end_i + 1);
             $j_text = $j + $add_j == $end_j + 1 ? $j + $add_j : $j + $add_j . ',' . ($end_j + 1);
             $last = $change ? 'c' : $last;
             $patch .= $i_text . $last . $j_text . "\n";
         }
     } elseif ($i == -1 && $j == -1) {
         $i_text = $i + $add_i == $end_i + 1 ? $i + $add_i : $i + $add_i . ',' . ($end_i + 1);
         $j_text = $j + $add_j == $end_j + 1 ? $j + $add_j : $j + $add_j . ',' . ($end_j + 1);
         $last = $change ? 'c' : $last;
         $patch .= $i_text . $last . $j_text . "\n";
     } else {
         $end_i = $end_i == 0 ? $i : $end_i;
         $end_j = $end_j == 0 ? $j : $end_j;
         if ($j >= 0 && ($i == -1 || $c[$i][$j - 1] >= $c[$i - 1][$j])) {
             $change = $last == 'd' || $change;
             $patch .= print_diff($c, $x, $y, $i, $j - 1, 'a', $change, $end_i, $end_j, 1, 2);
             $patch .= '> ' . $y[$j] . "\n";
         } elseif ($i >= 0 && ($j == -1 || $c[$i][$j - 1] < $c[$i - 1][$j])) {
             $change = $last == 'a' || $change;
             $patch .= print_diff($c, $x, $y, $i - 1, $j, 'd', $change, $end_i, $end_j, 2, 2);
         }
     }
     return $patch;
 }
Exemple #2
0
function mobile_html()
{
    global $result, $safe_week, $default_week, $day_not_given;
    global $link_tail_wowk, $prev_week, $next_week, $link_tail_tail;
    global $entity_name, $entity_type, $entity_multiple, $basis, $wijz;
    global $week_info;
    global $berichten;
    $dubbel = array();
    // in deze array houden we bij welke zermelo_ids
    // al aan de beurt geweest zijn, zodat 'verplaatsing + uitval'
    // alleen 'verplaatsing' wordt
    header("Content-Type: text/html; charset=UTF-8");
    ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="76x76" href="apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="120x120" href="apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="152x152" href="apple-touch-icon-152x152.png">
<link rel="shortcut icon" href="zermelo_zoom.ico">
<meta name="msapplication-config" content="none">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Roosterbord <?php 
    echo config('SCHOOL_AFKORTING') . ' ' . config('SCHOOLJAAR_LONG');
    ?>
</title>
<link rel="stylesheet" href="css/mobile.css">
<link rel="stylesheet" href="css/jquery.mobile-1.4.3.min.css">
<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.4.3.min.js"></script>
<?php 
    if (!isset($_GET['q']) || $_GET['q'] == '') {
        ?>
<script type="text/javascript">
$(document).on('pageshow', function () {
	$('#searchbar').val('');
});
</script>
<?php 
    }
    ?>
</head>
<body>
<div data-role="page" id="main">
<div data-role="header" data-position="fixed">
<a style="margin-left: 5px; margin-right: 5px" data-transition="slide" data-direction="reverse" class="ui-btn ui-btn-left ui-btn-inline ui-icon-carat-l ui-btn-icon-notext ui-corner-all<?php 
    if ($prev_week === NULL && $_GET['dy'] == 1) {
        ?>
 ui-state-disabled<?php 
    }
    ?>
" href="?q=<?php 
    echo urlencode($_GET['q']) . $link_tail_wowk . ($_GET['dy'] == 1 ? $prev_week : ($safe_week == $default_week ? '' : $safe_week)) . '&amp;m&amp;dy=' . ($_GET['dy'] == 1 ? 5 : $_GET['dy'] - 1) . $link_tail_tail;
    ?>
"></a>
<div class="ui-btn-right">
<a style="margin-left: 5px; margin-right: 5px; float: left" data-transition="slidefade" class="ui-btn ui-btn-inline ui-icon-home ui-btn-icon-notext ui-corner-all" href="?q=&amp;m<?php 
    echo $link_tail_tail;
    ?>
"></a>
<a style="margin-left: 5px; margin-right: 5px; float: left" data-transition="slide" class="ui-btn ui-btn-inline ui-icon-carat-r ui-btn-icon-notext ui-corner-all<?php 
    if ($next_week === NULL && $_GET['dy'] == 5) {
        ?>
 ui-state-disabled<?php 
    }
    ?>
" href="?q=<?php 
    echo urlencode($_GET['q']) . $link_tail_wowk . ($_GET['dy'] == 5 ? $next_week : ($safe_week == $default_week ? '' : $safe_week)) . '&amp;m&amp;dy=' . ($_GET['dy'] == 5 ? 1 : $_GET['dy'] + 1) . $link_tail_tail;
    if ($safe_week < 30) {
        $year = substr(config('SCHOOLJAAR_LONG'), 5);
    } else {
        $year = substr(config('SCHOOLJAAR_LONG'), 0, 4);
    }
    $day_in_week = strtotime(sprintf("{$year}-01-04 + %d weeks", $safe_week - 1));
    $thismonday = $day_in_week - (date('w', $day_in_week) + 6) % 7 * 24 * 60 * 60;
    ?>
"></a>
</div>
<h1><?php 
    echo config('SCHOOL_AFKORTING') . ' ';
    switch ($_GET['dy']) {
        case 1:
            echo 'ma';
            break;
        case 2:
            echo 'di';
            break;
        case 3:
            echo 'wo';
            break;
        case 4:
            echo 'do';
            break;
        case 5:
            echo 'vr';
            break;
    }
    echo ' ' . date('j-n', $thismonday + ($_GET['dy'] - 1) * 24 * 60 * 60);
    ?>
</h1>
</div>
<div data-role="main" class="ui-content">
<ul data-role="listview">
<li>
<form id="search" method="GET" data-transition="pop" accept-charset="UTF-8">
<input id="searchbar" type="search" name="q" placeholder="<?php 
    echo $entity_type === '' && $_GET['q'] != '' ? 'zoekterm ' . htmlenc($_GET['q']) . ' niet gevonden' : 'klas, leerlingnr, docent, lokaal...';
    ?>
" value="<?php 
    echo htmlenc($entity_name);
    ?>
">
<input type="hidden" name="m">
<input name="bw" type="hidden" value="<?php 
    echo $_GET['bw'];
    ?>
">
<input name="wk" type="hidden" value="<?php 
    if ($safe_week != $default_week) {
        echo $safe_week;
    }
    ?>
">
<input name="dy" type="hidden" value="<?php 
    if (!$day_not_given) {
        echo $_GET['dy'];
    }
    ?>
">
</form>
</li>
<?php 
    if ($entity_type !== '') {
        $bericht = NULL;
        if ($berichten) {
            $bericht = $berichten->fetchRow(MDB2_FETCHMODE_ASSOC);
        }
        if ($bericht) {
            ?>
<li><div data-role="collapsibleset"><?php 
            do {
                echo '<div data-role="collapsible"><h3>' . $bericht['bericht_title'] . ' (' . $bericht['bericht_entities'] . ')</h3>';
                echo '<p style="white-space: normal">' . $bericht['bericht_body'] . '</div>';
            } while ($bericht = $berichten->fetchRow(MDB2_FETCHMODE_ASSOC));
            ?>
</div></li><?php 
        }
        ?>
</ul>
<p>
<ul data-role="listview">
<?php 
        $row = $result->fetchRow();
        for ($i = 1; $i < config('MAX_LESUUR') + 1; $i++) {
            ?>
<li><div class="ui-grid-a"><div style="width: 5%" class="ui-block-a"><?php 
            echo $i;
            ?>
</div>
<div style="width: 95%" class="ui-block-b">
<?php 
            while ($row[UUR] == $i) {
                cleanup_row($row);
                $extra = '';
                $comment = '';
                if ($row[WIJZ_ID]) {
                    // deze les is: extra/nieuw, lokaalreservering, (fake)verplaatstvan of gewijzigd
                    if (!$row[DAG2] || !$row[VIS2] && $row[VIS]) {
                        // bij deze les hoort geen oude les, dus: extra, reservering of fakeverplaatstvan
                        if ($row[VAKKEN] == 'lok') {
                            $row[VAKKEN] = '';
                            $extra = ' lokaalreservering';
                            if ($row[NOTITIE]) {
                                $comment = '(<span class="onlyprint">lokaalreservering: </span>' . htmlenc($row[NOTITIE]) . ')';
                            } else {
                                $comment = '(lokaalreservering)';
                            }
                        } else {
                            if (preg_match('/^van /', $row[NOTITIE])) {
                                $extra = ' verplaatstvan';
                                $comment = '(' . htmlenc($row[NOTITIE]) . ')';
                            } else {
                                $extra = ' extra';
                                if ($_GET['bw'] == 'x') {
                                    $comment = ' (nieuw';
                                    if ($row[NOTITIE] != '') {
                                        $comment = '(<span class="onlyprint">nieuw: </span>' . htmlenc($row[NOTITIE]);
                                    }
                                } else {
                                    $comment = ' (extra';
                                    if ($row[NOTITIE] != '') {
                                        $comment = '(<span class="onlyprint">extra: </span>' . htmlenc($row[NOTITIE]);
                                    }
                                }
                                $comment .= ')';
                            }
                        }
                    } else {
                        // bij deze les hoort een oude les, dus gewijzigd of verplaatstvan
                        // staat de les op hetzelfde uur en is de oude les zichtbaar in dit rooster?
                        if ($row[UUR] == $row[UUR2] && $row[DAG] == $row[DAG2] && $row[VIS]) {
                            if ($row[LESGROEPEN] != $row[LESGROEPEN2] || $row[VAKKEN] != $row[VAKKEN2] || $row[DOCENTEN] != $row[DOCENTEN2] || $row[LOKALEN] != $row[LOKALEN2]) {
                                $extra = ' gewijzigd';
                                $comment = '(was ' . print_diff($row);
                                if ($row[NOTITIE] != '') {
                                    $comment .= ', ' . htmlenc($row[NOTITIE]);
                                }
                                $comment .= ')';
                            }
                        } else {
                            $extra = ' verplaatstvan';
                            $comment = '(van ' . print_diff($row);
                            if ($row[NOTITIE] != '') {
                                $comment .= ', ' . htmlenc($row[NOTITIE]);
                            }
                            $comment .= ')';
                        }
                    }
                } else {
                    if ($row[BASIS_ID2] || $_GET['bw'] == 'x' && $wijz['file_id']) {
                        // dit is uitval,vrijstelling,(fake)verplaatstnaar,gewijzigd
                        if (!$row[DAG2] || !$row[VIS2] && $row[VIS]) {
                            // bij deze les hoort geen nieuwe les, dus uitval/vrijstelling/fakeverplaatstnaar
                            // is deze les al aan de orde geweest bij een verplaatsing?
                            // zo ja, dan skippen we deze les
                            if (isset($dubbel[$row[BASIS_ID]])) {
                                $row = $result->fetchRow();
                                continue;
                            } else {
                                if ($_GET['bw'] == 'd') {
                                    // verberg vervallen lessen
                                    $row = $result->fetchRow();
                                    continue;
                                } else {
                                    if (preg_match('/^naar /', $row[NOTITIE2])) {
                                        $extra = ' verplaatstnaar';
                                        $comment = '(' . htmlenc($row[NOTITIE2]) . ')';
                                    } else {
                                        if (preg_match('/^vrij( (.*))?$/', $row[NOTITIE2], $matches)) {
                                            $extra = ' vrijstelling';
                                            if ($matches[2] != '') {
                                                $comment = '(<span class="onlyprint">vrijstelling: </span>' . htmlenc($matches[2]) . ')';
                                            } else {
                                                $comment = '(vrijstelling)';
                                            }
                                        } else {
                                            $extra = ' uitval';
                                            if ($_GET['bw'] == 'x') {
                                                $comment = ' (oud';
                                                if ($row[NOTITIE2] != '') {
                                                    $comment = '(<span class="onlyprint">oud: </span>' . htmlenc($row[NOTITIE2]);
                                                }
                                            } else {
                                                $comment = ' (uitval';
                                                if ($row[NOTITIE2] != '') {
                                                    $comment = '(<span class="onlyprint">uitval: </span>' . htmlenc($row[NOTITIE2]);
                                                }
                                            }
                                            $comment .= ')';
                                        }
                                    }
                                }
                            }
                        } else {
                            // bij deze les hoort een nieuwe les dus gewijzigd of verplaatstnaar
                            $dubbel[$row[BASIS_ID]] = 1;
                            // staat de nieuwe les op dezelfde plek en is deze zichtbaar in dit rooster?
                            if ($row[DAG] == $row[DAG2] && $row[UUR] == $row[UUR2] && $row[VIS]) {
                                $row = $result->fetchRow();
                                continue;
                            } else {
                                if ($_GET['bw'] == 'd') {
                                    // verberg verplaatste lessen
                                    $row = $result->fetchRow();
                                    continue;
                                } else {
                                    $extra = ' verplaatstnaar';
                                    $comment = '(naar ' . print_diff($row);
                                    if ($row[NOTITIE2] != '') {
                                        $comment .= ', ' . htmlenc($row[NOTITIE2]);
                                    }
                                    $comment .= ')';
                                }
                            }
                        }
                    } else {
                        if (!$week_info[$_GET['dy']] && $_GET['bw'] != 'b' && $_GET['bw'] != 'x') {
                            // deze dag valt uit
                            $extra = ' vrijstelling';
                            $comment = '(vrijstelling)';
                        } else {
                            // dit is een gewone les
                            if ($row[NOTITIE]) {
                                $comment = ' (' . $row[NOTITIE] . ')';
                            }
                        }
                    }
                }
                $info = array();
                add_lv($info, $row[LESGROEPEN], $row[VAKKEN]);
                add($info, $row[DOCENTEN], $row[WIJZ_ID] && $row[DOCENTEN2] ? '<span class="unknown">DOC?</span>' : '');
                add($info, $row[LOKALEN], $row[WIJZ_ID] && $row[LOKALEN2] ? '<span class="unknown">LOK?</span>' : '');
                echo '<div style="text-align: center">' . "\n";
                echo '<div class="les' . $extra . '">';
                if (count($info)) {
                    echo '<table><tr><td>' . implode('</td><td>/</td><td>', $info) . '</td></tr></table>';
                }
                if ($comment) {
                    echo '<div class="comment">' . $comment . '</div>';
                }
                echo '<div class="clear"></div></div>';
                $row = $result->fetchRow();
                echo '</div>';
            }
            echo '</div>';
            ?>
</div></li><?php 
        }
    } else {
        $bericht = NULL;
        if ($berichten) {
            $bericht = $berichten->fetchRow(MDB2_FETCHMODE_ASSOC);
        }
        if ($bericht) {
            $var = 0;
            ?>
<li><div data-role="collapsibleset"><?php 
            do {
                echo '<div ' . (!$var ? 'data-collapsed="false" ' : '') . 'data-role="collapsible"><h3>' . $bericht['bericht_title'] . ' (' . $bericht['bericht_entities'] . ')</h3>';
                echo '<p style="white-space: normal">' . $bericht['bericht_body'] . '</div>';
                $var = 1;
            } while ($bericht = $berichten->fetchRow(MDB2_FETCHMODE_ASSOC));
            ?>
</div></li><?php 
        }
    }
    ?>
</ul>
</div>
<div data-role="footer" data-position="fixed">
<div data-role="navbar">
<ul>
<li>
<?php 
    if (($klassenboek_url = config('KLASSENBOEK_URL')) != 'false') {
        if (!$entity_multiple && ($entity_type == STAMKLAS || $entity_type == LESGROEP || $entity_type == LEERLING)) {
            ?>
 <a href="<?php 
            echo $klassenboek_url;
            ?>
nologin.php?week=<?php 
            echo $safe_week;
            ?>
&amp;q=<?php 
            echo $entity_name;
            ?>
">Klassenboek</a>
<?php 
        } else {
            ?>
<a href="<?php 
            echo $klassenboek_url;
            ?>
">Klassenboek</a>
<?php 
        }
    }
    ?>
</li>
<li><?php 
    echo make_link2($_GET['q'], 'Desktop versie');
    ?>
</li>
</ul>
</div>
</div>
</div>
</body>
</html>
<?php 
}