Beispiel #1
0
    redirect_to("content.php");
}
include_once "includes/form_functions.php";
if (isset($_POST['submit'])) {
    $errors = array();
    $obavezna_polja = array('menu_name', 'position', 'visible', 'content');
    $errors = array_merge($errors, check_required_fields($obavezna_polja));
    $polje_sa_duzinom = array('menu_name' => 30);
    $errors = array_merge($errors, check_max_fields_length($polje_sa_duzinom));
    $id = mysql_prep($_GET['page']);
    $menu = mysql_prep($_POST['menu_name']);
    $position = mysql_prep($_POST['position']);
    $visible = mysql_prep($_POST['visible']);
    $content = mysql_prep($_POST['content']);
    $page_get = get_page_by_id($id);
    $pages_all = get_all_pages_for_subject($page_get['subject_id']);
    $page_fetch = mysql_fetch_array($pages_all);
    $count_pages = mysql_num_rows($pages_all);
    $position_old = $page_get['position'];
    if (empty($errors)) {
        if ($position_old != $position) {
            if ($position_old < $position) {
                for ($i = $position_old; $i < $position; $i++) {
                    $new = $i + 1;
                    $qry = "UPDATE pages SET";
                    $qry .= " position={$i}";
                    $qry .= "\tWHERE position={$new} AND subject_id={$page_get['subject_id']}";
                    mysql_query($qry, $conn);
                }
            } else {
                for ($i = $position_old; $i > $position; $i--) {
Beispiel #2
0
echo urlencode($select_sub['id']);
?>
"
			 onclick="return confirm('Are you sure?')">Delete subject</a>
		</form>
		
		<br />
		<a href="content.php">Cancel</a>
		<br />
		
		<div>
			<h3>Pages in this subject</h3>
			<ul>
			
			<?php 
$sub_pages = get_all_pages_for_subject($select_sub['id']);
while ($page = mysql_fetch_array($sub_pages)) {
    echo "<li><a href=\"content.php?page={$page['id']}\">{$page['menu_name']}</a></li>";
}
?>
			</ul>
			<br />
			<a href="new_page.php?subj=<?php 
echo $select_sub['id'];
?>
">+ Add a new page to this subject</a>
		</div>
		
	
	</td>
</tr>
Beispiel #3
0
function public_navigation($select_sub, $select_page, $public = true)
{
    $output = "<ul class=\"subjects\">";
    // 3. Izvrsiti query
    $sub_set = get_all_subjects($public);
    // 4. Ispsi podatke iz baze
    while ($menu = mysql_fetch_array($sub_set)) {
        $output .= "<li ";
        if ($menu["id"] == $select_sub["id"]) {
            $output .= "class=\"selected sel\" ";
        }
        $output .= "><a href=\"index.php?subj=" . urlencode($menu["id"]) . "\">{$menu['menu_name']}</a>";
        if ($menu["id"] == $select_sub["id"]) {
            $page_set = get_all_pages_for_subject($menu["id"], $public);
            $output .= "<ul class=\"pages\">";
            while ($page = mysql_fetch_array($page_set)) {
                $output .= "<li ";
                if ($page["id"] == $select_page["id"]) {
                    $output .= "class=\"selected\" ";
                }
                $output .= "><a href=\"index.php?page=" . urlencode($page["id"]) . "\">{$page['menu_name']}</a></li>";
            }
            $output .= "</ul>";
        }
        $output .= "</li>";
    }
    $output .= "<br/><br/>";
    $output .= "<li><a href=\"staff.php\"> Staff page </a></li>";
    $output .= "</ul>";
    return $output;
}