예제 #1
0
 /**
  * @param  LoopResultRow         $loopResultRow
  * @param  \Thelia\Model\Content $content
  * @param $defaultFolderId
  * @return LoopResultRow
  */
 private function findNextPrev(LoopResultRow $loopResultRow, ContentModel $content, $defaultFolderId)
 {
     $isBackendContext = $this->getBackendContext();
     if ($this->getWithPrevNextInfo()) {
         // Find previous and next category
         $previousQuery = ContentQuery::create()->joinContentFolder()->where('ContentFolder.folder_id = ?', $defaultFolderId)->filterByPosition($content->getPosition(), Criteria::LESS_THAN);
         if (!$isBackendContext) {
             $previousQuery->filterByVisible(true);
         }
         $previous = $previousQuery->orderByPosition(Criteria::DESC)->findOne();
         $nextQuery = ContentQuery::create()->joinContentFolder()->where('ContentFolder.folder_id = ?', $defaultFolderId)->filterByPosition($content->getPosition(), Criteria::GREATER_THAN);
         if (!$isBackendContext) {
             $nextQuery->filterByVisible(true);
         }
         $next = $nextQuery->orderByPosition(Criteria::ASC)->findOne();
         $loopResultRow->set("HAS_PREVIOUS", $previous != null ? 1 : 0)->set("HAS_NEXT", $next != null ? 1 : 0)->set("PREVIOUS", $previous != null ? $previous->getId() : -1)->set("NEXT", $next != null ? $next->getId() : -1);
     }
     return $loopResultRow;
 }
 /**
  * Filter the query by a related \Thelia\Model\Content object
  *
  * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildCategoryAssociatedContentQuery The current query, for fluid interface
  */
 public function filterByContent($content, $comparison = null)
 {
     if ($content instanceof \Thelia\Model\Content) {
         return $this->addUsingAlias(CategoryAssociatedContentTableMap::CONTENT_ID, $content->getId(), $comparison);
     } elseif ($content instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(CategoryAssociatedContentTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByContent() only accepts arguments of type \\Thelia\\Model\\Content or Collection');
     }
 }
예제 #3
0
 /**
  * Declares an association between this object and a ChildContent object.
  *
  * @param                  ChildContent $v
  * @return                 \Thelia\Model\ProductAssociatedContent The current object (for fluent API support)
  * @throws PropelException
  */
 public function setContent(ChildContent $v = null)
 {
     if ($v === null) {
         $this->setContentId(NULL);
     } else {
         $this->setContentId($v->getId());
     }
     $this->aContent = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the ChildContent object, it will not be re-added.
     if ($v !== null) {
         $v->addProductAssociatedContent($this);
     }
     return $this;
 }
예제 #4
0
파일: Content.php 프로젝트: thelia/thelia
 /**
  * @param LoopResultRow $loopResultRow
  * @param ContentModel $content
  * @param int $defaultFolderId
  */
 private function findNextPrev(LoopResultRow $loopResultRow, ContentModel $content, $defaultFolderId)
 {
     if ($this->getWithPrevNextInfo()) {
         $currentPosition = ContentFolderQuery::create()->filterByFolderId($defaultFolderId)->filterByContentId($content->getId())->findOne()->getPosition();
         // Find previous and next content
         $previousQuery = ContentFolderQuery::create()->filterByFolderId($defaultFolderId)->filterByPosition($currentPosition, Criteria::LESS_THAN);
         $nextQuery = ContentFolderQuery::create()->filterByFolderId($defaultFolderId)->filterByPosition($currentPosition, Criteria::GREATER_THAN);
         if (!$this->getBackendContext()) {
             $previousQuery->useContentQuery()->filterByVisible(true)->endUse();
             $previousQuery->useContentQuery()->filterByVisible(true)->endUse();
         }
         $previous = $previousQuery->orderByPosition(Criteria::DESC)->findOne();
         $next = $nextQuery->orderByPosition(Criteria::ASC)->findOne();
         $loopResultRow->set("HAS_PREVIOUS", $previous != null ? 1 : 0)->set("HAS_NEXT", $next != null ? 1 : 0)->set("PREVIOUS", $previous != null ? $previous->getContentId() : -1)->set("NEXT", $next != null ? $next->getContentId() : -1);
     }
 }
예제 #5
0
파일: Content.php 프로젝트: badelas/thelia
 public function create(ContentCreateEvent $event)
 {
     $content = new ContentModel();
     $content->setVisible($event->getVisible())->setLocale($event->getLocale())->setTitle($event->getTitle())->create($event->getDefaultFolder());
     $event->setContent($content);
 }
예제 #6
0
 /**
  * generates a folder and its contents to be used in Position tests
  *
  * @return Folder the parent folder
  */
 protected function getFolderForPositionTest()
 {
     if (null === self::$folderForPositionTest) {
         $folder = new Folder();
         $folder->setParent(0);
         $folder->setVisible(1);
         $folder->setPosition(1);
         $this->setI18n($folder);
         $folder->save();
         for ($i = 0; $i < 4; $i++) {
             $content = new ContentModel();
             $content->setVisible(1);
             $content->addFolder($folder);
             $this->setI18n($content);
             $content->save();
         }
         self::$folderForPositionTest = $folder;
     }
     return self::$folderForPositionTest;
 }
예제 #7
0
 /**
  * Returns the object ID from the object
  *
  * @param Content $object
  *
  * @return int content id
  */
 protected function getObjectId($object)
 {
     return $object->getId();
 }
예제 #8
0
 /**
  * Exclude object from result
  *
  * @param   ChildContent $content Object to remove from the list of results
  *
  * @return ChildContentQuery The current query, for fluid interface
  */
 public function prune($content = null)
 {
     if ($content) {
         $this->addUsingAlias(ContentTableMap::ID, $content->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }