Example #1
0
 function newsBlockAction()
 {
     $v_params['sys_name'] = SysPropertiesUtil::getPropertyValue("sys_name");
     $v_params['sys_slog'] = SysPropertiesUtil::getPropertyValue("sys_slog");
     if (LoginChecker::isAdmin()) {
         if (0 == strcmp("add", $_GET['act']) && isset($_GET['corresp'])) {
             $v_params['sys_news_art'] = SysNewsArtUtil::getSysNewsArtById($_GET['corresp']);
             if (isset($_POST['send_block_form'])) {
                 $sysNewsArtBlock['sys_news_art_id'] = $_GET['corresp'];
                 $sysNewsArtBlock['text_content'] = $_POST['text_content'];
                 $sysNewsArtBlock['order_in_art'] = (int) $_POST['order'];
                 $sysNewsArtBlock['image_id'] = (int) $_POST['pict_id'];
                 $sysNewsArtBlock['image_title'] = $_POST['img_desk'];
                 if (0 == $_POST['selected_tab']) {
                     $sysNewsArtBlock['block_type'] = 1;
                 } else {
                     if (1 == $_POST['selected_tab']) {
                         $sysNewsArtBlock['block_type'] = 0;
                     }
                 }
                 SysNewsArtBlockUtil::insertSysNewsArtBlock($sysNewsArtBlock);
                 $snaID = $v_params['sys_news_art']['id'];
                 header("Location: /superAdmin/newsArt?id={$snaID}&act=upd");
             }
             $img_albums = ImgAlbumUtil::getImgAlbumsByAccountID(0);
             $img_album_pictures = ImgPictureUtil::getImgPicturesNoAlbum(0);
             $v_params['img_albums'][] = array("name" => "Без альбома", "pictures" => $img_album_pictures);
             foreach ($img_albums as $img_album) {
                 $img_album_pictures = ImgPictureUtil::getImgPicturesByAlbumId($img_album['id'], 0);
                 $v_params['img_albums'][] = array("name" => $img_album['name'], "pictures" => $img_album_pictures);
             }
             $v_params['act_name'] = "Добавить блок";
             $v_params['num_tab'] = 0;
             Application::fastView('super-admin/news/news_page_block_au', $v_params);
             exit;
         } else {
             if (0 == strcmp("upd", $_GET['act']) && isset($_GET['corresp']) && isset($_GET['id'])) {
                 $v_params['sys_news_art'] = SysNewsArtUtil::getSysNewsArtById($_GET['corresp']);
                 $v_params['ssp_block'] = SysNewsArtBlockUtil::getSysNewsArtBlockById($_GET['id']);
                 $v_params['act_name'] = "Редактировать блок";
                 $img_albums = ImgAlbumUtil::getImgAlbumsByAccountID(0);
                 $img_album_pictures = ImgPictureUtil::getImgPicturesNoAlbum(0);
                 $v_params['img_albums'][] = array("name" => "Без альбома", "pictures" => $img_album_pictures);
                 foreach ($img_albums as $img_album) {
                     $img_album_pictures = ImgPictureUtil::getImgPicturesByAlbumId($img_album['id'], 0);
                     $v_params['img_albums'][] = array("name" => $img_album['name'], "pictures" => $img_album_pictures);
                 }
                 $v_params['num_tab'] = 0;
                 if (0 == $v_params['ssp_block']['block_type']) {
                     $v_params['num_tab'] = 1;
                 }
                 if (isset($_POST['send_block_form'])) {
                     $v_params['ssp_block']['sys_news_art_id'] = $_GET['corresp'];
                     $v_params['ssp_block']['text_content'] = $_POST['text_content'];
                     $v_params['ssp_block']['order_in_art'] = (int) $_POST['order'];
                     $v_params['ssp_block']['image_id'] = (int) $_POST['pict_id'];
                     $v_params['ssp_block']['image_title'] = $_POST['img_desk'];
                     if (0 == $_POST['selected_tab']) {
                         $v_params['ssp_block']['block_type'] = 1;
                     } else {
                         if (1 == $_POST['selected_tab']) {
                             $v_params['ssp_block']['block_type'] = 0;
                         }
                     }
                     SysNewsArtBlockUtil::updateSysNewsArtBlock($v_params['ssp_block']);
                 }
                 Application::fastView('super-admin/news/news_page_block_au', $v_params);
                 exit;
             } else {
                 if (0 == strcmp("del", $_GET['act']) && isset($_GET['corresp']) && isset($_GET['id'])) {
                     $v_params['sys_news_art'] = SysNewsArtUtil::getSysNewsArtById($_GET['corresp']);
                     if (isset($_POST['send_block_form'])) {
                         SysNewsArtBlockUtil::deleteSysNewsArtBlockById($_GET['id']);
                         $snaID = $v_params['sys_news_art']['id'];
                         header("Location: /superAdmin/newsArt?id={$snaID}&act=upd");
                     }
                     $v_params['ssp_block'] = SysNewsArtBlockUtil::getSysNewsArtBlockById($_GET['id']);
                     $v_params['act_name'] = "Удалить блок";
                     Application::fastView('super-admin/news/news_page_block_del', $v_params);
                     exit;
                 }
             }
         }
     } else {
         header("Location: /superAdmin/login");
     }
 }