Example #1
0
	function XsnsCategoryHandler()
	{
		parent::XsnsRootHandler();
		$this->obj_class = "XsnsCategory";
		$this->table_name = "c_commu_category";
		$this->primary_key = "c_commu_category_id";
		
		$this->handler = array(
			'cat_parent' => XsnsCategoryParentHandler::getInstance(),
			'community' => XsnsCommunityHandler::getInstance(),
		);
	}
function dispatch()
{
	$cat_handler =& XsnsCategoryHandler::getInstance();
	$cat_parent_handler =& XsnsCategoryParentHandler::getInstance();
	
	$msg_ok = _AM_XSNS_CATEGORY_DEL_OK;
	$msg_ng = _AM_XSNS_CATEGORY_DEL_NG;
	
	$mode = $this->getTextRequest('mode');
	
	$id = ($mode=='parent') ? $this->getIntRequest('pid') : $this->getIntRequest('id');
	
	$title = $this->getTextRequest('title'.$id);
	if(empty($title)){
		redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, _AM_XSNS_CATEGORY_NAME_NG);
	}
	
	$order = $this->getIntRequest('order'.$id);
	if($order < 0){
		redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, _AM_XSNS_CATEGORY_ORDER_NG);
	}
	
	if($mode=='parent'){
		$cat_parent =& $cat_parent_handler->get($id);
		if(!is_object($cat_parent)){
			redirect_header(XSNS_URL_ADMIN, 2, _NOPERM);
		}
		
		// 中カテゴリの削除
		$criteria = new Criteria('c_commu_category_parent_id', $id);
		$cat_obj_list =& $cat_handler->getObjects($criteria);
		foreach($cat_obj_list as $cat_obj){
			// 小カテゴリの削除
			$cat_handler->delete($cat_obj);
		}
		$ret = $cat_parent_handler->delete($cat_parent);
	}
	else{
		$cat =& $cat_handler->get($id);
		if(!is_object($cat)){
			redirect_header(XSNS_URL_ADMIN, 2, _NOPERM);
		}
		
		// 小カテゴリの削除
		$ret = $cat_handler->delete($cat);
	}
	
	if($ret && $cat_handler->updateSelector()){
		redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, $msg_ok);
	}
	redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, $msg_ng);
}
function dispatch()
{
	$cat_handler =& XsnsCategoryHandler::getInstance();
	$cat_parent_handler =& XsnsCategoryParentHandler::getInstance();
	
	$title = $this->getTextRequest('title');
	if(empty($title)){
		redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, _AM_XSNS_CATEGORY_NAME_NG);
	}
	
	$order = $this->getIntRequest('order');
	if($order < 0){
		redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, _AM_XSNS_CATEGORY_ORDER_NG);
	}
	
	$mode = $this->getTextRequest('mode');
	
	if($mode=='parent'){
		// 中カテゴリの作成
		$cat_parent =& $cat_parent_handler->create();
		$cat_parent->setVars(array(
			'name' => $title,
			'sort_order' => $order,
			'selector' => '<span></span>'	// NOT NULL
		));
		$ret = $cat_parent_handler->insert($cat_parent);
	}
	else{
		$pid = $this->getIntRequest('pid');
		if($pid < 0){
			redirect_header(XSNS_URL_ADMIN, 2, _AM_XSNS_CATEGORY_ADD_NG);
		}
		// 小カテゴリの作成
		$cat =& $cat_handler->create();
		$cat->setVars(array(
			'name' => $title,
			'sort_order' => $order,
			'c_commu_category_parent_id' => $pid,
		));
		$ret = $cat_handler->insert($cat);
	}
	
	if($ret && $cat_handler->updateSelector()){
		redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, _AM_XSNS_CATEGORY_ADD_OK);
	}
	redirect_header(XSNS_URL_ADMIN.'?'.XSNS_ACTION_ARG.'=category', 2, _AM_XSNS_CATEGORY_ADD_NG);
}
Example #4
0
function dispatch()
{
	$err = $this->checkPermission();
	if(!is_array($err) || count($err) > 0){
		$this->context->setAttribute('perm_error', $err);
		return "default";
	}
	
	$category_p = $category = array();
	
	$criteria = new CriteriaCompo();
	$criteria->setSort('sort_order');
	
	$category_p_handler =& XsnsCategoryParentHandler::getInstance();
	$category_p_obj_list =& $category_p_handler->getObjects($criteria);
	
	foreach($category_p_obj_list as $category_p_obj){
		if(is_object($category_p_obj)){
			$category_p[] = $category_p_obj->getVarsArray();
		}
	}
	unset($criteria);
	
	$criteria = new CriteriaCompo();
	$criteria->setSort('c_commu_category_parent_id,sort_order');
	
	$category_handler =& XsnsCategoryHandler::getInstance();
	$category_obj_list =& $category_handler->getObjects($criteria);
	
	foreach($category_obj_list as $category_obj){
		if(is_object($category_obj)){
			$pid = $category_obj->getVar('c_commu_category_parent_id');
			$category[$pid][] = $category_obj->getVarsArray();
		}
	}
	
	$this->context->setAttribute('category_p', $category_p);
	$this->context->setAttribute('category', $category);
}
Example #5
0
function dispatch()
{
	$limit = 10;
	
	$sess_handler =& XsnsSessionHandler::getInstance();
	$sess_handler->clearVars();
	
	$cid = $this->getIntRequest('cid', XSNS_REQUEST_GET);
	
	if($cid > 0){
		$commu_detail = $this->getCommunityDetail($cid);
		$this->context->setAttribute('commu', $commu_detail);
		
		return "detail";
	}
	
	$start = $this->getIntRequest('s', XSNS_REQUEST_GET);
	if(!isset($start) || $start<0){
		$start = 0;
	}
	
	$cat_id = $this->getIntRequest('cat_id', XSNS_REQUEST_GET);
	$keyword = $this->getTextRequest('keyword', XSNS_REQUEST_GET);
	$sort_method = $this->getTextRequest('sort', XSNS_REQUEST_GET);
	
	$commu_handler =& XsnsCommunityHandler::getInstance();
	
	$criteria = new CriteriaCompo();
	$criteria->setLimit($limit);
	$criteria->setStart($start);
	
	if($cat_id > 0){
		$criteria->add(new Criteria('c_commu_category_id', $cat_id));
	}
	if($keyword != ''){
		$kw_criteria = new CriteriaCompo(new Criteria('name', '%'.$keyword.'%', 'LIKE'));
		$kw_criteria->add(new Criteria('info', '%'.$keyword.'%', 'LIKE'), 'OR');
		$criteria->add($kw_criteria);
	}
	
	switch($sort_method){
		case 'date':
		default:
			$criteria->setSort('cc.r_datetime');
			$criteria->setOrder('DESC');
			break;
		
		case 'member':
			$criteria->setSort('member_count');
			$criteria->setOrder('DESC');
			break;
		
		case 'pop':
			$criteria->setSort('cc.popularity');
			$criteria->setOrder('DESC');
			break;
		
		case 'up':
			$criteria->setSort('cc.update_freq');
			$criteria->setOrder('DESC');
			break;
	}
	$commu_list =& $commu_handler->getList($criteria);
	$commu_total = $commu_handler->getCount($criteria);
	
	$base_url = XSNS_URL_COMMU.'?';
	if($cat_id > 0){
		$base_url .= "&cat_id=".$cat_id;
	}
	if($keyword != ''){
		$base_url .= "&keyword=".rawurlencode($keyword);
	}
	
	if($sort_method=='member' || $sort_method=='date' || $sort_method=='pop' || $sort_method=='up'){
		$base_url .= '&sort='.$sort_method;
	}
	
	$category_handler =& XsnsCategoryHandler::getInstance();
	$category_parent_handler =& XsnsCategoryParentHandler::getInstance();
	$category_selector = $category_handler->getSelectorHtml('cat_id', 0, _MD_XSNS_INDEX_CATEGORY_NO);
	$category_list =& $category_parent_handler->getList();
	
	$pager = $this->getPageSelector($base_url, 
				$start, $limit, count($commu_list), $commu_total);
	
	if(count($commu_list)==0){
		$pager['description'] = _MD_XSNS_INDEX_COMMU_COUNT0;
	}
	
	$keyword_option = empty($keyword)? '' : '&keyword='.rawurlencode($keyword);
	$cat_id_option = empty($cat_id)? '' : '&cat_id='.$cat_id;
	
	$url = array(
		'sort_member' => XSNS_URL_COMMU.'?sort=member'. $keyword_option. $cat_id_option,
		'sort_date' => XSNS_URL_COMMU.'?sort=date'. $keyword_option. $cat_id_option,
		'sort_pop' => XSNS_URL_COMMU.'?sort=pop'. $keyword_option. $cat_id_option,
		'sort_up' => XSNS_URL_COMMU.'?sort=up'. $keyword_option. $cat_id_option,
	);
	
	$this->context->setAttribute('is_guest', $this->isGuest());
	$this->context->setAttribute('keyword', $keyword);
	$this->context->setAttribute('url', $url);
	$this->context->setAttribute('category_selector', $category_selector);
	$this->context->setAttribute('category_list', $category_list);
	$this->context->setAttribute('pager', $pager);
	$this->context->setAttribute('commu_list', $commu_list);
}