예제 #1
0
 function ARTcatAction()
 {
     $img_id = $_SESSION['imag_id'];
     $imgAccount = ImgAccountUtil::getImgAccountById($img_id, TRUE);
     $v_params['sys_name'] = SysPropertiesUtil::getPropertyValue("sys_name");
     $v_params['sys_slog'] = SysPropertiesUtil::getPropertyValue("sys_slog");
     if (NULL != $imgAccount) {
         $v_params['logined'] = LoginChecker::isLogined();
         if ($v_params['logined'] == $img_id) {
             $v_params['mysc']['main'] = TRUE;
             $v_params['img_name'] = $imgAccount['img_name'];
             $v_params['url_prefix'] = "/" . IMAG_PREFIX . $imgAccount['id'] . "/admin/";
             $action = $_GET['act'];
             if (0 == strcmp("add", $action)) {
                 $v_params['actname'] = "Создать блок статей";
                 if (isset($_POST['img_cat_name'])) {
                     $imgBlogCat['account_id'] = $imgAccount['id'];
                     $imgBlogCat['name'] = $_POST['img_cat_name'];
                     if (0 != (int) $_POST['parent_cat']) {
                         $imgBlogCat['pid'] = $_POST['parent_cat'];
                     }
                     ImgBlogCatUtil::insertImgBlogCat($imgBlogCat);
                 }
                 $v_params['img_blog_cat'] = ImgBlogCatUtil::getImgBlogCat($blog_cat_id, $imgAccount['id']);
                 $v_params['img_blog_cats'] = ImgBlogCatUtil::getImgBlogCatsByAccountId($imgAccount['id']);
                 if (count($v_params['img_blog_cats'])) {
                     foreach ($v_params['img_blog_cats'] as $key => $imgBlogCat) {
                         if ($v_params['img_blog_cat']['id'] == $imgBlogCat['id']) {
                             unset($v_params['img_blog_cats'][$key]);
                         }
                     }
                 }
                 $v_params['img_all_gds_cats_href'] = "/" . IMAG_PREFIX . $img_id . "/" . IMAG_DIR;
                 $v_params['img_all_blog_cats_href'] = "/" . IMAG_PREFIX . $img_id . "/" . BLOG_DIR;
                 $v_params['img_gds_cats_HTML'] = ImgGdsCatUtil::createTreeHTML($imgAccount['id'], "/" . IMAG_PREFIX . $img_id . "/" . IMAG_DIR . "?" . PROD_CAT_PARAM_NAME . "=");
                 $v_params['img_blog_cats_HTML'] = ImgBlogCatUtil::createTreeHTML($imgAccount['id'], "/" . IMAG_PREFIX . $img_id . "/" . BLOG_DIR . "?" . ART_CAT_PARAM_NAME . "=");
                 Application::fastView('imag-admin/art-cats/img_blog_category_au', $v_params);
                 exit;
             } else {
                 if (0 == strcmp("upd", $action)) {
                     $v_params['actname'] = "Редактировать блок статей";
                     if (isset($_GET['ARTcat_id'])) {
                         $blog_cat_id = $_GET['ARTcat_id'];
                         if (isset($_POST['img_cat_name'])) {
                             $imgBlogCat['id'] = $blog_cat_id;
                             $imgBlogCat['account_id'] = $imgAccount['id'];
                             $imgBlogCat['name'] = $_POST['img_cat_name'];
                             if (0 != (int) $_POST['parent_cat']) {
                                 $imgBlogCat['pid'] = $_POST['parent_cat'];
                             }
                             ImgBlogCatUtil::updateImgBlogCat($imgBlogCat);
                         }
                         $v_params['img_blog_cat'] = ImgBlogCatUtil::getImgBlogCat($blog_cat_id, $imgAccount['id']);
                         $v_params['img_blog_cats'] = ImgBlogCatUtil::getImgBlogCatsByAccountId($imgAccount['id']);
                         foreach ($v_params['img_blog_cats'] as $key => $imgBlogCat) {
                             if ($v_params['img_blog_cat']['id'] == $imgBlogCat['id']) {
                                 unset($v_params['img_blog_cats'][$key]);
                             }
                         }
                         $v_params['img_all_gds_cats_href'] = "/" . IMAG_PREFIX . $img_id . "/" . IMAG_DIR;
                         $v_params['img_all_blog_cats_href'] = "/" . IMAG_PREFIX . $img_id . "/" . BLOG_DIR;
                         $v_params['img_gds_cats_HTML'] = ImgGdsCatUtil::createTreeHTML($imgAccount['id'], "/" . IMAG_PREFIX . $img_id . "/" . IMAG_DIR . "?" . PROD_CAT_PARAM_NAME . "=");
                         $v_params['img_blog_cats_HTML'] = ImgBlogCatUtil::createTreeHTML($imgAccount['id'], "/" . IMAG_PREFIX . $img_id . "/" . BLOG_DIR . "?" . ART_CAT_PARAM_NAME . "=");
                         Application::fastView('imag-admin/art-cats/img_blog_category_au', $v_params);
                         exit;
                     }
                 } else {
                     if (0 == strcmp("del", $action)) {
                         $v_params['actname'] = "Удалить блок статей";
                         $blog_cat_id = $_GET['ARTcat_id'];
                         $v_params['img_blog_cat'] = ImgBlogCatUtil::getImgBlogCat($blog_cat_id, $imgAccount['id']);
                         $v_params['img_blog_parent_cat'] = ImgBlogCatUtil::getImgBlogCat($v_params['img_blog_cat']['pid'], $imgAccount['id']);
                         if (isset($_POST['move_cat'])) {
                             $new_cat = $_POST['move_cat'];
                             ImgBlogCatUtil::moveBlogCats($blog_cat_id, $new_cat);
                             ImgBlogArtUtil::moveBlogArtss($blog_cat_id, $new_cat);
                             ImgBlogCatUtil::deleteImgBlogCat($v_params['img_blog_cat']);
                             $ARTcatsURL = $v_params['url_prefix'] . "ARTcats";
                             header("Location: {$ARTcatsURL}");
                         }
                         $v_params['img_blog_cats'] = ImgBlogCatUtil::getImgBlogCatsByAccountId($imgAccount['id']);
                         foreach ($v_params['img_blog_cats'] as $key => $imgBlogCat) {
                             if ($v_params['img_blog_cat']['id'] == $imgBlogCat['id']) {
                                 unset($v_params['img_blog_cats'][$key]);
                             }
                         }
                         $v_params['img_all_gds_cats_href'] = "/" . IMAG_PREFIX . $img_id . "/" . IMAG_DIR;
                         $v_params['img_all_blog_cats_href'] = "/" . IMAG_PREFIX . $img_id . "/" . BLOG_DIR;
                         $v_params['img_gds_cats_HTML'] = ImgGdsCatUtil::createTreeHTML($imgAccount['id'], "/" . IMAG_PREFIX . $img_id . "/" . IMAG_DIR . "?" . PROD_CAT_PARAM_NAME . "=");
                         $v_params['img_blog_cats_HTML'] = ImgBlogCatUtil::createTreeHTML($imgAccount['id'], "/" . IMAG_PREFIX . $img_id . "/" . BLOG_DIR . "?" . ART_CAT_PARAM_NAME . "=");
                         Application::fastView('imag-admin/art-cats/img_blog_category_del', $v_params);
                         exit;
                     }
                 }
             }
         }
     }
     Application::fastView('main/sys_error', $v_params);
 }