当前位置: 首页>>代码示例>>PHP>>正文


PHP parseForApi函数代码示例

本文整理汇总了PHP中parseForApi函数的典型用法代码示例。如果您正苦于以下问题:PHP parseForApi函数的具体用法?PHP parseForApi怎么用?PHP parseForApi使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parseForApi函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCommentListForApi

 /**
  * 获取评论列表,API使用
  * @param string $where 查询条件
  * @param integer $since_id 主键起始ID,默认为0
  * @param integer $max_id 主键最大ID,默认为0
  * @param integer $limit 每页结果集数目,默认为20
  * @param integer $page 页数,默认为1
  * @param boolean $source 是否获取资源信息,默认为false
  * @return array 评论列表数据
  */
 public function getCommentListForApi($where = '', $since_id = 0, $max_id = 0, $limit = 20, $page = 1, $source = false)
 {
     $since_id = intval($since_id);
     $max_id = intval($max_id);
     $limit = intval($limit);
     $page = intval($page);
     $where = empty($where) ? " is_del = 0 " : $where . ' AND is_del=0';
     if (!empty($since_id) || !empty($max_id)) {
         !empty($since_id) && ($where .= " AND comment_id > {$since_id}");
         !empty($max_id) && ($where .= " AND comment_id < {$max_id}");
     }
     $start = ($page - 1) * $limit;
     $end = $limit;
     $data = $this->where($where)->order('comment_id DESC')->limit("{$start}, {$end}")->findAll();
     foreach ($data as &$v) {
         $v['user_info'] = model('User')->getUserInfo($v['uid']);
         $v['content'] = parseForApi($v['content']);
         $v['ctime'] = date('Y-m-d H:i', $v['ctime']);
         $source && ($v['sourceInfo'] = model('Source')->getCommentSource($v, true));
         /* 解析出emoji */
         $v['content'] = formatEmoji(false, $v['content']);
     }
     is_null($data) && ($data = array());
     return $data;
 }
开发者ID:omusico,项目名称:ThinkSNS-4,代码行数:35,代码来源:CommentModel.class.php

示例2: getFeedInfo

 /**
  * 获取指定分享的信息,用于资源模型输出???
  * @param integer $id 分享ID
  * @param boolean $forApi 是否提供API数据,默认为false
  * @return array 指定分享数据
  */
 public function getFeedInfo($id, $forApi = false)
 {
     $data = model('Cache')->get('group_feed_info_' . $id);
     if ($data) {
         return $data;
     }
     $map['a.feed_id'] = $id;
     // $map['a.is_del'] = 0;//过滤已删除的分享
     $data = $this->where($map)->table("{$this->tablePrefix}group_feed AS a LEFT JOIN {$this->tablePrefix}group_feed_data AS b ON a.feed_id = b.feed_id ")->find();
     $fd = unserialize($data['feed_data']);
     $userInfo = model('User')->getUserInfo($data['uid']);
     $data['ctime'] = date('Y-m-d H:i', $data['publish_time']);
     $data['content'] = $forApi ? parseForApi($fd['body']) : $fd['body'];
     $data['uname'] = $userInfo['uname'];
     $data['avatar_big'] = $userInfo['avatar_big'];
     $data['avatar_middle'] = $userInfo['avatar_middle'];
     $data['avatar_small'] = $userInfo['avatar_small'];
     unset($data['feed_data']);
     // 分享转发
     if ($data['type'] == 'repost') {
         $data['transpond_id'] = $data['app_row_id'];
         $data['transpond_data'] = $this->getFeedInfo($data['transpond_id'], $forApi);
     }
     // 附件处理
     if (!empty($fd['attach_id'])) {
         $data['has_attach'] = 1;
         $attach = model('Attach')->getAttachByIds($fd['attach_id']);
         foreach ($attach as $ak => $av) {
             $_attach = array('attach_id' => $av['attach_id'], 'attach_name' => $av['name'], 'attach_url' => getImageUrl($av['save_path'] . $av['save_name']), 'extension' => $av['extension'], 'size' => $av['size']);
             if ($data['type'] == 'postimage') {
                 $_attach['attach_small'] = getImageUrl($av['save_path'] . $av['save_name'], 100, 100, true);
                 $_attach['attach_middle'] = getImageUrl($av['save_path'] . $av['save_name'], 740);
             }
             $data['attach'][] = $_attach;
         }
     } else {
         $data['has_attach'] = 0;
     }
     if ($data['type'] == 'postvideo') {
         $data['host'] = $fd['host'];
         $data['flashvar'] = $fd['flashvar'];
         $data['source'] = $fd['source'];
         $data['flashimg'] = $fd['flashimg'];
         $data['title'] = $fd['title'];
     }
     $data['feedType'] = $data['type'];
     // 是否收藏分享
     if ($forApi) {
         $data['iscoll'] = model('Collection')->getCollection($data['feed_id'], 'feed');
         if (empty($data['iscoll'])) {
             $data['iscoll']['colled'] = 0;
         } else {
             $data['iscoll']['colled'] = 1;
         }
     }
     // 分享详细信息
     $feedInfo = $this->get($id);
     $data['source_body'] = $feedInfo['body'];
     //一分钟缓存
     model('Cache')->set('group_feed_info_' . $id, $data, 60);
     return $data;
 }
