mambax7 /
extgallery
| 1 | <?php namespace XoopsModules\Extgallery; |
||
| 2 | |||
| 3 | /** |
||
| 4 | * Class MytsGallery |
||
| 5 | */ |
||
| 6 | class MytsGallery extends \MyTextSanitizerExtension |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * @param string $textarea_id |
||
| 10 | * @return array |
||
| 11 | */ |
||
| 12 | public function encode($textarea_id) |
||
| 13 | { |
||
| 14 | xoops_loadLanguage('extention', 'extgallery'); |
||
| 15 | |||
| 16 | /* $code = "<img src='" |
||
| 17 | . XOOPS_URL |
||
| 18 | . "/modules/extgallery/assets/images/extgallery-posticon.gif' alt='" |
||
| 19 | . _EXT_EXTGALLERY_ALTWMP |
||
| 20 | . "' onclick='xoopsCodeGallery(\"{$textarea_id}\", \"" |
||
| 21 | . _EXT_EXTGALLERY_TEXTID |
||
| 22 | . '", "' |
||
| 23 | . _EXT_EXTGALLERY_TEXTTITLE |
||
| 24 | . "\");' onmouseover='style.cursor=\"hand\"'> "; */ |
||
| 25 | $code = "<button type='button' class='btn btn-default' onclick='xoopsCodeGallery(\"{$textarea_id}\",\"" . _EXT_EXTGALLERY_TEXTID .'", "'. _EXT_EXTGALLERY_TEXTTITLE. "\");' onmouseover='style.cursor=\"hand\"' title='" . _EXT_EXTGALLERY_ALTWMP . "'><span class='fa fa-file-image-o' aria-hidden='true'></span><span style='font-size:75%;'> Gallery</span></button>"; |
||
| 26 | $javascript = <<<EOH |
||
| 27 | function xoopsCodeGallery(id, textId, photoTitle) { |
||
| 28 | var selection = xoopsGetSelect(id); |
||
| 29 | if (selection.length > 0) { |
||
| 30 | var text = selection; |
||
| 31 | } else { |
||
| 32 | var text = prompt(textId, ""); |
||
| 33 | } |
||
| 34 | if(text == null) { |
||
| 35 | return false; |
||
| 36 | } |
||
| 37 | var domobj = xoopsGetElementById(id); |
||
| 38 | if ( text.length > 0 ) { |
||
| 39 | if(isNaN(text)) { |
||
| 40 | return false; |
||
| 41 | } |
||
| 42 | var title = prompt(photoTitle, ""); |
||
| 43 | if(text != null && title.length > 0) { |
||
| 44 | title = " title='" + title + "'"; |
||
| 45 | } else { |
||
| 46 | title = ""; |
||
| 47 | } |
||
| 48 | var result = "[gallery" + title + "]" + parseInt(text,10) + "[/gallery]"; |
||
| 49 | xoopsInsertText(domobj, result); |
||
| 50 | } |
||
| 51 | domobj.focus(); |
||
| 52 | } |
||
| 53 | EOH; |
||
| 54 | |||
| 55 | return [$code, $javascript]; |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param $ts |
||
| 60 | */ |
||
| 61 | public function load($ts) |
||
| 62 | { |
||
| 63 | $ts->patterns[] = "/\[gallery]([0-9]*)\[\/gallery\]/sU"; |
||
| 64 | $ts->replacements[] = '<a href="' . XOOPS_URL . '/modules/extgallery/hook-photo.php?id=\\1" rel="lightbox" target="_blank"><img src="' . XOOPS_URL . '/modules/extgallery/hook-thumb.php?id=\\1" alt="" ></a>'; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 65 | |||
| 66 | $ts->patterns[] = "/\[gallery title=(['\"]?)([ a-zA-Z0-9]*)\\1]([0-9]*)\[\/gallery\]/sU"; |
||
| 67 | $ts->replacements[] = '<a href="' . XOOPS_URL . '/modules/extgallery/hook-photo.php?id=\\3" rel="lightbox" title="\\2" alt="\\2" target="_blank"><img src="' . XOOPS_URL . '/modules/extgallery/hook-thumb.php?id=\\3" alt="\\2" title="\\2" ></a>'; |
||
| 68 | |||
| 69 | $ts->patterns[] = "/\[gallery group=(['\"]?)([a-zA-Z0-9]*)\\1]([0-9]*)\[\/gallery\]/sU"; |
||
| 70 | $ts->replacements[] = '<a href="' . XOOPS_URL . '/modules/extgallery/hook-photo.php?id=\\3" rel="lightbox[\\2]" target="_blank"><img src="' . XOOPS_URL . '/modules/extgallery/hook-thumb.php?id=\\3" alt="" ></a>'; |
||
| 71 | |||
| 72 | $ts->patterns[] = "/\[gallery group=(['\"]?)([a-zA-Z0-9]*)\\1 title=(['\"]?)([ a-zA-Z0-9]*)\\3]([0-9]*)\[\/gallery\]/sU"; |
||
| 73 | $ts->replacements[] = '<a href="' . XOOPS_URL . '/modules/extgallery/hook-photo.php?id=\\5" rel="lightbox[\\2]" title="\\4" alt="\\4" target="_blank"><img src="' . XOOPS_URL . '/modules/extgallery/hook-thumb.php?id=\\5" title="\\4" alt="\\4" ></a>'; |
||
| 74 | |||
| 75 | $ts->patterns[] = "/\[gallery title=(['\"]?)([ a-zA-Z0-9]*)\\1 group=(['\"]?)([a-zA-Z0-9]*)\\3]([0-9]*)\[\/gallery\]/sU"; |
||
| 76 | $ts->replacements[] = '<a href="' . XOOPS_URL . '/modules/extgallery/hook-photo.php?id=\\5" rel="lightbox[\\4]" title="\\2" alt="\\2" target="_blank"><img src="' . XOOPS_URL . '/modules/extgallery/hook-thumb.php?id=\\5" title="\\2" alt="\\2" ></a>'; |
||
| 77 | } |
||
| 78 | } |
||
| 79 |