/** * Set progress text for Progress flash dialog. * * <code> * {% set options_backstretch = {'id': 'body', 'img': 'bundles/sfynxtemplate/images/layout/novedia/BACKGROUNDS/background-home.jpg' } %} * {{ renderJquery('TOOL', 'backstretch', options_backstretch )|raw }} * </code> * * @param $options tableau d'options. * @access protected * @return void * * @author Etienne de Longeaux <*****@*****.**> */ protected function render($options = null) { // Options management if (!isset($options['id']) || empty($options['id'])) { throw ExtensionException::optionValueNotSpecified('id', __CLASS__); } if (!isset($options['img']) || empty($options['img'])) { throw ExtensionException::optionValueNotSpecified('img', __CLASS__); } // if the file doesn't exist, we call an exception $is_file_exist = realpath($this->container->get('kernel')->getRootDir() . '/../web/' . $options['img']); if (!$is_file_exist) { throw ExtensionException::FileUnDefined('img', __CLASS__); } $Urlpath = $this->container->get('templating.helper.assets')->getUrl($options['img']); // We open the buffer. ob_start(); ?> $.backstretch("<?php echo $Urlpath; ?> "); <?php // We retrieve the contents of the buffer. $_content_js = ob_get_contents(); // We clean the buffer. ob_clean(); // We close the buffer. ob_end_flush(); return $this->renderScript($_content_js, '', 'cmf/backstretch/'); }
/** * Set progress text for Progress flash dialog. * * @param $options tableau d'options. * @access protected * @return void * * @author Etienne de Longeaux <*****@*****.**> */ protected function renderlistAction($options = null) { if (!isset($options['class']) || empty($options['class'])) { throw ExtensionException::optionValueNotSpecified('class', __CLASS__); } if (!isset($options['img-arrow']) || empty($options['img-arrow'])) { throw ExtensionException::optionValueNotSpecified('img-arrow', __CLASS__); } $em = $this->container->get('doctrine')->getManager(); $locale = $this->container->get('request')->getLocale(); $entities = $em->getRepository("SfynxAuthBundle:Langue")->getAllEnabled($locale, 'object', false); // if the file doesn't exist, we call an exception $img = "bundles/sfynxtemplate/images/arrow/" . $options['img-arrow']; $is_file_exist = realpath($this->container->get('kernel')->getRootDir() . '/../web/' . $img); if (!$is_file_exist) { throw ExtensionException::FileUnDefined('img', __CLASS__); } $Urlpath = $this->container->get('templating.helper.assets')->getUrl($img); // We open the buffer. ob_start(); ?> <div class="clear"> </div> <div class="acc-line"> </div> <a href="" class="language-subtitle">Local language</a> <div class="clear"> </div> <div class="acc-line"> </div> <a href=""><?php echo locale_get_display_name(strtolower($locale), strtolower($locale)); ?> </a> <div class="clear"> </div> <div class="acc-line"> </div> <a href="" class="language-subtitle"><?php echo $this->container->get('translator')->trans('pi.form.label.field.other'); ?> </a> <?php foreach ($entities as $key => $entity) { $url = $this->container->get('router')->generate('pi_layout_choisir_langue', array('langue' => $entity->getId())); if ($entity->getId() != $locale) { $name_language = locale_get_display_name(strtolower($entity->getId()), strtolower($locale)); ?> <div class="clear"> </div> <div class="acc-line"> </div> <a href="<?php echo $url; ?> " id="lang_select_<?php echo $entity->getId(); ?> " title="<?php echo $name_language; ?> "><?php echo $name_language; ?> </a> <?php } } ?> <?php // We retrieve the contents of the buffer. $_content = ob_get_contents(); // We clean the buffer. ob_clean(); // We close the buffer. ob_end_flush(); return $_content; }
/** * Return the metas of a page. * * @author Etienne de Longeaux <*****@*****.**> */ public function getMetaPageFunction($lang, array $options) { // we get the param. if (empty($lang)) { $lang = $this->container->get('request')->getLocale(); } $Uri = $this->container->get('request')->getUri(); $BasePath = $this->container->get('request')->getUriForPath(''); $author = str_replace(array('"', "'"), array("’", "’"), $this->container->getParameter('pi_app_admin.layout.meta.author')); $copyright = str_replace(array('"', "'"), array("’", "’"), $this->container->getParameter('pi_app_admin.layout.meta.copyright')); $description = str_replace(array('"', "'"), array("’", "’"), $this->container->getParameter('pi_app_admin.layout.meta.description')); $keywords = str_replace(array('"', "'"), array("’", "’"), $this->container->getParameter('pi_app_admin.layout.meta.keywords')); $og_title_add = str_replace(array('"', "'"), array("’", "’"), $this->container->getParameter('pi_app_admin.layout.meta.og_title_add')); $og_type = str_replace(array('"', "'"), array("’", "’"), $this->container->getParameter('pi_app_admin.layout.meta.og_type')); $og_image = str_replace(array('"', "'"), array("’", "’"), $this->container->getParameter('pi_app_admin.layout.meta.og_image')); $og_site_name = str_replace(array('"', "'"), array("’", "’"), $this->container->getParameter('pi_app_admin.layout.meta.og_site_name')); // if the file doesn't exist, we call an exception $og_image = strip_tags($this->container->get('translator')->trans($og_image)); $is_file_exist = realpath($this->container->get('kernel')->getRootDir() . '/../web/' . $og_image); if (!$is_file_exist) { throw ExtensionException::FileUnDefined('img', __CLASS__); } $og_image = $this->container->get('templating.helper.assets')->getUrl($og_image); // if (isset($options['title']) && !empty($options['title'])) { $title = $options['title']; } if (isset($options['description']) && !empty($options['description'])) { $description = $options['description']; } if (isset($options['keywords']) && !empty($options['keywords'])) { $keywords = $options['keywords']; } // we get all info of a the current page. $options = $this->container->get('pi_app_admin.manager.page')->getPageMetaInfo($lang, $title, $description, $keywords); // we create the copyright link if (isset($copyright) && !empty($copyright)) { $copyright = strip_tags($this->container->get('translator')->trans($copyright)); $metas[] = "<link rel='copyright' href=\"" . $copyright . "\"/>"; } // we create all meta tags. $metas[] = " <meta charset='" . $this->container->get('twig')->getCharset() . "'/>"; $metas[] = " <meta http-equiv='Content-Type'/>"; $metas[] = " <meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'/>"; $metas[] = " <meta name='generator' content=\"Sfynx\"/>"; // if (isset($author) && !empty($author)) { $author = strip_tags($this->container->get('translator')->trans($author)); $metas[] = " <meta name='author' content=\"" . $author . "\"/>"; } if (isset($options['description']) && !empty($options['description'])) { $metas[] = " <meta name='description' content=\"" . $options['description'] . "\"/>"; } if (isset($options['keywords']) && !empty($options['keywords'])) { $metas[] = " <meta name='keywords' content=\"" . $options['keywords'] . "\"/>"; } $metas[] = " <meta property='og:url' content=\"{$Uri}\"/>"; // if (isset($options['title']) && !empty($options['title'])) { $metas[] = " <meta property='og:title' content=\"{$og_title_add}{$options['title']}\"/>"; } if (isset($og_type) && !empty($og_type)) { $og_type = strip_tags($this->container->get('translator')->trans($og_type)); $metas[] = " <meta property='og:type' content=\"{$og_type}\"/>"; } if (isset($og_image) && !empty($og_image)) { $og_image = strip_tags($this->container->get('translator')->trans($og_image)); $metas[] = " <meta property='og:image' content=\"{$BasePath}{$og_image}\"/>"; } if (isset($og_site_name) && !empty($og_site_name)) { $og_site_name = strip_tags($this->container->get('translator')->trans($og_site_name)); $og_site_name = str_replace('https://', '', $og_site_name); $og_site_name = str_replace('http://', '', $og_site_name); $metas[] = " <meta property='og:site_name' content=\"{$og_site_name}\"/>"; } // additions management $additions = $this->container->getParameter('pi_app_admin.layout.meta.additions'); ksort($additions); foreach ($additions as $k => $values) { $metas[] = $values; } return implode(" \n", $metas); }