public function action($parent) { $c = $parent->config; $name = $parent->name; $path = $parent->path; $path_thumb = $parent->path_thumb; $util = new Utility(); if ($c['rename_folders']) { $name = $util->fix_filename($name, $c['transliteration'], $c['convert_spaces'], $c['replace_with']); $name = str_replace('.', '', $name); var_dump($name); if (!empty($name)) { if (!$util->rename_folder($path, $name, $c['transliteration'], $c['convert_spaces'])) { $this->r = array('The folder already exists', 403); return; } $util->rename_folder($path_thumb, $name, $c['transliteration'], $c['convert_spaces']); if ($c['fixed_image_creation']) { foreach ($fixed_path_from_filemanager as $k => $paths) { if ($paths != "" && $paths[strlen($paths) - 1] != "/") { $paths .= "/"; } $base_dir = $paths . substr_replace($path, '', 0, strlen($current_path)); $util->rename_folder($c['base_dir'], $name, $c['transliteration'], $c['convert_spaces']); } } $this->r = array('success', 200); return; } else { $this->r = array('The name is empty', 400); return; } } else { $this->r = array('errror: not allowed to rename folders', 400); return; } }
public function render_need_name($app, $files, $twigArr, $config, $subdir, $filter, $transliteration, $thumbs_path, $get_params, $rfm_subfolder) { //need to pass in rest of required variables. $jplayer_ext = array("mp4", "flv", "webmv", "webma", "webm", "m4a", "m4v", "ogv", "oga", "mp3", "midi", "mid", "ogg", "wav"); $html = ""; $util = new Utility(); foreach ($files as $file_array) { $file = $file_array['file']; if ($file == '.' || isset($file_array['extension']) && $file_array['extension'] != 'dir' || $file == '..' && $subdir == '' || in_array($file, $config['hidden_folders']) || $filter != '' && $n_files > $file_number_limit_js && $file != ".." && stripos($file, $filter) === false) { continue; } $new_name = $util->fix_filename($file, $transliteration); if ($file != '..' && $file != $new_name) { //rename $util->rename_folder($config['current_path'] . $subdir . $file, $new_name, $transliteration); $file = $new_name; } //add in thumbs folder if not exist if (!file_exists($thumbs_path . $subdir . $file)) { $util->create_folder(false, $thumbs_path . $subdir . $file); } $class_ext = 3; if ($file == '..' && trim($subdir) != '') { $src = explode("/", $subdir); unset($src[count($src) - 2]); $src = implode("/", $src); //if($src=='') $src="/"; if ($src == '') { $src = ""; } } elseif ($file != '..') { $src = $subdir . $file . "/"; } $twigArr['file'] = $file; $template = null; //template specifics $attr = array('folder_link' => "filemanager?" . $get_params . rawurlencode($src) . "&" . uniqid()); if ($file == '..') { $attr['path'] = str_replace('.', '', dirname($rfm_subfolder . $subdir)); $attr['path_thumb'] = dirname($thumbs_path . $subdir) . "/"; $template = 'FileManager/need_name/back.html.twig'; } else { $template = 'FileManager/need_name/folder.html.twig'; } $twigArr['file_prevent_rename'] = false; $twigArr['file_prevent_delete'] = false; if (isset($filePermissions[$file])) { $twigArr['file_prevent_rename'] = isset($filePermissions[$file]['prevent_rename']) && $filePermissions[$file]['prevent_rename']; $twigArr['file_prevent_delete'] = isset($filePermissions[$file]['prevent_delete']) && $filePermissions[$file]['prevent_delete']; } $twigArr['file_array'] = $file_array; $twigArr['temp_attr'] = $attr; $html = $html . $app['twig']->render($template, $twigArr); } $this->two = $this->two($app, $files, $twigArr, $config, $subdir, $filter, $transliteration, $thumbs_path, $get_params, $util, $rfm_subfolder); return $html; }