/** * Лента комментов */ public function executeIndex(sfWebRequest $request) { $this->executeNew(); $this->pager = new sfDoctrinePager('Comment', sfConfig::get('app_comments_per_page', 10)); $this->pager->setQuery(CommentTable::getInstance()->queryByPoint($this->point->getId())); $this->pager->setPage($request->getParameter('page')); $this->pager->init(); }
/** * 根据视频直播的id 查询出对应的评论列表 * @param unknown $vid */ public function get_comment_by_vid($vid) { $table = new CommentTable(); $comm_list = $table->get_comments_by_vid($vid); $userModule = new UserModule(@$user_id); date_default_timezone_set("Asia/Shanghai"); foreach ($comm_list as $comment) { $user_info = $userModule->get_by_id($comment->user->uuid); $now_time = date("Y-m-d H:i:s"); $comm_sub_time = $comment->subtime; $timestamp = strtotime($now_time) - strtotime($comm_sub_time); $str_time = ""; if ($timestamp < 0) { $str_time = $timestamp; } else { if ($timestamp < 60) { // $str_time = $timestamp . "秒前"; } else { if ($timestamp < 3600) { $str_time = floor($timestamp / 60) . "分钟前"; } else { if ($timestamp < 86400) { $str_time = floor($timestamp / 3600) . "小时前"; } else { if ($timestamp < 259200) { // 3天 $str_time = floor($timestamp / 86400) . "天前"; } else { $str_time = "3天以前"; } } } } } $comment->subtime = $str_time; // 距离现在过了多久 $comment->user = $user_info[0]; } return $comm_list; }
/** * Add an item to the exporting list * * @param Item $item The item to export * @param Type $type The type of the item * * @return AppExporterZoo2 $this for chaining support * * @since 2.0 */ protected function _addZooItem(Item $item, Type $type) { $data = array(); foreach ($this->item_attributes as $attribute) { if (isset($item->{$attribute})) { $data[$attribute] = $item->{$attribute}; } } if ($user = $this->app->user->get($item->created_by)) { $data['author'] = $user->username; } $data['tags'] = $item->getTags(); // store item content, metadata, config params $data['content'] = $item->getParams()->get('content.'); $data['metadata'] = $item->getParams()->get('metadata.'); $data['config'] = $item->getParams()->get('config.'); // add categories foreach ($item->getRelatedCategoryIds() as $category_id) { $alias = ''; if (empty($category_id)) { $alias = '_root'; } else { if (isset($this->_categories[$category_id])) { $alias = $this->_categories[$category_id]->alias; } } if (!empty($alias)) { $data['categories'][] = $alias; } if ($item->getPrimaryCategoryId() == $category_id) { $data['config']['primary_category'] = $alias; } } foreach ($item->elements as $identifier => $element_data) { if (!($element = $type->getElement($identifier))) { continue; } $element_type = $element->getElementType(); switch ($element_type) { case 'relateditems': $items = array(); if (isset($element_data['item'])) { foreach ($element_data['item'] as $item_id) { $items[] = $this->app->alias->item->translateIDToAlias($item_id); } } $element_data['item'] = $items; break; case 'relatedcategories': $categories = array(); if (isset($element_data['category'])) { foreach ($element_data['category'] as $category_id) { $categories[] = isset($this->_categories[$category_id]) ? $this->_categories[$category_id]->alias : $this->app->alias->category->translateIDToAlias($category_id); } } $element_data['category'] = $categories; break; } $data['elements'][$identifier]['type'] = $element_type; $data['elements'][$identifier]['name'] = $element->config->get('name'); $data['elements'][$identifier]['data'] = $element_data; foreach ($this->_comment_table->getCommentsForItem($item->id) as $comment) { foreach ($this->comment_attributes as $attribute) { if (isset($comment->{$attribute})) { $data['comments'][$comment->id][$attribute] = $comment->{$attribute}; } } if ($comment->user_type == 'joomla' && ($user = $this->app->user->get($comment->user_id))) { $data['comments'][$comment->id]['username'] = $user->username; } } } parent::_addItem($item->name, $item->alias, $type->name, $data); }
<?php require_once ykfile("source/dbtables/comment_table.php"); require_once ykfile("source/user_service.php"); require_once ykfile("source/score_service.php"); $json_param = json_decode(file_get_contents("php://input")); $user_id = $json_param->user_id; $video_id = $json_param->video_id; $detail = $json_param->detail; $comment = new CommentModel(); $comment->user->uuid = $user_id; $comment->video_live->id = $video_id; $comment->detail = $detail; $table = new CommentTable(); $rcode = $table->insert_comment($comment); $message = ""; if (!$rcode) { $message = "评论失败"; } else { $comm = $table->get_by_id($rcode); $userModule = new UserModule(@$user_id); date_default_timezone_set("Asia/Shanghai"); $user_info = $userModule->get_by_id($comm->user->uuid); $scoreSer = new ScoreService(); $rule_list = $scoreSer->apply_rule($user_info, GET_SCORE, ScoreModule::point_comment); file_put_contents("/tmp/yike.log", "rule_liist --->" . $rule_list, FILE_APPEND); if ($rule_list) { $message = ""; foreach ($rule_list as $rule) { $msg = $rule->title . " + " . $rule->amount; $message[] = $msg;
/** * @param sfWebRequest $request */ public function executeIndex(sfWebRequest $request) { $decision_id = $request->getParameter('decision_id', false); $this->decision = DecisionTable::getInstance()->getDecisionForUser($this->getUser()->getGuardUser(), $decision_id); $this->forward404Unless($this->decision); $this->forward404Unless($this->getUser()->verifyLightAccess($this->getContext())); $this->criteriaAnalyze = new CriteriaAnalyze(); $this->criteriaAnalyze->setDecisionId($decision_id); if ($this->decision->save_graph_weight) { $this->criteriaAnalyze->loadData(); } else { $this->criteriaAnalyze->load(); } $this->logicalFilter = new LogicalFilterView(); $this->logicalFilter->setDecisionId($decision_id); $this->logicalFilter->load(); $this->roleFilter = new RoleFilterView(); $this->roleFilter->setDecisionId($decision_id); $this->roleFilter->load(); $this->statusFilter = new StatusFilterView(); $this->statusFilter->setDecisionId($decision_id); $this->statusFilter->load(); $this->tagFilter = new TagFilterView(); $this->tagFilter->setDecisionId($decision_id); $this->tagFilter->load(); $this->stackedBarChart = new StackedBarChart(); $this->stackedBarChart->setDecisionId($decision_id); $this->stackedBarChart->setCriteriaValues($this->criteriaAnalyze->getCriteriaValues()); $this->stackedBarChart->setRoleFilterData($this->roleFilter->getData()); $this->stackedBarChart->setStatusFilterData($this->statusFilter->getData()); $this->stackedBarChart->setTagFilterData($this->tagFilter->getDataForSQL()); $this->stackedBarChart->setFilteredAlternativesIds($this->logicalFilter->getFilteredAlternativesIds()); $this->stackedBarChart->load(); $this->radarChart = new RadarChart(); $this->radarChart->setData($this->stackedBarChart->getData()); $this->radarChart->setAlternativeNames($this->stackedBarChart->getAlternativesNames()); $this->radarChart->setCriteriaNames($this->stackedBarChart->getCriteriaNames()); $this->radarChart->setAlternativesLabel($this->decision->getAlternativePluralAlias()); $this->pointChart = new PointChart(); $this->pointChart->setDecisionId($decision_id); $this->pointChart->setRoleFilterData($this->roleFilter->getData()); $this->pointChart->setStatusFilterData($this->statusFilter->getData()); $this->pointChart->setTagFilterData($this->tagFilter->getDataForSQL()); $this->pointChart->setFilteredAlternativesIds($this->logicalFilter->getFilteredAlternativesIds()); $this->pointChart->load(); $this->pointChart->setTotalBenefit($this->stackedBarChart->getTotalBenefit()); $this->costAnalyze = new CostAnalyze(); $this->costAnalyze->setDecisionId($decision_id); $this->costAnalyze->setSortedAlternativeIds($this->stackedBarChart->getSortedAlternativeIds()); $this->costAnalyze->setRoleFilterData($this->roleFilter->getData()); $this->costAnalyze->setStatusFilterData($this->statusFilter->getData()); $this->costAnalyze->setTagFilterData($this->tagFilter->getDataForSQL()); $this->costAnalyze->setCumulativeData($this->stackedBarChart->getCumulativeData()); $this->costAnalyze->setFilteredAlternativesIds($this->logicalFilter->getFilteredAlternativesIds()); $this->costAnalyze->load(); $this->cumulativeChart = new CumulativeGainChart(); $this->cumulativeChart->setDecisionId($decision_id); $this->cumulativeChart->setSortedAlternativeIds($this->stackedBarChart->getSortedAlternativeIds()); $this->cumulativeChart->setMeasurement($this->stackedBarChart->getCumulativeData()); $this->cumulativeChart->setCostData($this->costAnalyze->getData()); $this->cumulativeChart->setAlternativeNames($this->costAnalyze->getAlternativeNames()); $this->cumulativeChart->setCriterionNames($this->costAnalyze->getCriteria()); $this->cumulativeChart->load(); $this->bubbleChart = new BubbleChart(); $this->bubbleChart->setDecisionId($decision_id); $this->bubbleChart->setRoleFilterData($this->roleFilter->getData()); $this->bubbleChart->setStatusFilterData($this->statusFilter->getData()); $this->bubbleChart->setTagFilterData($this->tagFilter->getDataForSQL()); $this->bubbleChart->setFilteredAlternativesIds($this->logicalFilter->getFilteredAlternativesIds()); $this->bubbleChart->setTotalBenefit($this->stackedBarChart->getTotalBenefit()); $this->bubbleChart->load(); $this->releases = ProjectReleaseTable::getInstance()->getList($decision_id); $this->comments = CommentTable::getInstance()->getList($decision_id); }
public function load() { $this->criteria = Doctrine::getTable('Criterion')->getPlannedForPrioritization($this->role->id); $this->decision = Doctrine_Query::create()->from('Decision d')->where('d.Roles.id = ?', $this->role->id)->fetchOne(); $this->comments = CommentTable::getInstance()->getArrayByCriteria($this->criteria->getPrimaryKeys()); }
public function load() { $this->alternatives = Doctrine::getTable('Alternative')->getPlannedForMeasurement($this->role->id, $this->criterion_id); $this->criterion = Doctrine::getTable('Criterion')->find($this->criterion_id); $this->comments = CommentTable::getInstance()->getArrayForAlternatives($this->criterion_id, $this->alternatives->getPrimaryKeys(), $this->role); }
$manageObj->addColumn("Newswire", "title", "VARCHAR(255) default ''"); $manageObj->addColumn("Newswire", "caption", "TEXT default ''"); $manageObj->addColumn("Newswire", "source", "VARCHAR (150) default ''"); $manageObj->addColumn("Newswire", "url", "VARCHAR(255) default ''"); $manageObj->addColumn("Newswire", "date", "DATETIME"); // to do - deprecate $manageObj->addColumn("Newswire", "wireid", "INT(11) default 0"); // deprecated $manageObj->addColumn("Newswire", "feedid", "INT(11) default 0"); if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'content.class.php')) { require_once PATH_CORE . '/classes/content.class.php'; ContentTable::createTable($manageObj); } if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'comments.class.php')) { require_once PATH_CORE . '/classes/comments.class.php'; CommentTable::createTable($manageObj); } if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'cron.class.php')) { require_once PATH_CORE . '/classes/cron.class.php'; CronJobsTable::createTable($manageObj); } if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'log.class.php')) { require_once PATH_CORE . '/classes/log.class.php'; LogTable::createTable($manageObj); LogExtraTable::createTable($manageObj); } // Resources for Folders and Links $manageObj->addTable("Folders", "id", "INT(11) unsigned NOT NULL auto_increment", "MyISAM"); $manageObj->addColumn("Folders", "folderid", "INT(11) NOT NULL default 0"); $manageObj->addColumn("Folders", "uid", "INT(11) NOT NULL default 0"); $manageObj->addColumn("Folders", "title", "VARCHAR(50) default ''");
function buildActionItem($action) { require_once PATH_CORE . '/classes/user.class.php'; require_once PATH_CORE . '/classes/template.class.php'; $uit = new UserInfoTable($this->db); $fbIds = $uit->getFbIdsForUsers(array($action->userid1)); $fbId = $fbIds[0]; if ($action->userid2) { $fbIds2 = $uit->getFbIdsForUsers(array($action->userid2)); $fbId2 = $fbIds2[0]; } if (!$fbId) { // cant return anything or #&*$@! paging gets screwed //$code .= '<div class="hidden">No fbId found for userid '. $action->userid1 . '</div>'; $this->db->log("Action Feed: No fbId found for userid {$action->userid1} performing {$action->action} on {$action->t}"); return ''; //$code; } $ago .= self::getElapsedString(strtotime($action->t)); switch ($action->action) { case 'completedChallenge': $code .= $this->fetchChallengeCompletedFeedItem($action, $fbId, false); // hack for now so the console can access it also //$ct = new ChallengeTable($this->db); break; case 'signup': /*$code .= template::buildLinkedProfilePic($fbIds[0], 'size="square"') .' '. template::buildLinkedProfileName($fbIds[0]) .' joined the action team!'; */ $code .= '<div class="profilePicLarger">' . template::buildLinkedProfilePic($fbIds[0], 'size="square"') . ' ' . '</div> <div class="storyBlockWrap"> <h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' joined the ' . SITE_TEAM_TITLE . '!</span> ' . $ago . '</h3> </div><!__end "storyBlockWrap"__>'; break; case 'friendSignup': $code .= '<div class="profilePicLarger">' . template::buildLinkedProfilePic($fbIds[0], 'size="square"') . ' ' . '</div> <div class="storyBlockWrap"> <h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' got credit for inviting ' . template::buildLinkedProfileName($fbId2) . '!</span> ' . $ago . '</h3> </div><!__end "storyBlockWrap"__>'; break; case 'chatStory': require_once PATH_CORE . '/classes/content.class.php'; $contentTable = new ContentTable($this->db); $content = $contentTable->getRowObject(); $contentid = $action->itemid; // hack: since jeff put the fbId in itemid2 for chatStory $fbId2 = $action->userid2; if ($content->load($contentid)) { $code .= ' <div class="thumb">' . template::buildLinkedStoryImage($content->imageid, $contentid) . '</div> <div class="storyBlockWrap"> <div class="feed_poster">' . '<div class="avatar">' . template::buildLinkedProfilePic($fbIds[0], 'size="square" with="30" height="30"') . '</div>' . '<div class="avatar">' . template::buildLinkedProfilePic($fbId2, 'size="square" with="30" height="30"') . '</div>' . '<h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' chatted with ' . template::buildLinkedProfileName($fbId2) . ' about the story ' . template::buildStoryLink($content->title, $contentid) . '</span> ' . $ago . '</h3> </div> </div><!__end "storyBlockWrap"__>'; } break; //case 'acceptedInvite': // actually want to filter these? // yeah, dont show these //break; //case 'acceptedInvite': // actually want to filter these? // yeah, dont show these //break; case 'redeemed': require_once PATH_CORE . '/classes/prizes.class.php'; $prizeTable = new PrizeTable($this->db); $prize = $prizeTable->getRowObject(); if ($prize->load($action->itemid) && !$prize->isWeekly && !$prize->isGrand) { /* $indefarticle = template::getIndefiniteArticle($prize->title); $code .= template::buildLinkedProfilePic($fbIds[0], 'size="square"') .' '. template::buildLinkedProfileName($fbIds[0]) ." used {$prize->pointCost} points to get $indefarticle " . template::buildRewardLink($prize->title, $prize->id) ."" . template::buildLinkedRewardPic($prize->id, $prize->thumbnail, $width=70); //$code .= ' '. self::getElapsedString(strtotime($action->t)); */ $code .= '<div class="thumb">' . template::buildLinkedRewardPic($prize->id, $prize->thumbnail, $width = 70) . '</div> <div class="storyBlockWrap"> <div class="feed_poster"><div class="avatar">' . template::buildLinkedProfilePic($fbIds[0], 'size="square" with="30" height="30"') . '</div> <h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' redeemed <span class="pointValue">' . $prize->pointCost . '<span class="pts"> points</span></span>.</span> ' . $ago . '</h3> </div> <p class="storyHead">' . template::buildRewardLink($prize->title, $prize->id) . ' </p> <p class="storyCaption"></p> </div><!__end "storyBlockWrap"__>'; } else { // debug: //$code .= 'No prize found for id ' . $action->itemid; } break; case 'wonPrize': // implement require_once PATH_CORE . '/classes/prizes.class.php'; $prizeTable = new PrizeTable($this->db); $prize = $prizeTable->getRowObject(); if ($prize->load($action->itemid)) { if ($prize->isWeekly) { $winText = 'won a Weekly Prize!'; } if ($prize->isGrand == 1) { $winText = 'won the Grand Prize and made the planet green with envy!'; } if ($prize->isGrand > 1) { $winText = 'won a Runner-up Prize!'; } $code .= '<div class="thumb">' . template::buildLinkedRewardPic($prize->id, $prize->thumbnail, $width = 70) . '</div> <div class="storyBlockWrap"> <div class="feed_poster"><div class="avatar">' . template::buildLinkedProfilePic($fbIds[0], 'size="square" with="30" height="30"') . '</div> <h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' ' . $winText . ' ' . $ago . '</h3> </div> <p class="storyHead">' . template::buildRewardLink($prize->title, $prize->id) . ' </p> <p class="storyCaption"></p> </div><!__end "storyBlockWrap"__>'; } else { // debug: //$code .= 'No prize found for id ' . $action->itemid; } break; break; case 'publishStory': // TODO ? //return ''; //break; // TODO ? //return ''; //break; case 'postBlog': case 'postStory': require_once PATH_CORE . '/classes/content.class.php'; $contentTable = new ContentTable($this->db); $content = $contentTable->getRowObject(); $contentid = $action->itemid; if ($content->load($contentid)) { /*$code .= template::buildLinkedStoryImage($content->imageid, $contentid); $code .= template::buildLinkedProfilePic($fbIds[0], 'size="square"') .' '. template::buildLinkedProfileName($fbIds[0]) .' posted a story'; $code .= '<p>' . template::buildStoryLink($content->title, $contentid) .'</p>'; */ $code .= ' <div class="thumb">' . template::buildLinkedStoryImage($content->imageid, $contentid) . '</div> <div class="storyBlockWrap"> <div class="feed_poster"><div class="avatar">' . template::buildLinkedProfilePic($fbIds[0], 'size="square" with="30" height="30"') . '</div> <h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' posted a story</span> ' . $ago . '</h3> </div> <p class="storyHead">' . template::buildStoryLink($content->title, $contentid) . ' </p> <p class="storyCaption">' . $this->templateObj->ellipsis(strip_tags($content->caption, 200)) . ' ' . template::buildStoryLink('...more', $contentid) . '</p> </div><!__end "storyBlockWrap"__>'; //'</li>' } break; case 'vote': // ignore require_once PATH_CORE . '/classes/content.class.php'; $contentTable = new ContentTable($this->db); $content = $contentTable->getRowObject(); $contentid = $action->itemid; // grrrr if ($content->load($contentid)) { $code .= ' <div class="thumb">' . template::buildLinkedStoryImage($content->imageid, $contentid) . '</div> <div class="storyBlockWrap"> <div class="feed_poster">' . '<h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' voted on the story ' . template::buildStoryLink($content->title, $contentid) . '</span> ' . $ago . '</h3> </div> </div><!__end "storyBlockWrap"__> '; } break; case 'comment': /* * * <li class="panel_block"> <div class="thumb"><a href="http://www.msnbc.msn.com/id/28529073/"><img src="{URL_BASE}/index.php?p=scaleImg&id=34608&x=185&y=130&fixed=x&crop" /></a> </div> <div class="storyBlockWrap"> <h3><span class="bold"><a href="'.URL_CANVAS.'?p=profile&memberid=1180126201" onclick="return switchPage('profile', '', 1180126201);"><fb:name ifcantsee="Anonymous" uid="1180126201" capitalize="true" firstnameonly="false" linked="false" /></a> commented on the story <a href="#">It's Time to Aim Low</a></span> on Feb 2, 2009</h3> <blockquote> <div class="quotes"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam dolor nunc, vehicula et, tristique sed, auctor et, massa.</p> <p> Nam at purus vitae diam commodo venenatis. Ut leo enim, vestibulum eget, rhoncus in, suscipit laoreet, magna. Aliquam diam. Nunc tempor lorem eget nisl.</p> </div> </blockquote> </div><!__end "storyBlockWrap"__> </li> */ // assume comment->siteContentId is what is stored... require_once PATH_CORE . '/classes/content.class.php'; require_once PATH_CORE . '/classes/comments.class.php'; require_once PATH_CORE . '/classes/video.class.php'; $contentTable = new ContentTable($this->db); $commentTable = new CommentTable($this->db); $videoTable = new VideoTable($this->db); $content = $contentTable->getRowObject(); $comment = $commentTable->getRowObject(); $video = $videoTable->getRowObject(); $commentid = $action->itemid; // grr $contentid = $action->itemid2; // grrrr if ($comment->load($commentid) && $content->load($contentid)) { if ($comment->videoid && $video->load($comment->videoid)) { $quoteContents = '<div style="text-align:center;">' . videos::buildPlayerFromLink($video->embedCode, 160, 100) . '</div>'; } else { $quoteContents = '<p>' . $this->templateObj->ellipsis(strip_tags($comment->comments), 200) . ' ' . template::buildStoryLink('...more', $contentid) . '</p>'; } $code .= ' <div class="thumb">' . template::buildLinkedStoryImage($content->imageid, $contentid) . '</div> <div class="storyBlockWrap"> <div class="feed_poster"><div class="avatar">' . template::buildLinkedProfilePic($fbIds[0], 'size="square" height="30" width="30"') . '</div> <h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' commented on the story ' . template::buildStoryLink($content->title, $contentid) . '</span> ' . $ago . '</h3> </div> <blockquote> <div class="quotes">' . $quoteContents . '</div> </blockquote> </div><!__end "storyBlockWrap"__> '; } break; } return $code; }
/** * Последние комментарии */ public function executeLastComments() { $comments = CommentTable::getInstance()->queryFeed()->limit(sfConfig::get('app_feeds_last_comments_count', 30))->execute(array(), Doctrine::HYDRATE_ARRAY); $this->buildFeed($comments, array('title' => 'Последние комментарии | НеСкучайк!', 'permalink_url' => 'comment', 'permalink_param_name' => 'id', 'permalink_param_column' => 'point_id')); }