/** * Get result from cache or execute database query * * @param array $config query and cache parameters * @param ServiceLocatorInterface $sl * @return multitype:NULL */ protected function queryDbCacheResult($config, $sl) { $result = array(); $cache = $sl->get(static::CONTENTINUM_CACHE); $key = $config['cache']; if (!($result = $cache->getItem($key))) { $worker = new Worker($sl->get($config['entitymanager'])); $worker->setEntity($config['entity']); $entries = $worker->getStorage()->getRepository($worker->getEntityName())->findBy(array('publish' => 'yes'), array('itemRang' => 'ASC')); $i = 1; foreach ($entries as $entry) { $metas = array(); $metas['rel'] = $entry->metaRel ? $entry->metaRel : false; $metas['type'] = $entry->metaType ? $entry->metaType : false; $metas['title'] = $entry->metaTitle ? $entry->metaTitle : false; $metas['content'] = $entry->metaContent ? $entry->metaContent : false; if (1 !== $entry->webMedias->id) { $metas['href'] = $entry->webMedias->mediaLink; $metas['sizes'] = $entry->webMedias->mediaDimensions; } else { $metas['href'] = $entry->metaLink; } $result[$entry->webPages->id][] = $metas; $i++; } if (isset($config['savecache']) && true === $config['savecache']) { $cache->setItem($key, $result); } } if (null === $result) { $result = array(); } return $result; }
/** * (non-PHPdoc) * * @see \Contentinum\Service\WebsiteServiceFactory::queryDbCacheResult() */ protected function queryDbCacheResult($config, $sl) { $result = array(); $cache = $sl->get(static::CONTENTINUM_CACHE); $key = $config['cache']; if (!($result = $cache->getItem($key))) { try { $worker = new Worker($sl->get($config['entitymanager'])); $repos = $worker->getStorage()->getRepository($config['entity']); if (isset($config['findBy'])) { $entries = $repos->findBy($config['findBy']); } else { $entries = $repos->findAll(); } } catch (\Exception $e) { print $e->getMessage(); exit('application break'); } $rows = array(); foreach ($entries as $entry) { $row = array(); foreach ($this->cols as $col) { $row[$col] = $entry->{$col}; } $rows[$entry->webPreferences->hostId][$entry->url] = $row; } $result = new Config($rows); if (isset($config['savecache']) && true === $config['savecache']) { $cache->setItem($key, $result); } } return $result; }
/** * (non-PHPdoc) * * @see \Contentinum\Service\WebsiteServiceFactory::queryDbCacheResult() */ protected function queryDbCacheResult($config, $sl) { $result = array(); $cache = $sl->get(static::CONTENTINUM_CACHE); $key = $config['cache']; if (!($result = $cache->getItem($key))) { $worker = new Worker($sl->get($config['entitymanager'])); $entries = $worker->fetchAll("SELECT users_id, acl_group_id FROM user_acl_index ORDER BY acl_group_id ASC;"); $ident = false; $rows = array(); $tmp = array(); foreach ($entries as $entry) { if ($ident != $entry['acl_group_id']) { if (false !== $ident) { $rows[$ident] = $tmp; $tmp = array(); } $ident = $entry['acl_group_id']; } $tmp[] = $entry['users_id']; } $rows[$ident] = $tmp; $result = new Config($rows); if (isset($config['savecache']) && true === $config['savecache']) { $cache->setItem($key, $result); } } return $result; }
/** * (non-PHPdoc) * * @see \Contentinum\Service\WebsiteServiceFactory::queryDbCacheResult() */ protected function queryDbCacheResult($config, $sl) { $result = array(); $cache = $sl->get(static::CONTENTINUM_CACHE); $key = $config['cache']; if (!($result = $cache->getItem($key))) { $worker = new Worker($sl->get($config['entitymanager'])); $conn = $worker->getConnection(); $sql = "SELECT main.web_contentgroup_id, wc.title, wc.id, wpp.label "; $sql .= "FROM web_content_groups AS main "; $sql .= "LEFT JOIN web_content AS wc ON wc.id = main.web_content_id "; $sql .= "LEFT JOIN web_pages_content AS wpc ON wpc.web_contentgroup_id = main.web_contentgroup_id "; $sql .= "LEFT JOIN web_pages_parameter AS wpp ON wpp.id = wpc.web_pages_id "; $sql .= "WHERE main.scope = 'content' "; $sql .= "GROUP BY main.web_contentgroup_id "; $sql .= "ORDER BY wc.title ASC"; $entries = $conn->query($sql)->fetchAll(); $tmp = array(); foreach ($entries as $entry) { $tmp[$entry['web_contentgroup_id']] = array('name' => '(' . $entry['label'] . ') - ' . $entry['title']); } $result = new Config($tmp); if (isset($config['savecache']) && true === $config['savecache']) { $cache->setItem($key, $result); } } return $result; }
/** * (non-PHPdoc) * @see \Zend\ServiceManager\FactoryInterface::createService() */ public function createService(ServiceLocatorInterface $serviceLocator) { $worker = new Worker($serviceLocator->get('doctrine.entitymanager.orm_default')); $sql = "SELECT id, name "; $sql .= "FROM user_acl_groups "; $sql .= "WHERE params = 'members' "; $sql .= "ORDER BY name ASC;"; $result = $worker->fetchAll($sql); $options = array(); foreach ($result as $row) { $options[$row['id']] = $row['name']; } return $options; }
/** * (non-PHPdoc) * @see \Zend\ServiceManager\FactoryInterface::createService() */ public function createService(ServiceLocatorInterface $serviceLocator) { $worker = new Worker($serviceLocator->get('doctrine.entitymanager.orm_default')); $sql = "SELECT id, name "; $sql .= "FROM mcevent_dates_config "; $sql .= "ORDER BY name ASC;"; $result = $worker->fetchAll($sql); $options = array(); $options[0] = 'Keine Auswahl'; foreach ($result as $row) { $options[$row['id']] = $row['name']; } return $options; }
/** * (non-PHPdoc) * * @see \Contentinum\Service\WebsiteServiceFactory::queryDbCacheResult() */ protected function queryDbCacheResult($config, $sl) { $result = array(); $cache = $sl->get(static::CONTENTINUM_CACHE); $key = $config['cache']; if (!($result = $cache->getItem($key))) { $worker = new Worker($sl->get($config['entitymanager'])); $datas = $worker->fetchAll('SELECT * FROM mediainuse'); $result = array(); foreach ($datas as $row) { $result[$row['mediasid']][] = array($row['inuseid'], $row['groupname']); } $this->saveCacheItems($key, $result, $cache, $config); } return $result; }
/** * Get result from cache or execute database query * * @param array $config query and cache parameters * @param ServiceLocatorInterface $sl * @return multitype:NULL */ protected function queryDbCacheResult($config, $sl) { $result = array(); $cache = $sl->get(static::CONTENTINUM_CACHE); $key = $config['cache']; if (!($result = $cache->getItem($key))) { $worker = new Worker($sl->get($config['entitymanager'])); $worker->setEntity($config['entity']); $sortby = $config['sortby']; $entries = $worker->getStorage()->getRepository($worker->getEntityName())->findAll(); foreach ($entries as $entry) { $result[$entry->{$sortby}] = $entry->toArray(); } $this->saveCacheItems($key, $result, $cache, $config); } return $result; }
/** * (non-PHPdoc) * * @see \Contentinum\Service\WebsiteServiceFactory::queryDbCacheResult() */ protected function queryDbCacheResult($config, $sl) { $result = array(); $cache = $sl->get(static::CONTENTINUM_CACHE); $key = $config['cache']; if (!($result = $cache->getItem($key))) { $worker = new Worker($sl->get($config['entitymanager'])); $repos = $worker->getStorage()->getRepository($config['entity']); if (isset($config['findBy'])) { $orderBy = array(); if (isset($config['orderBy'])) { $orderBy = $config['orderBy']; } $entries = $repos->findBy($config['findBy'], $orderBy); } else { if (isset($config['orderBy'])) { $entries = $repos->findBy(array(), $config['orderBy']); } else { $entries = $repos->findAll(); } } $tmp = array(); foreach ($entries as $entry) { if (9 !== $entry->onlylink) { if (1 === $entry->onlylink) { $url = $entry->url; $label = ' (external)'; } else { if ('index' === $entry->url) { $url = '/'; } else { $url = '/' . $entry->url; } $label = ' (internal)'; } $tmp[$url] = array('name' => $entry->label . $label); } } $result = new Config($tmp); if (isset($config['savecache']) && true === $config['savecache']) { $cache->setItem($key, $result); } } return $result; }
protected function queryDbCacheResult($config, $sl) { $result = array(); $cache = $sl->get(static::CONTENTINUM_CACHE); $key = $config['cache']; if (!($result = $cache->getItem($key))) { $worker = new Worker($sl->get($config['entitymanager'])); $entries = $worker->getStorage()->getRepository($config['entity'])->findBy(array('eventOrganizer' => 1), array('organisation' => 'ASC')); $tmp = array(); foreach ($entries as $entry) { $tmp[$entry->id] = array('name' => $entry->organisation); } $result = new Config($tmp); if (isset($config['savecache']) && true === $config['savecache']) { $cache->setItem($key, $result); } } return $result; }
/** * (non-PHPdoc) * * @see \Contentinum\Service\WebsiteServiceFactory::queryDbCacheResult() */ protected function queryDbCacheResult($config, $sl) { $result = array(); $cache = $sl->get(static::CONTENTINUM_CACHE); $key = $config['cache']; if (!($result = $cache->getItem($key))) { $worker = new Worker($sl->get($config['entitymanager'])); $conn = $worker->getConnection(); $sql = "SELECT main.id, main.organisation, main.organisation_ext "; $sql .= "FROM accounts AS main "; $sql .= "ORDER BY main.organisation ASC"; $entries = $conn->query($sql)->fetchAll(); $tmp = array(); foreach ($entries as $entry) { $tmp[$entry['id']] = array('name' => $entry['organisation'] . ', ' . $entry['organisation_ext']); } $result = new Config($tmp); if (isset($config['savecache']) && true === $config['savecache']) { $cache->setItem($key, $result); } } return $result; }
/** * (non-PHPdoc) * @see \Zend\ServiceManager\FactoryInterface::createService() */ public function createService(ServiceLocatorInterface $serviceLocator) { $worker = new Worker($serviceLocator->get('doctrine.entitymanager.orm_default')); $current = date('Y-m-d') . ' 00:00:00'; $selectdate = date('Y'); $sql = "SELECT mtc.id, mtc.date_start, mtc.applicant_int, mtc.applicant_ext, mtc.summary "; $sql .= "FROM mcevent_dates AS mtc "; $sql .= "WHERE mtc.publish = 'yes' "; $sql .= "AND mtc.date_start >= '" . $selectdate . "%' "; $sql .= "AND mtc.configure_id > 0 "; $sql .= "ORDER BY mtc.date_start ASC;"; $trashdates = $worker->fetchAll($sql); $options = array(); $convert = new \ContentinumComponents\Tools\ConvertMonthDayNames(); foreach ($trashdates as $row) { if ($row['date_start'] >= $current) { $datetime = new \DateTime($row['date_start']); $trashDate = $convert->get($datetime->format('N'), 'dayname') . ', ' . $datetime->format('d') . '. ' . $convert->get($datetime->format('m')) . ' ' . $datetime->format('Y'); $options[$row['id']] = $row['summary'] . ' ' . $trashDate; } } return $options; }
/** * 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; } }