private function renderRecentJournalCommentTeaser($mJournalId) { $oJournalComment = JournalCommentQuery::create()->excludeUnverified()->joinJournalEntry()->useQuery('JournalEntry')->filterByJournalId($mJournalId)->excludeDraft()->endUse()->mostRecentFirst()->findOne(); if ($oJournalComment === null) { return null; } $oTemplate = $this->constructTemplate('journal_comment_teaser'); $sHref = LinkUtil::link($oJournalComment->getJournalEntry()->getLink($this->oJournalPage)) . '#comments'; $oTemplate->replaceIdentifier('title', TagWriter::quickTag('a', array('rel' => 'internal', 'href' => $sHref), $oJournalComment->getJournalEntry()->getTitle())); $oTemplate->replaceIdentifier('link_to_detail', $sHref); $oTemplate->replaceIdentifier('created_at', $oJournalComment->getCreatedAt('U')); $oTemplate->replaceIdentifier('name', $oJournalComment->getUsername()); $oTemplate->replaceIdentifier('text', $oJournalComment->getText(), null, Template::NO_HTML_ESCAPE); return $oTemplate; }
public function loadData() { $oJournalEntry = JournalEntryPeer::retrieveByPK($this->iJournalEntryId); if (!$oJournalEntry) { return; } $aResult = array(); $aResult = $oJournalEntry->toArray(); $aResult['Text'] = RichtextUtil::parseStorageForBackendOutput($aResult['Text'])->render(); $aResult['PublishAt'] = $oJournalEntry->getPublishAt('d.m.Y'); $aResult['CreatedInfo'] = Util::formatCreatedInfo($oJournalEntry); $aResult['UpdatedInfo'] = Util::formatUpdatedInfo($oJournalEntry); $aResult['comments'] = array(); foreach (JournalCommentQuery::create()->filterByJournalEntryId($this->iJournalEntryId)->orderByCreatedAt(Criteria::DESC)->find() as $oComment) { $aComment = array(); $aComment['CreatedAtFormatted'] = $oComment->getCreatedAtFormatted(); $aComment['Id'] = $oComment->getId(); $aComment['Email'] = $oComment->getEmail(); $aComment['Text'] = strip_tags($oComment->getText()); $aComment['IsPublished'] = $oComment->getIsPublished(); $aResult['comments'][] = $aComment; } return $aResult; }
public function __construct($aRequestPath) { parent::__construct($aRequestPath); $this->oJournalComment = JournalCommentQuery::create()->findHash(Manager::usePath()); $this->sAction = Manager::usePath(); }
/** * Returns a new JournalCommentQuery object. * * @param string $modelAlias The alias of a model in the query * @param JournalCommentQuery|Criteria $criteria Optional Criteria to build the query from * * @return JournalCommentQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof JournalCommentQuery) { return $criteria; } $query = new JournalCommentQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(JournalCommentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = JournalCommentQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // denyable behavior if (!(JournalCommentPeer::isIgnoringRights() || $this->mayOperate("delete"))) { throw new PropelException(new NotPermittedException("delete.by_role", array("role_key" => "journal_entries"))); } if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * renderRecentCommentsWidget() * * description: renders a comments teaser list * change limit count by overwriting the config param "recent_comments_limit" in your site/config/config.yml * @return Template object */ private function renderRecentCommentsWidget() { $oTemplate = $this->constructTemplate('widget_recent_comments'); $oItemPrototype = $this->constructTemplate('widget_recent_comment_item'); $iLimit = Settings::getSetting('journal', 'recent_comments_limit', 3); $oQuery = JournalCommentQuery::create()->excludeUnverified()->mostRecentFirst()->limit($iLimit)->useJournalEntryQuery()->filterByJournalId($this->aJournalIds)->endUse()->groupByJournalEntryId(); foreach ($oQuery->find() as $oComment) { $oCommentTemplate = clone $oItemPrototype; if ($oEntry = $oComment->getJournalEntry()) { $oCommentTemplate->replaceIdentifier('title', $oEntry->getTitle()); $oDetailLink = TagWriter::quickTag('a', array('rel' => 'internal', 'class' => 'read_more', 'href' => LinkUtil::link($oEntry->getLink($this->oPage)) . '#comments'), TranslationPeer::getString('journal_entry_teaser.read_more')); $oCommentTemplate->replaceIdentifier('link_to_detail', $oDetailLink); } $oCommentTemplate->replaceIdentifier('name', $oComment->getUsername()); $oCommentTemplate->replaceIdentifier('date', $oComment->getCreatedAtLocalized()); $oCommentTemplate->replaceIdentifier('text_stripped', StringUtil::truncate(strip_tags($oComment->getText()), 45)); $oCommentTemplate->replaceIdentifier('text', $oComment->getText()); $oTemplate->replaceIdentifierMultiple('comments', $oCommentTemplate); } return $oTemplate; }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this JournalEntry is new, it will return * an empty collection; or if this JournalEntry has previously * been saved, it will retrieve related JournalComments 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 JournalEntry. * * @param Criteria $criteria optional Criteria object to narrow the query * @param PropelPDO $con optional connection object * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return PropelObjectCollection|JournalComment[] List of JournalComment objects */ public function getJournalCommentsJoinUserRelatedByUpdatedBy($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $query = JournalCommentQuery::create(null, $criteria); $query->joinWith('UserRelatedByUpdatedBy', $join_behavior); return $this->getJournalComments($query, $con); }