本文整理汇总了PHP中Post::getID方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::getID方法的具体用法?PHP Post::getID怎么用?PHP Post::getID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::getID方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: visitPost
function visitPost(Post $p)
{
$text = $p->getText();
$title = $p->getTitle();
$author = $p->getAuthor();
$time = $p->getTime();
$id = $p->getID();
echo '<item>';
echo '<guid isPermaLink="false">' . utf8_encode("ABBOV_ID_" . $id) . '</guid>';
echo '<title>' . utf8_encode($title) . '</title>';
echo '<description>' . utf8_encode($text) . '</description>';
echo '<pubDate>' . date("D, d M Y G:i:s O", $time) . '</pubDate>';
echo '<dc:creator>' . $author . '</dc:creator>';
echo '</item>';
}
示例2: save
public function save(Post $post)
{
$wp_error = null;
if ($post->getID() != null) {
wp_update_post($post->getWPPost());
} else {
$post_id = wp_insert_post($post->getWPPost(), $wp_error);
$post->setID($post_id);
}
$metas = get_metadata('post', $post->getId());
foreach ($post->getMetas() as $key => $value) {
if (isset($metas[$key]) && $metas[$key] == $value) {
continue;
}
foreach ($value as $subkey => $subvalue) {
if ($subkey == 0) {
update_post_meta($post->getID(), $key, $subvalue);
} else {
add_post_meta($post->getID(), $key, $subvalue);
}
}
}
return $this;
}
示例3: visitPost
function visitPost(Post $p)
{
$text = $p->getText();
$title = $p->getTitle();
$author = $p->getAuthor();
$time = $p->getTime();
$tags = $this->tagsToString($p->getTags());
$id = $p->getID();
echo '<div class="post">';
echo '<b>' . $title . "</b><br>";
echo $author . ' @ ' . date("H:i:s - d/m/Y", $time) . '<br>';
echo 'Tags: ' . $tags . '<br><br>';
echo $text;
echo "<br><br>";
echo '<a href="deletepost.php?id=' . $id . '">Delete post</a>';
echo "<br><br>";
echo '</div>';
}
示例4: erase
function erase(Post $post)
{
return $this->delete($post->getID());
}
示例5: createFromDBResult
static function createFromDBResult($row, $loadComments = true)
{
if ($row[POST_TYPE] == "news" || $row[POST_TYPE] == "post" || $row[POST_TYPE] == "videoreportage") {
$content = $row[POST_CONTENT];
} else {
$content = unserialize($row[POST_CONTENT]);
}
$data = array("title" => $row[POST_TITLE], "subtitle" => $row[POST_SUBTITLE], "headline" => $row[POST_HEADLINE], "author" => intval($row[POST_AUTHOR]), "tags" => $row[POST_TAGS], "categories" => $row[POST_CATEGORIES], "content" => $content, "visible" => $row[POST_VISIBLE] > 0, "type" => $row[POST_TYPE], "place" => $row[POST_PLACE]);
require_once "post/PostCommon.php";
require_once "post/collection/Collection.php";
if ($row[POST_TYPE] == PostType::NEWS) {
$p = new News($data);
} else {
if ($row[POST_TYPE] == PostType::VIDEOREPORTAGE) {
$p = new VideoReportage($data);
} else {
if ($row[POST_TYPE] == PostType::ALBUM) {
$p = new Album($data);
} else {
if ($row[POST_TYPE] == PostType::MAGAZINE) {
$p = new Magazine($data);
} else {
if ($row[POST_TYPE] == PostType::PHOTOREPORTAGE) {
$p = new PhotoReportage($data);
} else {
if ($row[POST_TYPE] == PostType::PLAYLIST) {
$p = new Playlist($data);
} else {
if ($row[POST_TYPE] == PostType::COLLECTION) {
$p = new Collection($data);
} else {
$p = new Post($data);
}
}
}
}
}
}
}
$p->setCreationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[POST_CREATION_DATE])));
$p->setID(intval($row[POST_ID]));
if (!is_null($row[POST_MODIFICATION_DATE])) {
$p->setModificationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[POST_MODIFICATION_DATE])));
} else {
$p->setModificationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[POST_CREATION_DATE])));
}
if ($loadComments) {
$p->loadComments();
}
$user = Session::getUser();
if ($user !== false && $user->getRole() == "admin") {
$p->loadReports();
}
$p->setPermalink($row[POST_PERMALINK]);
require_once "common.php";
$p->setAccessCount(LogManager::getAccessCount("Post", $p->getID()));
return $p;
}
示例6: function
$ijson[] = ["url" => $i->getUrl(), "alt" => $i->getFileName()];
}
}
$j = ["post_id" => $p->getID(), "liked" => false, "tapped_into" => false, "likes_count" => 0, "comments_count" => 0, "taps_count" => 0, "text" => $p->getText(), "time" => $p->getTime(), "category" => $p->getCategory()->getName(), "user" => $user, "images" => $ijson, "comments" => []];
echo json_encode($j);
} else {
echo json_encode(["status" => false]);
}
});
$app->get('/posts', function () use($app) {
$posts = App::getPosts(["limit" => 25, "user_id" => 13]);
echo json_encode(Utility::formatActivitiesToPosts($posts, $app));
});
$app->delete('/posts/:id', function ($id) use($app) {
$p = new Post($id);
if ($p->getID() && $app->environment()['testify.user_id'] == $p->getAuthor()->getID()) {
$p->delete();
if ($p) {
echo json_encode(['status' => true]);
}
}
});
$app->post('/posts/:id/favorites', function ($id) use($app) {
if ($uid = $app->environment['testify.user_id']) {
$post = new Post($id);
if ($post) {
$u = new User($uid);
$u->favoritePost($post, true);
echo json_encode(array("favorites" => $post->countFavorites(), "status" => true));
}
}
示例7: showEditNewsForm
private static function showEditNewsForm($post, $error, $new = false)
{
$name = "Edit";
$caption = "Modifica";
if ($new) {
$post = new Post($post);
$name = "New";
$caption = "Nuova";
}
?>
<div class="title"><?php
echo $caption;
?>
Notizia</div>
<?php
if (is_array($error)) {
?>
<div class="error"><?php
foreach ($error as $err) {
?>
<p><?php
echo $err;
?>
</p>
<?php
}
?>
</div>
<?php
}
?>
<form name="<?php
echo $name;
?>
Post" action="?type=news" method="post" enctype="multipart/form-data">
<!--<p class="post_headline"><label>Occhiello:</label><br />
<input class="post_headline" name="headline" value="<?php
echo Filter::decodeFilteredText($post->getHeadline());
?>
"/></p>-->
<p class="title"><label>Titolo:</label><br/>
<input class="post_title" name="title" value="<?php
echo Filter::decodeFilteredText($post->getTitle());
?>
"/></p>
<p class="post_subtitle"><label>Sottotilolo:</label><br />
<input class="post_subtitle" name="subtitle" value="<?php
echo Filter::decodeFilteredText($post->getSubtitle());
?>
"/></p>
<p class="content"><label>Contenuto:</label><br/>
<textarea name="content" id="post_content"><?php
echo Filter::decodeFilteredText($post->getContent());
?>
</textarea>
<!-- sostituisco textarea standard con ckeditor -->
<script type="text/javascript">
CKEDITOR.replace( 'post_content', { toolbar : 'edited'});
</script>
<fieldset><legend>upload immagine</legend><?php
//se è presente la foto la visualizzo
if ($post->getID() != "") {
$rs_id = PostManager::getPostResource($post->getID());
if ($rs_id) {
$articlePhoto = ResourceManager::loadResource($rs_id);
echo "<img src='" . FileManager::appendToRootPath($articlePhoto->getPath()) . "' /></br>";
}
}
?>
<input type='file' name='upfile' />
</fieldset>
</p>
<p class="tags"><label>Tags:</label>
<input class="tags" id="post_tags_input" name="tags" value="<?php
echo Filter::decodeFilteredText($post->getTags());
?>
"/></p>
<p class="categories"><label>Categorie:</label><br/><?php
$cat = array();
if (trim($post->getCategories()) != "") {
$cat = explode(", ", Filter::decodeFilteredText($post->getCategories()));
}
self::showCategoryTree($cat);
?>
</p>
<p class="<?php
echo trim($post->getPlace()) == "" ? "hidden" : "";
?>
"><label id="place_label">Posizione: <?php
echo $post->getPlace();
?>
</label></p>
<input id="post_place" name="place" type="hidden" value="<?php
echo $post->getPlace();
?>
" />
<input name="visible" type="hidden" value="true" />
<input name="type" type="hidden" value="news" />
<p class="submit"><input type="submit" value="Pubblica" />
<input type="button" onclick="javascript:save();" value="Salva come bozza"/></p>
//.........这里部分代码省略.........
示例8: testPost
public function testPost()
{
$date = new \DateTime();
$post = new Post(123, 1, 'A post', 'Some content', 2, $date, 1, 0);
$this->assertEquals(123, $post->getID());
$this->assertEquals('A post', $post->getTitle());
$this->assertEquals('Some content', $post->getContent());
$this->assertEquals(2, $post->getVisibility());
$this->assertEquals($date, $post->getDate());
}