public function getDiaporamaDataAction($shortcode)
 {
     $diaporama = Diaporama::getByShortcode($shortcode);
     if (is_null($diaporama)) {
         $result = array('error' => $this->translator->trans('diaporama.read.no_shortcode %shortcode', array('shortcode' => $shortcode), Diaporamas::BO_MESSAGE_DOMAIN));
     } else {
         $result = array('id' => $diaporama->getId(), 'title' => $diaporama->getTitle(), 'shortcode' => $diaporama->getShortcode(), 'created_at' => $diaporama->getCreatedAt(), 'updated_at' => $diaporama->getUpdatedAt(), 'locale' => $diaporama->getLocale(), 'images' => array());
         // Data for images
         $loop = new DiaporamaImageLoop($this->getContainer());
         $loop->initializeArgs(array('source_id' => $diaporama->getId(), 'order' => 'manual'));
         /** @var DiaporamaImageQuery $query */
         $query = $loop->buildModelCriteria();
         $res = $query->find();
         $diaporamaImagesRows = $loop->parseResults(new LoopResult($res));
         /** @var LoopResultRow $row */
         foreach ($diaporamaImagesRows as $row) {
             $result['images'][] = array('id' => $row->get('ID'), 'position' => $row->get('POSITION'), 'visible' => boolval($row->get('VISIBLE')), 'title' => is_null($row->get('TITLE')) ? '' : $row->get('TITLE'), 'chapo' => is_null($row->get('CHAPO')) ? '' : $row->get('CHAPO'), 'description' => is_null($row->get('DESCRIPTION')) ? '' : $row->get('DESCRIPTION'), 'postscriptum' => is_null($row->get('POSTSCRIPTUM')) ? '' : $row->get('POSTSCRIPTUM'), 'image_url' => $row->get('IMAGE_URL'), 'processing_error' => boolval($row->get('PROCESSING_ERROR')));
         }
     }
     return new JsonResponse($result);
 }
 protected function createOrUpdate(DiaporamaEvent $event, Diaporama $model)
 {
     $con = Propel::getConnection(DiaporamaTableMap::DATABASE_NAME);
     $con->beginTransaction();
     try {
         $model->setLocale($event->getLocale());
         if (null !== ($id = $event->getId())) {
             $model->setId($id);
         }
         if (null !== ($title = $event->getTitle())) {
             $model->setTitle($title);
         }
         if (null !== ($shortcode = $event->getShortcode())) {
             $model->setShortcode($shortcode);
         }
         $model->save($con);
         $con->commit();
     } catch (\Exception $e) {
         $con->rollback();
         throw $e;
     }
     $event->setDiaporama($model);
 }
 /**
  * Filter the query by a related \Diaporamas\Model\Diaporama object
  *
  * @param \Diaporamas\Model\Diaporama|ObjectCollection $diaporama The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildDiaporamaVersionQuery The current query, for fluid interface
  */
 public function filterByDiaporama($diaporama, $comparison = null)
 {
     if ($diaporama instanceof \Diaporamas\Model\Diaporama) {
         return $this->addUsingAlias(DiaporamaVersionTableMap::ID, $diaporama->getId(), $comparison);
     } elseif ($diaporama instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(DiaporamaVersionTableMap::ID, $diaporama->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByDiaporama() only accepts arguments of type \\Diaporamas\\Model\\Diaporama or Collection');
     }
 }
 /**
  * Declares an association between this object and a ChildDiaporama object.
  *
  * @param                  ChildDiaporama $v
  * @return                 \Diaporamas\Model\DiaporamaVersion The current object (for fluent API support)
  * @throws PropelException
  */
 public function setDiaporama(ChildDiaporama $v = null)
 {
     if ($v === null) {
         $this->setId(NULL);
     } else {
         $this->setId($v->getId());
     }
     $this->aDiaporama = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the ChildDiaporama object, it will not be re-added.
     if ($v !== null) {
         $v->addDiaporamaVersion($this);
     }
     return $this;
 }
 /**
  * Parsing a description, in order to replace shortcodes with their HTML codes.
  *
  * Internal and reusable method to do it.
  * @param string $description The description
  */
 protected function updateDescription($description)
 {
     $shortcodeTags = array();
     if (!preg_match_all(Diaporama::SHORTCODETAG_HTMLENTITIES_REGEX, $description, $shortcodeTags)) {
         return $description;
     }
     // Array with all the captured shortcodes once
     $shortcodeTags = array_unique($shortcodeTags[0]);
     $diaporamaHtmlCodes = array();
     foreach ($shortcodeTags as $shortcodeTag) {
         $toParseshortcodeTag = str_replace(['£', ' '], ['£', ' '], $shortcodeTag);
         sscanf($toParseshortcodeTag, "[£ %s £]", $shortcode);
         if (Diaporama::existsByShortcode($shortcode)) {
             $diaporamaHtmlCodes[$shortcodeTag] = $this->getShortcodeHTML($shortcode, 200, 100);
         }
     }
     return str_replace(array_keys($diaporamaHtmlCodes), array_values($diaporamaHtmlCodes), $description);
 }
 /**
  * Exclude object from result
  *
  * @param   ChildDiaporama $diaporama Object to remove from the list of results
  *
  * @return ChildDiaporamaQuery The current query, for fluid interface
  */
 public function prune($diaporama = null)
 {
     if ($diaporama) {
         $this->addUsingAlias(DiaporamaTableMap::ID, $diaporama->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }