From c160eb2141dc55fc5a97c6ac0fb770ef30b15a75 Mon Sep 17 00:00:00 2001 From: TheCoreDev Date: Fri, 16 Apr 2021 19:23:51 +0200 Subject: [PATCH] =?UTF-8?q?On=20continue=20=C3=A0=20adapter=20le=20templat?= =?UTF-8?q?e...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backOffice/default/includes/cnc-main.html | 2 +- .../backOffice/default/js/cnc-main-js.html | 7 +- .../DigressivePrice/Loop/DigressiveLoop.php | 16 +- .../backOffice/default/includes/main.html | 2 +- local/modules/Recettes/Config/module.xml | 2 +- .../Selection/Action/SelectionAction.php | 275 ++ .../Action/SelectionContainerAction.php | 217 ++ local/modules/Selection/CHANGELOG.md | 48 + local/modules/Selection/Config/config.xml | 46 + local/modules/Selection/Config/destroy.sql | 0 local/modules/Selection/Config/module.xml | 32 + local/modules/Selection/Config/routing.xml | 209 ++ local/modules/Selection/Config/schema.xml | 132 + local/modules/Selection/Config/thelia.sql | 261 ++ .../modules/Selection/Config/update/.gitkeep | 0 .../Selection/Config/update/1.1.13.sql | 11 + .../modules/Selection/Config/update/1.1.5.sql | 111 + .../Controller/ImageUploadController.php | 523 +++ .../SelectionContainerUpdateController.php | 362 ++ .../Controller/SelectionController.php | 52 + .../SelectionRelatedContentController.php | 172 + .../SelectionRelatedProductController.php | 179 + .../Controller/SelectionUpdateController.php | 466 +++ .../Event/SelectionContainerEvent.php | 157 + .../Selection/Event/SelectionEvent.php | 213 ++ .../Selection/Event/SelectionEvents.php | 47 + .../Form/CreationCommonFieldsTrait.php | 85 + .../Form/SelectionContainerCreateForm.php | 48 + .../Form/SelectionContainerUpdateForm.php | 129 + .../Selection/Form/SelectionCreateForm.php | 52 + .../Form/SelectionImageModification.php | 13 + .../Selection/Form/SelectionUpdateForm.php | 193 ++ .../SelectioncontainerImageModification.php | 15 + local/modules/Selection/Hook/BackHook.php | 33 + .../I18n/backOffice/default/fr_FR.php | 75 + local/modules/Selection/I18n/en_US.php | 4 + local/modules/Selection/I18n/fr_FR.php | 13 + .../Selection/Loop/SelectionContainerLoop.php | 230 ++ .../Loop/SelectionContentRelated.php | 91 + .../modules/Selection/Loop/SelectionImage.php | 67 + .../modules/Selection/Loop/SelectionLoop.php | 231 ++ .../Selection/Loop/SelectionLoopCategory.php | 73 + .../Selection/Loop/SelectionLoopFolder.php | 71 + .../Loop/SelectionProductRelated.php | 102 + .../Selection/Model/Base/Selection.php | 3079 +++++++++++++++++ .../Model/Base/SelectionContainer.php | 2484 +++++++++++++ .../SelectionContainerAssociatedSelection.php | 1497 ++++++++ ...ctionContainerAssociatedSelectionQuery.php | 759 ++++ .../Model/Base/SelectionContainerI18n.php | 1616 +++++++++ .../Base/SelectionContainerI18nQuery.php | 706 ++++ .../Model/Base/SelectionContainerImage.php | 2066 +++++++++++ .../Base/SelectionContainerImageI18n.php | 1442 ++++++++ .../Base/SelectionContainerImageI18nQuery.php | 607 ++++ .../Base/SelectionContainerImageQuery.php | 891 +++++ .../Model/Base/SelectionContainerQuery.php | 886 +++++ .../Selection/Model/Base/SelectionContent.php | 1494 ++++++++ .../Model/Base/SelectionContentQuery.php | 774 +++++ .../Selection/Model/Base/SelectionI18n.php | 1616 +++++++++ .../Model/Base/SelectionI18nQuery.php | 706 ++++ .../Selection/Model/Base/SelectionImage.php | 2067 +++++++++++ .../Model/Base/SelectionImageI18n.php | 1442 ++++++++ .../Model/Base/SelectionImageI18nQuery.php | 607 ++++ .../Model/Base/SelectionImageQuery.php | 891 +++++ .../Selection/Model/Base/SelectionProduct.php | 1494 ++++++++ .../Model/Base/SelectionProductQuery.php | 774 +++++ .../Selection/Model/Base/SelectionQuery.php | 1040 ++++++ ...onContainerAssociatedSelectionTableMap.php | 445 +++ .../Map/SelectionContainerI18nTableMap.php | 522 +++ .../SelectionContainerImageI18nTableMap.php | 498 +++ .../Map/SelectionContainerImageTableMap.php | 480 +++ .../Model/Map/SelectionContainerTableMap.php | 467 +++ .../Model/Map/SelectionContentTableMap.php | 504 +++ .../Model/Map/SelectionI18nTableMap.php | 522 +++ .../Model/Map/SelectionImageI18nTableMap.php | 498 +++ .../Model/Map/SelectionImageTableMap.php | 484 +++ .../Model/Map/SelectionProductTableMap.php | 504 +++ .../Selection/Model/Map/SelectionTableMap.php | 475 +++ local/modules/Selection/Model/Selection.php | 80 + .../Selection/Model/SelectionContainer.php | 82 + .../SelectionContainerAssociatedSelection.php | 10 + ...ctionContainerAssociatedSelectionQuery.php | 21 + .../Model/SelectionContainerI18n.php | 10 + .../Model/SelectionContainerI18nQuery.php | 21 + .../Model/SelectionContainerImage.php | 121 + .../Model/SelectionContainerImageI18n.php | 10 + .../SelectionContainerImageI18nQuery.php | 21 + .../Model/SelectionContainerImageQuery.php | 21 + .../Model/SelectionContainerQuery.php | 52 + .../Selection/Model/SelectionContent.php | 10 + .../Selection/Model/SelectionContentQuery.php | 21 + .../modules/Selection/Model/SelectionI18n.php | 10 + .../Selection/Model/SelectionI18nQuery.php | 21 + .../Selection/Model/SelectionImage.php | 119 + .../Selection/Model/SelectionImageI18n.php | 10 + .../Model/SelectionImageI18nQuery.php | 21 + .../Selection/Model/SelectionImageQuery.php | 21 + .../Selection/Model/SelectionProduct.php | 20 + .../Selection/Model/SelectionProductQuery.php | 22 + .../Selection/Model/SelectionQuery.php | 22 + local/modules/Selection/Readme.md | 166 + local/modules/Selection/Selection.php | 95 + local/modules/Selection/composer.json | 11 + .../default/assets/style/selection-image.css | 12 + .../backOffice/default/container-edit.html | 153 + .../backOffice/default/container-view.html | 50 + .../default/image-upload-list-ajax.html | 64 + .../backOffice/default/image-upload.js | 259 ++ .../default/related/contentRelated.html | 16 + .../default/related/productRelated.html | 65 + .../backOffice/default/selection-edit.html | 324 ++ .../default/selection-image-edit.html | 135 + .../default/selection-list-containers.html | 156 + .../default/selection-list-containers.js | 35 + .../default/selection-list-selections.html | 166 + .../default/selection-list-selections.js | 35 + .../backOffice/default/selection-list.html | 51 + .../default/selectionContentRelated.html | 76 + .../default/selectionImageUpdate.html | 55 + .../default/selectionProductRelated.html | 81 + templates/frontOffice/custom/I18n/fr_FR.php | 3 + .../custom/assets/dist/css/custom.min.css | 2 +- .../custom/assets/src/css/custom.css | 43 + templates/frontOffice/custom/category.html | 8 +- .../custom/includes/single-product.html | 56 +- templates/frontOffice/custom/layout.tpl | 1 + .../HookNavigation}/main-navbar-primary.html | 4 + templates/frontOffice/custom/product.html | 24 +- 127 files changed, 42260 insertions(+), 36 deletions(-) create mode 100644 local/modules/Selection/Action/SelectionAction.php create mode 100644 local/modules/Selection/Action/SelectionContainerAction.php create mode 100644 local/modules/Selection/CHANGELOG.md create mode 100644 local/modules/Selection/Config/config.xml create mode 100644 local/modules/Selection/Config/destroy.sql create mode 100644 local/modules/Selection/Config/module.xml create mode 100644 local/modules/Selection/Config/routing.xml create mode 100644 local/modules/Selection/Config/schema.xml create mode 100644 local/modules/Selection/Config/thelia.sql create mode 100644 local/modules/Selection/Config/update/.gitkeep create mode 100644 local/modules/Selection/Config/update/1.1.13.sql create mode 100644 local/modules/Selection/Config/update/1.1.5.sql create mode 100644 local/modules/Selection/Controller/ImageUploadController.php create mode 100644 local/modules/Selection/Controller/SelectionContainerUpdateController.php create mode 100644 local/modules/Selection/Controller/SelectionController.php create mode 100644 local/modules/Selection/Controller/SelectionRelatedContentController.php create mode 100644 local/modules/Selection/Controller/SelectionRelatedProductController.php create mode 100644 local/modules/Selection/Controller/SelectionUpdateController.php create mode 100644 local/modules/Selection/Event/SelectionContainerEvent.php create mode 100644 local/modules/Selection/Event/SelectionEvent.php create mode 100644 local/modules/Selection/Event/SelectionEvents.php create mode 100644 local/modules/Selection/Form/CreationCommonFieldsTrait.php create mode 100644 local/modules/Selection/Form/SelectionContainerCreateForm.php create mode 100644 local/modules/Selection/Form/SelectionContainerUpdateForm.php create mode 100644 local/modules/Selection/Form/SelectionCreateForm.php create mode 100644 local/modules/Selection/Form/SelectionImageModification.php create mode 100644 local/modules/Selection/Form/SelectionUpdateForm.php create mode 100644 local/modules/Selection/Form/SelectioncontainerImageModification.php create mode 100644 local/modules/Selection/Hook/BackHook.php create mode 100644 local/modules/Selection/I18n/backOffice/default/fr_FR.php create mode 100644 local/modules/Selection/I18n/en_US.php create mode 100644 local/modules/Selection/I18n/fr_FR.php create mode 100644 local/modules/Selection/Loop/SelectionContainerLoop.php create mode 100644 local/modules/Selection/Loop/SelectionContentRelated.php create mode 100644 local/modules/Selection/Loop/SelectionImage.php create mode 100644 local/modules/Selection/Loop/SelectionLoop.php create mode 100644 local/modules/Selection/Loop/SelectionLoopCategory.php create mode 100644 local/modules/Selection/Loop/SelectionLoopFolder.php create mode 100644 local/modules/Selection/Loop/SelectionProductRelated.php create mode 100644 local/modules/Selection/Model/Base/Selection.php create mode 100644 local/modules/Selection/Model/Base/SelectionContainer.php create mode 100644 local/modules/Selection/Model/Base/SelectionContainerAssociatedSelection.php create mode 100644 local/modules/Selection/Model/Base/SelectionContainerAssociatedSelectionQuery.php create mode 100644 local/modules/Selection/Model/Base/SelectionContainerI18n.php create mode 100644 local/modules/Selection/Model/Base/SelectionContainerI18nQuery.php create mode 100644 local/modules/Selection/Model/Base/SelectionContainerImage.php create mode 100644 local/modules/Selection/Model/Base/SelectionContainerImageI18n.php create mode 100644 local/modules/Selection/Model/Base/SelectionContainerImageI18nQuery.php create mode 100644 local/modules/Selection/Model/Base/SelectionContainerImageQuery.php create mode 100644 local/modules/Selection/Model/Base/SelectionContainerQuery.php create mode 100644 local/modules/Selection/Model/Base/SelectionContent.php create mode 100644 local/modules/Selection/Model/Base/SelectionContentQuery.php create mode 100644 local/modules/Selection/Model/Base/SelectionI18n.php create mode 100644 local/modules/Selection/Model/Base/SelectionI18nQuery.php create mode 100644 local/modules/Selection/Model/Base/SelectionImage.php create mode 100644 local/modules/Selection/Model/Base/SelectionImageI18n.php create mode 100644 local/modules/Selection/Model/Base/SelectionImageI18nQuery.php create mode 100644 local/modules/Selection/Model/Base/SelectionImageQuery.php create mode 100644 local/modules/Selection/Model/Base/SelectionProduct.php create mode 100644 local/modules/Selection/Model/Base/SelectionProductQuery.php create mode 100644 local/modules/Selection/Model/Base/SelectionQuery.php create mode 100644 local/modules/Selection/Model/Map/SelectionContainerAssociatedSelectionTableMap.php create mode 100644 local/modules/Selection/Model/Map/SelectionContainerI18nTableMap.php create mode 100644 local/modules/Selection/Model/Map/SelectionContainerImageI18nTableMap.php create mode 100644 local/modules/Selection/Model/Map/SelectionContainerImageTableMap.php create mode 100644 local/modules/Selection/Model/Map/SelectionContainerTableMap.php create mode 100644 local/modules/Selection/Model/Map/SelectionContentTableMap.php create mode 100644 local/modules/Selection/Model/Map/SelectionI18nTableMap.php create mode 100644 local/modules/Selection/Model/Map/SelectionImageI18nTableMap.php create mode 100644 local/modules/Selection/Model/Map/SelectionImageTableMap.php create mode 100644 local/modules/Selection/Model/Map/SelectionProductTableMap.php create mode 100644 local/modules/Selection/Model/Map/SelectionTableMap.php create mode 100644 local/modules/Selection/Model/Selection.php create mode 100644 local/modules/Selection/Model/SelectionContainer.php create mode 100644 local/modules/Selection/Model/SelectionContainerAssociatedSelection.php create mode 100644 local/modules/Selection/Model/SelectionContainerAssociatedSelectionQuery.php create mode 100644 local/modules/Selection/Model/SelectionContainerI18n.php create mode 100644 local/modules/Selection/Model/SelectionContainerI18nQuery.php create mode 100644 local/modules/Selection/Model/SelectionContainerImage.php create mode 100644 local/modules/Selection/Model/SelectionContainerImageI18n.php create mode 100644 local/modules/Selection/Model/SelectionContainerImageI18nQuery.php create mode 100644 local/modules/Selection/Model/SelectionContainerImageQuery.php create mode 100644 local/modules/Selection/Model/SelectionContainerQuery.php create mode 100644 local/modules/Selection/Model/SelectionContent.php create mode 100644 local/modules/Selection/Model/SelectionContentQuery.php create mode 100644 local/modules/Selection/Model/SelectionI18n.php create mode 100644 local/modules/Selection/Model/SelectionI18nQuery.php create mode 100644 local/modules/Selection/Model/SelectionImage.php create mode 100644 local/modules/Selection/Model/SelectionImageI18n.php create mode 100644 local/modules/Selection/Model/SelectionImageI18nQuery.php create mode 100644 local/modules/Selection/Model/SelectionImageQuery.php create mode 100644 local/modules/Selection/Model/SelectionProduct.php create mode 100644 local/modules/Selection/Model/SelectionProductQuery.php create mode 100644 local/modules/Selection/Model/SelectionQuery.php create mode 100644 local/modules/Selection/Readme.md create mode 100644 local/modules/Selection/Selection.php create mode 100644 local/modules/Selection/composer.json create mode 100644 local/modules/Selection/templates/backOffice/default/assets/style/selection-image.css create mode 100644 local/modules/Selection/templates/backOffice/default/container-edit.html create mode 100644 local/modules/Selection/templates/backOffice/default/container-view.html create mode 100644 local/modules/Selection/templates/backOffice/default/image-upload-list-ajax.html create mode 100644 local/modules/Selection/templates/backOffice/default/image-upload.js create mode 100644 local/modules/Selection/templates/backOffice/default/related/contentRelated.html create mode 100644 local/modules/Selection/templates/backOffice/default/related/productRelated.html create mode 100644 local/modules/Selection/templates/backOffice/default/selection-edit.html create mode 100644 local/modules/Selection/templates/backOffice/default/selection-image-edit.html create mode 100644 local/modules/Selection/templates/backOffice/default/selection-list-containers.html create mode 100644 local/modules/Selection/templates/backOffice/default/selection-list-containers.js create mode 100644 local/modules/Selection/templates/backOffice/default/selection-list-selections.html create mode 100644 local/modules/Selection/templates/backOffice/default/selection-list-selections.js create mode 100644 local/modules/Selection/templates/backOffice/default/selection-list.html create mode 100644 local/modules/Selection/templates/backOffice/default/selectionContentRelated.html create mode 100644 local/modules/Selection/templates/backOffice/default/selectionImageUpdate.html create mode 100644 local/modules/Selection/templates/backOffice/default/selectionProductRelated.html rename {local/modules/HookNavigation/templates/frontOffice/custom => templates/frontOffice/custom/modules/HookNavigation}/main-navbar-primary.html (93%) diff --git a/local/modules/ClickAndCollect/templates/backOffice/default/includes/cnc-main.html b/local/modules/ClickAndCollect/templates/backOffice/default/includes/cnc-main.html index 17f83b8f..c6483afc 100644 --- a/local/modules/ClickAndCollect/templates/backOffice/default/includes/cnc-main.html +++ b/local/modules/ClickAndCollect/templates/backOffice/default/includes/cnc-main.html @@ -189,7 +189,7 @@
- +
diff --git a/local/modules/ClickAndCollect/templates/backOffice/default/js/cnc-main-js.html b/local/modules/ClickAndCollect/templates/backOffice/default/js/cnc-main-js.html index 2aa9ded9..4a4a0e76 100644 --- a/local/modules/ClickAndCollect/templates/backOffice/default/js/cnc-main-js.html +++ b/local/modules/ClickAndCollect/templates/backOffice/default/js/cnc-main-js.html @@ -5,6 +5,7 @@ function initMap() { + var opt = { center: new google.maps.LatLng($("#latitude").val(), $("#longitude").val()), zoom: 15, @@ -33,6 +34,7 @@ marker = new google.maps.Marker({ position: new google.maps.LatLng($("#latitude").val(), $("#longitude").val()), map: map, + draggable: true, title: $(document.getElementById("title")).val() }); } @@ -52,7 +54,8 @@ resultsMap.setCenter(results[0].geometry.location); marker = new google.maps.Marker({ map: resultsMap, - position: results[0].geometry.location + position: results[0].geometry.location, + draggable: true }); $("#latitude").val(results[0].geometry.location.lat); $("#longitude").val(results[0].geometry.location.lng); @@ -75,7 +78,7 @@ if (typeof(google) !== 'undefined') { if (typeof initMap === "function") initMap(); - } + } }); \ No newline at end of file diff --git a/local/modules/DigressivePrice/Loop/DigressiveLoop.php b/local/modules/DigressivePrice/Loop/DigressiveLoop.php index bd836687..4b6f6ff2 100644 --- a/local/modules/DigressivePrice/Loop/DigressiveLoop.php +++ b/local/modules/DigressivePrice/Loop/DigressiveLoop.php @@ -30,7 +30,8 @@ class DigressiveLoop extends BaseI18nLoop implements PropelSearchLoopInterface { return new ArgumentCollection( Argument::createIntTypeArgument('product_id'), - Argument::createIntTypeArgument('quantity') + Argument::createIntTypeArgument('quantity'), + Argument::createBooleanTypeArgument('order') ); } @@ -50,6 +51,19 @@ class DigressiveLoop extends BaseI18nLoop implements PropelSearchLoopInterface ; } + // TheCoreDev : rajout d'un tri sur la quantité + $order = $this->getOrder(); + if (!is_null($order)) { + switch ($order) { + case true : + $search->orderByQuantityFrom(); + break; + case false : + $search->orderByQuantityFrom(Criteria::DESC); + break; + } + } + return $search; } diff --git a/local/modules/PointRetrait/templates/backOffice/default/includes/main.html b/local/modules/PointRetrait/templates/backOffice/default/includes/main.html index 292fffa6..8ef281f9 100644 --- a/local/modules/PointRetrait/templates/backOffice/default/includes/main.html +++ b/local/modules/PointRetrait/templates/backOffice/default/includes/main.html @@ -185,7 +185,7 @@
- +
diff --git a/local/modules/Recettes/Config/module.xml b/local/modules/Recettes/Config/module.xml index 58c50b28..af5785fa 100644 --- a/local/modules/Recettes/Config/module.xml +++ b/local/modules/Recettes/Config/module.xml @@ -7,7 +7,7 @@ Esay way to display a recipe using Thelia's content feature - Permet de mettre ne page facilement une recette de cuisine via les contenus Thelia + Permet de mettre en page facilement une recette de cuisine via les contenus Thelia en_US diff --git a/local/modules/Selection/Action/SelectionAction.php b/local/modules/Selection/Action/SelectionAction.php new file mode 100644 index 00000000..8dd287f8 --- /dev/null +++ b/local/modules/Selection/Action/SelectionAction.php @@ -0,0 +1,275 @@ +createOrUpdate($event, new Selection()); + } + + /** + * @param SelectionEvent $event + * @throws \Exception + */ + public function update(SelectionEvent $event) + { + $model = $this->getSelection($event); + + $this->createOrUpdate($event, $model); + } + + /** + * @param UpdateSeoEvent $event + * @param $eventName + * @param EventDispatcherInterface $dispatcher + * @return mixed + */ + public function updateSeo( + UpdateSeoEvent $event, + /** @noinspection PhpUnusedParameterInspection */ + $eventName, + EventDispatcherInterface $dispatcher + ) { + return $this->genericUpdateSeo(SelectionQuery::create(), $event, $dispatcher); + } + + /** + * {@inheritDoc} + */ + public function getRewrittenUrlViewName() + { + return 'selection'; + } + + /** + * @param SelectionEvent $event + * @throws \Propel\Runtime\Exception\PropelException + */ + public function delete(SelectionEvent $event) + { + $this->getSelection($event)->delete(); + + RewritingUrlQuery::create() + ->filterByView($this->getRewrittenUrlViewName()) + ->filterByViewId($event->getId()) + ->update(array( + "View" => ConfigQuery::getObsoleteRewrittenUrlView() + )); + } + + protected function getSelection(SelectionEvent $event) + { + $model = SelectionQuery::create() + ->findPk($event->getId()); + + if (null === $model) { + throw new \RuntimeException(sprintf( + "Selection id '%d' doesn't exist", + $event->getId() + )); + } + return $model; + } + + /** + * @param SelectionEvent $event + * @param Selection $model + * @throws \Exception + */ + protected function createOrUpdate(SelectionEvent $event, Selection $model) + { + $con = Propel::getConnection(SelectionTableMap::DATABASE_NAME); + $con->beginTransaction(); + try { + if (null !== $locale = $event->getLocale()) { + $model->setLocale($locale); + } + if (null !== $id = $event->getId()) { + $model->setId($id); + } + + if (null !== $code = $event->getCode()) { + $model->setCode($code); + } + + if (null !== $title = $event->getTitle()) { + $model->setTitle($title); + } + + if (null !== $chapo = $event->getChapo()) { + $model->setChapo($chapo); + } + + if (null !== $description = $event->getDescription()) { + $model->setDescription($description); + } + + if (null !== $postscriptum = $event->getPostscriptum()) { + $model->setPostscriptum($postscriptum); + } + $model->save(); + + $event->setSelection($model); + + $this->updateContainerAssociatedToSelection($event, $con); + + $con->commit(); + } catch (\Exception $e) { + $con->rollBack(); + Tlog::getInstance()->error($e->getMessage()); + throw $e; + } + } + + /** + * @param SelectionEvent $event + * @param ConnectionInterface $con + * @throws \Propel\Runtime\Exception\PropelException + */ + protected function updateContainerAssociatedToSelection(SelectionEvent $event, ConnectionInterface $con) + { + $associationQuery = SelectionContainerAssociatedSelectionQuery::create(); + $association = $associationQuery->findOneBySelectionId($event->getId()); + $containerId = $event->getContainerId(); + if ($association === null) { + if (empty($containerId)) { + return; + } + $association = new SelectionContainerAssociatedSelection(); + $association->setSelectionId($event->getId()); + } else if ($association->getSelectionContainerId() === $containerId) { + return; + } else if (empty($containerId)) { + $association->delete($con); + return; + } + $association->setSelectionContainerId($containerId); + $association->save($con); + } + + /** + * @param SelectionEvent $event + * @throws \Propel\Runtime\Exception\PropelException + */ + public function toggleVisibility(SelectionEvent $event) + { + $selection = $event->getSelection(); + + $selection + ->setVisible($selection->getVisible() ? false : true) + ->save() + ; + + $event->setSelection($selection); + }/** @noinspection PhpUnusedParameterInspection */ + + /** + * Changes position, selecting absolute or relative change. + * + * @param UpdatePositionEvent $event + * @param $eventName + * @param EventDispatcherInterface $dispatcher + */ + public function updateProductPosition( + UpdatePositionEvent $event, + /** @noinspection PhpUnusedParameterInspection */ + $eventName, + /** @noinspection PhpUnusedParameterInspection */ + EventDispatcherInterface $dispatcher + ) { + $this->genericUpdateDelegatePosition( + SelectionProductQuery::create() + ->filterByProductId($event->getObjectId()) + ->filterBySelectionId($event->getReferrerId()), + $event + ); + } + + /** + * @param UpdatePositionEvent $event + * @param $eventName + * @param EventDispatcherInterface $dispatcher + */ + public function updatePosition( + UpdatePositionEvent $event, + /** @noinspection PhpUnusedParameterInspection */ + $eventName, + EventDispatcherInterface $dispatcher + ) { + $modelCriteria = SelectionQuery::create()->filterById($event->getObjectId()); + $this->genericUpdateDelegatePosition( + $modelCriteria, + $event, + $dispatcher + ); + } + + protected function genericUpdateDelegatePosition( + ModelCriteria $query, + UpdatePositionEvent $event, + EventDispatcherInterface $dispatcher = null + ) { + + if (null !== $object = $query->findOne()) { + if (!isset(class_uses($object)['Thelia\Model\Tools\PositionManagementTrait'])) { + throw new \InvalidArgumentException("Your model does not implement the PositionManagementTrait trait"); + } + + if (!is_null($dispatcher)) { + $object->setDispatcher($dispatcher); + } + + $mode = $event->getMode(); + + if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) { + $object->changeAbsolutePosition($event->getPosition()); + } elseif ($mode == UpdatePositionEvent::POSITION_UP) { + $object->movePositionUp(); + } elseif ($mode == UpdatePositionEvent::POSITION_DOWN) { + $object->movePositionDown(); + } + } + } + + public static function getSubscribedEvents() + { + return array( + SelectionEvents::SELECTION_CREATE => array("create", 128), + SelectionEvents::SELECTION_UPDATE => array("update", 128), + SelectionEvents::SELECTION_DELETE => array("delete", 128), + SelectionEvents::SELECTION_UPDATE_SEO => array("updateSeo", 128), + SelectionEvents::SELECTION_UPDATE_POSITION => array("updatePosition", 128), + SelectionEvents::SELECTION_TOGGLE_VISIBILITY => array("toggleVisibility", 128), + SelectionEvents::RELATED_PRODUCT_UPDATE_POSITION => array("updateProductPosition", 128), + ); + } +} diff --git a/local/modules/Selection/Action/SelectionContainerAction.php b/local/modules/Selection/Action/SelectionContainerAction.php new file mode 100644 index 00000000..7a18306e --- /dev/null +++ b/local/modules/Selection/Action/SelectionContainerAction.php @@ -0,0 +1,217 @@ +createOrUpdate($event, new SelectionContainer()); + } + + /** + * @param SelectionContainerEvent $event + * @throws \Exception + */ + public function update(SelectionContainerEvent $event) + { + $model = $this->getSelectionContainer($event); + + $this->createOrUpdate($event, $model); + } + + /** + * @param UpdateSeoEvent $event + * @param $eventName + * @param EventDispatcherInterface $dispatcher + * @return mixed + */ + public function updateSeo( + UpdateSeoEvent $event, + /** @noinspection PhpUnusedParameterInspection */ + $eventName, + EventDispatcherInterface $dispatcher + ) { + return $this->genericUpdateSeo(SelectionContainerQuery::create(), $event, $dispatcher); + } + + /** + * @param SelectionContainerEvent $event + * @throws \Propel\Runtime\Exception\PropelException + */ + public function delete(SelectionContainerEvent $event) + { + $this->getSelectionContainer($event)->delete(); + } + + protected function getSelectionContainer(SelectionContainerEvent $event) + { + $model = SelectionContainerQuery::create()->findPk($event->getId()); + + if (null === $model) { + throw new \RuntimeException(sprintf( + "SelectionContainer id '%d' doesn't exist", + $event->getId() + )); + } + return $model; + } + + /** + * @param SelectionContainerEvent $event + * @param SelectionContainer $model + * @throws \Exception + */ + protected function createOrUpdate(SelectionContainerEvent $event, SelectionContainer $model) + { + $con = Propel::getConnection(SelectionContainerTableMap::DATABASE_NAME); + $con->beginTransaction(); + try { + if (null !== $locale = $event->getLocale()) { + $model->setLocale($locale); + } + if (null !== $id = $event->getId()) { + $model->setId($id); + } + + if (null !== $code = $event->getCode()) { + $model->setCode($code); + } + + if (null !== $title = $event->getTitle()) { + $model->setTitle($title); + } + + if (null !== $chapo = $event->getChapo()) { + $model->setChapo($chapo); + } + + if (null !== $description = $event->getDescription()) { + $model->setDescription($description); + } + + if (null !== $postscriptum = $event->getPostscriptum()) { + $model->setPostscriptum($postscriptum); + } + $model->save(); + + $event->setSelectionContainer($model); + + $con->commit(); + } catch (\Exception $e) { + $con->rollBack(); + Tlog::getInstance()->error($e->getMessage()); + throw $e; + } + } + + /** + * @param SelectionContainerEvent $event + * @throws \Propel\Runtime\Exception\PropelException + */ + public function toggleVisibility(SelectionContainerEvent $event) + { + $selectionContainer = $event->getSelectionContainer(); + + $selectionContainer + ->setVisible($selectionContainer->getVisible() ? false : true) + ->save() + ; + + $event->setSelectionContainer($selectionContainer); + } + + + /** + * @param UpdatePositionEvent $event + * @param $eventName + * @param EventDispatcherInterface $dispatcher + */ + public function updatePosition( + UpdatePositionEvent $event, + /** @noinspection PhpUnusedParameterInspection */ + $eventName, + EventDispatcherInterface $dispatcher + ) { + $modelCriteria = SelectionContainerQuery::create()->filterById($event->getObjectId()); + $this->genericUpdateDelegatePosition( + $modelCriteria, + $event, + $dispatcher + ); + } + + /** + * @param ModelCriteria $query + * @param UpdatePositionEvent $event + * @param EventDispatcherInterface|null $dispatcher + */ + protected function genericUpdateDelegatePosition( + ModelCriteria $query, + UpdatePositionEvent $event, + EventDispatcherInterface $dispatcher = null + ) { + if (null !== $object = $query->findOne()) { + if (!isset(class_uses($object)['Thelia\Model\Tools\PositionManagementTrait'])) { + throw new \InvalidArgumentException("Your model does not implement the PositionManagementTrait trait"); + } + + if (!is_null($dispatcher)) { + $object->setDispatcher($dispatcher); + } + + $mode = $event->getMode(); + + if ($mode === UpdatePositionEvent::POSITION_ABSOLUTE) { + $object->changeAbsolutePosition($event->getPosition()); + } elseif ($mode === UpdatePositionEvent::POSITION_UP) { + $object->movePositionUp(); + } elseif ($mode === UpdatePositionEvent::POSITION_DOWN) { + $object->movePositionDown(); + } + } + } + + /** + * Returns an array of event names this subscriber wants to listen to. + * @return array The event names to listen to + */ + public static function getSubscribedEvents() + { + return array( + SelectionEvents::SELECTION_CONTAINER_CREATE => array("create", 128), + SelectionEvents::SELECTION_CONTAINER_UPDATE => array("update", 128), + SelectionEvents::SELECTION_CONTAINER_DELETE => array("delete", 128), + SelectionEvents::SELECTION_CONTAINER_UPDATE_SEO => array("updateSeo", 128), + SelectionEvents::SELECTION_CONTAINER_UPDATE_POSITION => array("updatePosition", 128), + SelectionEvents::SELECTION_CONTAINER_TOGGLE_VISIBILITY => array("toggleVisibility", 128), + ); + } +} diff --git a/local/modules/Selection/CHANGELOG.md b/local/modules/Selection/CHANGELOG.md new file mode 100644 index 00000000..88d241c7 --- /dev/null +++ b/local/modules/Selection/CHANGELOG.md @@ -0,0 +1,48 @@ +#Selection module changelog + +###1.1.9 +- Fixed title and language issues when editing a selection + +###1.1.8 +- Invisible products are not displayed anymore when editing a selection + +###1.1.7 +- Fixed rewritten urls not marked as obsolete on deletion + +###1.1.6 + - Fix products position update + +###1.1.4 + - #13 added missing update folder + +###1.1.3 +- #12 main loop wasn't returning meta infos + +###1.1.2 + - Fixed a duplication bug when displaying the selections in the back office + +###1.1.1 + - Added a 'SELECTION_URL' variable returned by the selection_list loop + +##1.1 + +- Cleaned a bit the code and added a few comments +- The 'title' parameter in the selection_list loop now actually works +- (#2) Added an exclude parameter to the selection_list loop +- (#3) Explained how to get the correct rewritten URL in the README +- (#4 & #7) The selection description can now be correctly called and displayed from the selection_list loop +- (#4) The selection chapo can now be correctly called and displayed from the selection_list loop +- (#4) The selection postscriptum can now be correctly called and displayed from the selection_list loop +- (#6) Added arrow buttons surrounding the products when editing a selection to change their position +- (#6) You can now change the position of a product in the list by clicking on it then choosing a new position. +- (#9) Rewrote the Readme with a better description and in a better english + +##1.0 +- Initial release + + + +##Contributors + +- Maxime Bruchet +- Luc Normandon diff --git a/local/modules/Selection/Config/config.xml b/local/modules/Selection/Config/config.xml new file mode 100644 index 00000000..af581fb8 --- /dev/null +++ b/local/modules/Selection/Config/config.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + %file_model.classes% + + + + + + + + + + + diff --git a/local/modules/Selection/Config/destroy.sql b/local/modules/Selection/Config/destroy.sql new file mode 100644 index 00000000..e69de29b diff --git a/local/modules/Selection/Config/module.xml b/local/modules/Selection/Config/module.xml new file mode 100644 index 00000000..1af3d191 --- /dev/null +++ b/local/modules/Selection/Config/module.xml @@ -0,0 +1,32 @@ + + + Selection\Selection + + Selection of product and/or content + + + Selection de produits et/ou de contenus + + + en_US + fr_FR + + 1.1.14 + + + Maxime BRUCHET + mbruchet@openstudio.fr + + + Franck Allimant + OpenStudio + fallimant@openstudio.fr + www.openstudio.fr + + + classic + 2.3.4 + other + diff --git a/local/modules/Selection/Config/routing.xml b/local/modules/Selection/Config/routing.xml new file mode 100644 index 00000000..8c0261c4 --- /dev/null +++ b/local/modules/Selection/Config/routing.xml @@ -0,0 +1,209 @@ + + + + + + + + + Selection\Controller\SelectionController::viewAction + + + + + + + Selection\Controller\SelectionUpdateController::updateAction + \d+ + + + + + Selection\Controller\SelectionRelatedProductController::getProductRelated + \d+ + + + + + Selection\Controller\SelectionRelatedContentController::getContentRelated + \d+ + + + + Selection\Controller\SelectionRelatedProductController::addProductRelated + \d+ + \d+ + + + + Selection\Controller\SelectionRelatedContentController::addContentRelated + \d+ + \d+ + + + + + Selection\Controller\SelectionRelatedProductController::showProduct + \d+ + + + + Selection\Controller\SelectionRelatedContentController::showContent + \d+ + + + + + Selection\Controller\SelectionUpdateController::processUpdateAction + + + + + Selection\Controller\SelectionUpdateController::createSelection + + + + + Selection\Controller\SelectionUpdateController::deleteAction + + + + + Selection\Controller\SelectionContainerUpdateController::createAction + + + + Selection\Controller\SelectionContainerUpdateController::processUpdateAction + + + + + Selection\Controller\SelectionContainerUpdateController::deleteAction + + + + + Selection\Controller\SelectionContainerUpdateController::viewAction + \d+ + + + + + Selection\Controller\SelectionContainerUpdateController::updateContainerAction + \d+ + + + + Selection\Controller\SelectionContainerUpdateController::updatePositionAction + + + + + Selection\Controller\SelectionContainerUpdateController::setToggleVisibilityAction + + + + + + + Selection\Controller\SelectionUpdateController::processUpdateSeoAction + + + + Selection\Controller\SelectionContainerUpdateController::processUpdateSeoAction + + + + + Selection\Controller\SelectionUpdateController::updatePositionAction + + + + + + Selection\Controller\ImageUploadController::getImageFormAjaxAction + .* + \d+ + + + + Selection\Controller\ImageUploadController::getImageListAjaxAction + .* + \d+ + + + + Selection\Controller\ImageUploadController::saveImageAjaxAction + .* + \d+ + + + + Selection\Controller\ImageUploadController::updateImageTitleAction + .* + \d+ + \d+ + + + + Selection\Controller\ImageUploadController::viewImageAction + .* + \d+ + + + + Selection\Controller\ImageUploadController::updateImageAction + .* + \d+ + + + + Selection\Controller\ImageUploadController::toggleVisibilityImageAction + .* + \d+ + \d+ + + + + Selection\Controller\ImageUploadController::deleteImageAction + .* + \d+ + \d+ + + + + Selection\Controller\ImageUploadController::updateImagePositionAction + .* + \d+ + + + + + + + + Selection\Controller\SelectionUpdateController::deleteRelatedProduct + \d+ + \d+ + + + Selection\Controller\SelectionUpdateController::deleteRelatedContent + \d+ + \d+ + + + + + + Selection\Controller\SelectionUpdateController::setToggleVisibilityAction + + + + Selection\Controller\SelectionUpdateController::updateSelectionPositionAction + + + + + diff --git a/local/modules/Selection/Config/schema.xml b/local/modules/Selection/Config/schema.xml new file mode 100644 index 00000000..4b94538d --- /dev/null +++ b/local/modules/Selection/Config/schema.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + +
diff --git a/local/modules/Selection/Config/thelia.sql b/local/modules/Selection/Config/thelia.sql new file mode 100644 index 00000000..808c036f --- /dev/null +++ b/local/modules/Selection/Config/thelia.sql @@ -0,0 +1,261 @@ + +# This is a fix for InnoDB in MySQL >= 4.1.x +# It "suspends judgement" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +-- --------------------------------------------------------------------- +-- selection +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `selection`; + +CREATE TABLE `selection` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `visible` TINYINT NOT NULL, + `code` VARCHAR(255), + `position` INTEGER, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`) +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- selection_product +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `selection_product`; + +CREATE TABLE `selection_product` +( + `selection_id` INTEGER NOT NULL, + `product_id` INTEGER NOT NULL, + `position` INTEGER NOT NULL, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`selection_id`,`product_id`), + INDEX `fi_selection_product_product_id` (`product_id`), + CONSTRAINT `fk_selection_product_product_id` + FOREIGN KEY (`product_id`) + REFERENCES `product` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE, + CONSTRAINT `fk_selection_product_selection_id` + FOREIGN KEY (`selection_id`) + REFERENCES `selection` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- selection_content +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `selection_content`; + +CREATE TABLE `selection_content` +( + `selection_id` INTEGER NOT NULL, + `content_id` INTEGER NOT NULL, + `position` INTEGER, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`selection_id`,`content_id`), + INDEX `fi_selection_content_content_id` (`content_id`), + CONSTRAINT `fk_selection_content_content_id` + FOREIGN KEY (`content_id`) + REFERENCES `content` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE, + CONSTRAINT `fk_selection_content_selection_id` + FOREIGN KEY (`selection_id`) + REFERENCES `selection` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- selection_image +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `selection_image`; + +CREATE TABLE `selection_image` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `selection_id` INTEGER NOT NULL, + `file` VARCHAR(255) NOT NULL, + `visible` TINYINT DEFAULT 1 NOT NULL, + `position` INTEGER, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `fi_selection_image_selection_id` (`selection_id`), + CONSTRAINT `fk_selection_image_selection_id` + FOREIGN KEY (`selection_id`) + REFERENCES `selection` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- selection_container +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `selection_container`; + +CREATE TABLE `selection_container` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `visible` TINYINT NOT NULL, + `code` VARCHAR(255), + `position` INTEGER, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`) +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- selection_container_associated_selection +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `selection_container_associated_selection`; + +CREATE TABLE `selection_container_associated_selection` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `selection_container_id` INTEGER NOT NULL, + `selection_id` INTEGER NOT NULL, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `idx_selection_container_associated_selection_container_id` (`selection_container_id`), + INDEX `idx_selection_container_associated_selection_id` (`selection_id`), + CONSTRAINT `selection_container_associated_selection_container_id` + FOREIGN KEY (`selection_container_id`) + REFERENCES `selection_container` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE, + CONSTRAINT `selection_container_associated_selection_selection_id` + FOREIGN KEY (`selection_id`) + REFERENCES `selection` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- selection_container_image +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `selection_container_image`; + +CREATE TABLE `selection_container_image` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `selection_container_id` INTEGER NOT NULL, + `file` VARCHAR(255) NOT NULL, + `visible` TINYINT DEFAULT 1 NOT NULL, + `position` INTEGER, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `fi_selection_container_image_selection_id` (`selection_container_id`), + CONSTRAINT `fk_selection_container_image_selection_id` + FOREIGN KEY (`selection_container_id`) + REFERENCES `selection_container` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- selection_i18n +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `selection_i18n`; + +CREATE TABLE `selection_i18n` +( + `id` INTEGER NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `title` VARCHAR(255), + `description` TEXT, + `chapo` TEXT, + `postscriptum` TEXT, + `meta_title` VARCHAR(255), + `meta_description` TEXT, + `meta_keywords` TEXT, + PRIMARY KEY (`id`,`locale`), + CONSTRAINT `selection_i18n_fk_765b89` + FOREIGN KEY (`id`) + REFERENCES `selection` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- selection_image_i18n +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `selection_image_i18n`; + +CREATE TABLE `selection_image_i18n` +( + `id` INTEGER NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `title` VARCHAR(255), + `description` LONGTEXT, + `chapo` TEXT, + `postscriptum` TEXT, + PRIMARY KEY (`id`,`locale`), + CONSTRAINT `selection_image_i18n_fk_d501a8` + FOREIGN KEY (`id`) + REFERENCES `selection_image` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- selection_container_i18n +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `selection_container_i18n`; + +CREATE TABLE `selection_container_i18n` +( + `id` INTEGER NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `title` VARCHAR(255), + `description` TEXT, + `chapo` TEXT, + `postscriptum` TEXT, + `meta_title` VARCHAR(255), + `meta_description` TEXT, + `meta_keywords` TEXT, + PRIMARY KEY (`id`,`locale`), + CONSTRAINT `selection_container_i18n_fk_25b287` + FOREIGN KEY (`id`) + REFERENCES `selection_container` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- selection_container_image_i18n +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `selection_container_image_i18n`; + +CREATE TABLE `selection_container_image_i18n` +( + `id` INTEGER NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `title` VARCHAR(255), + `description` LONGTEXT, + `chapo` TEXT, + `postscriptum` TEXT, + PRIMARY KEY (`id`,`locale`), + CONSTRAINT `selection_container_image_i18n_fk_eed190` + FOREIGN KEY (`id`) + REFERENCES `selection_container_image` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; diff --git a/local/modules/Selection/Config/update/.gitkeep b/local/modules/Selection/Config/update/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/local/modules/Selection/Config/update/1.1.13.sql b/local/modules/Selection/Config/update/1.1.13.sql new file mode 100644 index 00000000..9b8db583 --- /dev/null +++ b/local/modules/Selection/Config/update/1.1.13.sql @@ -0,0 +1,11 @@ +SET FOREIGN_KEY_CHECKS = 0; + +-- Add the 'code' column to the selection tables. +ALTER TABLE `selection` ADD `code` varchar(255) NOT NULL AFTER `visible`; +ALTER TABLE `selection_container` ADD `code` varchar(255) NOT NULL AFTER `visible`; + +-- Generate a pseudo-code for each existing selection +UPDATE `selection` set `code` = CONCAT('selection_', id); +UPDATE `selection_container` set `code` = CONCAT('container_', id); + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/local/modules/Selection/Config/update/1.1.5.sql b/local/modules/Selection/Config/update/1.1.5.sql new file mode 100644 index 00000000..b932cf61 --- /dev/null +++ b/local/modules/Selection/Config/update/1.1.5.sql @@ -0,0 +1,111 @@ +ALTER TABLE selection_i18n MODIFY description LONGTEXT; +ALTER TABLE selection_i18n MODIFY chapo LONGTEXT; +ALTER TABLE selection_i18n MODIFY postscriptum LONGTEXT; + +-- --------------------------------------------------------------------- +-- selection_container +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `selection_container` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `visible` TINYINT NOT NULL, + `position` INTEGER, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`) +) ENGINE = InnoDB; + +-- --------------------------------------------------------------------- +-- selection_container_associated_selection +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `selection_container_associated_selection` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `selection_container_id` INTEGER NOT NULL, + `selection_id` INTEGER NOT NULL, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `idx_selection_container_associated_selection_container_id`( `selection_container_id` +), +INDEX `idx_selection_container_associated_selection_id` (`selection_id` +), +CONSTRAINT `selection_container_associated_selection_container_id` +FOREIGN KEY (`selection_container_id` +) +REFERENCES `selection_container` (`id` +) +ON UPDATE RESTRICT +ON DELETE CASCADE, +CONSTRAINT `selection_container_associated_selection_selection_id` +FOREIGN KEY (`selection_id`) +REFERENCES `selection` (`id`) +ON UPDATE RESTRICT +ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- selection_container_i18n +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `selection_container_i18n` +( + `id` INTEGER NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `title` VARCHAR(255), + `description` TEXT, + `chapo` TEXT, + `postscriptum` TEXT, + `meta_title` VARCHAR(255), + `meta_description` TEXT, + `meta_keywords` TEXT, + PRIMARY KEY (`id`, `locale`), + CONSTRAINT `selection_container_i18n_FK_1` + FOREIGN KEY (`id`) + REFERENCES `selection_container` (`id`) + ON DELETE CASCADE +) ENGINE = InnoDB; + + + +-- --------------------------------------------------------------------- +-- selection_container_image +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS`selection_container_image` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `selection_container_id` INTEGER NOT NULL, + `file` VARCHAR(255) NOT NULL, + `visible` TINYINT DEFAULT 1 NOT NULL, + `position` INTEGER, + `created_at` DATETIME, + `updated_at` DATETIME, + PRIMARY KEY (`id`), + INDEX `FI_selection_container_image_selection_id` (`selection_container_id`), +CONSTRAINT `fk_selection_container_image_selection_id` +FOREIGN KEY (`selection_container_id`) +REFERENCES `selection_container` (`id`) +ON UPDATE RESTRICT +ON DELETE CASCADE +) ENGINE=InnoDB; + + +-- --------------------------------------------------------------------- +-- selection_container_image_i18n +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `selection_container_image_i18n` +( + `id` INTEGER NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `title` VARCHAR(255), + `description` LONGTEXT, + `chapo` TEXT, + `postscriptum` TEXT, + PRIMARY KEY (`id`,`locale`), + CONSTRAINT `selection_container_image_i18n_FK_1` + FOREIGN KEY (`id`) + REFERENCES `selection_container_image` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; diff --git a/local/modules/Selection/Controller/ImageUploadController.php b/local/modules/Selection/Controller/ImageUploadController.php new file mode 100644 index 00000000..8610508f --- /dev/null +++ b/local/modules/Selection/Controller/ImageUploadController.php @@ -0,0 +1,523 @@ +addModuleResource($parentType); + $this->registerFileModel($parentType); + $this->checkAccessForType(AccessManager::UPDATE, $parentType); + $this->checkXmlHttpRequest(); + $args = array('imageType' => $parentType, 'parentId' => $parentId); + return $this->render('image-upload-list-ajax', $args); + } + + /** + * @inheritdoc + * @throws \Exception + */ + public function getImageFormAjaxAction($parentId, $parentType) + { + $this->addModuleResource($parentType); + $this->registerFileModel($parentType); + $this->checkAccessForType(AccessManager::UPDATE, $parentType); + $this->checkXmlHttpRequest(); + $args = array('imageType' => $parentType, 'parentId' => $parentId); + return $this->render('selectionImageUpdate', $args); + } + + /** + * @param $imageId + * @param $parentType + * @return mixed|\Symfony\Component\HttpFoundation\Response + * @throws \Exception + */ + public function updateImageTitleAction($imageId, $parentType) + { + $this->addModuleResource($parentType); + $parentId = $this->getRequest()->get('parentId'); + $this->registerFileModel($parentType); + if (null !== $response = $this->checkAccessForType(AccessManager::UPDATE, $parentType)) { + return $response; + } + + $fileManager = $this->getFileManager(); + + $fileModelInstance = $fileManager->getModelInstance('image', $parentType); + /** @var FileModelInterface $file */ + $file = $fileModelInstance->getQueryInstance()->findPk($imageId); + + $new_title = $this->getRequest()->request->get('title'); + $locale = $this->getRequest()->request->get('locale'); + + if (!empty($new_title)) { + $file->setLocale($locale); + $file->setTitle($new_title); + $file->save(); + } + return $this->getImagetTypeUpdateRedirectionUrl($parentType, $parentId); + } + + /** + * @param int $fileId + * @param string $parentType + * @param string $objectType + * @param string $eventName + * @return \Symfony\Component\HttpFoundation\Response|Response + * @throws \Exception + */ + public function deleteFileAction($fileId, $parentType, $objectType, $eventName) + { + $message = null; + $this->addModuleResource($parentType); + $parentId = $this->getRequest()->get('parentId'); + $this->registerFileModel($parentType); + $this->checkAccessForType(AccessManager::UPDATE, $parentType); + $this->checkXmlHttpRequest(); + $fileManager = $this->getFileManager(); + $modelInstance = $fileManager->getModelInstance($objectType, $parentType); + $model = $modelInstance->getQueryInstance()->findPk($fileId); + if ($model == null) { + return $this->pageNotFound(); + } + // Feed event + $fileDeleteEvent = new FileDeleteEvent($model); + // Dispatch Event to the Action + try { + $this->dispatch($eventName, $fileDeleteEvent); + $this->adminUpadteLogAppend( + $parentType, + $this->getTranslator()->trans( + 'Deleting %obj% for %id% with parent id %parentId%', + array( + '%obj%' => $objectType, + '%id%' => $fileDeleteEvent->getFileToDelete()->getId(), + '%parentId%' => $fileDeleteEvent->getFileToDelete()->getParentId(), + ) + ), + $fileDeleteEvent->getFileToDelete()->getId() + ); + } catch (\Exception $e) { + $message = $this->getTranslator()->trans( + 'Fail to delete %obj% for %id% with parent id %parentId% (Exception : %e%)', + array( + '%obj%' => $objectType, + '%id%' => $fileDeleteEvent->getFileToDelete()->getId(), + '%parentId%' => $fileDeleteEvent->getFileToDelete()->getParentId(), + '%e%' => $e->getMessage() + ) + ); + } + if (null === $message) { + $message = $this->getTranslator()->trans( + '%obj%s deleted successfully', + ['%obj%' => ucfirst($objectType)], + Selection::DOMAIN_NAME + ); + } + $this->adminUpadteLogAppend($parentType, $message, $fileDeleteEvent->getFileToDelete()->getId()); + return $this->getImagetTypeUpdateRedirectionUrl($parentType, $parentId); + } + + /*----------------- My parts */ + + /** + * @param int $parentId + * @param string $parentType + * @param string $objectType + * @param array $validMimeTypes + * @param array $extBlackList + * @return mixed|\Symfony\Component\HttpFoundation\Response|Response|ResponseRest + * @throws \Exception + */ + public function saveFileAjaxAction( + $parentId, + $parentType, + $objectType, + $validMimeTypes = array(), + $extBlackList = array() + ) { + $this->addModuleResource($parentType); + $this->registerFileModel($parentType); + if (null !== $response = $this->checkAccessForType(AccessManager::UPDATE, $parentType)) { + return $response; + } + $this->checkXmlHttpRequest(); + if ($this->getRequest()->isMethod('POST')) { + /** @var UploadedFile $fileBeingUploaded */ + $fileBeingUploaded = $this->getRequest()->files->get('file'); + try { + if (null !== $fileBeingUploaded) { + $this->processFile( + $fileBeingUploaded, + $parentId, + $parentType, + $objectType, + $validMimeTypes, + $extBlackList + ); + } + } catch (ProcessFileException $e) { + return new ResponseRest($e->getMessage(), 'text', $e->getCode()); + } + return $this->getImagetTypeUpdateRedirectionUrl($parentType, $parentId); + } + + return new Response('', 404); + } + + /** + * @param int $imageId + * @param string $parentType + * @return mixed|Response + * @throws \Exception + */ + public function viewImageAction($imageId, $parentType) + { + $this->addModuleResource($parentType); + $this->registerFileModel($parentType); + if (null !== $response = $this->checkAccessForType(AccessManager::UPDATE, $parentType)) { + return $response; + } + $fileManager = $this->getFileManager(); + $imageModel = $fileManager->getModelInstance('image', $parentType); + $image = null; + $parentId = null; + if (SelectionContainer::IMAGE_TYPE_LABEL === $parentType) { + $image = SelectionContainerImageQuery::create()->findPk($imageId); + if ($image !== null) { + $parentId = $image->getSelectionContainerId(); + } + } else { + $image = SelectionImageQuery::create()->findPk($imageId); + if ($image !== null) { + $parentId = $image->getSelectionId(); + } + } + if ($image === null) { + return $this->pageNotFound(); + } + $redirectUrl = $this->getImagetTypeUpdateRedirectionUrl($parentType, $parentId); + return $this->render('selection-image-edit', array( + 'imageId' => $imageId, + 'imageType' => $parentType, + 'redirectUrl' => $redirectUrl, + 'formId' => $imageModel->getUpdateFormId(), + 'breadcrumb' => $image->getBreadcrumb( + $this->getRouter($this->getCurrentRouter()), + $this->container, + 'images', + $this->getCurrentEditionLocale() + ) + )); + } + + /** + * @param int $fileId + * @param string $parentType + * @param string $objectType + * @param string $eventName + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function updateFileAction($fileId, $parentType, $objectType, $eventName) + { + $message = false; + $fileManager = $this->getFileManager(); + $fileModelInstance = $fileManager->getModelInstance($objectType, $parentType); + $fileUpdateForm = $this->createForm($fileModelInstance->getUpdateFormId()); + + /** @var FileModelInterface $file */ + $file = $fileModelInstance->getQueryInstance()->findPk($fileId); + + try { + $oldFile = clone $file; + + if (null === $file) { + throw new \InvalidArgumentException(sprintf('%d %s id does not exist', $fileId, $objectType)); + } + + $data = $this->validateForm($fileUpdateForm)->getData(); + + $event = new FileCreateOrUpdateEvent(null); + + if (array_key_exists('visible', $data)) { + $file->setVisible($data['visible'] ? 1 : 0); + } + + $file->setLocale($data['locale']); + + if (array_key_exists('title', $data)) { + $file->setTitle($data['title']); + } + if (array_key_exists('chapo', $data)) { + $file->setChapo($data['chapo']); + } + if (array_key_exists('description', $data)) { + $file->setDescription($data['description']); + } + if (array_key_exists('postscriptum', $data)) { + $file->setPostscriptum($data['postscriptum']); + } + + if (isset($data['file'])) { + $file->setFile($data['file']); + } + + $event->setModel($file); + $event->setOldModel($oldFile); + + $files = $this->getRequest()->files; + + $fileForm = $files->get($fileUpdateForm->getName()); + + if (isset($fileForm['file'])) { + $event->setUploadedFile($fileForm['file']); + } + + $this->dispatch($eventName, $event); + + $fileUpdated = $event->getModel(); + + $this->adminUpadteLogAppend( + $parentType, + sprintf( + '%s with Ref %s (ID %d) modified', + ucfirst($objectType), + $fileUpdated->getTitle(), + $fileUpdated->getId() + ), + $fileUpdated->getId() + ); + } catch (FormValidationException $e) { + $message = sprintf('Please check your input: %s', $e->getMessage()); + } catch (\Exception $e) { + $message = sprintf('Sorry, an error occurred: %s', $e->getMessage() . ' ' . $e->getFile()); + } + + if ($message !== false) { + Tlog::getInstance()->error(sprintf('Error during %s editing : %s.', $objectType, $message)); + + $fileUpdateForm->setErrorMessage($message); + + $this->getParserContext() + ->addForm($fileUpdateForm) + ->setGeneralError($message); + } + if ($this->getRequest()->get('save_mode') === 'close') { + return $this->generateRedirect( + URL::getInstance()->absoluteUrl($file->getRedirectionUrl(), ['current_tab' => 'images']) + ); + } + return $this->generateSuccessRedirect($fileUpdateForm); + } + + /** + * @param int $imageId + * @param string $parentType + * @return mixed|Response|FileModelInterface + * @throws \Exception + */ + public function updateImageAction($imageId, $parentType) + { + $this->addModuleResource($parentType); + if (null !== $response = $this->checkAccessForType(AccessManager::UPDATE, $parentType)) { + return $response; + } + $this->registerFileModel($parentType); + return $this->updateFileAction($imageId, $parentType, 'image', TheliaEvents::IMAGE_UPDATE); + } + + /** + * @param $documentId + * @param string $parentType + * @param string $objectType + * @param string $eventName + * @return \Symfony\Component\HttpFoundation\Response|Response + * @throws \Exception + */ + public function toggleVisibilityFileAction($documentId, $parentType, $objectType, $eventName) + { + $message = null; + $this->addModuleResource($parentType); + $parentId = $this->getRequest()->get('parentId'); + $this->registerFileModel($parentType); + $this->checkAccessForType(AccessManager::UPDATE, $parentType); + $this->checkXmlHttpRequest(); + $fileManager = $this->getFileManager(); + $modelInstance = $fileManager->getModelInstance($objectType, $parentType); + $model = $modelInstance->getQueryInstance()->findPk($documentId); + if ($model === null) { + return $this->pageNotFound(); + } + + // Feed event + $event = new FileToggleVisibilityEvent( + $modelInstance->getQueryInstance(), + $documentId + ); + + // Dispatch Event to the Action + try { + $this->dispatch($eventName, $event); + } catch (\Exception $e) { + $message = $this->getTranslator()->trans( + 'Fail to update %type% visibility: %err%', + ['%type%' => $objectType, '%err%' => $e->getMessage()] + ); + } + + if (null === $message) { + $message = $this->getTranslator()->trans( + '%type% visibility updated', + ['%type%' => ucfirst($objectType)] + ); + } + $this->adminUpadteLogAppend($parentType, $message, $documentId); + return $this->generateRedirectFromRoute('selection.update', [], ['selectionId' => $parentId], null); + } + + /** + * @param $parentType + * @param $parentId + * @param $objectType + * @param $eventName + * @return Response + * @throws \Exception + */ + public function updateFilePositionAction($parentType, $parentId, $objectType, $eventName) + { + $message = null; + $this->addModuleResource($parentType); + $this->registerFileModel($parentType); + $position = $this->getRequest()->request->get('position'); + + $this->checkAccessForType(AccessManager::UPDATE, $parentType); + $this->checkXmlHttpRequest(); + + $fileManager = $this->getFileManager(); + $modelInstance = $fileManager->getModelInstance($objectType, $parentType); + $model = $modelInstance->getQueryInstance()->findPk($parentId); + + if ($model === null || $position === null) { + return $this->pageNotFound(); + } + + // Feed event + $event = new UpdateFilePositionEvent( + $modelInstance->getQueryInstance(), + $parentId, + UpdateFilePositionEvent::POSITION_ABSOLUTE, + $position + ); + + // Dispatch Event to the Action + try { + $this->dispatch($eventName, $event); + } catch (\Exception $e) { + $message = $this->getTranslator()->trans( + 'Fail to update %type% position: %err%', + ['%type%' => $objectType, '%err%' => $e->getMessage()] + ); + } + + if (null === $message) { + $message = $this->getTranslator()->trans( + '%type% position updated', + ['%type%' => ucfirst($objectType)] + ); + } + + return new Response($message); + } + + /** + * @param string $type + * @param $message string + * @param string|null $resourceId + */ + protected function adminUpadteLogAppend($type, $message, $resourceId = null) + { + $this->adminLogAppend( + $this->getAdminResources()->getResource($type, ucfirst(Selection::DOMAIN_NAME)), + AccessManager::UPDATE, + $message, + $resourceId + ); + } + + /** + * @param string $type + * @throws \Exception + */ + protected function addModuleResource($type) + { + $data = [strtoupper($type) => "admin.selection"]; + $module = ucfirst(Selection::DOMAIN_NAME); + /** @noinspection PhpParamsInspection */ + $this->getAdminResources()->addModuleResources($data, $module); + } + + /** + * @param string $access + * @param string $type + * @return mixed null if authorization is granted, or a Response object which contains the error page otherwise + */ + protected function checkAccessForType($access, $type) + { + return $this->checkAuth( + $this->getAdminResources()->getResource($type, ucfirst(Selection::DOMAIN_NAME)), + array(), + $access + ); + } + + /** + * @param string $type + */ + private function registerFileModel($type) + { + $this->getFileManager()->addFileModel( + 'image', + $type, + $type === 'SelectionContainer' ? SelectionContainerImage::class : SelectionImage::class + ); + } + + private function getImagetTypeUpdateRedirectionUrl($parentType, $parentId) + { + if ($parentType === SelectionContainer::IMAGE_TYPE_LABEL) { + return $this->generateRedirectFromRoute('admin.selection.container.update', [], ['selectionContainerId' => $parentId, 'current_tab' => 'images'], null); + } + return $this->generateRedirectFromRoute('selection.update', [], ['selectionId' => $parentId, 'current_tab' => 'images'], null); + } +} diff --git a/local/modules/Selection/Controller/SelectionContainerUpdateController.php b/local/modules/Selection/Controller/SelectionContainerUpdateController.php new file mode 100644 index 00000000..903fba1f --- /dev/null +++ b/local/modules/Selection/Controller/SelectionContainerUpdateController.php @@ -0,0 +1,362 @@ +createForm('admin.selection.container.create'); + } + + /** + * Return the update form for this object + * @param array $data + * @return BaseForm + */ + protected function getUpdateForm($data = []) + { + if (!is_array($data)) { + $data = array(); + } + + return $this->createForm('admin.selection.container.update', 'form', $data); + } + + /** + * Hydrate the update form for this object, before passing it to the update template + * @param SelectionContainer $object + * @return BaseForm + */ + protected function hydrateObjectForm($object) + { + $this->hydrateSeoForm($object); + $data = array( + 'selection_container_id'=> $object->getId(), + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + 'selection_container_code' => $object->getCode(), + 'selection_container_chapo' => $object->getChapo(), + 'selection_container_title' => $object->getTitle(), + 'selection_container_description' => $object->getDescription(), + 'selection_container_postscriptum' => $object->getPostscriptum(), + 'current_id' => $object->getId(), + ); + + return $this->getUpdateForm($data); + } + + /** + * Creates the creation event with the provided form data + * @param mixed $formData + * @return \Thelia\Core\Event\ActionEvent + */ + protected function getCreationEvent($formData) + { + $event = new SelectionContainerEvent(); + + $event->setTitle($formData['title']); + $event->setCode($formData['code']); + $event->setChapo($formData['chapo']); + $event->setDescription($formData['description']); + $event->setPostscriptum($formData['postscriptum']); + $event->setLocale($this->getCurrentEditionLocale()); + + return $event; + } + + /** + * Creates the update event with the provided form data + * @param mixed $formData + * @return \Thelia\Core\Event\ActionEvent + */ + protected function getUpdateEvent($formData) + { + $selectionContainer = SelectionContainerQuery::create()->findPk($formData['selection_container_id']); + $event = new SelectionContainerEvent($selectionContainer); + + $event->setId($formData['selection_container_id']); + $event->setCode($formData['selection_container_code']); + $event->setTitle($formData['selection_container_title']); + $event->setChapo($formData['selection_container_chapo']); + $event->setDescription($formData['selection_container_description']); + $event->setPostscriptum($formData['selection_container_postscriptum']); + $event->setLocale($this->getCurrentEditionLocale()); + return $event; + } + + /** + * Creates the delete event with the provided form data + * @return \Thelia\Core\Event\ActionEvent + */ + protected function getDeleteEvent() + { + $event = new SelectionContainerEvent(); + $selectionId = $this->getRequest()->request->get('selection_container_id'); + $event->setId($selectionId); + return $event; + } + + /** + * Return true if the event contains the object, e.g. the action has updated the object in the event. + * @param SelectionContainerEvent $event + * @return bool + */ + protected function eventContainsObject($event) + { + return $event->hasSelection(); + } + + /** + * Get the created object from an event. + * @param SelectionContainerEvent $event + * @return SelectionContainer + */ + protected function getObjectFromEvent($event) + { + return $event->getSelectionContainer(); + } + + /** + * Load an existing object from the database + */ + protected function getExistingObject() + { + $selectionContainer = SelectionContainerQuery::create() + ->findPk($this->getRequest()->get('selection_container_id', 0)); + if (null !== $selectionContainer) { + $selectionContainer->setLocale($this->getCurrentEditionLocale()); + } + + return $selectionContainer; + } + + /** + * Returns the object label form the object event (name, title, etc.) + * @param SelectionContainer|null $object + * @return string + */ + protected function getObjectLabel($object) + { + return empty($object) ? '' : $object->getTitle(); + } + + /** + * Returns the object ID from the object + * @param SelectionContainer|null $object + * @return int + */ + protected function getObjectId($object) + { + return $object->getId(); + } + + /** + * Render the main list template + * @param mixed $currentOrder , if any, null otherwise. + * @return \Thelia\Core\HttpFoundation\Response + */ + protected function renderListTemplate($currentOrder) + { + return $this->render( + 'selection-list', + ['order' => $currentOrder] + ); + } + + /** + * Render the edition template + * @return \Thelia\Core\HttpFoundation\Response + */ + protected function renderEditionTemplate() + { + $selectionContainerId = $this->getRequest()->get('selection_container_id'); + $currentTab = $this->getRequest()->get('current_tab'); + return $this->render( + "container-edit", + [ + 'selection_container_id' => $selectionContainerId, + 'current_tab' => $currentTab + ] + ); + } + + /** + * Must return a RedirectResponse instance + * @return RedirectResponse + */ + protected function redirectToEditionTemplate() + { + $id = $this->getRequest()->get('selection_container_id'); + + return new RedirectResponse( + URL::getInstance()->absoluteUrl( + "/admin/selection/container/update/".$id + ) + ); + } + + /** + * Must return a RedirectResponse instance + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ + protected function redirectToListTemplate() + { + return new RedirectResponse( + URL::getInstance()->absoluteUrl("/admin/selection") + ); + } + + /** + * Online status toggle + */ + public function setToggleVisibilityAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) { + return $response; + } + + $event = new SelectionContainerEvent($this->getExistingObject()); + + try { + $this->dispatch(SelectionEvents::SELECTION_CONTAINER_TOGGLE_VISIBILITY, $event); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + + // Ajax response -> no action + return $this->nullResponse(); + } + + public function createSelectionContainerAction() + { + $form = new SelectionCreateForm($this->getRequest()); + try { + $validForm = $this->validateForm($form); + $data = $validForm->getData(); + $title = $data['title']; + $chapo = $data['chapo']; + $description = $data['description']; + $postscriptum = $data['postscriptum']; + $date = new \DateTime(); + + $selectionContainer = new SelectionContainer(); + $lastSelection = SelectionContainerQuery::create()->orderByPosition(Criteria::DESC)->findOne(); + if (null !== $lastSelection) { + $position = $lastSelection->getPosition() + 1; + } else { + $position = 1; + } + $selectionContainer + ->setCreatedAt($date->format('Y-m-d H:i:s')) + ->setUpdatedAt($date->format('Y-m-d H:i:s')) + ->setVisible(1) + ->setPosition($position) + ->setLocale($this->getCurrentEditionLocale()) + ->setTitle($title) + ->setChapo($chapo) + ->setDescription($description) + ->setPostscriptum($postscriptum); + $selectionContainer->save(); + + return $this->generateRedirect("/admin/selection"); + } catch (FormValidationException $ex) { + // Form cannot be validated + $error_msg = $this->createStandardFormValidationErrorMessage($ex); + } catch (\Exception $ex) { + // Any other error + $error_msg = $ex->getMessage(); + } + + if (false !== $error_msg) { + $this->setupFormErrorContext( + $this->getTranslator()->trans("%obj creation", ['%obj' => $this->objectName]), + $error_msg, + $form, + $ex + ); + // At this point, the form has error, and should be redisplayed. + return $this->renderList(); + } + } + + /** + * Show the default template : selectionList + * display selections inide the container + * @param $selectionContainerId + * @return \Thelia\Core\HttpFoundation\Response + */ + public function viewAction($selectionContainerId) + { + $this->getRequest()->request->set("selectionContainerId", $selectionContainerId); + $selectionContainer = $this->getExistingObject(); + if (!is_null($selectionContainer)) { + $changeForm = $this->hydrateObjectForm($selectionContainer); + $this->getParserContext()->addForm($changeForm); + } + return $this->render("container-view", + array( + 'selected_container_id' => $selectionContainerId + )); + } + + /** + * @param $selectionContainerId + * @return \Thelia\Core\HttpFoundation\Response + */ + public function updateContainerAction($selectionContainerId) + { + $this->getRequest()->request->set("selection_container_id", $selectionContainerId); + return parent::updateAction(); + } + + public function processUpdateSeoAction() + { + $selectionContainerId = $this->getRequest()->get('current_id'); + $this->getRequest()->request->set("selection_container_id", $selectionContainerId); + return parent::processUpdateSeoAction(); + } +} diff --git a/local/modules/Selection/Controller/SelectionController.php b/local/modules/Selection/Controller/SelectionController.php new file mode 100644 index 00000000..f7b02c9f --- /dev/null +++ b/local/modules/Selection/Controller/SelectionController.php @@ -0,0 +1,52 @@ +render( + "selection-list", + [ + 'selection_order' => $this->getAttributeSelectionOrder(), + 'selection_container_order' => $this->getAttributeContainerOrder() + ] + ); + } + + private function getAttributeSelectionOrder() + { + return $this->getListOrderFromSession( + 'selection', + 'selection_order', + 'manual' + ); + } + + private function getAttributeContainerOrder() + { + return $this->getListOrderFromSession( + 'selectioncontainer', + 'selection_container_order', + 'manual' + ); + } + + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) + { + return new UpdatePositionEvent( + $this->getRequest()->get('selection_id', null), + $positionChangeMode, + $positionValue + ); + } +} diff --git a/local/modules/Selection/Controller/SelectionRelatedContentController.php b/local/modules/Selection/Controller/SelectionRelatedContentController.php new file mode 100644 index 00000000..363485ba --- /dev/null +++ b/local/modules/Selection/Controller/SelectionRelatedContentController.php @@ -0,0 +1,172 @@ +getRequest()->get('folderID'); + + $contentCategory = ContentFolderQuery::create(); + $lang = $this->getRequest()->getSession()->get('thelia.current.lang'); + + $result = array(); + + if ($folderId !== null) { + $contentCategory->filterByFolderId($folderId)->find(); + + if ($contentCategory !== null) { + /** @var ContentFolder $item */ + foreach ($contentCategory as $item) { + $content = ContentQuery::create() + ->filterById($item->getContentId()) + ->findOne(); + + $result[] = + [ + 'id' => $content->getId(), + 'title' => $content->getTranslation($lang->getLocale())->getTitle() + ]; + } + } + } + return $this->jsonResponse(json_encode($result)); + } + + /** + * Add content to current selection + * + * @return \Thelia\Core\HttpFoundation\Response + * @throws \Propel\Runtime\Exception\PropelException + */ + public function addContentRelated() + { + $contentId = $this->getRequest()->get('contentID'); + $selectionID = $this->getRequest()->get('selectionID'); + + $contentRelated = new SelectionContent(); + + if ($contentId !== null) { + $SelectionContent = SelectionContentQuery::create() + ->filterBySelectionId($selectionID) + ->filterByContentId($contentId) + ->findOne(); + + if (is_null($SelectionContent)) { + $contentRelated->setSelectionId($selectionID); + $contentRelated->setContentId($contentId); + + $position = SelectionContentQuery::create() + ->filterBySelectionId($selectionID) + ->orderByPosition(Criteria::DESC) + ->select('position') + ->findOne(); + if (null === $position) { + $contentRelated->setPosition(1); + } else { + $contentRelated->setPosition($position+1); + } + $contentRelated->save(); + } + + $lang = $this->getRequest()->getSession()->get('thelia.current.lang'); + + $search = ContentQuery::create(); + $selectionContentRelated = new Join( + ContentTableMap::ID, + SelectionContentTableMap::CONTENT_ID, + Criteria::INNER_JOIN + ); + + $search->addJoinObject($selectionContentRelated, 'selectionContentRelated'); + $search->addJoinCondition( + 'selectionContentRelated', + SelectionContentTableMap::SELECTION_ID.'='.$selectionID + ); + $search->find(); + + /** @var Content $row */ + foreach ($search as $row) { + $selectionContentPos = SelectionContentQuery::create() + ->filterBySelectionId($selectionID) + ->filterByContentId($row->getId()) + ->findOne(); + + $result = [ + 'id' => $row->getId() , + 'title' => $row->getTranslation($lang->getLocale())->getTitle(), + 'position' => $selectionContentPos->getPosition() + ]; + } + } + return $this->render('related/contentRelated', ['selection_id' => $selectionID]); + } + + /** + * Show content related to a selection + * + * @param null $p + * @return array|\Thelia\Core\HttpFoundation\Response + * @throws \Propel\Runtime\Exception\PropelException + */ + public function showContent($p = null) + { + $selectionID = $this->getRequest()->get('selectionID'); + $lang = $this->getRequest()->getSession()->get('thelia.current.lang'); + + $search = ContentQuery::create(); + $selectionContentRelated = new Join( + ContentTableMap::ID, + SelectionContentTableMap::CONTENT_ID, + Criteria::INNER_JOIN + ); + + $search->addJoinObject($selectionContentRelated, 'selectionContentRelated'); + $search->addJoinCondition( + 'selectionContentRelated', + SelectionContentTableMap::SELECTION_ID.'='.$selectionID + ); + $search->find(); + + /** @var Content $row */ + foreach ($search as $row) { + $selectionContentPos = SelectionContentQuery::create() + ->filterBySelectionId($selectionID) + ->filterByContentId($row->getId()) + ->findOne(); + + $result = [ + 'id' => $row->getId() , + 'title' => $row->getTranslation($lang->getLocale())->getTitle(), + 'position' => $selectionContentPos->getPosition() + ]; + } + + if ($p === null) { + return $this->render('related/contentRelated', ['selection_id' => $selectionID]); + } else { + return $result; + } + } +} diff --git a/local/modules/Selection/Controller/SelectionRelatedProductController.php b/local/modules/Selection/Controller/SelectionRelatedProductController.php new file mode 100644 index 00000000..db4d4c0c --- /dev/null +++ b/local/modules/Selection/Controller/SelectionRelatedProductController.php @@ -0,0 +1,179 @@ +getRequest()->get('categoryID'); + + $lang = $this->getRequest()->getSession()->get('thelia.current.lang'); + $productCategory = ProductCategoryQuery::create(); + + $result = array(); + + if ($categoryID !== null) { + $productCategory->filterByCategoryId($categoryID) + ->find(); + if ($productCategory !== null) { + /** @var ProductCategory $item */ + foreach ($productCategory as $item) { + $product = ProductQuery::create() + ->filterById($item->getProductId()) + ->filterByVisible(1) + ->findOne(); + + if (null !== $product) { + $result[] = [ + 'id' => $product->getId(), + 'title' => $product->getTranslation($lang->getLocale())->getTitle() + ]; + } + } + } + } + return $this->jsonResponse(json_encode($result)); + } + + /** + * Add product to the current selection + * + * @return \Thelia\Core\HttpFoundation\Response + * @throws \Propel\Runtime\Exception\PropelException + */ + public function addProductRelated() + { + $productID = $this->getRequest()->get('productID'); + $selectionID = $this->getRequest()->get('selectionID'); + $lang = $this->getRequest()->getSession()->get('thelia.current.lang'); + + $productRelated = new SelectionProduct(); + + + if ($productID !== null) { + $SelectionProduit = SelectionProductQuery::create() + ->filterByProductId($productID) + ->filterBySelectionId($selectionID) + ->findOne(); + + if (is_null($SelectionProduit)) { + //Insert in the table Selection_product + $productRelated->setSelectionId($selectionID); + $productRelated->setProductId($productID); + + $position = SelectionProductQuery::create() + ->filterBySelectionId($selectionID) + ->orderByPosition(Criteria::DESC) + ->select('position') + ->findOne(); + + if (null === $position) { + $productRelated->setPosition(1); + } else { + $productRelated->setPosition($position + 1); + } + $productRelated->save(); + } + /** @var \Thelia\Model\Product $search */ + /** @var LoopExtendsBuildModelCriteriaEvent $event */ + $search = ProductQuery::create(); + $selectionProductRelated = new Join( + ProductTableMap::ID, + SelectionProductTableMap::PRODUCT_ID, + Criteria::INNER_JOIN + ); + $search->addJoinObject($selectionProductRelated, 'selectionProductRelated'); + $search->addJoinCondition( + 'selectionProductRelated', + SelectionProductTableMap::SELECTION_ID.' = '.$selectionID + ); + $search->find(); + + $result = array(); + /** @var Product $row */ + foreach ($search as $row) { + $selectionProductPos = SelectionProductQuery::create() + ->filterBySelectionId($selectionID) + ->filterByProductId($row->getId()) + ->findOne(); + + $result = [ + 'id' => $row->getId() , + 'title' => $row->getTranslation($lang->getLocale())->getTitle(), + 'position' => $selectionProductPos->getPosition(), + ]; + } + } + return $this->render('related/productRelated', ['selection_id' => $selectionID]); + } + + /** + * Show product related to a selection + * + * @param null $p + * @return array|\Thelia\Core\HttpFoundation\Response + * @throws \Propel\Runtime\Exception\PropelException + */ + public function showProduct($p = null) + { + + $selectionID = $this->getRequest()->get('selectionID'); + $lang = $this->getRequest()->getSession()->get('thelia.current.lang'); + + /** @var \Thelia\Model\Product $search */ + /** @var LoopExtendsBuildModelCriteriaEvent $event */ + $search = ProductQuery::create(); + $selectionProductRelated = new Join( + ProductTableMap::ID, + SelectionProductTableMap::PRODUCT_ID, + Criteria::INNER_JOIN + ); + $search->addJoinObject($selectionProductRelated, 'selectionProductRelated'); + $search->addJoinCondition( + 'selectionProductRelated', + SelectionProductTableMap::SELECTION_ID.' = '.$selectionID + ); + $search->find(); + + $result = array(); + /** @var Product $row */ + foreach ($search as $row) { + $selectionProductPos = SelectionProductQuery::create() + ->filterBySelectionId($selectionID) + ->filterByProductId($row->getId()) + ->findOne(); + + $result = [ + 'id' => $row->getId() , + 'title' => $row->getTranslation($lang->getLocale())->getTitle(), + 'position' => $selectionProductPos->getPosition(), + ]; + } + + if ($p === null) { + return $this->render('related/productRelated', ['selection_id' => $selectionID]); + } else { + return $result; + } + } +} diff --git a/local/modules/Selection/Controller/SelectionUpdateController.php b/local/modules/Selection/Controller/SelectionUpdateController.php new file mode 100644 index 00000000..3851d5dd --- /dev/null +++ b/local/modules/Selection/Controller/SelectionUpdateController.php @@ -0,0 +1,466 @@ +getRequest()); + + $validForm = $this->validateForm($form); + $data = $validForm->getData(); + + $selectionID = $data['selection_id']; + $selectionCode = $data['selection_code']; + $selectionTitle = $data['selection_title']; + $selectionChapo = $data['selection_chapo']; + $selectionDescription = $data['selection_description']; + $selectionPostscriptum = $data['selection_postscriptum']; + + $aSelection = SelectionQuery::create()->findPk($selectionID); + + $aSelection + ->setCode($selectionCode) + ->setLocale($this->getCurrentEditionLocale()) + ->setTitle($selectionTitle) + ->setChapo($selectionChapo) + ->setDescription($selectionDescription) + ->setPostscriptum($selectionPostscriptum) + ->save(); + + if ($validForm->get('save_and_close')->isClicked()) { + return $this->render("electionlist"); + } + + return $this->generateRedirectFromRoute('selection.update', [], ['selectionId' => $selectionID], null); + } + + public function createSelection() + { + $form = new SelectionCreateForm($this->getRequest()); + try { + $validForm = $this->validateForm($form); + $data = $validForm->getData(); + $code = $data['code']; + $title = $data['title']; + $chapo = $data['chapo']; + $description = $data['description']; + $postscriptum = $data['postscriptum']; + $containerId = (int) $data['container_id']; + $date = new \DateTime(); + $selection = new SelectionModel(); + + $lastSelectionQuery = SelectionQuery::create()->orderByPosition(Criteria::DESC); + + if ($containerId > 0) { + $lastSelectionQuery + ->useSelectionContainerAssociatedSelectionQuery('toto', Criteria::LEFT_JOIN) + ->filterBySelectionContainerId($containerId) + ->endUse(); + } + + $position = 1; + + if (null !== $lastSelection = $lastSelectionQuery->findOne()) { + $position = $lastSelection->getPosition() + 1; + } + + $selection + ->setCreatedAt($date->format('Y-m-d H:i:s')) + ->setUpdatedAt($date->format('Y-m-d H:i:s')) + ->setVisible(1) + ->setCode($code) + ->setPosition($position) + ->setLocale($this->getCurrentEditionLocale()) + ->setTitle($title) + ->setChapo($chapo) + ->setDescription($description) + ->setPostscriptum($postscriptum) + ->save() + ; + + if ($containerId > 0) { + // Required, see Selection::preInsert(); + $selection->setPosition($position)->save(); + + (new SelectionContainerAssociatedSelection()) + ->setSelectionContainerId($containerId) + ->setSelectionId($selection->getId()) + ->save(); + + return $this->generateRedirect(URL::getInstance()->absoluteUrl("/admin/selection/container/view/" . $containerId)); + } + + return $this->generateRedirect(URL::getInstance()->absoluteUrl("/admin/selection")); + } catch (FormValidationException $ex) { + // Form cannot be validated + $error_msg = $this->createStandardFormValidationErrorMessage($ex); + } catch (\Exception $ex) { + // Any other error + $error_msg = $ex->getMessage(); + } + + if (false !== $error_msg) { + $this->setupFormErrorContext( + $this->getTranslator()->trans("%obj creation", ['%obj' => $this->objectName]), + $error_msg, + $form, + $ex + ); + // At this point, the form has error, and should be redisplayed. + return $this->renderList(); + } + } + + + public function updateSelectionPositionAction() + { + if (null !== $response = $this->checkAuth(array(AdminResources::MODULE), array(Selection::DOMAIN_NAME), AccessManager::UPDATE)) { + return $response; + } + try { + $mode = $this->getRequest()->get('mode', null); + + if ($mode === 'up') { + $mode = UpdatePositionEvent::POSITION_UP; + } elseif ($mode === 'down') { + $mode = UpdatePositionEvent::POSITION_DOWN; + } else { + $mode = UpdatePositionEvent::POSITION_ABSOLUTE; + } + + $position = $this->getRequest()->get('position', null); + + $event = $this->createUpdateSelectionPositionEvent($mode, $position); + + $this->dispatch(SelectionEvents::SELECTION_UPDATE_POSITION, $event); + } catch (\Exception $ex) { + Tlog::getInstance()->error($ex->getMessage()); + } + + return $this->forward('Selection\Controller\SelectionController::viewAction'); + } + + public function deleteRelatedProduct() + { + $selectionID = $this->getRequest()->get('selectionID'); + $productID = $this->getRequest()->get('productID'); + + try { + $selection = SelectionProductQuery::create() + ->filterByProductId($productID) + ->findOneBySelectionId($selectionID); + if (null !== $selection) { + $selection->delete(); + } + } catch (\Exception $e) { + Tlog::getInstance()->error($e->getMessage()); + } + + return $this->generateRedirectFromRoute('selection.update', [], ['selectionId' => $selectionID], null); + } + + public function deleteRelatedContent() + { + $selectionID = $this->getRequest()->get('selectionID'); + $contentID = $this->getRequest()->get('contentID'); + + try { + $selection = SelectionContentQuery::create() + ->filterByContentId($contentID) + ->findOneBySelectionId($selectionID); + if (null !== $selection) { + $selection->delete(); + } + } catch (\Exception $e) { + Tlog::getInstance()->error($e->getMessage()); + } + + return $this->generateRedirectFromRoute('selection.update', [], ['selectionId' => $selectionID], null); + } + /*-------------------------- Part Controller SEO */ + public function __construct() + { + parent::__construct( + 'selection', + 'selection_id', + 'order', + AdminResources::MODULE, + SelectionEvents::SELECTION_CREATE, + SelectionEvents::SELECTION_UPDATE, + SelectionEvents::SELECTION_DELETE, + null, + SelectionEvents::RELATED_PRODUCT_UPDATE_POSITION, + SelectionEvents::SELECTION_UPDATE_SEO, + Selection::DOMAIN_NAME + ); + } + + protected function getCreationForm() + { + return $this->createForm('admin.selection.update'); + } + + protected function getUpdateForm($data = array()) + { + if (!is_array($data)) { + $data = array(); + } + + return $this->createForm('admin.selection.update', 'form', $data); + } + + /** + * $object Selection + * @param \Selection\Model\Selection $selection + * @return \Thelia\Form\BaseForm + * @throws \Propel\Runtime\Exception\PropelException + */ + protected function hydrateObjectForm($selection) + { + $this->hydrateSeoForm($selection); + $associatedContainer = $selection->getSelectionContainerAssociatedSelections(); + $container = null; + if (!empty($associatedContainer) && count($associatedContainer) > 0) { + /** @var SelectionContainerAssociatedSelection[] $associatedContainer */ + $container = $associatedContainer[0]->getSelectionContainerId(); + } + $data = array( + 'selection_id' => $selection->getId(), + 'selection_container' => $container, + 'id' => $selection->getId(), + 'locale' => $selection->getLocale(), + 'selection_code' => $selection->getCode(), + 'selection_title' => $selection->getTitle(), + 'selection_chapo' => $selection->getChapo(), + 'selection_description' => $selection->getDescription(), + 'selection_postscriptum'=> $selection->getPostscriptum(), + 'current_id' => $selection->getId(), + ); + + return $this->getUpdateForm($data); + } + + protected function getCreationEvent($formData) + { + $event = new SelectionEvent(); + + $event->setCode($formData['code']); + $event->setTitle($formData['title']); + $event->setChapo($formData['chapo']); + $event->setDescription($formData['description']); + $event->setPostscriptum($formData['postscriptum']); + $event->setContainerId($formData['container_id']); + + return $event; + } + + protected function getUpdateEvent($formData) + { + $selection = SelectionQuery::create()->findPk($formData['selection_id']); + $event = new SelectionEvent($selection); + + $event->setId($formData['selection_id']); + $event->setContainerId($formData['selection_container_id']); + $event->setCode($formData['selection_code']); + $event->setTitle($formData['selection_title']); + $event->setChapo($formData['selection_chapo']); + $event->setDescription($formData['selection_description']); + $event->setPostscriptum($formData['selection_postscriptum']); + $event->setLocale($this->getCurrentEditionLocale()); + return $event; + } + + protected function getDeleteEvent() + { + $event = new SelectionEvent(); + $selectionId = $this->getRequest()->request->get('selection_id'); + $event->setId($selectionId); + return $event; + } + + protected function getDeleteGroupEvent() + { + $event = new SelectionContainerEvent(); + $selectionGroupId = $this->getRequest()->request->get('selection_group_id'); + $event->setId($selectionGroupId); + return $event; + } + + protected function eventContainsObject($event) + { + return $event->hasSelection(); + } + + protected function getObjectFromEvent($event) + { + return $event->getSelection(); + } + + protected function getExistingObject() + { + $selection = SelectionQuery::create() + ->findPk($this->getRequest()->get('selectionId', 0)); + + if (null !== $selection) { + $selection->setLocale($this->getCurrentEditionLocale()); + } + + return $selection; + } + + protected function getObjectLabel($object) + { + return ''; + } + + /** + * Returns the object ID from the object + * @param \Selection\Model\Selection $object + * @return int selection id + */ + protected function getObjectId($object) + { + return $object->getId(); + } + + protected function renderListTemplate($currentOrder) + { + $this->getParser()->assign("order", $currentOrder); + return $this->render('selection-list'); + } + + protected function renderEditionTemplate() + { + $selectionId = $this->getRequest()->get('selectionId'); + $currentTab = $this->getRequest()->get('current_tab'); + return $this->render( + 'selection-edit', + [ + 'selection_id' => $selectionId, + 'current_tab' => $currentTab + ] + ); + } + + protected function redirectToEditionTemplate() + { + if (!$id = $this->getRequest()->get('selection_id')) { + $id = $this->getRequest()->get('admin_selection_update')['selection_id']; + } + + return new RedirectResponse( + URL::getInstance()->absoluteUrl( + "/admin/selection/update/".$id + ) + ); + } + + protected function redirectToListTemplate() + { + return new RedirectResponse( + URL::getInstance()->absoluteUrl("/admin/selection") + ); + } + + /** + * Online status toggle product + */ + public function setToggleVisibilityAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) { + return $response; + } + + $event = new SelectionEvent($this->getExistingObject()); + + try { + $this->dispatch(SelectionEvents::SELECTION_TOGGLE_VISIBILITY, $event); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + + // Ajax response -> no action + return $this->nullResponse(); + } + + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) + { + return new UpdatePositionEvent( + $this->getRequest()->get('product_id', null), + $positionChangeMode, + $positionValue, + $this->getRequest()->get('selection_id', null) + ); + } + + protected function createUpdateSelectionPositionEvent($positionChangeMode, $positionValue) + { + return new UpdatePositionEvent( + $this->getRequest()->get('selection_id', null), + $positionChangeMode, + $positionValue, + Selection::getModuleId() + ); + } + + protected function performAdditionalUpdatePositionAction($positionEvent) + { + $selectionID = $this->getRequest()->get('selection_id'); + + return $this->generateRedirectFromRoute('selection.update', [], ['selectionId' => $selectionID], null); + } + + protected function performAdditionalDeleteAction($deleteEvent) + { + $containerId = (int) $this->getRequest()->get('container_id'); + + if ($containerId > 0) { + return $this->generateRedirect(URL::getInstance()->absoluteUrl("/admin/selection/container/view/" . $containerId)); + } + + return null; + } + + public function processUpdateSeoAction() + { + $selectionId = $this->getRequest()->get('current_id'); + $this->getRequest()->request->set("selectionId", $selectionId); + return parent::processUpdateSeoAction(); + } +} diff --git a/local/modules/Selection/Event/SelectionContainerEvent.php b/local/modules/Selection/Event/SelectionContainerEvent.php new file mode 100644 index 00000000..87d30582 --- /dev/null +++ b/local/modules/Selection/Event/SelectionContainerEvent.php @@ -0,0 +1,157 @@ +selectionContainer = $selectionContainer; + } + + /** + * @param mixed $id + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * @param mixed $title + */ + public function setTitle($title) + { + $this->title = $title; + } + + /** + * @param mixed $chapo + */ + public function setChapo($chapo) + { + $this->chapo = $chapo; + } + + /** + * @param mixed $postscriptum + */ + public function setPostscriptum($postscriptum) + { + $this->postscriptum = $postscriptum; + } + + /** + * @param mixed $desciption + */ + public function setDescription($description) + { + $this->description = $description; + } + + public function setLocale($locale) + { + $this->locale = $locale; + return $this; + } + + public function hasSelection() + { + return ! is_null($this->selectionContainer); + } + + public function getSelectionContainer() + { + return $this->selectionContainer; + } + + public function setSelectionContainer($selectionContainer) + { + $this->selectionContainer = $selectionContainer; + } + + /** + * @return mixed + */ + public function getLocale() + { + return $this->locale; + } + + /** + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * @return mixed + */ + public function getTitle() + { + return $this->title; + } + + /** + * @return mixed + */ + public function getChapo() + { + return $this->chapo; + } + + /** + * @return mixed + */ + public function getPostscriptum() + { + return $this->postscriptum; + } + + /** + * @return mixed + */ + public function getDescription() + { + return $this->description; + } + + /** + * @return mixed + */ + public function getCode() + { + return $this->code; + } + + /** + * @param mixed $code + * @return $this + */ + public function setCode($code) + { + $this->code = $code; + return $this; + } +} diff --git a/local/modules/Selection/Event/SelectionEvent.php b/local/modules/Selection/Event/SelectionEvent.php new file mode 100644 index 00000000..00830769 --- /dev/null +++ b/local/modules/Selection/Event/SelectionEvent.php @@ -0,0 +1,213 @@ +id; + } + + public function setId($id) + { + $this->id = $id; + + return $this; + } + + public function getTitle() + { + return $this->title; + } + + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + public function getChapo() + { + return $this->chapo; + } + + public function setChapo($chapo) + { + $this->chapo = $chapo; + + return $this; + } + + public function getDescription() + { + return $this->description; + } + + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + public function getPostscriptum() + { + return $this->postscriptum; + } + + public function setPostscriptum($postscriptum) + { + $this->postscriptum = $postscriptum; + + return $this; + } + + public function getLocale() + { + return $this->locale; + } + + public function setLocale($locale) + { + $this->locale = $locale; + return $this; + } + + + /*----------------------------- SEO EVENT PARTS */ + public function getUrl() + { + return $this->url; + } + + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + public function getMetaTitle() + { + return $this->meta_title; + } + + public function setMetaTitle($meta_title) + { + $this->meta_title = $meta_title; + + return $this; + } + + public function getMetaDescription() + { + return $this->meta_description; + } + + public function setMetaDescription($meta_description) + { + $this->meta_description = $meta_description; + + return $this; + } + + public function getMetaKeywords() + { + return $this->meta_keywords; + } + + public function setMetaKeywords($meta_keywords) + { + $this->meta_keywords = $meta_keywords; + + return $this; + } + + /*----------------------------- Selection object Parts*/ + public function __construct(Selection $selection = null) + { + $this->selection = $selection; + } + + public function getSelection() + { + return $this->selection; + } + + public function setSelection($selection) + { + $this->selection = $selection; + + return $this; + } + + public function hasSelection() + { + + return ! is_null($this->selection); + } + + /** + * @return mixed + */ + public function getContainerId() + { + return $this->containerId; + } + + /** + * @param mixed $containerId + */ + public function setContainerId($containerId) + { + $this->containerId = $containerId; + } + + /** + * @return mixed + */ + public function getCode() + { + return $this->code; + } + + /** + * @param mixed $code + * @return $this + */ + public function setCode($code) + { + $this->code = $code; + return $this; + } +} diff --git a/local/modules/Selection/Event/SelectionEvents.php b/local/modules/Selection/Event/SelectionEvents.php new file mode 100644 index 00000000..52814f8e --- /dev/null +++ b/local/modules/Selection/Event/SelectionEvents.php @@ -0,0 +1,47 @@ +formBuilder + ->add( + 'locale', + 'hidden', + [ + 'constraints' => [ new Constraints\NotBlank() ], + 'required' => true, + ] + ) + ->add( + 'title', + TextType::class, + array( + "constraints" => [ + new Constraints\NotBlank() + ], + "label" => Translator::getInstance()->trans('Title', [], Selection::DOMAIN_NAME) + ) + ) + ->add( + 'code', + TextType::class, + array( + "constraints" => [ + new Constraints\NotBlank(), + new Constraints\Callback([ + "methods" => [ + [$this, "checkDuplicateCode"], + ] + ]), + ], + "label" => Translator::getInstance()->trans('Code', [], Selection::DOMAIN_NAME) + ) + ) + ->add( + 'chapo', + TextareaType::class, + [ + 'required' => false, + "constraints" => [], + "label" => Translator::getInstance()->trans('Summary', [], Selection::DOMAIN_NAME), + ] + ) + ->add( + 'description', + TextareaType::class, + [ + 'required' => false, + 'attr' => ['class' => 'tinymce'], + "constraints" => [], + "label" => Translator::getInstance()->trans('Description', [], Selection::DOMAIN_NAME), + ] + ) + ->add( + 'postscriptum', + TextareaType::class, + [ + 'required' => false, + "constraints" => [], + "label" => Translator::getInstance()->trans('Conclusion', [], Selection::DOMAIN_NAME), + ] + ); + } +} diff --git a/local/modules/Selection/Form/SelectionContainerCreateForm.php b/local/modules/Selection/Form/SelectionContainerCreateForm.php new file mode 100644 index 00000000..4601a6e7 --- /dev/null +++ b/local/modules/Selection/Form/SelectionContainerCreateForm.php @@ -0,0 +1,48 @@ +addCommonFields(); + } + + public function checkDuplicateCode($value, ExecutionContextInterface $context) + { + if (SelectionContainerQuery::create()->filterByCode($value)->count() > 0) { + $context->addViolation( + Translator::getInstance()->trans( + "A selection container with code %code already exists. Please enter a different code.", + ['%code' => $value], + Selection::DOMAIN_NAME + ) + ); + } + } + + /** + * @return string the name of the form. This name need to be unique. + */ + public function getName() + { + return "admin_selection_contianer_create"; + } +} diff --git a/local/modules/Selection/Form/SelectionContainerUpdateForm.php b/local/modules/Selection/Form/SelectionContainerUpdateForm.php new file mode 100644 index 00000000..7b7d8649 --- /dev/null +++ b/local/modules/Selection/Form/SelectionContainerUpdateForm.php @@ -0,0 +1,129 @@ +formBuilder + ->add( + 'selection_container_id', + TextType::class, + array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans('Selection reference', [], Selection::DOMAIN_NAME), + "required" => false, + "read_only" => true, + ) + ) + ->add( + 'selection_container_code', + TextType::class, + array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback([ + "methods" => [ + [$this, "checkDuplicateCode"], + ] + ]), + ), + "label" => Translator::getInstance()->trans('Selection code', [], Selection::DOMAIN_NAME), + ) + ) + ->add( + 'selection_container_title', + TextType::class, + array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans('Title', [], Selection::DOMAIN_NAME), + "required" => false, + ) + ) + ->add( + 'selection_container_chapo', + TextareaType::class, + array( + 'attr' => array('class' => 'tinymce'), + "constraints" => array( + ), + "label" =>Translator::getInstance()->trans('Summary', [], Selection::DOMAIN_NAME), + "required" => false, + ) + ) + ->add( + 'selection_container_description', + TextareaType::class, + array( + 'attr' => array('class' => 'tinymce'), + "constraints" => array( + ), + "label" =>Translator::getInstance()->trans('Description', [], Selection::DOMAIN_NAME), + "required" => false, + ) + ) + ->add( + 'selection_container_postscriptum', + TextareaType::class, + array( + 'attr' => array('class' => 'tinymce'), + "constraints" => array( + ), + "label" => Translator::getInstance()->trans('Conclusion', [], Selection::DOMAIN_NAME), + "required" => false, + ) + ) + ; + } + + public function checkDuplicateCode($value, ExecutionContextInterface $context) + { + $data = $context->getRoot()->getData(); + + $count = SelectionContainerQuery::create() + ->filterById($data['selection_container_id'], Criteria::NOT_EQUAL) + ->filterByCode($value)->count(); + + if ($count > 0) { + $context->addViolation( + Translator::getInstance()->trans( + "A selection container with code %code already exists. Please enter a different code.", + ['%code' => $value], + Selection::DOMAIN_NAME + ) + ); + } + } + + /** + * @return string the name of the form. This name need to be unique. + */ + public function getName() + { + return "admin_selection_container_update"; + } +} diff --git a/local/modules/Selection/Form/SelectionCreateForm.php b/local/modules/Selection/Form/SelectionCreateForm.php new file mode 100644 index 00000000..6d10429b --- /dev/null +++ b/local/modules/Selection/Form/SelectionCreateForm.php @@ -0,0 +1,52 @@ +addCommonFields(); + + $this->formBuilder->add( + 'container_id', + HiddenType::class, + array( + "required" => false + ) + ); + } + + public function checkDuplicateCode($value, ExecutionContextInterface $context) + { + if (SelectionQuery::create()->filterByCode($value)->count() > 0) { + $context->addViolation( + Translator::getInstance()->trans( + "A selection with code %code already exists. Please enter a different code.", + ['%code' => $value], + Selection::DOMAIN_NAME + ) + ); + } + } + + /** + * @return string the name of the form. This name need to be unique. + */ + public function getName() + { + return "admin_selection_create"; + } +} diff --git a/local/modules/Selection/Form/SelectionImageModification.php b/local/modules/Selection/Form/SelectionImageModification.php new file mode 100644 index 00000000..c01ed43f --- /dev/null +++ b/local/modules/Selection/Form/SelectionImageModification.php @@ -0,0 +1,13 @@ +initContainers(); + $this->formBuilder + ->add( + 'selection_id', + TextType::class, + array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => Translator::getInstance()->trans('Selection reference', [], Selection::DOMAIN_NAME), + "required" => false, + "read_only" => true, + ) + ) + ->add( + 'selection_code', + TextType::class, + array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback([ + "methods" => [ + [$this, "checkDuplicateCode"], + ] + ]), + ), + "label" => Translator::getInstance()->trans('Selection code', [], Selection::DOMAIN_NAME), + ) + ) + ->add( + 'selection_container', + ChoiceType::class, + [ + 'choices' => $this->containersArray, + 'multiple' => false, + 'expanded' => false, + 'choice_label' => function ($key, $index, $value) { + return $key; + }, + 'choice_value' => function ($key) { + if (array_key_exists($key, $this->containersArray)) { + return $this->containersArray[$key]; + } + return '0'; + }, + + "label" => Translator::getInstance()->trans('Container', [], Selection::DOMAIN_NAME), + 'required' => false, + 'empty_data' => null, + ] + ) + ->add( + 'selection_title', + TextType::class, + [ + "constraints" => [], + "label" => Translator::getInstance()->trans('Title', [], Selection::DOMAIN_NAME), + "required" => false, + ] + ) + ->add( + 'selection_chapo', + TextareaType::class, + array( + 'attr' => array('class' => 'tinymce'), + "constraints" => [], + "label" =>Translator::getInstance()->trans('Summary', [], Selection::DOMAIN_NAME), + "required" => false, + ) + ) + ->add( + 'selection_description', + TextareaType::class, + array( + 'attr' => array('class' => 'tinymce'), + "constraints" => [], + "label" =>Translator::getInstance()->trans('Description', [], Selection::DOMAIN_NAME), + "required" => false, + ) + ) + ->add( + 'selection_postscriptum', + TextareaType::class, + array( + 'attr' => array('class' => 'tinymce'), + "constraints" => [], + "label" => Translator::getInstance()->trans('Conclusion', [], Selection::DOMAIN_NAME), + "required" => false, + ) + ); + + //instead of option value, symfony take option key! + //these 2 event listeners are a hack + $this->formBuilder->addEventListener( + FormEvents::SUBMIT, + function (FormEvent $event) { + $data = $event->getData(); + $selectionContainerWrongValue = $data['selection_container']; + $selectionContainerValue = $this->containersArray[$selectionContainerWrongValue]; + $data['selection_container_id'] = $selectionContainerValue; + $event->setData($data); + } + ); + + $this->formBuilder->addEventListener( + FormEvents::PRE_SET_DATA, + function (FormEvent $event) { + $data = $event->getData(); + if (!array_key_exists('selection_container', $data)) { + return; + } + $key = array_search($data['selection_container'], $this->containersArray); + $data['selection_container'] = $key; + $event->setData($data); + } + ); + } + + public function checkDuplicateCode($value, ExecutionContextInterface $context) + { + $data = $context->getRoot()->getData(); + + $count = SelectionQuery::create() + ->filterById($data['selection_id'], Criteria::NOT_EQUAL) + ->filterByCode($value)->count(); + + if ($count > 0) { + $context->addViolation( + Translator::getInstance()->trans( + "A selection with code %code already exists. Please enter a different code.", + array('%code' => $value) + ) + ); + } + } + + /** + * @return string the name of the form. This name need to be unique. + */ + public function getName() + { + return "admin_selection_update"; + } + + private function initContainers() + { + $lang = $this->request->getSession() ? $this->request->getSession()->getLang(true) : $this->request->lang = Lang::getDefaultLanguage(); + $containers = SelectionContainerQuery::getAll($lang); + $this->containersArray = []; + $this->containersArray[Translator::getInstance()->trans('None', [], Selection::DOMAIN_NAME)] = null; //because placeholder is not working + foreach ($containers as $container) { + try { + $this->containersArray[$container->getVirtualColumn("i18n_TITLE")] = $container->getId(); + } catch (PropelException $e) { + Tlog::getInstance()->error($e->getMessage()); + } + } + } +} diff --git a/local/modules/Selection/Form/SelectioncontainerImageModification.php b/local/modules/Selection/Form/SelectioncontainerImageModification.php new file mode 100644 index 00000000..c199361b --- /dev/null +++ b/local/modules/Selection/Form/SelectioncontainerImageModification.php @@ -0,0 +1,15 @@ + + */ +class BackHook extends BaseHook +{ + /*** + * Hook Selection module to the sidebar in tools menu + * + * @param HookRenderBlockEvent $event + */ + public function onMainTopMenuTools(HookRenderBlockEvent $event) + { + $event->add( + [ + 'id' => 'tools_menu_selection', + 'class' => '', + 'url' => URL::getInstance()->absoluteUrl('/admin/selection'), + 'title' => $this->trans('Selections', [], Selection::DOMAIN_NAME) + ] + ); + } +} diff --git a/local/modules/Selection/I18n/backOffice/default/fr_FR.php b/local/modules/Selection/I18n/backOffice/default/fr_FR.php new file mode 100644 index 00000000..18e9be17 --- /dev/null +++ b/local/modules/Selection/I18n/backOffice/default/fr_FR.php @@ -0,0 +1,75 @@ + '(Modification)', + 'Actions' => 'Actions', + 'Add a new Selection' => 'Ajouter une nouvelle sélection', + 'Add a new selection Container' => 'Ajout d\'un nouveau conteneur de sélection', + 'Add a selection to this container' => 'Ajouter une selection à ce conteneur', + 'Back' => 'Retour', + 'Browse files' => 'Rechercher des fichiers', + 'Can\'t load images, please refresh this page.' => 'Chargement des images impossible, veuillez actualiser la page', + 'Can\'t reorder images, please refresh this page.' => 'Classement des images impossible, veuillez actualiser la page', + 'Change this selection' => 'Changer cette sélection', + 'Container' => 'Conteneur', + 'Content title' => 'Titre du contenu', + 'Create a Selection Container' => 'Créer un conteneur de sélection', + 'Delete selection' => 'Supprimer une sélection', + 'Delete selection container' => 'Supprimer le conteneur de sélection', + 'Delete this selection' => 'Supprimer cette sélection', + 'Delete this value' => 'Supprimer cette valeur', + 'Display selections in this container' => 'Afficher les selections du conteneur ', + 'Do you really want to delete these %count image(s) ?' => 'Voulez-vous vraiment supprimer cette/ces %count image(s)?', + 'Do you really want to delete this container?' => 'Voulez-vous vraiment supprimer ce conteneur?', + 'Do you really want to delete this image ?' => 'Voulez-vous vraiment supprimer cette image?', + 'Do you really want to delete this selection ?' => 'Etes-vous sûr de vouloir supprimer cette sélection?', + 'Drop files to upload' => 'Déposer des fichiers pour les uploader', + 'Edit an image' => 'Editer une image', + 'Edit image "%name"' => 'Editer l\'image "%name" ', + 'Edit selection' => 'Édition Sélection', + 'Edit selection container' => 'Éditer le conteneur de sélection', + 'Editing image "%name"' => 'Édition de l\'image "%name" ', + 'Enter new product position' => 'Entrer la nouvelle position du produit', + 'General' => 'Général', + 'Home' => 'Accueil', + 'ID' => 'ID', + 'Image' => 'Image', + 'Image information' => 'Image information ', + 'Image+file+not+found' => 'Fichier+image+non+trouvé', + 'No' => 'Non', + 'No available content in this folder' => 'Aucun contenu disponible dans ce dossier', + 'No available product in this category' => 'Aucun produit disponible pour cette catégorie', + 'Online' => 'En ligne', + 'Or' => 'Ou', + 'Please retry' => 'Veuillez ré-essayer', + 'Position' => 'Position', + 'Preview' => 'Apperçu', + 'Product title' => 'Titre du produit', + 'Related content' => 'Contenus associés', + 'SEO' => 'SEO', + 'Save' => 'Enregistrer', + 'Select a category to get its product' => 'Sélectionner une catégorie pour afficher ces produits', + 'Select a category...' => 'Sélectionner une catégorie...', + 'Select a folder to get its content' => 'Sélectionner un dossier pour afficher son contenu', + 'Select a folder...' => 'Sélectionner un dossier...', + 'Select a product and click (+) to add it as an accessory' => 'Sélectionner un produit et cliquer (+) pour l\'ajouter comme accessoire', + 'Select a product...' => 'Sélectionner un produit...', + 'Selection' => 'Sélection', + 'Selection category' => 'Produits dans la sélection', + 'Selection container edit :' => 'Conteneur de sélection - Edition ', + 'Selection edit :' => 'Sélection édition :', + 'Selections' => 'Sélections', + 'Selections Containers' => 'Conteneur de sélection', + 'Selections without container' => 'Sélection(s) sans conteneur', + 'Send files' => 'Envoyer les fichiers', + 'Sorry, image ID=%id was not found.' => 'Désolé, l\'image ID=%id n\'a pas été trouvée', + 'There is no images attached to this %type.' => 'Aucune images attachée à ce %type', + 'Title' => 'Titre', + 'Tools' => 'Outils', + 'Update this image' => 'Mettre à jour cette image', + 'Visibility' => 'Visibilité', + 'Yes' => 'Oui', + 'You can attach here some category to this selection' => 'Indiquez ici les produits qui figurent dans cette sélection', + 'You can attach here some contents to this selection' => 'Attacher ici des contenus à la sélection', + 'delete image' => 'Supprimer l\'image', +); diff --git a/local/modules/Selection/I18n/en_US.php b/local/modules/Selection/I18n/en_US.php new file mode 100644 index 00000000..0b4fa142 --- /dev/null +++ b/local/modules/Selection/I18n/en_US.php @@ -0,0 +1,4 @@ + 'The displayed english string', +); diff --git a/local/modules/Selection/I18n/fr_FR.php b/local/modules/Selection/I18n/fr_FR.php new file mode 100644 index 00000000..3ee66a01 --- /dev/null +++ b/local/modules/Selection/I18n/fr_FR.php @@ -0,0 +1,13 @@ + 'Conclusion', + 'Container' => 'Conteneur', + 'Description' => 'Description', + 'Selection' => 'Sélection', + 'Selection code' => 'Code de la sélection', + 'Selection reference' => 'Référence de la sélection', + 'Summary' => 'Résumé', + 'Title' => 'Titre', + 'Selections' => 'Séléctions', +); diff --git a/local/modules/Selection/Loop/SelectionContainerLoop.php b/local/modules/Selection/Loop/SelectionContainerLoop.php new file mode 100644 index 00000000..6c6f3de1 --- /dev/null +++ b/local/modules/Selection/Loop/SelectionContainerLoop.php @@ -0,0 +1,230 @@ +configureI18nProcessing($search, array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION')); + + if (null !== $code = $this->getCode()) { + $search->filterByCode($code, Criteria::IN); + } + + if (null !== $excludeCode = $this->getExcludeCode()) { + $search->filterByCode($excludeCode, Criteria::NOT_IN); + } + + if (null !== $exclude = $this->getExclude()) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + if (null !== $id = $this->getId()) { + $search->filterById($id, Criteria::IN); + } + + if (null !== $position = $this->getPosition()) { + $search->filterByPosition($position, Criteria::IN); + } + + if (null !== $title = $this->getTitle()) { + //find all selections that match exactly this title and find with all locales. + try { + $search2 = SelectionI18nQuery::create() + ->filterByTitle($title, Criteria::LIKE) + ->select('id') + ->find(); + if ($search2) { + $search->filterById( + $search2, + Criteria::IN + ); + } + } catch (PropelException $e) { + Tlog::getInstance()->error($e->getMessage()); + } + } + + $visible = $this->getVisible(); + if (BooleanOrBothType::ANY !== $visible) { + $search->filterByVisible($visible ? 1 : 0); + } + + if (null !== $selectionId = $this->getSelectionId()) { + $search->innerJoinSelectionContainerAssociatedSelection(SelectionContainerAssociatedSelectionTableMap::TABLE_NAME); + $search->where(SelectionContainerAssociatedSelectionTableMap::SELECTION_ID . Criteria::EQUAL . $selectionId); + } + + /** @noinspection PhpUndefinedMethodInspection */ + $orders = $this->getOrder(); + + foreach ($orders as $order) { + switch ($order) { + case "id": + $search->orderById(Criteria::ASC); + break; + case "id_reverse": + $search->orderById(Criteria::DESC); + break; + case "code": + $search->orderByCode(Criteria::ASC); + break; + case "code_reverse": + $search->orderByCode(Criteria::DESC); + break; + case "alpha": + $search->addAscendingOrderByColumn('i18n_TITLE'); + break; + case "alpha_reverse": + $search->addDescendingOrderByColumn('i18n_TITLE'); + break; + case "manual": + $search->orderByPosition(Criteria::ASC); + break; + case "manual_reverse": + $search->orderByPosition(Criteria::DESC); + break; + case "visible": + $search->orderByVisible(Criteria::ASC); + break; + case "visible_reverse": + $search->orderByVisible(Criteria::DESC); + break; + case "created": + $search->addAscendingOrderByColumn('created_at'); + break; + case "created_reverse": + $search->addDescendingOrderByColumn('created_at'); + break; + case "updated": + $search->addAscendingOrderByColumn('updated_at'); + break; + case "updated_reverse": + $search->addDescendingOrderByColumn('updated_at'); + break; + case "random": + $search->clearOrderByColumns(); + $search->addAscendingOrderByColumn('RAND()'); + break; + default: + $search->orderByPosition(Criteria::ASC); + } + } + + return $search; + } + + /** + * @param LoopResult $loopResult + * + * @return LoopResult + */ + public function parseResults(LoopResult $loopResult) + { + /** @noinspection PhpUndefinedMethodInspection */ + $needSelectionCount = $this->getNeedSelectionCount() === null || !$this->getNeedSelectionCount(); + /** @var SelectionContainer $selectionContainer */ + foreach ($loopResult->getResultDataCollection() as $selectionContainer) { + $loopResultRow = new LoopResultRow($selectionContainer); + + /** @noinspection PhpUndefinedMethodInspection */ + $loopResultRow + ->set("SELECTION_CONTAINER_ID", $selectionContainer->getId()) + ->set("SELECTION_CONTAINER_URL", $this->getReturnUrl() ? $selectionContainer->getUrl($this->locale) : null) + ->set("SELECTION_CONTAINER_CODE", $selectionContainer->getCode()) + ->set("SELECTION_CONTAINER_TITLE", $selectionContainer->geti18n_TITLE()) + ->set("SELECTION_CONTAINER_META_TITLE", $selectionContainer->geti18n_META_TITLE()) + ->set("SELECTION_CONTAINER_POSITION", $selectionContainer->getPosition()) + ->set("SELECTION_CONTAINER_VISIBLE", $selectionContainer->getVisible()) + ->set("SELECTION_CONTAINER_DESCRIPTION", $selectionContainer->geti18n_DESCRIPTION()) + ->set("SELECTION_CONTAINER_META_DESCRIPTION", $selectionContainer->geti18n_META_DESCRIPTION()) + ->set("SELECTION_CONTAINER_POSTSCRIPTUM", $selectionContainer->geti18n_POSTSCRIPTUM()) + ->set("SELECTION_CONTAINER_CHAPO", $selectionContainer->geti18n_CHAPO()); + + if ($needSelectionCount) { + $associatedSelectionsQuery = SelectionContainerAssociatedSelectionQuery::create(); + $associatedSelectionsQuery->filterBySelectionContainerId($selectionContainer->getId()); + $childCount = $associatedSelectionsQuery->find()->count(); + $loopResultRow->set("SELECTION_COUNT", $childCount); + } + + $loopResult->addRow($loopResultRow); + } + return $loopResult; + } +} diff --git a/local/modules/Selection/Loop/SelectionContentRelated.php b/local/modules/Selection/Loop/SelectionContentRelated.php new file mode 100644 index 00000000..94add90c --- /dev/null +++ b/local/modules/Selection/Loop/SelectionContentRelated.php @@ -0,0 +1,91 @@ +getContentId()) { + $search->filterByContentId($content_id, Criteria::IN); + } + + if (null !== $position = $this->getPosition()) { + $search->filterByPosition($position, Criteria::IN); + } + if (null !== $selection_id = $this->getSelectionId()) { + $search->filterBySelectionId($selection_id, Criteria::IN); + } + + if (null !== $content_title = $this->getContentTitle()) { + $join = new Join( + ContentI18nTableMap::ID, + SelectionContentTableMap::CONTENT_ID, + Criteria::INNER_JOIN + ); + $search->addJoinObject($join, 'search') + ->addJoinCondition('search', ContentI18nTableMap::TITLE."=". $content_title); + } + return $search->orderByPosition(Criteria::ASC); + } + + /** + * @param LoopResult $loopResult + * @return LoopResult + * @throws \Propel\Runtime\Exception\PropelException + */ + public function parseResults(LoopResult $loopResult) + { + + foreach ($loopResult->getResultDataCollection() as $content) { + + /** @var SelectionContent $content */ + $loopResultRow = new LoopResultRow($content); + $lang = $this->request->getSession()->get('thelia.current.lang'); + $loopResultRow + ->set("CONTENT_ID", $content->getContentId()) + ->set("CONTENT_TITLE", $content->getContent()->getTitle()) + ->set("POSITION", $content->getPosition()) + ->set("selection_id", $content->getSelectionId()); + + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/local/modules/Selection/Loop/SelectionImage.php b/local/modules/Selection/Loop/SelectionImage.php new file mode 100644 index 00000000..3a8c52a2 --- /dev/null +++ b/local/modules/Selection/Loop/SelectionImage.php @@ -0,0 +1,67 @@ +invoke(null); // Static ! + + // $query->filterByXXX(id) + if (! is_null($object_id)) { + $method = new \ReflectionMethod($queryClass, $filterMethod); + $method->invoke($search, $object_id); + } + + $orders = $this->getOrder(); + + // Results ordering + foreach ($orders as $order) { + switch ($order) { + case "alpha": + $search->addAscendingOrderByColumn('i18n_TITLE'); + break; + case "alpha-reverse": + $search->addDescendingOrderByColumn('i18n_TITLE'); + break; + case "manual-reverse": + $search->orderByPosition(Criteria::DESC); + break; + case "manual": + $search->orderByPosition(Criteria::ASC); + break; + case "random": + $search->clearOrderByColumns(); + $search->addAscendingOrderByColumn('RAND()'); + break(2); + break; + } + } + + return $search; + } +} diff --git a/local/modules/Selection/Loop/SelectionLoop.php b/local/modules/Selection/Loop/SelectionLoop.php new file mode 100644 index 00000000..a68efc48 --- /dev/null +++ b/local/modules/Selection/Loop/SelectionLoop.php @@ -0,0 +1,231 @@ +configureI18nProcessing($search, array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION')); + + if (null !== $code = $this->getCode()) { + $search->filterByCode($code, Criteria::IN); + } + + if (null !== $excludeCode = $this->getExcludeCode()) { + $search->filterByCode($excludeCode, Criteria::NOT_IN); + } + + if (null !== $exclude = $this->getExclude()) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + if (null !== $id = $this->getId()) { + $search->filterById($id, Criteria::IN); + } + + if (null !== $position = $this->getPosition()) { + $search->filterByPosition($position, Criteria::IN); + } + + if (null !== $title = $this->getTitle()) { + //find all selections that match exactly this title and find with all locales. + $search2 = SelectionI18nQuery::create() + ->filterByTitle($title, Criteria::LIKE) + ->select('id') + ->find(); + + if ($search2) { + $search->filterById( + $search2, + Criteria::IN + ); + } + } + + $visible = $this->getVisible(); + if (BooleanOrBothType::ANY !== $visible) { + $search->filterByVisible($visible ? 1 : 0); + } + + + $search->leftJoinSelectionContainerAssociatedSelection(SelectionContainerAssociatedSelectionTableMap::TABLE_NAME); + /** @noinspection PhpUndefinedMethodInspection */ + $wantedContainerId = $this->getContainerId(); + /** @noinspection PhpUndefinedMethodInspection */ + $withoutContainer = $this->getWithoutContainer(); + if (null !== $wantedContainerId) { + $search->leftJoinSelectionContainerAssociatedSelection(SelectionContainerAssociatedSelectionTableMap::TABLE_NAME); + $search->where(SelectionContainerAssociatedSelectionTableMap::SELECTION_CONTAINER_ID . Criteria::EQUAL . $wantedContainerId); + } else if (null !== $withoutContainer && $withoutContainer) { + $search->leftJoinSelectionContainerAssociatedSelection(SelectionContainerAssociatedSelectionTableMap::TABLE_NAME); + $search->where(SelectionContainerAssociatedSelectionTableMap::SELECTION_ID . Criteria::ISNULL); + } + + /** @noinspection PhpUndefinedMethodInspection */ + $orders = $this->getOrder(); + + foreach ($orders as $order) { + switch ($order) { + case "id": + $search->orderById(Criteria::ASC); + break; + case "id_reverse": + $search->orderById(Criteria::DESC); + break; + case "code": + $search->orderByCode(Criteria::ASC); + break; + case "code_reverse": + $search->orderByCode(Criteria::DESC); + break; + case "alpha": + $search->addAscendingOrderByColumn('i18n_TITLE'); + break; + case "alpha_reverse": + $search->addDescendingOrderByColumn('i18n_TITLE'); + break; + case "manual": + $search->orderByPosition(Criteria::ASC); + break; + case "manual_reverse": + $search->orderByPosition(Criteria::DESC); + break; + case "visible": + $search->orderByVisible(Criteria::ASC); + break; + case "visible_reverse": + $search->orderByVisible(Criteria::DESC); + break; + case "created": + $search->addAscendingOrderByColumn('created_at'); + break; + case "created_reverse": + $search->addDescendingOrderByColumn('created_at'); + break; + case "updated": + $search->addAscendingOrderByColumn('updated_at'); + break; + case "updated_reverse": + $search->addDescendingOrderByColumn('updated_at'); + break; + case "random": + $search->clearOrderByColumns(); + $search->addAscendingOrderByColumn('RAND()'); + break; + default: + $search->orderByPosition(Criteria::ASC); + } + } + + return $search; + } + + /** + * @param LoopResult $loopResult + * + * @return LoopResult + * @throws PropelException + */ + public function parseResults(LoopResult $loopResult) + { + foreach ($loopResult->getResultDataCollection() as $selection) { + + /** @var Selection $selection */ + $loopResultRow = new LoopResultRow($selection); + /** @noinspection PhpUndefinedMethodInspection */ + $loopResultRow + ->set("SELECTION_ID", $selection->getId()) + ->set("SELECTION_URL", $this->getReturnUrl() ? $selection->getUrl($this->locale) : null) + ->set("SELECTION_TITLE", $selection->geti18n_TITLE()) + ->set("SELECTION_CODE", $selection->getCode()) + ->set("SELECTION_META_TITLE", $selection->geti18n_META_TITLE()) + ->set("SELECTION_POSITION", $selection->getPosition()) + ->set("SELECTION_VISIBLE", $selection->getVisible()) + ->set("SELECTION_DESCRIPTION", $selection->geti18n_DESCRIPTION()) + ->set("SELECTION_META_DESCRIPTION", $selection->geti18n_META_DESCRIPTION()) + ->set("SELECTION_POSTSCRIPTUM", $selection->geti18n_POSTSCRIPTUM()) + ->set("SELECTION_CHAPO", $selection->geti18n_CHAPO()) + ->set("SELECTION_CONTAINER_ID", $selection->getSelectionContainerAssociatedSelections()) + ; + + $loopResult->addRow($loopResultRow); + } + return $loopResult; + } +} diff --git a/local/modules/Selection/Loop/SelectionLoopCategory.php b/local/modules/Selection/Loop/SelectionLoopCategory.php new file mode 100644 index 00000000..4fdf8aa5 --- /dev/null +++ b/local/modules/Selection/Loop/SelectionLoopCategory.php @@ -0,0 +1,73 @@ +getCategoryId()) { + $search->filterById(); + } + + if (null !== $category_title = $this->getCategoryTitle()) { + $title = CategoryDocumentI18nQuery::create(); + $title->filterByTitle(); + } + + return $search; + } + + /** + * @param LoopResult $loopResult + * + * @return LoopResult + */ + public function parseResults(LoopResult $loopResult) + { + foreach ($loopResult->getResultDataCollection() as $category) { + /** @var Category $category */ + $loopResultRow = new LoopResultRow($category); + $lang = $this->request->getSession()->get('thelia.current.lang'); + $loopResultRow + ->set("CATEGORY_ID", $category->getId()) + ->set("CATEGORY_TITLE", $category->getTranslation($lang->getLocale())->getTitle()); + + $loopResult->addRow($loopResultRow); + } + return $loopResult; + } +} diff --git a/local/modules/Selection/Loop/SelectionLoopFolder.php b/local/modules/Selection/Loop/SelectionLoopFolder.php new file mode 100644 index 00000000..d467ee81 --- /dev/null +++ b/local/modules/Selection/Loop/SelectionLoopFolder.php @@ -0,0 +1,71 @@ +getFolderId()) { + $search->filterById(); + } + + if (null !== $folder_title = $this->getFolderTitle()) { + $title = FolderI18nQuery::create(); + $title->filterByTitle(); + } + + return $search; + } + + /** + * @param LoopResult $loopResult + * + * @return LoopResult + */ + public function parseResults(LoopResult $loopResult) + { + foreach ($loopResult->getResultDataCollection() as $folder) { + + /** @var Folder $folder */ + $loopResultRow = new LoopResultRow($folder); + $lang = $this->request->getSession()->get('thelia.current.lang'); + $loopResultRow + ->set('folder_id', $folder->getId()) + ->set('folder_title', $folder->getTranslation($lang->getLocale())->getTitle()); + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/local/modules/Selection/Loop/SelectionProductRelated.php b/local/modules/Selection/Loop/SelectionProductRelated.php new file mode 100644 index 00000000..daa81edf --- /dev/null +++ b/local/modules/Selection/Loop/SelectionProductRelated.php @@ -0,0 +1,102 @@ +getProductID()) { + $search->filterByProductId($product_id, Criteria::IN); + } + + + if (null !== $selection_id = $this->getSelectionId()) { + $search->filterBySelectionId($selection_id, Criteria::IN); + } + + if (null !== $position = $this->getPosition()) { + $search->filterByPosition($position, Criteria::IN); + } + + if (null !== $product_title = $this->getProductTitle()) { + $join = new Join( + ProductI18nTableMap::ID, + SelectionContentTableMap::CONTENT_ID, + Criteria::INNER_JOIN + ); + $search->addJoinObject($join, 'search') + ->addJoinCondition('search', ProductI18nTableMap::TITLE."=". $product_title); + } + return $search->orderByPosition(Criteria::ASC); + } + + /** + * @param LoopResult $loopResult + * @return LoopResult + * @throws \Propel\Runtime\Exception\PropelException + */ + public function parseResults(LoopResult $loopResult) + { + + foreach ($loopResult->getResultDataCollection() as $product) { + + /** @var SelectionProduct $product */ + $loopResultRow = new LoopResultRow($product); + $lang = $this->request->getSession()->get('thelia.current.lang'); + $loopResultRow + ->set("PRODUCT_ID", $product->getProductId()) + ->set("PRODUCT_TITLE", $product->getProduct()->getTitle()) + ->set("POSITION", $product->getPosition()) + ->set("selection_id", $product->getSelectionId()); + + $loopResult->addRow($loopResultRow); + } + return $loopResult; + } +} diff --git a/local/modules/Selection/Model/Base/Selection.php b/local/modules/Selection/Model/Base/Selection.php new file mode 100644 index 00000000..9a16b1ba --- /dev/null +++ b/local/modules/Selection/Model/Base/Selection.php @@ -0,0 +1,3079 @@ +modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Selection instance. If + * obj is an instance of Selection, delegates to + * equals(Selection). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Selection The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Selection The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [visible] column value. + * + * @return int + */ + public function getVisible() + { + + return $this->visible; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Selection\Model\Selection The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[SelectionTableMap::ID] = true; + } + + + return $this; + } // setId() + + /** + * Set the value of [visible] column. + * + * @param int $v new value + * @return \Selection\Model\Selection The current object (for fluent API support) + */ + public function setVisible($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->visible !== $v) { + $this->visible = $v; + $this->modifiedColumns[SelectionTableMap::VISIBLE] = true; + } + + + return $this; + } // setVisible() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Selection\Model\Selection The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[SelectionTableMap::POSITION] = true; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Selection\Model\Selection The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[SelectionTableMap::CREATED_AT] = true; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Selection\Model\Selection The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[SelectionTableMap::UPDATED_AT] = true; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : SelectionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : SelectionTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $this->visible = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : SelectionTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : SelectionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : SelectionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = SelectionTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Selection\Model\Selection object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildSelectionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->collSelectionProducts = null; + + $this->collSelectionContents = null; + + $this->collSelectionImages = null; + + $this->collSelectionContainerAssociatedSelections = null; + + $this->collSelectionI18ns = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see Selection::setDeleted() + * @see Selection::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildSelectionQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(SelectionTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(SelectionTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(SelectionTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + SelectionTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->selectionProductsScheduledForDeletion !== null) { + if (!$this->selectionProductsScheduledForDeletion->isEmpty()) { + \Selection\Model\SelectionProductQuery::create() + ->filterByPrimaryKeys($this->selectionProductsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->selectionProductsScheduledForDeletion = null; + } + } + + if ($this->collSelectionProducts !== null) { + foreach ($this->collSelectionProducts as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->selectionContentsScheduledForDeletion !== null) { + if (!$this->selectionContentsScheduledForDeletion->isEmpty()) { + \Selection\Model\SelectionContentQuery::create() + ->filterByPrimaryKeys($this->selectionContentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->selectionContentsScheduledForDeletion = null; + } + } + + if ($this->collSelectionContents !== null) { + foreach ($this->collSelectionContents as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->selectionImagesScheduledForDeletion !== null) { + if (!$this->selectionImagesScheduledForDeletion->isEmpty()) { + \Selection\Model\SelectionImageQuery::create() + ->filterByPrimaryKeys($this->selectionImagesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->selectionImagesScheduledForDeletion = null; + } + } + + if ($this->collSelectionImages !== null) { + foreach ($this->collSelectionImages as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->selectionContainerAssociatedSelectionsScheduledForDeletion !== null) { + if (!$this->selectionContainerAssociatedSelectionsScheduledForDeletion->isEmpty()) { + \Selection\Model\SelectionContainerAssociatedSelectionQuery::create() + ->filterByPrimaryKeys($this->selectionContainerAssociatedSelectionsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->selectionContainerAssociatedSelectionsScheduledForDeletion = null; + } + } + + if ($this->collSelectionContainerAssociatedSelections !== null) { + foreach ($this->collSelectionContainerAssociatedSelections as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->selectionI18nsScheduledForDeletion !== null) { + if (!$this->selectionI18nsScheduledForDeletion->isEmpty()) { + \Selection\Model\SelectionI18nQuery::create() + ->filterByPrimaryKeys($this->selectionI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->selectionI18nsScheduledForDeletion = null; + } + } + + if ($this->collSelectionI18ns !== null) { + foreach ($this->collSelectionI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[SelectionTableMap::ID] = true; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . SelectionTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(SelectionTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(SelectionTableMap::VISIBLE)) { + $modifiedColumns[':p' . $index++] = 'VISIBLE'; + } + if ($this->isColumnModified(SelectionTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(SelectionTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(SelectionTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO selection (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'VISIBLE': + $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getVisible(); + break; + case 2: + return $this->getPosition(); + break; + case 3: + return $this->getCreatedAt(); + break; + case 4: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['Selection'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['Selection'][$this->getPrimaryKey()] = true; + $keys = SelectionTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getVisible(), + $keys[2] => $this->getPosition(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->collSelectionProducts) { + $result['SelectionProducts'] = $this->collSelectionProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collSelectionContents) { + $result['SelectionContents'] = $this->collSelectionContents->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collSelectionImages) { + $result['SelectionImages'] = $this->collSelectionImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collSelectionContainerAssociatedSelections) { + $result['SelectionContainerAssociatedSelections'] = $this->collSelectionContainerAssociatedSelections->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collSelectionI18ns) { + $result['SelectionI18ns'] = $this->collSelectionI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setVisible($value); + break; + case 2: + $this->setPosition($value); + break; + case 3: + $this->setCreatedAt($value); + break; + case 4: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = SelectionTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setVisible($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(SelectionTableMap::DATABASE_NAME); + + if ($this->isColumnModified(SelectionTableMap::ID)) $criteria->add(SelectionTableMap::ID, $this->id); + if ($this->isColumnModified(SelectionTableMap::VISIBLE)) $criteria->add(SelectionTableMap::VISIBLE, $this->visible); + if ($this->isColumnModified(SelectionTableMap::POSITION)) $criteria->add(SelectionTableMap::POSITION, $this->position); + if ($this->isColumnModified(SelectionTableMap::CREATED_AT)) $criteria->add(SelectionTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(SelectionTableMap::UPDATED_AT)) $criteria->add(SelectionTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(SelectionTableMap::DATABASE_NAME); + $criteria->add(SelectionTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Selection\Model\Selection (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setVisible($this->getVisible()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getSelectionProducts() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addSelectionProduct($relObj->copy($deepCopy)); + } + } + + foreach ($this->getSelectionContents() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addSelectionContent($relObj->copy($deepCopy)); + } + } + + foreach ($this->getSelectionImages() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addSelectionImage($relObj->copy($deepCopy)); + } + } + + foreach ($this->getSelectionContainerAssociatedSelections() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addSelectionContainerAssociatedSelection($relObj->copy($deepCopy)); + } + } + + foreach ($this->getSelectionI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addSelectionI18n($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Selection\Model\Selection Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('SelectionProduct' == $relationName) { + return $this->initSelectionProducts(); + } + if ('SelectionContent' == $relationName) { + return $this->initSelectionContents(); + } + if ('SelectionImage' == $relationName) { + return $this->initSelectionImages(); + } + if ('SelectionContainerAssociatedSelection' == $relationName) { + return $this->initSelectionContainerAssociatedSelections(); + } + if ('SelectionI18n' == $relationName) { + return $this->initSelectionI18ns(); + } + } + + /** + * Clears out the collSelectionProducts collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addSelectionProducts() + */ + public function clearSelectionProducts() + { + $this->collSelectionProducts = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collSelectionProducts collection loaded partially. + */ + public function resetPartialSelectionProducts($v = true) + { + $this->collSelectionProductsPartial = $v; + } + + /** + * Initializes the collSelectionProducts collection. + * + * By default this just sets the collSelectionProducts collection to an empty array (like clearcollSelectionProducts()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initSelectionProducts($overrideExisting = true) + { + if (null !== $this->collSelectionProducts && !$overrideExisting) { + return; + } + $this->collSelectionProducts = new ObjectCollection(); + $this->collSelectionProducts->setModel('\Selection\Model\SelectionProduct'); + } + + /** + * Gets an array of ChildSelectionProduct objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildSelection is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildSelectionProduct[] List of ChildSelectionProduct objects + * @throws PropelException + */ + public function getSelectionProducts($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collSelectionProductsPartial && !$this->isNew(); + if (null === $this->collSelectionProducts || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionProducts) { + // return empty collection + $this->initSelectionProducts(); + } else { + $collSelectionProducts = ChildSelectionProductQuery::create(null, $criteria) + ->filterBySelection($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collSelectionProductsPartial && count($collSelectionProducts)) { + $this->initSelectionProducts(false); + + foreach ($collSelectionProducts as $obj) { + if (false == $this->collSelectionProducts->contains($obj)) { + $this->collSelectionProducts->append($obj); + } + } + + $this->collSelectionProductsPartial = true; + } + + reset($collSelectionProducts); + + return $collSelectionProducts; + } + + if ($partial && $this->collSelectionProducts) { + foreach ($this->collSelectionProducts as $obj) { + if ($obj->isNew()) { + $collSelectionProducts[] = $obj; + } + } + } + + $this->collSelectionProducts = $collSelectionProducts; + $this->collSelectionProductsPartial = false; + } + } + + return $this->collSelectionProducts; + } + + /** + * Sets a collection of SelectionProduct objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $selectionProducts A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildSelection The current object (for fluent API support) + */ + public function setSelectionProducts(Collection $selectionProducts, ConnectionInterface $con = null) + { + $selectionProductsToDelete = $this->getSelectionProducts(new Criteria(), $con)->diff($selectionProducts); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->selectionProductsScheduledForDeletion = clone $selectionProductsToDelete; + + foreach ($selectionProductsToDelete as $selectionProductRemoved) { + $selectionProductRemoved->setSelection(null); + } + + $this->collSelectionProducts = null; + foreach ($selectionProducts as $selectionProduct) { + $this->addSelectionProduct($selectionProduct); + } + + $this->collSelectionProducts = $selectionProducts; + $this->collSelectionProductsPartial = false; + + return $this; + } + + /** + * Returns the number of related SelectionProduct objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related SelectionProduct objects. + * @throws PropelException + */ + public function countSelectionProducts(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collSelectionProductsPartial && !$this->isNew(); + if (null === $this->collSelectionProducts || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionProducts) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getSelectionProducts()); + } + + $query = ChildSelectionProductQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterBySelection($this) + ->count($con); + } + + return count($this->collSelectionProducts); + } + + /** + * Method called to associate a ChildSelectionProduct object to this object + * through the ChildSelectionProduct foreign key attribute. + * + * @param ChildSelectionProduct $l ChildSelectionProduct + * @return \Selection\Model\Selection The current object (for fluent API support) + */ + public function addSelectionProduct(ChildSelectionProduct $l) + { + if ($this->collSelectionProducts === null) { + $this->initSelectionProducts(); + $this->collSelectionProductsPartial = true; + } + + if (!in_array($l, $this->collSelectionProducts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddSelectionProduct($l); + } + + return $this; + } + + /** + * @param SelectionProduct $selectionProduct The selectionProduct object to add. + */ + protected function doAddSelectionProduct($selectionProduct) + { + $this->collSelectionProducts[]= $selectionProduct; + $selectionProduct->setSelection($this); + } + + /** + * @param SelectionProduct $selectionProduct The selectionProduct object to remove. + * @return ChildSelection The current object (for fluent API support) + */ + public function removeSelectionProduct($selectionProduct) + { + if ($this->getSelectionProducts()->contains($selectionProduct)) { + $this->collSelectionProducts->remove($this->collSelectionProducts->search($selectionProduct)); + if (null === $this->selectionProductsScheduledForDeletion) { + $this->selectionProductsScheduledForDeletion = clone $this->collSelectionProducts; + $this->selectionProductsScheduledForDeletion->clear(); + } + $this->selectionProductsScheduledForDeletion[]= clone $selectionProduct; + $selectionProduct->setSelection(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Selection is new, it will return + * an empty collection; or if this Selection has previously + * been saved, it will retrieve related SelectionProducts 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 Selection. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildSelectionProduct[] List of ChildSelectionProduct objects + */ + public function getSelectionProductsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildSelectionProductQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); + + return $this->getSelectionProducts($query, $con); + } + + /** + * Clears out the collSelectionContents collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addSelectionContents() + */ + public function clearSelectionContents() + { + $this->collSelectionContents = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collSelectionContents collection loaded partially. + */ + public function resetPartialSelectionContents($v = true) + { + $this->collSelectionContentsPartial = $v; + } + + /** + * Initializes the collSelectionContents collection. + * + * By default this just sets the collSelectionContents collection to an empty array (like clearcollSelectionContents()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initSelectionContents($overrideExisting = true) + { + if (null !== $this->collSelectionContents && !$overrideExisting) { + return; + } + $this->collSelectionContents = new ObjectCollection(); + $this->collSelectionContents->setModel('\Selection\Model\SelectionContent'); + } + + /** + * Gets an array of ChildSelectionContent objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildSelection is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildSelectionContent[] List of ChildSelectionContent objects + * @throws PropelException + */ + public function getSelectionContents($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collSelectionContentsPartial && !$this->isNew(); + if (null === $this->collSelectionContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionContents) { + // return empty collection + $this->initSelectionContents(); + } else { + $collSelectionContents = ChildSelectionContentQuery::create(null, $criteria) + ->filterBySelection($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collSelectionContentsPartial && count($collSelectionContents)) { + $this->initSelectionContents(false); + + foreach ($collSelectionContents as $obj) { + if (false == $this->collSelectionContents->contains($obj)) { + $this->collSelectionContents->append($obj); + } + } + + $this->collSelectionContentsPartial = true; + } + + reset($collSelectionContents); + + return $collSelectionContents; + } + + if ($partial && $this->collSelectionContents) { + foreach ($this->collSelectionContents as $obj) { + if ($obj->isNew()) { + $collSelectionContents[] = $obj; + } + } + } + + $this->collSelectionContents = $collSelectionContents; + $this->collSelectionContentsPartial = false; + } + } + + return $this->collSelectionContents; + } + + /** + * Sets a collection of SelectionContent objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $selectionContents A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildSelection The current object (for fluent API support) + */ + public function setSelectionContents(Collection $selectionContents, ConnectionInterface $con = null) + { + $selectionContentsToDelete = $this->getSelectionContents(new Criteria(), $con)->diff($selectionContents); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->selectionContentsScheduledForDeletion = clone $selectionContentsToDelete; + + foreach ($selectionContentsToDelete as $selectionContentRemoved) { + $selectionContentRemoved->setSelection(null); + } + + $this->collSelectionContents = null; + foreach ($selectionContents as $selectionContent) { + $this->addSelectionContent($selectionContent); + } + + $this->collSelectionContents = $selectionContents; + $this->collSelectionContentsPartial = false; + + return $this; + } + + /** + * Returns the number of related SelectionContent objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related SelectionContent objects. + * @throws PropelException + */ + public function countSelectionContents(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collSelectionContentsPartial && !$this->isNew(); + if (null === $this->collSelectionContents || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionContents) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getSelectionContents()); + } + + $query = ChildSelectionContentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterBySelection($this) + ->count($con); + } + + return count($this->collSelectionContents); + } + + /** + * Method called to associate a ChildSelectionContent object to this object + * through the ChildSelectionContent foreign key attribute. + * + * @param ChildSelectionContent $l ChildSelectionContent + * @return \Selection\Model\Selection The current object (for fluent API support) + */ + public function addSelectionContent(ChildSelectionContent $l) + { + if ($this->collSelectionContents === null) { + $this->initSelectionContents(); + $this->collSelectionContentsPartial = true; + } + + if (!in_array($l, $this->collSelectionContents->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddSelectionContent($l); + } + + return $this; + } + + /** + * @param SelectionContent $selectionContent The selectionContent object to add. + */ + protected function doAddSelectionContent($selectionContent) + { + $this->collSelectionContents[]= $selectionContent; + $selectionContent->setSelection($this); + } + + /** + * @param SelectionContent $selectionContent The selectionContent object to remove. + * @return ChildSelection The current object (for fluent API support) + */ + public function removeSelectionContent($selectionContent) + { + if ($this->getSelectionContents()->contains($selectionContent)) { + $this->collSelectionContents->remove($this->collSelectionContents->search($selectionContent)); + if (null === $this->selectionContentsScheduledForDeletion) { + $this->selectionContentsScheduledForDeletion = clone $this->collSelectionContents; + $this->selectionContentsScheduledForDeletion->clear(); + } + $this->selectionContentsScheduledForDeletion[]= clone $selectionContent; + $selectionContent->setSelection(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Selection is new, it will return + * an empty collection; or if this Selection has previously + * been saved, it will retrieve related SelectionContents 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 Selection. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildSelectionContent[] List of ChildSelectionContent objects + */ + public function getSelectionContentsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildSelectionContentQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); + + return $this->getSelectionContents($query, $con); + } + + /** + * Clears out the collSelectionImages collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addSelectionImages() + */ + public function clearSelectionImages() + { + $this->collSelectionImages = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collSelectionImages collection loaded partially. + */ + public function resetPartialSelectionImages($v = true) + { + $this->collSelectionImagesPartial = $v; + } + + /** + * Initializes the collSelectionImages collection. + * + * By default this just sets the collSelectionImages collection to an empty array (like clearcollSelectionImages()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initSelectionImages($overrideExisting = true) + { + if (null !== $this->collSelectionImages && !$overrideExisting) { + return; + } + $this->collSelectionImages = new ObjectCollection(); + $this->collSelectionImages->setModel('\Selection\Model\SelectionImage'); + } + + /** + * Gets an array of ChildSelectionImage objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildSelection is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildSelectionImage[] List of ChildSelectionImage objects + * @throws PropelException + */ + public function getSelectionImages($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collSelectionImagesPartial && !$this->isNew(); + if (null === $this->collSelectionImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionImages) { + // return empty collection + $this->initSelectionImages(); + } else { + $collSelectionImages = ChildSelectionImageQuery::create(null, $criteria) + ->filterBySelection($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collSelectionImagesPartial && count($collSelectionImages)) { + $this->initSelectionImages(false); + + foreach ($collSelectionImages as $obj) { + if (false == $this->collSelectionImages->contains($obj)) { + $this->collSelectionImages->append($obj); + } + } + + $this->collSelectionImagesPartial = true; + } + + reset($collSelectionImages); + + return $collSelectionImages; + } + + if ($partial && $this->collSelectionImages) { + foreach ($this->collSelectionImages as $obj) { + if ($obj->isNew()) { + $collSelectionImages[] = $obj; + } + } + } + + $this->collSelectionImages = $collSelectionImages; + $this->collSelectionImagesPartial = false; + } + } + + return $this->collSelectionImages; + } + + /** + * Sets a collection of SelectionImage objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $selectionImages A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildSelection The current object (for fluent API support) + */ + public function setSelectionImages(Collection $selectionImages, ConnectionInterface $con = null) + { + $selectionImagesToDelete = $this->getSelectionImages(new Criteria(), $con)->diff($selectionImages); + + + $this->selectionImagesScheduledForDeletion = $selectionImagesToDelete; + + foreach ($selectionImagesToDelete as $selectionImageRemoved) { + $selectionImageRemoved->setSelection(null); + } + + $this->collSelectionImages = null; + foreach ($selectionImages as $selectionImage) { + $this->addSelectionImage($selectionImage); + } + + $this->collSelectionImages = $selectionImages; + $this->collSelectionImagesPartial = false; + + return $this; + } + + /** + * Returns the number of related SelectionImage objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related SelectionImage objects. + * @throws PropelException + */ + public function countSelectionImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collSelectionImagesPartial && !$this->isNew(); + if (null === $this->collSelectionImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionImages) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getSelectionImages()); + } + + $query = ChildSelectionImageQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterBySelection($this) + ->count($con); + } + + return count($this->collSelectionImages); + } + + /** + * Method called to associate a ChildSelectionImage object to this object + * through the ChildSelectionImage foreign key attribute. + * + * @param ChildSelectionImage $l ChildSelectionImage + * @return \Selection\Model\Selection The current object (for fluent API support) + */ + public function addSelectionImage(ChildSelectionImage $l) + { + if ($this->collSelectionImages === null) { + $this->initSelectionImages(); + $this->collSelectionImagesPartial = true; + } + + if (!in_array($l, $this->collSelectionImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddSelectionImage($l); + } + + return $this; + } + + /** + * @param SelectionImage $selectionImage The selectionImage object to add. + */ + protected function doAddSelectionImage($selectionImage) + { + $this->collSelectionImages[]= $selectionImage; + $selectionImage->setSelection($this); + } + + /** + * @param SelectionImage $selectionImage The selectionImage object to remove. + * @return ChildSelection The current object (for fluent API support) + */ + public function removeSelectionImage($selectionImage) + { + if ($this->getSelectionImages()->contains($selectionImage)) { + $this->collSelectionImages->remove($this->collSelectionImages->search($selectionImage)); + if (null === $this->selectionImagesScheduledForDeletion) { + $this->selectionImagesScheduledForDeletion = clone $this->collSelectionImages; + $this->selectionImagesScheduledForDeletion->clear(); + } + $this->selectionImagesScheduledForDeletion[]= clone $selectionImage; + $selectionImage->setSelection(null); + } + + return $this; + } + + /** + * Clears out the collSelectionContainerAssociatedSelections collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addSelectionContainerAssociatedSelections() + */ + public function clearSelectionContainerAssociatedSelections() + { + $this->collSelectionContainerAssociatedSelections = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collSelectionContainerAssociatedSelections collection loaded partially. + */ + public function resetPartialSelectionContainerAssociatedSelections($v = true) + { + $this->collSelectionContainerAssociatedSelectionsPartial = $v; + } + + /** + * Initializes the collSelectionContainerAssociatedSelections collection. + * + * By default this just sets the collSelectionContainerAssociatedSelections collection to an empty array (like clearcollSelectionContainerAssociatedSelections()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initSelectionContainerAssociatedSelections($overrideExisting = true) + { + if (null !== $this->collSelectionContainerAssociatedSelections && !$overrideExisting) { + return; + } + $this->collSelectionContainerAssociatedSelections = new ObjectCollection(); + $this->collSelectionContainerAssociatedSelections->setModel('\Selection\Model\SelectionContainerAssociatedSelection'); + } + + /** + * Gets an array of ChildSelectionContainerAssociatedSelection objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildSelection is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildSelectionContainerAssociatedSelection[] List of ChildSelectionContainerAssociatedSelection objects + * @throws PropelException + */ + public function getSelectionContainerAssociatedSelections($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collSelectionContainerAssociatedSelectionsPartial && !$this->isNew(); + if (null === $this->collSelectionContainerAssociatedSelections || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionContainerAssociatedSelections) { + // return empty collection + $this->initSelectionContainerAssociatedSelections(); + } else { + $collSelectionContainerAssociatedSelections = ChildSelectionContainerAssociatedSelectionQuery::create(null, $criteria) + ->filterBySelection($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collSelectionContainerAssociatedSelectionsPartial && count($collSelectionContainerAssociatedSelections)) { + $this->initSelectionContainerAssociatedSelections(false); + + foreach ($collSelectionContainerAssociatedSelections as $obj) { + if (false == $this->collSelectionContainerAssociatedSelections->contains($obj)) { + $this->collSelectionContainerAssociatedSelections->append($obj); + } + } + + $this->collSelectionContainerAssociatedSelectionsPartial = true; + } + + reset($collSelectionContainerAssociatedSelections); + + return $collSelectionContainerAssociatedSelections; + } + + if ($partial && $this->collSelectionContainerAssociatedSelections) { + foreach ($this->collSelectionContainerAssociatedSelections as $obj) { + if ($obj->isNew()) { + $collSelectionContainerAssociatedSelections[] = $obj; + } + } + } + + $this->collSelectionContainerAssociatedSelections = $collSelectionContainerAssociatedSelections; + $this->collSelectionContainerAssociatedSelectionsPartial = false; + } + } + + return $this->collSelectionContainerAssociatedSelections; + } + + /** + * Sets a collection of SelectionContainerAssociatedSelection objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $selectionContainerAssociatedSelections A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildSelection The current object (for fluent API support) + */ + public function setSelectionContainerAssociatedSelections(Collection $selectionContainerAssociatedSelections, ConnectionInterface $con = null) + { + $selectionContainerAssociatedSelectionsToDelete = $this->getSelectionContainerAssociatedSelections(new Criteria(), $con)->diff($selectionContainerAssociatedSelections); + + + $this->selectionContainerAssociatedSelectionsScheduledForDeletion = $selectionContainerAssociatedSelectionsToDelete; + + foreach ($selectionContainerAssociatedSelectionsToDelete as $selectionContainerAssociatedSelectionRemoved) { + $selectionContainerAssociatedSelectionRemoved->setSelection(null); + } + + $this->collSelectionContainerAssociatedSelections = null; + foreach ($selectionContainerAssociatedSelections as $selectionContainerAssociatedSelection) { + $this->addSelectionContainerAssociatedSelection($selectionContainerAssociatedSelection); + } + + $this->collSelectionContainerAssociatedSelections = $selectionContainerAssociatedSelections; + $this->collSelectionContainerAssociatedSelectionsPartial = false; + + return $this; + } + + /** + * Returns the number of related SelectionContainerAssociatedSelection objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related SelectionContainerAssociatedSelection objects. + * @throws PropelException + */ + public function countSelectionContainerAssociatedSelections(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collSelectionContainerAssociatedSelectionsPartial && !$this->isNew(); + if (null === $this->collSelectionContainerAssociatedSelections || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionContainerAssociatedSelections) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getSelectionContainerAssociatedSelections()); + } + + $query = ChildSelectionContainerAssociatedSelectionQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterBySelection($this) + ->count($con); + } + + return count($this->collSelectionContainerAssociatedSelections); + } + + /** + * Method called to associate a ChildSelectionContainerAssociatedSelection object to this object + * through the ChildSelectionContainerAssociatedSelection foreign key attribute. + * + * @param ChildSelectionContainerAssociatedSelection $l ChildSelectionContainerAssociatedSelection + * @return \Selection\Model\Selection The current object (for fluent API support) + */ + public function addSelectionContainerAssociatedSelection(ChildSelectionContainerAssociatedSelection $l) + { + if ($this->collSelectionContainerAssociatedSelections === null) { + $this->initSelectionContainerAssociatedSelections(); + $this->collSelectionContainerAssociatedSelectionsPartial = true; + } + + if (!in_array($l, $this->collSelectionContainerAssociatedSelections->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddSelectionContainerAssociatedSelection($l); + } + + return $this; + } + + /** + * @param SelectionContainerAssociatedSelection $selectionContainerAssociatedSelection The selectionContainerAssociatedSelection object to add. + */ + protected function doAddSelectionContainerAssociatedSelection($selectionContainerAssociatedSelection) + { + $this->collSelectionContainerAssociatedSelections[]= $selectionContainerAssociatedSelection; + $selectionContainerAssociatedSelection->setSelection($this); + } + + /** + * @param SelectionContainerAssociatedSelection $selectionContainerAssociatedSelection The selectionContainerAssociatedSelection object to remove. + * @return ChildSelection The current object (for fluent API support) + */ + public function removeSelectionContainerAssociatedSelection($selectionContainerAssociatedSelection) + { + if ($this->getSelectionContainerAssociatedSelections()->contains($selectionContainerAssociatedSelection)) { + $this->collSelectionContainerAssociatedSelections->remove($this->collSelectionContainerAssociatedSelections->search($selectionContainerAssociatedSelection)); + if (null === $this->selectionContainerAssociatedSelectionsScheduledForDeletion) { + $this->selectionContainerAssociatedSelectionsScheduledForDeletion = clone $this->collSelectionContainerAssociatedSelections; + $this->selectionContainerAssociatedSelectionsScheduledForDeletion->clear(); + } + $this->selectionContainerAssociatedSelectionsScheduledForDeletion[]= clone $selectionContainerAssociatedSelection; + $selectionContainerAssociatedSelection->setSelection(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Selection is new, it will return + * an empty collection; or if this Selection has previously + * been saved, it will retrieve related SelectionContainerAssociatedSelections 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 Selection. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildSelectionContainerAssociatedSelection[] List of ChildSelectionContainerAssociatedSelection objects + */ + public function getSelectionContainerAssociatedSelectionsJoinSelectionContainer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildSelectionContainerAssociatedSelectionQuery::create(null, $criteria); + $query->joinWith('SelectionContainer', $joinBehavior); + + return $this->getSelectionContainerAssociatedSelections($query, $con); + } + + /** + * Clears out the collSelectionI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addSelectionI18ns() + */ + public function clearSelectionI18ns() + { + $this->collSelectionI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collSelectionI18ns collection loaded partially. + */ + public function resetPartialSelectionI18ns($v = true) + { + $this->collSelectionI18nsPartial = $v; + } + + /** + * Initializes the collSelectionI18ns collection. + * + * By default this just sets the collSelectionI18ns collection to an empty array (like clearcollSelectionI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initSelectionI18ns($overrideExisting = true) + { + if (null !== $this->collSelectionI18ns && !$overrideExisting) { + return; + } + $this->collSelectionI18ns = new ObjectCollection(); + $this->collSelectionI18ns->setModel('\Selection\Model\SelectionI18n'); + } + + /** + * Gets an array of ChildSelectionI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildSelection is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildSelectionI18n[] List of ChildSelectionI18n objects + * @throws PropelException + */ + public function getSelectionI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collSelectionI18nsPartial && !$this->isNew(); + if (null === $this->collSelectionI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionI18ns) { + // return empty collection + $this->initSelectionI18ns(); + } else { + $collSelectionI18ns = ChildSelectionI18nQuery::create(null, $criteria) + ->filterBySelection($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collSelectionI18nsPartial && count($collSelectionI18ns)) { + $this->initSelectionI18ns(false); + + foreach ($collSelectionI18ns as $obj) { + if (false == $this->collSelectionI18ns->contains($obj)) { + $this->collSelectionI18ns->append($obj); + } + } + + $this->collSelectionI18nsPartial = true; + } + + reset($collSelectionI18ns); + + return $collSelectionI18ns; + } + + if ($partial && $this->collSelectionI18ns) { + foreach ($this->collSelectionI18ns as $obj) { + if ($obj->isNew()) { + $collSelectionI18ns[] = $obj; + } + } + } + + $this->collSelectionI18ns = $collSelectionI18ns; + $this->collSelectionI18nsPartial = false; + } + } + + return $this->collSelectionI18ns; + } + + /** + * Sets a collection of SelectionI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $selectionI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildSelection The current object (for fluent API support) + */ + public function setSelectionI18ns(Collection $selectionI18ns, ConnectionInterface $con = null) + { + $selectionI18nsToDelete = $this->getSelectionI18ns(new Criteria(), $con)->diff($selectionI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->selectionI18nsScheduledForDeletion = clone $selectionI18nsToDelete; + + foreach ($selectionI18nsToDelete as $selectionI18nRemoved) { + $selectionI18nRemoved->setSelection(null); + } + + $this->collSelectionI18ns = null; + foreach ($selectionI18ns as $selectionI18n) { + $this->addSelectionI18n($selectionI18n); + } + + $this->collSelectionI18ns = $selectionI18ns; + $this->collSelectionI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related SelectionI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related SelectionI18n objects. + * @throws PropelException + */ + public function countSelectionI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collSelectionI18nsPartial && !$this->isNew(); + if (null === $this->collSelectionI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getSelectionI18ns()); + } + + $query = ChildSelectionI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterBySelection($this) + ->count($con); + } + + return count($this->collSelectionI18ns); + } + + /** + * Method called to associate a ChildSelectionI18n object to this object + * through the ChildSelectionI18n foreign key attribute. + * + * @param ChildSelectionI18n $l ChildSelectionI18n + * @return \Selection\Model\Selection The current object (for fluent API support) + */ + public function addSelectionI18n(ChildSelectionI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collSelectionI18ns === null) { + $this->initSelectionI18ns(); + $this->collSelectionI18nsPartial = true; + } + + if (!in_array($l, $this->collSelectionI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddSelectionI18n($l); + } + + return $this; + } + + /** + * @param SelectionI18n $selectionI18n The selectionI18n object to add. + */ + protected function doAddSelectionI18n($selectionI18n) + { + $this->collSelectionI18ns[]= $selectionI18n; + $selectionI18n->setSelection($this); + } + + /** + * @param SelectionI18n $selectionI18n The selectionI18n object to remove. + * @return ChildSelection The current object (for fluent API support) + */ + public function removeSelectionI18n($selectionI18n) + { + if ($this->getSelectionI18ns()->contains($selectionI18n)) { + $this->collSelectionI18ns->remove($this->collSelectionI18ns->search($selectionI18n)); + if (null === $this->selectionI18nsScheduledForDeletion) { + $this->selectionI18nsScheduledForDeletion = clone $this->collSelectionI18ns; + $this->selectionI18nsScheduledForDeletion->clear(); + } + $this->selectionI18nsScheduledForDeletion[]= clone $selectionI18n; + $selectionI18n->setSelection(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->visible = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collSelectionProducts) { + foreach ($this->collSelectionProducts as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collSelectionContents) { + foreach ($this->collSelectionContents as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collSelectionImages) { + foreach ($this->collSelectionImages as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collSelectionContainerAssociatedSelections) { + foreach ($this->collSelectionContainerAssociatedSelections as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collSelectionI18ns) { + foreach ($this->collSelectionI18ns as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + // i18n behavior + $this->currentLocale = 'en_US'; + $this->currentTranslations = null; + + $this->collSelectionProducts = null; + $this->collSelectionContents = null; + $this->collSelectionImages = null; + $this->collSelectionContainerAssociatedSelections = null; + $this->collSelectionI18ns = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(SelectionTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildSelection The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[SelectionTableMap::UPDATED_AT] = true; + + return $this; + } + + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildSelection The current object (for fluent API support) + */ + public function setLocale($locale = 'en_US') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionI18n */ + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collSelectionI18ns) { + foreach ($this->collSelectionI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildSelectionI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildSelectionI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addSelectionI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelection The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildSelectionI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collSelectionI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collSelectionI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + return $this->getCurrentTranslation()->getTitle(); + } + + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setTitle($v) + { $this->getCurrentTranslation()->setTitle($v); + + return $this; + } + + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + return $this->getCurrentTranslation()->getDescription(); + } + + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setDescription($v) + { $this->getCurrentTranslation()->setDescription($v); + + return $this; + } + + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + return $this->getCurrentTranslation()->getChapo(); + } + + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setChapo($v) + { $this->getCurrentTranslation()->setChapo($v); + + return $this; + } + + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + return $this->getCurrentTranslation()->getPostscriptum(); + } + + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { $this->getCurrentTranslation()->setPostscriptum($v); + + return $this; + } + + + /** + * Get the [meta_title] column value. + * + * @return string + */ + public function getMetaTitle() + { + return $this->getCurrentTranslation()->getMetaTitle(); + } + + + /** + * Set the value of [meta_title] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setMetaTitle($v) + { $this->getCurrentTranslation()->setMetaTitle($v); + + return $this; + } + + + /** + * Get the [meta_description] column value. + * + * @return string + */ + public function getMetaDescription() + { + return $this->getCurrentTranslation()->getMetaDescription(); + } + + + /** + * Set the value of [meta_description] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setMetaDescription($v) + { $this->getCurrentTranslation()->setMetaDescription($v); + + return $this; + } + + + /** + * Get the [meta_keywords] column value. + * + * @return string + */ + public function getMetaKeywords() + { + return $this->getCurrentTranslation()->getMetaKeywords(); + } + + + /** + * Set the value of [meta_keywords] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setMetaKeywords($v) + { $this->getCurrentTranslation()->setMetaKeywords($v); + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/Selection/Model/Base/SelectionContainer.php b/local/modules/Selection/Model/Base/SelectionContainer.php new file mode 100644 index 00000000..ffd3e35f --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionContainer.php @@ -0,0 +1,2484 @@ +modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another SelectionContainer instance. If + * obj is an instance of SelectionContainer, delegates to + * equals(SelectionContainer). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return SelectionContainer The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return SelectionContainer The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [visible] column value. + * + * @return int + */ + public function getVisible() + { + + return $this->visible; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContainer The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[SelectionContainerTableMap::ID] = true; + } + + + return $this; + } // setId() + + /** + * Set the value of [visible] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContainer The current object (for fluent API support) + */ + public function setVisible($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->visible !== $v) { + $this->visible = $v; + $this->modifiedColumns[SelectionContainerTableMap::VISIBLE] = true; + } + + + return $this; + } // setVisible() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContainer The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[SelectionContainerTableMap::POSITION] = true; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Selection\Model\SelectionContainer The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[SelectionContainerTableMap::CREATED_AT] = true; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Selection\Model\SelectionContainer The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[SelectionContainerTableMap::UPDATED_AT] = true; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : SelectionContainerTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : SelectionContainerTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $this->visible = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : SelectionContainerTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : SelectionContainerTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : SelectionContainerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = SelectionContainerTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Selection\Model\SelectionContainer object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionContainerTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildSelectionContainerQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->collSelectionContainerAssociatedSelections = null; + + $this->collSelectionContainerImages = null; + + $this->collSelectionContainerI18ns = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see SelectionContainer::setDeleted() + * @see SelectionContainer::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildSelectionContainerQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(SelectionContainerTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(SelectionContainerTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(SelectionContainerTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + SelectionContainerTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->selectionContainerAssociatedSelectionsScheduledForDeletion !== null) { + if (!$this->selectionContainerAssociatedSelectionsScheduledForDeletion->isEmpty()) { + \Selection\Model\SelectionContainerAssociatedSelectionQuery::create() + ->filterByPrimaryKeys($this->selectionContainerAssociatedSelectionsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->selectionContainerAssociatedSelectionsScheduledForDeletion = null; + } + } + + if ($this->collSelectionContainerAssociatedSelections !== null) { + foreach ($this->collSelectionContainerAssociatedSelections as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->selectionContainerImagesScheduledForDeletion !== null) { + if (!$this->selectionContainerImagesScheduledForDeletion->isEmpty()) { + \Selection\Model\SelectionContainerImageQuery::create() + ->filterByPrimaryKeys($this->selectionContainerImagesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->selectionContainerImagesScheduledForDeletion = null; + } + } + + if ($this->collSelectionContainerImages !== null) { + foreach ($this->collSelectionContainerImages as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->selectionContainerI18nsScheduledForDeletion !== null) { + if (!$this->selectionContainerI18nsScheduledForDeletion->isEmpty()) { + \Selection\Model\SelectionContainerI18nQuery::create() + ->filterByPrimaryKeys($this->selectionContainerI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->selectionContainerI18nsScheduledForDeletion = null; + } + } + + if ($this->collSelectionContainerI18ns !== null) { + foreach ($this->collSelectionContainerI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[SelectionContainerTableMap::ID] = true; + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(SelectionContainerTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(SelectionContainerTableMap::VISIBLE)) { + $modifiedColumns[':p' . $index++] = 'VISIBLE'; + } + if ($this->isColumnModified(SelectionContainerTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(SelectionContainerTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(SelectionContainerTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO selection_container (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'VISIBLE': + $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + if ($pk !== null) { + $this->setId($pk); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionContainerTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getVisible(); + break; + case 2: + return $this->getPosition(); + break; + case 3: + return $this->getCreatedAt(); + break; + case 4: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['SelectionContainer'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['SelectionContainer'][$this->getPrimaryKey()] = true; + $keys = SelectionContainerTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getVisible(), + $keys[2] => $this->getPosition(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->collSelectionContainerAssociatedSelections) { + $result['SelectionContainerAssociatedSelections'] = $this->collSelectionContainerAssociatedSelections->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collSelectionContainerImages) { + $result['SelectionContainerImages'] = $this->collSelectionContainerImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collSelectionContainerI18ns) { + $result['SelectionContainerI18ns'] = $this->collSelectionContainerI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionContainerTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setVisible($value); + break; + case 2: + $this->setPosition($value); + break; + case 3: + $this->setCreatedAt($value); + break; + case 4: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = SelectionContainerTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setVisible($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(SelectionContainerTableMap::DATABASE_NAME); + + if ($this->isColumnModified(SelectionContainerTableMap::ID)) $criteria->add(SelectionContainerTableMap::ID, $this->id); + if ($this->isColumnModified(SelectionContainerTableMap::VISIBLE)) $criteria->add(SelectionContainerTableMap::VISIBLE, $this->visible); + if ($this->isColumnModified(SelectionContainerTableMap::POSITION)) $criteria->add(SelectionContainerTableMap::POSITION, $this->position); + if ($this->isColumnModified(SelectionContainerTableMap::CREATED_AT)) $criteria->add(SelectionContainerTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(SelectionContainerTableMap::UPDATED_AT)) $criteria->add(SelectionContainerTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(SelectionContainerTableMap::DATABASE_NAME); + $criteria->add(SelectionContainerTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Selection\Model\SelectionContainer (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setVisible($this->getVisible()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getSelectionContainerAssociatedSelections() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addSelectionContainerAssociatedSelection($relObj->copy($deepCopy)); + } + } + + foreach ($this->getSelectionContainerImages() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addSelectionContainerImage($relObj->copy($deepCopy)); + } + } + + foreach ($this->getSelectionContainerI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addSelectionContainerI18n($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Selection\Model\SelectionContainer Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('SelectionContainerAssociatedSelection' == $relationName) { + return $this->initSelectionContainerAssociatedSelections(); + } + if ('SelectionContainerImage' == $relationName) { + return $this->initSelectionContainerImages(); + } + if ('SelectionContainerI18n' == $relationName) { + return $this->initSelectionContainerI18ns(); + } + } + + /** + * Clears out the collSelectionContainerAssociatedSelections collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addSelectionContainerAssociatedSelections() + */ + public function clearSelectionContainerAssociatedSelections() + { + $this->collSelectionContainerAssociatedSelections = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collSelectionContainerAssociatedSelections collection loaded partially. + */ + public function resetPartialSelectionContainerAssociatedSelections($v = true) + { + $this->collSelectionContainerAssociatedSelectionsPartial = $v; + } + + /** + * Initializes the collSelectionContainerAssociatedSelections collection. + * + * By default this just sets the collSelectionContainerAssociatedSelections collection to an empty array (like clearcollSelectionContainerAssociatedSelections()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initSelectionContainerAssociatedSelections($overrideExisting = true) + { + if (null !== $this->collSelectionContainerAssociatedSelections && !$overrideExisting) { + return; + } + $this->collSelectionContainerAssociatedSelections = new ObjectCollection(); + $this->collSelectionContainerAssociatedSelections->setModel('\Selection\Model\SelectionContainerAssociatedSelection'); + } + + /** + * Gets an array of ChildSelectionContainerAssociatedSelection objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildSelectionContainer is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildSelectionContainerAssociatedSelection[] List of ChildSelectionContainerAssociatedSelection objects + * @throws PropelException + */ + public function getSelectionContainerAssociatedSelections($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collSelectionContainerAssociatedSelectionsPartial && !$this->isNew(); + if (null === $this->collSelectionContainerAssociatedSelections || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionContainerAssociatedSelections) { + // return empty collection + $this->initSelectionContainerAssociatedSelections(); + } else { + $collSelectionContainerAssociatedSelections = ChildSelectionContainerAssociatedSelectionQuery::create(null, $criteria) + ->filterBySelectionContainer($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collSelectionContainerAssociatedSelectionsPartial && count($collSelectionContainerAssociatedSelections)) { + $this->initSelectionContainerAssociatedSelections(false); + + foreach ($collSelectionContainerAssociatedSelections as $obj) { + if (false == $this->collSelectionContainerAssociatedSelections->contains($obj)) { + $this->collSelectionContainerAssociatedSelections->append($obj); + } + } + + $this->collSelectionContainerAssociatedSelectionsPartial = true; + } + + reset($collSelectionContainerAssociatedSelections); + + return $collSelectionContainerAssociatedSelections; + } + + if ($partial && $this->collSelectionContainerAssociatedSelections) { + foreach ($this->collSelectionContainerAssociatedSelections as $obj) { + if ($obj->isNew()) { + $collSelectionContainerAssociatedSelections[] = $obj; + } + } + } + + $this->collSelectionContainerAssociatedSelections = $collSelectionContainerAssociatedSelections; + $this->collSelectionContainerAssociatedSelectionsPartial = false; + } + } + + return $this->collSelectionContainerAssociatedSelections; + } + + /** + * Sets a collection of SelectionContainerAssociatedSelection objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $selectionContainerAssociatedSelections A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildSelectionContainer The current object (for fluent API support) + */ + public function setSelectionContainerAssociatedSelections(Collection $selectionContainerAssociatedSelections, ConnectionInterface $con = null) + { + $selectionContainerAssociatedSelectionsToDelete = $this->getSelectionContainerAssociatedSelections(new Criteria(), $con)->diff($selectionContainerAssociatedSelections); + + + $this->selectionContainerAssociatedSelectionsScheduledForDeletion = $selectionContainerAssociatedSelectionsToDelete; + + foreach ($selectionContainerAssociatedSelectionsToDelete as $selectionContainerAssociatedSelectionRemoved) { + $selectionContainerAssociatedSelectionRemoved->setSelectionContainer(null); + } + + $this->collSelectionContainerAssociatedSelections = null; + foreach ($selectionContainerAssociatedSelections as $selectionContainerAssociatedSelection) { + $this->addSelectionContainerAssociatedSelection($selectionContainerAssociatedSelection); + } + + $this->collSelectionContainerAssociatedSelections = $selectionContainerAssociatedSelections; + $this->collSelectionContainerAssociatedSelectionsPartial = false; + + return $this; + } + + /** + * Returns the number of related SelectionContainerAssociatedSelection objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related SelectionContainerAssociatedSelection objects. + * @throws PropelException + */ + public function countSelectionContainerAssociatedSelections(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collSelectionContainerAssociatedSelectionsPartial && !$this->isNew(); + if (null === $this->collSelectionContainerAssociatedSelections || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionContainerAssociatedSelections) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getSelectionContainerAssociatedSelections()); + } + + $query = ChildSelectionContainerAssociatedSelectionQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterBySelectionContainer($this) + ->count($con); + } + + return count($this->collSelectionContainerAssociatedSelections); + } + + /** + * Method called to associate a ChildSelectionContainerAssociatedSelection object to this object + * through the ChildSelectionContainerAssociatedSelection foreign key attribute. + * + * @param ChildSelectionContainerAssociatedSelection $l ChildSelectionContainerAssociatedSelection + * @return \Selection\Model\SelectionContainer The current object (for fluent API support) + */ + public function addSelectionContainerAssociatedSelection(ChildSelectionContainerAssociatedSelection $l) + { + if ($this->collSelectionContainerAssociatedSelections === null) { + $this->initSelectionContainerAssociatedSelections(); + $this->collSelectionContainerAssociatedSelectionsPartial = true; + } + + if (!in_array($l, $this->collSelectionContainerAssociatedSelections->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddSelectionContainerAssociatedSelection($l); + } + + return $this; + } + + /** + * @param SelectionContainerAssociatedSelection $selectionContainerAssociatedSelection The selectionContainerAssociatedSelection object to add. + */ + protected function doAddSelectionContainerAssociatedSelection($selectionContainerAssociatedSelection) + { + $this->collSelectionContainerAssociatedSelections[]= $selectionContainerAssociatedSelection; + $selectionContainerAssociatedSelection->setSelectionContainer($this); + } + + /** + * @param SelectionContainerAssociatedSelection $selectionContainerAssociatedSelection The selectionContainerAssociatedSelection object to remove. + * @return ChildSelectionContainer The current object (for fluent API support) + */ + public function removeSelectionContainerAssociatedSelection($selectionContainerAssociatedSelection) + { + if ($this->getSelectionContainerAssociatedSelections()->contains($selectionContainerAssociatedSelection)) { + $this->collSelectionContainerAssociatedSelections->remove($this->collSelectionContainerAssociatedSelections->search($selectionContainerAssociatedSelection)); + if (null === $this->selectionContainerAssociatedSelectionsScheduledForDeletion) { + $this->selectionContainerAssociatedSelectionsScheduledForDeletion = clone $this->collSelectionContainerAssociatedSelections; + $this->selectionContainerAssociatedSelectionsScheduledForDeletion->clear(); + } + $this->selectionContainerAssociatedSelectionsScheduledForDeletion[]= clone $selectionContainerAssociatedSelection; + $selectionContainerAssociatedSelection->setSelectionContainer(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this SelectionContainer is new, it will return + * an empty collection; or if this SelectionContainer has previously + * been saved, it will retrieve related SelectionContainerAssociatedSelections 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 SelectionContainer. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildSelectionContainerAssociatedSelection[] List of ChildSelectionContainerAssociatedSelection objects + */ + public function getSelectionContainerAssociatedSelectionsJoinSelection($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildSelectionContainerAssociatedSelectionQuery::create(null, $criteria); + $query->joinWith('Selection', $joinBehavior); + + return $this->getSelectionContainerAssociatedSelections($query, $con); + } + + /** + * Clears out the collSelectionContainerImages collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addSelectionContainerImages() + */ + public function clearSelectionContainerImages() + { + $this->collSelectionContainerImages = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collSelectionContainerImages collection loaded partially. + */ + public function resetPartialSelectionContainerImages($v = true) + { + $this->collSelectionContainerImagesPartial = $v; + } + + /** + * Initializes the collSelectionContainerImages collection. + * + * By default this just sets the collSelectionContainerImages collection to an empty array (like clearcollSelectionContainerImages()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initSelectionContainerImages($overrideExisting = true) + { + if (null !== $this->collSelectionContainerImages && !$overrideExisting) { + return; + } + $this->collSelectionContainerImages = new ObjectCollection(); + $this->collSelectionContainerImages->setModel('\Selection\Model\SelectionContainerImage'); + } + + /** + * Gets an array of ChildSelectionContainerImage objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildSelectionContainer is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildSelectionContainerImage[] List of ChildSelectionContainerImage objects + * @throws PropelException + */ + public function getSelectionContainerImages($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collSelectionContainerImagesPartial && !$this->isNew(); + if (null === $this->collSelectionContainerImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionContainerImages) { + // return empty collection + $this->initSelectionContainerImages(); + } else { + $collSelectionContainerImages = ChildSelectionContainerImageQuery::create(null, $criteria) + ->filterBySelectionContainer($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collSelectionContainerImagesPartial && count($collSelectionContainerImages)) { + $this->initSelectionContainerImages(false); + + foreach ($collSelectionContainerImages as $obj) { + if (false == $this->collSelectionContainerImages->contains($obj)) { + $this->collSelectionContainerImages->append($obj); + } + } + + $this->collSelectionContainerImagesPartial = true; + } + + reset($collSelectionContainerImages); + + return $collSelectionContainerImages; + } + + if ($partial && $this->collSelectionContainerImages) { + foreach ($this->collSelectionContainerImages as $obj) { + if ($obj->isNew()) { + $collSelectionContainerImages[] = $obj; + } + } + } + + $this->collSelectionContainerImages = $collSelectionContainerImages; + $this->collSelectionContainerImagesPartial = false; + } + } + + return $this->collSelectionContainerImages; + } + + /** + * Sets a collection of SelectionContainerImage objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $selectionContainerImages A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildSelectionContainer The current object (for fluent API support) + */ + public function setSelectionContainerImages(Collection $selectionContainerImages, ConnectionInterface $con = null) + { + $selectionContainerImagesToDelete = $this->getSelectionContainerImages(new Criteria(), $con)->diff($selectionContainerImages); + + + $this->selectionContainerImagesScheduledForDeletion = $selectionContainerImagesToDelete; + + foreach ($selectionContainerImagesToDelete as $selectionContainerImageRemoved) { + $selectionContainerImageRemoved->setSelectionContainer(null); + } + + $this->collSelectionContainerImages = null; + foreach ($selectionContainerImages as $selectionContainerImage) { + $this->addSelectionContainerImage($selectionContainerImage); + } + + $this->collSelectionContainerImages = $selectionContainerImages; + $this->collSelectionContainerImagesPartial = false; + + return $this; + } + + /** + * Returns the number of related SelectionContainerImage objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related SelectionContainerImage objects. + * @throws PropelException + */ + public function countSelectionContainerImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collSelectionContainerImagesPartial && !$this->isNew(); + if (null === $this->collSelectionContainerImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionContainerImages) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getSelectionContainerImages()); + } + + $query = ChildSelectionContainerImageQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterBySelectionContainer($this) + ->count($con); + } + + return count($this->collSelectionContainerImages); + } + + /** + * Method called to associate a ChildSelectionContainerImage object to this object + * through the ChildSelectionContainerImage foreign key attribute. + * + * @param ChildSelectionContainerImage $l ChildSelectionContainerImage + * @return \Selection\Model\SelectionContainer The current object (for fluent API support) + */ + public function addSelectionContainerImage(ChildSelectionContainerImage $l) + { + if ($this->collSelectionContainerImages === null) { + $this->initSelectionContainerImages(); + $this->collSelectionContainerImagesPartial = true; + } + + if (!in_array($l, $this->collSelectionContainerImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddSelectionContainerImage($l); + } + + return $this; + } + + /** + * @param SelectionContainerImage $selectionContainerImage The selectionContainerImage object to add. + */ + protected function doAddSelectionContainerImage($selectionContainerImage) + { + $this->collSelectionContainerImages[]= $selectionContainerImage; + $selectionContainerImage->setSelectionContainer($this); + } + + /** + * @param SelectionContainerImage $selectionContainerImage The selectionContainerImage object to remove. + * @return ChildSelectionContainer The current object (for fluent API support) + */ + public function removeSelectionContainerImage($selectionContainerImage) + { + if ($this->getSelectionContainerImages()->contains($selectionContainerImage)) { + $this->collSelectionContainerImages->remove($this->collSelectionContainerImages->search($selectionContainerImage)); + if (null === $this->selectionContainerImagesScheduledForDeletion) { + $this->selectionContainerImagesScheduledForDeletion = clone $this->collSelectionContainerImages; + $this->selectionContainerImagesScheduledForDeletion->clear(); + } + $this->selectionContainerImagesScheduledForDeletion[]= clone $selectionContainerImage; + $selectionContainerImage->setSelectionContainer(null); + } + + return $this; + } + + /** + * Clears out the collSelectionContainerI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addSelectionContainerI18ns() + */ + public function clearSelectionContainerI18ns() + { + $this->collSelectionContainerI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collSelectionContainerI18ns collection loaded partially. + */ + public function resetPartialSelectionContainerI18ns($v = true) + { + $this->collSelectionContainerI18nsPartial = $v; + } + + /** + * Initializes the collSelectionContainerI18ns collection. + * + * By default this just sets the collSelectionContainerI18ns collection to an empty array (like clearcollSelectionContainerI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initSelectionContainerI18ns($overrideExisting = true) + { + if (null !== $this->collSelectionContainerI18ns && !$overrideExisting) { + return; + } + $this->collSelectionContainerI18ns = new ObjectCollection(); + $this->collSelectionContainerI18ns->setModel('\Selection\Model\SelectionContainerI18n'); + } + + /** + * Gets an array of ChildSelectionContainerI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildSelectionContainer is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildSelectionContainerI18n[] List of ChildSelectionContainerI18n objects + * @throws PropelException + */ + public function getSelectionContainerI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collSelectionContainerI18nsPartial && !$this->isNew(); + if (null === $this->collSelectionContainerI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionContainerI18ns) { + // return empty collection + $this->initSelectionContainerI18ns(); + } else { + $collSelectionContainerI18ns = ChildSelectionContainerI18nQuery::create(null, $criteria) + ->filterBySelectionContainer($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collSelectionContainerI18nsPartial && count($collSelectionContainerI18ns)) { + $this->initSelectionContainerI18ns(false); + + foreach ($collSelectionContainerI18ns as $obj) { + if (false == $this->collSelectionContainerI18ns->contains($obj)) { + $this->collSelectionContainerI18ns->append($obj); + } + } + + $this->collSelectionContainerI18nsPartial = true; + } + + reset($collSelectionContainerI18ns); + + return $collSelectionContainerI18ns; + } + + if ($partial && $this->collSelectionContainerI18ns) { + foreach ($this->collSelectionContainerI18ns as $obj) { + if ($obj->isNew()) { + $collSelectionContainerI18ns[] = $obj; + } + } + } + + $this->collSelectionContainerI18ns = $collSelectionContainerI18ns; + $this->collSelectionContainerI18nsPartial = false; + } + } + + return $this->collSelectionContainerI18ns; + } + + /** + * Sets a collection of SelectionContainerI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $selectionContainerI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildSelectionContainer The current object (for fluent API support) + */ + public function setSelectionContainerI18ns(Collection $selectionContainerI18ns, ConnectionInterface $con = null) + { + $selectionContainerI18nsToDelete = $this->getSelectionContainerI18ns(new Criteria(), $con)->diff($selectionContainerI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->selectionContainerI18nsScheduledForDeletion = clone $selectionContainerI18nsToDelete; + + foreach ($selectionContainerI18nsToDelete as $selectionContainerI18nRemoved) { + $selectionContainerI18nRemoved->setSelectionContainer(null); + } + + $this->collSelectionContainerI18ns = null; + foreach ($selectionContainerI18ns as $selectionContainerI18n) { + $this->addSelectionContainerI18n($selectionContainerI18n); + } + + $this->collSelectionContainerI18ns = $selectionContainerI18ns; + $this->collSelectionContainerI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related SelectionContainerI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related SelectionContainerI18n objects. + * @throws PropelException + */ + public function countSelectionContainerI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collSelectionContainerI18nsPartial && !$this->isNew(); + if (null === $this->collSelectionContainerI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionContainerI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getSelectionContainerI18ns()); + } + + $query = ChildSelectionContainerI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterBySelectionContainer($this) + ->count($con); + } + + return count($this->collSelectionContainerI18ns); + } + + /** + * Method called to associate a ChildSelectionContainerI18n object to this object + * through the ChildSelectionContainerI18n foreign key attribute. + * + * @param ChildSelectionContainerI18n $l ChildSelectionContainerI18n + * @return \Selection\Model\SelectionContainer The current object (for fluent API support) + */ + public function addSelectionContainerI18n(ChildSelectionContainerI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collSelectionContainerI18ns === null) { + $this->initSelectionContainerI18ns(); + $this->collSelectionContainerI18nsPartial = true; + } + + if (!in_array($l, $this->collSelectionContainerI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddSelectionContainerI18n($l); + } + + return $this; + } + + /** + * @param SelectionContainerI18n $selectionContainerI18n The selectionContainerI18n object to add. + */ + protected function doAddSelectionContainerI18n($selectionContainerI18n) + { + $this->collSelectionContainerI18ns[]= $selectionContainerI18n; + $selectionContainerI18n->setSelectionContainer($this); + } + + /** + * @param SelectionContainerI18n $selectionContainerI18n The selectionContainerI18n object to remove. + * @return ChildSelectionContainer The current object (for fluent API support) + */ + public function removeSelectionContainerI18n($selectionContainerI18n) + { + if ($this->getSelectionContainerI18ns()->contains($selectionContainerI18n)) { + $this->collSelectionContainerI18ns->remove($this->collSelectionContainerI18ns->search($selectionContainerI18n)); + if (null === $this->selectionContainerI18nsScheduledForDeletion) { + $this->selectionContainerI18nsScheduledForDeletion = clone $this->collSelectionContainerI18ns; + $this->selectionContainerI18nsScheduledForDeletion->clear(); + } + $this->selectionContainerI18nsScheduledForDeletion[]= clone $selectionContainerI18n; + $selectionContainerI18n->setSelectionContainer(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->visible = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collSelectionContainerAssociatedSelections) { + foreach ($this->collSelectionContainerAssociatedSelections as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collSelectionContainerImages) { + foreach ($this->collSelectionContainerImages as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collSelectionContainerI18ns) { + foreach ($this->collSelectionContainerI18ns as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + // i18n behavior + $this->currentLocale = 'en_US'; + $this->currentTranslations = null; + + $this->collSelectionContainerAssociatedSelections = null; + $this->collSelectionContainerImages = null; + $this->collSelectionContainerI18ns = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(SelectionContainerTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildSelectionContainer The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[SelectionContainerTableMap::UPDATED_AT] = true; + + return $this; + } + + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildSelectionContainer The current object (for fluent API support) + */ + public function setLocale($locale = 'en_US') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionContainerI18n */ + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collSelectionContainerI18ns) { + foreach ($this->collSelectionContainerI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildSelectionContainerI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildSelectionContainerI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addSelectionContainerI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionContainer The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildSelectionContainerI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collSelectionContainerI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collSelectionContainerI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionContainerI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + return $this->getCurrentTranslation()->getTitle(); + } + + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setTitle($v) + { $this->getCurrentTranslation()->setTitle($v); + + return $this; + } + + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + return $this->getCurrentTranslation()->getDescription(); + } + + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setDescription($v) + { $this->getCurrentTranslation()->setDescription($v); + + return $this; + } + + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + return $this->getCurrentTranslation()->getChapo(); + } + + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setChapo($v) + { $this->getCurrentTranslation()->setChapo($v); + + return $this; + } + + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + return $this->getCurrentTranslation()->getPostscriptum(); + } + + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { $this->getCurrentTranslation()->setPostscriptum($v); + + return $this; + } + + + /** + * Get the [meta_title] column value. + * + * @return string + */ + public function getMetaTitle() + { + return $this->getCurrentTranslation()->getMetaTitle(); + } + + + /** + * Set the value of [meta_title] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setMetaTitle($v) + { $this->getCurrentTranslation()->setMetaTitle($v); + + return $this; + } + + + /** + * Get the [meta_description] column value. + * + * @return string + */ + public function getMetaDescription() + { + return $this->getCurrentTranslation()->getMetaDescription(); + } + + + /** + * Set the value of [meta_description] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setMetaDescription($v) + { $this->getCurrentTranslation()->setMetaDescription($v); + + return $this; + } + + + /** + * Get the [meta_keywords] column value. + * + * @return string + */ + public function getMetaKeywords() + { + return $this->getCurrentTranslation()->getMetaKeywords(); + } + + + /** + * Set the value of [meta_keywords] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setMetaKeywords($v) + { $this->getCurrentTranslation()->setMetaKeywords($v); + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/Selection/Model/Base/SelectionContainerAssociatedSelection.php b/local/modules/Selection/Model/Base/SelectionContainerAssociatedSelection.php new file mode 100644 index 00000000..a12f6146 --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionContainerAssociatedSelection.php @@ -0,0 +1,1497 @@ +modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another SelectionContainerAssociatedSelection instance. If + * obj is an instance of SelectionContainerAssociatedSelection, delegates to + * equals(SelectionContainerAssociatedSelection). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return SelectionContainerAssociatedSelection The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return SelectionContainerAssociatedSelection The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [selection_container_id] column value. + * + * @return int + */ + public function getSelectionContainerId() + { + + return $this->selection_container_id; + } + + /** + * Get the [selection_id] column value. + * + * @return int + */ + public function getSelectionId() + { + + return $this->selection_id; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContainerAssociatedSelection The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[SelectionContainerAssociatedSelectionTableMap::ID] = true; + } + + + return $this; + } // setId() + + /** + * Set the value of [selection_container_id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContainerAssociatedSelection The current object (for fluent API support) + */ + public function setSelectionContainerId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->selection_container_id !== $v) { + $this->selection_container_id = $v; + $this->modifiedColumns[SelectionContainerAssociatedSelectionTableMap::SELECTION_CONTAINER_ID] = true; + } + + if ($this->aSelectionContainer !== null && $this->aSelectionContainer->getId() !== $v) { + $this->aSelectionContainer = null; + } + + + return $this; + } // setSelectionContainerId() + + /** + * Set the value of [selection_id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContainerAssociatedSelection The current object (for fluent API support) + */ + public function setSelectionId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->selection_id !== $v) { + $this->selection_id = $v; + $this->modifiedColumns[SelectionContainerAssociatedSelectionTableMap::SELECTION_ID] = true; + } + + if ($this->aSelection !== null && $this->aSelection->getId() !== $v) { + $this->aSelection = null; + } + + + return $this; + } // setSelectionId() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Selection\Model\SelectionContainerAssociatedSelection The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[SelectionContainerAssociatedSelectionTableMap::CREATED_AT] = true; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Selection\Model\SelectionContainerAssociatedSelection The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[SelectionContainerAssociatedSelectionTableMap::UPDATED_AT] = true; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : SelectionContainerAssociatedSelectionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : SelectionContainerAssociatedSelectionTableMap::translateFieldName('SelectionContainerId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->selection_container_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : SelectionContainerAssociatedSelectionTableMap::translateFieldName('SelectionId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->selection_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : SelectionContainerAssociatedSelectionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : SelectionContainerAssociatedSelectionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = SelectionContainerAssociatedSelectionTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Selection\Model\SelectionContainerAssociatedSelection object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aSelectionContainer !== null && $this->selection_container_id !== $this->aSelectionContainer->getId()) { + $this->aSelectionContainer = null; + } + if ($this->aSelection !== null && $this->selection_id !== $this->aSelection->getId()) { + $this->aSelection = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionContainerAssociatedSelectionTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildSelectionContainerAssociatedSelectionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aSelectionContainer = null; + $this->aSelection = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see SelectionContainerAssociatedSelection::setDeleted() + * @see SelectionContainerAssociatedSelection::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerAssociatedSelectionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildSelectionContainerAssociatedSelectionQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerAssociatedSelectionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(SelectionContainerAssociatedSelectionTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(SelectionContainerAssociatedSelectionTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(SelectionContainerAssociatedSelectionTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + SelectionContainerAssociatedSelectionTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aSelectionContainer !== null) { + if ($this->aSelectionContainer->isModified() || $this->aSelectionContainer->isNew()) { + $affectedRows += $this->aSelectionContainer->save($con); + } + $this->setSelectionContainer($this->aSelectionContainer); + } + + if ($this->aSelection !== null) { + if ($this->aSelection->isModified() || $this->aSelection->isNew()) { + $affectedRows += $this->aSelection->save($con); + } + $this->setSelection($this->aSelection); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[SelectionContainerAssociatedSelectionTableMap::ID] = true; + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(SelectionContainerAssociatedSelectionTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(SelectionContainerAssociatedSelectionTableMap::SELECTION_CONTAINER_ID)) { + $modifiedColumns[':p' . $index++] = 'SELECTION_CONTAINER_ID'; + } + if ($this->isColumnModified(SelectionContainerAssociatedSelectionTableMap::SELECTION_ID)) { + $modifiedColumns[':p' . $index++] = 'SELECTION_ID'; + } + if ($this->isColumnModified(SelectionContainerAssociatedSelectionTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(SelectionContainerAssociatedSelectionTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO selection_container_associated_selection (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'SELECTION_CONTAINER_ID': + $stmt->bindValue($identifier, $this->selection_container_id, PDO::PARAM_INT); + break; + case 'SELECTION_ID': + $stmt->bindValue($identifier, $this->selection_id, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + if ($pk !== null) { + $this->setId($pk); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionContainerAssociatedSelectionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getSelectionContainerId(); + break; + case 2: + return $this->getSelectionId(); + break; + case 3: + return $this->getCreatedAt(); + break; + case 4: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['SelectionContainerAssociatedSelection'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['SelectionContainerAssociatedSelection'][$this->getPrimaryKey()] = true; + $keys = SelectionContainerAssociatedSelectionTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getSelectionContainerId(), + $keys[2] => $this->getSelectionId(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aSelectionContainer) { + $result['SelectionContainer'] = $this->aSelectionContainer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aSelection) { + $result['Selection'] = $this->aSelection->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionContainerAssociatedSelectionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setSelectionContainerId($value); + break; + case 2: + $this->setSelectionId($value); + break; + case 3: + $this->setCreatedAt($value); + break; + case 4: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = SelectionContainerAssociatedSelectionTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setSelectionContainerId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setSelectionId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(SelectionContainerAssociatedSelectionTableMap::DATABASE_NAME); + + if ($this->isColumnModified(SelectionContainerAssociatedSelectionTableMap::ID)) $criteria->add(SelectionContainerAssociatedSelectionTableMap::ID, $this->id); + if ($this->isColumnModified(SelectionContainerAssociatedSelectionTableMap::SELECTION_CONTAINER_ID)) $criteria->add(SelectionContainerAssociatedSelectionTableMap::SELECTION_CONTAINER_ID, $this->selection_container_id); + if ($this->isColumnModified(SelectionContainerAssociatedSelectionTableMap::SELECTION_ID)) $criteria->add(SelectionContainerAssociatedSelectionTableMap::SELECTION_ID, $this->selection_id); + if ($this->isColumnModified(SelectionContainerAssociatedSelectionTableMap::CREATED_AT)) $criteria->add(SelectionContainerAssociatedSelectionTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(SelectionContainerAssociatedSelectionTableMap::UPDATED_AT)) $criteria->add(SelectionContainerAssociatedSelectionTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(SelectionContainerAssociatedSelectionTableMap::DATABASE_NAME); + $criteria->add(SelectionContainerAssociatedSelectionTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Selection\Model\SelectionContainerAssociatedSelection (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setSelectionContainerId($this->getSelectionContainerId()); + $copyObj->setSelectionId($this->getSelectionId()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Selection\Model\SelectionContainerAssociatedSelection Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildSelectionContainer object. + * + * @param ChildSelectionContainer $v + * @return \Selection\Model\SelectionContainerAssociatedSelection The current object (for fluent API support) + * @throws PropelException + */ + public function setSelectionContainer(ChildSelectionContainer $v = null) + { + if ($v === null) { + $this->setSelectionContainerId(NULL); + } else { + $this->setSelectionContainerId($v->getId()); + } + + $this->aSelectionContainer = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildSelectionContainer object, it will not be re-added. + if ($v !== null) { + $v->addSelectionContainerAssociatedSelection($this); + } + + + return $this; + } + + + /** + * Get the associated ChildSelectionContainer object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildSelectionContainer The associated ChildSelectionContainer object. + * @throws PropelException + */ + public function getSelectionContainer(ConnectionInterface $con = null) + { + if ($this->aSelectionContainer === null && ($this->selection_container_id !== null)) { + $this->aSelectionContainer = ChildSelectionContainerQuery::create()->findPk($this->selection_container_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->aSelectionContainer->addSelectionContainerAssociatedSelections($this); + */ + } + + return $this->aSelectionContainer; + } + + /** + * Declares an association between this object and a ChildSelection object. + * + * @param ChildSelection $v + * @return \Selection\Model\SelectionContainerAssociatedSelection The current object (for fluent API support) + * @throws PropelException + */ + public function setSelection(ChildSelection $v = null) + { + if ($v === null) { + $this->setSelectionId(NULL); + } else { + $this->setSelectionId($v->getId()); + } + + $this->aSelection = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildSelection object, it will not be re-added. + if ($v !== null) { + $v->addSelectionContainerAssociatedSelection($this); + } + + + return $this; + } + + + /** + * Get the associated ChildSelection object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildSelection The associated ChildSelection object. + * @throws PropelException + */ + public function getSelection(ConnectionInterface $con = null) + { + if ($this->aSelection === null && ($this->selection_id !== null)) { + $this->aSelection = ChildSelectionQuery::create()->findPk($this->selection_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->aSelection->addSelectionContainerAssociatedSelections($this); + */ + } + + return $this->aSelection; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->selection_container_id = null; + $this->selection_id = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aSelectionContainer = null; + $this->aSelection = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(SelectionContainerAssociatedSelectionTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildSelectionContainerAssociatedSelection The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[SelectionContainerAssociatedSelectionTableMap::UPDATED_AT] = true; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/Selection/Model/Base/SelectionContainerAssociatedSelectionQuery.php b/local/modules/Selection/Model/Base/SelectionContainerAssociatedSelectionQuery.php new file mode 100644 index 00000000..7d5f0c8c --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionContainerAssociatedSelectionQuery.php @@ -0,0 +1,759 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionContainerAssociatedSelection|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = SelectionContainerAssociatedSelectionTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionContainerAssociatedSelectionTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionContainerAssociatedSelection A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, SELECTION_CONTAINER_ID, SELECTION_ID, CREATED_AT, UPDATED_AT FROM selection_container_associated_selection WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildSelectionContainerAssociatedSelection(); + $obj->hydrate($row); + SelectionContainerAssociatedSelectionTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionContainerAssociatedSelection|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the selection_container_id column + * + * Example usage: + * + * $query->filterBySelectionContainerId(1234); // WHERE selection_container_id = 1234 + * $query->filterBySelectionContainerId(array(12, 34)); // WHERE selection_container_id IN (12, 34) + * $query->filterBySelectionContainerId(array('min' => 12)); // WHERE selection_container_id > 12 + * + * + * @see filterBySelectionContainer() + * + * @param mixed $selectionContainerId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function filterBySelectionContainerId($selectionContainerId = null, $comparison = null) + { + if (is_array($selectionContainerId)) { + $useMinMax = false; + if (isset($selectionContainerId['min'])) { + $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::SELECTION_CONTAINER_ID, $selectionContainerId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($selectionContainerId['max'])) { + $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::SELECTION_CONTAINER_ID, $selectionContainerId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::SELECTION_CONTAINER_ID, $selectionContainerId, $comparison); + } + + /** + * Filter the query on the selection_id column + * + * Example usage: + * + * $query->filterBySelectionId(1234); // WHERE selection_id = 1234 + * $query->filterBySelectionId(array(12, 34)); // WHERE selection_id IN (12, 34) + * $query->filterBySelectionId(array('min' => 12)); // WHERE selection_id > 12 + * + * + * @see filterBySelection() + * + * @param mixed $selectionId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function filterBySelectionId($selectionId = null, $comparison = null) + { + if (is_array($selectionId)) { + $useMinMax = false; + if (isset($selectionId['min'])) { + $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::SELECTION_ID, $selectionId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($selectionId['max'])) { + $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::SELECTION_ID, $selectionId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::SELECTION_ID, $selectionId, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Selection\Model\SelectionContainer object + * + * @param \Selection\Model\SelectionContainer|ObjectCollection $selectionContainer The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function filterBySelectionContainer($selectionContainer, $comparison = null) + { + if ($selectionContainer instanceof \Selection\Model\SelectionContainer) { + return $this + ->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::SELECTION_CONTAINER_ID, $selectionContainer->getId(), $comparison); + } elseif ($selectionContainer instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::SELECTION_CONTAINER_ID, $selectionContainer->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterBySelectionContainer() only accepts arguments of type \Selection\Model\SelectionContainer or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionContainer relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function joinSelectionContainer($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionContainer'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionContainer'); + } + + return $this; + } + + /** + * Use the SelectionContainer relation SelectionContainer object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionContainerQuery A secondary query class using the current class as primary query + */ + public function useSelectionContainerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinSelectionContainer($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionContainer', '\Selection\Model\SelectionContainerQuery'); + } + + /** + * Filter the query by a related \Selection\Model\Selection object + * + * @param \Selection\Model\Selection|ObjectCollection $selection The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function filterBySelection($selection, $comparison = null) + { + if ($selection instanceof \Selection\Model\Selection) { + return $this + ->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::SELECTION_ID, $selection->getId(), $comparison); + } elseif ($selection instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::SELECTION_ID, $selection->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterBySelection() only accepts arguments of type \Selection\Model\Selection or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Selection relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function joinSelection($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Selection'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Selection'); + } + + return $this; + } + + /** + * Use the Selection relation Selection object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionQuery A secondary query class using the current class as primary query + */ + public function useSelectionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinSelection($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Selection', '\Selection\Model\SelectionQuery'); + } + + /** + * Exclude object from result + * + * @param ChildSelectionContainerAssociatedSelection $selectionContainerAssociatedSelection Object to remove from the list of results + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function prune($selectionContainerAssociatedSelection = null) + { + if ($selectionContainerAssociatedSelection) { + $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::ID, $selectionContainerAssociatedSelection->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the selection_container_associated_selection table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerAssociatedSelectionTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + SelectionContainerAssociatedSelectionTableMap::clearInstancePool(); + SelectionContainerAssociatedSelectionTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildSelectionContainerAssociatedSelection or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildSelectionContainerAssociatedSelection object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerAssociatedSelectionTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(SelectionContainerAssociatedSelectionTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + SelectionContainerAssociatedSelectionTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + SelectionContainerAssociatedSelectionTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(SelectionContainerAssociatedSelectionTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(SelectionContainerAssociatedSelectionTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(SelectionContainerAssociatedSelectionTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(SelectionContainerAssociatedSelectionTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildSelectionContainerAssociatedSelectionQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(SelectionContainerAssociatedSelectionTableMap::CREATED_AT); + } + +} // SelectionContainerAssociatedSelectionQuery diff --git a/local/modules/Selection/Model/Base/SelectionContainerI18n.php b/local/modules/Selection/Model/Base/SelectionContainerI18n.php new file mode 100644 index 00000000..a018d0ac --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionContainerI18n.php @@ -0,0 +1,1616 @@ +locale = 'en_US'; + } + + /** + * Initializes internal state of Selection\Model\Base\SelectionContainerI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !!$this->modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another SelectionContainerI18n instance. If + * obj is an instance of SelectionContainerI18n, delegates to + * equals(SelectionContainerI18n). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return SelectionContainerI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return SelectionContainerI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + + return $this->postscriptum; + } + + /** + * Get the [meta_title] column value. + * + * @return string + */ + public function getMetaTitle() + { + + return $this->meta_title; + } + + /** + * Get the [meta_description] column value. + * + * @return string + */ + public function getMetaDescription() + { + + return $this->meta_description; + } + + /** + * Get the [meta_keywords] column value. + * + * @return string + */ + public function getMetaKeywords() + { + + return $this->meta_keywords; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[SelectionContainerI18nTableMap::ID] = true; + } + + if ($this->aSelectionContainer !== null && $this->aSelectionContainer->getId() !== $v) { + $this->aSelectionContainer = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[SelectionContainerI18nTableMap::LOCALE] = true; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[SelectionContainerI18nTableMap::TITLE] = true; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[SelectionContainerI18nTableMap::DESCRIPTION] = true; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[SelectionContainerI18nTableMap::CHAPO] = true; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[SelectionContainerI18nTableMap::POSTSCRIPTUM] = true; + } + + + return $this; + } // setPostscriptum() + + /** + * Set the value of [meta_title] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setMetaTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_title !== $v) { + $this->meta_title = $v; + $this->modifiedColumns[SelectionContainerI18nTableMap::META_TITLE] = true; + } + + + return $this; + } // setMetaTitle() + + /** + * Set the value of [meta_description] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setMetaDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_description !== $v) { + $this->meta_description = $v; + $this->modifiedColumns[SelectionContainerI18nTableMap::META_DESCRIPTION] = true; + } + + + return $this; + } // setMetaDescription() + + /** + * Set the value of [meta_keywords] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + */ + public function setMetaKeywords($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_keywords !== $v) { + $this->meta_keywords = $v; + $this->modifiedColumns[SelectionContainerI18nTableMap::META_KEYWORDS] = true; + } + + + return $this; + } // setMetaKeywords() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_US') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : SelectionContainerI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : SelectionContainerI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : SelectionContainerI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : SelectionContainerI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : SelectionContainerI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : SelectionContainerI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : SelectionContainerI18nTableMap::translateFieldName('MetaTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : SelectionContainerI18nTableMap::translateFieldName('MetaDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : SelectionContainerI18nTableMap::translateFieldName('MetaKeywords', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_keywords = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 9; // 9 = SelectionContainerI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Selection\Model\SelectionContainerI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aSelectionContainer !== null && $this->id !== $this->aSelectionContainer->getId()) { + $this->aSelectionContainer = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionContainerI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildSelectionContainerI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aSelectionContainer = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see SelectionContainerI18n::setDeleted() + * @see SelectionContainerI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildSelectionContainerI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + SelectionContainerI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aSelectionContainer !== null) { + if ($this->aSelectionContainer->isModified() || $this->aSelectionContainer->isNew()) { + $affectedRows += $this->aSelectionContainer->save($con); + } + $this->setSelectionContainer($this->aSelectionContainer); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(SelectionContainerI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(SelectionContainerI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(SelectionContainerI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(SelectionContainerI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(SelectionContainerI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(SelectionContainerI18nTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; + } + if ($this->isColumnModified(SelectionContainerI18nTableMap::META_TITLE)) { + $modifiedColumns[':p' . $index++] = 'META_TITLE'; + } + if ($this->isColumnModified(SelectionContainerI18nTableMap::META_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'META_DESCRIPTION'; + } + if ($this->isColumnModified(SelectionContainerI18nTableMap::META_KEYWORDS)) { + $modifiedColumns[':p' . $index++] = 'META_KEYWORDS'; + } + + $sql = sprintf( + 'INSERT INTO selection_container_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); + break; + case 'META_TITLE': + $stmt->bindValue($identifier, $this->meta_title, PDO::PARAM_STR); + break; + case 'META_DESCRIPTION': + $stmt->bindValue($identifier, $this->meta_description, PDO::PARAM_STR); + break; + case 'META_KEYWORDS': + $stmt->bindValue($identifier, $this->meta_keywords, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionContainerI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getChapo(); + break; + case 5: + return $this->getPostscriptum(); + break; + case 6: + return $this->getMetaTitle(); + break; + case 7: + return $this->getMetaDescription(); + break; + case 8: + return $this->getMetaKeywords(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['SelectionContainerI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['SelectionContainerI18n'][serialize($this->getPrimaryKey())] = true; + $keys = SelectionContainerI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getChapo(), + $keys[5] => $this->getPostscriptum(), + $keys[6] => $this->getMetaTitle(), + $keys[7] => $this->getMetaDescription(), + $keys[8] => $this->getMetaKeywords(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aSelectionContainer) { + $result['SelectionContainer'] = $this->aSelectionContainer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionContainerI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setChapo($value); + break; + case 5: + $this->setPostscriptum($value); + break; + case 6: + $this->setMetaTitle($value); + break; + case 7: + $this->setMetaDescription($value); + break; + case 8: + $this->setMetaKeywords($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = SelectionContainerI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setMetaTitle($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setMetaDescription($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setMetaKeywords($arr[$keys[8]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(SelectionContainerI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(SelectionContainerI18nTableMap::ID)) $criteria->add(SelectionContainerI18nTableMap::ID, $this->id); + if ($this->isColumnModified(SelectionContainerI18nTableMap::LOCALE)) $criteria->add(SelectionContainerI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(SelectionContainerI18nTableMap::TITLE)) $criteria->add(SelectionContainerI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(SelectionContainerI18nTableMap::DESCRIPTION)) $criteria->add(SelectionContainerI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(SelectionContainerI18nTableMap::CHAPO)) $criteria->add(SelectionContainerI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(SelectionContainerI18nTableMap::POSTSCRIPTUM)) $criteria->add(SelectionContainerI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + if ($this->isColumnModified(SelectionContainerI18nTableMap::META_TITLE)) $criteria->add(SelectionContainerI18nTableMap::META_TITLE, $this->meta_title); + if ($this->isColumnModified(SelectionContainerI18nTableMap::META_DESCRIPTION)) $criteria->add(SelectionContainerI18nTableMap::META_DESCRIPTION, $this->meta_description); + if ($this->isColumnModified(SelectionContainerI18nTableMap::META_KEYWORDS)) $criteria->add(SelectionContainerI18nTableMap::META_KEYWORDS, $this->meta_keywords); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(SelectionContainerI18nTableMap::DATABASE_NAME); + $criteria->add(SelectionContainerI18nTableMap::ID, $this->id); + $criteria->add(SelectionContainerI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Selection\Model\SelectionContainerI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setChapo($this->getChapo()); + $copyObj->setPostscriptum($this->getPostscriptum()); + $copyObj->setMetaTitle($this->getMetaTitle()); + $copyObj->setMetaDescription($this->getMetaDescription()); + $copyObj->setMetaKeywords($this->getMetaKeywords()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Selection\Model\SelectionContainerI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildSelectionContainer object. + * + * @param ChildSelectionContainer $v + * @return \Selection\Model\SelectionContainerI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setSelectionContainer(ChildSelectionContainer $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aSelectionContainer = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildSelectionContainer object, it will not be re-added. + if ($v !== null) { + $v->addSelectionContainerI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildSelectionContainer object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildSelectionContainer The associated ChildSelectionContainer object. + * @throws PropelException + */ + public function getSelectionContainer(ConnectionInterface $con = null) + { + if ($this->aSelectionContainer === null && ($this->id !== null)) { + $this->aSelectionContainer = ChildSelectionContainerQuery::create()->findPk($this->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->aSelectionContainer->addSelectionContainerI18ns($this); + */ + } + + return $this->aSelectionContainer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->title = null; + $this->description = null; + $this->chapo = null; + $this->postscriptum = null; + $this->meta_title = null; + $this->meta_description = null; + $this->meta_keywords = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aSelectionContainer = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(SelectionContainerI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/Selection/Model/Base/SelectionContainerI18nQuery.php b/local/modules/Selection/Model/Base/SelectionContainerI18nQuery.php new file mode 100644 index 00000000..7c028511 --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionContainerI18nQuery.php @@ -0,0 +1,706 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionContainerI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = SelectionContainerI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionContainerI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionContainerI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM, META_TITLE, META_DESCRIPTION, META_KEYWORDS FROM selection_container_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildSelectionContainerI18n(); + $obj->hydrate($row); + SelectionContainerI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionContainerI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildSelectionContainerI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(SelectionContainerI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(SelectionContainerI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildSelectionContainerI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(SelectionContainerI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(SelectionContainerI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterBySelectionContainer() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(SelectionContainerI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(SelectionContainerI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionContainerI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerI18nQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionContainerI18nTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerI18nQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionContainerI18nTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerI18nQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionContainerI18nTableMap::CHAPO, $chapo, $comparison); + } + + /** + * Filter the query on the postscriptum column + * + * Example usage: + * + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' + * + * + * @param string $postscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerI18nQuery The current query, for fluid interface + */ + public function filterByPostscriptum($postscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($postscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionContainerI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query on the meta_title column + * + * Example usage: + * + * $query->filterByMetaTitle('fooValue'); // WHERE meta_title = 'fooValue' + * $query->filterByMetaTitle('%fooValue%'); // WHERE meta_title LIKE '%fooValue%' + * + * + * @param string $metaTitle The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerI18nQuery The current query, for fluid interface + */ + public function filterByMetaTitle($metaTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaTitle)) { + $metaTitle = str_replace('*', '%', $metaTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionContainerI18nTableMap::META_TITLE, $metaTitle, $comparison); + } + + /** + * Filter the query on the meta_description column + * + * Example usage: + * + * $query->filterByMetaDescription('fooValue'); // WHERE meta_description = 'fooValue' + * $query->filterByMetaDescription('%fooValue%'); // WHERE meta_description LIKE '%fooValue%' + * + * + * @param string $metaDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerI18nQuery The current query, for fluid interface + */ + public function filterByMetaDescription($metaDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaDescription)) { + $metaDescription = str_replace('*', '%', $metaDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionContainerI18nTableMap::META_DESCRIPTION, $metaDescription, $comparison); + } + + /** + * Filter the query on the meta_keywords column + * + * Example usage: + * + * $query->filterByMetaKeywords('fooValue'); // WHERE meta_keywords = 'fooValue' + * $query->filterByMetaKeywords('%fooValue%'); // WHERE meta_keywords LIKE '%fooValue%' + * + * + * @param string $metaKeywords The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerI18nQuery The current query, for fluid interface + */ + public function filterByMetaKeywords($metaKeywords = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaKeywords)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaKeywords)) { + $metaKeywords = str_replace('*', '%', $metaKeywords); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionContainerI18nTableMap::META_KEYWORDS, $metaKeywords, $comparison); + } + + /** + * Filter the query by a related \Selection\Model\SelectionContainer object + * + * @param \Selection\Model\SelectionContainer|ObjectCollection $selectionContainer The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerI18nQuery The current query, for fluid interface + */ + public function filterBySelectionContainer($selectionContainer, $comparison = null) + { + if ($selectionContainer instanceof \Selection\Model\SelectionContainer) { + return $this + ->addUsingAlias(SelectionContainerI18nTableMap::ID, $selectionContainer->getId(), $comparison); + } elseif ($selectionContainer instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(SelectionContainerI18nTableMap::ID, $selectionContainer->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterBySelectionContainer() only accepts arguments of type \Selection\Model\SelectionContainer or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionContainer relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionContainerI18nQuery The current query, for fluid interface + */ + public function joinSelectionContainer($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionContainer'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionContainer'); + } + + return $this; + } + + /** + * Use the SelectionContainer relation SelectionContainer object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionContainerQuery A secondary query class using the current class as primary query + */ + public function useSelectionContainerQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinSelectionContainer($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionContainer', '\Selection\Model\SelectionContainerQuery'); + } + + /** + * Exclude object from result + * + * @param ChildSelectionContainerI18n $selectionContainerI18n Object to remove from the list of results + * + * @return ChildSelectionContainerI18nQuery The current query, for fluid interface + */ + public function prune($selectionContainerI18n = null) + { + if ($selectionContainerI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(SelectionContainerI18nTableMap::ID), $selectionContainerI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(SelectionContainerI18nTableMap::LOCALE), $selectionContainerI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the selection_container_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + SelectionContainerI18nTableMap::clearInstancePool(); + SelectionContainerI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildSelectionContainerI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildSelectionContainerI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(SelectionContainerI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + SelectionContainerI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + SelectionContainerI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // SelectionContainerI18nQuery diff --git a/local/modules/Selection/Model/Base/SelectionContainerImage.php b/local/modules/Selection/Model/Base/SelectionContainerImage.php new file mode 100644 index 00000000..faa9fc8c --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionContainerImage.php @@ -0,0 +1,2066 @@ +visible = 1; + } + + /** + * Initializes internal state of Selection\Model\Base\SelectionContainerImage object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !!$this->modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another SelectionContainerImage instance. If + * obj is an instance of SelectionContainerImage, delegates to + * equals(SelectionContainerImage). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return SelectionContainerImage The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return SelectionContainerImage The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [selection_container_id] column value. + * + * @return int + */ + public function getSelectionContainerId() + { + + return $this->selection_container_id; + } + + /** + * Get the [file] column value. + * + * @return string + */ + public function getFile() + { + + return $this->file; + } + + /** + * Get the [visible] column value. + * + * @return int + */ + public function getVisible() + { + + return $this->visible; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContainerImage The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[SelectionContainerImageTableMap::ID] = true; + } + + + return $this; + } // setId() + + /** + * Set the value of [selection_container_id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContainerImage The current object (for fluent API support) + */ + public function setSelectionContainerId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->selection_container_id !== $v) { + $this->selection_container_id = $v; + $this->modifiedColumns[SelectionContainerImageTableMap::SELECTION_CONTAINER_ID] = true; + } + + if ($this->aSelectionContainer !== null && $this->aSelectionContainer->getId() !== $v) { + $this->aSelectionContainer = null; + } + + + return $this; + } // setSelectionContainerId() + + /** + * Set the value of [file] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerImage The current object (for fluent API support) + */ + public function setFile($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->file !== $v) { + $this->file = $v; + $this->modifiedColumns[SelectionContainerImageTableMap::FILE] = true; + } + + + return $this; + } // setFile() + + /** + * Set the value of [visible] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContainerImage The current object (for fluent API support) + */ + public function setVisible($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->visible !== $v) { + $this->visible = $v; + $this->modifiedColumns[SelectionContainerImageTableMap::VISIBLE] = true; + } + + + return $this; + } // setVisible() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContainerImage The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[SelectionContainerImageTableMap::POSITION] = true; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Selection\Model\SelectionContainerImage The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[SelectionContainerImageTableMap::CREATED_AT] = true; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Selection\Model\SelectionContainerImage The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[SelectionContainerImageTableMap::UPDATED_AT] = true; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->visible !== 1) { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : SelectionContainerImageTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : SelectionContainerImageTableMap::translateFieldName('SelectionContainerId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->selection_container_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : SelectionContainerImageTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; + $this->file = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : SelectionContainerImageTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $this->visible = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : SelectionContainerImageTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : SelectionContainerImageTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : SelectionContainerImageTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 7; // 7 = SelectionContainerImageTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Selection\Model\SelectionContainerImage object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aSelectionContainer !== null && $this->selection_container_id !== $this->aSelectionContainer->getId()) { + $this->aSelectionContainer = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionContainerImageTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildSelectionContainerImageQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aSelectionContainer = null; + $this->collSelectionContainerImageI18ns = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see SelectionContainerImage::setDeleted() + * @see SelectionContainerImage::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerImageTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildSelectionContainerImageQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerImageTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(SelectionContainerImageTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(SelectionContainerImageTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(SelectionContainerImageTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + SelectionContainerImageTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aSelectionContainer !== null) { + if ($this->aSelectionContainer->isModified() || $this->aSelectionContainer->isNew()) { + $affectedRows += $this->aSelectionContainer->save($con); + } + $this->setSelectionContainer($this->aSelectionContainer); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->selectionContainerImageI18nsScheduledForDeletion !== null) { + if (!$this->selectionContainerImageI18nsScheduledForDeletion->isEmpty()) { + \Selection\Model\SelectionContainerImageI18nQuery::create() + ->filterByPrimaryKeys($this->selectionContainerImageI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->selectionContainerImageI18nsScheduledForDeletion = null; + } + } + + if ($this->collSelectionContainerImageI18ns !== null) { + foreach ($this->collSelectionContainerImageI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[SelectionContainerImageTableMap::ID] = true; + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(SelectionContainerImageTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(SelectionContainerImageTableMap::SELECTION_CONTAINER_ID)) { + $modifiedColumns[':p' . $index++] = 'SELECTION_CONTAINER_ID'; + } + if ($this->isColumnModified(SelectionContainerImageTableMap::FILE)) { + $modifiedColumns[':p' . $index++] = 'FILE'; + } + if ($this->isColumnModified(SelectionContainerImageTableMap::VISIBLE)) { + $modifiedColumns[':p' . $index++] = 'VISIBLE'; + } + if ($this->isColumnModified(SelectionContainerImageTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(SelectionContainerImageTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(SelectionContainerImageTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO selection_container_image (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'SELECTION_CONTAINER_ID': + $stmt->bindValue($identifier, $this->selection_container_id, PDO::PARAM_INT); + break; + case 'FILE': + $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); + break; + case 'VISIBLE': + $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + if ($pk !== null) { + $this->setId($pk); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionContainerImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getSelectionContainerId(); + break; + case 2: + return $this->getFile(); + break; + case 3: + return $this->getVisible(); + break; + case 4: + return $this->getPosition(); + break; + case 5: + return $this->getCreatedAt(); + break; + case 6: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['SelectionContainerImage'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['SelectionContainerImage'][$this->getPrimaryKey()] = true; + $keys = SelectionContainerImageTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getSelectionContainerId(), + $keys[2] => $this->getFile(), + $keys[3] => $this->getVisible(), + $keys[4] => $this->getPosition(), + $keys[5] => $this->getCreatedAt(), + $keys[6] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aSelectionContainer) { + $result['SelectionContainer'] = $this->aSelectionContainer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collSelectionContainerImageI18ns) { + $result['SelectionContainerImageI18ns'] = $this->collSelectionContainerImageI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionContainerImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setSelectionContainerId($value); + break; + case 2: + $this->setFile($value); + break; + case 3: + $this->setVisible($value); + break; + case 4: + $this->setPosition($value); + break; + case 5: + $this->setCreatedAt($value); + break; + case 6: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = SelectionContainerImageTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setSelectionContainerId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setFile($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(SelectionContainerImageTableMap::DATABASE_NAME); + + if ($this->isColumnModified(SelectionContainerImageTableMap::ID)) $criteria->add(SelectionContainerImageTableMap::ID, $this->id); + if ($this->isColumnModified(SelectionContainerImageTableMap::SELECTION_CONTAINER_ID)) $criteria->add(SelectionContainerImageTableMap::SELECTION_CONTAINER_ID, $this->selection_container_id); + if ($this->isColumnModified(SelectionContainerImageTableMap::FILE)) $criteria->add(SelectionContainerImageTableMap::FILE, $this->file); + if ($this->isColumnModified(SelectionContainerImageTableMap::VISIBLE)) $criteria->add(SelectionContainerImageTableMap::VISIBLE, $this->visible); + if ($this->isColumnModified(SelectionContainerImageTableMap::POSITION)) $criteria->add(SelectionContainerImageTableMap::POSITION, $this->position); + if ($this->isColumnModified(SelectionContainerImageTableMap::CREATED_AT)) $criteria->add(SelectionContainerImageTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(SelectionContainerImageTableMap::UPDATED_AT)) $criteria->add(SelectionContainerImageTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(SelectionContainerImageTableMap::DATABASE_NAME); + $criteria->add(SelectionContainerImageTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Selection\Model\SelectionContainerImage (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setSelectionContainerId($this->getSelectionContainerId()); + $copyObj->setFile($this->getFile()); + $copyObj->setVisible($this->getVisible()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getSelectionContainerImageI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addSelectionContainerImageI18n($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Selection\Model\SelectionContainerImage Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildSelectionContainer object. + * + * @param ChildSelectionContainer $v + * @return \Selection\Model\SelectionContainerImage The current object (for fluent API support) + * @throws PropelException + */ + public function setSelectionContainer(ChildSelectionContainer $v = null) + { + if ($v === null) { + $this->setSelectionContainerId(NULL); + } else { + $this->setSelectionContainerId($v->getId()); + } + + $this->aSelectionContainer = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildSelectionContainer object, it will not be re-added. + if ($v !== null) { + $v->addSelectionContainerImage($this); + } + + + return $this; + } + + + /** + * Get the associated ChildSelectionContainer object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildSelectionContainer The associated ChildSelectionContainer object. + * @throws PropelException + */ + public function getSelectionContainer(ConnectionInterface $con = null) + { + if ($this->aSelectionContainer === null && ($this->selection_container_id !== null)) { + $this->aSelectionContainer = ChildSelectionContainerQuery::create()->findPk($this->selection_container_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->aSelectionContainer->addSelectionContainerImages($this); + */ + } + + return $this->aSelectionContainer; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('SelectionContainerImageI18n' == $relationName) { + return $this->initSelectionContainerImageI18ns(); + } + } + + /** + * Clears out the collSelectionContainerImageI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addSelectionContainerImageI18ns() + */ + public function clearSelectionContainerImageI18ns() + { + $this->collSelectionContainerImageI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collSelectionContainerImageI18ns collection loaded partially. + */ + public function resetPartialSelectionContainerImageI18ns($v = true) + { + $this->collSelectionContainerImageI18nsPartial = $v; + } + + /** + * Initializes the collSelectionContainerImageI18ns collection. + * + * By default this just sets the collSelectionContainerImageI18ns collection to an empty array (like clearcollSelectionContainerImageI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initSelectionContainerImageI18ns($overrideExisting = true) + { + if (null !== $this->collSelectionContainerImageI18ns && !$overrideExisting) { + return; + } + $this->collSelectionContainerImageI18ns = new ObjectCollection(); + $this->collSelectionContainerImageI18ns->setModel('\Selection\Model\SelectionContainerImageI18n'); + } + + /** + * Gets an array of ChildSelectionContainerImageI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildSelectionContainerImage is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildSelectionContainerImageI18n[] List of ChildSelectionContainerImageI18n objects + * @throws PropelException + */ + public function getSelectionContainerImageI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collSelectionContainerImageI18nsPartial && !$this->isNew(); + if (null === $this->collSelectionContainerImageI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionContainerImageI18ns) { + // return empty collection + $this->initSelectionContainerImageI18ns(); + } else { + $collSelectionContainerImageI18ns = ChildSelectionContainerImageI18nQuery::create(null, $criteria) + ->filterBySelectionContainerImage($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collSelectionContainerImageI18nsPartial && count($collSelectionContainerImageI18ns)) { + $this->initSelectionContainerImageI18ns(false); + + foreach ($collSelectionContainerImageI18ns as $obj) { + if (false == $this->collSelectionContainerImageI18ns->contains($obj)) { + $this->collSelectionContainerImageI18ns->append($obj); + } + } + + $this->collSelectionContainerImageI18nsPartial = true; + } + + reset($collSelectionContainerImageI18ns); + + return $collSelectionContainerImageI18ns; + } + + if ($partial && $this->collSelectionContainerImageI18ns) { + foreach ($this->collSelectionContainerImageI18ns as $obj) { + if ($obj->isNew()) { + $collSelectionContainerImageI18ns[] = $obj; + } + } + } + + $this->collSelectionContainerImageI18ns = $collSelectionContainerImageI18ns; + $this->collSelectionContainerImageI18nsPartial = false; + } + } + + return $this->collSelectionContainerImageI18ns; + } + + /** + * Sets a collection of SelectionContainerImageI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $selectionContainerImageI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildSelectionContainerImage The current object (for fluent API support) + */ + public function setSelectionContainerImageI18ns(Collection $selectionContainerImageI18ns, ConnectionInterface $con = null) + { + $selectionContainerImageI18nsToDelete = $this->getSelectionContainerImageI18ns(new Criteria(), $con)->diff($selectionContainerImageI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->selectionContainerImageI18nsScheduledForDeletion = clone $selectionContainerImageI18nsToDelete; + + foreach ($selectionContainerImageI18nsToDelete as $selectionContainerImageI18nRemoved) { + $selectionContainerImageI18nRemoved->setSelectionContainerImage(null); + } + + $this->collSelectionContainerImageI18ns = null; + foreach ($selectionContainerImageI18ns as $selectionContainerImageI18n) { + $this->addSelectionContainerImageI18n($selectionContainerImageI18n); + } + + $this->collSelectionContainerImageI18ns = $selectionContainerImageI18ns; + $this->collSelectionContainerImageI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related SelectionContainerImageI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related SelectionContainerImageI18n objects. + * @throws PropelException + */ + public function countSelectionContainerImageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collSelectionContainerImageI18nsPartial && !$this->isNew(); + if (null === $this->collSelectionContainerImageI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionContainerImageI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getSelectionContainerImageI18ns()); + } + + $query = ChildSelectionContainerImageI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterBySelectionContainerImage($this) + ->count($con); + } + + return count($this->collSelectionContainerImageI18ns); + } + + /** + * Method called to associate a ChildSelectionContainerImageI18n object to this object + * through the ChildSelectionContainerImageI18n foreign key attribute. + * + * @param ChildSelectionContainerImageI18n $l ChildSelectionContainerImageI18n + * @return \Selection\Model\SelectionContainerImage The current object (for fluent API support) + */ + public function addSelectionContainerImageI18n(ChildSelectionContainerImageI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collSelectionContainerImageI18ns === null) { + $this->initSelectionContainerImageI18ns(); + $this->collSelectionContainerImageI18nsPartial = true; + } + + if (!in_array($l, $this->collSelectionContainerImageI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddSelectionContainerImageI18n($l); + } + + return $this; + } + + /** + * @param SelectionContainerImageI18n $selectionContainerImageI18n The selectionContainerImageI18n object to add. + */ + protected function doAddSelectionContainerImageI18n($selectionContainerImageI18n) + { + $this->collSelectionContainerImageI18ns[]= $selectionContainerImageI18n; + $selectionContainerImageI18n->setSelectionContainerImage($this); + } + + /** + * @param SelectionContainerImageI18n $selectionContainerImageI18n The selectionContainerImageI18n object to remove. + * @return ChildSelectionContainerImage The current object (for fluent API support) + */ + public function removeSelectionContainerImageI18n($selectionContainerImageI18n) + { + if ($this->getSelectionContainerImageI18ns()->contains($selectionContainerImageI18n)) { + $this->collSelectionContainerImageI18ns->remove($this->collSelectionContainerImageI18ns->search($selectionContainerImageI18n)); + if (null === $this->selectionContainerImageI18nsScheduledForDeletion) { + $this->selectionContainerImageI18nsScheduledForDeletion = clone $this->collSelectionContainerImageI18ns; + $this->selectionContainerImageI18nsScheduledForDeletion->clear(); + } + $this->selectionContainerImageI18nsScheduledForDeletion[]= clone $selectionContainerImageI18n; + $selectionContainerImageI18n->setSelectionContainerImage(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->selection_container_id = null; + $this->file = null; + $this->visible = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collSelectionContainerImageI18ns) { + foreach ($this->collSelectionContainerImageI18ns as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + // i18n behavior + $this->currentLocale = 'en_US'; + $this->currentTranslations = null; + + $this->collSelectionContainerImageI18ns = null; + $this->aSelectionContainer = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(SelectionContainerImageTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildSelectionContainerImage The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[SelectionContainerImageTableMap::UPDATED_AT] = true; + + return $this; + } + + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildSelectionContainerImage The current object (for fluent API support) + */ + public function setLocale($locale = 'en_US') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionContainerImageI18n */ + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collSelectionContainerImageI18ns) { + foreach ($this->collSelectionContainerImageI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildSelectionContainerImageI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildSelectionContainerImageI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addSelectionContainerImageI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionContainerImage The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildSelectionContainerImageI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collSelectionContainerImageI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collSelectionContainerImageI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionContainerImageI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + return $this->getCurrentTranslation()->getTitle(); + } + + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerImageI18n The current object (for fluent API support) + */ + public function setTitle($v) + { $this->getCurrentTranslation()->setTitle($v); + + return $this; + } + + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + return $this->getCurrentTranslation()->getDescription(); + } + + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerImageI18n The current object (for fluent API support) + */ + public function setDescription($v) + { $this->getCurrentTranslation()->setDescription($v); + + return $this; + } + + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + return $this->getCurrentTranslation()->getChapo(); + } + + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerImageI18n The current object (for fluent API support) + */ + public function setChapo($v) + { $this->getCurrentTranslation()->setChapo($v); + + return $this; + } + + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + return $this->getCurrentTranslation()->getPostscriptum(); + } + + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerImageI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { $this->getCurrentTranslation()->setPostscriptum($v); + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/Selection/Model/Base/SelectionContainerImageI18n.php b/local/modules/Selection/Model/Base/SelectionContainerImageI18n.php new file mode 100644 index 00000000..4f89bf1b --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionContainerImageI18n.php @@ -0,0 +1,1442 @@ +locale = 'en_US'; + } + + /** + * Initializes internal state of Selection\Model\Base\SelectionContainerImageI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !!$this->modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another SelectionContainerImageI18n instance. If + * obj is an instance of SelectionContainerImageI18n, delegates to + * equals(SelectionContainerImageI18n). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return SelectionContainerImageI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return SelectionContainerImageI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + + return $this->postscriptum; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContainerImageI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[SelectionContainerImageI18nTableMap::ID] = true; + } + + if ($this->aSelectionContainerImage !== null && $this->aSelectionContainerImage->getId() !== $v) { + $this->aSelectionContainerImage = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerImageI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[SelectionContainerImageI18nTableMap::LOCALE] = true; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerImageI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[SelectionContainerImageI18nTableMap::TITLE] = true; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerImageI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[SelectionContainerImageI18nTableMap::DESCRIPTION] = true; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerImageI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[SelectionContainerImageI18nTableMap::CHAPO] = true; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionContainerImageI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[SelectionContainerImageI18nTableMap::POSTSCRIPTUM] = true; + } + + + return $this; + } // setPostscriptum() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_US') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : SelectionContainerImageI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : SelectionContainerImageI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : SelectionContainerImageI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : SelectionContainerImageI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : SelectionContainerImageI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : SelectionContainerImageI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = SelectionContainerImageI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Selection\Model\SelectionContainerImageI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aSelectionContainerImage !== null && $this->id !== $this->aSelectionContainerImage->getId()) { + $this->aSelectionContainerImage = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionContainerImageI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildSelectionContainerImageI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aSelectionContainerImage = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see SelectionContainerImageI18n::setDeleted() + * @see SelectionContainerImageI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerImageI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildSelectionContainerImageI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerImageI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + SelectionContainerImageI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aSelectionContainerImage !== null) { + if ($this->aSelectionContainerImage->isModified() || $this->aSelectionContainerImage->isNew()) { + $affectedRows += $this->aSelectionContainerImage->save($con); + } + $this->setSelectionContainerImage($this->aSelectionContainerImage); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(SelectionContainerImageI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(SelectionContainerImageI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(SelectionContainerImageI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(SelectionContainerImageI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(SelectionContainerImageI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(SelectionContainerImageI18nTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; + } + + $sql = sprintf( + 'INSERT INTO selection_container_image_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionContainerImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getChapo(); + break; + case 5: + return $this->getPostscriptum(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['SelectionContainerImageI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['SelectionContainerImageI18n'][serialize($this->getPrimaryKey())] = true; + $keys = SelectionContainerImageI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getChapo(), + $keys[5] => $this->getPostscriptum(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aSelectionContainerImage) { + $result['SelectionContainerImage'] = $this->aSelectionContainerImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionContainerImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setChapo($value); + break; + case 5: + $this->setPostscriptum($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = SelectionContainerImageI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(SelectionContainerImageI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(SelectionContainerImageI18nTableMap::ID)) $criteria->add(SelectionContainerImageI18nTableMap::ID, $this->id); + if ($this->isColumnModified(SelectionContainerImageI18nTableMap::LOCALE)) $criteria->add(SelectionContainerImageI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(SelectionContainerImageI18nTableMap::TITLE)) $criteria->add(SelectionContainerImageI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(SelectionContainerImageI18nTableMap::DESCRIPTION)) $criteria->add(SelectionContainerImageI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(SelectionContainerImageI18nTableMap::CHAPO)) $criteria->add(SelectionContainerImageI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(SelectionContainerImageI18nTableMap::POSTSCRIPTUM)) $criteria->add(SelectionContainerImageI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(SelectionContainerImageI18nTableMap::DATABASE_NAME); + $criteria->add(SelectionContainerImageI18nTableMap::ID, $this->id); + $criteria->add(SelectionContainerImageI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Selection\Model\SelectionContainerImageI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setChapo($this->getChapo()); + $copyObj->setPostscriptum($this->getPostscriptum()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Selection\Model\SelectionContainerImageI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildSelectionContainerImage object. + * + * @param ChildSelectionContainerImage $v + * @return \Selection\Model\SelectionContainerImageI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setSelectionContainerImage(ChildSelectionContainerImage $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aSelectionContainerImage = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildSelectionContainerImage object, it will not be re-added. + if ($v !== null) { + $v->addSelectionContainerImageI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildSelectionContainerImage object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildSelectionContainerImage The associated ChildSelectionContainerImage object. + * @throws PropelException + */ + public function getSelectionContainerImage(ConnectionInterface $con = null) + { + if ($this->aSelectionContainerImage === null && ($this->id !== null)) { + $this->aSelectionContainerImage = ChildSelectionContainerImageQuery::create()->findPk($this->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->aSelectionContainerImage->addSelectionContainerImageI18ns($this); + */ + } + + return $this->aSelectionContainerImage; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->title = null; + $this->description = null; + $this->chapo = null; + $this->postscriptum = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aSelectionContainerImage = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(SelectionContainerImageI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/Selection/Model/Base/SelectionContainerImageI18nQuery.php b/local/modules/Selection/Model/Base/SelectionContainerImageI18nQuery.php new file mode 100644 index 00000000..d3176713 --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionContainerImageI18nQuery.php @@ -0,0 +1,607 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionContainerImageI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = SelectionContainerImageI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionContainerImageI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionContainerImageI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM selection_container_image_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildSelectionContainerImageI18n(); + $obj->hydrate($row); + SelectionContainerImageI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionContainerImageI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildSelectionContainerImageI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(SelectionContainerImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(SelectionContainerImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildSelectionContainerImageI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(SelectionContainerImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(SelectionContainerImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterBySelectionContainerImage() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(SelectionContainerImageI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(SelectionContainerImageI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerImageI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionContainerImageI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageI18nQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionContainerImageI18nTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageI18nQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionContainerImageI18nTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageI18nQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionContainerImageI18nTableMap::CHAPO, $chapo, $comparison); + } + + /** + * Filter the query on the postscriptum column + * + * Example usage: + * + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' + * + * + * @param string $postscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageI18nQuery The current query, for fluid interface + */ + public function filterByPostscriptum($postscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($postscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionContainerImageI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query by a related \Selection\Model\SelectionContainerImage object + * + * @param \Selection\Model\SelectionContainerImage|ObjectCollection $selectionContainerImage The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageI18nQuery The current query, for fluid interface + */ + public function filterBySelectionContainerImage($selectionContainerImage, $comparison = null) + { + if ($selectionContainerImage instanceof \Selection\Model\SelectionContainerImage) { + return $this + ->addUsingAlias(SelectionContainerImageI18nTableMap::ID, $selectionContainerImage->getId(), $comparison); + } elseif ($selectionContainerImage instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(SelectionContainerImageI18nTableMap::ID, $selectionContainerImage->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterBySelectionContainerImage() only accepts arguments of type \Selection\Model\SelectionContainerImage or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionContainerImage relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionContainerImageI18nQuery The current query, for fluid interface + */ + public function joinSelectionContainerImage($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionContainerImage'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionContainerImage'); + } + + return $this; + } + + /** + * Use the SelectionContainerImage relation SelectionContainerImage object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionContainerImageQuery A secondary query class using the current class as primary query + */ + public function useSelectionContainerImageQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinSelectionContainerImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionContainerImage', '\Selection\Model\SelectionContainerImageQuery'); + } + + /** + * Exclude object from result + * + * @param ChildSelectionContainerImageI18n $selectionContainerImageI18n Object to remove from the list of results + * + * @return ChildSelectionContainerImageI18nQuery The current query, for fluid interface + */ + public function prune($selectionContainerImageI18n = null) + { + if ($selectionContainerImageI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(SelectionContainerImageI18nTableMap::ID), $selectionContainerImageI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(SelectionContainerImageI18nTableMap::LOCALE), $selectionContainerImageI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the selection_container_image_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerImageI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + SelectionContainerImageI18nTableMap::clearInstancePool(); + SelectionContainerImageI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildSelectionContainerImageI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildSelectionContainerImageI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerImageI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(SelectionContainerImageI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + SelectionContainerImageI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + SelectionContainerImageI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // SelectionContainerImageI18nQuery diff --git a/local/modules/Selection/Model/Base/SelectionContainerImageQuery.php b/local/modules/Selection/Model/Base/SelectionContainerImageQuery.php new file mode 100644 index 00000000..31aa5eb5 --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionContainerImageQuery.php @@ -0,0 +1,891 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionContainerImage|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = SelectionContainerImageTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionContainerImageTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionContainerImage A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, SELECTION_CONTAINER_ID, FILE, VISIBLE, POSITION, CREATED_AT, UPDATED_AT FROM selection_container_image WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildSelectionContainerImage(); + $obj->hydrate($row); + SelectionContainerImageTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionContainerImage|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(SelectionContainerImageTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(SelectionContainerImageTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(SelectionContainerImageTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(SelectionContainerImageTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerImageTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the selection_container_id column + * + * Example usage: + * + * $query->filterBySelectionContainerId(1234); // WHERE selection_container_id = 1234 + * $query->filterBySelectionContainerId(array(12, 34)); // WHERE selection_container_id IN (12, 34) + * $query->filterBySelectionContainerId(array('min' => 12)); // WHERE selection_container_id > 12 + * + * + * @see filterBySelectionContainer() + * + * @param mixed $selectionContainerId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function filterBySelectionContainerId($selectionContainerId = null, $comparison = null) + { + if (is_array($selectionContainerId)) { + $useMinMax = false; + if (isset($selectionContainerId['min'])) { + $this->addUsingAlias(SelectionContainerImageTableMap::SELECTION_CONTAINER_ID, $selectionContainerId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($selectionContainerId['max'])) { + $this->addUsingAlias(SelectionContainerImageTableMap::SELECTION_CONTAINER_ID, $selectionContainerId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerImageTableMap::SELECTION_CONTAINER_ID, $selectionContainerId, $comparison); + } + + /** + * Filter the query on the file column + * + * Example usage: + * + * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' + * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' + * + * + * @param string $file The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function filterByFile($file = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($file)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $file)) { + $file = str_replace('*', '%', $file); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionContainerImageTableMap::FILE, $file, $comparison); + } + + /** + * Filter the query on the visible column + * + * Example usage: + * + * $query->filterByVisible(1234); // WHERE visible = 1234 + * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) + * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 + * + * + * @param mixed $visible The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function filterByVisible($visible = null, $comparison = null) + { + if (is_array($visible)) { + $useMinMax = false; + if (isset($visible['min'])) { + $this->addUsingAlias(SelectionContainerImageTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($visible['max'])) { + $this->addUsingAlias(SelectionContainerImageTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerImageTableMap::VISIBLE, $visible, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(SelectionContainerImageTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(SelectionContainerImageTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerImageTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(SelectionContainerImageTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(SelectionContainerImageTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerImageTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(SelectionContainerImageTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(SelectionContainerImageTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerImageTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Selection\Model\SelectionContainer object + * + * @param \Selection\Model\SelectionContainer|ObjectCollection $selectionContainer The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function filterBySelectionContainer($selectionContainer, $comparison = null) + { + if ($selectionContainer instanceof \Selection\Model\SelectionContainer) { + return $this + ->addUsingAlias(SelectionContainerImageTableMap::SELECTION_CONTAINER_ID, $selectionContainer->getId(), $comparison); + } elseif ($selectionContainer instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(SelectionContainerImageTableMap::SELECTION_CONTAINER_ID, $selectionContainer->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterBySelectionContainer() only accepts arguments of type \Selection\Model\SelectionContainer or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionContainer relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function joinSelectionContainer($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionContainer'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionContainer'); + } + + return $this; + } + + /** + * Use the SelectionContainer relation SelectionContainer object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionContainerQuery A secondary query class using the current class as primary query + */ + public function useSelectionContainerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinSelectionContainer($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionContainer', '\Selection\Model\SelectionContainerQuery'); + } + + /** + * Filter the query by a related \Selection\Model\SelectionContainerImageI18n object + * + * @param \Selection\Model\SelectionContainerImageI18n|ObjectCollection $selectionContainerImageI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function filterBySelectionContainerImageI18n($selectionContainerImageI18n, $comparison = null) + { + if ($selectionContainerImageI18n instanceof \Selection\Model\SelectionContainerImageI18n) { + return $this + ->addUsingAlias(SelectionContainerImageTableMap::ID, $selectionContainerImageI18n->getId(), $comparison); + } elseif ($selectionContainerImageI18n instanceof ObjectCollection) { + return $this + ->useSelectionContainerImageI18nQuery() + ->filterByPrimaryKeys($selectionContainerImageI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterBySelectionContainerImageI18n() only accepts arguments of type \Selection\Model\SelectionContainerImageI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionContainerImageI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function joinSelectionContainerImageI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionContainerImageI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionContainerImageI18n'); + } + + return $this; + } + + /** + * Use the SelectionContainerImageI18n relation SelectionContainerImageI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionContainerImageI18nQuery A secondary query class using the current class as primary query + */ + public function useSelectionContainerImageI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinSelectionContainerImageI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionContainerImageI18n', '\Selection\Model\SelectionContainerImageI18nQuery'); + } + + /** + * Exclude object from result + * + * @param ChildSelectionContainerImage $selectionContainerImage Object to remove from the list of results + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function prune($selectionContainerImage = null) + { + if ($selectionContainerImage) { + $this->addUsingAlias(SelectionContainerImageTableMap::ID, $selectionContainerImage->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the selection_container_image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerImageTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + SelectionContainerImageTableMap::clearInstancePool(); + SelectionContainerImageTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildSelectionContainerImage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildSelectionContainerImage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerImageTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(SelectionContainerImageTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + SelectionContainerImageTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + SelectionContainerImageTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(SelectionContainerImageTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(SelectionContainerImageTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(SelectionContainerImageTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(SelectionContainerImageTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(SelectionContainerImageTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(SelectionContainerImageTableMap::CREATED_AT); + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'SelectionContainerImageI18n'; + + return $this + ->joinSelectionContainerImageI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildSelectionContainerImageQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('SelectionContainerImageI18n'); + $this->with['SelectionContainerImageI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildSelectionContainerImageI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionContainerImageI18n', '\Selection\Model\SelectionContainerImageI18nQuery'); + } + +} // SelectionContainerImageQuery diff --git a/local/modules/Selection/Model/Base/SelectionContainerQuery.php b/local/modules/Selection/Model/Base/SelectionContainerQuery.php new file mode 100644 index 00000000..d0920df4 --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionContainerQuery.php @@ -0,0 +1,886 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionContainer|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = SelectionContainerTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionContainerTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionContainer A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, VISIBLE, POSITION, CREATED_AT, UPDATED_AT FROM selection_container WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildSelectionContainer(); + $obj->hydrate($row); + SelectionContainerTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionContainer|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(SelectionContainerTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(SelectionContainerTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(SelectionContainerTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(SelectionContainerTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the visible column + * + * Example usage: + * + * $query->filterByVisible(1234); // WHERE visible = 1234 + * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) + * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 + * + * + * @param mixed $visible The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function filterByVisible($visible = null, $comparison = null) + { + if (is_array($visible)) { + $useMinMax = false; + if (isset($visible['min'])) { + $this->addUsingAlias(SelectionContainerTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($visible['max'])) { + $this->addUsingAlias(SelectionContainerTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerTableMap::VISIBLE, $visible, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(SelectionContainerTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(SelectionContainerTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(SelectionContainerTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(SelectionContainerTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(SelectionContainerTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(SelectionContainerTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContainerTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Selection\Model\SelectionContainerAssociatedSelection object + * + * @param \Selection\Model\SelectionContainerAssociatedSelection|ObjectCollection $selectionContainerAssociatedSelection the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function filterBySelectionContainerAssociatedSelection($selectionContainerAssociatedSelection, $comparison = null) + { + if ($selectionContainerAssociatedSelection instanceof \Selection\Model\SelectionContainerAssociatedSelection) { + return $this + ->addUsingAlias(SelectionContainerTableMap::ID, $selectionContainerAssociatedSelection->getSelectionContainerId(), $comparison); + } elseif ($selectionContainerAssociatedSelection instanceof ObjectCollection) { + return $this + ->useSelectionContainerAssociatedSelectionQuery() + ->filterByPrimaryKeys($selectionContainerAssociatedSelection->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterBySelectionContainerAssociatedSelection() only accepts arguments of type \Selection\Model\SelectionContainerAssociatedSelection or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionContainerAssociatedSelection relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function joinSelectionContainerAssociatedSelection($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionContainerAssociatedSelection'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionContainerAssociatedSelection'); + } + + return $this; + } + + /** + * Use the SelectionContainerAssociatedSelection relation SelectionContainerAssociatedSelection object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionContainerAssociatedSelectionQuery A secondary query class using the current class as primary query + */ + public function useSelectionContainerAssociatedSelectionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinSelectionContainerAssociatedSelection($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionContainerAssociatedSelection', '\Selection\Model\SelectionContainerAssociatedSelectionQuery'); + } + + /** + * Filter the query by a related \Selection\Model\SelectionContainerImage object + * + * @param \Selection\Model\SelectionContainerImage|ObjectCollection $selectionContainerImage the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function filterBySelectionContainerImage($selectionContainerImage, $comparison = null) + { + if ($selectionContainerImage instanceof \Selection\Model\SelectionContainerImage) { + return $this + ->addUsingAlias(SelectionContainerTableMap::ID, $selectionContainerImage->getSelectionContainerId(), $comparison); + } elseif ($selectionContainerImage instanceof ObjectCollection) { + return $this + ->useSelectionContainerImageQuery() + ->filterByPrimaryKeys($selectionContainerImage->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterBySelectionContainerImage() only accepts arguments of type \Selection\Model\SelectionContainerImage or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionContainerImage relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function joinSelectionContainerImage($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionContainerImage'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionContainerImage'); + } + + return $this; + } + + /** + * Use the SelectionContainerImage relation SelectionContainerImage object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionContainerImageQuery A secondary query class using the current class as primary query + */ + public function useSelectionContainerImageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinSelectionContainerImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionContainerImage', '\Selection\Model\SelectionContainerImageQuery'); + } + + /** + * Filter the query by a related \Selection\Model\SelectionContainerI18n object + * + * @param \Selection\Model\SelectionContainerI18n|ObjectCollection $selectionContainerI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function filterBySelectionContainerI18n($selectionContainerI18n, $comparison = null) + { + if ($selectionContainerI18n instanceof \Selection\Model\SelectionContainerI18n) { + return $this + ->addUsingAlias(SelectionContainerTableMap::ID, $selectionContainerI18n->getId(), $comparison); + } elseif ($selectionContainerI18n instanceof ObjectCollection) { + return $this + ->useSelectionContainerI18nQuery() + ->filterByPrimaryKeys($selectionContainerI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterBySelectionContainerI18n() only accepts arguments of type \Selection\Model\SelectionContainerI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionContainerI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function joinSelectionContainerI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionContainerI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionContainerI18n'); + } + + return $this; + } + + /** + * Use the SelectionContainerI18n relation SelectionContainerI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionContainerI18nQuery A secondary query class using the current class as primary query + */ + public function useSelectionContainerI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinSelectionContainerI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionContainerI18n', '\Selection\Model\SelectionContainerI18nQuery'); + } + + /** + * Exclude object from result + * + * @param ChildSelectionContainer $selectionContainer Object to remove from the list of results + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function prune($selectionContainer = null) + { + if ($selectionContainer) { + $this->addUsingAlias(SelectionContainerTableMap::ID, $selectionContainer->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the selection_container table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + SelectionContainerTableMap::clearInstancePool(); + SelectionContainerTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildSelectionContainer or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildSelectionContainer object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(SelectionContainerTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + SelectionContainerTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + SelectionContainerTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(SelectionContainerTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(SelectionContainerTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(SelectionContainerTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(SelectionContainerTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(SelectionContainerTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(SelectionContainerTableMap::CREATED_AT); + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'SelectionContainerI18n'; + + return $this + ->joinSelectionContainerI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildSelectionContainerQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('SelectionContainerI18n'); + $this->with['SelectionContainerI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildSelectionContainerI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionContainerI18n', '\Selection\Model\SelectionContainerI18nQuery'); + } + +} // SelectionContainerQuery diff --git a/local/modules/Selection/Model/Base/SelectionContent.php b/local/modules/Selection/Model/Base/SelectionContent.php new file mode 100644 index 00000000..6156abad --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionContent.php @@ -0,0 +1,1494 @@ +modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another SelectionContent instance. If + * obj is an instance of SelectionContent, delegates to + * equals(SelectionContent). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return SelectionContent The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return SelectionContent The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [selection_id] column value. + * + * @return int + */ + public function getSelectionId() + { + + return $this->selection_id; + } + + /** + * Get the [content_id] column value. + * + * @return int + */ + public function getContentId() + { + + return $this->content_id; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [selection_id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContent The current object (for fluent API support) + */ + public function setSelectionId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->selection_id !== $v) { + $this->selection_id = $v; + $this->modifiedColumns[SelectionContentTableMap::SELECTION_ID] = true; + } + + if ($this->aSelection !== null && $this->aSelection->getId() !== $v) { + $this->aSelection = null; + } + + + return $this; + } // setSelectionId() + + /** + * Set the value of [content_id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContent The current object (for fluent API support) + */ + public function setContentId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->content_id !== $v) { + $this->content_id = $v; + $this->modifiedColumns[SelectionContentTableMap::CONTENT_ID] = true; + } + + if ($this->aContent !== null && $this->aContent->getId() !== $v) { + $this->aContent = null; + } + + + return $this; + } // setContentId() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionContent The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[SelectionContentTableMap::POSITION] = true; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Selection\Model\SelectionContent The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[SelectionContentTableMap::CREATED_AT] = true; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Selection\Model\SelectionContent The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[SelectionContentTableMap::UPDATED_AT] = true; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : SelectionContentTableMap::translateFieldName('SelectionId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->selection_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : SelectionContentTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->content_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : SelectionContentTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : SelectionContentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : SelectionContentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = SelectionContentTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Selection\Model\SelectionContent object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aSelection !== null && $this->selection_id !== $this->aSelection->getId()) { + $this->aSelection = null; + } + if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { + $this->aContent = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionContentTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildSelectionContentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aContent = null; + $this->aSelection = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see SelectionContent::setDeleted() + * @see SelectionContent::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildSelectionContentQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(SelectionContentTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(SelectionContentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(SelectionContentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + SelectionContentTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aContent !== null) { + if ($this->aContent->isModified() || $this->aContent->isNew()) { + $affectedRows += $this->aContent->save($con); + } + $this->setContent($this->aContent); + } + + if ($this->aSelection !== null) { + if ($this->aSelection->isModified() || $this->aSelection->isNew()) { + $affectedRows += $this->aSelection->save($con); + } + $this->setSelection($this->aSelection); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(SelectionContentTableMap::SELECTION_ID)) { + $modifiedColumns[':p' . $index++] = 'SELECTION_ID'; + } + if ($this->isColumnModified(SelectionContentTableMap::CONTENT_ID)) { + $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; + } + if ($this->isColumnModified(SelectionContentTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(SelectionContentTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(SelectionContentTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO selection_content (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'SELECTION_ID': + $stmt->bindValue($identifier, $this->selection_id, PDO::PARAM_INT); + break; + case 'CONTENT_ID': + $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionContentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getSelectionId(); + break; + case 1: + return $this->getContentId(); + break; + case 2: + return $this->getPosition(); + break; + case 3: + return $this->getCreatedAt(); + break; + case 4: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['SelectionContent'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['SelectionContent'][serialize($this->getPrimaryKey())] = true; + $keys = SelectionContentTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getSelectionId(), + $keys[1] => $this->getContentId(), + $keys[2] => $this->getPosition(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aContent) { + $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aSelection) { + $result['Selection'] = $this->aSelection->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionContentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setSelectionId($value); + break; + case 1: + $this->setContentId($value); + break; + case 2: + $this->setPosition($value); + break; + case 3: + $this->setCreatedAt($value); + break; + case 4: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = SelectionContentTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setSelectionId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setContentId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(SelectionContentTableMap::DATABASE_NAME); + + if ($this->isColumnModified(SelectionContentTableMap::SELECTION_ID)) $criteria->add(SelectionContentTableMap::SELECTION_ID, $this->selection_id); + if ($this->isColumnModified(SelectionContentTableMap::CONTENT_ID)) $criteria->add(SelectionContentTableMap::CONTENT_ID, $this->content_id); + if ($this->isColumnModified(SelectionContentTableMap::POSITION)) $criteria->add(SelectionContentTableMap::POSITION, $this->position); + if ($this->isColumnModified(SelectionContentTableMap::CREATED_AT)) $criteria->add(SelectionContentTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(SelectionContentTableMap::UPDATED_AT)) $criteria->add(SelectionContentTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(SelectionContentTableMap::DATABASE_NAME); + $criteria->add(SelectionContentTableMap::SELECTION_ID, $this->selection_id); + $criteria->add(SelectionContentTableMap::CONTENT_ID, $this->content_id); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getSelectionId(); + $pks[1] = $this->getContentId(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setSelectionId($keys[0]); + $this->setContentId($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getSelectionId()) && (null === $this->getContentId()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Selection\Model\SelectionContent (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setSelectionId($this->getSelectionId()); + $copyObj->setContentId($this->getContentId()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Selection\Model\SelectionContent Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildContent object. + * + * @param ChildContent $v + * @return \Selection\Model\SelectionContent 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->addSelectionContent($this); + } + + + return $this; + } + + + /** + * Get the associated ChildContent object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContent The associated ChildContent object. + * @throws PropelException + */ + public function getContent(ConnectionInterface $con = null) + { + if ($this->aContent === null && ($this->content_id !== null)) { + $this->aContent = ContentQuery::create()->findPk($this->content_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->aContent->addSelectionContents($this); + */ + } + + return $this->aContent; + } + + /** + * Declares an association between this object and a ChildSelection object. + * + * @param ChildSelection $v + * @return \Selection\Model\SelectionContent The current object (for fluent API support) + * @throws PropelException + */ + public function setSelection(ChildSelection $v = null) + { + if ($v === null) { + $this->setSelectionId(NULL); + } else { + $this->setSelectionId($v->getId()); + } + + $this->aSelection = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildSelection object, it will not be re-added. + if ($v !== null) { + $v->addSelectionContent($this); + } + + + return $this; + } + + + /** + * Get the associated ChildSelection object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildSelection The associated ChildSelection object. + * @throws PropelException + */ + public function getSelection(ConnectionInterface $con = null) + { + if ($this->aSelection === null && ($this->selection_id !== null)) { + $this->aSelection = ChildSelectionQuery::create()->findPk($this->selection_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->aSelection->addSelectionContents($this); + */ + } + + return $this->aSelection; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->selection_id = null; + $this->content_id = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aContent = null; + $this->aSelection = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(SelectionContentTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildSelectionContent The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[SelectionContentTableMap::UPDATED_AT] = true; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/Selection/Model/Base/SelectionContentQuery.php b/local/modules/Selection/Model/Base/SelectionContentQuery.php new file mode 100644 index 00000000..6b9b299c --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionContentQuery.php @@ -0,0 +1,774 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$selection_id, $content_id] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionContent|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = SelectionContentTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionContentTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionContent A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT SELECTION_ID, CONTENT_ID, POSITION, CREATED_AT, UPDATED_AT FROM selection_content WHERE SELECTION_ID = :p0 AND CONTENT_ID = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildSelectionContent(); + $obj->hydrate($row); + SelectionContentTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionContent|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(SelectionContentTableMap::SELECTION_ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(SelectionContentTableMap::CONTENT_ID, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(SelectionContentTableMap::SELECTION_ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(SelectionContentTableMap::CONTENT_ID, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the selection_id column + * + * Example usage: + * + * $query->filterBySelectionId(1234); // WHERE selection_id = 1234 + * $query->filterBySelectionId(array(12, 34)); // WHERE selection_id IN (12, 34) + * $query->filterBySelectionId(array('min' => 12)); // WHERE selection_id > 12 + * + * + * @see filterBySelection() + * + * @param mixed $selectionId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function filterBySelectionId($selectionId = null, $comparison = null) + { + if (is_array($selectionId)) { + $useMinMax = false; + if (isset($selectionId['min'])) { + $this->addUsingAlias(SelectionContentTableMap::SELECTION_ID, $selectionId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($selectionId['max'])) { + $this->addUsingAlias(SelectionContentTableMap::SELECTION_ID, $selectionId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContentTableMap::SELECTION_ID, $selectionId, $comparison); + } + + /** + * Filter the query on the content_id column + * + * Example usage: + * + * $query->filterByContentId(1234); // WHERE content_id = 1234 + * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) + * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 + * + * + * @see filterByContent() + * + * @param mixed $contentId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function filterByContentId($contentId = null, $comparison = null) + { + if (is_array($contentId)) { + $useMinMax = false; + if (isset($contentId['min'])) { + $this->addUsingAlias(SelectionContentTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($contentId['max'])) { + $this->addUsingAlias(SelectionContentTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContentTableMap::CONTENT_ID, $contentId, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(SelectionContentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(SelectionContentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContentTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(SelectionContentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(SelectionContentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContentTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(SelectionContentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(SelectionContentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionContentTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * 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 ChildSelectionContentQuery The current query, for fluid interface + */ + public function filterByContent($content, $comparison = null) + { + if ($content instanceof \Thelia\Model\Content) { + return $this + ->addUsingAlias(SelectionContentTableMap::CONTENT_ID, $content->getId(), $comparison); + } elseif ($content instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(SelectionContentTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Content relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Content'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Content'); + } + + return $this; + } + + /** + * Use the Content relation Content object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query + */ + public function useContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); + } + + /** + * Filter the query by a related \Selection\Model\Selection object + * + * @param \Selection\Model\Selection|ObjectCollection $selection The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function filterBySelection($selection, $comparison = null) + { + if ($selection instanceof \Selection\Model\Selection) { + return $this + ->addUsingAlias(SelectionContentTableMap::SELECTION_ID, $selection->getId(), $comparison); + } elseif ($selection instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(SelectionContentTableMap::SELECTION_ID, $selection->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterBySelection() only accepts arguments of type \Selection\Model\Selection or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Selection relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function joinSelection($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Selection'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Selection'); + } + + return $this; + } + + /** + * Use the Selection relation Selection object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionQuery A secondary query class using the current class as primary query + */ + public function useSelectionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinSelection($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Selection', '\Selection\Model\SelectionQuery'); + } + + /** + * Exclude object from result + * + * @param ChildSelectionContent $selectionContent Object to remove from the list of results + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function prune($selectionContent = null) + { + if ($selectionContent) { + $this->addCond('pruneCond0', $this->getAliasedColName(SelectionContentTableMap::SELECTION_ID), $selectionContent->getSelectionId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(SelectionContentTableMap::CONTENT_ID), $selectionContent->getContentId(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the selection_content table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContentTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + SelectionContentTableMap::clearInstancePool(); + SelectionContentTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildSelectionContent or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildSelectionContent object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContentTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(SelectionContentTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + SelectionContentTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + SelectionContentTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(SelectionContentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(SelectionContentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(SelectionContentTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(SelectionContentTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(SelectionContentTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildSelectionContentQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(SelectionContentTableMap::CREATED_AT); + } + +} // SelectionContentQuery diff --git a/local/modules/Selection/Model/Base/SelectionI18n.php b/local/modules/Selection/Model/Base/SelectionI18n.php new file mode 100644 index 00000000..09101714 --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionI18n.php @@ -0,0 +1,1616 @@ +locale = 'en_US'; + } + + /** + * Initializes internal state of Selection\Model\Base\SelectionI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !!$this->modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another SelectionI18n instance. If + * obj is an instance of SelectionI18n, delegates to + * equals(SelectionI18n). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return SelectionI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return SelectionI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + + return $this->postscriptum; + } + + /** + * Get the [meta_title] column value. + * + * @return string + */ + public function getMetaTitle() + { + + return $this->meta_title; + } + + /** + * Get the [meta_description] column value. + * + * @return string + */ + public function getMetaDescription() + { + + return $this->meta_description; + } + + /** + * Get the [meta_keywords] column value. + * + * @return string + */ + public function getMetaKeywords() + { + + return $this->meta_keywords; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[SelectionI18nTableMap::ID] = true; + } + + if ($this->aSelection !== null && $this->aSelection->getId() !== $v) { + $this->aSelection = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[SelectionI18nTableMap::LOCALE] = true; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[SelectionI18nTableMap::TITLE] = true; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[SelectionI18nTableMap::DESCRIPTION] = true; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[SelectionI18nTableMap::CHAPO] = true; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[SelectionI18nTableMap::POSTSCRIPTUM] = true; + } + + + return $this; + } // setPostscriptum() + + /** + * Set the value of [meta_title] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setMetaTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_title !== $v) { + $this->meta_title = $v; + $this->modifiedColumns[SelectionI18nTableMap::META_TITLE] = true; + } + + + return $this; + } // setMetaTitle() + + /** + * Set the value of [meta_description] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setMetaDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_description !== $v) { + $this->meta_description = $v; + $this->modifiedColumns[SelectionI18nTableMap::META_DESCRIPTION] = true; + } + + + return $this; + } // setMetaDescription() + + /** + * Set the value of [meta_keywords] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + */ + public function setMetaKeywords($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->meta_keywords !== $v) { + $this->meta_keywords = $v; + $this->modifiedColumns[SelectionI18nTableMap::META_KEYWORDS] = true; + } + + + return $this; + } // setMetaKeywords() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_US') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : SelectionI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : SelectionI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : SelectionI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : SelectionI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : SelectionI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : SelectionI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : SelectionI18nTableMap::translateFieldName('MetaTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : SelectionI18nTableMap::translateFieldName('MetaDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : SelectionI18nTableMap::translateFieldName('MetaKeywords', TableMap::TYPE_PHPNAME, $indexType)]; + $this->meta_keywords = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 9; // 9 = SelectionI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Selection\Model\SelectionI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aSelection !== null && $this->id !== $this->aSelection->getId()) { + $this->aSelection = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildSelectionI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aSelection = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see SelectionI18n::setDeleted() + * @see SelectionI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildSelectionI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + SelectionI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aSelection !== null) { + if ($this->aSelection->isModified() || $this->aSelection->isNew()) { + $affectedRows += $this->aSelection->save($con); + } + $this->setSelection($this->aSelection); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(SelectionI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(SelectionI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(SelectionI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(SelectionI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(SelectionI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(SelectionI18nTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; + } + if ($this->isColumnModified(SelectionI18nTableMap::META_TITLE)) { + $modifiedColumns[':p' . $index++] = 'META_TITLE'; + } + if ($this->isColumnModified(SelectionI18nTableMap::META_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'META_DESCRIPTION'; + } + if ($this->isColumnModified(SelectionI18nTableMap::META_KEYWORDS)) { + $modifiedColumns[':p' . $index++] = 'META_KEYWORDS'; + } + + $sql = sprintf( + 'INSERT INTO selection_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); + break; + case 'META_TITLE': + $stmt->bindValue($identifier, $this->meta_title, PDO::PARAM_STR); + break; + case 'META_DESCRIPTION': + $stmt->bindValue($identifier, $this->meta_description, PDO::PARAM_STR); + break; + case 'META_KEYWORDS': + $stmt->bindValue($identifier, $this->meta_keywords, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getChapo(); + break; + case 5: + return $this->getPostscriptum(); + break; + case 6: + return $this->getMetaTitle(); + break; + case 7: + return $this->getMetaDescription(); + break; + case 8: + return $this->getMetaKeywords(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['SelectionI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['SelectionI18n'][serialize($this->getPrimaryKey())] = true; + $keys = SelectionI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getChapo(), + $keys[5] => $this->getPostscriptum(), + $keys[6] => $this->getMetaTitle(), + $keys[7] => $this->getMetaDescription(), + $keys[8] => $this->getMetaKeywords(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aSelection) { + $result['Selection'] = $this->aSelection->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setChapo($value); + break; + case 5: + $this->setPostscriptum($value); + break; + case 6: + $this->setMetaTitle($value); + break; + case 7: + $this->setMetaDescription($value); + break; + case 8: + $this->setMetaKeywords($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = SelectionI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setMetaTitle($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setMetaDescription($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setMetaKeywords($arr[$keys[8]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(SelectionI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(SelectionI18nTableMap::ID)) $criteria->add(SelectionI18nTableMap::ID, $this->id); + if ($this->isColumnModified(SelectionI18nTableMap::LOCALE)) $criteria->add(SelectionI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(SelectionI18nTableMap::TITLE)) $criteria->add(SelectionI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(SelectionI18nTableMap::DESCRIPTION)) $criteria->add(SelectionI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(SelectionI18nTableMap::CHAPO)) $criteria->add(SelectionI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(SelectionI18nTableMap::POSTSCRIPTUM)) $criteria->add(SelectionI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + if ($this->isColumnModified(SelectionI18nTableMap::META_TITLE)) $criteria->add(SelectionI18nTableMap::META_TITLE, $this->meta_title); + if ($this->isColumnModified(SelectionI18nTableMap::META_DESCRIPTION)) $criteria->add(SelectionI18nTableMap::META_DESCRIPTION, $this->meta_description); + if ($this->isColumnModified(SelectionI18nTableMap::META_KEYWORDS)) $criteria->add(SelectionI18nTableMap::META_KEYWORDS, $this->meta_keywords); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(SelectionI18nTableMap::DATABASE_NAME); + $criteria->add(SelectionI18nTableMap::ID, $this->id); + $criteria->add(SelectionI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Selection\Model\SelectionI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setChapo($this->getChapo()); + $copyObj->setPostscriptum($this->getPostscriptum()); + $copyObj->setMetaTitle($this->getMetaTitle()); + $copyObj->setMetaDescription($this->getMetaDescription()); + $copyObj->setMetaKeywords($this->getMetaKeywords()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Selection\Model\SelectionI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildSelection object. + * + * @param ChildSelection $v + * @return \Selection\Model\SelectionI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setSelection(ChildSelection $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aSelection = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildSelection object, it will not be re-added. + if ($v !== null) { + $v->addSelectionI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildSelection object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildSelection The associated ChildSelection object. + * @throws PropelException + */ + public function getSelection(ConnectionInterface $con = null) + { + if ($this->aSelection === null && ($this->id !== null)) { + $this->aSelection = ChildSelectionQuery::create()->findPk($this->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->aSelection->addSelectionI18ns($this); + */ + } + + return $this->aSelection; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->title = null; + $this->description = null; + $this->chapo = null; + $this->postscriptum = null; + $this->meta_title = null; + $this->meta_description = null; + $this->meta_keywords = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aSelection = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(SelectionI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/Selection/Model/Base/SelectionI18nQuery.php b/local/modules/Selection/Model/Base/SelectionI18nQuery.php new file mode 100644 index 00000000..00c454d9 --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionI18nQuery.php @@ -0,0 +1,706 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = SelectionI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM, META_TITLE, META_DESCRIPTION, META_KEYWORDS FROM selection_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildSelectionI18n(); + $obj->hydrate($row); + SelectionI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildSelectionI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(SelectionI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(SelectionI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildSelectionI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(SelectionI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(SelectionI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterBySelection() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(SelectionI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(SelectionI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionI18nQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionI18nTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionI18nQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionI18nTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionI18nQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionI18nTableMap::CHAPO, $chapo, $comparison); + } + + /** + * Filter the query on the postscriptum column + * + * Example usage: + * + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' + * + * + * @param string $postscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionI18nQuery The current query, for fluid interface + */ + public function filterByPostscriptum($postscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($postscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query on the meta_title column + * + * Example usage: + * + * $query->filterByMetaTitle('fooValue'); // WHERE meta_title = 'fooValue' + * $query->filterByMetaTitle('%fooValue%'); // WHERE meta_title LIKE '%fooValue%' + * + * + * @param string $metaTitle The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionI18nQuery The current query, for fluid interface + */ + public function filterByMetaTitle($metaTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaTitle)) { + $metaTitle = str_replace('*', '%', $metaTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionI18nTableMap::META_TITLE, $metaTitle, $comparison); + } + + /** + * Filter the query on the meta_description column + * + * Example usage: + * + * $query->filterByMetaDescription('fooValue'); // WHERE meta_description = 'fooValue' + * $query->filterByMetaDescription('%fooValue%'); // WHERE meta_description LIKE '%fooValue%' + * + * + * @param string $metaDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionI18nQuery The current query, for fluid interface + */ + public function filterByMetaDescription($metaDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaDescription)) { + $metaDescription = str_replace('*', '%', $metaDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionI18nTableMap::META_DESCRIPTION, $metaDescription, $comparison); + } + + /** + * Filter the query on the meta_keywords column + * + * Example usage: + * + * $query->filterByMetaKeywords('fooValue'); // WHERE meta_keywords = 'fooValue' + * $query->filterByMetaKeywords('%fooValue%'); // WHERE meta_keywords LIKE '%fooValue%' + * + * + * @param string $metaKeywords The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionI18nQuery The current query, for fluid interface + */ + public function filterByMetaKeywords($metaKeywords = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($metaKeywords)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $metaKeywords)) { + $metaKeywords = str_replace('*', '%', $metaKeywords); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionI18nTableMap::META_KEYWORDS, $metaKeywords, $comparison); + } + + /** + * Filter the query by a related \Selection\Model\Selection object + * + * @param \Selection\Model\Selection|ObjectCollection $selection The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionI18nQuery The current query, for fluid interface + */ + public function filterBySelection($selection, $comparison = null) + { + if ($selection instanceof \Selection\Model\Selection) { + return $this + ->addUsingAlias(SelectionI18nTableMap::ID, $selection->getId(), $comparison); + } elseif ($selection instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(SelectionI18nTableMap::ID, $selection->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterBySelection() only accepts arguments of type \Selection\Model\Selection or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Selection relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionI18nQuery The current query, for fluid interface + */ + public function joinSelection($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Selection'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Selection'); + } + + return $this; + } + + /** + * Use the Selection relation Selection object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionQuery A secondary query class using the current class as primary query + */ + public function useSelectionQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinSelection($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Selection', '\Selection\Model\SelectionQuery'); + } + + /** + * Exclude object from result + * + * @param ChildSelectionI18n $selectionI18n Object to remove from the list of results + * + * @return ChildSelectionI18nQuery The current query, for fluid interface + */ + public function prune($selectionI18n = null) + { + if ($selectionI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(SelectionI18nTableMap::ID), $selectionI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(SelectionI18nTableMap::LOCALE), $selectionI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the selection_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + SelectionI18nTableMap::clearInstancePool(); + SelectionI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildSelectionI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildSelectionI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(SelectionI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + SelectionI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + SelectionI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // SelectionI18nQuery diff --git a/local/modules/Selection/Model/Base/SelectionImage.php b/local/modules/Selection/Model/Base/SelectionImage.php new file mode 100644 index 00000000..7ecf9b7e --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionImage.php @@ -0,0 +1,2067 @@ +visible = 1; + } + + /** + * Initializes internal state of Selection\Model\Base\SelectionImage object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !!$this->modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another SelectionImage instance. If + * obj is an instance of SelectionImage, delegates to + * equals(SelectionImage). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return SelectionImage The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return SelectionImage The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [selection_id] column value. + * + * @return int + */ + public function getSelectionId() + { + + return $this->selection_id; + } + + /** + * Get the [file] column value. + * + * @return string + */ + public function getFile() + { + + return $this->file; + } + + /** + * Get the [visible] column value. + * + * @return int + */ + public function getVisible() + { + + return $this->visible; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionImage The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[SelectionImageTableMap::ID] = true; + } + + + return $this; + } // setId() + + /** + * Set the value of [selection_id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionImage The current object (for fluent API support) + */ + public function setSelectionId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->selection_id !== $v) { + $this->selection_id = $v; + $this->modifiedColumns[SelectionImageTableMap::SELECTION_ID] = true; + } + + if ($this->aSelection !== null && $this->aSelection->getId() !== $v) { + $this->aSelection = null; + } + + + return $this; + } // setSelectionId() + + /** + * Set the value of [file] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionImage The current object (for fluent API support) + */ + public function setFile($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->file !== $v) { + $this->file = $v; + $this->modifiedColumns[SelectionImageTableMap::FILE] = true; + } + + + return $this; + } // setFile() + + /** + * Set the value of [visible] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionImage The current object (for fluent API support) + */ + public function setVisible($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->visible !== $v) { + $this->visible = $v; + $this->modifiedColumns[SelectionImageTableMap::VISIBLE] = true; + } + + + return $this; + } // setVisible() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionImage The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[SelectionImageTableMap::POSITION] = true; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Selection\Model\SelectionImage The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[SelectionImageTableMap::CREATED_AT] = true; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Selection\Model\SelectionImage The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[SelectionImageTableMap::UPDATED_AT] = true; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->visible !== 1) { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : SelectionImageTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : SelectionImageTableMap::translateFieldName('SelectionId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->selection_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : SelectionImageTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; + $this->file = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : SelectionImageTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $this->visible = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : SelectionImageTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : SelectionImageTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : SelectionImageTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 7; // 7 = SelectionImageTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Selection\Model\SelectionImage object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aSelection !== null && $this->selection_id !== $this->aSelection->getId()) { + $this->aSelection = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionImageTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildSelectionImageQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aSelection = null; + $this->collSelectionImageI18ns = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see SelectionImage::setDeleted() + * @see SelectionImage::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionImageTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildSelectionImageQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionImageTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(SelectionImageTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(SelectionImageTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(SelectionImageTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + SelectionImageTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aSelection !== null) { + if ($this->aSelection->isModified() || $this->aSelection->isNew()) { + $affectedRows += $this->aSelection->save($con); + } + $this->setSelection($this->aSelection); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->selectionImageI18nsScheduledForDeletion !== null) { + if (!$this->selectionImageI18nsScheduledForDeletion->isEmpty()) { + \Selection\Model\SelectionImageI18nQuery::create() + ->filterByPrimaryKeys($this->selectionImageI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->selectionImageI18nsScheduledForDeletion = null; + } + } + + if ($this->collSelectionImageI18ns !== null) { + foreach ($this->collSelectionImageI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[SelectionImageTableMap::ID] = true; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . SelectionImageTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(SelectionImageTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(SelectionImageTableMap::SELECTION_ID)) { + $modifiedColumns[':p' . $index++] = 'SELECTION_ID'; + } + if ($this->isColumnModified(SelectionImageTableMap::FILE)) { + $modifiedColumns[':p' . $index++] = 'FILE'; + } + if ($this->isColumnModified(SelectionImageTableMap::VISIBLE)) { + $modifiedColumns[':p' . $index++] = 'VISIBLE'; + } + if ($this->isColumnModified(SelectionImageTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(SelectionImageTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(SelectionImageTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO selection_image (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'SELECTION_ID': + $stmt->bindValue($identifier, $this->selection_id, PDO::PARAM_INT); + break; + case 'FILE': + $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); + break; + case 'VISIBLE': + $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getSelectionId(); + break; + case 2: + return $this->getFile(); + break; + case 3: + return $this->getVisible(); + break; + case 4: + return $this->getPosition(); + break; + case 5: + return $this->getCreatedAt(); + break; + case 6: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['SelectionImage'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['SelectionImage'][$this->getPrimaryKey()] = true; + $keys = SelectionImageTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getSelectionId(), + $keys[2] => $this->getFile(), + $keys[3] => $this->getVisible(), + $keys[4] => $this->getPosition(), + $keys[5] => $this->getCreatedAt(), + $keys[6] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aSelection) { + $result['Selection'] = $this->aSelection->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collSelectionImageI18ns) { + $result['SelectionImageI18ns'] = $this->collSelectionImageI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setSelectionId($value); + break; + case 2: + $this->setFile($value); + break; + case 3: + $this->setVisible($value); + break; + case 4: + $this->setPosition($value); + break; + case 5: + $this->setCreatedAt($value); + break; + case 6: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = SelectionImageTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setSelectionId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setFile($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(SelectionImageTableMap::DATABASE_NAME); + + if ($this->isColumnModified(SelectionImageTableMap::ID)) $criteria->add(SelectionImageTableMap::ID, $this->id); + if ($this->isColumnModified(SelectionImageTableMap::SELECTION_ID)) $criteria->add(SelectionImageTableMap::SELECTION_ID, $this->selection_id); + if ($this->isColumnModified(SelectionImageTableMap::FILE)) $criteria->add(SelectionImageTableMap::FILE, $this->file); + if ($this->isColumnModified(SelectionImageTableMap::VISIBLE)) $criteria->add(SelectionImageTableMap::VISIBLE, $this->visible); + if ($this->isColumnModified(SelectionImageTableMap::POSITION)) $criteria->add(SelectionImageTableMap::POSITION, $this->position); + if ($this->isColumnModified(SelectionImageTableMap::CREATED_AT)) $criteria->add(SelectionImageTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(SelectionImageTableMap::UPDATED_AT)) $criteria->add(SelectionImageTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(SelectionImageTableMap::DATABASE_NAME); + $criteria->add(SelectionImageTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Selection\Model\SelectionImage (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setSelectionId($this->getSelectionId()); + $copyObj->setFile($this->getFile()); + $copyObj->setVisible($this->getVisible()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getSelectionImageI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addSelectionImageI18n($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Selection\Model\SelectionImage Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildSelection object. + * + * @param ChildSelection $v + * @return \Selection\Model\SelectionImage The current object (for fluent API support) + * @throws PropelException + */ + public function setSelection(ChildSelection $v = null) + { + if ($v === null) { + $this->setSelectionId(NULL); + } else { + $this->setSelectionId($v->getId()); + } + + $this->aSelection = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildSelection object, it will not be re-added. + if ($v !== null) { + $v->addSelectionImage($this); + } + + + return $this; + } + + + /** + * Get the associated ChildSelection object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildSelection The associated ChildSelection object. + * @throws PropelException + */ + public function getSelection(ConnectionInterface $con = null) + { + if ($this->aSelection === null && ($this->selection_id !== null)) { + $this->aSelection = ChildSelectionQuery::create()->findPk($this->selection_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->aSelection->addSelectionImages($this); + */ + } + + return $this->aSelection; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('SelectionImageI18n' == $relationName) { + return $this->initSelectionImageI18ns(); + } + } + + /** + * Clears out the collSelectionImageI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addSelectionImageI18ns() + */ + public function clearSelectionImageI18ns() + { + $this->collSelectionImageI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collSelectionImageI18ns collection loaded partially. + */ + public function resetPartialSelectionImageI18ns($v = true) + { + $this->collSelectionImageI18nsPartial = $v; + } + + /** + * Initializes the collSelectionImageI18ns collection. + * + * By default this just sets the collSelectionImageI18ns collection to an empty array (like clearcollSelectionImageI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initSelectionImageI18ns($overrideExisting = true) + { + if (null !== $this->collSelectionImageI18ns && !$overrideExisting) { + return; + } + $this->collSelectionImageI18ns = new ObjectCollection(); + $this->collSelectionImageI18ns->setModel('\Selection\Model\SelectionImageI18n'); + } + + /** + * Gets an array of ChildSelectionImageI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildSelectionImage is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildSelectionImageI18n[] List of ChildSelectionImageI18n objects + * @throws PropelException + */ + public function getSelectionImageI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collSelectionImageI18nsPartial && !$this->isNew(); + if (null === $this->collSelectionImageI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionImageI18ns) { + // return empty collection + $this->initSelectionImageI18ns(); + } else { + $collSelectionImageI18ns = ChildSelectionImageI18nQuery::create(null, $criteria) + ->filterBySelectionImage($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collSelectionImageI18nsPartial && count($collSelectionImageI18ns)) { + $this->initSelectionImageI18ns(false); + + foreach ($collSelectionImageI18ns as $obj) { + if (false == $this->collSelectionImageI18ns->contains($obj)) { + $this->collSelectionImageI18ns->append($obj); + } + } + + $this->collSelectionImageI18nsPartial = true; + } + + reset($collSelectionImageI18ns); + + return $collSelectionImageI18ns; + } + + if ($partial && $this->collSelectionImageI18ns) { + foreach ($this->collSelectionImageI18ns as $obj) { + if ($obj->isNew()) { + $collSelectionImageI18ns[] = $obj; + } + } + } + + $this->collSelectionImageI18ns = $collSelectionImageI18ns; + $this->collSelectionImageI18nsPartial = false; + } + } + + return $this->collSelectionImageI18ns; + } + + /** + * Sets a collection of SelectionImageI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $selectionImageI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildSelectionImage The current object (for fluent API support) + */ + public function setSelectionImageI18ns(Collection $selectionImageI18ns, ConnectionInterface $con = null) + { + $selectionImageI18nsToDelete = $this->getSelectionImageI18ns(new Criteria(), $con)->diff($selectionImageI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->selectionImageI18nsScheduledForDeletion = clone $selectionImageI18nsToDelete; + + foreach ($selectionImageI18nsToDelete as $selectionImageI18nRemoved) { + $selectionImageI18nRemoved->setSelectionImage(null); + } + + $this->collSelectionImageI18ns = null; + foreach ($selectionImageI18ns as $selectionImageI18n) { + $this->addSelectionImageI18n($selectionImageI18n); + } + + $this->collSelectionImageI18ns = $selectionImageI18ns; + $this->collSelectionImageI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related SelectionImageI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related SelectionImageI18n objects. + * @throws PropelException + */ + public function countSelectionImageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collSelectionImageI18nsPartial && !$this->isNew(); + if (null === $this->collSelectionImageI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collSelectionImageI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getSelectionImageI18ns()); + } + + $query = ChildSelectionImageI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterBySelectionImage($this) + ->count($con); + } + + return count($this->collSelectionImageI18ns); + } + + /** + * Method called to associate a ChildSelectionImageI18n object to this object + * through the ChildSelectionImageI18n foreign key attribute. + * + * @param ChildSelectionImageI18n $l ChildSelectionImageI18n + * @return \Selection\Model\SelectionImage The current object (for fluent API support) + */ + public function addSelectionImageI18n(ChildSelectionImageI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collSelectionImageI18ns === null) { + $this->initSelectionImageI18ns(); + $this->collSelectionImageI18nsPartial = true; + } + + if (!in_array($l, $this->collSelectionImageI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddSelectionImageI18n($l); + } + + return $this; + } + + /** + * @param SelectionImageI18n $selectionImageI18n The selectionImageI18n object to add. + */ + protected function doAddSelectionImageI18n($selectionImageI18n) + { + $this->collSelectionImageI18ns[]= $selectionImageI18n; + $selectionImageI18n->setSelectionImage($this); + } + + /** + * @param SelectionImageI18n $selectionImageI18n The selectionImageI18n object to remove. + * @return ChildSelectionImage The current object (for fluent API support) + */ + public function removeSelectionImageI18n($selectionImageI18n) + { + if ($this->getSelectionImageI18ns()->contains($selectionImageI18n)) { + $this->collSelectionImageI18ns->remove($this->collSelectionImageI18ns->search($selectionImageI18n)); + if (null === $this->selectionImageI18nsScheduledForDeletion) { + $this->selectionImageI18nsScheduledForDeletion = clone $this->collSelectionImageI18ns; + $this->selectionImageI18nsScheduledForDeletion->clear(); + } + $this->selectionImageI18nsScheduledForDeletion[]= clone $selectionImageI18n; + $selectionImageI18n->setSelectionImage(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->selection_id = null; + $this->file = null; + $this->visible = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collSelectionImageI18ns) { + foreach ($this->collSelectionImageI18ns as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + // i18n behavior + $this->currentLocale = 'en_US'; + $this->currentTranslations = null; + + $this->collSelectionImageI18ns = null; + $this->aSelection = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(SelectionImageTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildSelectionImage The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[SelectionImageTableMap::UPDATED_AT] = true; + + return $this; + } + + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildSelectionImage The current object (for fluent API support) + */ + public function setLocale($locale = 'en_US') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionImageI18n */ + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collSelectionImageI18ns) { + foreach ($this->collSelectionImageI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildSelectionImageI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildSelectionImageI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addSelectionImageI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionImage The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildSelectionImageI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collSelectionImageI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collSelectionImageI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionImageI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + return $this->getCurrentTranslation()->getTitle(); + } + + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionImageI18n The current object (for fluent API support) + */ + public function setTitle($v) + { $this->getCurrentTranslation()->setTitle($v); + + return $this; + } + + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + return $this->getCurrentTranslation()->getDescription(); + } + + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionImageI18n The current object (for fluent API support) + */ + public function setDescription($v) + { $this->getCurrentTranslation()->setDescription($v); + + return $this; + } + + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + return $this->getCurrentTranslation()->getChapo(); + } + + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionImageI18n The current object (for fluent API support) + */ + public function setChapo($v) + { $this->getCurrentTranslation()->setChapo($v); + + return $this; + } + + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + return $this->getCurrentTranslation()->getPostscriptum(); + } + + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionImageI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { $this->getCurrentTranslation()->setPostscriptum($v); + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/Selection/Model/Base/SelectionImageI18n.php b/local/modules/Selection/Model/Base/SelectionImageI18n.php new file mode 100644 index 00000000..b9071de3 --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionImageI18n.php @@ -0,0 +1,1442 @@ +locale = 'en_US'; + } + + /** + * Initializes internal state of Selection\Model\Base\SelectionImageI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !!$this->modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another SelectionImageI18n instance. If + * obj is an instance of SelectionImageI18n, delegates to + * equals(SelectionImageI18n). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return SelectionImageI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return SelectionImageI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + + return $this->postscriptum; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionImageI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[SelectionImageI18nTableMap::ID] = true; + } + + if ($this->aSelectionImage !== null && $this->aSelectionImage->getId() !== $v) { + $this->aSelectionImage = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionImageI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[SelectionImageI18nTableMap::LOCALE] = true; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionImageI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[SelectionImageI18nTableMap::TITLE] = true; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionImageI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[SelectionImageI18nTableMap::DESCRIPTION] = true; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionImageI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[SelectionImageI18nTableMap::CHAPO] = true; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Selection\Model\SelectionImageI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[SelectionImageI18nTableMap::POSTSCRIPTUM] = true; + } + + + return $this; + } // setPostscriptum() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_US') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : SelectionImageI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : SelectionImageI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : SelectionImageI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : SelectionImageI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : SelectionImageI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : SelectionImageI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = SelectionImageI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Selection\Model\SelectionImageI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aSelectionImage !== null && $this->id !== $this->aSelectionImage->getId()) { + $this->aSelectionImage = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionImageI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildSelectionImageI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aSelectionImage = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see SelectionImageI18n::setDeleted() + * @see SelectionImageI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionImageI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildSelectionImageI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionImageI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + SelectionImageI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aSelectionImage !== null) { + if ($this->aSelectionImage->isModified() || $this->aSelectionImage->isNew()) { + $affectedRows += $this->aSelectionImage->save($con); + } + $this->setSelectionImage($this->aSelectionImage); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(SelectionImageI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(SelectionImageI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(SelectionImageI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(SelectionImageI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(SelectionImageI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(SelectionImageI18nTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; + } + + $sql = sprintf( + 'INSERT INTO selection_image_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getChapo(); + break; + case 5: + return $this->getPostscriptum(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['SelectionImageI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['SelectionImageI18n'][serialize($this->getPrimaryKey())] = true; + $keys = SelectionImageI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getChapo(), + $keys[5] => $this->getPostscriptum(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aSelectionImage) { + $result['SelectionImage'] = $this->aSelectionImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setChapo($value); + break; + case 5: + $this->setPostscriptum($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = SelectionImageI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(SelectionImageI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(SelectionImageI18nTableMap::ID)) $criteria->add(SelectionImageI18nTableMap::ID, $this->id); + if ($this->isColumnModified(SelectionImageI18nTableMap::LOCALE)) $criteria->add(SelectionImageI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(SelectionImageI18nTableMap::TITLE)) $criteria->add(SelectionImageI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(SelectionImageI18nTableMap::DESCRIPTION)) $criteria->add(SelectionImageI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(SelectionImageI18nTableMap::CHAPO)) $criteria->add(SelectionImageI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(SelectionImageI18nTableMap::POSTSCRIPTUM)) $criteria->add(SelectionImageI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(SelectionImageI18nTableMap::DATABASE_NAME); + $criteria->add(SelectionImageI18nTableMap::ID, $this->id); + $criteria->add(SelectionImageI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Selection\Model\SelectionImageI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setChapo($this->getChapo()); + $copyObj->setPostscriptum($this->getPostscriptum()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Selection\Model\SelectionImageI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildSelectionImage object. + * + * @param ChildSelectionImage $v + * @return \Selection\Model\SelectionImageI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setSelectionImage(ChildSelectionImage $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aSelectionImage = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildSelectionImage object, it will not be re-added. + if ($v !== null) { + $v->addSelectionImageI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildSelectionImage object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildSelectionImage The associated ChildSelectionImage object. + * @throws PropelException + */ + public function getSelectionImage(ConnectionInterface $con = null) + { + if ($this->aSelectionImage === null && ($this->id !== null)) { + $this->aSelectionImage = ChildSelectionImageQuery::create()->findPk($this->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->aSelectionImage->addSelectionImageI18ns($this); + */ + } + + return $this->aSelectionImage; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->title = null; + $this->description = null; + $this->chapo = null; + $this->postscriptum = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aSelectionImage = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(SelectionImageI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/Selection/Model/Base/SelectionImageI18nQuery.php b/local/modules/Selection/Model/Base/SelectionImageI18nQuery.php new file mode 100644 index 00000000..131c478a --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionImageI18nQuery.php @@ -0,0 +1,607 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionImageI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = SelectionImageI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionImageI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionImageI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM selection_image_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildSelectionImageI18n(); + $obj->hydrate($row); + SelectionImageI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionImageI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildSelectionImageI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(SelectionImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(SelectionImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildSelectionImageI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(SelectionImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(SelectionImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterBySelectionImage() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(SelectionImageI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(SelectionImageI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionImageI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionImageI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageI18nQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionImageI18nTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageI18nQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionImageI18nTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageI18nQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionImageI18nTableMap::CHAPO, $chapo, $comparison); + } + + /** + * Filter the query on the postscriptum column + * + * Example usage: + * + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' + * + * + * @param string $postscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageI18nQuery The current query, for fluid interface + */ + public function filterByPostscriptum($postscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($postscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionImageI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query by a related \Selection\Model\SelectionImage object + * + * @param \Selection\Model\SelectionImage|ObjectCollection $selectionImage The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageI18nQuery The current query, for fluid interface + */ + public function filterBySelectionImage($selectionImage, $comparison = null) + { + if ($selectionImage instanceof \Selection\Model\SelectionImage) { + return $this + ->addUsingAlias(SelectionImageI18nTableMap::ID, $selectionImage->getId(), $comparison); + } elseif ($selectionImage instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(SelectionImageI18nTableMap::ID, $selectionImage->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterBySelectionImage() only accepts arguments of type \Selection\Model\SelectionImage or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionImage relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionImageI18nQuery The current query, for fluid interface + */ + public function joinSelectionImage($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionImage'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionImage'); + } + + return $this; + } + + /** + * Use the SelectionImage relation SelectionImage object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionImageQuery A secondary query class using the current class as primary query + */ + public function useSelectionImageQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinSelectionImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionImage', '\Selection\Model\SelectionImageQuery'); + } + + /** + * Exclude object from result + * + * @param ChildSelectionImageI18n $selectionImageI18n Object to remove from the list of results + * + * @return ChildSelectionImageI18nQuery The current query, for fluid interface + */ + public function prune($selectionImageI18n = null) + { + if ($selectionImageI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(SelectionImageI18nTableMap::ID), $selectionImageI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(SelectionImageI18nTableMap::LOCALE), $selectionImageI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the selection_image_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionImageI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + SelectionImageI18nTableMap::clearInstancePool(); + SelectionImageI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildSelectionImageI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildSelectionImageI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionImageI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(SelectionImageI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + SelectionImageI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + SelectionImageI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // SelectionImageI18nQuery diff --git a/local/modules/Selection/Model/Base/SelectionImageQuery.php b/local/modules/Selection/Model/Base/SelectionImageQuery.php new file mode 100644 index 00000000..2a1d9500 --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionImageQuery.php @@ -0,0 +1,891 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionImage|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = SelectionImageTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionImageTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionImage A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, SELECTION_ID, FILE, VISIBLE, POSITION, CREATED_AT, UPDATED_AT FROM selection_image WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildSelectionImage(); + $obj->hydrate($row); + SelectionImageTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionImage|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(SelectionImageTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(SelectionImageTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(SelectionImageTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(SelectionImageTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionImageTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the selection_id column + * + * Example usage: + * + * $query->filterBySelectionId(1234); // WHERE selection_id = 1234 + * $query->filterBySelectionId(array(12, 34)); // WHERE selection_id IN (12, 34) + * $query->filterBySelectionId(array('min' => 12)); // WHERE selection_id > 12 + * + * + * @see filterBySelection() + * + * @param mixed $selectionId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function filterBySelectionId($selectionId = null, $comparison = null) + { + if (is_array($selectionId)) { + $useMinMax = false; + if (isset($selectionId['min'])) { + $this->addUsingAlias(SelectionImageTableMap::SELECTION_ID, $selectionId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($selectionId['max'])) { + $this->addUsingAlias(SelectionImageTableMap::SELECTION_ID, $selectionId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionImageTableMap::SELECTION_ID, $selectionId, $comparison); + } + + /** + * Filter the query on the file column + * + * Example usage: + * + * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' + * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' + * + * + * @param string $file The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function filterByFile($file = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($file)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $file)) { + $file = str_replace('*', '%', $file); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(SelectionImageTableMap::FILE, $file, $comparison); + } + + /** + * Filter the query on the visible column + * + * Example usage: + * + * $query->filterByVisible(1234); // WHERE visible = 1234 + * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) + * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 + * + * + * @param mixed $visible The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function filterByVisible($visible = null, $comparison = null) + { + if (is_array($visible)) { + $useMinMax = false; + if (isset($visible['min'])) { + $this->addUsingAlias(SelectionImageTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($visible['max'])) { + $this->addUsingAlias(SelectionImageTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionImageTableMap::VISIBLE, $visible, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(SelectionImageTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(SelectionImageTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionImageTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(SelectionImageTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(SelectionImageTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionImageTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(SelectionImageTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(SelectionImageTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionImageTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Selection\Model\Selection object + * + * @param \Selection\Model\Selection|ObjectCollection $selection The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function filterBySelection($selection, $comparison = null) + { + if ($selection instanceof \Selection\Model\Selection) { + return $this + ->addUsingAlias(SelectionImageTableMap::SELECTION_ID, $selection->getId(), $comparison); + } elseif ($selection instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(SelectionImageTableMap::SELECTION_ID, $selection->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterBySelection() only accepts arguments of type \Selection\Model\Selection or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Selection relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function joinSelection($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Selection'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Selection'); + } + + return $this; + } + + /** + * Use the Selection relation Selection object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionQuery A secondary query class using the current class as primary query + */ + public function useSelectionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinSelection($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Selection', '\Selection\Model\SelectionQuery'); + } + + /** + * Filter the query by a related \Selection\Model\SelectionImageI18n object + * + * @param \Selection\Model\SelectionImageI18n|ObjectCollection $selectionImageI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function filterBySelectionImageI18n($selectionImageI18n, $comparison = null) + { + if ($selectionImageI18n instanceof \Selection\Model\SelectionImageI18n) { + return $this + ->addUsingAlias(SelectionImageTableMap::ID, $selectionImageI18n->getId(), $comparison); + } elseif ($selectionImageI18n instanceof ObjectCollection) { + return $this + ->useSelectionImageI18nQuery() + ->filterByPrimaryKeys($selectionImageI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterBySelectionImageI18n() only accepts arguments of type \Selection\Model\SelectionImageI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionImageI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function joinSelectionImageI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionImageI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionImageI18n'); + } + + return $this; + } + + /** + * Use the SelectionImageI18n relation SelectionImageI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionImageI18nQuery A secondary query class using the current class as primary query + */ + public function useSelectionImageI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinSelectionImageI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionImageI18n', '\Selection\Model\SelectionImageI18nQuery'); + } + + /** + * Exclude object from result + * + * @param ChildSelectionImage $selectionImage Object to remove from the list of results + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function prune($selectionImage = null) + { + if ($selectionImage) { + $this->addUsingAlias(SelectionImageTableMap::ID, $selectionImage->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the selection_image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionImageTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + SelectionImageTableMap::clearInstancePool(); + SelectionImageTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildSelectionImage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildSelectionImage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionImageTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(SelectionImageTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + SelectionImageTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + SelectionImageTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(SelectionImageTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(SelectionImageTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(SelectionImageTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(SelectionImageTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(SelectionImageTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(SelectionImageTableMap::CREATED_AT); + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'SelectionImageI18n'; + + return $this + ->joinSelectionImageI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildSelectionImageQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('SelectionImageI18n'); + $this->with['SelectionImageI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildSelectionImageI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionImageI18n', '\Selection\Model\SelectionImageI18nQuery'); + } + +} // SelectionImageQuery diff --git a/local/modules/Selection/Model/Base/SelectionProduct.php b/local/modules/Selection/Model/Base/SelectionProduct.php new file mode 100644 index 00000000..a70a6cf9 --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionProduct.php @@ -0,0 +1,1494 @@ +modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another SelectionProduct instance. If + * obj is an instance of SelectionProduct, delegates to + * equals(SelectionProduct). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return SelectionProduct The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return SelectionProduct The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [selection_id] column value. + * + * @return int + */ + public function getSelectionId() + { + + return $this->selection_id; + } + + /** + * Get the [product_id] column value. + * + * @return int + */ + public function getProductId() + { + + return $this->product_id; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [selection_id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionProduct The current object (for fluent API support) + */ + public function setSelectionId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->selection_id !== $v) { + $this->selection_id = $v; + $this->modifiedColumns[SelectionProductTableMap::SELECTION_ID] = true; + } + + if ($this->aSelection !== null && $this->aSelection->getId() !== $v) { + $this->aSelection = null; + } + + + return $this; + } // setSelectionId() + + /** + * Set the value of [product_id] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionProduct The current object (for fluent API support) + */ + public function setProductId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->product_id !== $v) { + $this->product_id = $v; + $this->modifiedColumns[SelectionProductTableMap::PRODUCT_ID] = true; + } + + if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { + $this->aProduct = null; + } + + + return $this; + } // setProductId() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Selection\Model\SelectionProduct The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[SelectionProductTableMap::POSITION] = true; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Selection\Model\SelectionProduct The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[SelectionProductTableMap::CREATED_AT] = true; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Selection\Model\SelectionProduct The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[SelectionProductTableMap::UPDATED_AT] = true; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : SelectionProductTableMap::translateFieldName('SelectionId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->selection_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : SelectionProductTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : SelectionProductTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : SelectionProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : SelectionProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = SelectionProductTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Selection\Model\SelectionProduct object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aSelection !== null && $this->selection_id !== $this->aSelection->getId()) { + $this->aSelection = null; + } + if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { + $this->aProduct = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionProductTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildSelectionProductQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aProduct = null; + $this->aSelection = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see SelectionProduct::setDeleted() + * @see SelectionProduct::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionProductTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildSelectionProductQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionProductTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(SelectionProductTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(SelectionProductTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(SelectionProductTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + SelectionProductTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aProduct !== null) { + if ($this->aProduct->isModified() || $this->aProduct->isNew()) { + $affectedRows += $this->aProduct->save($con); + } + $this->setProduct($this->aProduct); + } + + if ($this->aSelection !== null) { + if ($this->aSelection->isModified() || $this->aSelection->isNew()) { + $affectedRows += $this->aSelection->save($con); + } + $this->setSelection($this->aSelection); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(SelectionProductTableMap::SELECTION_ID)) { + $modifiedColumns[':p' . $index++] = 'SELECTION_ID'; + } + if ($this->isColumnModified(SelectionProductTableMap::PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; + } + if ($this->isColumnModified(SelectionProductTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(SelectionProductTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(SelectionProductTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO selection_product (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'SELECTION_ID': + $stmt->bindValue($identifier, $this->selection_id, PDO::PARAM_INT); + break; + case 'PRODUCT_ID': + $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionProductTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getSelectionId(); + break; + case 1: + return $this->getProductId(); + break; + case 2: + return $this->getPosition(); + break; + case 3: + return $this->getCreatedAt(); + break; + case 4: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['SelectionProduct'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['SelectionProduct'][serialize($this->getPrimaryKey())] = true; + $keys = SelectionProductTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getSelectionId(), + $keys[1] => $this->getProductId(), + $keys[2] => $this->getPosition(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aProduct) { + $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aSelection) { + $result['Selection'] = $this->aSelection->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = SelectionProductTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setSelectionId($value); + break; + case 1: + $this->setProductId($value); + break; + case 2: + $this->setPosition($value); + break; + case 3: + $this->setCreatedAt($value); + break; + case 4: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = SelectionProductTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setSelectionId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(SelectionProductTableMap::DATABASE_NAME); + + if ($this->isColumnModified(SelectionProductTableMap::SELECTION_ID)) $criteria->add(SelectionProductTableMap::SELECTION_ID, $this->selection_id); + if ($this->isColumnModified(SelectionProductTableMap::PRODUCT_ID)) $criteria->add(SelectionProductTableMap::PRODUCT_ID, $this->product_id); + if ($this->isColumnModified(SelectionProductTableMap::POSITION)) $criteria->add(SelectionProductTableMap::POSITION, $this->position); + if ($this->isColumnModified(SelectionProductTableMap::CREATED_AT)) $criteria->add(SelectionProductTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(SelectionProductTableMap::UPDATED_AT)) $criteria->add(SelectionProductTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(SelectionProductTableMap::DATABASE_NAME); + $criteria->add(SelectionProductTableMap::SELECTION_ID, $this->selection_id); + $criteria->add(SelectionProductTableMap::PRODUCT_ID, $this->product_id); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getSelectionId(); + $pks[1] = $this->getProductId(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setSelectionId($keys[0]); + $this->setProductId($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getSelectionId()) && (null === $this->getProductId()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Selection\Model\SelectionProduct (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setSelectionId($this->getSelectionId()); + $copyObj->setProductId($this->getProductId()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Selection\Model\SelectionProduct Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildProduct object. + * + * @param ChildProduct $v + * @return \Selection\Model\SelectionProduct The current object (for fluent API support) + * @throws PropelException + */ + public function setProduct(ChildProduct $v = null) + { + if ($v === null) { + $this->setProductId(NULL); + } else { + $this->setProductId($v->getId()); + } + + $this->aProduct = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildProduct object, it will not be re-added. + if ($v !== null) { + $v->addSelectionProduct($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. + * @throws PropelException + */ + public function getProduct(ConnectionInterface $con = null) + { + if ($this->aProduct === null && ($this->product_id !== null)) { + $this->aProduct = ProductQuery::create()->findPk($this->product_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->aProduct->addSelectionProducts($this); + */ + } + + return $this->aProduct; + } + + /** + * Declares an association between this object and a ChildSelection object. + * + * @param ChildSelection $v + * @return \Selection\Model\SelectionProduct The current object (for fluent API support) + * @throws PropelException + */ + public function setSelection(ChildSelection $v = null) + { + if ($v === null) { + $this->setSelectionId(NULL); + } else { + $this->setSelectionId($v->getId()); + } + + $this->aSelection = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildSelection object, it will not be re-added. + if ($v !== null) { + $v->addSelectionProduct($this); + } + + + return $this; + } + + + /** + * Get the associated ChildSelection object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildSelection The associated ChildSelection object. + * @throws PropelException + */ + public function getSelection(ConnectionInterface $con = null) + { + if ($this->aSelection === null && ($this->selection_id !== null)) { + $this->aSelection = ChildSelectionQuery::create()->findPk($this->selection_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->aSelection->addSelectionProducts($this); + */ + } + + return $this->aSelection; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->selection_id = null; + $this->product_id = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aProduct = null; + $this->aSelection = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(SelectionProductTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildSelectionProduct The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[SelectionProductTableMap::UPDATED_AT] = true; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/Selection/Model/Base/SelectionProductQuery.php b/local/modules/Selection/Model/Base/SelectionProductQuery.php new file mode 100644 index 00000000..f2a1592c --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionProductQuery.php @@ -0,0 +1,774 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$selection_id, $product_id] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelectionProduct|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = SelectionProductTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionProductTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionProduct A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT SELECTION_ID, PRODUCT_ID, POSITION, CREATED_AT, UPDATED_AT FROM selection_product WHERE SELECTION_ID = :p0 AND PRODUCT_ID = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildSelectionProduct(); + $obj->hydrate($row); + SelectionProductTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelectionProduct|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(SelectionProductTableMap::SELECTION_ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(SelectionProductTableMap::PRODUCT_ID, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(SelectionProductTableMap::SELECTION_ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(SelectionProductTableMap::PRODUCT_ID, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the selection_id column + * + * Example usage: + * + * $query->filterBySelectionId(1234); // WHERE selection_id = 1234 + * $query->filterBySelectionId(array(12, 34)); // WHERE selection_id IN (12, 34) + * $query->filterBySelectionId(array('min' => 12)); // WHERE selection_id > 12 + * + * + * @see filterBySelection() + * + * @param mixed $selectionId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function filterBySelectionId($selectionId = null, $comparison = null) + { + if (is_array($selectionId)) { + $useMinMax = false; + if (isset($selectionId['min'])) { + $this->addUsingAlias(SelectionProductTableMap::SELECTION_ID, $selectionId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($selectionId['max'])) { + $this->addUsingAlias(SelectionProductTableMap::SELECTION_ID, $selectionId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionProductTableMap::SELECTION_ID, $selectionId, $comparison); + } + + /** + * Filter the query on the product_id column + * + * Example usage: + * + * $query->filterByProductId(1234); // WHERE product_id = 1234 + * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) + * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 + * + * + * @see filterByProduct() + * + * @param mixed $productId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function filterByProductId($productId = null, $comparison = null) + { + if (is_array($productId)) { + $useMinMax = false; + if (isset($productId['min'])) { + $this->addUsingAlias(SelectionProductTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($productId['max'])) { + $this->addUsingAlias(SelectionProductTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionProductTableMap::PRODUCT_ID, $productId, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(SelectionProductTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(SelectionProductTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionProductTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(SelectionProductTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(SelectionProductTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionProductTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(SelectionProductTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(SelectionProductTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionProductTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Product object + * + * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function filterByProduct($product, $comparison = null) + { + if ($product instanceof \Thelia\Model\Product) { + return $this + ->addUsingAlias(SelectionProductTableMap::PRODUCT_ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(SelectionProductTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Product relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Product'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Product'); + } + + return $this; + } + + /** + * Use the Product relation Product object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query + */ + public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProduct($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); + } + + /** + * Filter the query by a related \Selection\Model\Selection object + * + * @param \Selection\Model\Selection|ObjectCollection $selection The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function filterBySelection($selection, $comparison = null) + { + if ($selection instanceof \Selection\Model\Selection) { + return $this + ->addUsingAlias(SelectionProductTableMap::SELECTION_ID, $selection->getId(), $comparison); + } elseif ($selection instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(SelectionProductTableMap::SELECTION_ID, $selection->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterBySelection() only accepts arguments of type \Selection\Model\Selection or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Selection relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function joinSelection($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Selection'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Selection'); + } + + return $this; + } + + /** + * Use the Selection relation Selection object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionQuery A secondary query class using the current class as primary query + */ + public function useSelectionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinSelection($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Selection', '\Selection\Model\SelectionQuery'); + } + + /** + * Exclude object from result + * + * @param ChildSelectionProduct $selectionProduct Object to remove from the list of results + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function prune($selectionProduct = null) + { + if ($selectionProduct) { + $this->addCond('pruneCond0', $this->getAliasedColName(SelectionProductTableMap::SELECTION_ID), $selectionProduct->getSelectionId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(SelectionProductTableMap::PRODUCT_ID), $selectionProduct->getProductId(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the selection_product table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionProductTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + SelectionProductTableMap::clearInstancePool(); + SelectionProductTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildSelectionProduct or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildSelectionProduct object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionProductTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(SelectionProductTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + SelectionProductTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + SelectionProductTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(SelectionProductTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(SelectionProductTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(SelectionProductTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(SelectionProductTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(SelectionProductTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildSelectionProductQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(SelectionProductTableMap::CREATED_AT); + } + +} // SelectionProductQuery diff --git a/local/modules/Selection/Model/Base/SelectionQuery.php b/local/modules/Selection/Model/Base/SelectionQuery.php new file mode 100644 index 00000000..69062e66 --- /dev/null +++ b/local/modules/Selection/Model/Base/SelectionQuery.php @@ -0,0 +1,1040 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildSelection|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = SelectionTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(SelectionTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelection A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, VISIBLE, POSITION, CREATED_AT, UPDATED_AT FROM selection WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildSelection(); + $obj->hydrate($row); + SelectionTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildSelection|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(SelectionTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(SelectionTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(SelectionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(SelectionTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the visible column + * + * Example usage: + * + * $query->filterByVisible(1234); // WHERE visible = 1234 + * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) + * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 + * + * + * @param mixed $visible The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function filterByVisible($visible = null, $comparison = null) + { + if (is_array($visible)) { + $useMinMax = false; + if (isset($visible['min'])) { + $this->addUsingAlias(SelectionTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($visible['max'])) { + $this->addUsingAlias(SelectionTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionTableMap::VISIBLE, $visible, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(SelectionTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(SelectionTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(SelectionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(SelectionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(SelectionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(SelectionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(SelectionTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Selection\Model\SelectionProduct object + * + * @param \Selection\Model\SelectionProduct|ObjectCollection $selectionProduct the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function filterBySelectionProduct($selectionProduct, $comparison = null) + { + if ($selectionProduct instanceof \Selection\Model\SelectionProduct) { + return $this + ->addUsingAlias(SelectionTableMap::ID, $selectionProduct->getSelectionId(), $comparison); + } elseif ($selectionProduct instanceof ObjectCollection) { + return $this + ->useSelectionProductQuery() + ->filterByPrimaryKeys($selectionProduct->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterBySelectionProduct() only accepts arguments of type \Selection\Model\SelectionProduct or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionProduct relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function joinSelectionProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionProduct'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionProduct'); + } + + return $this; + } + + /** + * Use the SelectionProduct relation SelectionProduct object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionProductQuery A secondary query class using the current class as primary query + */ + public function useSelectionProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinSelectionProduct($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionProduct', '\Selection\Model\SelectionProductQuery'); + } + + /** + * Filter the query by a related \Selection\Model\SelectionContent object + * + * @param \Selection\Model\SelectionContent|ObjectCollection $selectionContent the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function filterBySelectionContent($selectionContent, $comparison = null) + { + if ($selectionContent instanceof \Selection\Model\SelectionContent) { + return $this + ->addUsingAlias(SelectionTableMap::ID, $selectionContent->getSelectionId(), $comparison); + } elseif ($selectionContent instanceof ObjectCollection) { + return $this + ->useSelectionContentQuery() + ->filterByPrimaryKeys($selectionContent->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterBySelectionContent() only accepts arguments of type \Selection\Model\SelectionContent or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionContent relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function joinSelectionContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionContent'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionContent'); + } + + return $this; + } + + /** + * Use the SelectionContent relation SelectionContent object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionContentQuery A secondary query class using the current class as primary query + */ + public function useSelectionContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinSelectionContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionContent', '\Selection\Model\SelectionContentQuery'); + } + + /** + * Filter the query by a related \Selection\Model\SelectionImage object + * + * @param \Selection\Model\SelectionImage|ObjectCollection $selectionImage the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function filterBySelectionImage($selectionImage, $comparison = null) + { + if ($selectionImage instanceof \Selection\Model\SelectionImage) { + return $this + ->addUsingAlias(SelectionTableMap::ID, $selectionImage->getSelectionId(), $comparison); + } elseif ($selectionImage instanceof ObjectCollection) { + return $this + ->useSelectionImageQuery() + ->filterByPrimaryKeys($selectionImage->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterBySelectionImage() only accepts arguments of type \Selection\Model\SelectionImage or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionImage relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function joinSelectionImage($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionImage'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionImage'); + } + + return $this; + } + + /** + * Use the SelectionImage relation SelectionImage object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionImageQuery A secondary query class using the current class as primary query + */ + public function useSelectionImageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinSelectionImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionImage', '\Selection\Model\SelectionImageQuery'); + } + + /** + * Filter the query by a related \Selection\Model\SelectionContainerAssociatedSelection object + * + * @param \Selection\Model\SelectionContainerAssociatedSelection|ObjectCollection $selectionContainerAssociatedSelection the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function filterBySelectionContainerAssociatedSelection($selectionContainerAssociatedSelection, $comparison = null) + { + if ($selectionContainerAssociatedSelection instanceof \Selection\Model\SelectionContainerAssociatedSelection) { + return $this + ->addUsingAlias(SelectionTableMap::ID, $selectionContainerAssociatedSelection->getSelectionId(), $comparison); + } elseif ($selectionContainerAssociatedSelection instanceof ObjectCollection) { + return $this + ->useSelectionContainerAssociatedSelectionQuery() + ->filterByPrimaryKeys($selectionContainerAssociatedSelection->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterBySelectionContainerAssociatedSelection() only accepts arguments of type \Selection\Model\SelectionContainerAssociatedSelection or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionContainerAssociatedSelection relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function joinSelectionContainerAssociatedSelection($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionContainerAssociatedSelection'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionContainerAssociatedSelection'); + } + + return $this; + } + + /** + * Use the SelectionContainerAssociatedSelection relation SelectionContainerAssociatedSelection object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionContainerAssociatedSelectionQuery A secondary query class using the current class as primary query + */ + public function useSelectionContainerAssociatedSelectionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinSelectionContainerAssociatedSelection($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionContainerAssociatedSelection', '\Selection\Model\SelectionContainerAssociatedSelectionQuery'); + } + + /** + * Filter the query by a related \Selection\Model\SelectionI18n object + * + * @param \Selection\Model\SelectionI18n|ObjectCollection $selectionI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function filterBySelectionI18n($selectionI18n, $comparison = null) + { + if ($selectionI18n instanceof \Selection\Model\SelectionI18n) { + return $this + ->addUsingAlias(SelectionTableMap::ID, $selectionI18n->getId(), $comparison); + } elseif ($selectionI18n instanceof ObjectCollection) { + return $this + ->useSelectionI18nQuery() + ->filterByPrimaryKeys($selectionI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterBySelectionI18n() only accepts arguments of type \Selection\Model\SelectionI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the SelectionI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function joinSelectionI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('SelectionI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'SelectionI18n'); + } + + return $this; + } + + /** + * Use the SelectionI18n relation SelectionI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Selection\Model\SelectionI18nQuery A secondary query class using the current class as primary query + */ + public function useSelectionI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinSelectionI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionI18n', '\Selection\Model\SelectionI18nQuery'); + } + + /** + * Exclude object from result + * + * @param ChildSelection $selection Object to remove from the list of results + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function prune($selection = null) + { + if ($selection) { + $this->addUsingAlias(SelectionTableMap::ID, $selection->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the selection table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + SelectionTableMap::clearInstancePool(); + SelectionTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildSelection or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildSelection object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(SelectionTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + SelectionTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + SelectionTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(SelectionTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(SelectionTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(SelectionTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(SelectionTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(SelectionTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(SelectionTableMap::CREATED_AT); + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'SelectionI18n'; + + return $this + ->joinSelectionI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildSelectionQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('SelectionI18n'); + $this->with['SelectionI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildSelectionI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'SelectionI18n', '\Selection\Model\SelectionI18nQuery'); + } + +} // SelectionQuery diff --git a/local/modules/Selection/Model/Map/SelectionContainerAssociatedSelectionTableMap.php b/local/modules/Selection/Model/Map/SelectionContainerAssociatedSelectionTableMap.php new file mode 100644 index 00000000..7af5b94d --- /dev/null +++ b/local/modules/Selection/Model/Map/SelectionContainerAssociatedSelectionTableMap.php @@ -0,0 +1,445 @@ + array('Id', 'SelectionContainerId', 'SelectionId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'selectionContainerId', 'selectionId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(SelectionContainerAssociatedSelectionTableMap::ID, SelectionContainerAssociatedSelectionTableMap::SELECTION_CONTAINER_ID, SelectionContainerAssociatedSelectionTableMap::SELECTION_ID, SelectionContainerAssociatedSelectionTableMap::CREATED_AT, SelectionContainerAssociatedSelectionTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'SELECTION_CONTAINER_ID', 'SELECTION_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'selection_container_id', 'selection_id', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'SelectionContainerId' => 1, 'SelectionId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'selectionContainerId' => 1, 'selectionId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(SelectionContainerAssociatedSelectionTableMap::ID => 0, SelectionContainerAssociatedSelectionTableMap::SELECTION_CONTAINER_ID => 1, SelectionContainerAssociatedSelectionTableMap::SELECTION_ID => 2, SelectionContainerAssociatedSelectionTableMap::CREATED_AT => 3, SelectionContainerAssociatedSelectionTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'SELECTION_CONTAINER_ID' => 1, 'SELECTION_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'selection_container_id' => 1, 'selection_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('selection_container_associated_selection'); + $this->setPhpName('SelectionContainerAssociatedSelection'); + $this->setClassName('\\Selection\\Model\\SelectionContainerAssociatedSelection'); + $this->setPackage('Selection.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('SELECTION_CONTAINER_ID', 'SelectionContainerId', 'INTEGER', 'selection_container', 'ID', true, null, null); + $this->addForeignKey('SELECTION_ID', 'SelectionId', 'INTEGER', 'selection', 'ID', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('SelectionContainer', '\\Selection\\Model\\SelectionContainer', RelationMap::MANY_TO_ONE, array('selection_container_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Selection', '\\Selection\\Model\\Selection', RelationMap::MANY_TO_ONE, array('selection_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? SelectionContainerAssociatedSelectionTableMap::CLASS_DEFAULT : SelectionContainerAssociatedSelectionTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (SelectionContainerAssociatedSelection object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = SelectionContainerAssociatedSelectionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = SelectionContainerAssociatedSelectionTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + SelectionContainerAssociatedSelectionTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = SelectionContainerAssociatedSelectionTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + SelectionContainerAssociatedSelectionTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = SelectionContainerAssociatedSelectionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = SelectionContainerAssociatedSelectionTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + SelectionContainerAssociatedSelectionTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(SelectionContainerAssociatedSelectionTableMap::ID); + $criteria->addSelectColumn(SelectionContainerAssociatedSelectionTableMap::SELECTION_CONTAINER_ID); + $criteria->addSelectColumn(SelectionContainerAssociatedSelectionTableMap::SELECTION_ID); + $criteria->addSelectColumn(SelectionContainerAssociatedSelectionTableMap::CREATED_AT); + $criteria->addSelectColumn(SelectionContainerAssociatedSelectionTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.SELECTION_CONTAINER_ID'); + $criteria->addSelectColumn($alias . '.SELECTION_ID'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(SelectionContainerAssociatedSelectionTableMap::DATABASE_NAME)->getTable(SelectionContainerAssociatedSelectionTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(SelectionContainerAssociatedSelectionTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(SelectionContainerAssociatedSelectionTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new SelectionContainerAssociatedSelectionTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a SelectionContainerAssociatedSelection or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or SelectionContainerAssociatedSelection object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerAssociatedSelectionTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Selection\Model\SelectionContainerAssociatedSelection) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(SelectionContainerAssociatedSelectionTableMap::DATABASE_NAME); + $criteria->add(SelectionContainerAssociatedSelectionTableMap::ID, (array) $values, Criteria::IN); + } + + $query = SelectionContainerAssociatedSelectionQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { SelectionContainerAssociatedSelectionTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { SelectionContainerAssociatedSelectionTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the selection_container_associated_selection table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return SelectionContainerAssociatedSelectionQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a SelectionContainerAssociatedSelection or Criteria object. + * + * @param mixed $criteria Criteria or SelectionContainerAssociatedSelection object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerAssociatedSelectionTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from SelectionContainerAssociatedSelection object + } + + + // Set the correct dbName + $query = SelectionContainerAssociatedSelectionQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // SelectionContainerAssociatedSelectionTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +SelectionContainerAssociatedSelectionTableMap::buildTableMap(); diff --git a/local/modules/Selection/Model/Map/SelectionContainerI18nTableMap.php b/local/modules/Selection/Model/Map/SelectionContainerI18nTableMap.php new file mode 100644 index 00000000..6fdacb6c --- /dev/null +++ b/local/modules/Selection/Model/Map/SelectionContainerI18nTableMap.php @@ -0,0 +1,522 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', 'MetaTitle', 'MetaDescription', 'MetaKeywords', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'metaTitle', 'metaDescription', 'metaKeywords', ), + self::TYPE_COLNAME => array(SelectionContainerI18nTableMap::ID, SelectionContainerI18nTableMap::LOCALE, SelectionContainerI18nTableMap::TITLE, SelectionContainerI18nTableMap::DESCRIPTION, SelectionContainerI18nTableMap::CHAPO, SelectionContainerI18nTableMap::POSTSCRIPTUM, SelectionContainerI18nTableMap::META_TITLE, SelectionContainerI18nTableMap::META_DESCRIPTION, SelectionContainerI18nTableMap::META_KEYWORDS, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'meta_title', 'meta_description', 'meta_keywords', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, 'MetaTitle' => 6, 'MetaDescription' => 7, 'MetaKeywords' => 8, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'metaTitle' => 6, 'metaDescription' => 7, 'metaKeywords' => 8, ), + self::TYPE_COLNAME => array(SelectionContainerI18nTableMap::ID => 0, SelectionContainerI18nTableMap::LOCALE => 1, SelectionContainerI18nTableMap::TITLE => 2, SelectionContainerI18nTableMap::DESCRIPTION => 3, SelectionContainerI18nTableMap::CHAPO => 4, SelectionContainerI18nTableMap::POSTSCRIPTUM => 5, SelectionContainerI18nTableMap::META_TITLE => 6, SelectionContainerI18nTableMap::META_DESCRIPTION => 7, SelectionContainerI18nTableMap::META_KEYWORDS => 8, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, 'META_TITLE' => 6, 'META_DESCRIPTION' => 7, 'META_KEYWORDS' => 8, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'meta_title' => 6, 'meta_description' => 7, 'meta_keywords' => 8, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('selection_container_i18n'); + $this->setPhpName('SelectionContainerI18n'); + $this->setClassName('\\Selection\\Model\\SelectionContainerI18n'); + $this->setPackage('Selection.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'selection_container', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); + $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addColumn('META_TITLE', 'MetaTitle', 'VARCHAR', false, 255, null); + $this->addColumn('META_DESCRIPTION', 'MetaDescription', 'LONGVARCHAR', false, null, null); + $this->addColumn('META_KEYWORDS', 'MetaKeywords', 'LONGVARCHAR', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('SelectionContainer', '\\Selection\\Model\\SelectionContainer', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Selection\Model\SelectionContainerI18n $obj A \Selection\Model\SelectionContainerI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Selection\Model\SelectionContainerI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Selection\Model\SelectionContainerI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Selection\Model\SelectionContainerI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? SelectionContainerI18nTableMap::CLASS_DEFAULT : SelectionContainerI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (SelectionContainerI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = SelectionContainerI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = SelectionContainerI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + SelectionContainerI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = SelectionContainerI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + SelectionContainerI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = SelectionContainerI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = SelectionContainerI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + SelectionContainerI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(SelectionContainerI18nTableMap::ID); + $criteria->addSelectColumn(SelectionContainerI18nTableMap::LOCALE); + $criteria->addSelectColumn(SelectionContainerI18nTableMap::TITLE); + $criteria->addSelectColumn(SelectionContainerI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(SelectionContainerI18nTableMap::CHAPO); + $criteria->addSelectColumn(SelectionContainerI18nTableMap::POSTSCRIPTUM); + $criteria->addSelectColumn(SelectionContainerI18nTableMap::META_TITLE); + $criteria->addSelectColumn(SelectionContainerI18nTableMap::META_DESCRIPTION); + $criteria->addSelectColumn(SelectionContainerI18nTableMap::META_KEYWORDS); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.META_TITLE'); + $criteria->addSelectColumn($alias . '.META_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.META_KEYWORDS'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(SelectionContainerI18nTableMap::DATABASE_NAME)->getTable(SelectionContainerI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(SelectionContainerI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(SelectionContainerI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new SelectionContainerI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a SelectionContainerI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or SelectionContainerI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Selection\Model\SelectionContainerI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(SelectionContainerI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(SelectionContainerI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(SelectionContainerI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = SelectionContainerI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { SelectionContainerI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { SelectionContainerI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the selection_container_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return SelectionContainerI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a SelectionContainerI18n or Criteria object. + * + * @param mixed $criteria Criteria or SelectionContainerI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from SelectionContainerI18n object + } + + + // Set the correct dbName + $query = SelectionContainerI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // SelectionContainerI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +SelectionContainerI18nTableMap::buildTableMap(); diff --git a/local/modules/Selection/Model/Map/SelectionContainerImageI18nTableMap.php b/local/modules/Selection/Model/Map/SelectionContainerImageI18nTableMap.php new file mode 100644 index 00000000..bbea9d07 --- /dev/null +++ b/local/modules/Selection/Model/Map/SelectionContainerImageI18nTableMap.php @@ -0,0 +1,498 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(SelectionContainerImageI18nTableMap::ID, SelectionContainerImageI18nTableMap::LOCALE, SelectionContainerImageI18nTableMap::TITLE, SelectionContainerImageI18nTableMap::DESCRIPTION, SelectionContainerImageI18nTableMap::CHAPO, SelectionContainerImageI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(SelectionContainerImageI18nTableMap::ID => 0, SelectionContainerImageI18nTableMap::LOCALE => 1, SelectionContainerImageI18nTableMap::TITLE => 2, SelectionContainerImageI18nTableMap::DESCRIPTION => 3, SelectionContainerImageI18nTableMap::CHAPO => 4, SelectionContainerImageI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('selection_container_image_i18n'); + $this->setPhpName('SelectionContainerImageI18n'); + $this->setClassName('\\Selection\\Model\\SelectionContainerImageI18n'); + $this->setPackage('Selection.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'selection_container_image', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('SelectionContainerImage', '\\Selection\\Model\\SelectionContainerImage', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Selection\Model\SelectionContainerImageI18n $obj A \Selection\Model\SelectionContainerImageI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Selection\Model\SelectionContainerImageI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Selection\Model\SelectionContainerImageI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Selection\Model\SelectionContainerImageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? SelectionContainerImageI18nTableMap::CLASS_DEFAULT : SelectionContainerImageI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (SelectionContainerImageI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = SelectionContainerImageI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = SelectionContainerImageI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + SelectionContainerImageI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = SelectionContainerImageI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + SelectionContainerImageI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = SelectionContainerImageI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = SelectionContainerImageI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + SelectionContainerImageI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(SelectionContainerImageI18nTableMap::ID); + $criteria->addSelectColumn(SelectionContainerImageI18nTableMap::LOCALE); + $criteria->addSelectColumn(SelectionContainerImageI18nTableMap::TITLE); + $criteria->addSelectColumn(SelectionContainerImageI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(SelectionContainerImageI18nTableMap::CHAPO); + $criteria->addSelectColumn(SelectionContainerImageI18nTableMap::POSTSCRIPTUM); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(SelectionContainerImageI18nTableMap::DATABASE_NAME)->getTable(SelectionContainerImageI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(SelectionContainerImageI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(SelectionContainerImageI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new SelectionContainerImageI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a SelectionContainerImageI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or SelectionContainerImageI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerImageI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Selection\Model\SelectionContainerImageI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(SelectionContainerImageI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(SelectionContainerImageI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(SelectionContainerImageI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = SelectionContainerImageI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { SelectionContainerImageI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { SelectionContainerImageI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the selection_container_image_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return SelectionContainerImageI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a SelectionContainerImageI18n or Criteria object. + * + * @param mixed $criteria Criteria or SelectionContainerImageI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerImageI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from SelectionContainerImageI18n object + } + + + // Set the correct dbName + $query = SelectionContainerImageI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // SelectionContainerImageI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +SelectionContainerImageI18nTableMap::buildTableMap(); diff --git a/local/modules/Selection/Model/Map/SelectionContainerImageTableMap.php b/local/modules/Selection/Model/Map/SelectionContainerImageTableMap.php new file mode 100644 index 00000000..5c77e11b --- /dev/null +++ b/local/modules/Selection/Model/Map/SelectionContainerImageTableMap.php @@ -0,0 +1,480 @@ + array('Id', 'SelectionContainerId', 'File', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'selectionContainerId', 'file', 'visible', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(SelectionContainerImageTableMap::ID, SelectionContainerImageTableMap::SELECTION_CONTAINER_ID, SelectionContainerImageTableMap::FILE, SelectionContainerImageTableMap::VISIBLE, SelectionContainerImageTableMap::POSITION, SelectionContainerImageTableMap::CREATED_AT, SelectionContainerImageTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'SELECTION_CONTAINER_ID', 'FILE', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'selection_container_id', 'file', 'visible', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'SelectionContainerId' => 1, 'File' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'selectionContainerId' => 1, 'file' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(SelectionContainerImageTableMap::ID => 0, SelectionContainerImageTableMap::SELECTION_CONTAINER_ID => 1, SelectionContainerImageTableMap::FILE => 2, SelectionContainerImageTableMap::VISIBLE => 3, SelectionContainerImageTableMap::POSITION => 4, SelectionContainerImageTableMap::CREATED_AT => 5, SelectionContainerImageTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'SELECTION_CONTAINER_ID' => 1, 'FILE' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'selection_container_id' => 1, 'file' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('selection_container_image'); + $this->setPhpName('SelectionContainerImage'); + $this->setClassName('\\Selection\\Model\\SelectionContainerImage'); + $this->setPackage('Selection.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('SELECTION_CONTAINER_ID', 'SelectionContainerId', 'INTEGER', 'selection_container', 'ID', true, null, null); + $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null); + $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 1); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('SelectionContainer', '\\Selection\\Model\\SelectionContainer', RelationMap::MANY_TO_ONE, array('selection_container_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('SelectionContainerImageI18n', '\\Selection\\Model\\SelectionContainerImageI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'SelectionContainerImageI18ns'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to selection_container_image * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + SelectionContainerImageI18nTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? SelectionContainerImageTableMap::CLASS_DEFAULT : SelectionContainerImageTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (SelectionContainerImage object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = SelectionContainerImageTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = SelectionContainerImageTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + SelectionContainerImageTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = SelectionContainerImageTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + SelectionContainerImageTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = SelectionContainerImageTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = SelectionContainerImageTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + SelectionContainerImageTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(SelectionContainerImageTableMap::ID); + $criteria->addSelectColumn(SelectionContainerImageTableMap::SELECTION_CONTAINER_ID); + $criteria->addSelectColumn(SelectionContainerImageTableMap::FILE); + $criteria->addSelectColumn(SelectionContainerImageTableMap::VISIBLE); + $criteria->addSelectColumn(SelectionContainerImageTableMap::POSITION); + $criteria->addSelectColumn(SelectionContainerImageTableMap::CREATED_AT); + $criteria->addSelectColumn(SelectionContainerImageTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.SELECTION_CONTAINER_ID'); + $criteria->addSelectColumn($alias . '.FILE'); + $criteria->addSelectColumn($alias . '.VISIBLE'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(SelectionContainerImageTableMap::DATABASE_NAME)->getTable(SelectionContainerImageTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(SelectionContainerImageTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(SelectionContainerImageTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new SelectionContainerImageTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a SelectionContainerImage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or SelectionContainerImage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerImageTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Selection\Model\SelectionContainerImage) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(SelectionContainerImageTableMap::DATABASE_NAME); + $criteria->add(SelectionContainerImageTableMap::ID, (array) $values, Criteria::IN); + } + + $query = SelectionContainerImageQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { SelectionContainerImageTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { SelectionContainerImageTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the selection_container_image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return SelectionContainerImageQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a SelectionContainerImage or Criteria object. + * + * @param mixed $criteria Criteria or SelectionContainerImage object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerImageTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from SelectionContainerImage object + } + + + // Set the correct dbName + $query = SelectionContainerImageQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // SelectionContainerImageTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +SelectionContainerImageTableMap::buildTableMap(); diff --git a/local/modules/Selection/Model/Map/SelectionContainerTableMap.php b/local/modules/Selection/Model/Map/SelectionContainerTableMap.php new file mode 100644 index 00000000..5b3d086d --- /dev/null +++ b/local/modules/Selection/Model/Map/SelectionContainerTableMap.php @@ -0,0 +1,467 @@ + array('Id', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'visible', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(SelectionContainerTableMap::ID, SelectionContainerTableMap::VISIBLE, SelectionContainerTableMap::POSITION, SelectionContainerTableMap::CREATED_AT, SelectionContainerTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'visible', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(SelectionContainerTableMap::ID => 0, SelectionContainerTableMap::VISIBLE => 1, SelectionContainerTableMap::POSITION => 2, SelectionContainerTableMap::CREATED_AT => 3, SelectionContainerTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'VISIBLE' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('selection_container'); + $this->setPhpName('SelectionContainer'); + $this->setClassName('\\Selection\\Model\\SelectionContainer'); + $this->setPackage('Selection.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('SelectionContainerAssociatedSelection', '\\Selection\\Model\\SelectionContainerAssociatedSelection', RelationMap::ONE_TO_MANY, array('id' => 'selection_container_id', ), 'CASCADE', 'RESTRICT', 'SelectionContainerAssociatedSelections'); + $this->addRelation('SelectionContainerImage', '\\Selection\\Model\\SelectionContainerImage', RelationMap::ONE_TO_MANY, array('id' => 'selection_container_id', ), 'CASCADE', 'RESTRICT', 'SelectionContainerImages'); + $this->addRelation('SelectionContainerI18n', '\\Selection\\Model\\SelectionContainerI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'SelectionContainerI18ns'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum, meta_title, meta_description, meta_keywords', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to selection_container * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + SelectionContainerAssociatedSelectionTableMap::clearInstancePool(); + SelectionContainerImageTableMap::clearInstancePool(); + SelectionContainerI18nTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? SelectionContainerTableMap::CLASS_DEFAULT : SelectionContainerTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (SelectionContainer object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = SelectionContainerTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = SelectionContainerTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + SelectionContainerTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = SelectionContainerTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + SelectionContainerTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = SelectionContainerTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = SelectionContainerTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + SelectionContainerTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(SelectionContainerTableMap::ID); + $criteria->addSelectColumn(SelectionContainerTableMap::VISIBLE); + $criteria->addSelectColumn(SelectionContainerTableMap::POSITION); + $criteria->addSelectColumn(SelectionContainerTableMap::CREATED_AT); + $criteria->addSelectColumn(SelectionContainerTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.VISIBLE'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(SelectionContainerTableMap::DATABASE_NAME)->getTable(SelectionContainerTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(SelectionContainerTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(SelectionContainerTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new SelectionContainerTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a SelectionContainer or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or SelectionContainer object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Selection\Model\SelectionContainer) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(SelectionContainerTableMap::DATABASE_NAME); + $criteria->add(SelectionContainerTableMap::ID, (array) $values, Criteria::IN); + } + + $query = SelectionContainerQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { SelectionContainerTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { SelectionContainerTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the selection_container table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return SelectionContainerQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a SelectionContainer or Criteria object. + * + * @param mixed $criteria Criteria or SelectionContainer object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContainerTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from SelectionContainer object + } + + + // Set the correct dbName + $query = SelectionContainerQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // SelectionContainerTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +SelectionContainerTableMap::buildTableMap(); diff --git a/local/modules/Selection/Model/Map/SelectionContentTableMap.php b/local/modules/Selection/Model/Map/SelectionContentTableMap.php new file mode 100644 index 00000000..b3d39737 --- /dev/null +++ b/local/modules/Selection/Model/Map/SelectionContentTableMap.php @@ -0,0 +1,504 @@ + array('SelectionId', 'ContentId', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('selectionId', 'contentId', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(SelectionContentTableMap::SELECTION_ID, SelectionContentTableMap::CONTENT_ID, SelectionContentTableMap::POSITION, SelectionContentTableMap::CREATED_AT, SelectionContentTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('SELECTION_ID', 'CONTENT_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('selection_id', 'content_id', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('SelectionId' => 0, 'ContentId' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('selectionId' => 0, 'contentId' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(SelectionContentTableMap::SELECTION_ID => 0, SelectionContentTableMap::CONTENT_ID => 1, SelectionContentTableMap::POSITION => 2, SelectionContentTableMap::CREATED_AT => 3, SelectionContentTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('SELECTION_ID' => 0, 'CONTENT_ID' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('selection_id' => 0, 'content_id' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('selection_content'); + $this->setPhpName('SelectionContent'); + $this->setClassName('\\Selection\\Model\\SelectionContent'); + $this->setPackage('Selection.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('SELECTION_ID', 'SelectionId', 'INTEGER' , 'selection', 'ID', true, null, null); + $this->addForeignPrimaryKey('CONTENT_ID', 'ContentId', 'INTEGER' , 'content', 'ID', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Selection', '\\Selection\\Model\\Selection', RelationMap::MANY_TO_ONE, array('selection_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Selection\Model\SelectionContent $obj A \Selection\Model\SelectionContent object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getSelectionId(), (string) $obj->getContentId())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Selection\Model\SelectionContent object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Selection\Model\SelectionContent) { + $key = serialize(array((string) $value->getSelectionId(), (string) $value->getContentId())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Selection\Model\SelectionContent object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('SelectionId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('SelectionId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? SelectionContentTableMap::CLASS_DEFAULT : SelectionContentTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (SelectionContent object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = SelectionContentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = SelectionContentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + SelectionContentTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = SelectionContentTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + SelectionContentTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = SelectionContentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = SelectionContentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + SelectionContentTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(SelectionContentTableMap::SELECTION_ID); + $criteria->addSelectColumn(SelectionContentTableMap::CONTENT_ID); + $criteria->addSelectColumn(SelectionContentTableMap::POSITION); + $criteria->addSelectColumn(SelectionContentTableMap::CREATED_AT); + $criteria->addSelectColumn(SelectionContentTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.SELECTION_ID'); + $criteria->addSelectColumn($alias . '.CONTENT_ID'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(SelectionContentTableMap::DATABASE_NAME)->getTable(SelectionContentTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(SelectionContentTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(SelectionContentTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new SelectionContentTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a SelectionContent or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or SelectionContent object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContentTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Selection\Model\SelectionContent) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(SelectionContentTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(SelectionContentTableMap::SELECTION_ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(SelectionContentTableMap::CONTENT_ID, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = SelectionContentQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { SelectionContentTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { SelectionContentTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the selection_content table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return SelectionContentQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a SelectionContent or Criteria object. + * + * @param mixed $criteria Criteria or SelectionContent object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionContentTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from SelectionContent object + } + + + // Set the correct dbName + $query = SelectionContentQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // SelectionContentTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +SelectionContentTableMap::buildTableMap(); diff --git a/local/modules/Selection/Model/Map/SelectionI18nTableMap.php b/local/modules/Selection/Model/Map/SelectionI18nTableMap.php new file mode 100644 index 00000000..f0a2440d --- /dev/null +++ b/local/modules/Selection/Model/Map/SelectionI18nTableMap.php @@ -0,0 +1,522 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', 'MetaTitle', 'MetaDescription', 'MetaKeywords', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'metaTitle', 'metaDescription', 'metaKeywords', ), + self::TYPE_COLNAME => array(SelectionI18nTableMap::ID, SelectionI18nTableMap::LOCALE, SelectionI18nTableMap::TITLE, SelectionI18nTableMap::DESCRIPTION, SelectionI18nTableMap::CHAPO, SelectionI18nTableMap::POSTSCRIPTUM, SelectionI18nTableMap::META_TITLE, SelectionI18nTableMap::META_DESCRIPTION, SelectionI18nTableMap::META_KEYWORDS, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', 'meta_title', 'meta_description', 'meta_keywords', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, 'MetaTitle' => 6, 'MetaDescription' => 7, 'MetaKeywords' => 8, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'metaTitle' => 6, 'metaDescription' => 7, 'metaKeywords' => 8, ), + self::TYPE_COLNAME => array(SelectionI18nTableMap::ID => 0, SelectionI18nTableMap::LOCALE => 1, SelectionI18nTableMap::TITLE => 2, SelectionI18nTableMap::DESCRIPTION => 3, SelectionI18nTableMap::CHAPO => 4, SelectionI18nTableMap::POSTSCRIPTUM => 5, SelectionI18nTableMap::META_TITLE => 6, SelectionI18nTableMap::META_DESCRIPTION => 7, SelectionI18nTableMap::META_KEYWORDS => 8, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, 'META_TITLE' => 6, 'META_DESCRIPTION' => 7, 'META_KEYWORDS' => 8, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, 'meta_title' => 6, 'meta_description' => 7, 'meta_keywords' => 8, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('selection_i18n'); + $this->setPhpName('SelectionI18n'); + $this->setClassName('\\Selection\\Model\\SelectionI18n'); + $this->setPackage('Selection.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'selection', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); + $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addColumn('META_TITLE', 'MetaTitle', 'VARCHAR', false, 255, null); + $this->addColumn('META_DESCRIPTION', 'MetaDescription', 'LONGVARCHAR', false, null, null); + $this->addColumn('META_KEYWORDS', 'MetaKeywords', 'LONGVARCHAR', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Selection', '\\Selection\\Model\\Selection', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Selection\Model\SelectionI18n $obj A \Selection\Model\SelectionI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Selection\Model\SelectionI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Selection\Model\SelectionI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Selection\Model\SelectionI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? SelectionI18nTableMap::CLASS_DEFAULT : SelectionI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (SelectionI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = SelectionI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = SelectionI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + SelectionI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = SelectionI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + SelectionI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = SelectionI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = SelectionI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + SelectionI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(SelectionI18nTableMap::ID); + $criteria->addSelectColumn(SelectionI18nTableMap::LOCALE); + $criteria->addSelectColumn(SelectionI18nTableMap::TITLE); + $criteria->addSelectColumn(SelectionI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(SelectionI18nTableMap::CHAPO); + $criteria->addSelectColumn(SelectionI18nTableMap::POSTSCRIPTUM); + $criteria->addSelectColumn(SelectionI18nTableMap::META_TITLE); + $criteria->addSelectColumn(SelectionI18nTableMap::META_DESCRIPTION); + $criteria->addSelectColumn(SelectionI18nTableMap::META_KEYWORDS); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.META_TITLE'); + $criteria->addSelectColumn($alias . '.META_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.META_KEYWORDS'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(SelectionI18nTableMap::DATABASE_NAME)->getTable(SelectionI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(SelectionI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(SelectionI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new SelectionI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a SelectionI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or SelectionI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Selection\Model\SelectionI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(SelectionI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(SelectionI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(SelectionI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = SelectionI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { SelectionI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { SelectionI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the selection_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return SelectionI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a SelectionI18n or Criteria object. + * + * @param mixed $criteria Criteria or SelectionI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from SelectionI18n object + } + + + // Set the correct dbName + $query = SelectionI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // SelectionI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +SelectionI18nTableMap::buildTableMap(); diff --git a/local/modules/Selection/Model/Map/SelectionImageI18nTableMap.php b/local/modules/Selection/Model/Map/SelectionImageI18nTableMap.php new file mode 100644 index 00000000..547bdf63 --- /dev/null +++ b/local/modules/Selection/Model/Map/SelectionImageI18nTableMap.php @@ -0,0 +1,498 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(SelectionImageI18nTableMap::ID, SelectionImageI18nTableMap::LOCALE, SelectionImageI18nTableMap::TITLE, SelectionImageI18nTableMap::DESCRIPTION, SelectionImageI18nTableMap::CHAPO, SelectionImageI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(SelectionImageI18nTableMap::ID => 0, SelectionImageI18nTableMap::LOCALE => 1, SelectionImageI18nTableMap::TITLE => 2, SelectionImageI18nTableMap::DESCRIPTION => 3, SelectionImageI18nTableMap::CHAPO => 4, SelectionImageI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('selection_image_i18n'); + $this->setPhpName('SelectionImageI18n'); + $this->setClassName('\\Selection\\Model\\SelectionImageI18n'); + $this->setPackage('Selection.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'selection_image', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('SelectionImage', '\\Selection\\Model\\SelectionImage', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Selection\Model\SelectionImageI18n $obj A \Selection\Model\SelectionImageI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Selection\Model\SelectionImageI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Selection\Model\SelectionImageI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Selection\Model\SelectionImageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? SelectionImageI18nTableMap::CLASS_DEFAULT : SelectionImageI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (SelectionImageI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = SelectionImageI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = SelectionImageI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + SelectionImageI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = SelectionImageI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + SelectionImageI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = SelectionImageI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = SelectionImageI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + SelectionImageI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(SelectionImageI18nTableMap::ID); + $criteria->addSelectColumn(SelectionImageI18nTableMap::LOCALE); + $criteria->addSelectColumn(SelectionImageI18nTableMap::TITLE); + $criteria->addSelectColumn(SelectionImageI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(SelectionImageI18nTableMap::CHAPO); + $criteria->addSelectColumn(SelectionImageI18nTableMap::POSTSCRIPTUM); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(SelectionImageI18nTableMap::DATABASE_NAME)->getTable(SelectionImageI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(SelectionImageI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(SelectionImageI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new SelectionImageI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a SelectionImageI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or SelectionImageI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionImageI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Selection\Model\SelectionImageI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(SelectionImageI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(SelectionImageI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(SelectionImageI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = SelectionImageI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { SelectionImageI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { SelectionImageI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the selection_image_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return SelectionImageI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a SelectionImageI18n or Criteria object. + * + * @param mixed $criteria Criteria or SelectionImageI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionImageI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from SelectionImageI18n object + } + + + // Set the correct dbName + $query = SelectionImageI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // SelectionImageI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +SelectionImageI18nTableMap::buildTableMap(); diff --git a/local/modules/Selection/Model/Map/SelectionImageTableMap.php b/local/modules/Selection/Model/Map/SelectionImageTableMap.php new file mode 100644 index 00000000..5658a2f4 --- /dev/null +++ b/local/modules/Selection/Model/Map/SelectionImageTableMap.php @@ -0,0 +1,484 @@ + array('Id', 'SelectionId', 'File', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'selectionId', 'file', 'visible', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(SelectionImageTableMap::ID, SelectionImageTableMap::SELECTION_ID, SelectionImageTableMap::FILE, SelectionImageTableMap::VISIBLE, SelectionImageTableMap::POSITION, SelectionImageTableMap::CREATED_AT, SelectionImageTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'SELECTION_ID', 'FILE', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'selection_id', 'file', 'visible', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'SelectionId' => 1, 'File' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'selectionId' => 1, 'file' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(SelectionImageTableMap::ID => 0, SelectionImageTableMap::SELECTION_ID => 1, SelectionImageTableMap::FILE => 2, SelectionImageTableMap::VISIBLE => 3, SelectionImageTableMap::POSITION => 4, SelectionImageTableMap::CREATED_AT => 5, SelectionImageTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'SELECTION_ID' => 1, 'FILE' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'selection_id' => 1, 'file' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('selection_image'); + $this->setPhpName('SelectionImage'); + $this->setClassName('\\Selection\\Model\\SelectionImage'); + $this->setPackage('Selection.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('SELECTION_ID', 'SelectionId', 'INTEGER', 'selection', 'ID', true, null, null); + $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null); + $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 1); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Selection', '\\Selection\\Model\\Selection', RelationMap::MANY_TO_ONE, array('selection_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('SelectionImageI18n', '\\Selection\\Model\\SelectionImageI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'SelectionImageI18ns'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to selection_image * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + SelectionImageI18nTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? SelectionImageTableMap::CLASS_DEFAULT : SelectionImageTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (SelectionImage object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = SelectionImageTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = SelectionImageTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + SelectionImageTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = SelectionImageTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + SelectionImageTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = SelectionImageTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = SelectionImageTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + SelectionImageTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(SelectionImageTableMap::ID); + $criteria->addSelectColumn(SelectionImageTableMap::SELECTION_ID); + $criteria->addSelectColumn(SelectionImageTableMap::FILE); + $criteria->addSelectColumn(SelectionImageTableMap::VISIBLE); + $criteria->addSelectColumn(SelectionImageTableMap::POSITION); + $criteria->addSelectColumn(SelectionImageTableMap::CREATED_AT); + $criteria->addSelectColumn(SelectionImageTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.SELECTION_ID'); + $criteria->addSelectColumn($alias . '.FILE'); + $criteria->addSelectColumn($alias . '.VISIBLE'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(SelectionImageTableMap::DATABASE_NAME)->getTable(SelectionImageTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(SelectionImageTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(SelectionImageTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new SelectionImageTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a SelectionImage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or SelectionImage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionImageTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Selection\Model\SelectionImage) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(SelectionImageTableMap::DATABASE_NAME); + $criteria->add(SelectionImageTableMap::ID, (array) $values, Criteria::IN); + } + + $query = SelectionImageQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { SelectionImageTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { SelectionImageTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the selection_image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return SelectionImageQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a SelectionImage or Criteria object. + * + * @param mixed $criteria Criteria or SelectionImage object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionImageTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from SelectionImage object + } + + if ($criteria->containsKey(SelectionImageTableMap::ID) && $criteria->keyContainsValue(SelectionImageTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.SelectionImageTableMap::ID.')'); + } + + + // Set the correct dbName + $query = SelectionImageQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // SelectionImageTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +SelectionImageTableMap::buildTableMap(); diff --git a/local/modules/Selection/Model/Map/SelectionProductTableMap.php b/local/modules/Selection/Model/Map/SelectionProductTableMap.php new file mode 100644 index 00000000..9f5d0d84 --- /dev/null +++ b/local/modules/Selection/Model/Map/SelectionProductTableMap.php @@ -0,0 +1,504 @@ + array('SelectionId', 'ProductId', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('selectionId', 'productId', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(SelectionProductTableMap::SELECTION_ID, SelectionProductTableMap::PRODUCT_ID, SelectionProductTableMap::POSITION, SelectionProductTableMap::CREATED_AT, SelectionProductTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('SELECTION_ID', 'PRODUCT_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('selection_id', 'product_id', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('SelectionId' => 0, 'ProductId' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('selectionId' => 0, 'productId' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(SelectionProductTableMap::SELECTION_ID => 0, SelectionProductTableMap::PRODUCT_ID => 1, SelectionProductTableMap::POSITION => 2, SelectionProductTableMap::CREATED_AT => 3, SelectionProductTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('SELECTION_ID' => 0, 'PRODUCT_ID' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('selection_id' => 0, 'product_id' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('selection_product'); + $this->setPhpName('SelectionProduct'); + $this->setClassName('\\Selection\\Model\\SelectionProduct'); + $this->setPackage('Selection.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('SELECTION_ID', 'SelectionId', 'INTEGER' , 'selection', 'ID', true, null, null); + $this->addForeignPrimaryKey('PRODUCT_ID', 'ProductId', 'INTEGER' , 'product', 'ID', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Selection', '\\Selection\\Model\\Selection', RelationMap::MANY_TO_ONE, array('selection_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Selection\Model\SelectionProduct $obj A \Selection\Model\SelectionProduct object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getSelectionId(), (string) $obj->getProductId())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Selection\Model\SelectionProduct object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Selection\Model\SelectionProduct) { + $key = serialize(array((string) $value->getSelectionId(), (string) $value->getProductId())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Selection\Model\SelectionProduct object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('SelectionId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('SelectionId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? SelectionProductTableMap::CLASS_DEFAULT : SelectionProductTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (SelectionProduct object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = SelectionProductTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = SelectionProductTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + SelectionProductTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = SelectionProductTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + SelectionProductTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = SelectionProductTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = SelectionProductTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + SelectionProductTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(SelectionProductTableMap::SELECTION_ID); + $criteria->addSelectColumn(SelectionProductTableMap::PRODUCT_ID); + $criteria->addSelectColumn(SelectionProductTableMap::POSITION); + $criteria->addSelectColumn(SelectionProductTableMap::CREATED_AT); + $criteria->addSelectColumn(SelectionProductTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.SELECTION_ID'); + $criteria->addSelectColumn($alias . '.PRODUCT_ID'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(SelectionProductTableMap::DATABASE_NAME)->getTable(SelectionProductTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(SelectionProductTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(SelectionProductTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new SelectionProductTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a SelectionProduct or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or SelectionProduct object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionProductTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Selection\Model\SelectionProduct) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(SelectionProductTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(SelectionProductTableMap::SELECTION_ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(SelectionProductTableMap::PRODUCT_ID, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = SelectionProductQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { SelectionProductTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { SelectionProductTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the selection_product table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return SelectionProductQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a SelectionProduct or Criteria object. + * + * @param mixed $criteria Criteria or SelectionProduct object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionProductTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from SelectionProduct object + } + + + // Set the correct dbName + $query = SelectionProductQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // SelectionProductTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +SelectionProductTableMap::buildTableMap(); diff --git a/local/modules/Selection/Model/Map/SelectionTableMap.php b/local/modules/Selection/Model/Map/SelectionTableMap.php new file mode 100644 index 00000000..c3cb73fd --- /dev/null +++ b/local/modules/Selection/Model/Map/SelectionTableMap.php @@ -0,0 +1,475 @@ + array('Id', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'visible', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(SelectionTableMap::ID, SelectionTableMap::VISIBLE, SelectionTableMap::POSITION, SelectionTableMap::CREATED_AT, SelectionTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'visible', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(SelectionTableMap::ID => 0, SelectionTableMap::VISIBLE => 1, SelectionTableMap::POSITION => 2, SelectionTableMap::CREATED_AT => 3, SelectionTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'VISIBLE' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('selection'); + $this->setPhpName('Selection'); + $this->setClassName('\\Selection\\Model\\Selection'); + $this->setPackage('Selection.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('SelectionProduct', '\\Selection\\Model\\SelectionProduct', RelationMap::ONE_TO_MANY, array('id' => 'selection_id', ), 'CASCADE', 'RESTRICT', 'SelectionProducts'); + $this->addRelation('SelectionContent', '\\Selection\\Model\\SelectionContent', RelationMap::ONE_TO_MANY, array('id' => 'selection_id', ), 'CASCADE', 'RESTRICT', 'SelectionContents'); + $this->addRelation('SelectionImage', '\\Selection\\Model\\SelectionImage', RelationMap::ONE_TO_MANY, array('id' => 'selection_id', ), 'CASCADE', 'RESTRICT', 'SelectionImages'); + $this->addRelation('SelectionContainerAssociatedSelection', '\\Selection\\Model\\SelectionContainerAssociatedSelection', RelationMap::ONE_TO_MANY, array('id' => 'selection_id', ), 'CASCADE', 'RESTRICT', 'SelectionContainerAssociatedSelections'); + $this->addRelation('SelectionI18n', '\\Selection\\Model\\SelectionI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'SelectionI18ns'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum, meta_title, meta_description, meta_keywords', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to selection * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + SelectionProductTableMap::clearInstancePool(); + SelectionContentTableMap::clearInstancePool(); + SelectionImageTableMap::clearInstancePool(); + SelectionContainerAssociatedSelectionTableMap::clearInstancePool(); + SelectionI18nTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? SelectionTableMap::CLASS_DEFAULT : SelectionTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (Selection object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = SelectionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = SelectionTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + SelectionTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = SelectionTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + SelectionTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = SelectionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = SelectionTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + SelectionTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(SelectionTableMap::ID); + $criteria->addSelectColumn(SelectionTableMap::VISIBLE); + $criteria->addSelectColumn(SelectionTableMap::POSITION); + $criteria->addSelectColumn(SelectionTableMap::CREATED_AT); + $criteria->addSelectColumn(SelectionTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.VISIBLE'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(SelectionTableMap::DATABASE_NAME)->getTable(SelectionTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(SelectionTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(SelectionTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new SelectionTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a Selection or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or Selection object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Selection\Model\Selection) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(SelectionTableMap::DATABASE_NAME); + $criteria->add(SelectionTableMap::ID, (array) $values, Criteria::IN); + } + + $query = SelectionQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { SelectionTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { SelectionTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the selection table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return SelectionQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Selection or Criteria object. + * + * @param mixed $criteria Criteria or Selection object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(SelectionTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Selection object + } + + if ($criteria->containsKey(SelectionTableMap::ID) && $criteria->keyContainsValue(SelectionTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.SelectionTableMap::ID.')'); + } + + + // Set the correct dbName + $query = SelectionQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // SelectionTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +SelectionTableMap::buildTableMap(); diff --git a/local/modules/Selection/Model/Selection.php b/local/modules/Selection/Model/Selection.php new file mode 100644 index 00000000..fbb999e9 --- /dev/null +++ b/local/modules/Selection/Model/Selection.php @@ -0,0 +1,80 @@ +setPosition($this->getNextPosition()); + + $this->dispatchEvent(SelectionEvents::BEFORE_CREATE_SELECTION, new SelectionEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(SelectionEvents::AFTER_CREATE_SELECTION, new SelectionEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(SelectionEvents::BEFORE_UPDATE_SELECTION, new SelectionEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(SelectionEvents::AFTER_UPDATE_SELECTION, new SelectionEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(SelectionEvents::BEFORE_DELETE_SELECTION, new SelectionEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(SelectionEvents::AFTER_DELETE_SELECTION, new SelectionEvent($this)); + } +} diff --git a/local/modules/Selection/Model/SelectionContainer.php b/local/modules/Selection/Model/SelectionContainer.php new file mode 100644 index 00000000..e8ce92e8 --- /dev/null +++ b/local/modules/Selection/Model/SelectionContainer.php @@ -0,0 +1,82 @@ +setPosition($this->getNextPosition()); + + $this->dispatchEvent(SelectionEvents::BEFORE_CREATE_SELECTION_CONTAINER, new SelectionContainerEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(SelectionEvents::AFTER_CREATE_SELECTION_CONTAINER, new SelectionContainerEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(SelectionEvents::BEFORE_UPDATE_SELECTION_CONTAINER, new SelectionContainerEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(SelectionEvents::AFTER_UPDATE_SELECTION_CONTAINER, new SelectionContainerEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(SelectionEvents::BEFORE_DELETE_SELECTION_CONTAINER, new SelectionContainerEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(SelectionEvents::AFTER_DELETE_SELECTION_CONTAINER, new SelectionContainerEvent($this)); + } +} diff --git a/local/modules/Selection/Model/SelectionContainerAssociatedSelection.php b/local/modules/Selection/Model/SelectionContainerAssociatedSelection.php new file mode 100644 index 00000000..b45959cd --- /dev/null +++ b/local/modules/Selection/Model/SelectionContainerAssociatedSelection.php @@ -0,0 +1,10 @@ +filterById($this->getId()); + } + /** + * @inheritDoc + */ + public function preInsert(ConnectionInterface $con = null) + { + $lastImage = SelectionImageQuery::create() + ->filterBySelectionId( + $this->getSelectionContainerId() + ) + ->orderByPosition(Criteria::DESC) + ->findOne(); + + if (null !== $lastImage) { + $position = $lastImage->getPosition() + 1; + } else { + $position = 1; + } + + $this->setPosition($position); + + return true; + } + + public function setParentId($parentId) + { + $this->setSelectionContainerId($parentId); + return $this; + } + + public function getUpdateFormId() + { + return 'admin.selection.image.modification'; + } + + public function getUploadDir() + { + $uploadDir = ConfigQuery::read('images_library_path'); + if ($uploadDir === null) { + $uploadDir = THELIA_LOCAL_DIR . 'media' . DS . 'images'; + } else { + $uploadDir = THELIA_ROOT . $uploadDir; + } + + return $uploadDir . DS . strtolower(SelectionContainer::IMAGE_TYPE_LABEL); + } + + + public function getRedirectionUrl() + { + return '/admin/selection/container/update/' . $this->getSelectionContainerId(); + } + + public function getParentId() + { + return $this->getId(); + } + + public function getParentFileModel() + { + return new SelectionContainer(); + } + + public function getQueryInstance() + { + return SelectionContainerImageQuery::create(); + } + + /** + * @param Router $router + * @param ContainerInterface $container + * @param string $tab + * @param string $locale + * @return array|mixed + * @throws \Propel\Runtime\Exception\PropelException + */ + public function getBreadcrumb(Router $router, ContainerInterface $container, $tab, $locale) + { + /** @var SelectionContainerImage $selectionContainer */ + $selectionContainer = $this->getSelectionContainer(); + + $selectionContainer->setLocale($locale); + + $breadcrumb[$selectionContainer->getTitle()] = sprintf( + "%s?current_tab=%s", + $router->generate( + 'admin.selection.container.view', + ['selectionContainerId' => $selectionContainer->getId()], + Router::ABSOLUTE_URL + ), + $tab + ); + + return $breadcrumb; + } +} diff --git a/local/modules/Selection/Model/SelectionContainerImageI18n.php b/local/modules/Selection/Model/SelectionContainerImageI18n.php new file mode 100644 index 00000000..d65ba774 --- /dev/null +++ b/local/modules/Selection/Model/SelectionContainerImageI18n.php @@ -0,0 +1,10 @@ +getId(), + $containerQuery, + $lang->getLocale(), + array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'META_TITLE', 'META_DESCRIPTION', 'META_KEYWORDS'), + null, + 'ID', + false + ); + $containers = $containerQuery->find(); + if (empty($containers)) { + return []; + } + return $containers; + } catch (\Exception $e) { + Tlog::getInstance()->error($e->getMessage()); + } + return []; + } +} // SelectionContainerQuery diff --git a/local/modules/Selection/Model/SelectionContent.php b/local/modules/Selection/Model/SelectionContent.php new file mode 100644 index 00000000..64c42a4b --- /dev/null +++ b/local/modules/Selection/Model/SelectionContent.php @@ -0,0 +1,10 @@ +filterById($this->getId()); + } + /** + * @inheritDoc + */ + public function preInsert(ConnectionInterface $con = null) + { + $lastImage = SelectionImageQuery::create() + ->filterBySelectionId( + $this->getSelection() + ->getId() + ) + ->orderByPosition(Criteria::DESC) + ->findOne(); + + if (null !== $lastImage) { + $position = $lastImage->getPosition() + 1; + } else { + $position = 1; + } + + $this->setPosition($position); + + return true; + } + + public function setParentId($parentId) + { + $this->setSelectionId($parentId); + + return $this; + } + + public function getUpdateFormId() + { + return 'admin.selection.image.modification'; + } + + public function getUploadDir() + { + $uploadDir = ConfigQuery::read('images_library_path'); + if ($uploadDir === null) { + $uploadDir = THELIA_LOCAL_DIR . 'media' . DS . 'images'; + } else { + $uploadDir = THELIA_ROOT . $uploadDir; + } + + return $uploadDir . DS . 'selection'; + } + + + public function getRedirectionUrl() + { + return '/admin/selection/update/' . $this->getId(); + } + + public function getParentId() + { + return $this->getId(); + } + + public function getParentFileModel() + { + return new Selection(); + } + + public function getQueryInstance() + { + return SelectionImageQuery::create(); + } + + public function getBreadcrumb(Router $router, ContainerInterface $container, $tab, $locale) + { + $translator = Translator::getInstance(); + + /** @var SelectionImage $selection */ + $selection = $this->getSelection(); + + $selection->setLocale($locale); + + $breadcrumb[$selection->getTitle()] = sprintf( + "%s?current_tab=%s", + $router->generate( + 'selection.update', + ['selectionId' => $selection->getId()], + Router::ABSOLUTE_URL + ), + $tab + ); + + return $breadcrumb; + } +} diff --git a/local/modules/Selection/Model/SelectionImageI18n.php b/local/modules/Selection/Model/SelectionImageI18n.php new file mode 100644 index 00000000..a6abf784 --- /dev/null +++ b/local/modules/Selection/Model/SelectionImageI18n.php @@ -0,0 +1,10 @@ +filterBySelectionId($this->getSelectionId()); + } + +} diff --git a/local/modules/Selection/Model/SelectionProductQuery.php b/local/modules/Selection/Model/SelectionProductQuery.php new file mode 100644 index 00000000..590e101f --- /dev/null +++ b/local/modules/Selection/Model/SelectionProductQuery.php @@ -0,0 +1,22 @@ +/local/modules/``` directory and be sure that the name of the module is Selection. +* Activate it in your thelia administration panel + +### Composer + +Add it in your main thelia composer.json file + +``` +composer require thelia/selection-module:~1.1.11 +``` + +## Usage + +Once activated, a new button called "Selection" will appear in the tool menu on the left sidebar of the admin panel. +Clicking on it will redirect you to the list of all the selections you've created so far. + +Once on the page with all your selections you may : + +- Create a new selection by clicking on the + button at the top right of the page. +- Toggle the visibility of your selection (whether people will see it or not) by clicking on the "Online" button in +front of the selection you wish to make visible or invisible. +- Edit an already created selection by clicking on its name or on the cog button then on the pencil button in front +of the selection you wish to edit. +- Delete a selection by clicking on the cog button then on the trash button in front of the selection you wish to delete. + +You may then display your selection on your website by calling the selection_list loop. + +## Hook + +This module has a single hook in the back office, adding the Selection button to the tools menu of the sidebar on +the left, redirecting to the list of selection. + +## Loop + +[selection_list] + +This loop returns a list of selections. You can use it to display the selections you've created in your website. + +### Input arguments + +|Variable |Description | +|--- |--- | +|**id** | A string containing the IDs of all the selections you wish to display. To get the ID of the current rewritten URL, use : $app->request->get('selection_id') in your template| +|**code** | A string containing one or more codes of the selections you wish to display.| +|**exclude_code** | A string containing one or more codes of the selections you wish to exclude from the loop results.| +|**title** | The title of the selection you wish to display | +|**visible** | Whether your selection will be visible or not. Default : true | +|**position** | The position of the selection you wish to display | +|**exclude** | A string containing the IDs of all the selections you wish not to display | +|**order** | A string with a value inside these values : 'id', 'id_reverse', 'alpha', 'alpha_reverse', 'manual', 'manual_reverse', 'visible', 'visible_reverse', 'created', 'created_reverse', 'updated', 'updated_reverse', 'random'| +|**return_url** | A boolean indicating if we want the url (cf BaseLoop) +|**without_container** | A boolean indicating if we want to display selection that are not inside a container only +|**container_id** | The container id to query only the selections inside that container + +### Output arguments + +|Variable |Description | +|--- |--- | +|**SELECTION_ID** | The ID of the current Selection | +|**SELECTION_CODE** | The code of the current Selection | +|**SELECTION_TITLE** | The title of the current Selection | +|**SELECTION_DESCRIPTION** | The description of the current Selection | +|**SELECTION_CHAPO** | The chapo of the current Selection | +|**SELECTION_POSTSCRIPTUM** | The postscriptum of the current Selection | +|**SELECTION_VISIBLE** | Whether the current selection is visible or not | +|**SELECTION_POSITION** | The position of the current selection | +|**SELECTION_URL** | The URL of the current selection | +|**SELECTION_CONTAINER_ID** | The id of the container associated to the current Selection | + +### Exemple +```` + {loop name="selection_list" type="selection_list" visible=true id='1,4'} + This selection id : {$SELECTION_ID} + This selection title : {$SELECTION_TITLE} + This selection code : {$SELECTION_CODE} + This selection status : {$SELECTION_VISIBLE} + This selection description : {$SELECTION_DESCRIPTION} + This selection chapo : {$SELECTION_CHAPO} + This selection url : {$SELECTION_URL} + This selection postscriptum : {$SELECTION_POSTSCRIPTUM} + This selection position : {$SELECTION_POSITION} + {/loop} +```` + +[selection_image] + +This loop returns the images related to a selection. + +### Input arguments + +Input Arguments are extended by Thelia\Core\Templates\Loop\Image + +### Output arguments + +Output Arguments are extended by Thelia\Core\Templates\Loop\Image + + +### Exemple +```` + {loop type="selection_image" name="selection_image" source="selection" source_id=$SELECTION_ID limit="1" visible="true"} + {/loop} +```` + + +[selection_container] + +This loop returns a list of selections containers. You can use it to display the selections containers you've created in your website. + +### Input arguments + + +|Variable |Description | +|--- |--- | +|**id** | A string containing the IDs of all the selections containers you wish to display. To get the ID of the current rewritten URL, use : $app->request->get('selection_id') in your template| +|**code** | A string containing one or more codes of the selection containers you wish to display.| +|**exclude_code** | A string containing one or more codes of the selection containers you wish to exclude from the loop results.| +|**selection_id** | The selection id to find +|**need_selection_count** | boolean indicating if we want to have the number of selection inside this container +|**title** | The title of the selection you wish to display | +|**visible** | Whether your selection will be visible or not. Default : true | +|**position** | The position of the selection you wish to display | +|**exclude** | A string containing the IDs of all the selections you wish not to display | +|**order** | A string with a value inside these values : 'id', 'id_reverse', 'alpha', 'alpha_reverse', 'manual', 'manual_reverse', 'visible', 'visible_reverse', 'created', 'created_reverse', 'updated', 'updated_reverse', 'random'| +|**return_url** | A boolean indicating if we want the url (cf BaseLoop) + +### Output arguments + +|Variable |Description | +|--- |--- | +|**SELECTION_CONTAINER_ID** | The ID of the current container | +|**SELECTION_CONTAINER_TITLE** | The title of the current container | +|**SELECTION_CONTAINER_CODE** | The code of the current container | +|**SELECTION_CONTAINER_DESCRIPTION** | The description of the current container | +|**SELECTION_CONTAINER_CHAPO** | The chapo of the current container | +|**SELECTION_CONTAINER_POSTSCRIPTUM** | The postscriptum of the current container | +|**SELECTION_CONTAINER_VISIBLE** | Whether the current container is visible or not | +|**SELECTION_CONTAINER_POSITION** | The position of the current container | +|**SELECTION_CONTAINER_URL** | The url of the current container | +|**SELECTION_COUNT** | The number of selections in the current container | + + +### Exemple +```` +{loop name="selection_container" type="selection_container" visible="*" backend_context="1" lang=$lang_id order=$selection_container_order} + {$SELECTION_CONTAINER_ID}
+ {loop type="selection_image" name="selection_image" lang="$edit_language_id" source="selection" source_id=$SELECTION_CONTAINER_ID width="70" height="50" resize_mode="borders" limit="1" visible="true"} + + {/loop} + {{$SELECTION_CONTAINER_ID}}
+ {$SELECTION_CONTAINER_TITLE}
+ {$SELECTION_CONTAINER_POSITION}
+{/loop} +```` diff --git a/local/modules/Selection/Selection.php b/local/modules/Selection/Selection.php new file mode 100644 index 00000000..83c301fc --- /dev/null +++ b/local/modules/Selection/Selection.php @@ -0,0 +1,95 @@ +findOne(); + } catch (\Exception $e) { + $database = new Database($con); + $database->insertSql(null, [__DIR__ . '/Config/thelia.sql']); + } + + $this->addRessource(self::RESOURCES_SELECTION); + + //Initialize the module_config + self::setConfigValue(self::CONFIG_ALLOW_PROFILE_ID, ''); + } + + /** + * @param ConnectionInterface|null $con + * @param false $deleteModuleData + */ + public function destroy(ConnectionInterface $con = null, $deleteModuleData = false) + { + $database = new Database($con); + $database->insertSql(null, [__DIR__ . '/Config/destroy.sql']); + } + + public function update($currentVersion, $newVersion, ConnectionInterface $con = null) + { + $finder = Finder::create() + ->name('*.sql') + ->depth(0) + ->sortByName() + ->in(__DIR__ . DS . 'Config' . DS . 'update'); + + $database = new Database($con); + + /** @var \SplFileInfo $file */ + foreach ($finder as $file) { + if (version_compare($currentVersion, $file->getBasename('.sql'), '<')) { + $database->insertSql(null, [$file->getPathname()]); + } + } + } + + /** + * @param $code + * @throws \Propel\Runtime\Exception\PropelException + */ + protected function addRessource($code) + { + if (null === ResourceQuery::create()->findOneByCode($code)) { + $resource = new Resource(); + $resource->setCode($code); + $resource->setTitle($code); + $resource->save(); + } + } +} diff --git a/local/modules/Selection/composer.json b/local/modules/Selection/composer.json new file mode 100644 index 00000000..3c5795e1 --- /dev/null +++ b/local/modules/Selection/composer.json @@ -0,0 +1,11 @@ +{ + "name": "thelia/selection-module", + "license": "LGPL-3.0+", + "type": "thelia-module", + "require": { + "thelia/installer": "~1.1" + }, + "extra": { + "installer-name": "Selection" + } +} \ No newline at end of file diff --git a/local/modules/Selection/templates/backOffice/default/assets/style/selection-image.css b/local/modules/Selection/templates/backOffice/default/assets/style/selection-image.css new file mode 100644 index 00000000..d9eb6bc5 --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/assets/style/selection-image.css @@ -0,0 +1,12 @@ +.thumbnail-container { + position: relative; +} + +.existing-image .col-sm-6 .btn-group{ + position: absolute; + bottom: -14px; + right: 5px; +} +.tab-content { + margin: 30px; +} diff --git a/local/modules/Selection/templates/backOffice/default/container-edit.html b/local/modules/Selection/templates/backOffice/default/container-edit.html new file mode 100644 index 00000000..890f7bc0 --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/container-edit.html @@ -0,0 +1,153 @@ +{extends file="admin-layout.tpl"} +{block name="no-return-functions"} + {$admin_current_location = 'tools'} +{/block} + +{block name="check-resource"}admin.selection{/block} +{block name="check-access"}view{/block} + +{block name="page-title"}{intl l='Edit selection container' d='selection.bo.default'}{/block} +{block name="after-bootstrap-css"} + {stylesheets source="Selection" file="assets/style/selection-image.css"} + + {/stylesheets} +{/block} + +{block name="main-content"} + + {loop name="selection_container" type="selection_container" limit="1" visible="*" id=$selection_container_id} + +
+
+
+ {intl l="Edit selection container"} #{$selection_container_id} : {$SELECTION_CONTAINER_TITLE}
+
+
+
+ {if $message != ""} +
+
+
+ +
+
+
+ {/if} +
+ +
+
+ +
+
+ {form name="admin.selection.container.update"} + + {form_hidden_fields form=$form} + {render_form_field form=$form field="success_url" value="{url path='/admin/selection/container/update/%selection_container_id' selection_container_id=$selection_container_id}"} + + {include + file = "includes/inner-form-toolbar.html" + close_url = {url path='/admin/selection'} + current_tab = "general" + } + + + + {form_field field="success_url"} + + {/form_field} + +
+
+ {render_form_field field="selection_container_id"} + {render_form_field field="selection_container_code"} + {render_form_field field="selection_container_title"} + {render_form_field field="selection_container_chapo"} + {render_form_field field="selection_container_description" extra_class="wysiwyg"} + {render_form_field field="selection_container_postscriptum"} +
+
+ + {/form} +
+
+
+
+ + {include file="includes/seo-tab.html" + formAction = "{url path='/admin/selection/container/seo/save/'}" + pageUrl = "{url path='/admin/selection/container/update/%selection_container_id' selection_container_id=$selection_container_id}" + closeUrl = $close_url + current_id = $selection_container_id + success_url = "{url path='/admin/selection/container/update/%selection_container_id' selection_container_id=$selection_container_id}" + seoType = 'selection.container' + } + +
+
+
+
+ {include file="selectionImageUpdate.html" + imageType='SelectionContainer' + parentId=$selection_container_id + } +
+
+
+
+
+
+ {/loop} + +{/block} + + +{block name="javascript-last-call"} + {hook name="wysiwyg.js"} +{/block} + +{block name="javascript-initialization"} + {javascripts file='assets/js/dropzone.js'} + + {/javascripts} + {javascripts file='assets/js/image-upload.js'} + + {/javascripts} + + {javascripts file='assets/js/jquery-ui-1.10.3.custom.min.js'} + + {/javascripts} + + +{/block} + +{block name="javascript-last-call"} + {hook name="selection-container.edit-js" location="selection-container-edit-js" selection_id={$selection_container_id} } + {hook name="wysiwyg.js" location="wysiwyg-selection-container-edit-js" } +{/block} diff --git a/local/modules/Selection/templates/backOffice/default/container-view.html b/local/modules/Selection/templates/backOffice/default/container-view.html new file mode 100644 index 00000000..e71e7d5d --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/container-view.html @@ -0,0 +1,50 @@ +{extends file="admin-layout.tpl"} + +{block name="no-return-functions"} + {$admin_current_location = 'tools'} +{/block} + +{block name="check-resource"}admin.selection{/block} +{block name="check-access"}view{/block} + +{block name="page-title"}{intl l='Selections' d='selection.bo.default'}{/block} + +{block name="main-content"} +
+ + {if $message != ""} +
+
+
+ +
+
+
+ {/if} + {include file="selection-list-selections.html" } +{/block} + +{block name="javascript-last-call"} + {hook name="wysiwyg.js"} + + {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} + + {/javascripts} + + {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + {/javascripts} + + {javascripts file='assets/js/jquery-ui-1.10.3.custom.min.js'} + + {/javascripts} + + {include file="selection-list-selections.js"} +{/block} \ No newline at end of file diff --git a/local/modules/Selection/templates/backOffice/default/image-upload-list-ajax.html b/local/modules/Selection/templates/backOffice/default/image-upload-list-ajax.html new file mode 100644 index 00000000..6b11ac8d --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/image-upload-list-ajax.html @@ -0,0 +1,64 @@ +{default_translation_domain domain='bo.default'} + +{ifloop rel="selection_image"} +
    + {loop type="selection_image" name="selection_image" backend_context="on" lang="$edit_language_id" source=$imageType order="manual" source_id=$parentId width="200" height="100" resize_mode="borders" visible="*"} + +
  • + +
    + + {if $PROCESSING_ERROR} + {$TITLE} + {else} + {$TITLE} + {/if} + + +
    + {$POSITION} + + {loop type="auth" name="can_change" role="ADMIN" resource="{$resource|default:"admin.selection"}" access="UPDATE"} + + + + + + + + {/loop} + {elseloop rel="can_change"} + + + + {/elseloop} + + {loop type="auth" name="can_delete" role="ADMIN" resource="{$resource|default:"admin.selection"}" access="DELETE"} + + + + {/loop} +
    +
    + +
    + + + +
    + + + + + +
    +
    +
  • + {/loop} +
+{/ifloop} +{elseloop rel="selection_image"} +
{intl l='There is no images attached to this %type.' type={$imageType} d='selection.bo.default'}
+{/elseloop} \ No newline at end of file diff --git a/local/modules/Selection/templates/backOffice/default/image-upload.js b/local/modules/Selection/templates/backOffice/default/image-upload.js new file mode 100644 index 00000000..5f0230fa --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/image-upload.js @@ -0,0 +1,259 @@ +$(function($){ + // Manage picture upload + $.imageUploadManager = {}; + + Dropzone.autoDiscover = false; + + // Remove image on click + $.imageUploadManager.initImageDropZone = function() { + + $.imageUploadManager.onClickDeleteImage(); + $.imageUploadManager.onClickModal(); + $.imageUploadManager.onModalHidden(); + $.imageUploadManager.sortImage(); + $.imageUploadManager.onClickToggleVisibilityImage(); + $.imageUploadManager.onClickBtnDeleteSelectedImages(); + $.imageUploadManager.onClickBtnSelectDeselectImages(); + + var imageDropzone = new Dropzone("#images-dropzone", { + dictDefaultMessage : $('.btn-browse').html(), + uploadMultiple: false, + acceptedFiles: 'image/png, image/gif, image/jpeg' + }); + + var totalFiles = 0, + completedFiles = 0; + + imageDropzone.on("addedfile", function(file){ + totalFiles += 1; + + if(totalFiles == 1){ + $('.dz-message').hide(); + } + }); + + imageDropzone.on("complete", function(file){ + completedFiles += 1; + + if (completedFiles === totalFiles){ + $('.dz-message').slideDown(); + } + }); + + imageDropzone.on("success", function(file) { + imageDropzone.removeFile(file); + $.imageUploadManager.updateImageListAjax(); + $.imageUploadManager.onClickDeleteImage(); + $.imageUploadManager.onClickToggleVisibilityImage(); + }); + + + + }; + + // Update picture list via AJAX call + $.imageUploadManager.updateImageListAjax = function() { + var $imageListArea = $(".image-manager .existing-image"); + $imageListArea.html('
'); + $.ajax({ + type: "POST", + url: imageListUrl, + statusCode: { + 404: function() { + $imageListArea.html( + imageListErrorMessage + ); + } + } + }).done(function(data) { + $imageListArea.html( + data + ); + $.imageUploadManager.onClickDeleteImage(); + $.imageUploadManager.sortImage(); + $.imageUploadManager.onClickToggleVisibilityImage(); + }); + }; + + // Remove image on click + $.imageUploadManager.onClickDeleteImage = function() { + $('.image-manager .image-delete-btn').on('click', function (e) { + e.preventDefault(); + var $btnSubmit = $("#submit-delete-image"); + $btnSubmit.data("element-id", $(this).attr("id")); + $btnSubmit.data("type", "one"); + $('#modal-body-delete-image').html(imageDeleteOneWarningMessage); + $('#image_delete_dialog').modal("show"); + + return false; + }); + }; + + $.imageUploadManager.onClickBtnDeleteSelectedImages = function(){ + $('.btn-delete-selected-images').on('click', function(e) { + e.preventDefault(); + var $btnSubmit = $("#submit-delete-image"); + $btnSubmit.data("type", "multiple"); + var $count = $('.image-select-checkbox:checked').length; + var $warning; + if($count == 1){ + $warning = imageDeleteOneWarningMessage; + }else{ + $warning = imageDeleteMultipleWarningMessage.replace("%count", $count); + } + $('#modal-body-delete-image').html($warning); + $('#image_delete_dialog').modal("show"); + + return false; + }); + }; + + $.imageUploadManager.onClickBtnSelectDeselectImages = function(){ + $('.btn-select-all-images').on('click', function(e) { + e.preventDefault(); + $('.image-select-checkbox').prop('checked', true); + }); + + $('.btn-deselect-all-images').on('click', function(e) { + e.preventDefault(); + $('.image-select-checkbox').prop('checked', false); + }); + }; + + $.imageUploadManager.onModalHidden = function() { + $("#image_delete_dialog").on('hidden.bs.modal', function (e) { + var $btnSubmit = $("#submit-delete-image"); + $btnSubmit.data("element-id", ""); + $btnSubmit.data("type", ""); + $('#modal-body-delete-image').html(''); + }); + }; + + $.imageUploadManager.deleteSelectedImages = function(){ + $('.image-select-checkbox:checked').each(function(){ + $.imageUploadManager.deleteImage($(this).data("id")); + }); + }; + + $.imageUploadManager.deleteImage = function($id){ + var $this = $("#"+$id); + var $parent = $this.parent(); + var $greatParent = $parent.parent(); + + $greatParent.append('
'); + $greatParent.find('.btn-group').remove(); + var $url = $this.attr("href"); + var errorMessage = $this.attr("data-error-message"); + $.ajax({ + type: "POST", + url: $url, + statusCode: { + 404: function() { + $(".image-manager .message").html( + errorMessage + ); + } + } + }).done(function(data) { + $greatParent.parent().remove(); + $(".image-manager .message").html( + data + ); + + /* refresh position */ + $( "#js-sort-image").children('li').each(function(position, element) { + $(element).find('.js-sorted-position').html(position + 1); + }); + }).always(function(){ + $('#image_delete_dialog').modal("hide"); + }); + }; + + $.imageUploadManager.onClickModal = function() { + $("#submit-delete-image").on('click', function(e){ + var $type = $(this).data("type"); + if($type == 'one') { + var $id = $(this).data("element-id"); + $.imageUploadManager.deleteImage($id); + }else if($type == 'multiple'){ + $.imageUploadManager.deleteSelectedImages(); + } + }); + }; + + // toggle document on click + $.imageUploadManager.onClickToggleVisibilityImage = function() { + $('.image-manager').on('click', '.image-toggle-btn', function (e) { + e.preventDefault(); + var $this = $(this); + var $url = $this.attr("href"); + var errorMessage = $this.attr("data-error-message"); + $.ajax({ + type: "GET", + url: $url, + statusCode: { + 404: function() { + $(".image-manager .message").html( + errorMessage + ); + } + } + }).done(function(data) { + $(".image-manager .message").html( + data + ); + + $this.toggleClass("visibility-visible"); + }); + return false; + }); + }; + + $.imageUploadManager.sortImage = function() { + $( "#js-sort-image" ).sortable({ + placeholder: "ui-sortable-placeholder col-sm-6 col-md-3", + change: function( event, ui ) { + /* refresh position */ + var pickedElement = ui.item; + var position = 0; + $( "#js-sort-image").children('li').each(function(k, element) { + if($(element).data('sort-id') == pickedElement.data('sort-id')) { + return true; + } + position++; + if($(element).is('.ui-sortable-placeholder')) { + pickedElement.find('.js-sorted-position').html(position); + } else { + $(element).find('.js-sorted-position').html(position); + } + }); + }, + stop: function( event, ui ) { + /* update */ + var newPosition = ui.item.find('.js-sorted-position').html(); + var imageId = ui.item.data('sort-id'); + + $.ajax({ + type: "POST", + url: imageReorder, + data: { + image_id: imageId, + position: newPosition + }, + statusCode: { + 404: function() { + $(".image-manager .message").html( + imageReorderErrorMessage + ); + } + } + }).done(function(data) { + $(".image-manager .message").html( + data + ); + }); + } + }); + $( "#js-sort-image" ).disableSelection(); + }; +}); diff --git a/local/modules/Selection/templates/backOffice/default/related/contentRelated.html b/local/modules/Selection/templates/backOffice/default/related/contentRelated.html new file mode 100644 index 00000000..c67c9881 --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/related/contentRelated.html @@ -0,0 +1,16 @@ +{loop name="selection_content_related" type="selection_content_related" selection_id=$selection_id} + + {$CONTENT_ID} + {$CONTENT_TITLE} + + {$POSITION} + + + {loop type="auth" name="can_delete" role="ADMIN" resource="admin.selection" access="DELETE"} + + + + {/loop} + + +{/loop} \ No newline at end of file diff --git a/local/modules/Selection/templates/backOffice/default/related/productRelated.html b/local/modules/Selection/templates/backOffice/default/related/productRelated.html new file mode 100644 index 00000000..8f90349e --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/related/productRelated.html @@ -0,0 +1,65 @@ +{loop name="selection_product_related" type="selection_product_related" selection_id=$selection_id} + + {$PRODUCT_ID} + {$PRODUCT_TITLE} + + {admin_position_block + resource="admin.selection" + access="UPDATE" + path={url path='/admin/selection/product-related/update-position' product_id=$PRODUCT_ID selection_id=$selection_id} + url_parameter="product_id" + in_place_edit_class="productPositionChange" + position=$POSITION + id=$PRODUCT_ID + } + + + + {loop type="auth" name="can_delete" role="ADMIN" resource="admin.selection" access="DELETE"} + + + + {/loop} + + +{/loop} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + {/javascripts} + + {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} + + {/javascripts} + {javascripts file='assets/js/jquery.typewatch.js'} + + {/javascripts} + +{/block} + +{block name="javascript-last-call"} + {hook name="categories.js" location="categories-js" } +{/block} \ No newline at end of file diff --git a/local/modules/Selection/templates/backOffice/default/selection-edit.html b/local/modules/Selection/templates/backOffice/default/selection-edit.html new file mode 100644 index 00000000..a760c3f8 --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/selection-edit.html @@ -0,0 +1,324 @@ +{extends file="admin-layout.tpl"} +{block name="no-return-functions"} + {$admin_current_location = 'tools'} +{/block} + +{block name="check-resource"}admin.selection{/block} +{block name="check-access"}view{/block} + +{block name="page-title"}{intl l='Edit selection' d='selection.bo.default'}{/block} +{block name="after-bootstrap-css"} + {stylesheets source="Selection" file="assets/style/selection-image.css"} + + {/stylesheets} +{/block} + +{block name="main-content"} + + {loop name="selection_list" type="selection_list" limit="1" visible="*" id=$selection_id} + +
+
+
+ {intl l="Edit selection"} #{$selection_id} : {$SELECTION_TITLE}
+
+
+
+ {if $message != ""} +
+
+
+ +
+
+
+ {/if} +
+ +
+
+ +
+
+ {form name="admin.selection.update"} +
+ {form_hidden_fields form=$form} + {render_form_field form=$form field="success_url" value="{url path='/admin/selection'}"} + + {include + file = "includes/inner-form-toolbar.html" + page_url = "{url path='/admin/selection/update/%selection_id' selection_id = $selection_id}" + close_url = "{url path='/admin/selection'}" + current_tab = "general" + } +
+
+ + {render_form_field field="selection_id"} + {render_form_field field="selection_code"} + {render_form_field field="selection_container"} + {render_form_field field="selection_title"} + {render_form_field field="selection_chapo"} + {render_form_field field="selection_description" extra_class="wysiwyg"} + {render_form_field field="selection_postscriptum"} + +
+
+
+ {include file='selectionProductRelated.html'} +
+ +
+ {include file='selectionContentRelated.html'} +
+
+
+
+ {/form} +
+
+
+
+ + {include file="includes/seo-tab.html" + formAction = "{url path='/admin/selection/seo/save/'}" + pageUrl = "{url path='/admin/selection/update/%selection_id' selection_id = $selection_id}" + closeUrl = "{url path='/admin/selection'}" + current_id = $selection_id + success_url = "{url path='/admin/selection/update/%selection_id' selection_id = $selection_id}" + seoType = 'selection' + hide_save_and_close_button = true + } + +
+
+
+
+ {include file="selectionImageUpdate.html" + imageType='selection' + parentId=$selection_id + } +
+
+
+
+
+
+ {/loop} + +{/block} + + +{block name="javascript-last-call"} + {hook name="wysiwyg.js"} + +{/block} + +{block name="javascript-initialization"} + {javascripts file='assets/js/dropzone.js'} + + {/javascripts} + {javascripts file='assets/js/image-upload.js'} + + {/javascripts} + + {javascripts file='assets/js/jquery-ui-1.10.3.custom.min.js'} + + {/javascripts} + + +{/block} + +{block name="javascript-last-call"} + {hook name="selection.edit-js" location="selection-edit-js" selection_id={$selection_id} } + {hook name="wysiwyg.js" location="wysiwyg-selection-edit-js" } +{/block} diff --git a/local/modules/Selection/templates/backOffice/default/selection-image-edit.html b/local/modules/Selection/templates/backOffice/default/selection-image-edit.html new file mode 100644 index 00000000..c1fa6817 --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/selection-image-edit.html @@ -0,0 +1,135 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Edit an image' d='selection.bo.default'}{/block} + +{block name="check-access"}update{/block} + +{block name="main-content"} +
+ +
+ + {loop type="selection_image" name="selection_image" source="{$imageType}" id="{$imageId}" width="580" backend_context="1" lang="$edit_language_id" visible="*"} + + + {hook name="image-edit.top" image_id=$imageId} + +
+
+
+ +
+ {intl l='Edit image "%name"' name={$TITLE} d='selection.bo.default'} +
+ +
+
+ + {form name="$formId"} +
+ {include + file = "includes/inner-form-toolbar.html" + hide_submit_buttons = false + + page_url = "{url path="/selection/image/type/{$imageType}/{$ID}/update"}" + close_url = "{url path="{$redirectUrl}" current_tab="images" noamp=1}" + } + + {form_hidden_fields} + + {render_form_field field="success_url" value="{url path="/selection/image/type/%image/%id/update" image=$imageType id=$ID}"} + {render_form_field field="locale" value="$edit_language_locale"} + + {if $form_error}
{$form_error_message}
{/if} + +

{intl l="Image information" d='selection.bo.default'}

+ +
+
+
+ +

+ + {if $PROCESSING_ERROR} + {$TITLE} + {else} + {$TITLE} + {/if} + +

+
+
+ +
+ {render_form_field field="file"} + + {form_field field='visible'} +
+ + +
+ +
+
+ {/form_field} + + {render_form_field field="title" value=$TITLE} + {render_form_field field="chapo" value=$CHAPO} + {render_form_field field="postscriptum" value=$POSTSCRIPTUM} +
+
+
+
+ {render_form_field field="description" value=$DESCRIPTION extra_class="wysiwyg"} +
+
+ + {include + file = "includes/inner-form-toolbar.html" + hide_submit_buttons = false + hide_flags = true + + page_url = "{url path="/admin/image/type/%image/%id/update" image=$imageType id=$ID}" + close_url = "{url path="{$redirectUrl}" current_tab="images"}" + } +
+ {/form} + +
+
+ +
+
+ +
+ + {hook name="image-edit.bottom" image_id=$imageId} + + {/loop} + + {elseloop rel="selection_image"} +
+
+ +
+ {intl l="Sorry, image ID=%id was not found." id={$imageId} d='selection.bo.default'} +
+
+
+ {/elseloop} + +
+
+{/block} \ No newline at end of file diff --git a/local/modules/Selection/templates/backOffice/default/selection-list-containers.html b/local/modules/Selection/templates/backOffice/default/selection-list-containers.html new file mode 100644 index 00000000..0b04d807 --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/selection-list-containers.html @@ -0,0 +1,156 @@ +
+
+
+
+ + + + + + + + + + + + + {loop name="selection_container" type="selection_container" visible="*" backend_context="1" lang=$lang_id order=$selection_container_order} + + + + + + + + + + + + + + {/loop} + +
+ {intl l='Selections Containers' d='selection.bo.default'} + {loop type="auth" name="can_create" role="ADMIN" resource="admin.selection" access="CREATE"} + + + + + + {/loop} +
{intl l='ID' d='selection.bo.default'}{intl l="Code" d='selection.bo.default'}{intl l="Title" d='selection.bo.default'} + {admin_sortable_header + current_order=$selection_container_order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/selection' parent=$parent} + request_parameter_name='selection_container_order' + label="{intl l='Position' d='selection.bo.default'}" + } + {intl l='Online' d='selection.bo.default'}{intl l='Actions'}
{$SELECTION_CONTAINER_ID} + {loop type="selection_image" name="selection_image" lang="$edit_language_id" source="selection" source_id=$SELECTION_CONTAINER_ID width="70" height="50" resize_mode="borders" limit="1" visible="true"} + + {/loop} + + {loop type="auth" name="can_change" role="ADMIN" resource="admin.selection"} + {$SELECTION_CONTAINER_CODE} + {/loop} + {elseloop rel="can_change"} + {$SELECTION_CONTAINER_CODE} + {/elseloop} + + {loop type="auth" name="can_change" role="ADMIN" resource="admin.selection"} + {$SELECTION_CONTAINER_TITLE} + {/loop} + {elseloop rel="can_change"} + {$SELECTION_CONTAINER_TITLE} + {/elseloop} + + {admin_position_block + resource="admin.selection" + access="UPDATE" + path={url path='admin/selection/container/update-position' selection_container_id=$SELECTION_CONTAINER_ID position=$SELECTION_CONTAINER_POSITION} + url_parameter="selection_container_id" + in_place_edit_class="selectionContainerPositionChange" + position=$SELECTION_CONTAINER_POSITION + id=$SELECTION_CONTAINER_ID + } + + {loop type="auth" name="can_change" role="ADMIN" resource="admin.selection" access="UPDATE"} +
+ +
+ {/loop} + {elseloop rel="can_change"} +
+ +
+ {/elseloop} +
+
+ +
+ +
+
+
+
+
+{form name="admin.selection.container.create"} +{capture "selection_container_creation_dialog"} + {form_hidden_fields exclude='locale'} + {render_form_field form=$form field="success_url" value="{url path='/admin/selection/'}"} + {render_form_field field="code"} + {loop type="lang" name="default-lang" default_only=1} + {* Switch edition to the current locale *} + + + {render_form_field field="locale" value=$LOCALE} + + {custom_render_form_field field="title"} +
+ + {$TITLE} +
+ {/custom_render_form_field} + {/loop} + {render_form_field field='chapo'} + {render_form_field field='description' extra_class='wysiwyg'} + {render_form_field field='postscriptum'} +{/capture} + {include + file = "includes/generic-create-dialog.html" + dialog_id = "selection_container_creation_dialog" + dialog_title = {intl l="Create a Selection Container"} + dialog_body = {$smarty.capture.selection_container_creation_dialog nofilter} + dialog_ok_label = {intl l="Save"} + form_action = {url path='/admin/selection/container/create'} + form_enctype = {form_enctype} + form_error_message = $form_error_message +} +{/form} + +{capture "selection_container_delete_dialog"} + + {hook name="selection.container.delete-form" location="selection_container_delete_form" } +{/capture} + +{include file = "includes/generic-confirm-dialog.html" +dialog_id = "selection_container_delete_dialog" +dialog_title = {intl l="Delete selection container"} +dialog_message = {intl l="Do you really want to delete this container?"} +form_action = {token_url path='/admin/selection/container/delete'} +form_content = {$smarty.capture.selection_container_delete_dialog nofilter} +} diff --git a/local/modules/Selection/templates/backOffice/default/selection-list-containers.js b/local/modules/Selection/templates/backOffice/default/selection-list-containers.js new file mode 100644 index 00000000..3abd2264 --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/selection-list-containers.js @@ -0,0 +1,35 @@ + \ No newline at end of file diff --git a/local/modules/Selection/templates/backOffice/default/selection-list-selections.html b/local/modules/Selection/templates/backOffice/default/selection-list-selections.html new file mode 100644 index 00000000..01db9afb --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/selection-list-selections.html @@ -0,0 +1,166 @@ +{if not $selected_container_id} + {assign var="without_container" value = true} +{else} + {assign var="without_container" value = false} +{/if} +
+
+
+
+ + + + + + + + + + + + + {loop name="selection" type="selection_list" visible="*" backend_context="1" lang=$lang_id order=$selection_order container_id=$selected_container_id without_container=$without_container} + + + + + + + + + + + + {/loop} + +
+ {if not $selected_container_id} + {intl l='Selections without container' d='selection.bo.default'} + {else} + {loop name="selection_container_selected" type="selection_container" id=$selected_container_id visible="*" backend_context="1" lang=$lang_id order=$selection_order} + {$SELECTION_CONTAINER_TITLE} + {/loop} + {/if} + {loop type="auth" name="can_create" role="ADMIN" resource="admin.selection" access="CREATE"} + + + + + + {/loop} +
{intl l='ID' d='selection.bo.default'}{intl l="Code" d='selection.bo.default'}{intl l="Title" d='selection.bo.default'} + {admin_sortable_header + current_order=$selection_order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/selection' parent=$parent} + request_parameter_name='selection_order' + label="{intl l='Position' d='selection.bo.default'}" + } + {intl l='Online' d='selection.bo.default'}{intl l='Actions' d='selection.bo.default'}
{$SELECTION_ID} + {loop type="selection_image" name="selection_image" lang="$edit_language_id" source="selection" source_id=$SELECTION_ID width="70" height="50" resize_mode="borders" limit="1" visible="true"} + + {/loop} + + {loop type="auth" name="can_change" role="ADMIN" resource="admin.selection"} + {$SELECTION_CODE} + {/loop} + {elseloop rel="can_change"} + {$SELECTION_CODE} + {/elseloop} + + {loop type="auth" name="can_change" role="ADMIN" resource="admin.selection"} + {$SELECTION_TITLE} + {/loop} + {elseloop rel="can_change"} + {$SELECTION_TITLE} + {/elseloop} + + {admin_position_block + resource="admin.selection" + access="UPDATE" + path={url path='admin/selection/update-position' selection_id=$SELECTION_ID position=$SELECTION_POSITION} + url_parameter="selection_id" + in_place_edit_class="selectionPositionChange" + position=$SELECTION_POSITION + id=$SELECTION_ID + } + + {loop type="auth" name="can_change" role="ADMIN" resource="admin.selection" access="UPDATE"} +
+ +
+ {/loop} + {elseloop rel="can_change"} +
+ +
+ {/elseloop} +
+
+ +
+ +
+
+
+
+
+{form name="admin.selection.create"} + {capture "selection_creation_dialog"} + {form_hidden_fields exclude="locale"} + {render_form_field field="code"} + {loop type="lang" name="default-lang" default_only=1} + {* Switch edition to the default locale *} + + + {render_form_field field="locale" value=$LOCALE} + + {custom_render_form_field field="title"} +
+ + {$TITLE} +
+ {/custom_render_form_field} + {/loop} + {render_form_field field="container_id" value=$selected_container_id} + {render_form_field field='chapo'} + {render_form_field field='description' extra_class='wysiwyg'} + {render_form_field field='postscriptum'} +{/capture} +{include + file = "includes/generic-create-dialog.html" + dialog_id = "selection_creation_dialog" + dialog_title = {intl l="Add a selection to this container" d='selection.bo.default'} + dialog_body = {$smarty.capture.selection_creation_dialog nofilter} + dialog_ok_label = {intl l="Save" d='selection.bo.default'} + form_action = {url path='/admin/selection/create'} + form_enctype = {form_enctype} + form_error_message = $form_error_message +} +{/form} + +{capture "selection_delete_dialog"} + + + {hook name="selection.delete-form" location="selection_delete_form" } +{/capture} + +{include file = "includes/generic-confirm-dialog.html" +dialog_id = "selection_delete_dialog" +dialog_title = {intl l="Delete selection" d='selection.bo.default'} +dialog_message = {intl l="Do you really want to delete this selection ?" d='selection.bo.default'} +form_action = {token_url path='/admin/selection/delete'} +form_content = {$smarty.capture.selection_delete_dialog nofilter} +} diff --git a/local/modules/Selection/templates/backOffice/default/selection-list-selections.js b/local/modules/Selection/templates/backOffice/default/selection-list-selections.js new file mode 100644 index 00000000..ac2d264d --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/selection-list-selections.js @@ -0,0 +1,35 @@ + \ No newline at end of file diff --git a/local/modules/Selection/templates/backOffice/default/selection-list.html b/local/modules/Selection/templates/backOffice/default/selection-list.html new file mode 100644 index 00000000..0675731e --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/selection-list.html @@ -0,0 +1,51 @@ +{extends file="admin-layout.tpl"} + +{block name="no-return-functions"} + {$admin_current_location = 'tools'} +{/block} + +{block name="check-resource"}admin.selection{/block} +{block name="check-access"}view{/block} + +{block name="page-title"}{intl l='Selections' d='selection.bo.default'}{/block} + +{block name="main-content"} +
+ + {if $message != ""} +
+
+
+ +
+
+
+ {/if} + {include file="selection-list-containers.html"} + {include file="selection-list-selections.html"} +{/block} + +{block name="javascript-last-call"} + {hook name="wysiwyg.js"} + + {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} + + {/javascripts} + + {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + {/javascripts} + + {javascripts file='assets/js/jquery-ui-1.10.3.custom.min.js'} + + {/javascripts} + + {include file="selection-list-containers.js"} + {include file="selection-list-selections.js"} +{/block} \ No newline at end of file diff --git a/local/modules/Selection/templates/backOffice/default/selectionContentRelated.html b/local/modules/Selection/templates/backOffice/default/selectionContentRelated.html new file mode 100644 index 00000000..2ad98109 --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/selectionContentRelated.html @@ -0,0 +1,76 @@ +
+
+ + +

{intl l='Related content' d='selection.bo.default'}

+

{intl l='You can attach here some contents to this selection' d='selection.bo.default'}

+ + + + +
+
+ + + {**} + {**} + {**} + +
+ {intl l='Select a folder to get its content' d='selection.bo.default'} +
+ +
+
+ + + + + + + {* + + *} + +
+ {intl l='Select a product and click (+) to add it as an accessory' d='selection.bo.default'} +
+ +
+
+ {intl l="No available content in this folder" d='selection.bo.default'} +
+
+
+ +
+ + + + + + + + + + + {hook name="product.contents-table-header" location="product_contents_table_header" } + + + + + + + +
{intl l='ID' d='selection.bo.default'}{intl l='Content title' d='selection.bo.default'}{intl l='Position' d='selection.bo.default'}{intl l="Actions" d='selection.bo.default'}
+
+
diff --git a/local/modules/Selection/templates/backOffice/default/selectionImageUpdate.html b/local/modules/Selection/templates/backOffice/default/selectionImageUpdate.html new file mode 100644 index 00000000..0734408d --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/selectionImageUpdate.html @@ -0,0 +1,55 @@ +{default_translation_domain domain='bo.default'} +
+ {include + file = "includes/inner-form-toolbar.html" + hide_submit_buttons = true + hide_save_buttons = true + hide_save_and_close_button = true + page_url = "{navigate to="previous"}" + } +
+
+ + +
+ +
+ {intl l="Drop files to upload" d='selection.bo.default'} + {intl l="Or" d='selection.bo.default'} + +
+
+
+ {include file='image-upload-list-ajax.html' + imageType=$imageType + parentId=$parentId + resource='admin.Selection' + } +
+ + + +
\ No newline at end of file diff --git a/local/modules/Selection/templates/backOffice/default/selectionProductRelated.html b/local/modules/Selection/templates/backOffice/default/selectionProductRelated.html new file mode 100644 index 00000000..846c4605 --- /dev/null +++ b/local/modules/Selection/templates/backOffice/default/selectionProductRelated.html @@ -0,0 +1,81 @@ +
+
+

{intl l='Selection category' d='selection.bo.default'}

+

{intl l='You can attach here some category to this selection' d='selection.bo.default'}

+ + + + +
+
+ + + + {* + + + + *} +
+ + {intl l='Select a category to get its product' d='selection.bo.default'} + +
+ +
+
+ + + + + + {* + + + *} + + +
+ + {intl l='Select a product and click (+) to add it as an accessory' d='selection.bo.default'} + +
+ +
+
+ {intl l="No available product in this category" d='selection.bo.default'} +
+
+ + +
+ + + + + + + + + + + + + + + + + +
{intl l='ID' d='selection.bo.default'}{intl l='Product title' d='selection.bo.default'}{intl l='Position' d='selection.bo.default'}{intl l="Actions" d='selection.bo.default'}
+
+
+
diff --git a/templates/frontOffice/custom/I18n/fr_FR.php b/templates/frontOffice/custom/I18n/fr_FR.php index 7e74dcb1..6d9974e5 100644 --- a/templates/frontOffice/custom/I18n/fr_FR.php +++ b/templates/frontOffice/custom/I18n/fr_FR.php @@ -269,4 +269,7 @@ return array( 'per page' => 'par page', 'update' => 'mettre à jour', 'with:' => 'avec :', + + 'unite' => ' le kilo', + 'nouveaute' => "Nouveauté", ); diff --git a/templates/frontOffice/custom/assets/dist/css/custom.min.css b/templates/frontOffice/custom/assets/dist/css/custom.min.css index 9e7213e4..5da02f91 100644 --- a/templates/frontOffice/custom/assets/dist/css/custom.min.css +++ b/templates/frontOffice/custom/assets/dist/css/custom.min.css @@ -1 +1 @@ -@font-face{font-family:sofia_prolight;src:url(../fonts/sofiapro/sofiapro-light-webfont.woff2) format('woff2'),url(../fonts/sofiapro/sofiapro-light-webfont.woff) format('woff');font-weight:400;font-style:normal}html{font-family:sofia_prolight,sans-serif!important}#products-new .overlay:after,#products-offer .overlay:after,#products-upsell .overlay:after,body{font-family:sofia_prolight,'Open Sans',sans-serif!important}div.container{width:90%!important}@media (min-width:992px){.header__main{width:90%}}@media (min-width:768px){.header__content{flex-direction:column}}.header__content{display:flex}.header__main{align-items:center;display:flex;flex-direction:row;justify-content:space-between}.header__secondary{display:inline-flex}.navbar-default{background-color:transparent}.navbar li>a.home:before{display:none}.nav>li{text-transform:uppercase}.header__content .container-fluid{padding-left:0;padding-right:0}.navbar-form .form-control{width:150px}.logo-boutique{width:160px}.navbar{margin-bottom:0}.glyphicon,a{color:#95c11e}.btn-primary{background-color:#95c11e;border-left:0;border-color:#95c11e}.navbar-default .navbar-nav>li>a{color:#3c3c3b}.nav>li>a:focus,.nav>li>a:hover,.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:focus,.navbar-default .navbar-nav>.active>a:hover,.navbar-default .navbar-nav>li>a:focus,.navbar-default .navbar-nav>li>a:hover{background-color:#95c11e;color:#fff} \ No newline at end of file +@font-face{font-family:sofia_prolight;src:url(../fonts/sofiapro/sofiapro-light-webfont.woff2) format('woff2'),url(../fonts/sofiapro/sofiapro-light-webfont.woff) format('woff');font-weight:400;font-style:normal}aside.col-left,footer.footer-info,section.category-description{display:none}html{font-family:sofia_prolight,sans-serif!important}#products-new .overlay:after,#products-offer .overlay:after,#products-upsell .overlay:after,body{font-family:sofia_prolight,'Open Sans',sans-serif!important}div.container{width:90%!important}@media (min-width:992px){.header__main{width:90%}}@media (min-width:768px){.header__content{flex-direction:column}}.header__content{display:flex}.header__main{align-items:center;display:flex;flex-direction:row;justify-content:space-between}.header__secondary{display:inline-flex}.navbar-default{background-color:transparent}.navbar li>a.home:before{display:none}.nav>li{text-transform:uppercase}.header__content .container-fluid{padding-left:0;padding-right:0}.navbar-form .form-control{width:150px}.logo-boutique{width:160px}.navbar{margin-bottom:0}.glyphicon,a{color:#95c11e}.btn-primary{background-color:#95c11e;border-left:0;border-color:#95c11e}.navbar-default .navbar-nav>li>a{color:#3c3c3b}.nav>li>a:focus,.nav>li>a:hover,.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:focus,.navbar-default .navbar-nav>.active>a:hover,.navbar-default .navbar-nav>li>a:focus,.navbar-default .navbar-nav>li>a:hover{background-color:#95c11e;color:#fff}.price,.toolbar .amount{color:#95c11e}.breadcrumb{text-align:center;font-size:large;margin-bottom:30px}.grid #category-products .item>article .product-info .name{height:1.5em}.pagination>.active>a,.pagination>.active>a:focus,.pagination>.active>a:hover,.pagination>.active>span,.pagination>.active>span:focus,.pagination>.active>span:hover{background-color:#95c11e;border-color:#95c11e}.nouveaute{position:relative;z-index:300;display:block;background-color:red;border-radius:5px;color:#fff;bottom:170px;width:80px;text-align:center;transform:rotate(-10deg)} \ No newline at end of file diff --git a/templates/frontOffice/custom/assets/src/css/custom.css b/templates/frontOffice/custom/assets/src/css/custom.css index 3bab5fcc..c3432946 100644 --- a/templates/frontOffice/custom/assets/src/css/custom.css +++ b/templates/frontOffice/custom/assets/src/css/custom.css @@ -6,6 +6,17 @@ font-style: normal; } +section.category-description { + display: none; +} +aside.col-left { + display: none; +} +footer.footer-info { + display: none; +} + + html { font-family: 'sofia_prolight', sans-serif !important; } @@ -88,4 +99,36 @@ div.container { .nav>li>a:focus, .nav>li>a:hover { background-color: #95c11e; color: white; +} +.breadcrumb { + text-align: center; + font-size: large; + margin-bottom: 30px; +} +.toolbar .amount{ + color: #95c11e; +} +.grid #category-products .item>article .product-info .name { + height: 1.5em; +} +.price { + color: #95c11e; +} +.pagination>.active>a, .pagination>.active>a:focus, .pagination>.active>a:hover, .pagination>.active>span, .pagination>.active>span:focus, .pagination>.active>span:hover { + background-color: #95c11e; + border-color: #95c11e; +} + + +.nouveaute { + position: relative; + z-index: 300; + display: block; + background-color: red; + border-radius: 5px; + color: white; + bottom: 170px; + width: 80px; + text-align: center; + transform: rotate(-10deg); } \ No newline at end of file diff --git a/templates/frontOffice/custom/category.html b/templates/frontOffice/custom/category.html index fb9b98ec..ab5041b1 100644 --- a/templates/frontOffice/custom/category.html +++ b/templates/frontOffice/custom/category.html @@ -60,7 +60,8 @@ {hook name="category.content-top" category="$category_id"} - {if #category_display_detail# && $category_id} + + {if #category_display_detail# && $category_id}
{loop name="category.description" type="category" id={$category_id} limit="1" }

{category attr="title"}

@@ -107,7 +108,7 @@
    {loop type="product" name="product_list" category=$category_id limit=$limit page=$product_page order=$product_order} - {include file="includes/single-product.html" product_id=$ID hasBtn=true hasDescription=true hasQuickView=true width="218" height="146"} + {include file="includes/single-product.html" product_id=$ID hasBtn=false hasDescription=true hasQuickView=false width="218" height="146"} {/loop}
@@ -125,11 +126,10 @@ {hook name="category.content-bottom" category="$category_id"} - - //--> {hook name="category.main-bottom" category="$category_id"} diff --git a/templates/frontOffice/custom/includes/single-product.html b/templates/frontOffice/custom/includes/single-product.html index ca6fff49..34af936b 100644 --- a/templates/frontOffice/custom/includes/single-product.html +++ b/templates/frontOffice/custom/includes/single-product.html @@ -20,8 +20,12 @@ {/elseloop} + {if $IS_NEW} + {intl l="nouveaute"} + {/if} +
-

{$productTitle}

+

{$productTitle}

{if $hasDescription}

{$DESCRIPTION nofilter}

@@ -52,22 +56,44 @@ {if $IS_PROMO } {assign var="combination_count" value={count type="product_sale_elements" promo="1" product=$ID}} - {loop type="digressive" name="digressivePrice" product_id=$ID quantity=1} - {intl l="Special Price:"} - {if $combination_count > 1} - {intl l="From %price" price={format_money number=$TAXED_PROMO_PRICE}} - {else} - {format_money number=$TAXED_PROMO_PRICE} + {ifloop rel="dp"} + {loop type="digressive" name="dp" product_id=$ID order="false" limit=1} + + {intl l="From %price" price={format_money number=$TAXED_PROMO_PRICE}}{intl l="unite"} + + {if $SHOW_ORIGINAL_PRICE} + + {intl l="Regular Price:"} + {format_money number=$TAXED_PRICE} + {/if} - - {if $SHOW_ORIGINAL_PRICE} - {intl l="Regular Price:"} {format_money number=$TAXED_PRICE} - {/if} - {/loop} + {/loop} + {/ifloop} + {elseloop rel="dp"} + {loop type="product_sale_elements" name="pse" default=1 product=$product_id} + + {format_money number=$TAXED_PROMO_PRICE}{intl l="unite"} + + {if $SHOW_ORIGINAL_PRICE} + + {intl l="Regular Price:"} + {format_money number=$TAXED_PRICE} + + {/if} + {/loop} + {/elseloop} + {else} - {loop type="digressive" name="digressivePrice" product_id=$ID quantity=1} - {format_money number=$TAXED_PRICE} - {/loop} + {ifloop rel="dp"} + {loop type="digressive" name="dp" limit=1 product_id=$product_id order="false"} + {intl l="From %price" price={format_money number=$TAXED_PRICE}}{intl l="unite"} + {/loop} + {/ifloop} + {elseloop rel="dp"} + {loop type="product_sale_elements" name="pse" default=1 product=$product_id} + {format_money number=$TAXED_PRICE}{intl l="unite"} + {/loop} + {/elseloop} {/if}
diff --git a/templates/frontOffice/custom/layout.tpl b/templates/frontOffice/custom/layout.tpl index b476d9d4..b3a93378 100644 --- a/templates/frontOffice/custom/layout.tpl +++ b/templates/frontOffice/custom/layout.tpl @@ -211,6 +211,7 @@ GNU General Public License : http://www.gnu.org/licenses/
{/ifhook} + {ifhook rel="main.footer-bottom"}
diff --git a/local/modules/HookNavigation/templates/frontOffice/custom/main-navbar-primary.html b/templates/frontOffice/custom/modules/HookNavigation/main-navbar-primary.html similarity index 93% rename from local/modules/HookNavigation/templates/frontOffice/custom/main-navbar-primary.html rename to templates/frontOffice/custom/modules/HookNavigation/main-navbar-primary.html index 1f8e2d41..1bede1e3 100644 --- a/local/modules/HookNavigation/templates/frontOffice/custom/main-navbar-primary.html +++ b/templates/frontOffice/custom/modules/HookNavigation/main-navbar-primary.html @@ -26,6 +26,10 @@
  • {$TITLE}
  • {/if} {/loop} + +
  • Nos recettes
  • +
  • Contact
  • +
    diff --git a/templates/frontOffice/custom/product.html b/templates/frontOffice/custom/product.html index 353dcac9..57a9bcf7 100644 --- a/templates/frontOffice/custom/product.html +++ b/templates/frontOffice/custom/product.html @@ -208,17 +208,21 @@ - {loop type="digressive" name="digressivePriceLoop" product_id=$product_id quantity=1} - {intl l="Special Price:"} - {if $IS_PROMO} - {format_money number=$TAXED_PROMO_PRICE symbol={currency attr="symbol"}} - {else} - {format_money number=$TAXED_PRICE symbol={currency attr="symbol"}} - {/if} - - {/loop} + {ifloop rel="dp"} + {loop type="digressive" name="dp" product_id=$product_id quantity=1} + {intl l="Special Price:"} + {if $IS_PROMO} + {format_money number=$TAXED_PROMO_PRICE symbol={currency attr="symbol"}} + {else} + {format_money number=$TAXED_PRICE symbol={currency attr="symbol"}} + {/if} + + {/loop} + {/ifloop} + {elseloop rel="dp"} + {/elseloop} - + {if $SHOW_ORIGINAL_PRICE} {intl l="Regular Price:"} {format_money number=$TAXED_PRICE}