开发者ID:omusico,项目名称:ThinkSNS-4,代码行数:68,代码来源:GroupFeedModel.class.php

示例3: getSourceInfo

 /**
  * 为feed提供应用数据来源信息 - 与模板weiba_post.feed.php配合使用
  * @param integer row_id 帖子ID
  * @param bool _forApi 提供给API的数据
  */
 public function getSourceInfo($row_id, $_forApi = false)
 {
     $info = $this->find($row_id);
     if (!$info) {
         return false;
     }
     $info['source_user_info'] = model('User')->getUserInfo($info['post_uid']);
     $info['source_user'] = $info['post_uid'] == $GLOBALS['ts']['mid'] ? L('PUBLIC_ME') : $info['source_user_info']['space_link'];
     // 我
     $info['source_type'] = L('PUBLIC_WEIBA');
     $info['source_title'] = $forApi ? parseForApi($info['source_user_info']['space_link']) : $info['source_user_info']['space_link'];
     //分享title暂时为空
     $info['source_url'] = U('weiba/Index/postDetail', array('post_id' => $row_id));
     $info['ctime'] = $info['post_time'];
     $feed = D('feed_data')->field('feed_id,feed_content')->find($info['feed_id']);
     $info['source_content'] = $feed['feed_content'];
     $info['app_row_table'] = 'weiba_post';
     $info['app_row_id'] = $info['post_id'];
     return $info;
 }
开发者ID:weiphpdev,项目名称:xindongfang,代码行数:25,代码来源:WeibaPostModel.class.php

示例4: getUserAttachData

 private function getUserAttachData($uid, $limit = 10, $page = 1)
 {
     $map['a.uid'] = $uid;
     $map['a.type'] = 'postimage';
     $map['a.is_del'] = 0;
     $limit_start = ($page - 1) * $limit;
     $list = D()->table('`' . C('DB_PREFIX') . 'feed` AS a LEFT JOIN `' . C('DB_PREFIX') . 'feed_data` AS b ON a.`feed_id` = b.`feed_id`')->field('a.`feed_id`, a.`publish_time`, b.`feed_data`')->where($map)->order('feed_id DESC')->limit($limit_start . ',' . $limit)->findAll();
     // 获取附件信息
     foreach ($list as &$value) {
         $tmp = unserialize($value['feed_data']);
         $attachId = is_array($tmp['attach_id']) ? intval($tmp['attach_id'][0]) : intval($tmp['attach_id']);
         $attachInfo = model('Attach')->getAttachById($attachId);
         $value['savepath'] = $attachInfo['save_path'] . $attachInfo['save_name'];
         $value['name'] = $attachInfo['name'];
         $value['body'] = parseForApi($tmp['body']);
     }
     return $list;
 }
开发者ID:boxshadow,项目名称:ThinkSNS-4,代码行数:18,代码来源:WeiboStatusesApi.class.php

