站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
建站程序
开发
服务器
办公软件
开发教程
服务器教程
软件使用教程
运营教程
热门电子书
WordPress教程
宝塔面板教程
CSS教程
Shopify教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
ThinkSNS-应用开发范例-开始编程ACTION层
”
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
<span style="text-align:center; border:1px solid #000; float:right; padding:6px;"><strong>导航:</strong> [[ThinkSNS|上一页]]</span> <div style="clear:both;"></div> '''ACTION层''' 在Lib/Action/目录下,建立IndexAction.class.php,并增加以下程序。下面的程序已经附上最详细的注释了。 <pre> <?php class IndexAction extends Action{ private $gift; //礼品表模型 private $gift_category; //礼品类型表模型 private $user_gift; //用户送礼记录表模型 /** * 初始化函数 * */ function _initialize(){ //参数转义 new_addslashes($_POST); new_addslashes($_GET); //整个应用的赋值 $this->gift = D('Gift'); $this->gift_category = D('GiftCategory'); $this->user_gift = D('UserGift'); $this->user_gift->setApi($this->api); $this->user_gift->setGift($this->gift); $this->user_gift->setCategory($this->gift_category); $this->gift_category->setGift($this->gift); $mid = $this->mid; $config = D('AppConfig')->getConfig(); $this->assign('config',$config); } /** * 礼物中心 * */ function index() { //获取分组好的礼物列表 $giftList = $this->gift_category->GiftToCategory(); //把用户姓名和头像赋值给模板 $this->__assignNameAndFace(intval($_GET['uid'])); //赋值给模板 $this->assign('categorys',$giftList); $this->display(); } /** * 收到的礼物 * */ function receivebox(){ //获取收到的礼物列表 $gift = $this->user_gift->receiveList($this->mid); $this->assign('gifts',$gift); $this->display(); } /** * 某人的礼物 * */ function personal(){ //获取用户ID $uid = intval($_GET['uid']); if(empty($uid)){ $this->error('非法操作!'); } $this->assign('uid',$uid); //获取收到的礼物列表 if(isset($_GET['isSend'])) { $gift = $this->user_gift->sendList($uid); $this->assign('on2','on'); }else{ $gift = $this->user_gift->receiveList($uid); $this->assign('on1','on'); } $this->assign('gifts',$gift); $this->display(); } /** * 送出的礼物 * */ function sendBox(){ //获取送出的礼物列表 $gift = $this->user_gift->sendList($this->mid); $this->assign('gifts',$gift); $this->display(); } /** * 送出礼物 * */ function send(){ //获取当前用户的ID 和姓名 $fromUid = $this->mid; $fromUserName = $this->my_name; //获取要发送的好友ID,如有不明可参考'好友选择widget'的说明 $toUserId = $_POST['fri_ids']; if(empty($toUserId)){ $this->error('你还没有选择好友'); exit; } //获取附加信息 $sendInfo['sendInfo'] = t($_POST['sendInfo']); //获取发送方式 $sendInfo['sendWay'] = t($_POST['sendWay']); //获取礼品ID 并用t 函数过滤 $giftId = t($_POST['giftId']); //查询数据库获取礼品的全部信息 $giftInfo = $this->gift->where('id='。$giftId)->find(); //发送礼品 $result = $this->user_gift- >sendGift($toUserId,$fromUid,$fromUserName,$sendInfo,$giftInfo); if($result==1){ //如果发送成功就跳到‘送出的礼品’页面 $this->redirect('sendbox'); }else{ //如果发送失败就跳转到错误提示页并显示失败原因 $this->error($result); } } /** * 把用户姓名和头像赋值给模板 * */ private function __assignNameAndFace($uid){ if($uid && $uid != $this->mid){ $toUserName = getUserName($uid); $toUserFace = getUserFace($uid); $this->assign('toUserName',$toUserName); $this->assign('toUserFace',$toUserFace); } } } ?> </pre> ==参考资料== *[http://www.thinksns.com 参考来源] [[category:ThinkSNS]]
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)