Example #1
0
 public function addLangVars($lang = null)
 {
     $views = Config::get('settings', 'modules');
     foreach ($views as $view) {
         $dir = explode('/', $view);
         $lang_dir = 'app/' . $dir[0] . '/lang';
         $di = new Dirs();
         if (is_dir($lang_dir) && !$di->isEmptyDirectory($lang_dir)) {
             if (is_file($lang_dir . '/' . $lang . '.php')) {
                 $vars = (require_once $lang_dir . '/' . $lang . '.php');
             } elseif (is_file($lang_dir . '/' . $this->config['default_lang'] . '.php')) {
                 $vars = (require_once $lang_dir . '/' . $this->config['default_lang'] . '.php');
             } else {
                 $files = $di->getFiles();
                 $vars = (require_once $lang_dir . '/' . $files[0]);
             }
             $this->lang_var = array_merge($this->lang_var, $vars);
         }
     }
 }
Example #2
0
 private function check($file)
 {
     $dirs = new Dirs();
     $dirs->setPath($_SERVER['DOCUMENT_ROOT'] . '/' . $this->config['upload_dir']);
     $files = $dirs->getFiles();
     if ($files) {
         $i = 0;
         $newName = $file;
         $arrayNameFiles = array();
         preg_match("#([\\w()-_]+)\\.([\\w]{1,4})#i", $file, $arrayNameFiles);
         $nameStart = $arrayNameFiles[1];
         $nameEnd = $arrayNameFiles[2];
         while (in_array($newName, $files)) {
             $newName = "{$nameStart}" . "{$i}.{$nameEnd}";
             $i++;
         }
         return $newName;
     } else {
         return $file;
     }
 }