delportalcategoryfolder($_GET['catid']);
     $editcat['foldername'] = '';
 }
 $primaltplname = $viewprimaltplname = '';
 if (!empty($_GET['listprimaltplname'])) {
     $primaltplname = $_GET['listprimaltplname'];
     if (!isset($_GET['signs']['list'][dsign($primaltplname)])) {
         cpmsg(cplang('diy_sign_invalid') . ',' . cplang('return'), NULL, 'error');
     }
     $checktpl = checkprimaltpl($primaltplname);
     if ($checktpl !== true) {
         cpmsg(cplang($checktpl) . ',' . cplang('return'), NULL, 'error');
     }
 }
 if (empty($_GET['viewprimaltplname'])) {
     $_GET['viewprimaltplname'] = getparentviewprimaltplname($_GET['catid']);
 } else {
     if (!isset($_GET['signs']['view'][dsign($_GET['viewprimaltplname'])])) {
         cpmsg(cplang('diy_sign_invalid') . ',' . cplang('return'), NULL, 'error');
     }
 }
 $viewprimaltplname = strpos($_GET['viewprimaltplname'], ':') === false ? $_G['cache']['style_default']['tpldir'] . ':portal/' . $_GET['viewprimaltplname'] : $_GET['viewprimaltplname'];
 $checktpl = checkprimaltpl($viewprimaltplname);
 if ($checktpl !== true) {
     cpmsg(cplang($checktpl) . ',' . cplang('return'), NULL, 'error');
 }
 $editcat['primaltplname'] = $primaltplname;
 $editcat['articleprimaltplname'] = $viewprimaltplname;
 if ($_GET['catid']) {
     if ($portalcategory[$_G['catid']]['level'] < 2) {
         $editcat['shownav'] = intval($_GET['shownav']);
         $editcat['foldername'] = $foldername;
     }
 } elseif (empty($foldername) && $portalcategory[$_GET['catid']]['foldername']) {
     delportalcategoryfolder($_GET['catid']);
     $editcat['foldername'] = '';
 }
 $primaltplname = $viewprimaltplname = '';
 if (!empty($_G['gp_listprimaltplname'])) {
     $primaltplname = 'portal/' . $_G['gp_listprimaltplname'];
     $checktpl = checkprimaltpl($primaltplname);
     if ($checktpl !== true) {
         cpmsg(cplang($checktpl) . ',' . cplang('return'), NULL, 'error');
     }
 }
 if (empty($_G['gp_viewprimaltplname'])) {
     $_G['gp_viewprimaltplname'] = getparentviewprimaltplname($_G['gp_catid']);
 }
 $viewprimaltplname = 'portal/' . $_G['gp_viewprimaltplname'];
 $checktpl = checkprimaltpl($viewprimaltplname);
 if ($checktpl !== true) {
     cpmsg(cplang($checktpl) . ',' . cplang('return'), NULL, 'error');
 }
 $editcat['primaltplname'] = $primaltplname;
 $editcat['articleprimaltplname'] = $viewprimaltplname;
 if ($_G['gp_catid']) {
     if ($portalcategory[$_G['catid']]['level'] < 2) {
         $editcat['shownav'] = intval($_G['gp_shownav']);
     }
     if ($domain && $portalcategory[$_G['catid']]['level'] == 0) {
         $editcat['domain'] = $domain;
     } else {