XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
image.php
Go to the documentation of this file.
1 <?php
20 defined('XOOPS_ROOT_PATH') or die('Restricted access');
21 global $xoopsConfig;
22 include_once $GLOBALS['xoops']->path('language/' . $xoopsConfig['language'] . '/misc.php');
23 
25 {
26  function load(&$ts)
27  {
28  static $jsLoaded;
29 
30  $config = $this->loadConfig(dirname(__FILE__));
31  $ts->patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1 width=(['\"]?)([0-9]*)\\3]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
32  $ts->patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
33  $ts->patterns[] = "/\[img width=(['\"]?)([0-9]*)\\1]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
34  $ts->patterns[] = "/\[img]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
35 
36  $ts->patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1 id=(['\"]?)([0-9]*)\\3]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
37  $ts->patterns[] = "/\[img id=(['\"]?)([0-9]*)\\1]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
38 
39  if (empty($ts->config['allowimage'])) {
40  $ts->replacements[] = '<a href="\\5" rel="external">\\5</a>';
41  $ts->replacements[] = '<a href="\\3" rel="external">\\3</a>';
42  $ts->replacements[] = '<a href="\\3" rel="external">\\3</a>';
43  $ts->replacements[] = '<a href="\\1" rel="external">\\1</a>';
44 
45  $ts->replacements[] = '<a href="' . XOOPS_URL . '/image.php?id=\\4" rel="external" title="\\5">\\5</a>';
46  $ts->replacements[] = '<a href="' . XOOPS_URL . '/image.php?id=\\2" rel="external" title="\\3">\\3</a>';
47 
48  } else {
49  if (!empty($config['resize']) && empty($config['clickable']) && !empty($config['max_width']) && !empty($GLOBALS['xoTheme'])) {
50  if (!$jsLoaded) {
51  $jsLoaded = true;
52  $GLOBALS['xoTheme']->addScript('/class/textsanitizer/image/image.js', array(
53  'type' => 'text/javascript'));
54  }
55  $ts->replacements[] = "<img src='\\5' class='\\2' alt='"._MSC_RESIZED_IMAGE . "' border='0' onload=\"JavaScript:if(this.width>\\4)this.width=\\4\" />";
56  $ts->replacements[] = "<img src='\\3' class='\\2' alt='"._MSC_RESIZED_IMAGE . "' border='0'" . ($config['resize'] ? "onload=\"javascript:imageResize(this, " . $config['max_width'] . ")\"" : "") . "/>";
57  $ts->replacements[] = "<img src='\\3' alt='"._MSC_RESIZED_IMAGE . "' border='0' onload=\"JavaScript:if(this.width>\\2)this.width=\\2\" /><br />";
58  $ts->replacements[] = "<img src='\\1' alt='"._MSC_RESIZED_IMAGE . "' border='0'" . ($config['resize'] ? " onload=\"javascript:imageResize(this, " . $config['max_width'] . ")\"" : "") . "/>";
59 
60  } elseif
61 
62  (!empty($config['clickable']) && !empty($config['max_width']) && !empty($GLOBALS['xoTheme'])) {
63  if (!$jsLoaded) {
64  $jsLoaded = true;
65  $GLOBALS['xoTheme']->addScript('/class/textsanitizer/image/image.js', array(
66  'type' => 'text/javascript'));
67  }
68  $ts->replacements[] = "<a href='javascript:CaricaFoto(\"\\5\");'><img src='\\5' class='\\2' alt='"._MSC_CLICK_TO_OPEN_IMAGE . "' border='0' onload=\"JavaScript:if(this.width>\\4)this.width=\\4\" /></a>";
69  $ts->replacements[] = "<a href='javascript:CaricaFoto(\"\\3\");'><img src='\\3' class='\\2' alt='"._MSC_CLICK_TO_OPEN_IMAGE . "' border='0' " . ($config['resize'] ? "onload=\"javascript:imageResize(this, " . $config['max_width'] . ")\"" : "") . "/></a>";
70  $ts->replacements[] = "<a href='javascript:CaricaFoto(\"\\3\");'><img src='\\3' alt='"._MSC_CLICK_TO_OPEN_IMAGE . "' border='0' onload=\"JavaScript:if(this.width>\\2)this.width=\\2\" /></a><br />";
71  $ts->replacements[] = "<a href='javascript:CaricaFoto(\"\\1\");'><img src='\\1' alt='"._MSC_CLICK_TO_OPEN_IMAGE . "' border='0' title='"._MSC_CLICK_TO_OPEN_IMAGE . "'" . ($config['resize'] ? " onload=\"javascript:imageResize(this, " . $config['max_width'] . ")\"" : "") . "/></a>";}
72 
73  else {
74  $ts->replacements[] = "<img src='\\5' class='\\2' border='0' alt='"._MSC_ORIGINAL_IMAGE ."' onload=\"JavaScript:if(this.width>\\4) this.width=\\4\" />";
75  $ts->replacements[] = "<img src='\\3' class='\\2' border='0' alt='"._MSC_ORIGINAL_IMAGE ."' " . ($config['resize'] ? "onload=\"javascript:imageResize(this, " . $config['max_width'] . ")\"" : "") . "/>";
76  $ts->replacements[] = "<img src='\\3' border='0' alt='"._MSC_ORIGINAL_IMAGE ."' onload=\"JavaScript:if(this.width>\\2) this.width=\\2\" />";
77  $ts->replacements[] = "<img src='\\1' border='0' alt='"._MSC_ORIGINAL_IMAGE ."' " . ($config['resize'] ? " onload=\"javascript:imageResize(this, " . $config['max_width'] . ")\"" : "") . "/>";
78  }
79  $ts->replacements[] = '<img src="' . XOOPS_URL . '/image.php?id=\\4" class="\\2" title="\\5" />';
80  $ts->replacements[] = '<img src="' . XOOPS_URL . '/image.php?id=\\2" title="\\3" />';
81  }
82  return true;
83  }
84 }
85 
86 ?>