/**
  * Return a JS file in the container in links.
  *
  * @param string $content_js string   content js value
  * @param string $content_html string content html value
  * @param string $path_prefix string  prefix repository value
  * @param string $result              ['both', 'html', 'linkJs']
  * 
  * @return string
  * @access public
  * @author Etienne de Longeaux <*****@*****.**>
  */
 public function renderScript($content_js, $content_html, $path_prefix = '/', $result = "both")
 {
     $TEMP_FILES_DIR = $this->getContainer()->getParameter("kernel.root_dir") . "/../web/yui/js/" . $path_prefix;
     // we create repository if does not exit
     PiFileManager::mkdirr($TEMP_FILES_DIR, 0777);
     //  we create single file from all input
     $input_hash = sha1($content_js);
     $file = $TEMP_FILES_DIR . $input_hash . '.js';
     // we compress the content
     if (!file_exists($file)) {
         $this->getContainer()->get('sfynx.tool.file_manager')->save($file, $content_js, 0777);
     }
     // we set result
     $this->getContainer()->get('sfynx.tool.twig.extension.layouthead')->addJsFile("yui/js/" . $input_hash . '.js');
     $resultScript = '<script type="text/javascript" src="/yui/js/' . $path_prefix . $input_hash . '.js" ></script>';
     // we return the result
     if ($result == "both") {
         return $content_html . $resultScript;
     } elseif ($result == "html") {
         return $content_html;
     } elseif ($result == "linkJs") {
         return $resultScript;
     } else {
         return $content_html . "\n            <script type='text/javascript'>\n            //<![CDATA[\n            " . $content_js . "\n            //]]>\n            </script>\n            ";
     }
 }
 /**
  * Constructor.
  *
  * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
  */
 public function __construct(ContainerInterface $container)
 {
     parent::__construct($container);
     $dossier = $this->container->getParameter('pi_app_admin.cache_dir.indexation');
     if (\Sfynx\ToolBundle\Util\PiFileManager::mkdirr($dossier, 0777)) {
         $this->_indexPath = $dossier . self::NAME_INDEX;
     } else {
         throw new \InvalidArgumentException("The Indexation cache repository is not created correctly");
     }
 }
 /**
  * The execute method
  *
  * @param InputInterface  $input  The Input class
  * @param OutputInterface $output The output class
  *
  * @access protected
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $start_date = time();
     $this->em = $this->getContainer()->get('doctrine')->getManager('default');
     $root_dir = $this->getContainer()->getParameter("kernel.root_dir") . "/config/gatling/data";
     PiFileManager::mkdirr($root_dir, 0777);
     $path = $root_dir . "/connexion_sfynx.csv";
     file_put_contents($path, 'username,password' . "\n", LOCK_EX);
     //
     $firstId = (int) $input->getOption('firstId');
     $lastId = (int) $input->getOption('lastId');
     $output->writeln('First id user : '******'last id user : '******'fr_FR', :user, :user, :user, :user, 1, '73rwkq08i3wo0ow840c0g48k800o0ok', " . "'xREF5HHqHbZmlmoO3+s5BXtVtYa3TIf8Wv+IVXJsQwx+0FG1WnqxjJ46toQ1u/+v1lfKOwo90FqEbqiPDzDo+g==', '2014-11-13 00:00:00', " . "0, 0, NULL, NULL, NULL, 'a:1:{i:0;s:9:\"ROLE_USER\";}', 'a:4:{i:0;s:4:\"VIEW\";i:1;s:4:\"EDIT\";i:2;s:6:\"CREATE\";i:3;s:6:\"DELETE\";}', 0, NULL, :user, :user, '2014-11-12 17:55:21' " . ");";
     $this->em->getConnection()->beginTransaction();
     $stmtuser = $this->em->getConnection()->prepare($sqluser);
     try {
         $psw = "user";
         $start_date_user = time();
         for ($j = $firstId; $j <= $lastId; $j++) {
             $user_value = 'user' . $j;
             $params = array('id' => $j, 'user' => $user_value, 'user' => $user_value, 'user' => $user_value, 'user' => $user_value, 'user' => $user_value, 'user' => $user_value);
             $stmtuser->execute($params);
             //
             file_put_contents($path, "{$user_value},{$psw}\n", FILE_APPEND);
         }
         $end_date_user = time();
         $duration_user = $end_date_user - $start_date_user;
         $output->writeln(" - fin de chargement de données des users en " . $duration_user . "s");
         $this->em->flush();
         // Try and commit the transaction
         $this->em->getConnection()->commit();
     } catch (\Exception $e) {
         $output->writeln($e->getMessage());
         // Rollback the failed transaction attempt
         $this->em->getConnection()->rollback();
         $this->em->close();
     }
     $end_date = time();
     $duration = $end_date - $start_date;
     $output->writeln(" - fin de chargement de donnée en " . $duration . "s");
 }
 /**
  * Return the url of a media (and put the result in cache).
  *
  * @param string $id
  * @param string $format   ["default_small", "default_big", "reference"]
  * @param string $cachable
  *
  * @return string
  * @access public
  * @author Etienne de Longeaux <*****@*****.**>
  */
 public function getMediaUrlFunction($id, $format = "small", $cachable = true, $modifdate = false, $pattern = "media_")
 {
     if ($modifdate instanceof \Datetime) {
         $timestamp = $modifdate->getTimestamp();
     } elseif (is_string($modifdate)) {
         $timestamp = $modifdate;
     } else {
         $timestamp = 0;
     }
     try {
         if (!$cachable) {
             $url_public_media = $this->container->get('sonata.media.twig.extension')->path($id, $format) . "?v.{$timestamp}";
         } else {
             $dossier = $this->container->getParameter("sfynx.core.cache_dir.media");
             PiFileManager::mkdirr($dossier, 0777);
             $this->container->get("sfynx.cache.filecache")->getClient()->setPath($dossier);
             $url_public_media = $this->container->get("sfynx.cache.filecache")->get($format . $pattern . $id . '_' . $timestamp);
             if (!$url_public_media) {
                 $url_public_media = $this->container->get('sonata.media.twig.extension')->path($id, $format) . "?v.{$timestamp}";
                 $this->container->get("sfynx.cache.filecache")->set($format . $pattern . $id . '_' . $timestamp, $url_public_media, 0);
             }
         }
     } catch (\Exception $e) {
         $url_public_media = "";
     }
     $src = $this->container->get('kernel')->getRootDir() . '/../web' . $url_public_media;
     if ((empty($url_public_media) || !file_exists($src)) && $format != 'reference') {
         return $this->getMediaUrlFunction($id, "reference", $cachable, $modifdate, $pattern);
     } else {
         return $url_public_media;
     }
 }
 /**
  * We set the path of the all failure login filecache.
  *
  * @return void
  * @author Etienne de Longeaux <*****@*****.**>
  */
 public function setCachePath()
 {
     // we create path
     $dossier = $this->container->getParameter("sfynx.auth.loginfailure.cache_dir");
     PiFileManager::mkdirr($dossier, 0777);
     $this->container->get("sfynx.cache.filecache")->getClient()->setPath($dossier);
 }
 /**
  * Save a content in the log file.
  *
  * @param integer $flag Flag value
  * @param octal   $mode mode file
  * 
  * @return mixed    return 0 if the file is save correctly, otherwise return the instance.
  * @access public
  * @author Etienne de Longeaux <*****@*****.**>
  */
 public function save($flag = FILE_APPEND, $mode = 0777)
 {
     if (\Sfynx\ToolBundle\Util\PiFileManager::mkdirr(dirname($this->_file), $mode)) {
         $result = file_put_contents($this->_file, PHP_EOL . implode("\n", $this->_info), $flag);
     } else {
         $result = false;
     }
     if ($result) {
         return $this;
     } else {
         return false;
     }
 }
 /**
  * Event handler that renders not found page
  * in case of a NotFoundHttpException
  *
  * @param GetResponseForExceptionEvent $event
  *
  * @access public
  * @return void
  * @author Riad Hellal <*****@*****.**>
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $this->request = $event->getRequest($event);
     // provide the better way to display a enhanced error page only in prod environment, if you want
     if (in_array($this->kernel->getEnvironment(), array('test', 'prod'))) {
         // exception object
         $exception = $event->getException();
         // new Response object
         $response = new Response();
         //$requestDuplicate = $this->request->duplicate(null, null, ['_controller' => 'MyAppSiteBundle:Default:exception']);
         //$response = $this->kernel->handle($requestDuplicate, HttpKernelInterface::SUB_REQUEST);
         if ($this->container->hasParameter('sfynx.auth.theme.layout.error.html') && $this->container->getParameter('sfynx.auth.theme.layout.error.html') != "") {
             $path_error_file = realpath($this->kernel->locateResource($this->container->getParameter('sfynx.auth.theme.layout.error.html')));
             $response->setContent(file_get_contents($path_error_file));
         } else {
             if ($this->container->hasParameter('sfynx.auth.theme.layout.error.route_name') && $this->container->getParameter('sfynx.auth.theme.layout.error.route_name') != "") {
                 $route_name = $this->container->getParameter('sfynx.auth.theme.layout.error.route_name');
             } else {
                 $route_name = 'error_404';
             }
             $url = $this->container->get('sfynx.tool.route.factory')->getRoute($route_name, array('locale' => $this->locale));
             $content = PiFileManager::getCurl('/' . $url, null, null, $this->request->getUriForPath(''));
             $response->setContent($content);
         }
         // HttpExceptionInterface is a special type of exception
         // that holds status code and header details
         if (method_exists($exception, "getStatusCode")) {
             $response->setStatusCode($exception->getStatusCode());
         } else {
             $response->setStatusCode('404');
         }
         if (method_exists($response, "getHeaders")) {
             $response->headers->replace($exception->getHeaders());
         }
         // set the new $response object to the $event
         $event->setResponse($response);
     }
 }
 /**
  * List of all countries.
  *
  * @link https://github.com/umpirsky/country-list/blob/master/country/cldr/en/country.php
  * @param string $locale
  * @access public
  * @return array
  * @static
  *
  * @author Etienne de Longeaux <*****@*****.**>
  */
 public static function allCountries($locale, $strtolowerKeys = true)
 {
     //         // we get the current directory.
     //         $path = realpath(dirname(__FILE__) . "/Countries/cldr");
     //         $all_files = \Sfynx\ToolBundle\Util\PiFileManager::ListFiles($path, "json");
     //         foreach($all_files as $key => $path_file){
     //             $dir_path_win     = explode('\\', realpath(dirname($path_file)));
     //             $dir_path_linux = explode('//', realpath(dirname($path_file)));
     //             $local_value_win     = end($dir_path_win);
     //             $local_value_linux = end($dir_path_linux);
     //             if ($local_value_win != realpath(dirname($path_file))){
     //                 $new_path = realpath(dirname(__FILE__)) . "/Countries/" . $local_value_win . "_country.json";
     //                 copy($path_file, $new_path);
     //                 print_r($local_value_win);
     //                 print_r("<br />");
     //             }
     //         }
     //         exit;
     // we get the current directory.
     $path = realpath(dirname(__FILE__) . "/Countries");
     // we create the file name.
     //$locale = strtolower($locale);
     $file = "{$locale}_country.json";
     // we take all json files existing.
     $all_files = \Sfynx\ToolBundle\Util\PiFileManager::getFilesByType($path, "json");
     //print_r(file_get_contents($path.'/'.$file));exit;
     //print_r(get_object_vars(json_decode(file_get_contents(realpath($path.'/'.$file)))));exit;
     // we return the country.jon content file if it's existed.
     if (in_array($file, $all_files)) {
         $all_countries = get_object_vars(json_decode(file_get_contents(realpath($path . '/' . $file))));
     } else {
         $all_countries = get_object_vars(json_decode(file_get_contents(realpath($path . '/en_country.json'))));
     }
     asort($all_countries);
     if ($strtolowerKeys) {
         $news_key = array_map(function ($key) {
             return (string) strtolower($key);
         }, array_keys($all_countries));
         return array_combine($news_key, array_values($all_countries));
     } else {
         return $all_countries;
     }
 }
 /**
  * Sets the SEO url valule if is a old url.
  *
  * @access protected
  * @return false|RedirectResponse
  * @author Etienne de Longeaux <*****@*****.**>
  */
 protected function isNoScope()
 {
     $locale = $this->request->getLocale();
     if ($this->is_scop_authorized && $this->container->has("sfynx.browser.lib.mobiledetect") && $this->container->has("sfynx.browser.lib.browscap")) {
         // we get the browser
         \Sfynx\ToolBundle\Util\PiFileManager::mkdirr($this->browscap_cache_dir, 0777);
         if ($this->request->attributes->has('sfynx-browser')) {
             $this->browser = $this->request->attributes->get('sfynx-browser');
         } else {
             $this->browser = $this->container->get("sfynx.browser.lib.browscap")->getBrowser();
         }
         if ($this->request->attributes->has('sfynx-mobiledetect')) {
             $this->mobiledetect = $this->request->attributes->get('sfynx-mobiledetect');
         } else {
             $this->mobiledetect = $this->container->get("sfynx.browser.lib.mobiledetect");
         }
         // we set globals information
         $globals = $this->scop_globals;
         $nav_desktop = strtolower($this->browser->Browser);
         $nav_mobile = strtolower($this->browser->Platform);
         $isNoScope = false;
         if (!$this->browser->isMobileDevice && (!isset($globals["navigator"][$nav_desktop]) || floatval($this->browser->Version) <= $globals["navigator"][$nav_desktop])) {
             $isNoScope = true;
         } elseif ($this->browser->isMobileDevice && !$this->mobiledetect->isTablet() && (!isset($globals["mobile"][$nav_mobile]) || floatval($this->browser->Platform_Version) <= $globals["mobile"][$nav_mobile])) {
             $isNoScope = true;
         } elseif ($this->browser->isMobileDevice && $this->mobiledetect->isTablet() && (!isset($globals["tablet"][$nav_mobile]) || floatval($this->browser->Platform_Version) <= $globals["tablet"][$nav_mobile])) {
             $isNoScope = true;
         }
         if ($this->browser->Version == 0.0 || $this->browser->Platform_Version == 0.0) {
             $isNoScope = false;
         }
         if ($isNoScope) {
             if (!$this->browser->isMobileDevice) {
                 if (isset($globals["navigator"][$nav_desktop]) && floatval($this->browser->Version) <= $globals["navigator"][$nav_desktop]) {
                     $isNav = false;
                 } else {
                     $isNav = true;
                 }
             } elseif ($bc->getBrowser()->isMobileDevice) {
                 if (isset($globals["navigator"][$nav_mobile]) && floatval($this->browser->Platform_Version) <= $globals["navigator"][$nav_mobile]) {
                     $isNav = false;
                 } else {
                     $isNav = true;
                 }
             }
             $isCookies = $this->browser->Cookies;
             $isJs = $this->browser->JavaScript;
             // we set response
             $response = new \Symfony\Component\HttpFoundation\Response($this->request->getUri());
             $response->headers->set('Content-Type', 'text/html');
             $response = $this->container->get('templating')->renderResponse('SfynxTemplateBundle:Template\\Nonav:nonav.html.twig', array('locale' => $locale, 'isCookies' => $isCookies, 'isJs' => $isJs, 'isNav' => $isNav), $response);
             // we apply all events allowed to change the response
             $event_response = new ResponseEvent($response, $this->date_expire);
             $this->container->get('event_dispatcher')->dispatch(SfynxCmfEvents::HANDLER_REQUEST_CHANGERESPONSE_NOSCOPE, $event_response);
             $response = $event_response->getResponse();
             return $response;
         }
     }
     return false;
 }
 /**
  * Executes the compression command in shell
  *
  * @param string $result            ['path', 'content']
  * @param string $compressor        ['yui', 'php_js', 'php_css']
  *
  * @return string    file path result
  * @access public
  *
  * @author Etienne de Longeaux <*****@*****.**>
  */
 private function compress($result = "path", $compressor = "yui")
 {
     // we get the value of css_js_cache_file param
     $is_refresh_css_js_cache_file = $this->container->getParameter("pi_app_admin.page.refresh.css_js_cache_file");
     // we create csss and js repository if does not exist
     \Sfynx\ToolBundle\Util\PiFileManager::mkdirr($this->container->getParameter("kernel.root_dir") . '/../web/yui/css', 0777);
     \Sfynx\ToolBundle\Util\PiFileManager::mkdirr($this->container->getParameter("kernel.root_dir") . '/../web/yui/js', 0777);
     // create the input
     foreach ($this->files as $file) {
         $basePath = str_replace($this->container->getParameter("kernel.root_dir") . '/../web/', '', dirname($file));
         if (strtolower($this->options['type']) == "css") {
             $content_file = str_replace(array('url("', "url('", "')", '")'), array('url(', 'url(', ')', ')'), file_get_contents($file));
             $content_file = str_replace(array('url('), array('url(../../' . $basePath . '/'), $content_file);
             $content_file = str_replace('@import "', "   @import \"../../" . $basePath . "/", $content_file);
             $content_file = str_replace('";', '";   ', $content_file);
             $this->string .= $content_file;
         } else {
             $this->string .= file_get_contents($file);
         }
     }
     if (preg_match_all('/@import "([^`]*?)";/i', $this->string, $allImports, PREG_SET_ORDER)) {
         $this->string = preg_replace_callback('/@import "([^`]*?)";/i', function ($matches) {
             return "";
         }, $this->string);
         foreach ($allImports as $k => $import) {
             $this->string = $import[0] . "  " . $this->string;
         }
     }
     // create single file from all input
     $input_hash = sha1($this->string);
     // create path file
     $nameFile = strtolower($this->options['type']) . '/' . $input_hash . '.' . strtolower($this->options['type']);
     $file = $this->TEMP_FILES_DIR . '/' . $nameFile;
     // we compress the content
     if ($is_refresh_css_js_cache_file && !file_exists($file) && $this->container->get('sfynx.tool.file_manager')->save($file, $this->string, 0777)) {
         switch (true) {
             case $compressor == "yui":
                 // start with basic command
                 $cmd = "java -Xmx32m -jar " . escapeshellarg($this->JAR_PATH) . ' ' . escapeshellarg($file) . " --charset UTF-8";
                 // set the file type
                 $cmd .= " --type " . (strtolower($this->options['type']) == "css" ? "css" : "js");
                 // and add options as needed
                 if ($this->options['linebreak'] && intval($this->options['linebreak']) > 0) {
                     $cmd .= ' --line-break ' . intval($this->options['linebreak']);
                 }
                 if ($this->options['verbose']) {
                     $cmd .= " -v";
                 }
                 if ($this->options['nomunge']) {
                     $cmd .= ' --nomunge';
                 }
                 if ($this->options['semi']) {
                     $cmd .= ' --preserve-semi';
                 }
                 if ($this->options['nooptimize']) {
                     $cmd .= ' --disable-optimizations';
                 }
                 // execute the command
                 exec($cmd . ' 2>&1', $raw_output);
                 // add line breaks to show errors in an intelligible manner
                 $flattened_output = implode("\n", $raw_output);
                 // we put the compressor content in the file.
                 file_put_contents($file, $flattened_output);
                 break;
             case $compressor == "php_js":
                 $flattened_output = str_replace("/*\n", "\n\n /*\n", $this->string);
                 $flattened_output = str_replace("/*!\n", "\n\n /*!\n", $flattened_output);
                 // we put the compressor content in the file.
                 file_put_contents($file, $flattened_output);
                 break;
             case $compressor == "php_css":
                 // Remove comments
                 $flattened_output = $this->container->get('sfynx.tool.string_manager')->remove_comment_in_css_file($this->string);
                 // Remove space after colons
                 $flattened_output = str_replace(': ', ':', $flattened_output);
                 // Remove whitespace
                 $flattened_output = $this->container->get('sfynx.tool.string_manager')->cleanWhitespace($flattened_output);
                 // we put the compressor content in the file.
                 file_put_contents($file, $flattened_output);
                 break;
             default:
                 // use default
                 break;
         }
     }
     // we initialize the content.
     $this->string = "";
     // we return result
     switch (true) {
         case $result == "content":
             if (file_exists($file)) {
                 return file_get_contents($file);
             } else {
                 return '';
             }
         case $result == "path":
             return $input_hash;
         default:
             return "";
     }
 }