示例5: get_source_info

 /**
  * 获取资源信息 --using
  *
  * @param
  *            varchar app 应用名称
  * @param
  *            integer app_row_table 资源所在表
  * @param
  *            integer app_row_id 资源ID
  * @return array 资源信息
  */
 private function get_source_info($app, $app_row_table, $app_row_id)
 {
     switch ($app) {
         case 'weiba':
             $weiba_post = D('weiba_post')->where('post_id=' . $app_row_id . ' AND is_del = 0')->field('weiba_id,post_uid,title,content')->find();
             if ($weiba_post) {
                 $source_info['user_info'] = $this->get_user_info($weiba_post['post_uid']);
                 $source_info['title'] = $weiba_post['title'];
                 $source_info['content'] = real_strip_tags($weiba_post['content']);
                 $source_info['url'] = 'mod=Weibo&act=weibo_detail&id=' . $app_row_id;
                 $source_info['source_name'] = D('weiba')->where('weiba_id=' . $weiba_post['weiba_id'])->getField('weiba_name');
                 $source_info['source_url'] = 'api.php?mod=Weiba&act=post_detail&id=' . $app_row_id;
                 $source_info['source_imgs'] = array();
                 //获取微吧转发的图片
                 if (!empty($app_row_id)) {
                     $source_info['source_imgs'] = $this->getEditorImages($weiba_post['content']);
                 }
             } else {
                 $source_info['is_del'] = 1;
             }
             break;
         default:
             $tablePrefix = C('DB_PREFIX');
             $map['a.feed_id'] = $app_row_id;
             $map['a.is_del'] = 0;
             $data = model('Feed')->where($map)->table("{$tablePrefix}feed AS a LEFT JOIN {$tablePrefix}feed_data AS b ON a.feed_id = b.feed_id ")->find();
             if ($data['feed_id']) {
                 $source_info['publish_time'] = $data['publish_time'];
                 $source_info['feed_id'] = $app_row_id;
                 $source_info['user_info'] = $this->get_user_info($data['uid']);
                 $source_info['type'] = real_strip_tags($data['type']);
                 $source_info['content'] = real_strip_tags($data['feed_content']);
                 $source_info['content'] = parseForApi($source_info['content']);
                 $source_info['url'] = 'mod=Weibo&act=weibo_detail&id=' . $app_row_id;
                 // 附件处理
                 $feed_data = unserialize($data['feed_data']);
                 if (!empty($feed_data['attach_id'])) {
                     $attach = model('Attach')->getAttachByIds($feed_data['attach_id']);
                     foreach ($attach as $ak => $av) {
                         $_attach = array('attach_id' => $av['attach_id'], 'attach_name' => $av['name']);
                         if ($data['type'] == 'postimage') {
                             $_attach['attach_origin'] = getImageUrl($av['save_path'] . $av['save_name']);
                             $_attach['attach_origin_width'] = $av['width'];
                             $_attach['attach_origin_height'] = $av['height'];
                             if ($av['width'] > 550 && $av['height'] > 550) {
                                 $_attach['attach_small'] = getImageUrl($av['save_path'] . $av['save_name'], 550, 550, true);
                             } else {
                                 $_attach['attach_small'] = $_attach['attach_origin'];
                             }
                         }
                         $source_info['attach_info'][] = $_attach;
                     }
                 } else {
                     $source_info['attach_info'] = array();
                 }
                 if ($data['type'] == 'postvideo') {
                     if ($feed_data['video_id']) {
                         $video_config = model('Xdata')->get('admin_Content:video_config');
                         $video_server = $video_config['video_server'] ? $video_config['video_server'] : SITE_URL;
                         $video_info['video_id'] = $feed_data['video_id'];
                         $video_info['flashimg'] = $video_server . $feed_data['image_path'];
                         $video_info['flash_width'] = $feed_data['image_width'];
                         $video_info['flash_height'] = $feed_data['image_height'];
                         if ($feed_data['transfer_id'] && !D('video_transfer')->where('transfer_id=' . $feed_data['transfer_id'])->getField('status')) {
                             $video_info['transfering'] = 1;
                         } else {
                             $video_info['flashvar'] = $feed_data['video_mobile_path'] ? $video_server . $feed_data['video_mobile_path'] : $video_server . $feed_data['video_path'];
                             $video_info['flashvar_part'] = $video_server . $feed_data['video_part_path'];
                         }
                     } else {
                         $video_info['host'] = $feed_data['host'];
                         $video_info['flashvar'] = $feed_data['source'];
                         $video_info['source'] = $feed_data['source'];
                         $video_info['flashimg'] = UPLOAD_URL . $feed_data['flashimg'];
                         $video_info['title'] = $feed_data['title'];
                     }
                     $source_info['attach_info'][] = $video_info;
                 }
             } else {
                 $source_info['is_del'] = 1;
             }
             break;
     }
     return $source_info;
 }
