Completed
Push — master ( 047d50...4f5633 )
by Michael
02:19
created

MytsGallery::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 1
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
1
<?php namespace XoopsModules\Extgallery;
2
3
/**
4
 * Class MytsGallery
5
 */
6
class MytsGallery extends \MyTextSanitizerExtension
0 ignored issues
show
Bug introduced by
The type MyTextSanitizerExtension was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
{
8
    /**
9
     * @param string $textarea_id
10
     * @return array
11
     */
12
    public function encode($textarea_id)
13
    {
14
        xoops_loadLanguage('extention', 'extgallery');
0 ignored issues
show
Bug introduced by
The function xoops_loadLanguage was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
        /** @scrutinizer ignore-call */ 
15
        xoops_loadLanguage('extention', 'extgallery');
Loading history...
15
16
        /*   $code       = "<img src='"
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
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\"'>&nbsp;"; */
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
The constant XoopsModules\Extgallery\XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
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