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


PHP Post::from_db方法代码示例

本文整理汇总了PHP中Post::from_db方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::from_db方法的具体用法?PHP Post::from_db怎么用?PHP Post::from_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Post的用法示例。


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

示例1: print_result

function print_result()
{
    global $response, $page_size;
    if ($response['ids']) {
        $rows = min($response['rows'], 1000);
        foreach ($response['ids'] as $id) {
            switch ($_REQUEST['w']) {
                case 'posts':
                    $obj = Post::from_db($id);
                    break;
                case 'comments':
                    $obj = Comment::from_db($id);
                    break;
                case 'links':
                default:
                    $obj = Link::from_db($id);
            }
            if (!$obj) {
                continue;
            }
            $obj->basic_summary = true;
            switch ($_REQUEST['w']) {
                case 'posts':
                    $obj->print_summary(800);
                    break;
                case 'comments':
                    if ($obj->type == 'admin' && !$current_user->admin) {
                        continue;
                    }
                    // link_object
                    $obj->print_summary(800);
                    break;
                case 'links':
                default:
                    $obj->print_summary();
            }
        }
    }
    do_pages($rows, $page_size);
}
开发者ID:GallardoAlba,项目名称:Meneame,代码行数:40,代码来源:search.php

示例2: User

if ($votes_freq > $freq) {
    if ($current_user->user_id > 0 && $current_user->user_karma > 4) {
        // Crazy votes attack, decrease karma
        // she does not deserve it :-)
        $user = new User();
        $user->id = $current_user->user_id;
        $user->read();
        $user->karma = $user->karma - 0.1;
        $user->store();
        error(_('¡tranquilo cowboy!, tu karma ha bajado: ') . $user->karma);
    } else {
        error(_('¡tranquilo cowboy!'));
    }
}
$vote->value = $value * $current_user->user_karma;
$post = Post::from_db($id);
if (!$post) {
    error(_('nota no existente'));
}
if ($post->author == $current_user->user_id) {
    error(_('no puedes votar a tus comentarios'));
}
if ($post->date < time() - $globals['time_enabled_votes']) {
    error(_('votos cerrados'));
}
if (!$post->insert_vote($current_user->user_id, $vote->value)) {
    error(_('ya ha votado antes'));
}
$dict = array();
$dict['id'] = $id;
$dict['votes'] = $post->votes + 1;
开发者ID:GallardoAlba,项目名称:Meneame,代码行数:31,代码来源:menealo_post.php