开发者ID:songhongyu,项目名称:THINKSNS,代码行数:96,代码来源:WeiboApi.class.php

示例6: all_topic

 public function all_topic()
 {
     $max_id = intval($this->data['max_id']);
     $limit = intval($this->data['limit']);
     if (empty($max_id)) {
         $map2['recommend'] = 1;
         $map2['lock'] = 0;
         $res['commends'] = (array) M('feed_topic')->where($map2)->order('recommend_time desc')->limit(5)->findAll();
         empty($res['commends']) || ($map['topic_id'] = array('not in', getSubByKey($res['commends'], 'topic_id')));
     } else {
         $map['topic_id'] = array('lt', $max_id);
     }
     $map['lock'] = 0;
     $res['lists'] = (array) M('feed_topic')->where($map)->order('topic_id desc')->limit($limit)->findAll();
     foreach ($res['lists'] as &$v) {
         $v['topic_name'] = parseForApi($v['topic_name']);
     }
     return $res;
 }
开发者ID:medz,项目名称:thinksns-4,代码行数:19,代码来源:WeiboApi.class.php

示例7: getFeedInfo

 /**
  * 获取指定分享的信息,用于资源模型输出???
  * @param integer $id 分享ID
  * @param boolean $forApi 是否提供API数据,默认为false
  * @return array 指定分享数据
  */
 public function getFeedInfo($id, $forApi = false)
 {
     $data = model('Cache')->get('feed_info_' . $id);
     if ($data !== false && ($forApi === false || $forApi === true && isset($data['iscoll']))) {
         return $data;
     }
     $map['a.feed_id'] = $id;
     // //过滤已删除的分享 wap 版收藏
     // if($forApi){
     // 	$map['a.is_del'] = 0;
     // }
     $data = $this->where($map)->table("{$this->tablePrefix}feed AS a LEFT JOIN {$this->tablePrefix}feed_data AS b ON a.feed_id = b.feed_id ")->find();
     $fd = unserialize($data['feed_data']);
     $userInfo = model('User')->getUserInfo($data['uid']);
     $data['ctime'] = date('Y-m-d H:i', $data['publish_time']);
     $data['content'] = $forApi ? parseForApi($fd['body']) : $fd['body'];
     $data['uname'] = $userInfo['uname'];
     $data['user_group'] = $userInfo['api_user_group'];
     $data['user_gicon'] = $userInfo['group_icon_only'];
     $data['avatar_big'] = $userInfo['avatar_big'];
     $data['avatar_middle'] = $userInfo['avatar_middle'];
     $data['avatar_small'] = $userInfo['avatar_small'];
     unset($data['feed_data']);
     // 分享转发
     if ($data['type'] == 'repost') {
         $data['transpond_id'] = $data['app_row_id'];
         $data['transpond_data'] = $this->getFeedInfo($data['transpond_id'], $forApi);
     }
     // 附件处理
     if (!empty($fd['attach_id'])) {
         $data['has_attach'] = 1;
         $attach = model('Attach')->getAttachByIds($fd['attach_id']);
         foreach ($attach as $ak => $av) {
             $_attach = array('attach_id' => $av['attach_id'], 'attach_name' => $av['name'], 'attach_url' => getImageUrl($av['save_path'] . $av['save_name']), 'extension' => $av['extension'], 'size' => $av['size']);
             if ($data['type'] == 'postimage') {
                 $_attach['attach_small'] = getImageUrl($av['save_path'] . $av['save_name'], 120, 120, true);
                 $_attach['attach_medium'] = getImageUrl($av['save_path'] . $av['save_name'], 240);
                 $_attach['attach_middle'] = getImageUrl($av['save_path'] . $av['save_name'], 740);
                 $_attach['attach_middle_box'] = getImageUrl($av['save_path'] . $av['save_name'], 240, 240, true);
             }
             $data['attach'][] = $_attach;
         }
     } else {
         $data['has_attach'] = 0;
     }
     if ($data['type'] == 'postvideo') {
         if ($fd['video_id']) {
             $video_config = model('Xdata')->get('admin_Content:video_config');
             $video_server = $video_config['video_server'] ? $video_config['video_server'] : SITE_URL;
             $data['video_id'] = $fd['video_id'];
             if ($forApi) {
                 $data['flashvar'] = $fd['video_mobile_path'] ? $video_server . $fd['video_mobile_path'] : $video_server . $fd['video_path'];
                 $data['flashvar_part'] = $video_server . $fd['video_part_path'];
             } else {
                 $data['flashvar'] = $video_server . $fd['video_path'];
             }
             $data['flashimg'] = $video_server . $fd['image_path'];
             $data['flash_width'] = $fd['image_width'];
             $data['flash_height'] = $fd['image_height'];
             if ($fd['transfer_id'] && !D('video_transfer')->where('transfer_id=' . $fd['transfer_id'])->getField('status')) {
                 $data['transfering'] = 1;
             }
         } else {
             $data['host'] = $fd['host'];
             if ($forApi) {
                 $data['flashvar'] = $fd['source'];
             } else {
                 $data['flashvar'] = $fd['flashvar'];
             }
             $data['source'] = $fd['source'];
             $data['flashimg'] = $fd['flashimg'];
             $data['title'] = $fd['title'];
         }
     }
     $data['feedType'] = $data['type'];
     // 是否收藏分享
     if ($forApi) {
         $data['iscoll'] = model('Collection')->getCollection($data['feed_id'], 'feed');
         if (empty($data['iscoll'])) {
             $data['iscoll']['colled'] = 0;
         } else {
             $data['iscoll']['colled'] = 1;
         }
         //是否赞过
         $diggarr = model('FeedDigg')->checkIsDigg($data['feed_id'], $GLOBALS['ts']['mid']);
         $data['is_digg'] = $diggarr[$data['feed_id']] ? 1 : 0;
     }
     //获取赞过分享的人
     $diggs = model('FeedDigg')->where("feed_id=" . $id)->order('id desc')->limit(10)->findAll();
     foreach ($diggs as &$v) {
         $v['user'] = model('User')->getUserInfo($v['uid']);
     }
     $data['diggs'] = $diggs;
     // 分享详细信息
//.........这里部分代码省略.........
开发者ID:nanhuacrab,项目名称:ThinkSNS4,代码行数:101,代码来源:FeedModel.class.php

示例8: getInfoFromComment

 /**
  * 从评论中提取资源数据
  *
  * @param string $table
  *        	资源表名
  * @param integer $row_id
  *        	资源ID
  * @param boolean $forApi
  *        	是否提供API,默认为false
  * @return array 格式化后的资源数据
  */
 private function getInfoFromComment($table, $row_id, $forApi)
 {
     $_info = model('Comment')->getCommentInfo($row_id, true);
     $info['uid'] = $_info['app_uid'];
     $info['row_id'] = $_info['row_id'];
     $info['is_audit'] = $_info['is_audit'];
     $info['source_user'] = $info['uid'] == $GLOBALS['ts']['mid'] ? L('PUBLIC_ME') : $_info['user_info']['space_link'];
     // 我
     $info['comment_user_info'] = model('User')->getUserInfo($_info['user_info']['uid']);
     $forApi && ($info['source_user'] = parseForApi($info['source_user']));
     $info['source_user_info'] = model('User')->getUserInfo($info['uid']);
     $info['source_type'] = L('PUBLIC_STREAM_COMMENT');
     // 评论
     $info['source_content'] = $forApi ? parseForApi($_info['content']) : $_info['content'];
     $info['source_url'] = $_info['sourceInfo']['source_url'];
     $info['ctime'] = $_info['ctime'];
     $info['app'] = $_info['app'];
     $info['sourceInfo'] = $_info['sourceInfo'];
     // 微博title暂时为空
     $info['source_title'] = $forApi ? parseForApi($_info['user_info']['space_link']) : $_info['user_info']['space_link'];
     return $info;
 }
开发者ID:yang7hua,项目名称:hunshe,代码行数:33,代码来源:SourceModel.class.php


注:本文中的parseForApi函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。