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()); }
public function editPost(Post $post) { $STH = $this->DBH->prepare("UPDATE Posts SET textpost=:textpost, title=:title\n WHERE id=:id"); $STH->bindValue(":textpost", $post->getTextpost()); $STH->bindValue(":title", $post->getTitle()); $STH->execute(); }
public function testNewPostFromArray() { $data = array('title' => 'titolo del post', 'intro' => 'intro del post', 'body' => 'il body', 'image' => 'nice.jpg', 'published_at' => new DateTime('now')); $post = new Post(); $post->fromArray($data); $this->assertEquals('titolo del post', $post->getTitle()); }
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(); } }
function visitPost(Post $p) { $text = $p->getText(); $title = $p->getTitle(); $author = $p->getAuthor(); $time = $p->getTime(); $tags = $this->tagsToString($p->getTags()); echo '<div id="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 '</div>'; }
function visitPost(Post $p) { $text = $p->getText(); $title = $p->getTitle(); $author = $p->getAuthor(); $time = $p->getTime(); $tags = $this->tagsToString($p->getTags()); echo '<post>'; echo '<title>' . utf8_encode($title) . '</title>'; echo '<author>' . utf8_encode($author) . '</author>'; echo '<time>' . utf8_encode(date("H:i:s - d/m/Y", $time)) . '</time>'; echo '<tags>' . utf8_encode($tags) . '</tags>'; echo '<text>' . utf8_encode($text) . '</text>'; echo '</post>'; }
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>'; }
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>'; }
/** * Renderize the view. * * @return null */ public function render(Post $post) { ?> <!-- JQUERY UI --> <link type="text/css" rel="stylesheet" href="<?php echo APP_PATH; ?> /css/jquery-ui.min.css"> <link type="text/css" rel="stylesheet" href="<?php echo APP_PATH; ?> /css/jquery-ui.theme.min.css"> <script type="text/javascript" src="<?php echo APP_PATH; ?> /js/jquery-ui.min.js"></script> <script type="text/javascript"> $(function(){ $("#date").datepicker({dateFormat: "yy-mm-dd"}); }); </script> <p> <?php echo REQUIRED_FIELDS_TEXT; ?> </p> <form action="<?php echo $this->generateURL('post', 'edit', $post->getIdPost()); ?> " method="post"> <fieldset> <div class="row"> <div class="col-md-6"> <div> <label for="title"> Título <small>(*)</small> </label> <input name="title" type="text" required value="<?php echo $post->getTitle(); ?> " /> </div> <div> <label for="headline"> Copete <small>(*)</small> </label> <textarea name="headline" required><?php echo $post->getHeadline(); ?> </textarea> </div> <div> <label for="date"> Fecha <small>(*)</small> </label> <input id="date" name="date" type="text" required value="<?php echo $post->getDate(); ?> " /> </div> <div> <label for="body"> Cuerpo <small>(*)</small> </label> <textarea name="body" required><?php echo $post->getBody(); ?> </textarea> </div> </div> <div class="col-md-6"> <div> <label for="source"> Fuente <small>(*)</small> </label> <input name="source" type="text" value="<?php echo $post->getSource(); ?> " required /> </div> <div> <label for="category"> Categoría <small>(*)</small> </label> <select name="category" required> <option value=""> Seleccionar </option> <?php if ($post->getCategory() === "Noticia") { ?> <option value="Noticia" selected> Noticia </option> <option value="Evento"> Evento </option> <?php } else { ?> <option value="Noticia"> Noticia </option> <option value="Evento" selected> Evento </option> <?php } ?> </select> </div> <div> <label for="status"> Estado <small>(*)</small> </label> <select name="status" required> <option value=""> Seleccionar </option> <?php if ($post->getStatus() === "DESTACADO") { ?> <option value="DESTACADO" selected> Destacado </option> <option value="NO DESTACADO"> No Destacado </option> <?php } else { ?> <option value="DESTACADO"> Destacado </option> <option value="NO DESTACADO" selected> No Destacado </option> <?php } ?> </select> </div> <div> <input type="submit" value="Modificar" /> </div> </div> </div> </fieldset> </form> <?php }
if ($resp["response"]) { $optionList = $resp["allPosts"]; foreach ($optionList as $post) { echo '<option value="' . $post->getId() . '">' . $post->getTitle() . '</option>'; } } else { echo '<option value="">nessun post</option>'; } ?> </select></div><div class="col-md-2"> <input class="form-control" type="hidden" name="action" id="action" value="add_get"><input type="submit" class="btn btn-warning" value="Select Post"></div> </form> <br><br><br> <form action="../controller/post_controller.php" method="POST"> <textarea class="form-control" type="text" name="title" id="title" ><?php echo $postOnGet->getTitle(); ?> </textarea><br> <textarea class="form-control" type="text" name="subtitle" id="subtitle" ><?php echo $postOnGet->getSubTitle(); ?> </textarea><br> <textarea class="form-control" type="text" name="text" id="text"><?php echo $postOnGet->getText(); ?> </textarea><br> <input class="form-control" type="date" name="date" id="date" <?php echo 'value=' . $postOnGet->getDate(); ?> ><br> <select class="form-control editAvatar" name="image" id="avatar">
/** * Save post object and populate it with id * * @param Post $post * @return Post */ public function save(Post $post) { $id = $this->persistence->persist(array('author' => $post->getAuthor(), 'created' => $post->getCreated(), 'text' => $post->getText(), 'title' => $post->getTitle())); $post->setId($id); return $post; }
/** * Modify a post saved in the database. * * @param Post $post * @return integer */ public function editPost(Post $post) { $sql = "UPDATE post \n\t\t\tSET id_post = '" . $post->getIdPost() . "', category = '" . $post->getCategory() . "', title = '" . replaceCharacters($post->getTitle()) . "', body = '" . $this->formatBody(replaceCharacters($post->getBody())) . "', video = '" . $post->getVideo() . "' WHERE id_post = '" . $post->getIdPost() . "'"; return DB::query($sql); }
</style> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script src="http://static.wix.com/services/wix-public/1.8.0/js/Wix.js" type="text/javascript"></script> <script> $(document).ready(function () { Wix.reportHeightChange($('body').outerHeight(true)); }); </script> </head> <body style="width: <?php print getWixWidth(); ?> "> <!-- POST --> <div> <h1><?php print $post->getTitle(); ?> </h1> <div style="padding-top: 10px"> <?php print nl2br($post->getBody()); ?> </div> </div> </body> </html>
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()); }
public function save(Post $post) { $id = $this->persistence->persist(['text' => $post->getText(), 'title' => $post->getTitle()]); $post->setId($id); }
public function testSave() { $post = new Post(); $post->setDate('2012-01-01 12:12'); $post->setTitle('New Post'); $post->setContent('New content'); $post->save('/tmp/'); $newPost = new Post('/tmp/2012-01-01-new-post.md'); $this->assertEquals('New Post', $post->getTitle()); $newPost->setTitle('change-url'); $newPost->save('/tmp/'); }
/** * 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())); }
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"> function save() { document.<?php echo $name; ?> Post.visible.value = false; document.<?php echo $name; ?> Post.submit(); } </script> <?php require_once 'manager/MapManager.php'; MapManager::setCenterToMap($post->getPlace(), "map_canvas"); ?> </form> <?php } }
/** * Renderize the view. * * @return null */ public function render(Post $post) { ?> <!-- JQUERY UI --> <link type="text/css" rel="stylesheet" href="<?php echo APP_PATH; ?> /css/jquery-ui.min.css"> <link type="text/css" rel="stylesheet" href="<?php echo APP_PATH; ?> /css/jquery-ui.theme.min.css"> <script type="text/javascript" src="<?php echo APP_PATH; ?> /js/jquery-ui.min.js"></script> <script type="text/javascript"> $(function(){ $("#date").datepicker({dateFormat: "yy-mm-dd"}); }); </script> <p> <?php echo REQUIRED_FIELDS_TEXT; ?> </p> <form action="<?php echo $this->generateURL('post', 'edit', $post->getIdPost()); ?> " method="post"> <fieldset> <div class="row"> <div class="col-md-6"> <div> <label for="category"> Categoría <small>(*)</small> </label> <select name="category" required> <option value=""> Seleccionar </option> <?php if ($post->getCategory() === "Editorial") { ?> <option selected> Editorial </option> <option> Noticia </option> <option> Informate </option> <?php } else { if ($post->getCategory() === "Noticia") { ?> <option> Editorial </option> <option selected> Noticia </option> <option> Informate </option> <?php } else { ?> <option> Editorial </option> <option> Noticia </option> <option selected> Informate </option> <?php } } ?> </select> </div> <div> <label for="title"> Título <small>(*)</small> </label> <input name="title" type="text" required value="<?php echo $post->getTitle(); ?> " /> </div> <div> <label for="body"> Cuerpo <small>(*)</small> </label> <textarea name="body" required><?php echo $post->getBody(); ?> </textarea> </div> </div> <div class="col-md-6"> <div> <label for="video"> Video </label> <textarea name="video"><?php echo $post->getVideo(); ?> </textarea> </div> <div> <input type="submit" value="Modificar" /> </div> </div> </div> </fieldset> </form> <?php }
/** * 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.'); } }
/** * Generate HTML from source + templates and sitemap.xml into output directory. * * @return bool */ public function generateStaticPosts() { if ($this->sourcePath === null || $this->templatePath === null || $this->outputPath === null) { throw new \InvalidArgumentException('Check paths'); } $sourceFiles = array(); foreach (glob($this->sourcePath . '/*.md') as $mdFile) { $sourceFiles[] = $mdFile; } if (count($sourceFiles) === 0) { throw new \LengthException('No Markdown files found to crunch.'); } /** * Source files prefixed with running number => goodness * '1-first-post.md','2-second-post.md' etc. */ natsort($sourceFiles); $sourceFiles = array_reverse($sourceFiles); $lastPostKey = false; $postFilenames = $links = $posts = array(); foreach ($sourceFiles as $key => $mdFile) { $post = new Post($mdFile); if ($post->isPublic()) { $links[] = array('url' => $post->getHtmlFilename(), 'title' => $post->getTitle()); } if ($lastPostKey === false && $post->isPublic()) { $lastPostKey = $key; } if (array_search($post->getHtmlFilename(), $postFilenames) !== false) { throw new \LogicException('Titles resulting in identical filenames found "' . $post->getTitle() . '"'); } $postFilenames[] = $post->getHtmlFilename(); $posts[$key] = $post; } foreach (glob($this->outputPath . '/*.html') as $htmlFile) { unlink($htmlFile); } $loader = new \Twig_Loader_Filesystem($this->templatePath); $twig = new \Twig_Environment($loader); $siteMapUrls = array(); /* @var $post \Oblog\Post */ foreach ($posts as $key => $post) { $postHtml = $twig->render('post.html', array('title' => $post->getTitle(), 'modifiedAt' => $post->getModifiedAt(), 'post' => $post->getHtml())); $pageVariables = array('article' => $postHtml, 'links' => $links, 'title' => $post->getTitle()); if ($key == $lastPostKey) { $pageVariables['canonical'] = $this->baseUrl . '/' . $post->getHtmlFilename(); } $pageHtml = $twig->render('page.html', $pageVariables); $outputFilename = $post->getHtmlFilename(); file_put_contents($this->outputPath . '/' . $outputFilename, $pageHtml); touch($this->outputPath . '/' . $outputFilename, $post->getModifiedAt()); if ($key == $lastPostKey) { file_put_contents($this->outputPath . '/index.html', $pageHtml); } if ($post->isPublic()) { $siteMapUrls[] = array('loc' => $this->baseUrl . '/' . $outputFilename, 'priority' => 0.5, 'lastmod' => date('Y-m-d', $post->getModifiedAt())); } else { echo PHP_EOL . 'DRAFT at ' . $this->baseUrl . '/' . $outputFilename; } } if ($lastPostKey !== false) { $siteMapUrls[] = array('loc' => $this->baseUrl . '/', 'priority' => '1', 'lastmod' => date('Y-m-d', $posts[$lastPostKey]->getModifiedAt()), 'changefreq' => 'daily'); } $siteMapVariables = array('baseurl' => $this->baseUrl, 'urls' => $siteMapUrls); $sitemapXml = $twig->render('sitemap.xml', $siteMapVariables); file_put_contents($this->outputPath . '/sitemap.xml', $sitemapXml); return true; }
function addPost(Post $p) { $query = "INSERT INTO `" . $this->_database . "`.`Posts` "; $query .= "(`ID`, `Title`, `Text`, `Author`, `Time`, `Tags`) "; $query .= "VALUES (NULL, '" . $p->getTitle() . "', "; $query .= "'" . $p->getText() . "', "; $query .= "'" . $p->getAuthor() . "', "; $query .= "'" . $p->getTime() . "', "; $query .= "'" . serialize($p->getTags()) . "');"; $added = mysql_query($query, $this->_connection); }
public function __construct(Post $post, $tags = array()) { parent::__construct('save'); $this->service = PostService::getInstance(); $this->post = $post; $this->setMethod('post'); $titleTextField = new TextField('title'); $this->addElement($titleTextField->setLabel(OW::getLanguage()->text('blogs', 'save_form_lbl_title'))->setValue($post->getTitle())->setRequired(true)); $buttons = array(BOL_TextFormatService::WS_BTN_BOLD, BOL_TextFormatService::WS_BTN_ITALIC, BOL_TextFormatService::WS_BTN_UNDERLINE, BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_LINK, BOL_TextFormatService::WS_BTN_ORDERED_LIST, BOL_TextFormatService::WS_BTN_UNORDERED_LIST, BOL_TextFormatService::WS_BTN_MORE, BOL_TextFormatService::WS_BTN_SWITCH_HTML, BOL_TextFormatService::WS_BTN_HTML, BOL_TextFormatService::WS_BTN_VIDEO); $postTextArea = new WysiwygTextarea('post', $buttons); $postTextArea->setSize(WysiwygTextarea::SIZE_L); $postTextArea->setLabel(OW::getLanguage()->text('blogs', 'save_form_lbl_post')); $postTextArea->setValue($post->getPost()); $postTextArea->setRequired(true); $this->addElement($postTextArea); $draftSubmit = new Submit('draft'); $draftSubmit->addAttribute('onclick', "\$('#save_post_command').attr('value', 'draft');"); if ($post->getId() != null && !$post->isDraft()) { $text = OW::getLanguage()->text('blogs', 'change_status_draft'); } else { $text = OW::getLanguage()->text('blogs', 'sava_draft'); } $this->addElement($draftSubmit->setValue($text)); if ($post->getId() != null && !$post->isDraft()) { $text = OW::getLanguage()->text('blogs', 'update'); } else { $text = OW::getLanguage()->text('blogs', 'save_publish'); } $publishSubmit = new Submit('publish'); $publishSubmit->addAttribute('onclick', "\$('#save_post_command').attr('value', 'publish');"); $this->addElement($publishSubmit->setValue($text)); $tagService = BOL_TagService::getInstance(); $tags = array(); if (intval($this->post->getId()) > 0) { $arr = $tagService->findEntityTags($this->post->getId(), 'blog-post'); foreach (!empty($arr) ? $arr : array() as $dto) { $tags[] = $dto->getLabel(); } } $tf = new TagsInputField('tf'); $tf->setLabel(OW::getLanguage()->text('blogs', 'tags_field_label')); $tf->setValue($tags); $this->addElement($tf); }
/** * Modify a post saved in the database. * * @param Post $post * @return integer */ public function editPost(Post $post) { $sql = "UPDATE post \n\t\t\tSET id_post = '" . $post->getIdPost() . "', title = '" . replaceCharacters($post->getTitle()) . "', headline = '" . replaceCharacters($post->getHeadline()) . "', date = '" . $post->getDate() . "', body = '" . $this->formatBody(replaceCharacters($post->getBody())) . "', source = '" . replaceCharacters($post->getSource()) . "', category = '" . $post->getCategory() . "', status = '" . $post->getStatus() . "' WHERE id_post = '" . $post->getIdPost() . "'"; return DB::query($sql); }