本文整理汇总了PHP中Link::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Link::read方法的具体用法?PHP Link::read怎么用?PHP Link::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Link
的用法示例。
在下文中一共展示了Link::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: status_comment_submit
function status_comment_submit($vars)
{
global $db, $main_smarty;
if (get_misc_data('status_switch') != '1') {
return;
}
$comment = $vars['comment'];
if (!$comment->id) {
return;
}
$user = new User();
$user->id = $comment->author;
$linkres = new Link();
$linkres->id = $comment->link;
if ($user->read() && $linkres->read()) {
if (!status_is_allowed($user) || !$user->extra_field['status_switch'] || !$user->extra_field['status_comment']) {
return;
}
$main_smarty->config_load(status_lang_conf);
$text = $main_smarty->get_config_vars('PLIGG_Status_Comment_Update');
$limit = get_misc_data('status_max_chars');
if ($limit > 0 && strlen($text) + strlen($user->username) + strlen($linkres->title) - 4 > $limit) {
$linkres->title = substr($linkres->title, 0, max($limit + 4 - strlen($text) - strlen($user->username) - 3, 10)) . '...';
}
$text = sprintf($text, $user->username, '<a href="' . $linkres->get_internal_url() . '">' . $linkres->title . '</a>');
$db->query($sql = "INSERT INTO " . table_prefix . "updates SET update_time=UNIX_TIMESTAMP(), \r\n\t\t\t\t\t\t\t update_type='c',\r\n\t\t\t\t\t\t\t update_user_id='{$comment->author}',\r\n\t\t\t\t\t\t\t update_link_id='{$comment->id}',\r\n\t\t\t\t\t\t\t update_text='{$text}'\r\n\t\t\t\t\t\t\t ");
}
}
示例2: related_stories
function related_stories($storyid, $related_tags, $category)
{
// this returns similar stories based on tags in common and in the same category
global $db;
if (!is_numeric($storyid)) {
die;
}
$related_tags = "'" . preg_replace('/,\\s*/', "','", addslashes($related_tags)) . "'";
// This gives us the proper string structure for IN SQL statement
// Select 20 stories that share tags with the current story and order them by number of tags they share
$sql = "SELECT tag_link_id, COUNT(tag_link_id) AS relevance\n\t\t\tFROM " . table_tags . "\n\t\t\tWHERE tag_words IN ({$related_tags}) AND tag_link_id!={$storyid}\n\t\t\tGROUP BY tag_link_id \n\t\t\tORDER BY relevance DESC \n\t\t\tLIMIT 20";
$related_story = $db->get_results($sql);
$related_story = object_2_array($related_story);
$stories = array();
foreach ($related_story as $id => $rs) {
$rs2 = new Link();
$rs2->id = $rs['tag_link_id'];
if ($rs2->read() && ($rs2->status == 'new' || $rs2->status == 'published')) {
$related_story[$id] = array_merge($related_story[$id], array('link_id' => $rs2->id, 'link_category' => $rs2->category, 'link_title' => $rs2->title, 'link_title_url' => $rs2->title_url));
if ($rs2->title_url == "") {
$related_story[$id]['url'] = getmyurl("story", $rs2->id);
} else {
$related_story[$id]['url'] = getmyurl("storyURL", $rs2->category_safe_names(), urlencode($rs2->title_url), $rs2->id);
}
$stories[] = $related_story[$id];
}
}
return $stories;
}
示例3: store
function store()
{
// save the comment to the database
global $db, $current_user, $the_template;
if (!$this->date) {
$this->date = time();
}
$comment_id = $this->id;
if (!is_numeric($comment_id)) {
return false;
}
$comment_author = $this->author;
$comment_link = $this->link;
$comment_karma = $this->karma;
$comment_date = $this->date;
$comment_randkey = $this->randkey;
$comment_content = $db->escape($this->content);
$comment_votes = $this->votes;
$comment_parent = $this->parent;
if ($this->id === 0) {
$this->canSave = true;
// assume we can save
$vars = array('comment' => &$this);
check_actions('comment_save', $vars);
if ($this->canSave == true) {
// if this is a new comment
$sql = "INSERT INTO " . table_comments . " (comment_parent, comment_user_id, comment_link_id, comment_karma, comment_date, comment_randkey, comment_content) VALUES ({$comment_parent}, {$comment_author}, {$comment_link}, {$comment_karma}, FROM_UNIXTIME({$comment_date}), {$comment_randkey}, '{$comment_content}')";
$db->query($sql);
$this->id = $db->insert_id;
$link = new Link();
$link->id = $this->link;
$link->read();
$link->adjust_comment(1);
$link->store();
$link = '';
$vars = array('comment' => &$this);
check_actions('comment_post_save', $vars);
}
} else {
// if we're editing an existing comment
$sql = "UPDATE " . table_comments . " set comment_votes={$comment_votes}, comment_user_id={$comment_author}, comment_link_id={$comment_link}, comment_karma={$comment_karma}, comment_date=FROM_UNIXTIME({$comment_date}), comment_randkey={$comment_randkey}, comment_content='{$comment_content}' WHERE comment_id={$comment_id}";
$db->query($sql);
}
$vars = array('comment' => $this);
check_actions('comment_store_post_sql', $vars);
}
示例4: do_link_item
function do_link_item($sql)
{
global $db;
$link = new Link();
$links = $db->get_col($sql);
if ($links) {
foreach ($links as $link_id) {
$link->id = $link_id;
$link->read();
if ($_REQUEST['url'] == 'source') {
$url = __($link->url);
} else {
$url = $link->get_permalink();
}
echo '<DT><A HREF="' . $url . '" REL="nofollow">' . $link->title . '</A>' . "\n";
}
}
}
示例5: insert_anonymous_comment
function insert_anonymous_comment(&$vars)
{
global $db;
$link_id = $vars['link_id'];
$user_id = $vars['user_id'];
$randkey = $vars['randkey'];
$comment_content = $vars['comment_content'];
$a_username = $vars['a_username'];
$a_email = $vars['a_email'];
$a_website = $vars['a_website'];
$sql = "INSERT INTO " . table_comments . " (comment_user_id, comment_link_id, comment_date, comment_randkey, comment_content,`comment_anonymous_username`, `comment_anonymous_email`, `comment_anonymous_website` ) VALUES ({$user_id}, {$link_id}, NOW(), {$randkey}, '{$comment_content}', '{$a_username}','{$a_email}', '{$a_website}')";
$result = $db->query($sql);
// DB 12/17/08
$link = new Link();
$link->id = $link_id;
$link->read();
$link->adjust_comment(1);
$link->store();
/////
}
示例6: show
function show()
{
global $main_smarty, $db;
include_once mnminclude . 'search.php';
$search = new Search();
$search->orderBy = $this->orderBy;
$search->pagesize = $this->pagesize;
$search->filterToStatus = $this->filterToStatus;
$search->filterToTimeFrame = $this->filterToTimeFrame;
$search->doSearch();
$linksum_sql = $search->sql;
$link = new Link();
$links = $db->get_col($linksum_sql);
if ($links) {
foreach ($links as $link_id) {
$link->id = $link_id;
$link->read();
$main_smarty = $link->fill_smarty($main_smarty);
$main_smarty->display($this->template);
}
}
}
示例7: delete_comment
function delete_comment($key)
{
global $db;
if (!is_numeric($key)) {
return;
}
$link_id = $db->get_var("SELECT comment_link_id FROM `" . table_comments . "` WHERE `comment_id` = " . $key . ";");
$vars = array('comment_id' => $key);
check_actions('comment_deleted', $vars);
$comments = $db->get_results($sql = "SELECT comment_id FROM " . table_comments . " WHERE `comment_parent` = '{$key}'");
foreach ($comments as $comment) {
$vars = array('comment_id' => $comment->comment_id);
check_actions('comment_deleted', $vars);
}
$db->query('DELETE FROM `' . table_comments . '` WHERE `comment_parent` = "' . $key . '"');
$db->query('DELETE FROM `' . table_comments . '` WHERE `comment_id` = "' . $key . '"');
$link = new Link();
$link->id = $link_id;
$link->read();
$link->recalc_comments();
$link->store();
}
示例8: Link
function print_summary($link = 0, $length = 0, $single_link = true)
{
global $current_user, $globals;
if (!$this->read) {
return;
}
if (!$link && $this->link > 0) {
$link = new Link();
$link->id = $this->link;
$link->read();
$this->link_object = $link;
}
$this->link_permalink = $link->get_relative_permalink();
$this->check_visibility();
if ($this->hidden) {
$comment_meta_class = 'comment-meta-hidden';
$comment_class = 'comment-body-hidden';
} else {
$comment_meta_class = 'comment-meta';
$comment_class = 'comment-body';
if ($this->karma > $globals['comment_highlight_karma']) {
$comment_class .= ' high';
}
}
$this->truncate($length);
$this->txt_content = $this->to_html($this->content);
if ($this->type == 'admin') {
$author = '<strong>' . _('admin') . '</strong> ';
} else {
$author = '<a href="' . get_user_uri($this->username) . '" title="karma: ' . $this->user_karma . '">' . $this->username . '</a> ';
}
if ($this->media_size > 0) {
$this->media_thumb_dir = Upload::get_cache_relative_dir($this->id);
}
$vars = compact('comment_meta_class', 'comment_class', 'author');
$vars['self'] = $this;
return Haanga::Load('mobile/comment_summary.html', $vars);
}
示例9: group_shared
function group_shared($requestID, $catId, $flag = 0)
{
global $db, $main_smarty, $the_template, $page_size, $cached_links;
if (!is_numeric($requestID)) {
die;
}
$link = new Link();
$group_shared_display = "";
if ($catId) {
$child_cats = '';
// do we also search the subcategories?
if (Independent_Subcategories == true) {
$child_array = '';
// get a list of all children and put them in $child_array.
children_id_to_array($child_array, table_categories, $catId);
if ($child_array != '') {
// build the sql
foreach ($child_array as $child_cat_id) {
$child_cat_sql .= ' OR `link_category` = ' . $child_cat_id . ' ';
if (Multiple_Categories) {
$child_cat_sql .= ' OR ac_cat_id = ' . $child_cat_id . ' ';
}
}
}
}
if (Multiple_Categories) {
$child_cat_sql .= " OR ac_cat_id = {$catId} ";
}
$from_where .= " AND (link_category={$catId} " . $child_cat_sql . ")";
}
$offset = (get_current_page() - 1) * $page_size;
if ($flag == 1) {
$sql = "SELECT SQL_CALC_FOUND_ROWS b.* FROM " . table_group_shared . " a\r\n\t\t\t\t LEFT JOIN " . table_links . " b ON link_id=share_link_id\r\n\t\t\t\t WHERE share_group_id = {$requestID} AND !ISNULL(link_id) {$from_where} \r\n\t\t\t\t GROUP BY link_id\r\n\t\t\t\t ORDER BY link_published_date DESC, link_date DESC ";
} else {
$sql = "SELECT SQL_CALC_FOUND_ROWS b.* FROM " . table_group_shared . " a\r\n\t\t\t\t LEFT JOIN " . table_links . " b ON link_id=share_link_id\r\n\t\t\t\t WHERE share_group_id = {$requestID} AND !ISNULL(link_id) {$from_where} \r\n\t\t\t\t GROUP BY link_id\r\n\t\t\t\t ORDER BY link_published_date DESC, link_date DESC LIMIT {$offset}, {$page_size}";
}
// Search on additional categories
if ($catId && Multiple_Categories) {
$sql = str_replace("WHERE", " LEFT JOIN " . table_additional_categories . " ON ac_link_id=link_id WHERE", $sql);
}
$links = $db->get_results($sql);
$rows = $db->get_var("SELECT FOUND_ROWS()");
if ($flag == 1) {
return $rows;
}
if ($links) {
foreach ($links as $dblink) {
$link->id = $dblink->link_id;
$cached_links[$dblink->link_id] = $dblink;
$link->read();
$group_shared_display .= $link->print_summary('summary', true);
}
}
$main_smarty->assign('group_shared_display', $group_shared_display);
//for auto scrolling
if (Auto_scroll == 2 || Auto_scroll == 3) {
$main_smarty->assign("scrollpageSize", $page_size);
$main_smarty->assign('total_row', $rows);
if ($catId) {
$main_smarty->assign('catID', $catId);
}
$main_smarty->assign('total_row', $rows);
} else {
$main_smarty->assign('group_story_pagination', do_pages($rows, $page_size, 'group_story', true));
}
}
示例10: intval
die;
}
$tb_url = $_POST['url'];
$title = $_POST['title'];
$excerpt = $_POST['excerpt'];
$blog_name = $_POST['blog_name'];
$charset = $_POST['charset'];
if (!empty($charset)) {
$title = @iconv($charset, 'UTF-8//IGNORE', $title);
$excerpt = @iconv($charset, 'UTF-8//IGNORE', $excerpt);
$blog_name = @iconv($charset, 'UTF-8//IGNORE', $blog_name);
}
$tb_id = intval($_GET['id']);
$link = new Link();
$link->id = $tb_id;
if (!$tb_id > 0 || !$link->read()) {
trackback_response(1, 'I really need an ID for this to work.');
}
if (empty($title) && empty($tb_url) && empty($blog_name)) {
// If it doesn't look like a trackback at all...
header('Location: ' . $link->get_permalink());
exit;
}
if (!empty($tb_url) && !empty($title) && !empty($excerpt)) {
header('Content-Type: text/xml; charset=UTF-8');
$title = htmlspecialchars(strip_tags($title));
$title = strlen($title) > 150 ? substr($title, 0, 150) . '...' : $title;
$excerpt = strip_tags($excerpt);
$excerpt = strlen($excerpt) > 200 ? substr($excerpt, 0, 200) . '...' : $excerpt;
$trackres = new Trackback();
$trackres->link = $tb_id;
示例11: Vote
function insert_vote($user = 0, $value = 10)
{
global $anon_karma;
require_once mnminclude . 'votes.php';
if (!is_numeric($this->id)) {
return false;
}
$vote = new Vote();
$vote->type = 'comments';
$vote->user = $user;
$vote->link = $this->id;
$vote->value = $value;
if ($vote->insert()) {
$vote = new Vote();
$vote->type = 'comments';
$vote->link = $this->id;
$this->votes = $vote->count() - $vote->count('<0');
if (comment_buries_spam > 0 && $vote->count_all("<0") >= comment_buries_spam) {
$this->status = 'discard';
$this->store();
$vars = array('comment_id' => $this->id);
check_actions('comment_spam', $vars);
require_once mnminclude . 'link.php';
$link = new Link();
$link->id = $this->link;
$link->read();
$link->recalc_comments();
$link->store();
}
$vars = array('vote' => $this);
check_actions('comment_insert_vote_post', $vars);
return $vote->sum();
}
return false;
}
示例12: do_best_queued
function do_best_queued()
{
global $db, $globals, $dblang;
if ($globals['mobile']) {
return;
}
$foo_link = new Link();
$key = 'best_queued_' . $globals['css_main'] . '_' . $globals['meta_current'];
if (memcache_mprint($key)) {
return;
}
if ($globals['meta_current'] && $globals['meta_categories']) {
$category_list = 'and link_category in (' . $globals['meta_categories'] . ')';
$title = sprintf(_('candidatas en «%s»'), $globals['meta_current_name']);
} else {
$category_list = '';
$title = _('candidatas');
}
$output = '<div class="sidebox"><div class="header"><h4><a href="' . $globals['base_url'] . 'promote.php">' . $title . '</a></h4></div>';
$min_date = date("Y-m-d H:i:00", $globals['now'] - 86400 * 4);
// 4 days
// The order is not exactly the votes
// but a time-decreasing function applied to the number of votes
$res = $db->get_results("select link_id from links where link_status='queued' and link_date > '{$min_date}' {$category_list} order by link_karma desc limit 15");
if ($res) {
$link = new Link();
foreach ($res as $l) {
$output .= '<div class="cell">';
$link->id = $l->link_id;
$link->read();
$url = $link->get_relative_permalink();
$output .= '<div class="votes queued">' . ($link->votes + $link->anonymous) . '</div>';
if ($link->negatives >= $link->votes / 10) {
// add the warn icon if it has 10% negatives
$warn = 'style="padding-left:20px;background: url(../../img/common/error_s.png) no-repeat left center"';
} else {
$warn = '';
// Show the thumbnail only if it has less than 10% negatives
if ($thumb = $link->has_thumb()) {
$link->thumb_x = round($link->thumb_x / 2);
$link->thumb_y = round($link->thumb_y / 2);
$output .= "<img src='{$thumb}' width='{$link->thumb_x}' height='{$link->thumb_y}' alt='' class='thumbnail'/>";
}
}
$output .= '<h5 ' . $warn . '><a href="' . $url . '">' . $link->title . '</a></h5>';
$output .= '</div>';
// class="cell";
}
$output .= '</div>' . "\n";
echo $output;
memcache_madd($key, $output, 180);
}
}
示例13: elseif
function print_summary($link = 0, $length = 0, $single_link=true, $no_padding = false) {
global $current_user, $globals;
if(!$this->read) return;
if (! $link && $this->link > 0) {
$link = new Link;
$link->id = $this->link;
$link->read();
$this->link_object = $link;
}
if ($single_link) $html_id = $this->order;
else $html_id = $this->id;
if ($this->nested_level == 1)
$no_padding = true;
if ($no_padding) {
$padding = 0;//(int)$this->level * 30;
} else {
$padding = 33;//(int)$this->level * 30;
}
//echo '<div id="c-'.$html_id.'" class="'.(($this->nested_level>1)?'cmt':'cmt').'" style="margin-left:'.$padding.'px;" >';
echo '<style>';
echo '
div.cmt {
border-width:0px 0px 0px 1px;
border-style:dotted;
border-color:#AADB7A;
}';
echo '</style>';
echo '<div id="c-'.$html_id.'" class="'.(($this->nested_level>1)?'cmt':'').'" style="margin-left:'.$padding.'px;" >';
/*
if ($this->type != 'admin' && $this->user_level != 'disabled') {
// Print the votes info (left)
if ($current_user->user_id > 0
&& $this->author != $current_user->user_id
&& $single_link
&& $this->date > $globals['now'] - $globals['time_enabled_comments']
&& $this->level != 'autodisabled') {
*/
$this->print_shake_icons();
/*
} else {
echo '<div style="float:left">';
echo '<span id="c-votes-'.$this->id.'">';
echo '<a href="javascript:menealo_comment('."$current_user->user_id,$this->id,1".')" title="'._('informativo, opinión razonada, buen humor...').'"><img src="'.$globals['base_static'].'img/common/vote-up02.png" width="18" height="16" alt="'._('voto positivo').'"/></a><br/>';
echo '<a href="javascript:menealo_comment('."$current_user->user_id,$this->id,-1".')" title="'._('abuso, insulto, acoso, spam, magufo...').'"><img style="padding-top:5px;" src="'.$globals['base_static'].'img/common/vote-down02.png" width="18" height="16" alt="'._('voto negativo').'"/></a> ';
echo '</span>';
echo '</div>';
}
}
*/
$this->ignored = ($current_user->user_id > 0 && $this->type != 'admin' && User::friend_exists($current_user->user_id, $this->author) < 0);
$this->hidden = ($globals['comment_highlight_karma'] > 0 && $this->karma < -$globals['comment_highlight_karma'])
|| ($this->user_level == 'disabled' && $this->type != 'admin');
if ($this->hidden || $this->ignored) {
$comment_meta_class = 'comment-meta-hidden';
$comment_class = 'comment-body-hidden';
} else {
$comment_meta_class = 'comment-meta';
$comment_class = 'comment-body';
if ($this->type == 'admin') {
$comment_class .= ' admin';
} elseif ($globals['comment_highlight_karma'] > 0 && $this->karma > $globals['comment_highlight_karma']) {
$comment_class .= ' high';
}
}
$this->link_permalink = $link->get_relative_permalink();
/*
$bgcolor = Array("R"=>hexdec("C5"),"G"=>hexdec("E7"),"B"=>hexdec("A4"));
$n = $this->nested_level - 1;
$bgcolor["R"] = min($bgcolor["R"] + (((255 - $bgcolor["R"]) / 5) * $n), 255);
$bgcolor["G"] = min($bgcolor["G"] + (((255 - $bgcolor["G"]) / 5) * $n), 255);
$bgcolor["B"] = min($bgcolor["B"] + (((255 - $bgcolor["B"]) / 5) * $n), 255);
$bgcolor = dechex($bgcolor["R"]) . dechex($bgcolor["G"]) . dechex($bgcolor["B"]);
*/
$color_list = Array( '#C5E7A4',
'#C4E6A2',
'#A2E6A2',
'#A2E6C4',
'#A2E6E6',
'#A2C4E6',
'#A2A2E6',
'#C4A2E6',
'#E6A2E6',
'#E6A2C4',
'#E6A2A2',
'#E6C4A2',
'#E6E6A2',
//.........这里部分代码省略.........
示例14: do_submit3
function do_submit3() {
global $db, $current_user;
$linkres=new Link;
$linkres->id=$link_id = intval($_POST['id']);
$linkres->read();
// Check it is not in the queue already
if($linkres->votes == 0 && $linkres->status != 'queued') {
$linkres->status='queued';
$linkres->date=time();
$linkres->store_basic();
$linkres->insert_vote($current_user->user_id);
$db->query("delete from links where link_author = $linkres->author and link_status='discard' and link_votes=0");
if(!empty($_POST['trackback'])) {
require_once(mnminclude.'trackback.php');
$trackres = new Trackback;
$trackres->url=preg_replace('/ /', '+', trim($_POST['trackback']));
$trackres->link=$linkres->id;
$trackres->title=$linkres->title;
$trackres->author=$linkres->author;
$trackres->content=$linkres->content;
$res = $trackres->send();
}
}
header("Location: ./shakeit.php");
die;
}
示例15: do_shaken
function do_shaken()
{
global $db, $rows, $user, $offset, $page_size, $globals;
if ($globals['bot']) {
return;
}
do_user_subheader(array(_('envíos propios') => get_user_uri($user->username, 'history'), _('votados') => get_user_uri($user->username, 'shaken'), _('favoritos') => get_user_uri($user->username, 'favorites'), _('votados por amigos') => get_user_uri($user->username, 'friends_shaken')), 1, 'rss2.php?voted_by=' . $user->id, _('votadas en rss2'));
$link = new Link();
$rows = -1;
//$db->get_var("SELECT count(*) FROM votes WHERE vote_type='links' and vote_user_id=$user->id");
$links = $db->get_results("SELECT vote_link_id as id, vote_value FROM votes WHERE vote_type='links' and vote_user_id={$user->id} ORDER BY vote_date DESC LIMIT {$offset},{$page_size}");
if ($links) {
foreach ($links as $linkdb) {
$link->id = $linkdb->id;
$link->read();
if ($link->author == $user->id) {
continue;
}
echo '<div style="max-width: 60em">';
$link->print_summary('short', 0, false);
if ($linkdb->vote_value < 0) {
echo '<div class="box" style="z-index:1;margin:0 0 -5x 0;background:#FF3333;position:relative;top:-5px;left:85px;width:8em;padding: 1px 1px 1px 1px;border-color:#f00;opacity:0.9;text-align:center;font-size:0.9em;color:#fff;text-shadow: 0 1px 0 #000">';
echo get_negative_vote($linkdb->vote_value);
echo "</div>\n";
}
echo "</div>\n";
}
echo '<br/><span style="color: #FF6400;"><strong>' . _('Nota') . '</strong>: ' . _('sólo se visualizan los votos de los últimos meses') . '</span><br />';
}
}