public function setObjectId($iObjectId) { if ($this->oInternalWidget instanceof RichTextWidgetModule) { $oContentObject = ContentObjectQuery::create()->findPk($iObjectId); $oPage = PageQuery::create()->filterByContentObject($oContentObject)->findOne(); $this->oInternalWidget->setTemplate($oPage->getTemplateNameUsed()); } }
private function prepareContainerForReSort($sNewContainer, $iOldPosition, $iNewPosition) { $sNewContainer = self::normalizeContainerName($sNewContainer); $iDelta = $iNewPosition > $iOldPosition ? -1 : 1; $iMinPos = min($iOldPosition, $iNewPosition); $iMaxPos = max($iOldPosition, $iNewPosition); $oQuery = ContentObjectQuery::create()->orderBySort(); foreach ($oQuery->filterById($this->getId(), "<>")->filterByPageId($this->getPageId())->filterByContainerName($sNewContainer)->filterBySort($iMinPos, ">=")->filterBySort($iMaxPos, "<=")->find() as $oObject) { $oObject->setSort($oObject->getSort() + $iDelta); $oObject->save(); } }
public function preUp($manager) { require_once $_SERVER['PWD'] . '/base/lib/inc.php'; $iSort = 0; $sPrevContainer = null; $iPrevPageId = null; foreach (ContentObjectQuery::create()->orderByPageId()->orderByContainerName()->orderBySort()->find() as $oContentObject) { if ($oContentObject->getContainerName() !== $sPrevContainer || $oContentObject->getPageId() !== $iPrevPageId) { $iSort = 0; } $oContentObject->setSort($iSort++); $oContentObject->save(); $sPrevContainer = $oContentObject->getContainerName(); $iPrevPageId = $oContentObject->getPageId(); } }
public function saveData($aCondition) { $oContentObject = ContentObjectQuery::create()->findPk($this->iContentObjectId); $bHasCondition = false; if (trim($aCondition['condition_left']) === '') { $oContentObject->setConditionSerialized(null); } else { $oConditionTemplate = new Template('', null, true); $aTemplateContents = array(); $oIf = new TemplateIdentifier('if', $aCondition['comparison'], array(), $oConditionTemplate); $oIf->setParameter('1', $aCondition['condition_left']); $oIf->setParameter('2', $aCondition['condition_right']); $aTemplateContents[] = $oIf; $aTemplateContents[] = 'visible'; $aTemplateContents[] = new TemplateIdentifier('endIf', null, array(), $oConditionTemplate); $oConditionTemplate = new Template($aTemplateContents, null, true); $oContentObject->setConditionSerialized(serialize($oConditionTemplate)); $bHasCondition = true; } $oContentObject->save(); return $bHasCondition; }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Page is new, it will return * an empty collection; or if this Page has previously * been saved, it will retrieve related ContentObjects 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 Page. * * @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|ContentObject[] List of ContentObject objects */ public function getContentObjectsJoinUserRelatedByUpdatedBy($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $query = ContentObjectQuery::create(null, $criteria); $query->joinWith('UserRelatedByUpdatedBy', $join_behavior); return $this->getContentObjects($query, $con); }
/** * Get the associated ContentObject object * * @param PropelPDO $con Optional Connection object. * @param $doQuery Executes a query to get the object if required * @return ContentObject The associated ContentObject object. * @throws PropelException */ public function getContentObject(PropelPDO $con = null, $doQuery = true) { if ($this->aContentObject === null && $this->object_id !== null && $doQuery) { $this->aContentObject = ContentObjectQuery::create()->findPk($this->object_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->aContentObject->addLanguageObjectHistorys($this); */ } return $this->aContentObject; }
/** * 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(ContentObjectPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = ContentObjectQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // denyable behavior if (!(ContentObjectPeer::isIgnoringRights() || $this->mayOperate("delete"))) { throw new PropelException(new NotPermittedException("delete.backend_user", array("role_key" => "objects"))); } 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 adminMoveObject($iObjectId, $iSort, $sNewContainerName = null) { $iSort = (int) $iSort; $oContentObject = ContentObjectQuery::create()->findPk((int) $iObjectId); // fix if content object is deleted in trash, it is moved at the same time but not found anymore! if ($oContentObject === null) { return; } if ($sNewContainerName) { $oContentObject->sortIntoNew($sNewContainerName, $iSort); } else { $oContentObject->sortInsideExisting($iSort); } $oContentObject->save(); return $oContentObject->getId(); }