forked from friendica/friendica-addons
Code style
This commit is contained in:
parent
1a5b19ff69
commit
537ee2e656
|
@ -21,26 +21,17 @@ function fancybox_head(App $a, string &$b)
|
||||||
{
|
{
|
||||||
DI::page()->registerStylesheet(__DIR__ . '/asset/fancybox/jquery.fancybox.min.css');
|
DI::page()->registerStylesheet(__DIR__ . '/asset/fancybox/jquery.fancybox.min.css');
|
||||||
}
|
}
|
||||||
|
|
||||||
function fancybox_footer(App $a, string &$str)
|
function fancybox_footer(App $a, string &$str)
|
||||||
{
|
{
|
||||||
DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/jquery.fancybox.min.js');
|
DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/jquery.fancybox.min.js');
|
||||||
DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/fancybox.config.js');
|
DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/fancybox.config.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
function fancybox_render(App $a, array &$b)
|
||||||
|
{
|
||||||
prepare_body_final
|
|
||||||
|
|
||||||
Called at the end of prepare_body(). Hook data:
|
|
||||||
|
|
||||||
item: item array (input)
|
|
||||||
html: converted item body (input/output)
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
function fancybox_render(App $a, array &$b) {
|
|
||||||
$matches = [];
|
$matches = [];
|
||||||
$pattern='#<div class="body-attach">.*?</div>#s';
|
$pattern = '#<div class="body-attach">.*?</div>#s';
|
||||||
$gallery = 'gallery';
|
$gallery = 'gallery';
|
||||||
if (array_key_exists('item', $b)) {
|
if (array_key_exists('item', $b)) {
|
||||||
$item = $b['item'];
|
$item = $b['item'];
|
||||||
|
@ -50,11 +41,11 @@ function fancybox_render(App $a, array &$b) {
|
||||||
}
|
}
|
||||||
$html = $b['html'];
|
$html = $b['html'];
|
||||||
while (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {
|
while (preg_match($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) {
|
||||||
if (is_array($matches)) $matches=$matches[0];
|
if (is_array($matches)) $matches = $matches[0];
|
||||||
$part = $matches[0];
|
$part = $matches[0];
|
||||||
$replaced = str_replace('<a href', '<a data-fancybox="' . $gallery . '" href', $part);
|
$replaced = str_replace('<a href', '<a data-fancybox="' . $gallery . '" href', $part);
|
||||||
$replaced = str_replace('<div class="body-attach"', '<div class="body-attach done"', $replaced);
|
$replaced = str_replace('<div class="body-attach"', '<div class="body-attach done"', $replaced);
|
||||||
$html =str_replace($part, $replaced, $html);
|
$html = str_replace($part, $replaced, $html);
|
||||||
}
|
}
|
||||||
$html = str_replace('class="body-attach done"', 'class="body-attach"', $html);
|
$html = str_replace('class="body-attach done"', 'class="body-attach"', $html);
|
||||||
$b['html'] = $html;
|
$b['html'] = $html;
|
||||||
|
|
Loading…
Reference in a new issue