public function saveData($aTagData)
 {
     $aTagData['name'] = StringUtil::normalize($aTagData['name']);
     if ($this->iTagId === null) {
         $oTag = new Tag();
     } else {
         $oTag = TagQuery::create()->findPk($this->iTagId);
     }
     $this->validate($aTagData);
     if (!Flash::noErrors()) {
         throw new ValidationException();
     }
     $sStringName = "tag.{$aTagData['name']}";
     if ($oTag->getName() !== $aTagData['name']) {
         //Rename Strings for the tag
         $sOldStringName = "tag.{$oTag->getName()}";
         foreach (TranslationQuery::create()->filterByStringKey($sOldStringName)->find() as $oString) {
             $sLanguageId = $oString->getLanguageId();
             //You can’t technically rename strings because string_key is the PKEY so we delete it and re-generate
             $oString->delete();
             $oString = new Translation();
             $oString->setStringKey($sStringName);
             $oString->setLanguageId($sLanguageId);
             $oString->save();
         }
         $oTag->setName($aTagData['name']);
     }
     foreach ($aTagData['edited_languages'] as $iIndex => $sLanguageId) {
         TranslationPeer::addOrUpdateString($sStringName, $aTagData['text'][$iIndex], $sLanguageId);
     }
     $oTag->save();
 }
Example #2
0
 public function renderFrontend()
 {
     $aData = unserialize($this->getData());
     $oTemplate = new Template($aData['template']);
     $oItemTemplatePrototype = new Template($aData['template'] . '_item');
     $bItemFound = false;
     // FIXME: Keep track of output $oCorrespondingItems and refuse output if already done
     foreach ($aData['tags'] as $iTagID) {
         $oTag = TagQuery::create()->findPk($iTagID);
         if ($oTag === null) {
             continue;
         }
         $aCorrespondingItems = $oTag->getAllCorrespondingDataEntries($aData['types']);
         foreach ($aCorrespondingItems as $i => $oCorrespondingItem) {
             if (!method_exists($oCorrespondingItem, 'renderListItem')) {
                 return;
             }
             if (!$oCorrespondingItem->shouldBeIncludedInList(Session::language(), FrontendManager::$CURRENT_PAGE)) {
                 continue;
             }
             $bItemFound = true;
             $oItemTemplate = clone $oItemTemplatePrototype;
             $oItemTemplate->replaceIdentifier('model', get_class($oCorrespondingItem));
             $oItemTemplate->replaceIdentifier('counter', $i + 1);
             $oCorrespondingItem->renderListItem($oItemTemplate);
             $oTemplate->replaceIdentifierMultiple("items", $oItemTemplate);
         }
     }
     if (!$bItemFound) {
         return null;
     }
     return $oTemplate;
 }
Example #3
0
function getTag($tag_id)
{
    # Get tag object
    $tag_object = TagQuery::create()->findOneById($tag_id);
    # Return tag object
    return $tag_object;
}
Example #4
0
 public function tagId($sTagName)
 {
     $oTag = TagQuery::create()->filterByName($sTagName)->findOne();
     if ($oTag === null) {
         return null;
     }
     return $oTag->getId();
 }
Example #5
0
 public function getCriteria()
 {
     $oQuery = TagQuery::create();
     $aExcludes = array(CriteriaListWidgetDelegate::SELECT_ALL, 'Tag');
     if ($this->oDelegateProxy->getTagModelName() !== CriteriaListWidgetDelegate::SELECT_ALL) {
         $oQuery->distinct()->joinTagInstance()->useQuery('TagInstance')->filterByModelName($this->oDelegateProxy->getTagModelName())->endUse();
     }
     return $oQuery;
 }
 public static function getTagOptions()
 {
     $aResult = TagQuery::create()->filterByTagged('Document')->select(array('Id', 'Name'))->find()->toKeyValue('Id', 'Name');
     if (count($aResult) > 0 && !Settings::getSetting('admin', 'list_allows_multiple_categories', true)) {
         $aResult = array('' => ' ---- ') + $aResult;
     }
     if (count($aResult) === 0) {
         $aResult = array('' => TranslationPeer::getString('wns.document_list.no_tags_available'));
     }
     return $aResult;
 }
