Ejemplo n.º 1
0
 /**
  * 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    ChildContent The current object (for fluent API support)
  */
 public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null)
 {
     if (!$this->isNew()) {
         ChildContentI18nQuery::create()->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))->delete($con);
     }
     if (isset($this->currentTranslations[$locale])) {
         unset($this->currentTranslations[$locale]);
     }
     foreach ($this->collContentI18ns as $key => $translation) {
         if ($translation->getLocale() == $locale) {
             unset($this->collContentI18ns[$key]);
             break;
         }
     }
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Performs an INSERT on the database, given a ContentI18n or Criteria object.
  *
  * @param mixed               $criteria Criteria or ContentI18n 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(ContentI18nTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from ContentI18n object
     }
     // Set the correct dbName
     $query = ContentI18nQuery::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;
 }
Ejemplo n.º 3
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      ConnectionInterface $con
  * @return void
  * @throws PropelException
  * @see ContentI18n::setDeleted()
  * @see ContentI18n::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(ContentI18nTableMap::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = ChildContentI18nQuery::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;
     }
 }
Ejemplo n.º 4
0
 Model\FeatureAvQuery::create()->deleteAll();
 Model\FeatureAvI18nQuery::create()->deleteAll();
 Model\AttributeQuery::create()->deleteAll();
 Model\AttributeI18nQuery::create()->deleteAll();
 Model\AttributeAvQuery::create()->deleteAll();
 Model\AttributeAvI18nQuery::create()->deleteAll();
 Model\CategoryQuery::create()->deleteAll();
 Model\CategoryI18nQuery::create()->deleteAll();
 Model\ProductQuery::create()->deleteAll();
 Model\ProductI18nQuery::create()->deleteAll();
 Model\CustomerQuery::create()->deleteAll();
 Model\AdminQuery::create()->deleteAll();
 Model\FolderQuery::create()->deleteAll();
 Model\FolderI18nQuery::create()->deleteAll();
 Model\ContentQuery::create()->deleteAll();
 Model\ContentI18nQuery::create()->deleteAll();
 Model\AccessoryQuery::create()->deleteAll();
 Model\ProductSaleElementsQuery::create()->deleteAll();
 Model\ProductPriceQuery::create()->deleteAll();
 Model\BrandQuery::create()->deleteAll();
 Model\BrandI18nQuery::create()->deleteAll();
 Model\ProductImageQuery::create()->deleteAll();
 Model\CategoryImageQuery::create()->deleteAll();
 Model\FolderImageQuery::create()->deleteAll();
 Model\ContentImageQuery::create()->deleteAll();
 Model\BrandImageQuery::create()->deleteAll();
 Model\ProductDocumentQuery::create()->deleteAll();
 Model\CategoryDocumentQuery::create()->deleteAll();
 Model\FolderDocumentQuery::create()->deleteAll();
 Model\ContentDocumentQuery::create()->deleteAll();
 Model\BrandDocumentQuery::create()->deleteAll();
 /**
  * @return mixed|\Thelia\Core\HttpFoundation\Response
  * @throws \Propel\Runtime\Exception\PropelException
  */
 public function searchAction()
 {
     if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), 'RewriteUrl', AccessManager::VIEW))) {
         return $response;
     }
     $search = '%' . $this->getRequest()->query->get('q') . '%';
     $resultArray = array();
     $categoriesI18n = CategoryI18nQuery::create()->filterByTitle($search)->limit(10);
     $contentsI18n = ContentI18nQuery::create()->filterByTitle($search)->limit(10);
     $foldersI18n = FolderI18nQuery::create()->filterByTitle($search)->limit(10);
     $brandsI18n = BrandI18nQuery::create()->filterByTitle($search)->limit(10);
     $productsI18n = ProductI18nQuery::create()->filterByTitle($search)->limit(10);
     $productsRef = ProductQuery::create()->filterByRef($search)->limit(10);
     /** @var \Thelia\Model\CategoryI18n $categoryI18n */
     foreach ($categoriesI18n as $categoryI18n) {
         $category = $categoryI18n->getCategory();
         $resultArray['category'][$category->getId()] = $categoryI18n->getTitle();
     }
     /** @var \Thelia\Model\ContentI18n $contentI18n */
     foreach ($contentsI18n as $contentI18n) {
         $content = $contentI18n->getContent();
         $resultArray['content'][$content->getId()] = $contentI18n->getTitle();
     }
     /** @var \Thelia\Model\FolderI18n $folderI18n */
     foreach ($foldersI18n as $folderI18n) {
         $folder = $folderI18n->getFolder();
         $resultArray['folder'][$folder->getId()] = $folderI18n->getTitle();
     }
     /** @var \Thelia\Model\BrandI18n $brandI18n */
     foreach ($brandsI18n as $brandI18n) {
         $brand = $brandI18n->getBrand();
         $resultArray['brand'][$brand->getId()] = $brandI18n->getTitle();
     }
     /** @var \Thelia\Model\ProductI18n $productI18n */
     foreach ($productsI18n as $productI18n) {
         $product = $productI18n->getProduct();
         $resultArray['product'][$product->getId()] = $productI18n->getTitle();
     }
     /** @var \Thelia\Model\Product $product */
     foreach ($productsRef as $product) {
         $productI18n = ProductI18nQuery::create()->filterByProduct($product)->findOne();
         $resultArray['product'][$product->getId()] = $productI18n->getTitle();
     }
     return $this->jsonResponse(json_encode($resultArray));
 }