XOOPS  2.6.0
image.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
25 {
30  public function load(MyTextSanitizer &$ts)
31  {
32  static $jsLoaded;
33 
35  $config = $this->loadConfig(__DIR__);
36  $ts->patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1 width=(['\"]?)([0-9]*)\\3]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
37  $ts->patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
38  $ts->patterns[] = "/\[img width=(['\"]?)([0-9]*)\\1]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
39  $ts->patterns[] = "/\[img]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
40 
41  $ts->patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1 id=(['\"]?)([0-9]*)\\3]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
42  $ts->patterns[] = "/\[img id=(['\"]?)([0-9]*)\\1]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
43 
45 
46  if (empty($ts->config['allowimage'])) {
47  $ts->replacements[] = '<a href="\\5" rel="external">\\5</a>';
48  $ts->replacements[] = '<a href="\\3" rel="external">\\3</a>';
49  $ts->replacements[] = '<a href="\\3" rel="external">\\3</a>';
50  $ts->replacements[] = '<a href="\\1" rel="external">\\1</a>';
51 
52  $ts->replacements[] = '<a href="' . $xoops_url . '/image.php?id=\\4" rel="external" title="\\5">\\5</a>';
53  $ts->replacements[] = '<a href="' . $xoops_url . '/image.php?id=\\2" rel="external" title="\\3">\\3</a>';
54 
55  } else {
56  if (!empty($config['resize']) && empty($config['clickable']) && !empty($config['max_width']) && is_object($xoops->theme())) {
57  if (!$jsLoaded) {
58  $jsLoaded = true;
59  $xoops->theme()->addScript('/class/textsanitizer/image/image.js', array(
60  'type' => 'text/javascript'
61  ));
62  }
63  $resizedStr = XoopsLocale::RESIZED_IMAGE;
64  $ts->replacements[] = "<img src='\\5' class='\\2' alt='" . $resizedStr . "' border='0' onload=\"JavaScript:if(this.width>\\4)this.width=\\4\" />";
65  $ts->replacements[] = "<img src='\\3' class='\\2' alt='" . $resizedStr . "' border='0'" . ($config['resize']
66  ? "onload=\"javascript:imageResize(this, " . $config['max_width'] . ")\"" : "") . "/>";
67  $ts->replacements[] = "<img src='\\3' alt='" . $resizedStr . "' border='0' onload=\"JavaScript:if(this.width>\\2)this.width=\\2\" /><br />";
68  $ts->replacements[] = "<img src='\\1' alt='" . $resizedStr . "' border='0'" . ($config['resize']
69  ? " onload=\"javascript:imageResize(this, " . $config['max_width'] . ")\"" : "") . "/>";
70 
71  } else {
72  if (!empty($config['clickable']) && !empty($config['max_width']) && is_object($xoops->theme())) {
73  if (!$jsLoaded) {
74  $jsLoaded = true;
75  $xoops->theme()->addScript('/class/textsanitizer/image/image.js', array(
76  'type' => 'text/javascript'
77  ));
78  }
80  $ts->replacements[] = "<a href='javascript:CaricaFoto(\"\\5\");'><img src='\\5' class='\\2' alt='" . $openImageStr . "' border='0' onload=\"JavaScript:if(this.width>\\4)this.width=\\4\" /></a>";
81  $ts->replacements[] = "<a href='javascript:CaricaFoto(\"\\3\");'><img src='\\3' class='\\2' alt='" . $openImageStr . "' border='0' " . ($config['resize']
82  ? "onload=\"javascript:imageResize(this, " . $config['max_width'] . ")\"" : "") . "/></a>";
83  $ts->replacements[] = "<a href='javascript:CaricaFoto(\"\\3\");'><img src='\\3' alt='" . $openImageStr . "' border='0' onload=\"JavaScript:if(this.width>\\2)this.width=\\2\" /></a><br />";
84  $ts->replacements[] = "<a href='javascript:CaricaFoto(\"\\1\");'><img src='\\1' alt='" . $openImageStr . "' border='0' title='" . $openImageStr . "'" . ($config['resize']
85  ? " onload=\"javascript:imageResize(this, " . $config['max_width'] . ")\"" : "") . "/></a>";
86  } else {
87  $originalStr = XoopsLocale::ORIGINAL_IMAGE;
88  $ts->replacements[] = "<img src='\\5' class='\\2' border='0' alt='" . $originalStr . "' onload=\"JavaScript:if(this.width>\\4) this.width=\\4\" />";
89  $ts->replacements[] = "<img src='\\3' class='\\2' border='0' alt='" . $originalStr . "' " . ($config['resize']
90  ? "onload=\"javascript:imageResize(this, " . $config['max_width'] . ")\"" : "") . "/>";
91  $ts->replacements[] = "<img src='\\3' border='0' alt='" . $originalStr . "' onload=\"JavaScript:if(this.width>\\2) this.width=\\2\" />";
92  $ts->replacements[] = "<img src='\\1' border='0' alt='" . $originalStr . "' " . ($config['resize']
93  ? " onload=\"javascript:imageResize(this, " . $config['max_width'] . ")\"" : "") . "/>";
94  }
95  }
96  $ts->replacements[] = '<img src="' . $xoops_url . '/image.php?id=\\4" class="\\2" title="\\5" />';
97  $ts->replacements[] = '<img src="' . $xoops_url . '/image.php?id=\\2" title="\\3" />';
98  }
99  return true;
100  }
101 }
$xoops_url
Definition: backend.php:32
load(MyTextSanitizer &$ts)
Definition: image.php:30
static getInstance()
Definition: Xoops.php:160
$xoops
Definition: image.php:25
const ORIGINAL_IMAGE
Definition: en_US.php:891
static get($name)
const RESIZED_IMAGE
Definition: en_US.php:957
const CLICK_TO_SEE_ORIGINAL_IMAGE_IN_NEW_WINDOW
Definition: en_US.php:164