/** * replace * 对数据集进行追加处理 * @param array $data 数据集 * @param array $mention 需要被追加的值 * @access protected * @return void */ protected function replace($data, $mentiondata = null) { $result = $data; $categoryname = $this->getCategory(null); //获取所有的分类 //如果$mention为空就需要从数据库中取出数据 if (empty($mentiondata)) { $mention = self::factoryModel('mention'); $mentioncontent = $mention->getUserMention(); } //TODO 配置信息,截取字数控制 foreach ($result as &$value) { $value['category'] = array("name" => $categoryname[$value['category']]['name'], "id" => $value['category']); //替换日志类型 //追加日志中提到的内容 $value['mention'] = !isset($mentiondata) ? $mentioncontent[$value['id']] : $mentiondata[$value['id']]; //日志截断 $short = $this->config->titleshort == 0 ? 4000 : $this->config->titleshort; if (StrLenW($value['content']) > $short) { $value['content'] = getBlogShort($value['content'], $short) . $this->config->suffix; } } return $result; }
/** * doAddEvent * 添加活动 * @param mixed $map * @param mixed $feed * @access public * @return void */ public function doAddEvent($eventMap, $optsMap, $cover) { $eventMap['cTime'] = isset($eventMap['cTime']) ? $eventMap['cTime'] : time(); $eventMap['coverId'] = $cover['status'] ? $cover['info'][0]['id'] : 0; $eventMap['limitCount'] = 0 == intval($eventMap['limitCount']) ? 999999999 : $eventMap['limitCount']; $eventMap['explain'] = nl2br($eventMap['explain']); $has_friend = $optsMap['opts']['friend']; $optsMap['opts'] = serialize($optsMap['opts']); //false $optsDao = D('EventOpts'); if ($eventMap['optsId'] = $optsDao->add($optsMap)) { $eventMap = $this->merge($eventMap); $addId = $this->add($eventMap); } else { return false; } //添加参与动作 $user = self::factoryModel('user'); $map['uid'] = $eventMap['uid']; $map['name'] = $eventMap['name']; $map['eventId'] = $addId; $map['action'] = 'admin'; $map['ctime'] = 'cTime'; $user->add($map); //如果是只有好友可参与,给所有好友发送通知 if (1 == $has_friend) { $temp = $this->api->friend_get(); $title_data['title'] = sprintf("<a href=\"%s/Index/eventDetail/id/%s/uid/%s\">%s</a>", __APP__, $addId, $eventMap['uid'], $eventMap['title']); $body['content'] = getBlogShort(t($eventMap['explain']), 40); $url = sprintf("%s/eventDetail/id/%s/uid/%s", __URL__, $addId, $eventMap['uid']); $this->doNotify($temp, "add_event", $title_data, $body, $url); } //发送动态 $title['title'] = sprintf("<a href=\"%s/Index/eventDetail/id/%s/uid/%s\">%s</a>", __APP__, $addId, $eventMap['uid'], $eventMap['title']); //$body['content'] = getBlogShort(t($map['explain']),40); $feedId = $this->doFeed("event", $title); if ($feedId != false) { $temp['feedId'] = $feedId; $this->where('id =' . $addId)->save($temp); } $count = $this->where('uid=' . $map['uid'] . ' AND deadline>' . time())->count(); $result = $this->api->space_changeCount('event', $count); return $addId; }
/** * replace * 对数据集进行追加处理 * @param array $data 数据集 * @param array $mention 需要被追加的值 * @access protected * @return void */ protected function replace($data, $mentiondata = null) { $result = $data; $categoryname = $this->getCategory(null); //获取所有的分类 //TODO 配置信息,截取字数控制 foreach ($result as &$value) { if (3 == $value['private']) { // if(Cookie::get($value['id'].'password') == $value['private_data']) { // $value['private'] = 0; // } Change } $value['content'] = str_replace("&nbsp;", "", h($value['content'])); // $value['category'] = array( // "name" => $categoryname[$value['category']]['name'], // "id" => $value['category']); //替换文章类型 //文章截断 $short = $this->config->titleshort == 0 ? 4000 : $this->config->titleshort; $suffix = StrLenW($value['content']) > $short ? $this->config->suffix : ''; $value['content'] = getBlogShort($value['content'], $short) . $suffix; //文章标题 $value['title'] = stripslashes($value['title']); } return $result; }
public function insert() { $title = $_POST['title']; $content = $_POST['content']; if (empty($title) || empty($content)) { $this->error('日志不能为空!'); exit; } $dao = D('Blog'); $dao->title = $title; $dao->content = $content; $dao->cTime = time(); $dao->userId = $this->mid; //$dao->tagIds = $this->addTag($_POST['tags']); if ($result = $dao->add()) { /* 可以插入日志标签 * / $this->addTagIndex($_POST['tags'],$result); /**/ /* add_user_feed */ $feedTitle = "添加了新日志"; $blogImages = matchImages(stripslashes($content)); if ($blogImages) { $feedInfo .= "<a href=\"/Blog/content/id/{$result}\"><img src=\"" . WEB_PUBLIC_URL . "/Thumb/?w=100&h=100&t=f&url={$blogImages[0]}\" alt=\"{$title}\" /></a>"; } $feedInfo .= "<strong><a href=\"/Blog/content/id/{$result}\">{$title}</a></strong><br />" . getBlogShort($content); $this->addUserFeed($this->mid, 'add', 'blog', $result, $feedTitle, $feedInfo); /* /add_user_feed */ header('location:' . __APP__ . '/blog/' . $result); //$this->success("添加日志成功!",$result); } else { $this->error("添加日志失败!"); } }
function doaddShare() { $type['typeId'] = 5; $type['typeName'] = '日志'; $type['alias'] = 'blog'; $info = h($_REQUEST['info']); $aimId = intval($_REQUEST['aimId']); $field = 'name,uid,content,title'; $data = $this->blog->where("id='{$aimId}'")->field($field)->find(); //$data['title'] = h($_REQUEST['title']); $intro = str_replace("&nbsp;", "", t($data['content'])); $data['intro'] = getBlogShort($intro, 120); $fids = $_REQUEST['fids']; $result = $this->api->share_addShare($type, $aimId, $data, $info, 0, $fids); echo $result; }
function getShareContent($module = 'Space', $id) { $content = ''; if ($module == 'Space') { $blog = D('User')->find($id); $userFace = getUserFace($id, 'm'); $userName = getUserName($id); $userProvince = getUserProvince($id); $userNews = getUserNews($id); $content .= "<div class=\"share-content-photo\"><a href=\"" . __APP__ . "/space/" . $id . "\"><img src=\"" . $userFace . "\" alt=\"" . $userName . "\"></a></div>"; $content .= "<div class=\"share-content-desc\"><strong><a href=\"" . __APP__ . "/space/" . $id . "\">" . $userName . "</a></strong><br>" . $userProvince . "<br><br>" . $userNews . "</div>"; } else { if ($module == 'Blog') { $blog = D('Blog')->find($id); $titleImage = getBlogTitleImage($id); if ($titleImage) { $content .= "<div class=\"share-content-photo\"><a href=\"" . __APP__ . "/blog/" . $blog->id . "\"><img src=\"" . WEB_PUBLIC_URL . "/Thumb/?w=72&h=72&url=" . $titleImage . "\" alt=\"" . $blog->title . "\"></a></div>"; } $content .= "<div class=\"share-content-desc\"><strong><a href=\"" . __APP__ . "/blog/" . $blog->id . "\">" . $blog->title . "</a></strong> - <a href=\"" . __APP__ . "/space/" . $blog->userId . "\">" . getUserName($blog->userId) . "</a><br>" . getBlogShort($blog->content) . "<br><a href=\"" . __APP__ . "/blog/" . $blog->id . "\">阅读全文</a></div>"; } else { if ($module == 'Photo') { $photo = D('Photo')->find($id); $titleImage = $photo->imagePath; $album = D('Album')->find($photo->albumId); if ($titleImage) { $content .= "<div class=\"share-content-photo\"><a href=\"" . __APP__ . "/photo/" . $photo->id . "\"><img src=\"" . WEB_PUBLIC_URL . "/Thumb/?w=130&h=200&t=f&url=" . $titleImage . "\" alt=\"" . $photo->title . "\"></a></div>"; } $content .= "<div class=\"share-content-desc\">相册:<a href=\"" . __APP__ . "/album/" . $album->id . "\">" . $album->title . "</a><br>用户:<a href=\"" . __APP__ . "/space/" . $photo->userId . "\">" . getUserName($photo->userId) . "</a><br><strong><a href=\"__APP__/photo/" . $photo->id . "\">" . $photo->title . "</a></strong></div>"; } else { if ($module == 'Album') { $album = D('Album')->find($id); $titleImage = $album->coverPhotoId; if ($titleImage > 0) { $titleImage = D('Photo')->find($album->coverPhotoId)->imagePath; $content .= "<div class=\"share-content-photo\"><a href=\"" . __APP__ . "/album/" . $album->id . "\"><img src=\"" . WEB_PUBLIC_URL . "/Thumb/?w=130&h=200&t=f&url=" . $titleImage . "\" alt=\"" . $album->title . "\"></a></div>"; } $content .= "<div class=\"share-content-desc\"><strong><a href=\"" . __APP__ . "/album/" . $album->id . "\">" . $album->title . "</a></strong> - <a href=\"" . __APP__ . "/space/" . $album->userId . "\">" . getUserName($album->userId) . "</a><br>共" . $album->photoCount . "张照片<br>" . $album->info . "</div>"; } } } } return $content; }