示例3: UNIX_TIMESTAMP

    //
    // All posts
    //
    $id = 0;
    $sql = "SELECT post_id FROM posts WHERE {$from_time} ORDER BY post_date DESC LIMIT {$rows}";
    $last_modified = $db->get_var("SELECT UNIX_TIMESTAMP(post_date) FROM posts ORDER BY post_date DESC LIMIT 1");
    $title = _('Nótame') . ': ' . _('notas');
}
do_header($title);
$post = new Post();
if ($sql) {
    $posts = $db->get_col($sql);
}
if ($posts) {
    foreach ($posts as $post_id) {
        $post = Post::from_db($post_id);
        if (!$post) {
            continue;
        }
        $title = text_to_summary($post->clean_content(), 40);
        $title = $post->username . ': ' . htmlentities2unicodeentities($title);
        $content = htmlentities2unicodeentities(put_smileys($post->to_html($post->clean_content())));
        echo "\t<item>\n";
        echo "\t\t<title>{$title}</title>\n";
        echo "\t\t<link>http://" . get_server_name() . post_get_base_url($post->username) . '/' . $post->id . "</link>\n";
        echo "\t\t<pubDate>" . date("r", $post->date) . "</pubDate>\n";
        echo "\t\t<dc:creator>{$post->username}</dc:creator>\n";
        echo "\t\t<guid>http://" . get_server_name() . post_get_base_url($post->username) . '/' . $post->id . "</guid>\n";
        // Insert GEO
        if ($latlng = geo_latlng('user', $post->author)) {
            echo "\t\t<georss:point>{$latlng->lat} {$latlng->lng}</georss:point>\n";
开发者ID:GallardoAlba,项目名称:Meneame,代码行数:31,代码来源:sneakme_rss2.php

示例4: intval

 $id = intval($id);
 // Filter id, could be anything from $sorted
 if (!$show_thread) {
     if (isset($all[$id])) {
         foreach ($all[$id] as $e) {
             $leaves[$e] = true;
         }
     }
 }
 if (isset($leaves[$id])) {
     unset($leaves[$id]);
 }
 //$obj->basic_summary = true;
 switch ($type) {
     case 'posts':
         $obj = Post::from_db($id);
         break;
     case 'comments':
         $obj = Comment::from_db($id);
         break;
 }
 if (!$obj || $obj->type == 'admin' && !$current_user->admin) {
     continue;
 }
 if ($obj->author == $id1) {
     echo '<div style="margin-top: -10;margin-left: 10px; width:70%">';
 } else {
     echo '<div style="margin-top: -10;margin-left:30%">';
 }
 $obj->print_summary();
 echo "</div>\n";
开发者ID:manelio,项目名称:woolr,代码行数:31,代码来源:between.php

示例5: print_answers

function print_answers($id, $level, $visited = false)
{
    // Print "conversation" for a given note
    global $db;
    if (!$visited) {
        $visited = array();
        $visited[] = $id;
    }
    $printed = array();
    $answers = $db->get_col("SELECT conversation_from FROM conversations WHERE conversation_type='post' and conversation_to = {$id} ORDER BY conversation_from asc LIMIT 100");
    $parent_reference = "/@\\p{L}[\\._\\p{L}\\d]+,{$id}/ui";
    // To check that the notes references to $id
    if ($answers) {
        echo '<div style="padding-left: 5%; padding-top: 5px;">';
        echo '<ol class="comments-list">';
        foreach ($answers as $post_id) {
            if (in_array($post_id, $visited)) {
                continue;
            }
            $answer = Post::from_db($post_id);
            if (!$answer) {
                continue;
            }
            if ($answer->user_level == 'autodisabled' || $answers->user_level == 'disabled') {
                continue;
            }
            // Check the post has a real reference to the parent (with the id), ignore othewrise
            if (!preg_match($parent_reference, $answer->content)) {
                continue;
            }
            echo '<li>';
            $answer->print_summary();
            echo '</li>';
            if ($level > 0) {
                $res = print_answers($answer->id, $level - 1, array_merge($visited, $answers));
                $visited = array_merge($visited, $res);
            }
            $printed[] = $answer->id;
            $visited[] = $answer->id;
        }
        echo '</ol>';
        echo '</div>';
        if ($level == 0) {
            Haanga::Load('get_total_answers_by_ids.html', array('type' => 'post', 'ids' => implode(',', $printed)));
        }
    }
    return $printed;
}
开发者ID:manelio,项目名称:woolr,代码行数:48,代码来源:index.php

示例6: function

			if (overlay && overlay.myId > 0) {
				GDownloadUrl(base_url+"geo/"+overlay.myType+".php?id="+overlay.myId, function(data, responseCode) {
				overlay.openInfoWindowHtml(data);
				});
			} //else if (point) geo_map.panTo(point);
		});
	}
}
</script>
<?
} else {
	$posts = $db->get_results($sql);
	if ($posts) {
		echo '<ol class="comments-list">';
		foreach ($posts as $dbpost) {
			$post = Post::from_db($dbpost->post_id);
			if ( $post_id > 0 && $user->id > 0 && $user->id != $post->author) {
				echo '<li>'. _('Error: nota no existente') . '</li>';
			} else {
				echo '<li>';
				$post->print_summary();
				echo '</li>';
			}
		}
		echo "</ol>\n";

		// Print "conversation" for a given note
		if ($post_id > 0) {
			$sql = "SELECT conversation_from as post_id FROM conversations, posts WHERE conversation_type='post' and conversation_to = $post_id and post_id = conversation_from ORDER BY conversation_from asc LIMIT $page_size";
			$answers = $db->get_results($sql);
			if ($answers) {
开发者ID:rasomu,项目名称:chuza,代码行数:31,代码来源:index.php

示例7: switch

// It has to remove parenthesis
if (empty($_GET['what'])) {
    $what = 'link';
} else {
    $what = $_GET['what'];
}
$object = false;
switch ($what) {
    case 'link':
    case 'links':
        $object = Link::from_db($id, null, false);
        break;
    case 'comment':
    case 'comments':
        $object = Comment::from_db($id);
        break;
    case 'post':
    case 'posts':
        $object = Post::from_db($id);
        break;
}
if (!$object) {
    die;
}
$output = new stdClass();
foreach (preg_split('/,/', $fields, 10, PREG_SPLIT_NO_EMPTY) as $f) {
    if (!in_array($f, $forbidden) && property_exists($object, $f)) {
        $output->{$f} = $object->{$f};
    }
}
echo json_encode($output);
开发者ID:brainsqueezer,项目名称:fffff,代码行数:31,代码来源:info.php

示例8: intval

<?php

// The source code packaged with this file is Free Software, Copyright (C) 2005-2011 by
// Ricardo Galli <gallir at gmail dot com>and Menéame Comunicacions
// It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
// You can get copies of the licenses here:
// 		http://www.affero.org/oagpl.html
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING".
// Use the alternate server for api, if it exists
// $globals['alternate_db_server'] = 'backend';
include '../config.php';
$id = intval($_GET['id']);
if (!$id) {
    die;
}
// Print answers to the comment
$sql = "SELECT conversation_from as comment_id FROM conversations, posts WHERE conversation_type='post' and conversation_to = {$id} and post_id = conversation_from ORDER BY conversation_from asc";
$res = $db->get_col($sql);
if ($res) {
    header('Content-Type: text/html; charset=UTF-8');
    foreach ($res as $answer) {
        $post = Post::from_db($answer);
        $post->basic_summary = true;
        $post->not_ignored = true;
        $post->prefix_id = "{$id}-";
        // This a trick in order not to confuse with other ids
        $post->print_summary();
        echo "\n";
    }
}
开发者ID:brainsqueezer,项目名称:fffff,代码行数:30,代码来源:get_post_answers.php


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