Exemple #1
0
 public function testOembed()
 {
     $replacements = ['https://www.youtube.com/watch?v=5omxorBHiv8' => '<iframe width="459" height="344" src="https://www.youtube.com/embed/5omxorBHiv8?feature=oembed" frameborder="0" allowfullscreen></iframe>', 'https://youtu.be/5omxorBHiv8' => '<iframe width="459" height="344" src="https://www.youtube.com/embed/5omxorBHiv8?feature=oembed" frameborder="0" allowfullscreen></iframe>', '<a href="https://youtu.be/5omxorBHiv8">https://youtu.be/5omxorBHiv8</a>' => '<a href="https://youtu.be/5omxorBHiv8">https://youtu.be/5omxorBHiv8</a>'];
     foreach ($replacements as $original => $after) {
         $this->AssertEquals($after, Str::OEmbed($original));
     }
 }
Exemple #2
0
 public function setTextAttribute($text)
 {
     $text = str_replace('&nbsp;', ' ', $text);
     if ($this->slotname === 'standfirst') {
         $siteText = $text = strip_tags($text);
     } else {
         $text = Str::makeInternalLinksRelative($text);
         $siteText = Str::StorifyEmbed(Str::OEmbed($text));
     }
     $this->attributes['text'] = $text;
     $this->attributes['site_text'] = $siteText;
 }
 public function handle(PageEvent $event)
 {
     $page = $event->getPage();
     $title = $event->getNewTitle();
     if ($title !== Page::DEFAULT_TITLE && empty($page->getInternalName())) {
         $slug = Str::slug($title);
         $unique = Str::unique($slug, function ($name) {
             return PageFacade::internalNameExists($name) === false;
         });
         $page->setInternalName($unique);
         PageFacade::save($page);
     }
 }
Exemple #4
0
 public function getReadableFilesizeAttribute()
 {
     return Str::filesize($this->getFilesize());
 }
Exemple #5
0
 /**
  * Increments a numeric suffix until the URL is unique.
  *
  * @param string $url
  *
  * @return string
  */
 public static function makeUnique($url)
 {
     return Str::unique($url, function ($url) {
         return URLFacade::isAvailable($url);
     });
 }
Exemple #6
0
 public function createTemplateWithFilename($theme, $filename)
 {
     $this->repository->create(['name' => Str::filenameToTitle($filename), 'theme' => $theme, 'filename' => $filename]);
 }