| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 | 
							- <?php
 
- namespace Cas\Controller\Admin\Focus;
 
- use KIF\Core\Request;
 
- use Cas\Controller\Admin\Controller;
 
- use KIF\Page\Page;
 
- use Cas\Dao\Platform;
 
- use Cas\Dao\Focus;
 
- use KIF\Verify;
 
- /**
 
-  * "推荐相关" - "列表"[推荐相关信息]
 
-  *
 
-  * @author rabin
 
-  *         页面: "推荐信息"列表 doPageList
 
-  *         页面: 查看&修改 "推荐信息" doPageShow
 
-  *         事件: 创建"推荐信息" doReqCreate
 
-  *         事件: 修改"推荐信息" doReqUp
 
-  *         事件: 删除"推荐信息" doReqDel  
 
-  */
 
- class Index extends Controller {
 
- 	private $objDFocus;
 
- 	private $operatorData;
 
- 	
 
- 	/**
 
- 	 *  初始化
 
- 	 */
 
- 	public function __construct() {
 
- 		header ( "Content-Type: text/html; charset=utf-8" );
 
- 		$this->objDFocus = new Focus ();
 
- 		$this->operatorData = $this->getUser ();
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 默认
 
- 	 */
 
- 	public function doDefault() {
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 页面: "推荐信息"列表
 
- 	 * 地址:http://cas.lishuy.com/?c=Admin_Focus_Index&a=PageList
 
- 	 */
 
- 	public function doPageList() {
 
- 		$page = Request::varGetInt ( 'page', 1 );
 
- 		$size = 10;
 
- 		$offset = ($page - 1) * $size;
 
- 		$limit = "{$offset},{$size}";
 
- 		$condition = array ();
 
- 		$total_num = $this->objDFocus->totals ( $condition );
 
- 		$url_tpl = Request::schemeDomain () . "?c=Admin_Focus_Index&a=PageList";
 
- 		$url_tpl .= "&page={page}";
 
- 		$objPage = new Page ( $total_num, $url_tpl, $page, $size );
 
- 		$page_html = $objPage->html ();
 
- 		
 
- 		$order = '`index` desc, id desc';
 
- 		$ids = $this->objDFocus->findIdsBy ( $condition, $limit, $order );
 
- 		$focusData = $this->objDFocus->gets ( $ids );
 
- 		
 
- 		$this->tpl = 'admin/focus/list';
 
- 		$title = '推荐列表';
 
- 		$this->setOutput('title', $title);
 
- 		$this->setOutput('menu_active', array('name' => 'focuslist', 'item' => 'list')); //激活菜单
 
- 		$this->addNavMenu('推荐设置');
 
- 		$this->addNavMenu($title);
 
- 		$platformList = array ();
 
- 		$objDPlatform = new Platform ();
 
- 		$platformList = $objDPlatform->getsAll ();
 
- 		$this->setOutput ( 'platformList', $platformList ); // 
 
- 		
 
- 		$this->setOutput('pagePublicData', $this->getPagePublicData()); // 后台管理相关数据
 
- 		$this->setOutput ( 'page_html', $page_html ); // 分页Html
 
- 		$this->setOutput ( 'focusData', $focusData ); // 当前"推荐信息"列表数据
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 页面: 查看&修改 "推荐信息"
 
- 	 * 地址:http://cas.lishuy.com/?c=Admin_Focus_Index&a=PageShow&id=nn
 
- 	 * 参数:id "推荐信息"id
 
- 	 */
 
- 	public function doPageShow() {
 
- 		$id = Request::g ( 'id' );
 
- 		
 
- 		$focusData = $this->objDFocus->get ( $id );
 
- 		
 
- 		$this->tpl = 'admin/focus/edit';
 
- 		$title = '编辑推荐信息';
 
- 		$this->setOutput('title', $title);
 
- 		$this->setOutput('menu_active', array('name' => 'focuslist', 'item' => 'list')); //激活菜单
 
- 		$this->addNavMenu('推荐设置');
 
- 		$this->addNavMenu('推荐列表', Request::schemeDomain() . '/?c=Admin_Focus_index&a=PageList');
 
- 		$this->addNavMenu($title);
 
- 		$platformList = array ();
 
- 		$objDPlatform = new Platform ();
 
- 		$platformList = $objDPlatform->getsAll ();
 
- 		$this->setOutput ( 'platformList', $platformList ); // 
 
- 		
 
- 		$this->setOutput('pagePublicData', $this->getPagePublicData()); // 后台管理相关数据
 
- 		
 
- 		$this->setOutput ( 'focusData', $focusData ); // 当前"推荐信息"内容
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 事件:创建"推荐信息"
 
- 	 * 地址:http://cas.lishuy.com/index.php?c=Admin_Focus_Index&a=ReqCreate
 
- 	 * 参数:见方法内
 
- 	 */
 
- 	public function doReqCreate() {
 
- 		$tableInfo = $_POST;
 
- 		$operator_uid = $this->operatorData ['uid'];
 
- 		
 
- 		$info = array_merge($tableInfo, array(
 
- 			'operator_uid' => $operator_uid
 
- 		));
 
- 		
 
- 		$tmpResult = $this->objDFocus->add ( $info );
 
- 		if (!$tmpResult) {
 
- 			$this->ajax_fail_exit('添加新推荐失败');
 
- 		}
 
- 		
 
- 		$this->ajax_success_exit();
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 事件: 修改"推荐信息"
 
- 	 * 地址:http://cas.lishuy.com/index.php?c=Admin_Focus_Index&a=ReqUp
 
- 	 * 参数:见方法内
 
- 	 */
 
- 	public function doReqUp() {
 
- 		$tableInfo = $_POST;
 
- 		
 
- 		$id = $tableInfo['id'];
 
- 		unset($tableInfo['id']);
 
- 		
 
- 		$operator_uid = $this->operatorData ['uid'];
 
- 		
 
- 		$info = array_merge($tableInfo, array(
 
- 			'operator_uid' => $operator_uid
 
- 		));
 
- 		$tmpResult = $this->objDFocus->modify ( $info, array (
 
- 				'id' => $id 
 
- 		) );
 
- 		
 
- 		if (!$tmpResult->isSuccess()) {
 
- 			$this->ajax_fail_exit($tmpResult->getData());
 
- 		}
 
- 		
 
- 		$this->ajax_success_exit();
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 事件: 删除"推荐信息"
 
- 	 * 地址:http://cas.lishuy.com/index.php?c=Admin_Focus_Index&a=ReqDel
 
- 	 * 参数:见方法内
 
- 	 */
 
- 	public function doReqDel() {
 
- 		$id = Request::p ( 'id' );
 
- 		
 
- 		$this->objDFocus->delete ( array (
 
- 				'id' => $id 
 
- 		) );
 
- 		
 
- 		// TODO 根据前端自定义返回结果或跳转
 
- 		header ( "Location: " . Request::schemeDomain () . "/?c=Admin_Focus_Index&a=PageList" );
 
- 		exit ();
 
- 	}
 
- 	public function doDelete() {
 
- 		\KIF\Core\PermissionController::requireCompetence();
 
- 		
 
- 		$id = Request::p('id');
 
- 		if (!Verify::unsignedInt($id)) {
 
- 			$this->ajax_fail_exit('无效id');
 
- 		}
 
- 		
 
- 		$this->objDFocus->delete ( array (
 
- 				'id' => $id 
 
- 		) );
 
- 		$this->ajax_success_exit();
 
- 	}
 
- 	public function display() {
 
- 		return $this->render ();
 
- 	}
 
- }
 
- 	
 
 
  |