/** * string to slug, friendly, readable url * @param string $source example: báo Dân Trí Việt Nam * @return string example: bao-dan-tri-viet-nam */ function str_to_slug($source) { return \Cake\Utility\Inflector::slug(str_unsign_unicode($source)); }
/** * Rename directory * * @param string $old_path Directory to rename * @param string $name New directory name * @param bool $transliteration * * @return bool */ function rename_folder($old_path, $name, $transliteration) { $name = str_unsign_unicode($name); $name = fix_filename($name, $transliteration, false, '_', true); if (file_exists($old_path)) { $new_path = fix_dirname($old_path) . "/" . $name; if (file_exists($new_path) && $old_path == $new_path) { return false; } return rename($old_path, $new_path); } }
} $base_dir = $paths . substr_replace($info['dirname'] . "/", '', 0, strlen($current_path)); if (file_exists($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'])) { rename_file($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'], $fixed_image_creation_name_to_prepend[$k] . $name . $fixed_image_creation_to_append[$k], $transliteration); } } } } else { response(trans('Empty_name') . AddErrorLocation())->send(); exit; } } break; case 'duplicate_file': if ($duplicate_files) { $name = str_unsign_unicode($name); $name = fix_filename($name, $transliteration, $convert_spaces, $replace_with); if (!empty($name)) { if (!checkresultingsize(filesize($path))) { response(sprintf(trans('max_size_reached'), $MaxSizeTotal) . AddErrorLocation())->send(); exit; } if (!duplicate_file($path, $name)) { response(trans('Rename_existing_file') . AddErrorLocation())->send(); exit; } duplicate_file($path_thumb, $name); if ($fixed_image_creation) { $info = pathinfo($path); foreach ($fixed_path_from_filemanager as $k => $paths) { if ($paths != "" && $paths[strlen($paths) - 1] != "/") {