/** * @param $id * @return string * @throws ResourceNotFoundException * @throws \Propel\Runtime\Exception\PropelException */ public function deleteArticle($id) { $article = ArticleQuery::create()->findPk($id); if (!$article) { throw new ResourceNotFoundException($id); } $article->delete(); return $this->response([], 204); }
public function single($id) { $gallery = GalleryQuery::create()->findPk($id); $images = $gallery->getImages(); if (!$gallery) { $this->addPopup('danger', 'Galerie se specifikovaným identifikačním číslem neexistuje.'); redirectTo('/galerie'); } $this->view('Gallery/single', 'base_template', ['active' => 'gallery', 'title' => 'Galerie', 'recent' => ArticleQuery::recent(), 'gallery' => $gallery, 'images' => $images, 'js' => 'plugins/fotorama/fotorama', 'css' => 'plugins/fotorama/fotorama']); }
public function index() { if (isset($_POST["search"])) { $s = $_POST["search"]; } $users = UserQuery::create()->where('User.Username like ?', '%' . $s . '%')->orderByPermissions('desc')->join('Image')->withColumn('Image.Path', 'AvatarPath')->select('Username', 'AvatarPath')->find(); $articles = ArticleQuery::create()->where('Article.Title like ?', '%' . $s . '%')->_or()->where('Article.Keywords like ?', '%' . $s . '%')->orderByCreatedAt('desc')->join('User')->withColumn('User.Username', 'Author')->join('Category')->withColumn('Category.Name', 'CatgName')->join('Image')->withColumn('Image.Path', 'ImgPath')->select(array('Author', 'CatgName', 'ImgPath', 'Id', 'Title'))->find(); if ($articles->isEmpty() && $users->isEmpty()) { $this->addPopup('danger', 'Nebyl nalezen žádný článek ani uživatel.'); } $this->view('Search/index', 'base_template', ['active' => 'search', 'title' => 'Vyhledávání', 'recent' => ArticleQuery::recent(), 'articles' => $articles, 'users' => $users]); }
/** * Performs an INSERT on the database, given a Article or Criteria object. * * @param mixed $criteria Criteria or Article object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(ArticleTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from Article object } if ($criteria->containsKey(ArticleTableMap::COL_ID) && $criteria->keyContainsValue(ArticleTableMap::COL_ID)) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . ArticleTableMap::COL_ID . ')'); } // Set the correct dbName $query = ArticleQuery::create()->mergeWith($criteria); // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) return $con->transaction(function () use($con, $query) { return $query->doInsert($con); }); }
public function index() { $participants = array(2, 1); $users = UserQuery::create()->filterByIdMember($participants)->joinWith('Image')->joinWith('Member')->useMemberQuery()->joinWith('Quote')->endUse()->find(); $this->view('Landing/index', 'base_template', ['active' => 'landing', 'title' => 'Hlavní stránka', 'recent' => ArticleQuery::recent(), 'js' => array('plugins/fotorama/fotorama', 'scripts/landingpagemembers'), 'css' => 'plugins/fotorama/fotorama', 'users' => $users]); }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this User is new, it will return * an empty collection; or if this User has previously * been saved, it will retrieve related Articles from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in User. * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return ObjectCollection|ChildArticle[] List of ChildArticle objects */ public function getArticlesJoinCategory(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildArticleQuery::create(null, $criteria); $query->joinWith('Category', $joinBehavior); return $this->getArticles($query, $con); }
public static function recent() { $recent = ArticleQuery::create()->joinWithImage()->joinWithCategory()->orderByCreatedAt("desc")->limit(5)->find(); return $recent; }
public function index() { //SQL $this->view('Register/index', 'base_template', ['active' => 'register', 'title' => 'Registrace', 'recent' => ArticleQuery::recent()]); }
public function showByCategoryPage($category, $id) { $id = $id == 0 ? 1 : $id; $articles = ArticleQuery::create()->useCategoryQuery()->filterByUrl($category)->endUse()->joinWith("Category")->orderByCreatedAt("desc")->paginate($page = $id, $maxPerPage = 10); $this->view('Article/category', 'base_template', ['active' => 'blog', 'title' => $articles->getFirst()->getCategory()->getName(), 'recent' => ArticleQuery::recent(), 'articles' => $articles]); }
/** * Get the associated ChildArticle object * * @param ConnectionInterface $con Optional Connection object. * @return ChildArticle The associated ChildArticle object. * @throws PropelException */ public function getArticle(ConnectionInterface $con = null) { if ($this->aArticle === null && $this->id_article !== null) { $this->aArticle = ChildArticleQuery::create()->findPk($this->id_article, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aArticle->addComments($this); */ } return $this->aArticle; }
public function ideaSuggestionPage() { if (!$this->isLogged()) { $this->addPopup('danger', 'Pro podání návrhu na zlepšení musíte být přihlášeni.'); redirectTo("/"); } $this->view('Profile/ideaSuggestion', 'base_template', ['active' => 'ideaSuggestion', 'title' => 'Podat návrh', 'recent' => ArticleQuery::recent()]); }
public function newArticlesPage() { $articles = ArticleQuery::create()->filterByCreatedAt(array('min' => time() - 7 * 24 * 60 * 60))->joinWith('User')->orderByCreatedAt('desc')->find(); if ($articles->isEmpty()) { $this->addPopup('danger', 'Za poslední týden nebyly přidány žádné články.'); } $this->view('Admin/newArticles', 'admin_template', ['active' => 'newArticles', 'title' => 'Nové články', 'articles' => $articles]); }
/** * Builds a Criteria object containing the primary key for this object. * * Unlike buildCriteria() this method includes the primary key values regardless * of whether or not they have been modified. * * @throws LogicException if no primary key is defined * * @return Criteria The Criteria object containing value(s) for primary key(s). */ public function buildPkeyCriteria() { $criteria = ChildArticleQuery::create(); $criteria->add(ArticleTableMap::COL_ID, $this->id); return $criteria; }
/** * Returns a new ChildArticleQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return ChildArticleQuery */ public static function create($modelAlias = null, Criteria $criteria = null) { if ($criteria instanceof ChildArticleQuery) { return $criteria; } $query = new ChildArticleQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
public function index() { $participants = UserQuery::create()->joinWith("Member")->joinWith("Image")->find(); $this->view('Info/index', 'base_template', ['active' => 'info', 'title' => 'Informace', 'recent' => ArticleQuery::recent(), 'participants' => $participants]); }