protected function mediaMetas($metas, $name)
 {
     if (null === $this->mcSerialize) {
         $this->mcSerialize = new HandleSerializeDatabase();
     }
     $metas = $this->mcSerialize->execUnserialize($metas);
     if (isset($metas['linkname']) && strlen($metas['linkname']) > 1) {
         return $metas['linkname'];
     } else {
         return $name;
     }
 }
 /**
  * Unserialize group params if avaiable
  * 
  * @param string $datas
  * @return Ambigous <multitype:, mixed>
  */
 public function unserializeGroupParams($datas)
 {
     if (null === $this->mcSerialize) {
         $this->mcSerialize = new HandleSerializeDatabase();
     }
     return $this->mcSerialize->execUnserialize($datas);
 }
 /**
  * Content query
  * 
  * @param array $params query conditions
  * @return multitype:
  */
 public function fetchContent(array $params = null)
 {
     if (isset($params['id'])) {
         $result = $this->find($params['id']);
         $groupParams = $result->groupParams;
         if (strlen($groupParams) > 1) {
             $mcSerialize = new HandleSerializeDatabase();
             return $mcSerialize->execUnserialize($groupParams);
         }
     }
     return array();
 }
 /**
  * Content query
  * @param array $params query conditions
  * @return multitype:
  */
 public function fetchContent(array $params = null)
 {
     if (isset($params['id'])) {
         $id = $params['id'];
     } elseif (isset($params['query']['id'])) {
         $id = $params['query']['id'];
     } else {
         return array('error' => 'miss_paramter');
     }
     $entry = $this->fetchPopulateValues($id);
     if (isset($entry['mediaMetas'])) {
         $mcSerialize = new HandleSerializeDatabase();
         return $mcSerialize->execUnserialize($entry['mediaMetas']);
     } else {
         return array('error' => 'data_not_found');
     }
 }
 /**
  * form field elements
  * 
  * @see \ContentinumComponents\Forms\AbstractForms::elements()
  */
 public function elements()
 {
     $sl = $this->getServiceLocator();
     $pageOptions = $sl->get('contentinum_pages');
     $configuration = $pageOptions->getParameter('categoryvalue');
     $con = new Worker($sl->get('doctrine.entitymanager.orm_default'));
     $result = $con->fetchRow("SELECT * FROM mcevent_dates_config WHERE id = {$configuration};");
     if (isset($result['settings_formular']) && strlen($result['settings_formular']) > 1) {
         $mcSerialize = new HandleSerializeDatabase();
         $formSettings = $mcSerialize->execUnserialize($result['settings_formular']);
         $onlysingle = false;
         $fields = array();
         $fields[] = array('spec' => array('name' => 'mceventIdent', 'required' => true, 'options' => array('label' => 'Termin wählen', 'empty_option' => 'Please select', 'value_options' => $this->getServiceLocator()->get('mcevent_options_eventdatepublic'), 'deco-row' => $this->getDecorators(self::DECO_ELM_ROW)), 'type' => 'Select', 'attributes' => array('required' => 'required', 'id' => 'mceventIdent')));
         foreach ($formSettings as $setting) {
             if ('onlysingle' == $setting) {
                 $onlysingle = true;
             }
             if ('fieldname' == $setting) {
                 $field = '';
                 $field['name'] = 'name';
                 $field['required'] = true;
                 $field['options'] = array();
                 $field['options']['label'] = 'Name';
                 $field['options']['deco-row'] = $this->getDecorators(self::DECO_ELM_ROW);
                 $field['type'] = 'Text';
                 $field['attributes'] = array();
                 $field['attributes']['id'] = 'name';
                 $field['attributes']['required'] = 'required';
                 $fields[] = array('spec' => $field);
             }
             if ('fieldphone' == $setting) {
                 $field = '';
                 $field['name'] = 'phone';
                 $field['required'] = true;
                 $field['options'] = array();
                 $field['options']['label'] = 'Telefon';
                 $field['options']['deco-row'] = $this->getDecorators(self::DECO_ELM_ROW);
                 $field['type'] = 'ContentinumComponents\\Forms\\Elements\\Tel';
                 $field['attributes'] = array();
                 $field['attributes']['id'] = 'phone';
                 $field['attributes']['required'] = 'required';
                 $fields[] = array('spec' => $field);
             }
             if ('fieldemail' == $setting) {
                 $field = '';
                 $field['name'] = 'email';
                 $field['required'] = true;
                 $field['options'] = array();
                 $field['options']['label'] = 'E-Mailadresse';
                 $field['options']['deco-row'] = $this->getDecorators(self::DECO_ELM_ROW);
                 $field['type'] = 'Email';
                 $field['attributes'] = array();
                 $field['attributes']['id'] = 'email';
                 $field['attributes']['required'] = 'required';
                 $fields[] = array('spec' => $field);
             }
             if ('fielddescription' == $setting) {
                 $field = '';
                 $field['name'] = 'description';
                 $field['required'] = false;
                 $field['options'] = array();
                 $field['options']['label'] = 'Bemerkung';
                 $field['options']['deco-row'] = $this->getDecorators(self::DECO_ELM_ROW);
                 $field['options']['description'] = 'Bemerkung zur Anmeldung, Nachricht an Organisator';
                 $field['type'] = 'Textarea';
                 $field['attributes'] = array();
                 $field['attributes']['id'] = 'description';
                 $field['attributes']['row'] = '2';
                 $fields[] = array('spec' => $field);
             }
             if ('fieldstayOvernight' == $setting) {
                 $field = '';
                 $field['name'] = 'stayOvernight';
                 $field['required'] = true;
                 $field['options'] = array();
                 $field['options']['label'] = 'Übernachtung bestätigen';
                 $field['options']['value_options'] = array('yes' => 'Ja, ich nutze das Übernachtungsangebot', 'no' => 'Nein, keine Übernachtung', 'perhaps' => 'Noch unentschlossen');
                 $field['options']['deco-row'] = $this->getDecorators(self::DECO_ELM_ROW);
                 $field['options']['description'] = 'Bestätigen Sie Bitte ob Sie übernachten möchten';
                 $field['type'] = 'Select';
                 $field['attributes'] = array();
                 $field['attributes']['id'] = 'stayOvernight';
                 $field['attributes']['required'] = 'required';
                 $field['attributes']['value'] = 'yes';
                 $fields[] = array('spec' => $field);
             }
         }
         $fields[] = array('spec' => array('name' => 'send', 'type' => 'Submit', 'attributes' => array('class' => 'button expand', 'value' => 'Absenden', 'id' => 'sendbutton')));
         return $fields;
     } else {
         print '<p><strong>Formularfehler, wenden Sie sich Bitte an den Administrator</strong></p>';
         exit;
     }
 }
 /**
  * Populate database entries in form fields
  */
 protected function populate($id, $pageOptions)
 {
     $datas = $this->worker->fetchPopulateValues($id);
     if ($this->populateentity) {
         $furtherDatas = array();
         foreach ($this->populateentity as $column => $row) {
             $furtherDatas = $this->worker->populateFurtherEntities($row['entity'], $column, $id, $row['columns'], $datas);
         }
         if (is_array($furtherDatas) && !empty($furtherDatas)) {
             $datas = array_merge($datas, $furtherDatas);
         }
     }
     if (false !== ($populateFromFactory = $pageOptions->getApp('populateFromFactory'))) {
         $factoryDatas = array();
         foreach ($populateFromFactory as $key => $row) {
             $result = array();
             $mapper = $this->getServiceLocator()->get($key);
             $result = $mapper->fetchContent(array($row['query'] => $id));
             if (isset($result[$row['result']])) {
                 $factoryDatas[$row['populate']] = $result[$row['result']];
             }
         }
         if (is_array($factoryDatas) && !empty($factoryDatas)) {
             $datas = array_merge($datas, $factoryDatas);
         }
     }
     if (false !== ($populateFromDb = $pageOptions->getApp('populateFromDb'))) {
         foreach ($populateFromDb as $key) {
             $mapper = $this->getServiceLocator()->get($key);
             $datas = $mapper->fetchContent($datas);
         }
     }
     if (false !== $this->notPopulate) {
         foreach ($this->notPopulate as $field) {
             if (isset($datas[$field])) {
                 unset($datas[$field]);
             }
         }
     }
     if (is_array($this->unserialize)) {
         $mcSerialize = new HandleSerializeDatabase();
         foreach ($this->unserialize as $field) {
             if (isset($datas[$field]) && strlen($datas[$field]) > 1) {
                 if ('y' == $pageOptions->getApp('populateSerialize')) {
                     $datas[$field] = $mcSerialize->execUnserialize($datas[$field]);
                 } else {
                     $datas = array_merge($datas, $mcSerialize->execUnserialize($datas[$field]));
                 }
             }
         }
     }
     return $datas;
 }
 /**
  *
  * @param unknown $params
  */
 protected function convertGroupParams($group)
 {
     $this->groupName = $group['name'];
     $this->groupurl = $group['url'];
     foreach ($this->imagesProperties as $prop) {
         if (isset($group[$prop])) {
             $this->groupImages[$prop] = $group[$prop];
         }
     }
     if (strlen($group['group_params']) > 4) {
         $mcSerialize = new HandleSerializeDatabase();
         $this->groupParams = $mcSerialize->execUnserialize($group['group_params']);
     } else {
         $this->groupParams = array();
     }
 }
 /**
  *
  * @param unknown $article
  * @param unknown $medias
  * @param string $template
  * @param string $setSize
  * @return string
  */
 public function __invoke($content, $media, $template, $setSize = null, $onlyImg = false)
 {
     $htmlwidgets = '';
     if ('nomediastyle' !== $content->htmlwidgets) {
         $htmlwidgets = $content->htmlwidgets;
         if ($template->contribution->{$htmlwidgets}) {
             $this->setTemplate($template->contribution->{$htmlwidgets});
         } elseif ($template->contribution->_defaultimages) {
             $this->setTemplate($template->contribution->_defaultimages);
         } else {
             $onlyImg = true;
         }
     }
     $size = null;
     $src = $media->mediaLink;
     $unserialize = new HandleSerializeDatabase();
     $mediaMetas = $unserialize->execUnserialize($media->mediaMetas);
     $styleAttr = '';
     $img = '<img src="' . $src . '"';
     if (isset($mediaMetas['alt'])) {
         $img .= ' alt="' . $mediaMetas['alt'] . '"';
     }
     if (false !== ($title = $this->hasValue($mediaMetas, 'title'))) {
         $img .= ' title="' . $title . '"';
     }
     $img .= ' />';
     if (strlen($content->mediaLinkUrl) > 0) {
         $img = '<a href="' . $content->mediaLinkUrl . '">' . $img . '</a>';
     }
     if (true === $onlyImg || 'nomediastyle' === $content->htmlwidgets) {
         $this->unsetProperties();
         return $this->formatElement($img . $content->content, $content);
     }
     $mediarows = $this->media->toArray();
     $mediarows['row']['attr']['class'] .= ' ' . $content->mediaStyle;
     if (false !== ($caption = $this->hasValue($mediaMetas, 'caption'))) {
         $mediarows['row']['content:before'] = $img;
         $images = $this->deployRow($mediarows, $caption);
     } else {
         $images = $this->deployRow(array('grid' => $mediarows['row']), $img);
     }
     switch ($this->direction) {
         case 'left':
             $html = $this->deployRow($this->wrapper, $this->deployRow($this->block, $images) . $this->deployRow($this->content, $this->formatElement($content->content, $content)));
             break;
         case 'right':
             $html = $this->deployRow($this->wrapper, $this->deployRow($this->content, $this->formatElement($content->content, $content)) . $this->deployRow($this->block, $images));
             break;
         default:
             if (1 === $content->mediaPlaceholder) {
                 $html = $this->formatElement(str_replace('{MEDIAPLACE}', $images, $content->content), $content);
             } else {
                 $html = $this->formatElement($images . $content->content, $content);
             }
             break;
     }
     $this->unsetProperties();
     $mediarows = null;
     $images = null;
     return $html;
 }