本文整理汇总了PHP中Post::setTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::setTitle方法的具体用法?PHP Post::setTitle怎么用?PHP Post::setTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::setTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLockedFields
public function testLockedFields()
{
$post = new Post();
$post->activateLocker();
$post->activateLockCheck();
$post->setTitle('A super book');
$post->save();
$this->assertTrue($post->getTitleLock());
$this->assertEquals('A super book', $post->getTitle());
$post->setTitle('New Title');
$this->assertEquals('New Title', $post->getTitle());
$post->save();
$this->assertEquals('A super book', $post->getTitle());
}
示例2: createPost
public function createPost($data)
{
$currentUser = parent::authenticateUser();
$post = new Post();
if (isset($data->title) && isset($data->content)) {
$post->setTitle($data->title);
$post->setContent($data->content);
$post->setAuthor($currentUser);
}
try {
// validate Post object
$post->checkIsValidForCreate();
// if it fails, ValidationException
// save the Post object into the database
$postId = $this->postMapper->save($post);
// response OK. Also send post in content
header($_SERVER['SERVER_PROTOCOL'] . ' 201 Created');
header('Location: ' . $_SERVER['REQUEST_URI'] . "/" . $postId);
header('Content-Type: application/json');
echo json_encode(array("id" => $postId, "title" => $post->getTitle(), "content" => $post->getContent()));
} catch (ValidationException $e) {
header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad request');
echo json_encode($e->getErrors());
}
}
示例3: parseItem
function parseItem($blog, $item, $ts)
{
if ($ts != 0 && $item->pubdate <= $ts) {
logmsg('Zatrzymanie na wpisie: %s', StringUtils::removeAccents($item->title));
return false;
}
logmsg(' - Parsowanie wpisu: %s', StringUtils::removeAccents($item->title));
$post = new Post();
$post->setBlog($blog);
foreach ($item->tags as $name) {
$tag = TagPeer::retriveByName($name, true);
if ($post->addTag($tag)) {
logmsg(' - Znaleziono tag: %s', $name);
}
}
if ($post->hasTags()) {
$shortened = $post->setFullContent($item->content);
$post->setLink(htmlspecialchars($item->link));
$post->setTitle($item->title);
$post->setCreatedAt($item->pubdate);
$post->setShortened($shortened);
$post->save();
} else {
logmsg(' - Nie znaleziono tagow');
}
return true;
}
示例4: controlerJob
public function controlerJob($maincont)
{
if ($maincont->isLoggued()) {
if (isset($_POST["title"])) {
$p = new Post();
$p->setTitle($_POST["title"]);
$p->setBody($_POST["body"]);
$p->setHour(date("h:i:s"));
$p->setDate(date("Y-m-d"));
// gestion des tags
$tags = explode(" ", $_POST["tags"]);
foreach ($tags as $t) {
if ($t == "") {
continue;
}
$ta = Tag::getByTag($t);
//echo "Tag : $t<br />";
if (count($ta) == 0) {
$mytag = new Tag();
$mytag->setTag($t);
} else {
$mytag = $ta[0];
}
// création du posttag liant le tag et le post
$pt = new Posttag();
$pt->setPostid($p->id);
$pt->setTagid($mytag->id);
}
}
$maincont->goModule("post", "admin");
} else {
$maincont->goModule("home", "display");
}
}
示例5: getPostFromJSON
private static function getPostFromJSON($id, $json)
{
$post = new Post($id);
$post->setText($json['text']);
$post->setTitle($json['title']);
return $post;
}
示例6: save
static function save($id)
{
$post = new Post($id);
$post->setText($_POST['post_text']);
$post->setTitle($_POST['post_title']);
$newid = PostStorage::savePost($post);
redirect_to('/' . $newid);
}
示例7: findPost
/**
* {@inheritDoc}
*/
public function findPost($id)
{
$postData = $this->data[$id];
$model = new Post();
$model->setId($postData['id']);
$model->setTitle($postData['title']);
$model->setText($postData['text']);
return $model;
}
示例8: getById
/**
* Returns Post object by specified id
*
* @param int $id
* @return Post|null
*/
public function getById($id)
{
$arrayData = $this->persistence->retrieve($id);
if (is_null($arrayData)) {
return null;
}
$post = new Post();
$post->setId($arrayData['id']);
$post->setAuthor($arrayData['author']);
$post->setCreated($arrayData['created']);
$post->setText($arrayData['text']);
$post->setTitle($arrayData['title']);
return $post;
}
示例9: processResults
private function processResults($statement)
{
$results = array();
if ($statement) {
while ($row = $statement->fetch(PDO::FETCH_OBJ)) {
$post = new Post();
$post->setId($row->post_id);
$post->setTitle($row->title);
$post->setContent($row->content);
$results[] = $post;
}
}
return $results;
}
示例10: user_update_post
public function user_update_post()
{
$db = new PDO("mysql:dbname=xuthulu", 'root', 'password');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$post = new Post($db, $_SESSION['user_id'], $_POST['prod_id']);
$post->setTitle($_POST['title']);
$post->setDescription($_POST['description']);
$post->setCondition($_POST['condition']);
$post->setPrice($_POST['price']);
if ($post->update_post()) {
header('Location: userpage.php');
exit;
} else {
throw new Exception("An error has occured. Please try again.");
}
}
示例11: fixturesAction
/**
* Console-only route to generate fixtures.
*/
public function fixturesAction()
{
$em = $this->getEntityManager();
for ($i = 0; $i < 100; $i++) {
$post = new Post();
$post->setTitle('Post ' . uniqid());
$post->setIntro(str_repeat('intro ', rand(1, 100)));
$content = '';
for ($j = mt_rand(1, 100); $j > 0; $j--) {
$content .= str_repeat('lorem ipsum ', rand(1, 20));
}
$post->setContent($content);
$em->persist($post);
}
$em->flush();
}
示例12: load
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager)
{
$p1 = new Post();
$p1->setTitle("1 Lorem Impsum post");
$p1->setBody("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.");
$p1->setAuthor($this->getAuthor($manager, 'Vlad'));
$p2 = new Post();
$p2->setTitle("2 Lorem Impsum post");
$p2->setBody("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.");
$p2->setAuthor($this->getAuthor($manager, 'Nikolay'));
$p3 = new Post();
$p3->setTitle("3 Lorem Impsum post");
$p3->setBody("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.");
$p3->setAuthor($this->getAuthor($manager, 'Edgar'));
$manager->persist($p1);
$manager->persist($p2);
$manager->persist($p3);
$manager->flush();
}
示例13: process
public function process($ctrl)
{
OW::getCacheManager()->clean(array(PostDao::CACHE_TAG_POST_COUNT));
$service = PostService::getInstance();
/* @var $postDao PostService */
$data = $this->getValues();
$data['title'] = UTIL_HtmlTag::stripJs($data['title']);
$postIsNotPublished = $this->post->getStatus() == 2;
$text = UTIL_HtmlTag::sanitize($data['post']);
/* @var $post Post */
$this->post->setTitle($data['title']);
$this->post->setPost($text);
$this->post->setIsDraft($_POST['command'] == 'draft');
$isCreate = empty($this->post->id);
if ($isCreate) {
$this->post->setTimestamp(time());
//Required to make #698 and #822 work together
if ($_POST['command'] == 'draft') {
$this->post->setIsDraft(2);
}
BOL_AuthorizationService::getInstance()->trackAction('blogs', 'add_blog');
} else {
//If post is not new and saved as draft, remove their item from newsfeed
if ($_POST['command'] == 'draft') {
OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'blog-post', 'entityId' => $this->post->id)));
} else {
if ($postIsNotPublished) {
// Update timestamp if post was published for the first time
$this->post->setTimestamp(time());
}
}
}
$service->save($this->post);
$tags = array();
if (intval($this->post->getId()) > 0) {
$tags = $data['tf'];
foreach ($tags as $id => $tag) {
$tags[$id] = UTIL_HtmlTag::stripTags($tag);
}
}
$tagService = BOL_TagService::getInstance();
$tagService->updateEntityTags($this->post->getId(), 'blog-post', $tags);
if ($this->post->isDraft()) {
$tagService->setEntityStatus('blog-post', $this->post->getId(), false);
if ($isCreate) {
OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'create_draft_success_msg'));
} else {
OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'edit_draft_success_msg'));
}
} else {
$tagService->setEntityStatus('blog-post', $this->post->getId(), true);
//Newsfeed
$event = new OW_Event('feed.action', array('pluginKey' => 'blogs', 'entityType' => 'blog-post', 'entityId' => $this->post->getId(), 'userId' => $this->post->getAuthorId()));
OW::getEventManager()->trigger($event);
if ($isCreate) {
OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'create_success_msg'));
OW::getEventManager()->trigger(new OW_Event(PostService::EVENT_AFTER_ADD, array('postId' => $this->post->getId())));
} else {
OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'edit_success_msg'));
OW::getEventManager()->trigger(new OW_Event(PostService::EVENT_AFTER_EDIT, array('postId' => $this->post->getId())));
}
$ctrl->redirect(OW::getRouter()->urlForRoute('post', array('id' => $this->post->getId())));
}
}
示例14: PDO
<?php
include_once 'Registry.php';
include_once 'dao/PostDAO.php';
include_once 'model/Post.php';
// Instanciar uma conexão com PDO
$conn = new PDO('mysql:host=localhost;port=3306;dbname=example-pdo', 'user', 'password');
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Armazenar essa instância no Registry
$registry = Registry::getInstance();
$registry->set('Connection', $conn);
// Instanciar um novo Post e setar informações
$primeiroPost = new Post();
$primeiroPost->setTitle('Primeiro post');
$primeiroPost->setContent('Conteudo!');
// Instanciar um novo Post e setar informações
$segundoPost = new Post();
$segundoPost->setTitle('Segundo post');
$segundoPost->setContent('Conteudo!');
// Instanciar o DAO e trabalhar com os métodos
$postDAO = new PostDAO();
$postDAO->insert($primeiroPost);
$postDAO->insert($segundoPost);
// Resgatar todos os registros e iterar
$results = $postDAO->getAll();
foreach ($results as $post) {
echo $post->getTitle() . '<br />';
echo $post->getContent() . '<br />';
echo '<br />';
}
示例15: Create
<?php
require_once 'autoloader.php';
echo "ok";
$query = new Create();
$query->createDatabase();
$user = new Post();
$user->setTitle('Etiam posuere');
$user->setPhotos('pics02.jpg');
$user->setContent('Pellentesque viverra vulputate enim. Aliquam erat volutpat. Pellentesque tristique ante. Sed vel tellus.');
$user->save();