/var/www/hkosl.com/aga/wp-content/plugins/smart-slider-3/nextend/library/libraries/html/html.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
<?php

/**
 * Class N2Html
 */
class N2Html {

    public static 
$closeSingleTags true;
    
/**
     * @var boolean whether to render special attributes value. Defaults to true. Can be set to false for HTML5.
     * @since 1.1.13
     */
    
public static $renderSpecialAttributesValue true;


    
/**
     * Decodes special HTML entities back to the corresponding characters.
     * This is the opposite of {@link encode()}.
     *
     * @param string $text data to be decoded
     *
     * @return string the decoded data
     * @see   http://www.php.net/manual/en/function.htmlspecialchars-decode.php
     * @since 1.1.8
     */
    
public static function decode($text) {
        return 
htmlspecialchars_decode($textENT_QUOTES);
    }

    
/**
     * Generates an HTML element.
     *
     * @param string  $tag         the tag name
     * @param array   $htmlOptions the element attributes. The values will be HTML-encoded using {@link encode()}.
     *                             If an 'encode' attribute is given and its value is false,
     *                             the rest of the attribute values will NOT be HTML-encoded.
     *                             Since version 1.1.5, attributes whose value is null will not be rendered.
     * @param mixed   $content     the content to be enclosed between open and close element tags. It will not be HTML-encoded.
     *                             If false, it means there is no body content.
     * @param boolean $closeTag    whether to generate the close tag.
     *
     * @return string the generated HTML element tag
     */
    
public static function tag($tag$htmlOptions = array(), $content ""$closeTag true) {
        
$html '<' $tag self::renderAttributes($htmlOptions);
        if (
$content === false) return $closeTag && self::$closeSingleTags $html ' />' $html '>'; else
            return 
$closeTag $html '>' $content '</' $tag '>' $html '>' $content;
    }

    
/**
     * Generates an open HTML element.
     *
     * @param string $tag         the tag name
     * @param array  $htmlOptions the element attributes. The values will be HTML-encoded using {@link encode()}.
     *                            If an 'encode' attribute is given and its value is false,
     *                            the rest of the attribute values will NOT be HTML-encoded.
     *                            Since version 1.1.5, attributes whose value is null will not be rendered.
     *
     * @return string the generated HTML element tag
     */
    
public static function openTag($tag$htmlOptions = array()) {
        return 
'<' $tag self::renderAttributes($htmlOptions) . '>';
    }

    
/**
     * Generates a close HTML element.
     *
     * @param string $tag the tag name
     *
     * @return string the generated HTML element tag
     */
    
public static function closeTag($tag) {
        return 
'</' $tag '>';
    }

    
/**
     * Generates an image tag.
     *
     * @param string $src         the image URL
     * @param string $alt         the alternative text display
     * @param array  $htmlOptions additional HTML attributes (see {@link tag}).
     *
     * @return string the generated image tag
     */
    
public static function image($src$alt ''$htmlOptions = array()) {
        
$htmlOptions['src'] = $src;
        
$htmlOptions['alt'] = $alt;

        return 
self::tag('img'$htmlOptionsfalse);
    }

    
/**
     * Renders the HTML tag attributes.
     * Since version 1.1.5, attributes whose value is null will not be rendered.
     * Special attributes, such as 'checked', 'disabled', 'readonly', will be rendered
     * properly based on their corresponding boolean value.
     *
     * @param array $htmlOptions attributes to be rendered
     *
     * @return string the rendering result
     */
    
public static function renderAttributes($htmlOptions = array()) {
        static 
$specialAttributes = array(
            
'autofocus'          => 1,
            
'autoplay'           => 1,
            
'controls'           => 1,
            
'declare'            => 1,
            
'default'            => 1,
            
'disabled'           => 1,
            
'ismap'              => 1,
            
'loop'               => 1,
            
'muted'              => 1,
            
'playsinline'        => 1,
            
'webkit-playsinline' => 1,
            
'nohref'             => 1,
            
'noresize'           => 1,
            
'novalidate'         => 1,
            
'open'               => 1,
            
'reversed'           => 1,
            
'scoped'             => 1,
            
'seamless'           => 1,
            
'selected'           => 1,
            
'typemustmatch'      => 1,
            
'lazyload'           => 1,
        ), 
$specialAttributesNoValue = array(
            
'defer' => 1,
            
'async' => 1
        
);

        if (
$htmlOptions === array()) return '';

        
$html '';
        if (isset(
$htmlOptions['encode'])) {
            
$raw = !$htmlOptions['encode'];
            unset(
$htmlOptions['encode']);
        } else
            
$raw false;

        foreach (
$htmlOptions as $name => $value) {
            if (isset(
$specialAttributes[$name])) {
                if (
$value) {
                    
$html .= ' ' $name;
                    if (
self::$renderSpecialAttributesValue$html .= '="' $name '"';
                }
            } else if (isset(
$specialAttributesNoValue[$name])) {
                
$html .= ' ' $name;
            } else if (
$value !== null$html .= ' ' $name '="' . ($raw $value self::encode($value)) . '"';
        }

        return 
$html;
    }

    
/**
     * @param $text
     *
     * @return string
     */
    
public static function encode($text) {
        return 
htmlspecialchars($textENT_QUOTES'UTF-8');
    }

    public static function 
link($name$url$htmlOptions = array()) {
        
$htmlOptions["href"] = $url;
        
//$htmlOptions["encode"] = false;

        
$url self::openTag("a"$htmlOptions);
        if (isset(
$htmlOptions["encode"]) && $htmlOptions["encode"]) {
            
$url .= self::encode($name);
        } else {
            
$url .= $name;
        }

        
$url .= self::closeTag("a");

        return 
$url;
    }

    
/**
     * Insert stylesheet
     *
     * @param string $script
     * @param bool   $file
     * @param array  $scriptOptions
     *
     * @return string
     */
    
public static function style($script$file false$scriptOptions = array()) {
        if (
$file) {
            
$options = array(
                
"rel"  => "stylesheet",
                
"type" => "text/css",
                
"href" => $script
            
);
            
$options array_merge($options$scriptOptions);

            return 
N2Html::tag('link'$optionsfalse);
        }

        return 
N2Html::tag("style"$scriptOptions + array(
                
"type" => "text/css"
            
), $script);
    }

    
/**
     * Insert script
     *
     * @param string $script
     * @param bool   $file
     *
     * @return string
     */
    
public static function script($script$file false) {
        if (
$file) {
            return 
N2Html::tag('script', array(
                    
'type' => 'text/javascript',
                    
'src'  => $script
                
) + self::getScriptAttributes(), '');
        }

        return 
self::tag('script', array(
            
'type'   => 'text/javascript',
            
'encode' => false
        
), $script);
    }

    public static function 
scriptFile($script$attributes = array()) {
        return 
N2Html::tag('script', array(
                
'type' => 'text/javascript',
                
'src'  => $script
            
) + self::getScriptAttributes() + $attributes'');
    }

    public static function 
clear() {
        return 
self::tag("div", array("class" => "n2-clear"), "");
    }

    private static function 
getScriptAttributes() {
        static 
$attributes null;
        if (
$attributes === null) {
            if (
class_exists('N2Settings'false)) {
                
$value       trim(html_entity_decode(strip_tags(N2Settings::get('scriptattributes'''))));
                
$_attributes explode(' 'str_replace('\''""str_replace("\""""$value)));
                if (!empty(
$value) && !empty($_attributes)) {
                    foreach (
$_attributes AS $attr) {
                        if (
strpos($attr'=') !== false) {
                            
$atts explode("="$attr);
                            if (
count($atts) <= 2) {
                                
$attributes[$atts[0]] = $atts[1];
                            } else {
                                
$attributes[$attr] = $attr;
                            }
                        } else {
                            
$attributes[$attr] = $attr;
                        }
                    }
                } else {
                    
$attributes = array();
                }
            } else {
                return array();
            }
        }

        return 
$attributes;
    }

    public static function 
topBar($options = array()) {
        static 
$params = array(
            
'menu'         => array(),
            
'actions'      => array(),
            
'snapClass'    => 'n2-main-top-bar',
            
'fixTo'        => true,
            
'expert'       => true,
            
'notification' => true,
            
'hideSidebar'  => false,
            
'back'         => false,
            
'middle'       => ''
        
);

        
$options array_merge($params$options);

        if (!
$options['fixTo']) {
            
$options['snapClass'] = '';
        }

        if (!
is_array($options['actions'])) {
            
$options['actions'] = array();
        }
        if (!
N2Base::$currentApplicationType->app->hasExpertMode()) {
            
$options['expert'] = false;
        }

        
extract($options);
        include(
dirname(__FILE__) . '/fragments/topbar.phtml');

    }

    public static function 
definitionList($options = array()) {
        static 
$params = array(
            
'class' => 'n2-definition-list',
        );
        
$options array_merge($params$options);
        
extract($options);

        include(
dirname(__FILE__) . '/fragments/definitionlist.phtml');
    }

    public static function 
buttonMenu($options = array()) {
        static 
$params = array(
            
'content' => '',
        ), 
$init;

        
$options array_merge($params$options);
        
extract($options);

        include(
dirname(__FILE__) . '/fragments/buttonmenu.phtml');

        if (!
$init) {
            
N2JS::addInline('$(".n2-button-menu-open").n2opener();');
            
$init true;
        }
    }

    public static function 
ulList($options = array()) {
        static 
$params = array(
            
'ul' => array(
                
'htmlOptions' => '',
                
'orderable'   => false,
                
'link'        => '',
                
'iconclass'   => '',
                
'title'       => '',
                
'actions'     => array(),
                
'id'          => false
            
)
        );

        
$options array_merge($params$options);
        
extract($options);

        include(
dirname(__FILE__) . '/fragments/list.phtml');
    }

    public static function 
nav($options = array()) {
        static 
$params = array(
            
'logoUrl'      => false,
            
'logoImageUrl' => false,
            
'views'        => array(),
            
'actions'      => array()
        );

        
$options array_merge($params$options);
        
extract($options);

        include(
dirname(__FILE__) . '/fragments/nav.phtml');
    }

    private static function 
addClass(&$a$class) {
        if (empty(
$a['class'])) {
            
$a['class'] = '';
        }
        
$a['class'] .= ' ' $class;
    }

    public static function 
box($options = array()) {
        static 
$params = array(
            
'attributes'         => array(),
            
'center'             => null,
            
'centerAttributes'   => array(),
            
'lt'                 => null,
            
'rt'                 => null,
            
'lb'                 => null,
            
'rb'                 => null,
            
'ltAttributes'       => array(),
            
'rtAttributes'       => array(),
            
'lbAttributes'       => array(),
            
'rbAttributes'       => array(),
            
'overlay'            => false,
            
'placeholderAlign'   => '',
            
'placeholderContent' => ''
        
);

        
$options array_merge($params$options);

        
self::addClass($options['attributes'], 'n2-box');
        
self::addClass($options['centerAttributes'], 'n2-box-center');

        
self::addClass($options['ltAttributes'], 'n2-box-lt');
        
self::addClass($options['rtAttributes'], 'n2-box-rt');
        
self::addClass($options['lbAttributes'], 'n2-box-lb');
        
self::addClass($options['rbAttributes'], 'n2-box-rb');

        
extract($options);

        include(
dirname(__FILE__) . '/fragments/box.phtml');
    }

    public static function 
heading($options = array()) {
        static 
$params = array(
            
'title'     => '',
            
'menu'      => array(),
            
'actions'   => array(),
            
'snap'      => false,
            
'snapClass' => ''
        
);

        
$options array_merge($params$options);

        
extract($options);

        include(
dirname(__FILE__) . '/fragments/heading.phtml');
    }

    public static function 
banner($options = array()) {
        static 
$params = array(
            
'id'          => '',
            
'image'       => '',
            
'imageLink'   => '',
            
'title'       => '',
            
'description' => '',
            
'buttons'     => array()
        );

        
$options array_merge($params$options);

        
extract($options);

        include(
dirname(__FILE__) . '/fragments/banner.phtml');
    }

    
/**
     * @param array $array1
     * @param array $array2 [optional]
     * @param array $_      [optional]
     *
     * @return array the resulting array.
     * @since 4.0
     * @since 5.0
     */
    
public static function mergeAttributes($array1$array2 null$_ null) {
        
$arguments func_get_args();
        
$target    array_shift($arguments);
        foreach (
$arguments AS $array) {
            if (isset(
$array['style'])) {
                if (!isset(
$target['style'])) $target['style'] = '';
                
$target['style'] .= $array['style'];
                unset(
$array['style']);
            }
            if (isset(
$array['class'])) {
                if (!isset(
$target['class'])) $target['class'] = '';
                
$target['class'] .= ' ' $array['class'];
                unset(
$array['class']);
            }

            
$target array_merge($target$array);
        }

        return 
$target;
    }

    public static function 
addExcludeLazyLoadAttributes($target) {

        return 
self::mergeAttributes($targetself::getExcludeLazyLoadAttributes());
    }

    public static function 
getExcludeLazyLoadAttributes() {
        static 
$attrs;
        if (
$attrs === null) {
            
$attrs = array(
                
'data-no-lazy' => 1,
                
'data-hack'    => 'data-lazy-src'
            
);

            if (
class_exists('\FlorianBrinkmann\LazyLoadResponsiveImages\Plugin'false)) {
                
$attrs['data-no-lazyload'] = 1;
            }

            if (
function_exists('thb_lazy_images_filter')) {
                
$attrs['class'] = 'no-lazyload';
            }
        }

        return 
$attrs;
    }
}