-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
87 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Darkle\Fancybox; | ||
|
||
use s9e\TextFormatter\Configurator; | ||
|
||
class DefineGalleryTemplate | ||
{ | ||
public function __invoke(Configurator $config) | ||
{ | ||
$tag = $config->tags->add('IMG-GALLERY'); | ||
$tag->template = <<<XML | ||
<div class="f-carousel" data-fancybox="gallery"> | ||
<div class="f-carousel__track"> | ||
<xsl:apply-templates/> | ||
</div> | ||
</div> | ||
XML; | ||
|
||
$tag = $config->tags->add('IMG-GALLERY-ITEM'); | ||
$tag->template = <<<XML | ||
<div class="f-carousel__slide"> | ||
<xsl:apply-templates/> | ||
</div> | ||
XML; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Darkle\Fancybox; | ||
|
||
use s9e\TextFormatter\Renderer; | ||
use s9e\TextFormatter\Utils; | ||
|
||
class WrapImagesInGallery | ||
{ | ||
const MATCH_IMG_TAGS = '((?:<UPL-IMAGE-PREVIEW[^>]*>(?:(?!<\/UPL-IMAGE-PREVIEW>).)*<\/UPL-IMAGE-PREVIEW>)|(?:<IMG[^>]*>(?:(?!<\/IMG>).)*<\/IMG>))'; | ||
const MATCH_GALLERY_REGEX = '((?:'.self::MATCH_IMG_TAGS.'(?:\n|<br\/>)*){2,})'; | ||
|
||
public function __invoke(Renderer $renderer, $context, string $xml): string | ||
{ | ||
return preg_replace_callback('/'.self::MATCH_GALLERY_REGEX.'/m', function ($matches) { | ||
$m = preg_replace('/'.self::MATCH_IMG_TAGS.'/m', '<IMG-GALLERY-ITEM>$1</IMG-GALLERY-ITEM>', $matches[0]); | ||
|
||
return '<IMG-GALLERY>' . str_replace('<br/>', '', $m) . '</IMG-GALLERY>'; | ||
}, $xml); | ||
} | ||
} |