/**
  * @return string
  * @throws \Propel\Runtime\Exception\PropelException
  */
 public function postArticle()
 {
     $data = \Kernel::getInstance()->app->request()->post();
     $article = new Article();
     $article->fromArray($data);
     return $this->response(['success' => (bool) $article->save()], 201);
 }
 public function actionAdd()
 {
     $model = new Article();
     if (Request::isPost()) {
         if ($model->add(['title' => Request::post('title'), 'content' => Request::post('content')])) {
             Redirect::home();
         }
     }
     echo $this->view->render('add');
 }
Exemple #3
0
 public function home($req, $req2)
 {
     //$article = Article::first();
     //echo __FILE__;
     //echo $req.'<br>'.$req2;
     //require dirname(__FILE__).'/../views/home.php';
     $this->view = \View::make('home')->with('article', Article::first())->withTitle('MFFC :-D')->withFindMe('OK!')->withReq($req)->with('req2', $req2);
     /*$this->mail = \Mail::to(['*****@*****.**', '*****@*****.**'])
     
                 ->from('M**********r <*****@*****.**>')
     
                 ->title('F**k Me!')
     
                 ->content('<h1>Hello~~</h1>');*/
     \Redis::set('key', 'value', 5, 's');
     echo \Redis::get('key') . '<br>';
 }
 private static function insert(Article $model)
 {
     $db = Database::getInstance('app');
     $query = "INSERT INTO articles (title,introNewsData,newsData,picture,thumbnail,createdAt,category_id,isPosted) VALUES (:title, :introNewsData, :newsData, :picture, :thumbnail, :createdAt, :category_id, :isPosted);";
     $result = $db->prepare($query);
     $result->execute([':title' => $model->getTitle(), ':introNewsData' => $model->getIntroNewsData(), ':newsData' => $model->getNewsData(), ':picture' => $model->getPicture(), ':thumbnail' => $model->getThumbnail(), ':createdAt' => $model->getCreatedAt(), ':category_id' => $model->getCategory_id(), ':isPosted' => $model->getIsPosted()]);
     $model->setId($db->lastId());
 }
Exemple #5
0
 /**
  * @param ChildArticle $article The ChildArticle object to add.
  */
 protected function doAddArticle(ChildArticle $article)
 {
     $this->collArticles[] = $article;
     $article->setUser($this);
 }
 private static function insert(Article $model)
 {
     $db = Database::getInstance('app');
     $query = "INSERT INTO articles (title,content,post_date,articleImage,titleBG,contentBG) VALUES (:title, :content, :post_date, :articleImage, :titleBG, :contentBG);";
     $result = $db->prepare($query);
     $result->execute([':title' => $model->getTitle(), ':content' => $model->getContent(), ':post_date' => $model->getPost_date(), ':articleImage' => $model->getArticleImage(), ':titleBG' => $model->getTitleBG(), ':contentBG' => $model->getContentBG()]);
     $model->setId($db->lastId());
 }
Exemple #7
0
 /**
  * Filter the query by a related \Models\Article object
  *
  * @param \Models\Article|ObjectCollection $article the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildUserQuery The current query, for fluid interface
  */
 public function filterByArticle($article, $comparison = null)
 {
     if ($article instanceof \Models\Article) {
         return $this->addUsingAlias(UserTableMap::COL_ID, $article->getIdUser(), $comparison);
     } elseif ($article instanceof ObjectCollection) {
         return $this->useArticleQuery()->filterByPrimaryKeys($article->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByArticle() only accepts arguments of type \\Models\\Article or Collection');
     }
 }
Exemple #8
0
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aUser) {
         $this->aUser->removeComment($this);
     }
     if (null !== $this->aArticle) {
         $this->aArticle->removeComment($this);
     }
     $this->id = null;
     $this->id_user = null;
     $this->id_article = null;
     $this->content = null;
     $this->like_count = null;
     $this->created_at = null;
     $this->updated_at = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->applyDefaultValues();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
