本文整理汇总了PHP中Post::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::getContent方法的具体用法?PHP Post::getContent怎么用?PHP Post::getContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::getContent方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create($content, $idAuthor, Topic $Topic, SCategory $SCategory)
{
$post = new Post($this->db);
try {
$post->setContent($content);
$post->setIdAuthor($idAuthor);
$post->setTopic($Topic);
$post->setSCategory($SCategory);
} catch (Exception $e) {
$errors = $e->getMessage();
echo $errors;
}
if (!isset($err)) {
$content = $this->db->quote($post->getContent());
$idAuthor = $post->getIdAuthor();
$idTopic = $post->getIdTopic();
$idSCategory = $post->getIdSCategory();
$query = 'INSERT INTO post(content, id_author, id_topic, id_sCategory)
VALUE (' . $content . ',' . $idAuthor . ', ' . $idTopic . ', ' . $idSCategory . ')';
}
$res = $this->db->exec($query);
if ($res) {
$id = $this->db->lastInsertId();
if ($id) {
return $this->findById($id);
} else {
throw new Exception('Database error');
}
} else {
throw new Exception($errors);
}
}
示例2: testGetContent
/**
*/
public function testGetContent()
{
$expected = "It's that time in the week when 'A foreign affair' goes to the quiz-night at the Grands. We usually ends up at the bottom half in the results. This might be the result of the lack of knowledge we have in things not categorized in either technology, movies or music.\n\nSometimes we've been lucky enough to hit the second to last place, that given us a whopping \$20 bar tab. Split that money on 4-5 people and we can almost get half a beer each.\n\nUsually it's three europeans and one kiwi, but tonight we're getting some help from the french nation.";
$this->assertEquals($expected, $this->object->getContent());
$this->object->setContent('This is the new content');
$this->assertEquals('This is the new content', $this->object->getContent());
}
示例3: insert
public function insert(Post $post)
{
$this->conn->beginTransaction();
try {
$stmt = $this->conn->prepare('INSERT INTO posts (title, content) VALUES (:title, :content)');
$stmt->bindValue(':title', $post->getTitle());
$stmt->bindValue(':content', $post->getContent());
$stmt->execute();
$this->conn->commit();
} catch (Exception $e) {
$this->conn->rollback();
}
}
示例4: view_post
function view_post($post)
{
require_once ROOT . '/application/models/Post.php';
$app = \Slim\Slim::getInstance();
// get the posts directory, and post filename
$dir = POST::POST_PATH;
$post = new Post($path, $dir);
$post->createPostFromFile();
$post_metadata = $post->getMetadata();
// parse the markdown portion into HTML
$post_html = $app->config('md')->text($post->getContent());
// build the final post object
$post_result = array('title' => $post_metadata['title'], 'date' => $post_metadata['date'], 'desc' => $post_metadata['desc'], 'html' => $post_html);
// render the post view
$app->render('blog_post.php', array('post' => $post_result));
}
示例5: getLastPosts
public static function getLastPosts()
{
$session_id = '1000004';
$connexion = new PDO(PDO_DSN, USER, PASSWD);
$connexion->exec("set names utf8");
$query = "SELECT p.post_id, p.post_user, m.mbr_name, m.mbr_birthdate, m.mbr_inscription, p.post_content, p.post_date, p.post_picture FROM post AS p JOIN member m ON p.post_user = m.mbr_id WHERE p.post_user IN ( SELECT frs_a FROM friendship WHERE frs_b = ? UNION SELECT frs_b FROM friendship WHERE frs_a = ? ) ORDER BY post_date DESC";
$stmt = $connexion->prepare($query);
$stmt->bindParam(1, $session_id, PDO::PARAM_INT);
$stmt->bindParam(2, $session_id, PDO::PARAM_INT);
$stmt->execute();
if ($stmt->rowCount()) {
while ($ligne = $stmt->fetch(PDO::FETCH_OBJ)) {
$member = new User($ligne->post_user, $ligne->mbr_name, $ligne->mbr_birthdate, $ligne->mbr_inscription);
$post = new Post($ligne->post_id, $member, $ligne->post_content, $ligne->post_date, $ligne->post_picture);
echo $member->getName() . ":" . $post->getContent() . "<br>";
// SHOW POSTS HERE
}
} else {
echo 404;
}
}
示例6: Post
/*$client = new IXR_Client('http://localhost/exercises/php_exercises/chapter4/server.php');
if (!$client->query('time.getGMTTime')) {
die("Something went wrong - " . $client->getErrorCode() . $client->getErrorMessage());
}
echo($client->getResponse());*/
/*---------- Design Patterns: Decorator Pattern ----------*/
print "<br/><br/>";
$bbcode_enabled = 0;
$emoticon_enabled = 1;
$post = new Post();
$comment = new Comment();
$post->filter("Test Title: A Test", "Lorem Ipsum Amet");
$comment->filter("Dolot avenus persina olatus");
if ($bbcode_enabled == false && $emoticon_enabled == false) {
$postcontent = $post->getContent();
$commentcontent = $comment->getContent();
} elseif ($bbcode_enabled == true && $emoticon_enabled == false) {
$bb = new BBCodeParser($post);
// Passing the Post() object to BBCodeParser()
$postcontent = $bb->getContent();
$bb = new BBCodeParser($comment);
$commentcontent = $bb->getContent();
} elseif ($bbcode_enabled == false && $emoticon_enabled == true) {
$em = new EmoticonParser($post);
$postcontent = $em->getContent();
$em = new EmoticonParser($comment);
$commentcontent = $em->getContent();
}
/*---------- Design Patterns: Facade Pattern ----------*/
$F = new Facade();
示例7: create
public function create($idTopic, $content)
{
$post = new Post();
$set = $post->setContent($content);
if ($set === true) {
$manager = new TopicManager($this->db);
$topic = $manager->findById($idTopic);
$set = $post->setIdTopic($topic);
if ($set === true) {
if (isset($_SESSION['id'])) {
$manager = new UserManager($this->db);
$user = $manager->getCurrent();
$set = $post->setIdAuthor($user);
if ($set === true) {
$idAuthor = intval($user->getId());
$idTopic = intval($post->getIdTopic());
$content = mysqli_real_escape_string($this->db, $post->getContent());
$query = "INSERT INTO post (id_author, id_topic, content) VALUES (" . $idAuthor . ", " . $idTopic . ", '" . $content . "')";
$result = mysqli_query($this->db, $query);
if ($result) {
$id = mysqli_insert_id($this->db);
if ($id) {
return $this->findById($id);
} else {
return "Erreur serveur.";
}
} else {
return mysqli_error();
}
} else {
return $set;
}
} else {
return "Utilisateur déconnecté.";
}
} else {
return $set;
}
} else {
return $set;
}
}
示例8: update
/**
* Updates a Post in the database
*
* @param Post $post The post to be updated
* @throws PDOException if a database error occurs
* @return void
*/
public function update(Post $post)
{
$stmt = $this->db->prepare("UPDATE posts set title=?, content=? where id=?");
$stmt->execute(array($post->getTitle(), $post->getContent(), $post->getId()));
}
示例9: showEditVideoReportageForm
private static function showEditVideoReportageForm($post, $error, $new = false)
{
$name = "Edit";
$caption = "Modifica";
if ($new) {
$post = new Post($post);
$name = "New";
$caption = "Nuovo";
}
?>
<div class="title"><?php
echo $caption;
?>
Videoreportage</div>
<?php
if (is_array($error)) {
?>
<div class="error"><?php
foreach ($error as $err) {
?>
<p><?php
echo $err;
?>
</p>
<?php
}
?>
</div>
<?php
}
if (!isset($_GET["phase"]) || count($error) != 0) {
?>
<form name="<?php
echo $name;
?>
Post" action="?type=videoreportage" method="post">
<!--<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"><?php
if ($post->getContent() != "") {
echo youtubeManager::getVideoPlayer($post->getContent());
}
?>
<fieldset><legend>Video:</legend>
<label>Inserisci l'URL del video: </label><input type="text" name="userUrl" value="<?php
echo youtubeManager::getUrl($post->getContent());
?>
">
</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 type="hidden" name="phase" value="<?php
if (isset($_POST["phase"]) == 2) {
echo '2';
} else {
echo '1';
}
?>
">
<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="videoreportage" />
<p class="submit"><input type="submit" value="Pubblica" />
<input type="button" onclick="javascript:save();" value="Salva come bozza"/></p>
<script type="text/javascript">
//.........这里部分代码省略.........
示例10: getPost
/**
* Get post
*
* This function retrieves an existing post from the server.
*
* @param array $args (in appkey string, in blogid string, in postid string,
* in username string, in password string)
* @return string Upon success this will return the content of the post. Upon
* failure, the fault will be returned.
* @link http://docs.openlinksw.com/virtuoso/fn_blogger.getPost.html
*/
function getPost($args)
{
global $server, $site;
$postid = $args[1] + 0;
$password = $args[3];
if ($password === $site->ad_pass) {
$post = new Post($site);
$post->fetch_from_db($postid);
// error occured?
if ($post->postid <= 0) {
$server->error(8003, 'No post found.');
}
$content = '<title>' . $post->getTitle() . '</title>' . $post->getContent();
$content .= '<template>' . $post->getAttribute('template') . '</template>';
$content .= '<allow_comments>' . $post->getAttribute('allow_comments') . '</allow_comments>';
$content .= '<comment_alert>' . $post->getAttribute('comment_alert') . '</comment_alert>';
$return = array('dateCreated' => $post->time, 'userid' => 1, 'blogid' => 1, 'content' => $content);
return $return;
} else {
$server->error(8000, 'Wrong password given.');
}
}
示例11: 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">
<p class="post_headline"><label>Occhiello:</label><br />
<input class="post_headline" name="headline" value="<?php
echo $post->getHeadline();
?>
"/></p>
<p class="title"><label>Titolo:</label><br/>
<input class="post_title" name="title" value="<?php
echo $post->getTitle();
?>
"/></p>
<p class="post_subtitle"><label>Sottotilolo:</label><br />
<input class="post_subtitle" name="subtitle" value="<?php
echo $post->getSubtitle();
?>
"/></p>
<p class="content"><label>Contenuto:</label><br/>
<textarea name="content" id="post_content"><?php
echo $post->getContent();
?>
</textarea>
<!-- sostituisco textarea standard con ckeditor -->
<script type="text/javascript">
CKEDITOR.replace( 'post_content', { toolbar : 'edited'});
</script>
</p>
<p class="tags"><label>Tags:</label>
<input class="tags" id="post_tags_input" name="tags" value="<?php
echo $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>
<script type="text/javascript">
function save() {
document.<?php
echo $name;
?>
Post.visible.value = false;
document.<?php
echo $name;
?>
Post.submit();
}
</script>
//.........这里部分代码省略.........
示例12: 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());
}