Разработка структуры web-узла и реализация web-узла, страница 3

    }

    else

    {

        if ($page == "archive")

        {

            if ($query['1'] == "") $query['1'] = 0;

            $page_num = intval($query['1']);

            $count = $main->db->Count($t_news);

            $news_onpage = $main->config['newsarchive_onpage'];

            $main->assign('title', "Архив новостей");

            $main->assign('header', "Архив новостей");

            $main->assign('pages', $main->Pages($PATH."archive/", "", $page_num, $count, $news_onpage, ""));

            $main->assign('archive', 1);

            $main->assign('head_nav', array(0 => array("url" => "{$PATH}", "text" => "Новости"), 1 => array("url" => "{$PATH}archive/", "text" => "Архив новостей")));

        }

        else

        {

            $news_onpage = $main->config['news_onpage'];

            $main->assign('title', "Новости");

            $main->assign('header', "Новости");

            $main->assign('head_nav', array(0 => array("url" => "{$PATH}", "text" => "Новости")));

            $page_num = 0;

        }

        if ($main->db->Query("SELECT id, name, text, DATE_FORMAT(date, '%Y-%m-%d') as date, DATE_FORMAT(date, '%e %b %Y года') as date_format FROM $t_news ORDER BY id DESC LIMIT $page_num, $news_onpage"))

        {

            $main->assign('news', $main->db->GetArrayResult());

            $main->assign('show', 1);

        }

        if ($main->db->Count($t_news) > $news_onpage) $main->assign('archive_link', 1);

    }

    $main->assign('today', 1);

    $main->display('news.tpl');

}

?>

Файл programs.php:

<?php

$id = intval($query['1']);

if ($id != 0)

{

    if ($main->db->Query("SELECT * FROM $t_programs WHERE id='$id'"))

    {

        $program = $main->db->GetArrayResult();

        $program['text']['0'] = str_replace("src=img_upload", "src={$PATH}img_upload", $program['text']['0']);

        $main->assign('header', "Программы");

        $main->assign('program', $program);

        $main->assign('view', 1);

    }

    else

    {

        $main->assign('view', 0);

        $main->assign('header', "Ошибка");

    }

    $main->assign('programs', 1);

    $main->assign('head_nav', array(0 => array("url" => "{$PATH}programs/", "text" => "Программы"), 1 => array("url" => "{$PATH}programs/$id/", "text" => "Просмотр программы")));

}

else

{

    if ($query['1'] == "all")

    {

        if ($main->db->Query("SELECT * FROM $t_programs_cats ORDER BY num"))

        {

            $count = $main->db->GetCount();

            $programs = $main->db->GetArrayResultInvert();

            for ($i=0; $i<$count; $i++)

            {

                $id = $programs[$i]['id'];

                if ($main->db->Query("SELECT * FROM $t_programs WHERE programs_id='$id'")) $programs[$i]['programs'] = $main->db->GetArrayResultInvert();

            }

            $main->assign('show', 1);

            $main->assign('all', 1);

            $main->assign('programs', $programs);