XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
image_link.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
8 class image_link extends EditorHandler
9 {
10  // editor_sequence from the editor must attend mandatory wearing ....
12  var $component_path = '';
13 
18  {
19  $this->editor_sequence = $editor_sequence;
20  $this->component_path = $component_path;
21  }
22 
26  function getPopupContent()
27  {
28  // Pre-compiled source code to compile template return to
29  $tpl_path = $this->component_path.'tpl';
30  $tpl_file = 'popup.html';
31 
32  Context::set("tpl_path", $tpl_path);
33 
34  $oTemplate = &TemplateHandler::getInstance();
35  return $oTemplate->compile($tpl_path, $tpl_file);
36  }
37 
44  function transHTML($xml_obj)
45  {
46  $src = $xml_obj->attrs->src;
47  $width = $xml_obj->attrs->width;
48  $height = $xml_obj->attrs->height;
49  $align = $xml_obj->attrs->align;
50  $alt = $xml_obj->attrs->alt;
51  $title = $xml_obj->attrs->title;
52  $border = (int)$xml_obj->attrs->border;
53  $link_url = $xml_obj->attrs->link_url;
54  $open_window = $xml_obj->attrs->open_window;
55  $style = $xml_obj->attrs->style;
56  $margin = (int)$xml_obj->attrs->margin;
57 
58  $src = str_replace(array('&','"'), array('&amp;','&qout;'), $src);
59  $src = str_replace('&amp;amp;', '&amp;', $src);
60 
61  $sslPort = Context::get('_https_port');
62  $sslPort = $sslPort != '443' ? ':'.$sslPort : '';
63 
64  // Image containing the address to the address conversion request uri (rss output, etc. purposes)
65  $temp_src = explode('/', $src);
66  if(substr($src, 0,2)=='./') $src = Context::getRequestUri().substr($src, 2);
67  else if(substr($src , 0, 1)=='/')
68  {
69  if($_SERVER['HTTPS']=='on') {
70  $http_src = 'https://';
71  $src = $http_src.$_SERVER['HTTP_HOST'].$sslPort.$src;
72  } else {
73  $http_src = 'http://';
74  $src = $http_src.$_SERVER['HTTP_HOST'].$src;
75  }
76 
77  }
78  else if(!strpos($temp_src[0],':') && $src) $src = Context::getRequestUri().$src;
79 
80  $attr_output = array();
81  $attr_output = array("src=\"".$src."\"");
82  $attr_output[] = "alt=\"".$alt."\"";
83 
84  if($title)
85  {
86  $attr_output[] = "title=\"".$title."\"";
87  }
88  if($margin)
89  {
90  $style = trim(preg_replace('/margin[a-z\-]*[ ]*:[ ]*[0-9 a-z]+(;| )/i','', $style)).';';
91  $style = str_replace(';;',';',$style);
92  if($style == ';') $style = '';
93  $style .= ' margin:'.$margin.'px;';
94  }
95  if($align) $attr_output[] = "align=\"".$align."\"";
96  if($width) $attr_output[] = 'width="'.$width.'"';
97  if($height) $attr_output[] = 'height="'.$height.'"';
98  if($border)
99  {
100  $style = trim(preg_replace('/border[a-z\-]*[ ]*:[ ]*[0-9 a-z]+(;| )/i','', $style)).';';
101  $style = str_replace(';;',';',$style);
102  if($style == ';') $style = '';
103  $style .= ' border-style: solid; border-width:'.$border.'px;';
104  }
105 
106  $code = sprintf("<img %s style=\"%s\" />", implode(' ',$attr_output), $style);
107 
108  if($link_url)
109  {
110  if($open_window =='Y') $code = sprintf('<a href="%s" target="_blank" rel="noopener">%s</a>', $link_url, $code);
111  else $code = sprintf('<a href="%s" >%s</a>', $link_url, $code);
112  }
113  return $code;
114  }
115 }
116 /* End of file image_link.class.php */
117 /* Location: ./modules/editor/components/image_link/image_link.class.php */
set($key, $val, $set_to_get_vars=0)
getRequestUri($ssl_mode=FOLLOW_REQUEST_SSL, $domain=null)