Example #7
0
function getLessonTags($lesson_id, $order_by = 'vote_count')
{
    # Get lesson object
    $lesson_object = getLesson($lesson_id);
    # Get lesson tags IDs
    $lesson_tags_ids = $lesson_object->getLessonTags()->getPrimaryKeys();
    # Get tag verse column to sort by
    $tag_verse_column_to_order_by = Propel::getDatabaseMap()->getTableByPhpName('TagVerse')->getColumnByPhpName('VerseId')->getFullyQualifiedName();
    # Get applicable tag objects
    $tags_objects = TagQuery::create()->useLessonTagQuery()->filterByPrimaryKeys($lesson_tags_ids)->endUse()->_if($order_by == 'vote_count')->orderByVoteCount()->_elseif($order_by == 'date_tagged')->orderById('DESC')->_endif()->joinWithTagVerse()->addAscendingOrderByColumn($tag_verse_column_to_order_by)->find();
    # Handle lesson tags objects
    $lesson_tags_to_return = [];
    foreach ($tags_objects as $tag_object) {
        # Append lesson tag to lesson tags to return
        $lesson_tags_to_return[] = ['id' => $tag_object->getId()];
    }
    # Return lesson tags
    return $lesson_tags_to_return;
}
Example #8
0
 /**
  * Remove tag from the Page given by the id
  */
 public static function removeTagFrom($sPageId, $mTag)
 {
     if (is_string($mTag)) {
         $mTag = TagQuery::create()->findOneByName($mTag);
     }
     if ($mTag instanceof TagInstance) {
         $mTag = $mTag->getTag();
     }
     if (!$mTag instanceof Tag) {
         return;
     }
     $oQuery = TagInstanceQuery::create();
     $oQuery->filterByTaggedItemId($sPageId);
     $oQuery->filterByModelName("Page");
     $oQuery->filterByTag($mTag);
     $oTagInstance = $oQuery->findOne();
     if ($oTagInstance) {
         $oTagInstance->delete();
     }
 }
Example #9
0
 public function getTagName()
 {
     if ($iTagId = $this->oDelegateProxy->getListSettings()->getFilterColumnValue('has_tags')) {
         return TagQuery::create()->filterById($iTagId)->select('Name')->findOne();
     }
     return null;
 }
