Beispiel #1
0
 public function fixValidations()
 {
     CmsPage::extend(function ($page) {
         $page->rules['url'] = ['required', 'regex:/^\\/[۰-۹آا-یa-z0-9\\/\\:_\\-\\*\\[\\]\\+\\?\\|\\.\\^\\\\$]*$/iu'];
     });
     //edit blog url validation rule
     if (PluginManager::instance()->exists('rainlab.blog')) {
         \RainLab\Blog\Models\Post::extend(function ($post) {
             $post->rules['slug'] = ['required', 'regex:/^[۰-۹آا-یa-z0-9\\/\\:_\\-\\*\\[\\]\\+\\?\\|]*$/iu', 'unique:rainlab_blog_posts'];
         });
     }
     //extending rainlab.pages
     if (PluginManager::instance()->exists('rainlab.pages')) {
         //edit rainlab page url validation rule
         \RainLab\Pages\Classes\Page::extend(function ($page) {
             $page->rules['url'] = ['required', 'regex:/^\\/[۰-۹آا-یa-z0-9\\/_\\-]*$/iu', 'uniqueUrl'];
         });
         //edit rainlab page filename in crating
         \RainLab\Pages\Classes\Page::creating(function ($page) {
             $page->fileName = \Str::ascii($page->fileName);
         }, -1);
     }
 }
Beispiel #2
0
 function shadow($text)
 {
     $text = Str::ascii($text);
     $text = Str::lower($text);
     return $text;
 }
Beispiel #3
0
 /**
  * Generate a URL friendly "slug".
  *
  * <code>
  *		// Returns "this-is-my-blog-post"
  *		$slug = URL::slug('This is my blog post!');
  *
  *		// Returns "this_is_my_blog_post"
  *		$slug = URL::slug('This is my blog post!', '_');
  * </code>
  *
  * @param  string  $title
  * @param  string  $separator
  * @return string
  */
 public static function slug($title, $separator = '-')
 {
     $title = Str::ascii($title);
     // Remove all characters that are not the separator, letters, numbers, or whitespace.
     $title = preg_replace('![^' . preg_quote($separator) . '\\pL\\pN\\s]+!u', '', Str::lower($title));
     // Replace all separator characters and whitespace by a single separator
     $title = preg_replace('![' . preg_quote($separator) . '\\s]+!u', $separator, $title);
     return trim($title, $separator);
 }
 public function getFilename()
 {
     $orig = parent::getFilename();
     $orig = str_replace('%', '', $orig);
     return Str::ascii($orig);
 }
Beispiel #5
0
 /**
  * Download the file by file id.
  *
  * @param  int  $id
  * @return Response
  */
 public function downloadByFileId($file_id)
 {
     //
     $file = DownloadFile::file($file_id);
     $real_path = storage_path() . $file->save_path;
     $headers = array('Content-Type:' . $file->type);
     // return $file->save_path;
     $realFile = $real_path . DIRECTORY_SEPARATOR . $file->save_name;
     $response = new Response();
     // return $response->download($realFile, $file->real_name, $headers);
     // echo iconv('UTF-8', 'ASCII', $realFile);
     $realFile = mb_convert_encoding($realFile, 'ASCII');
     // exit;
     // return response()->download(iconv('UTF-8', 'ASCII', $realFile), $file->real_name, $headers);
     return Response::download($realFile, $file->real_name, $headers);
     $response = new BinaryFileResponse($file, 200, $headers, true);
     if (is_null($name)) {
         $name = basename($file);
     }
     return $response->setContentDisposition($disposition, $name, Str::ascii($name));
 }