/** * {@inheritdoc} */ public function execute(BlockInterface $block, Response $response = null) { // merge settings $settings = array_merge($this->getDefaultSettings(), $block->getSettings()); $media = $settings['mediaId']; return $this->renderResponse('SonataMediaBundle:Block:block_feature_media.html.twig', array('media' => $media, 'block' => $block, 'settings' => $settings), $response); }
/** * {@inheritdoc} */ public function load(BlockInterface $block) { $userManager = $this->container->get('fos_user.user_manager'); $settings = $block->getSettings(); $userRegistrations = $userManager->fetchRegistrationCount(isset($settings['fetchCountRecord']) ? $settings['fetchCountRecord'] : 5); $block->setSetting('userRegistrations', $userRegistrations); }
/** * {@inheritdoc} */ public function execute(BlockInterface $block, Response $response = null) { $settings = array_merge($this->getDefaultSettings(), $block->getSettings()); $revisions = array(); foreach ($this->auditReader->findRevisionHistory($settings['limit'], 0) as $revision) { $revisions[] = array('revision' => $revision, 'entities' => $this->auditReader->findEntitesChangedAtRevision($revision->getRev())); } return $this->renderResponse('SonataDoctrineORMAdminBundle:Block:block_audit.html.twig', array('block' => $block, 'settings' => $settings, 'revisions' => $revisions), $response); }
/** * {@inheritdoc} */ public function execute(BlockInterface $block, Response $response = null) { $settings = array_merge($this->getDefaultSettings(), $block->getSettings()); $response = $this->renderResponse('IphpCoreBundle:Block:block_container.html.twig', array('container' => $block, 'settings' => $settings), $response); //$response->setContent('Контент контейнера' /*Mustache::replace($settings['layout'], array( 'CONTENT' => $response->getContent() ))*/ //); return $response; }
/** * @param BlockInterface $block * @param OutputInterface $output * @param int $spance */ public function renderBlock(BlockInterface $block, OutputInterface $output, $extended, $space = 0) { $output->writeln(sprintf("%s <comment>> Id: %d - type: %s - name: %s</comment>", str_repeat(" ", $space), $block->getId(), $block->getType(), $block->getName())); if ($extended) { foreach ($block->getSettings() as $name => $value) { $output->writeln(sprintf("%s %s: %s", str_repeat(" ", $space + 1), $name, var_export($value, 1))); } } foreach ($block->getChildren() as $block) { $this->renderBlock($block, $output, $extended, $space + 1); } }
/** * {@inheritdoc} */ public function execute(BlockInterface $block, Response $response = null) { $settings = array_merge($this->getDefaultSettings(), $block->getSettings()); $dashboardGroups = $this->pool->getDashboardGroups(); $visibleGroups = array(); foreach ($dashboardGroups as $name => $dashboardGroup) { if (!$settings['groups'] || in_array($name, $settings['groups'])) { $visibleGroups[] = $dashboardGroup; } } return $this->renderResponse($this->pool->getTemplate('list_block'), array('block' => $block, 'settings' => $settings, 'admin_pool' => $this->pool, 'groups' => $visibleGroups), $response); }
/** * {@inheritdoc} */ public function execute(BlockInterface $block, Response $response = null) { $parameters = (array) json_decode($block->getSetting('parameters'), true); $parameters = array_merge($parameters, array('_block' => $block)); $settings = array_merge($this->getDefaultSettings(), (array) $block->getSettings()); try { $actionContent = $this->kernel->render($settings['action'], $parameters); } catch (\Exception $e) { throw $e; } $content = self::mustache($block->getSetting('layout'), array('CONTENT' => $actionContent)); return $this->renderResponse('SonataBlockBundle:Block:block_core_action.html.twig', array('content' => $content, 'block' => $block), $response); }
/** * {@inheritdoc} */ public function execute(BlockInterface $block, Response $response = null) { // merge settings $settings = array_merge($this->getDefaultSettings(), $block->getSettings()); $feeds = false; if ($settings['url']) { $options = array('http' => array('user_agent' => 'Sonata/RSS Reader', 'timeout' => 2)); // retrieve contents with a specific stream context to avoid php errors $content = @file_get_contents($settings['url'], false, stream_context_create($options)); if ($content) { // generate a simple xml element try { $feeds = new \SimpleXMLElement($content); $feeds = $feeds->channel->item; } catch (\Exception $e) { // silently fail error } } } return $this->renderResponse('SonataBlockBundle:Block:block_core_rss.html.twig', array('feeds' => $feeds, 'block' => $block, 'settings' => $settings), $response); }
/** * @param BlockInterface $block * @param array $attributes * @param string $prefix * * @return string */ public function renderAttributes(BlockInterface $block = null, $attributes = array(), $prefix = 'attr') { if ($attributes && is_string($attributes)) { $prefix = $attributes; $attributes = array(); } if ($block) { foreach ($block->getSettings() as $key => $value) { $key = trim(mb_strtolower($key, 'utf8')); $match = null; if (preg_match('@^' . preg_quote($prefix) . '-([a-z][-a-z0-9]*)$@', $key, $match)) { $attributes[$match[1]] = $value; } } } $attributesString = ''; foreach ($attributes as $key => $value) { $key = trim(mb_strtolower($key, 'utf8')); if (preg_match('@^[a-z][-a-z0-9]*$@', $key)) { $attributesString .= $key . '="' . addslashes($value) . '" '; } } return trim($attributesString); }
/** * {@inheritdoc} */ public function execute(BlockInterface $block, Response $response = null) { $settings = array_merge($this->getDefaultSettings(), $block->getSettings()); return $this->renderResponse('SonataAdminBundle:Block:block_admin_list.html.twig', array('block' => $block, 'settings' => $settings, 'admin_pool' => $this->pool), $response); }
/** * {@inheritdoc} */ public function execute(BlockInterface $block, Response $response = null) { $settings = array_merge($this->getDefaultSettings(), $block->getSettings()); return $this->renderResponse('RadioSolutionMenuBundle:Block:block_core_menu.html.twig', array('block' => $block, 'settings' => $settings), $response); }
/** * {@inheritdoc} */ public function execute(BlockInterface $block, Response $response = null) { // merge settings $settings = array_merge($this->getDefaultSettings(), $block->getSettings()); $gallery = $settings['galleryId']; return $this->renderResponse('SonataMediaBundle:Block:block_gallery.html.twig', array('gallery' => $gallery, 'block' => $block, 'settings' => $settings, 'elements' => $gallery ? $this->buildElements($gallery) : array()), $response); }
/** * @param BlockInterface $block * * @return array */ protected function createBlocks(BlockInterface $block) { $content = array(); $content['id'] = $block->getId(); $content['name'] = $block->getName(); $content['enabled'] = $block->getEnabled(); $content['position'] = $block->getPosition(); $content['settings'] = $block->getSettings(); $content['type'] = $block->getType(); $content['created_at'] = $block->getCreatedAt()->format('U'); $content['updated_at'] = $block->getUpdatedAt()->format('U'); $content['blocks'] = array(); foreach ($block->getChildren() as $child) { $content['blocks'][] = $this->createBlocks($child); } return $content; }
/** * {@inheritdoc} */ public function execute(BlockInterface $block, Response $response = null) { $settings = array_merge($this->getDefaultSettings(), $block->getSettings()); $response = $this->renderResponse('IphpContentBundle:Block:content_announces.html.twig', array('block' => $block, 'settings' => $settings, 'contents' => $this->prepareContents($settings)), $response); return $response; }
/** * {@inheritdoc} */ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) { $settings = $block->getSettings(); $formMapper->add('settings', 'sonata_type_immutable_array', array('translation_domain' => 'BrotherMapBundle', 'keys' => array(array('map', 'sonata_type_immutable_array', array('keys' => array(array('html_id', 'text', array('required' => true, 'data' => empty($settings['map']['html_id']) ? 'ymap' : $settings['map']['html_id'])), array('type', 'choice', array('required' => true, 'data' => empty($settings['map']['type']) ? $this->config['type'] : $settings['map']['type'], 'choices' => array(YMap::MAP_TYPE_HYBRID => 'Гибрит', YMap::MAP_TYPE_MAP => 'Схема', YMap::MAP_TYPE_PUBLIC => 'Народная', YMap::MAP_TYPE_PUBLIC_HYBRID => 'Народная гибрит', YMap::MAP_TYPE_SATELLITE => 'Спутник'))), array('zoom', 'choice', array('required' => true, 'data' => empty($settings['map']['zoom']) ? $this->config['zoom'] : $settings['map']['zoom'], 'choices' => array(1 => 'Мелко', 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 'Средне', 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 16 => 'Крупно')))))), array('point', 'sonata_type_immutable_array', array('keys' => array(array('title', 'text', array('required' => false)), array('title_style', 'choice', array('required' => false, 'choices' => PresetStorage::$stretchIcons)), array('latitude', 'number', array('required' => true, 'data' => empty($settings['point']['latitude']) ? $this->config['latitude'] : $settings['point']['latitude'], 'precision' => 6)), array('longitude', 'number', array('required' => true, 'data' => empty($settings['point']['longitude']) ? $this->config['longitude'] : $settings['point']['longitude'], 'precision' => 6))))), array('polygon', 'sonata_type_immutable_array', array('keys' => array(array('points', 'textarea', array('required' => false)), array(GeoObject::OPTION_STROKE_WIDTH, 'text', array('required' => false)), array(GeoObject::OPTION_STROKE_COLOR, 'text', array('required' => false)), array(GeoObject::OPTION_OPACITY, 'text', array('required' => false)))))))); }
/** * {@inheritdoc} */ public function execute(BlockInterface $block, Response $response = null) { // merge settings $settings = array_merge($this->getDefaultSettings(), $block->getSettings()); $media = $settings['menuId']; return $this->renderResponse($this->getTemplate(), array('menu' => menu, 'block' => $block, 'settings' => $settings), $response); }