Example #10
0
 /**
  * Get the associated Tag object
  *
  * @param PropelPDO $con Optional Connection object.
  * @param $doQuery Executes a query to get the object if required
  * @return Tag The associated Tag object.
  * @throws PropelException
  */
 public function getTag(PropelPDO $con = null, $doQuery = true)
 {
     if ($this->aTag === null && $this->tag_id !== null && $doQuery) {
         $this->aTag = TagQuery::create()->findPk($this->tag_id, $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->aTag->addTagInstances($this);
            */
     }
     return $this->aTag;
 }
Example #11
0
function find_tags_by_keyword($keyword, $tag_type_value = false)
{
    # Find keyword
    $keyword = find_keyword($keyword);
    # Find tag type
    if ($tag_type_value) {
        $tag_type = find_tag_type($tag_type_value);
    }
    # Find tags
    $tags = TagQuery::create()->filterByKeyword($keyword);
    if ($tag_type) {
        $tags->filterByType($tag_type);
    }
    $tags->find();
    # Return tag
    return $tags;
}
Example #12
0
<?php

require_once '../vendor/autoload.php';
require_once '../generated-conf/config.php';
$tag_object = TagQuery::create()->filterById(1)->findOne();
$tag_vote_object = new TagVote();
$tag_vote_object->setTag($tag_object)->save();
Example #13
0
 /**
  * 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(TagPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = TagQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         // denyable behavior
         if (!(TagPeer::isIgnoringRights() || $this->mayOperate("delete"))) {
             throw new PropelException(new NotPermittedException("delete.custom", array("role_key" => "tags")));
         }
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
Example #14
0
 public function listTags()
 {
     return TagQuery::create()->find()->toArray();
 }
Example #15
0
 public function getHasTags()
 {
     return TagQuery::create()->filterByTagged($this)->count() > 0;
 }
Example #16
0
 public function getCriteria()
 {
     return TagQuery::create()->filterByTagged($this->oTagList->getTaggedModelName());
 }
         <td><h3><?php echo __('Comments', null, 'sf_simple_blog') ?></h3></td>
       </tr>
       <tr>
         <td><?php echo sfSimpleBlogPostQuery::create()->count() ?> Posts</td>
         <td><?php echo $nbComments = sfNestedCommentQuery::create()->count() ?> Comments</td>
       </tr>
       <tr>
         <td><?php echo sfSimpleBlogPageQuery::create()->count() ?> Pages</td>
         <td><?php echo $nbApprovedComments = sfNestedCommentQuery::create()->approved()->count() ?> Approved</td>
       </tr>
       <tr>
         <td><?php echo sfSimpleBlogCategoryQuery::create()->count() ?> Categories</td>
         <td><?php echo $nbComments - $nbApprovedComments ?> Pending</td>
       </tr>
       <tr>
         <td><?php echo TagQuery::create()->count() ?> Tags</td>
       </tr>
     </tbody>
   </table>
 </div>
 <div class="box">
   <h2><?php echo __('Recent Comments', null, 'sf_simple_blog') ?></h2>
   <table>
     <tbody>
       <?php foreach ($recentComments as $i => $recentComment): ?>
         <tr>
           <td><?php echo $i+1 ?></td>
           <td>
             <h4><?php echo __('From ') ?><?php echo $recentComment->getAuthorName() ?><?php echo __(' on ') ?>"<?php echo $recentComment->getCommentableTitle() ?>"</h4>
             <?php $strippedComment = strip_tags($recentComment->getContent(ESC_RAW)) ?>
             <?php if (strlen($strippedComment) > 100): ?>
 /**
  * renderTagCloudWidget()
  *
  * description:
  * display tags with variable font-size, @see config.yml section journal tag_cloud [pixel_size_min, pixel_size_max]
  * @return Template object / null
  */
 private function renderTagCloudWidget()
 {
     // get all tags related to
     // • model JournalEntry
     // • active journal_enties with current journal_id
     $aIncludeJournalEntryIds = $this->createQuery()->filterByJournalId($this->aJournalIds)->select('Id')->find()->getData();
     $oTagQuery = TagQuery::create()->orderByName()->withTagInstanceCountFilteredByModel('JournalEntry', $aIncludeJournalEntryIds);
     $aTags = $oTagQuery->find()->toKeyValue('Name', 'TagInstanceCount');
     if (empty($aTags)) {
         return null;
     }
     // Configure display style of cloud
     $bUseSizes = false;
     $iMinPixelFontSize = null;
     $iMaxPixelFontSize = null;
     $aSizeParams = Settings::getSetting('journal', 'tag_cloud', null);
     if (isset($aSizeParams['pixel_size_min'])) {
         $iMinPixelFontSize = $aSizeParams['pixel_size_min'];
     }
     if (isset($aSizeParams['pixel_size_max'])) {
         $iMaxPixelFontSize = $aSizeParams['pixel_size_max'];
     }
     if ($iMinPixelFontSize !== null && $iMaxPixelFontSize !== null) {
         $bUseSizes = true;
     }
     // Calculate font sizes
     if ($bUseSizes) {
         $iMinCount = min($aTags);
         $iMaxCount = max($aTags);
         $iFactor = 1;
         if ($iMaxCount > $iMinCount) {
             $iFactor = $iMaxCount - $iMinCount;
         }
         $iPixelStep = ($iMaxPixelFontSize - $iMinPixelFontSize) / $iFactor;
     }
     // Render tags
     $oTemplate = $this->constructTemplate('widget_tag');
     if ($this->tagFilterIsActive()) {
         $sHref = LinkUtil::link($this->oNavigationItem->getLink(), null, array(self::RESET_TAGS => 'true'));
         $oTemplate->replaceIdentifier('reset_tags_href', $sHref, null, Template::NO_HTML_ESCAPE);
     }
     $oItemPrototype = $this->constructTemplate('widget_tag_item');
     foreach ($aTags as $sName => $iCount) {
         $oItemTemplate = clone $oItemPrototype;
         if ($bUseSizes) {
             $iFontSize = (int) ceil($iMinPixelFontSize + ($iCount - $iMinCount) * $iPixelStep);
             $oItemTemplate->replaceIdentifier('size_style', ' style="font-size:' . $iFontSize . 'px;line-height:' . ceil($iFontSize * 1.2) . 'px;"', null, Template::NO_HTML_ESCAPE);
         }
         if (is_array($this->aFilteredTags) && in_array($sName, $this->aFilteredTags)) {
             $oItemTemplate->replaceIdentifier('class_active', ' active');
             $oItemTemplate->replaceIdentifier('tag_link_title', TranslationPeer::getString('tag_link_title.remove'));
             $oItemTemplate->replaceIdentifier('tag_link', LinkUtil::link($this->oNavigationItem->getLink(), null, array(self::REMOVE_TAG => $sName)));
         } else {
             $oItemTemplate->replaceIdentifier('tag_link', LinkUtil::link($this->oNavigationItem->getLink(), null, array(self::ADD_TAG => $sName)));
             $oItemTemplate->replaceIdentifier('tag_link_title', TranslationPeer::getString('tag_link_title.add', null, null, array('tagname' => StringUtil::makeReadableName($sName)), true));
         }
         $oItemTemplate->replaceIdentifier('tag_name', ucfirst(TranslationPeer::getString('tag.' . $sName, null, $sName)));
         $oItemTemplate->replaceIdentifier('count_instances', $iCount);
         $oTemplate->replaceIdentifierMultiple('tag_item', $oItemTemplate);
     }
     return $oTemplate;
 }