本文整理汇总了PHP中Article::setContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::setContent方法的具体用法?PHP Article::setContent怎么用?PHP Article::setContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::setContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadOne
protected function loadOne($file)
{
$xml = new SimpleXMLElement($file, 0, true);
if ((string) $xml->head->title == null) {
return null;
}
$article = new Article();
foreach ($xml->head->meta as $meta) {
$name = (string) $meta['name'];
$content = (string) $meta['content'];
switch ($name) {
case 'date':
$article->setPublicationDate(new DateTime($content));
break;
case 'author':
$article->setAuthor($content);
break;
}
}
$article->setTitle((string) $xml->head->title);
$article->setHash($this->getHash($article->getTitle()));
$content = "";
foreach ($xml->body->children() as $child) {
$content .= $child->asXml();
}
$article->setContent($content);
return $article;
}
示例2: create
public function create($title, $content, User $user)
{
$article = new Article();
$valide = $article->setContent($content);
if ($valide === true) {
$valide = $article->setUser($user);
if ($valide === true) {
$content = mysqli_real_escape_string($this->db, $article->getContent());
$id_user = $article->getId_user();
$query = "INSERT INTO article (title, content, id_user) VALUES('" . $title . "', '" . $content . "', '" . $id_user . "')";
$res = mysqli_query($this->db, $query);
if ($res) {
$id = mysqli_insert_id($this->db);
if ($id) {
return $this->findById($id);
} else {
return "Internal server error";
}
} else {
echo 'test14';
exit;
return mysqli_error($this->db);
}
} else {
return $valide;
}
} else {
return $valide;
}
}
示例3: getArticleDetail
public function getArticleDetail($id)
{
$sqlHelper = new SqlHelper();
$article = new Article();
$sql = "select * from lavender_article where id={$id}";
$res = $sqlHelper->dql_arr($sql);
$article->setId($res[0]['id']);
$article->setPraise($res[0]['praise']);
$article->setContent($res[0]['content']);
$article->setDate($res[0]['date']);
$article->setReadTime($res[0]['read_time']);
$article->setImg($res[0]['img']);
$article->setNoPraise($res[0]['no_praise']);
$article->setTitle($res[0]['title']);
return $article;
}
示例4: executeRandomArticle
function executeRandomArticle()
{
$post = new Article();
$arr = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
for ($i = 0; $i < 6; $i = $i + 1) {
$index = rand(0, Count($arr));
$title = $title . $arr[$index];
}
$post->setTitle($title);
for ($i = 0; $i < 30; $i = $i + 1) {
$index = rand(0, Count($arr));
$content = $content . $arr[$index];
}
$post->setContent($content);
$post->save();
$this->redirect('adminblog/index');
}
示例5: testAction
public function testAction()
{
$article = new Article();
$article->setTitle("L'histoire d'un bon weekend !");
$article->setContent("Le weekend était vraiment trop bien !");
$article->setCreatedAt(new \DateTime('now', new \DateTimeZone('Europe/Paris')));
$article->setEnabled(true);
$em = $this->getDoctrine()->getManager();
$user = $this->getUser();
if ($user) {
$article->setUser($user);
}
$em->persist($article);
$em->flush();
$url = $this->generateUrl('suplol_user_homepage');
return $this->redirect($url);
}
示例6: create
public function create($title, $content, $image, $idAuthor)
{
$article = new Article($this->db);
try {
$article->setTitle($title);
$article->setContent($content);
$article->setImage($image);
$article->setIdAuthor($idAuthor);
} catch (Exception $e) {
$errors = $e->getMessage();
echo $errors;
}
if (!isset($err)) {
$title = $this->db->quote($article->getTitle());
$content = $this->db->quote($article->getContent());
$idAuthor = $article->getIdAuthor();
if ($image == "") {
$query = 'INSERT INTO article(title, content, idAuthor)
VALUE (' . $title . ',' . $content . ',' . $idAuthor . ')';
} else {
$image = $this->db->quote($article->getImage());
$query = 'INSERT INTO article(title, content, image, idAuthor)
VALUE (' . $title . ',' . $content . ',' . $image . ',' . $idAuthor . ')';
}
}
$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);
}
}
示例7: CategoryDao
<?php
include_once 'data/CategoryDAO.php';
include_once 'control/ArticleControls.php';
include_once 'business/Article.php';
$categoryDao = new CategoryDao();
$articleController = new ArticleControls();
$article = new Article();
$article->setName($_POST['title']);
$article->setId(intval($_POST['id']));
$article->setContent($_POST['editor']);
$article->setSumup($_POST['sumup_editor']);
$article->setTags($_POST['tags']);
$ret = $articleController->alterArticle($article);
if ($ret) {
header("location:../news.php?art_id=" . $_POST['id']);
} else {
echo "Unexpected exception";
}
示例8: Article
<?php
include_once 'business/Article.php';
include 'control/ArticleControls.php';
include_once 'business/Comment.php';
$article = new Article();
$control = new ArticleControls();
$article->setTitle($_POST['title']);
$article->setContent($_POST['category']);
// $article->setUser_name($_POST['name']);
// $article->setNews_id($_POST['id']);
// $article->setIp($_POST['ip']);
if ($control->addMail($article)) {
header("location:../news.php?art_id=" . $_POST['id']);
} else {
echo "La requête n'a pu être exécutée";
}
示例9: __invoke
public function __invoke($args)
{
if (count($args) < 2) {
throw new OrongoScriptParseException("Arguments missing for Articles.SetContent()");
}
$article = new Article($args[0]);
$article->setContent($args[1]);
}
示例10: Article
try {
$article = new Article($id);
} catch (Exception $e) {
if ($e->getCode() == ARTICLE_NOT_EXIST) {
header("Location: " . orongoURL("orongo-admin/manage.php?msg=0&obj=articles"));
exit;
} else {
header("Location: " . orongoURL("orongo-admin/index.php?msg=2"));
exit;
}
}
if (!empty($_POST['title'])) {
$article->setTitle($_POST['title']);
}
if (!empty($_POST['content'])) {
$article->setContent($_POST['content']);
}
if (!empty($_POST['tags'])) {
$tags = explode(",", trim($_POST['tags']));
foreach ($tags as &$tag) {
trim($tag);
}
$article->setTags($tags);
}
header("Location: " . orongoURL("orongo-admin/view.php?msg=1&obj=article&id=" . $article->getID()));
exit;
break;
case "page":
if (getUser()->getRank() < RANK_WRITER) {
header("Location: " . orongoURL("orongo-admin/index.php?msg=0"));
exit;
示例11: run
/**
* Run method with main page logic
*
* Populate template and display form for creating a new article entry. For POST requests,
* validate form data and save information to database. Available to admins only
* @access public
*/
public function run()
{
$session = Session::getInstance();
$user = $session->getUser();
if (!$user || !$user->isAdmin()) {
$session->setMessage("Do not have permission to access", Session::MESSAGE_ERROR);
header("Location: " . BASE_URL);
return;
}
$form_errors = array();
$form_values = array("title" => "", "content" => "", "postDate" => "", "published" => "", "tags" => "");
$articleDAO = ArticleDAO::getInstance();
$tagDAO = ArticleTagDAO::getInstance();
if (!empty($_POST)) {
$form_values["title"] = isset($_POST["title"]) ? trim($_POST["title"]) : "";
$form_values["content"] = isset($_POST["content"]) ? trim($_POST["content"]) : "";
$form_values["postDate"] = isset($_POST["postDate"]) ? trim($_POST["postDate"]) : "";
$form_values["published"] = isset($_POST["published"]) ? trim($_POST["published"]) : "";
$form_values["tags"] = isset($_POST["tags"]) ? trim($_POST["tags"]) : "";
if (empty($form_values["title"])) {
$form_errors["title"] = "No title specified";
}
if (empty($form_values["content"])) {
$form_errors["content"] = "No content specified";
}
if (empty($form_values["postDate"])) {
$form_errors["postDate"] = "No post date specified";
} else {
if (strtotime($_POST["postDate"]) == 0) {
$form_errors["postDate"] = "An invalid post date was specified";
$form_values["postDate"] = "";
}
}
if ($form_values["published"] != "true" && $form_values["published"] != "false") {
$form_errors["published"] = "Invalid published choice";
}
if (empty($form_errors)) {
$article = new Article();
$article->setTitle($form_values["title"]);
$article->setContent($form_values["content"]);
$article->setPostDate(strtotime($form_values["postDate"]));
$article->setUpdateDate(0);
$published = $form_values["published"] == "true" ? 1 : 0;
$article->setPublished($published);
$article->setUserId($user->id);
//$article->setTags ($form_values["tags"]);
$sorted_tag_array = ArticleTag::tagsFromString($form_values["tags"]);
$sorted_tags = implode(" ", $sorted_tag_array);
$article->setTags($sorted_tags);
if ($articleDAO->insert($article)) {
$tagDAO->updateTags($article);
$session->setMessage("Article details saved");
header("Location: edit_article.php?id={$article->id}");
return;
} else {
$session->setMessage("Article details could not be saved", Session::MESSAGE_ERROR);
}
}
}
$this->template->render(array("title" => "Create Article", "extra_header" => joinPath("headers", "jscal_header_tpl.php"), "main_page" => "create_article_tpl.php", "session" => $session, "form_errors" => $form_errors, "form_values" => $form_values));
}
示例12: Article
<?php
require '../class/class_article.php';
if (isset($_POST) && !empty($_POST)) {
$article = new Article();
$article->setTitle($_POST['title']);
$article->setContent($_POST["content"]);
$article->setIdAuthor($_POST["idAuthor"]);
$article->setIdDisaster($_POST["idDisaster"]);
$disaster->setDateCreation(date("Y-m-d H:i:s"));
$article->create();
var_dump($article);
exit;
}
示例13: formatContent
private function formatContent(Article $article)
{
$var = $article->getContent();
$var = str_replace("\n", "<br/>", $var);
$article->setContent($var);
}
示例14: update
public function update($id)
{
try {
$article = new Article($id);
if (!UserHelper::isEditor()) {
throw new fValidationException('not allowed');
}
$article->setType(fRequest::get('type'));
$article->setTitle(fRequest::get('title'));
$article->setContent(fRequest::get('content'));
$article->setPriority(fRequest::get('priority', 'integer'));
$article->setVisible(fRequest::get('visible', 'boolean'));
$article->store();
$this->ajaxReturn(array('result' => 'success', 'article_id' => $article->getId()));
} catch (fException $e) {
$this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage()));
}
}
示例15: Article
$t->is($human->getHumanRelatedByFatherId()->getName(), 'John', 'with() with self-referenced foreign keys hydrates the related objects');
$t->is(Propel::getConnection()->getLastExecutedQuery(), $sql, 'with() with self-referenced foreign keys avoids subsequent queries');
/******************************/
/* sfPropelFinder::withI18n() */
/******************************/
$t->diag('sfPropelFinder::withI18n()');
CommentPeer::doDeleteAll();
ArticlePeer::doDeleteAll();
ArticleI18nPeer::doDeleteAll();
$article1 = new Article();
$article1->setTitle('aaa');
$article1->setCulture('en');
$article1->setContent('english content');
$article1->setCulture('fr');
$article1->setContent('contenu français');
$article1->save();
$baseSQL = 'SELECT article.ID, article.TITLE, article.CATEGORY_ID, article_i18n.CONTENT, article_i18n.ID, article_i18n.CULTURE FROM article INNER JOIN article_i18n ON (article.ID=article_i18n.ID) ';
sfContext::getInstance()->getUser()->setCulture('en');
$finder = sfPropelFinder::from('Article')->
withI18n();
$article = $finder->findOne();
$query = $baseSQL . 'WHERE article_i18n.CULTURE=\'en\' LIMIT 1';
$t->is($finder->getLatestQuery(), $query, 'withI18n() hydrates the related I18n object with a culture taken from the user object');
$t->is($article->getContent(), 'english content', 'withI18n() considers the current user culture for hydration');
$t->is(Propel::getConnection()->getLastExecutedQuery(), $query, 'withI18n() hydrates the i18n object so that no further query is necessary');
sfContext::getInstance()->getUser()->setCulture('fr');