Exemple #9
0
 public function articleSave()
 {
     //If saving a new article
     if ($_POST["save"] == "Přidat") {
         $article = new Article();
         $article->setIdUser($_POST["author"]);
         if (isset($_POST["image-article"])) {
             $data = explode(',', $_POST["image-article"]);
             if (count($data) == 2 && $data[0] == "data:image/png;base64" && base64_decode($data[1])) {
                 $dir = "includes/images/fullsize/";
                 $img = imagecreatefromstring(base64_decode($data[1]));
                 do {
                     $name = token(20) . ".png";
                     $path = $dir . $name;
                 } while (file_exists($path));
                 $i = new Image();
                 $i->setPath($name)->setThumbnailPath($name)->setType("fullsize")->save();
                 imagepng($img, $path);
                 $dir = "includes/images/960x540/";
                 $path = $dir . $name;
                 imagepng(resizeImg($img, 960, 540), $path);
                 $dir = "includes/images/50x50/";
                 $path = $dir . $name;
                 imagepng(resizeImg($img, 50, 50), $path);
             } else {
                 $this->addPopup('danger', 'Něco se pokazilo při nahrávání obrázku. Zkuste to prosím znovu.');
                 redirectTo('/administrace/clanky/pridat');
             }
         } else {
             $this->addPopup('danger', 'Něco se pokazilo při nahrávání obrázku. Zkuste to prosím znovu.');
             redirectTo('/administrace/clanky/pridat');
         }
         $im = ImageQuery::create()->filterByPath($name)->findOne();
         $article->setIdImage($im->getId());
         $article->setIdCategory($_POST["category"]);
         $article->setTitle($_POST["title"]);
         $article->setKeywords(str_replace(", ", ",", $_POST["keywords"]));
         $article->setContent($_POST["content"]);
         $article->save();
         $article = ArticleQuery::create()->orderByCreatedAt('desc')->findOne();
         $article->setUrl($article->getId());
         $article->save();
         $this->addPopup('success', 'Článek byl úspěšně přidán!');
         redirectTo("/administrace");
     } elseif ($_POST["save"] == "Upravit") {
         $article = ArticleQuery::create()->findPk($_POST["article"]);
         $article->setIdCategory($_POST["category"]);
         $article->setTitle($_POST["title"]);
         $article->setKeywords(str_replace(", ", ",", $_POST["keywords"]));
         $article->setContent($_POST["content"]);
         if (isset($_POST["image-article"])) {
             $data = explode(',', $_POST["image-article"]);
             if (count($data) == 2 && $data[0] == "data:image/png;base64" && base64_decode($data[1])) {
                 $dir = "includes/images/fullsize/";
                 $img = imagecreatefromstring(base64_decode($data[1]));
                 do {
                     $name = token(20) . ".png";
                     $path = $dir . $name;
                 } while (file_exists($path));
                 $i = new Image();
                 $i->setPath($name)->setThumbnailPath($name)->setType("fullsize")->save();
                 imagepng($img, $path);
                 $dir = "includes/images/960x540/";
                 $path = $dir . $name;
                 imagepng(resizeImg($img, 960, 540), $path);
                 $dir = "includes/images/50x50/";
                 $path = $dir . $name;
                 imagepng(resizeImg($img, 50, 50), $path);
                 $im = ImageQuery::create()->filterByPath($name)->findOne();
                 $article->setIdImage($im->getId());
             } else {
                 $this->addPopup('danger', 'Něco se pokazilo při nahrávání obrázku. Zkuste to prosím znovu.');
                 redirectTo('/administrace/clanek/' . $id . '/upravit');
             }
         }
         $article->save();
         $this->addPopup('success', 'Článek byl úspěšně upraven!');
         redirectTo("/administrace/clanky");
     }
 }
Exemple #10
0
 /**
  * Exclude object from result
  *
  * @param   ChildArticle $article Object to remove from the list of results
  *
  * @return $this|ChildArticleQuery The current query, for fluid interface
  */
 public function prune($article = null)
 {
     if ($article) {
         $this->addUsingAlias(ArticleTableMap::COL_ID, $article->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Exemple #11
0
 /**
  * Filter the query by a related \Models\Article object
  *
  * @param \Models\Article|ObjectCollection $article The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return ChildCommentQuery The current query, for fluid interface
  */
 public function filterByArticle($article, $comparison = null)
 {
     if ($article instanceof \Models\Article) {
         return $this->addUsingAlias(CommentTableMap::COL_ID_ARTICLE, $article->getId(), $comparison);
     } elseif ($article instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(CommentTableMap::COL_ID_ARTICLE, $article->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByArticle() only accepts arguments of type \\Models\\Article or Collection');
     }
 }