Example #11
0
 /**
  * Create the repository of the cache widget files
  *
  * @return string   path value
  * @access public
  * @author Etienne de Longeaux <*****@*****.**>
  * @since  2014-06-21
  */
 public function createCacheWidgetRepository()
 {
     $path = $this->container->getParameter("pi_app_admin.cache_dir.widget");
     PiFileManager::mkdirr($path, 0777);
     return $path;
 }
Example #12
0
 /**
  * Delete the cache of all elements of an entity (Page, TranslationPages, widgets)
  *
  * @param object $entity Page or TranslationPage entity
  * @param string $type   ['persist', 'update', 'remove']
  * 
  * @return string
  * @access public
  * @author Etienne de Longeaux <*****@*****.**>
  * @since  2014-06-07
  */
 public function cachePage($entity, $type)
 {
     if ($entity instanceof TranslationPage) {
         $entity = $entity->getPage();
     }
     if ($entity instanceof Page) {
         $path_page_json_file = $this->createJsonFileName('page-json', $entity->getRouteName());
         if (in_array($type, array('persist', 'update'))) {
             $reports = serialize($entity);
             $result = \Sfynx\ToolBundle\Util\PiFileManager::save($path_page_json_file, $reports, 0777, LOCK_EX);
         } elseif ($type == 'remove') {
             if (file_exists($path_page_json_file)) {
                 unlink($path_page_json_file);
             }
         }
     }
 }
 /**
  * Sets the specific sortOrders.
  * 
  * @param string $domain    The domain
  * @param string $extension The extension name
  * 
  * @return void
  * @access public
  */
 public function createTranslationFiles($domain = "messages", $extension = "yml")
 {
     $foundBundle = $this->container->get('kernel')->getBundle('SfynxTranslatorBundle');
     $basePath = $foundBundle->getPath() . "/Resources/translations/";
     $transfiles = PiFileManager::GlobFiles($basePath . '*.' . $extension);
     // more fast in linux but not in windows
     $dir = PiFileManager::mkdirr($basePath);
     if (count($transfiles) == 0) {
         $all_locales = $this->container->get('sfynx.auth.locale_manager')->getAllLocales();
         foreach ($all_locales as $key => $lang) {
             $filename = $basePath . $domain . "." . $lang . "." . $extension;
             @file_put_contents($filename, '', LOCK_EX);
         }
     }
 }
 /**
  * Sets the the path where will be write the backup file.
  * 
  * @param array $options
  * @return void
  * @access protected
  *
  * @author Etienne de Longeaux <*****@*****.**>
  * @since 2012-02-03
  */
 protected function setPath(array $options = null)
 {
     if (isset($options['path']) && !empty($options['path'])) {
         $path = $options['path'];
     } else {
         $path = $this->getContainer()->get('kernel')->getRootDir() . '\\cache\\Backup';
     }
     if (isset($options['filename']) && !empty($options['filename'])) {
         $filename = '/' . $options['filename'];
     } else {
         $filename = '/doctrine_backup_database-' . $this->getDatabase() . '_' . date('Y-m-d-H-i-s') . '.sql';
     }
     if (\Sfynx\ToolBundle\Util\PiFileManager::mkdirr($path, 0777)) {
         $this->path = realpath($path);
         $this->path = $this->path . $filename;
     }
 }
 /**
  * Put result content in cache with ttl.
  *
  * @author Etienne de Longeaux <*****@*****.**>
  */
 protected function setCacheFunction($key, $ttl, $newvalue)
 {
     $dossier = $this->container->getParameter("kernel.root_dir") . "/cache/widget/";
     \Sfynx\ToolBundle\Util\PiFileManager::mkdirr($dossier, 0777);
     $this->container->get("sfynx.cache.filecache")->getClient()->setPath($dossier);
     // important : if ttl is equal to zero then the cache is infini
     $this->container->get("sfynx.cache.filecache")->set($key, $newvalue, $ttl);
 }
 /**
  * Invoked to modify the controller that should be executed.
  *
  * @param GetResponseEvent $event The event
  * 
  * @access public
  * @return void
  * @author Etienne de Longeaux <*****@*****.**>
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
         // ne rien faire si ce n'est pas la requête principale
         return;
     }
     // Set request
     $this->request = $event->getRequest($event);
     // Sets parameter template values.
     $this->setParams();
     //
     if ($this->request->cookies->has('sfynx-layout')) {
         $this->layout = $this->request->cookies->get('sfynx-layout');
     } else {
         $this->layout = $this->container->getParameter('sfynx.auth.theme.layout.front.pc') . $this->init_pc_layout;
     }
     if ($this->request->cookies->has('sfynx-screen')) {
         $this->screen = $this->request->cookies->get('sfynx-screen');
     } else {
         $this->screen = "layout";
     }
     if ($this->is_browser_authorized && !$this->request->cookies->has('sfynx-layout') && $this->container->has("sfynx.browser.lib.mobiledetect") && $this->container->has("sfynx.browser.lib.browscap")) {
         // we get the browser
         PiFileManager::mkdirr($this->browscap_cache_dir, 0777);
         if ($this->request->attributes->has('sfynx-browser')) {
             $this->browser = $this->request->attributes->get('sfynx-browser');
         } else {
             $this->browser = $this->container->get("sfynx.browser.lib.browscap")->getBrowser();
         }
         if ($this->request->attributes->has('sfynx-mobiledetect')) {
             $this->mobiledetect = $this->request->attributes->get('sfynx-mobiledetect');
         } else {
             $this->mobiledetect = $this->container->get("sfynx.browser.lib.mobiledetect");
         }
         //
         $this->request->attributes->set('sfynx-browser', $this->browser);
         $this->request->attributes->set('sfynx-mobiledetect', $this->mobiledetect);
         //
         if ($this->browser->isMobileDevice) {
             if (!$this->mobiledetect->isTablet()) {
                 $this->screen = "layout-poor";
             } elseif ($this->mobiledetect->isTablet()) {
                 $this->screen = "layout-medium";
             } else {
                 $this->screen = 'layout-medium';
             }
             $this->layout = $this->container->getParameter('sfynx.auth.theme.layout.front.mobile') . $this->init_mobile_layout . '\\' . $this->screen . '.html.twig';
             $this->request->setRequestFormat('mobile');
         }
     }
     // we add sfynx-layout and sfynx-screen info in the request
     $this->request->attributes->set('sfynx-layout', $this->layout);
     $this->request->attributes->set('sfynx-screen', $this->screen);
 }
 /**
  * upload attached files
  *
  * @param void|array $files The files value
  *
  * @access public
  * @return array
  * @author Etienne de Longeaux <*****@*****.**>
  */
 public function uploadAttached($files = array())
 {
     $list_files = array();
     $dir = $this->container->get('kernel')->getRootDir() . '/../web/uploads/attachements/';
     \Sfynx\ToolBundle\Util\PiFileManager::mkdirr($dir);
     foreach ($files as $inputname => $file) {
         $list_files[$inputname] = $dir . $file['name'];
         move_uploaded_file($file['tmp_name'], $list_files[$inputname]);
         $this->files[] = $dir . $file['name'];
     }
     return $list_files;
 }