public function deleteTaggedItem($iTagId, $iTaggedItemId, $sModelName) { $oResult = new stdClass(); $oResult->removed = true; $oResult->model_removed = false; $oTagInstance = TagInstanceQuery::create()->findPk(array($iTagId, $iTaggedItemId, $sModelName)); if ($oTagInstance) { $sModelName = $oTagInstance->getModelName(); $oTagInstance->delete(); $oResult->model_removed = TagInstanceQuery::create()->filterByModelName($sModelName)->count() === 0; } return $oResult; }
protected static function hasTags() { return TagInstanceQuery::create()->filterByModelName('Link')->count() > 0; }
/** * @return All tags for the Page given by the id */ public static function tagsFor($sPageId = null, $sReturn = 'tag') { $oQuery = TagInstanceQuery::create(); if ($sPageId !== null) { $oQuery->filterByTaggedItemId($sPageId); } $oQuery->filterByModelName("Page"); if ($sReturn === 'count') { return $oQuery->find()->count(); } $aTagInstances = $oQuery->find()->getArrayCopy(); if ($sReturn === 'instances') { return $aTagInstances; } if ($sReturn === 'tags') { return array_map(function ($oTagInstance) { return $oTagInstance->getTag(); }, $aTagInstances); } return array_map(function ($oTagInstance) { return $oTagInstance->getTag()->getName(); }, $aTagInstances); }
/** * Returns a new TagInstanceQuery object. * * @param string $modelAlias The alias of a model in the query * @param TagInstanceQuery|Criteria $criteria Optional Criteria to build the query from * * @return TagInstanceQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof TagInstanceQuery) { return $criteria; } $query = new TagInstanceQuery(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(TagInstancePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = TagInstanceQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // denyable behavior if (!(TagInstancePeer::isIgnoringRights() || $this->mayOperate("delete"))) { throw new PropelException(new NotPermittedException("delete.custom", array("role_key" => "tag_instances"))); } if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
public function filterByTagName($sTagName) { $aTaggedItems = TagInstanceQuery::create()->filterByTagName($sTagName)->filterByModelName('Document')->select('TaggedItemId')->find(); $this->filterById($aTaggedItems, Criteria::IN); return $this; }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Tag is new, it will return * an empty collection; or if this Tag has previously * been saved, it will retrieve related TagInstances 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 Tag. * * @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|TagInstance[] List of TagInstance objects */ public function getTagInstancesJoinUserRelatedByUpdatedBy($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $query = TagInstanceQuery::create(null, $criteria); $query->joinWith('UserRelatedByUpdatedBy', $join_behavior); return $this->getTagInstances($query, $con); }
public function filterByTagId($aTagId) { $aTaggedLinkIds = TagInstanceQuery::create()->filterByTagId($aTagId)->filterByModelName('Link')->select(array('TaggedItemId'))->find(); return $this->filterById($aTaggedLinkIds, Criteria::IN); }
private static function hasTags() { return TagInstanceQuery::create()->filterByModelName('Document')->count() > 0; }
private function renderEntry(JournalEntry $oEntry, Template $oEntryTemplate, $bIsAjax = false) { $oCommentQuery = JournalCommentQuery::create()->excludeUnverified(); $oEntryTemplate->replaceIdentifier('journal_title', $oEntry->getJournal()->getName()); $oEntryTemplate->replaceIdentifier('slug', $oEntry->getSlug()); $oEntryTemplate->replaceIdentifier('name', $oEntry->getSlug()); $oEntryTemplate->replaceIdentifier('user_name', $oEntry->getUserRelatedByCreatedBy()->getFullName()); $oEntryTemplate->replaceIdentifier('id', $oEntry->getId()); $oEntryTemplate->replaceIdentifier('date', LocaleUtil::localizeDate($oEntry->getPublishAtTimestamp())); $oEntryTemplate->replaceIdentifier('title', $oEntry->getTitle()); $oEntryTemplate->replaceIdentifier('comment_count', $oEntry->countJournalComments($oCommentQuery)); // Manager in link has to be set manually for the case when it's called asynchroneously in preview $sDetailLink = LinkUtil::link($oEntry->getLink($this->oPage), $this->bIsPreview ? 'PreviewManager' : 'FrontendManager'); $oEntryTemplate->replaceIdentifier('link', LinkUtil::absoluteLink($sDetailLink), null, LinkUtil::isSSL()); $oEntryTemplate->replaceIdentifier('detail_link_title', TranslationPeer::getString('journal_entry.add_comment_title', null, null, array('title' => $oEntry->getTitle()))); if ($oEntryTemplate->hasIdentifier('text')) { $oEntryTemplate->replaceIdentifier('text', RichtextUtil::parseStorageForFrontendOutput($oEntry->getText())); } if ($oEntryTemplate->hasIdentifier('text_short')) { $oEntryTemplate->replaceIdentifier('text_short', RichtextUtil::parseStorageForFrontendOutput($oEntry->getTextShort())); } if ($this->oEntry !== null && $this->oEntry == $oEntry) { $oEntryTemplate->replaceIdentifier('current_class', ' class="current"', null, Template::NO_HTML_ESCAPE); } if ($oEntryTemplate->hasIdentifier('tags')) { $aTagInstances = TagInstanceQuery::create()->filterByModelName('JournalEntry')->filterByTaggedItemId($oEntry->getId())->joinTag()->find(); foreach ($aTagInstances as $i => $oTagInstance) { if ($i > 0) { $oEntryTemplate->replaceIdentifierMultiple('tags', ', ', null, Template::NO_NEWLINE | Template::NO_NEW_CONTEXT); } $oEntryTemplate->replaceIdentifierMultiple('tags', $oTagInstance->getTag()->getReadableName(), null, Template::NO_NEW_CONTEXT | Template::NO_NEWLINE); } } if ($oEntryTemplate->hasIdentifier('journal_comments')) { $oEntryTemplate->replaceIdentifier('journal_comments', $this->renderComments($oEntry->getJournalComments($oCommentQuery), $oEntry, $oEntry === $this->oEntry)); } if ($oEntryTemplate->hasIdentifier('journal_gallery') && $oEntry->countJournalEntryImages() > 0) { $oEntryTemplate->replaceIdentifier('journal_gallery', $this->renderGallery($oEntry)); } if ($this->bIsPreview && !$bIsAjax) { $oEntryTemplate = TagWriter::quickTag('div', array('class' => 'journal_entry-container filled-container', 'data-entry-id' => $oEntry->getId(), 'data-is-not-shown' => $oEntry->isNotShown(), 'data-template' => $oEntryTemplate->getTemplateName()), $oEntryTemplate); } return $oEntryTemplate; }
public static function getCategories($iBlogId, $sUserName, $sPassword) { if (!self::checkLogin($sUserName, $sPassword)) { return self::loginError(); } $aTags = array(); foreach (TagInstanceQuery::create()->filterByModelName('JournalEntry')->find() as $oTagInstance) { $sTagName = $oTagInstance->getTagName(); if (isset($aTags[$sTagName])) { $aTags[$sTagName]++; } else { $aTags[$sTagName] = 1; } } return array_keys($aTags); }