';
echo '
';
echo $template;
echo '
';
showformfooter();
}
} elseif($operation=='delete') {
$_GET['styleid'] = intval($_GET['styleid']);
$thestyle = C::t('common_block_style')->fetch($_GET['styleid']);
if(empty($thestyle)) {
cpmsg('blockstyle_not_found', 'action=blockstyle', 'error');
}
$styles = array();
if(($styles = C::t('common_block_style')->fetch_all_by_blockclass($thestyle['blockclass']))) {
unset($styles[$_GET['styleid']]);
}
if(empty($styles)) {
cpmsg('blockstyle_should_be_kept', 'action=blockstyle', 'error');
}
if(submitcheck('deletesubmit')) {
$_POST['moveto'] = intval($_POST['moveto']);
$newstyle = C::t('common_block_style')->fetch($_POST['moveto']);
if($newstyle['blockclass'] != $thestyle['blockclass']) {
cpmsg('blockstyle_blockclass_not_match', 'action=blockstyle', 'error');
}
C::t('common_block')->update_by_styleid($styleid, array('styleid' => $_POST[moveto]));
C::t('common_block_style')->delete($_GET['styleid']);
updatecache('blockclass');
cpmsg('blockstyle_delete_succeed', 'action=blockstyle', 'succeed');
}
if(C::t('common_block')->fetch_by_styleid($_GET['styleid'])) {
showtips('blockstyle_delete_tips');
showformheader('blockstyle&operation=delete&styleid='.$_GET['styleid']);
showtableheader();
$movetoselect = '
';
showsetting('blockstyle_moveto', '', '', $movetoselect);
showsubmit('deletesubmit');
showtablefooter();
showformfooter();
} else {
C::t('common_block_style')->delete($_GET['styleid']);
updatecache('blockclass');
cpmsg('blockstyle_delete_succeed', 'action=blockstyle', 'succeed');
}
} else {
$_GET = $_GET + $_POST;
$searchctrl = '
'
.''.cplang('show_search').''
.''.cplang('hide_search').''
.'';
showsubmenu('blockstyle', array(
array('list', 'blockstyle', 1),
array('add', 'blockstyle&operation=add', 0)
), $searchctrl);
$mpurl = ADMINSCRIPT.'?action=blockstyle';
$intkeys = array('styleid');
$strkeys = array('blockclass');
$randkeys = array();
$likekeys = array('name', 'template');
$results = getwheres($intkeys, $strkeys, $randkeys, $likekeys);
foreach($likekeys as $k) {
$_GET[$k] = dhtmlspecialchars($_GET[$k]);
}
$wherearr = $results['wherearr'];
$mpurl .= '&'.implode('&', $results['urls']);
$wheresql = empty($wherearr)?'1':implode(' AND ', $wherearr);
$orders = getorders(array('blockclass'), 'styleid');
$ordersql = $orders['sql'];
if($orders['urls']) $mpurl .= '&'.implode('&', $orders['urls']);
$orderby = array($_GET['orderby']=>' selected');
$ordersc = array($_GET['ordersc']=>' selected');
$perpage = empty($_GET['perpage'])?0:intval($_GET['perpage']);
if(!in_array($perpage, array(10,20,50,100))) $perpage = 20;
$perpages = array($perpage=>' selected');
$mpurl .= '&perpage='.$perpage;
$searchlang = array();
$keys = array('search', 'likesupport', 'resultsort', 'defaultsort', 'orderdesc', 'orderasc', 'perpage_10', 'perpage_20', 'perpage_50', 'perpage_100',
'blockstyle_id', 'blockstyle_name', 'blockstyle_blockclass', 'blockstyle_template');
foreach ($keys as $key) {
$searchlang[$key] = cplang($key);
}
$blockclass_sel = '
';
$adminscript = ADMINSCRIPT;
echo <<
SEARCH;
$start = ($page-1)*$perpage;
showformheader('blockstyle');
showtableheader('blockstyle_list');
showsubtitle(array('blockstyle_name', 'blockstyle_blockclass', 'operation'));
$multipage = '';
if(($count = C::t(common_block_style)->count_by_where($wheresql))) {
include_once libfile('function/block');
foreach(C::t('common_block_style')->fetch_all_by_where($wheresql, $ordersql, $start, $perpage) as $value) {
$theclass = block_getclass($value['blockclass']);
list($c1, $c2) = explode('_', $value['blockclass']);
showtablerow('', array('class=""', 'class=""', 'class="td28"'), array(
$value['name'],
$theclass['name'],
"".cplang('blockstyle_edit')." ".
"".cplang('blockstyle_delete').""
));
}
$multipage = multi($count, $perpage, $page, $mpurl);
}
showsubmit('', '', '', '', $multipage);
showtablefooter();
showformfooter();
}
?>