XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
emoticon.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
8 class emoticon extends EditorHandler
9 {
10  // editor_sequence from the editor must attend mandatory wearing ....
12  var $component_path = '';
13  var $emoticon_path = '';
14 
19  {
20  $this->editor_sequence = $editor_sequence;
21  $this->component_path = $component_path;
22  $this->emoticon_path = sprintf('%s%s/images',preg_replace('/^\.\//i','',$this->component_path),'tpl','images');
23  }
24 
28  function getEmoticonList()
29  {
30  $emoticon = Context::get('emoticon');
31  if(!$emoticon || !preg_match("/^([a-z0-9\_]+)$/i",$emoticon)) return new BaseObject(-1,'msg_invalid_request');
32 
33  $list = $this->getEmoticons($emoticon);
34 
35  $this->add('emoticons', implode("\n",$list));
36  }
37 
41  function getEmoticons($path)
42  {
43  $emoticon_path = sprintf("%s/%s", $this->emoticon_path, $path);
44  $output = array();
45 
46  $oDir = dir($emoticon_path);
47  while($file = $oDir->read())
48  {
49  if(substr($file,0,1)=='.') continue;
50  if(preg_match('/\.(jpg|jpeg|gif|png)$/i',$file)) $output[] = sprintf("%s/%s", $path, str_replace($this->emoticon_path,'',$file));
51  }
52  $oDir->close();
53  if(count($output)) asort($output);
54  return $output;
55  }
56 
60  function getPopupContent()
61  {
62  // Bringing a list of emoticons directory
63  $emoticon_dirs = FileHandler::readDir($this->emoticon_path);
64  $emoticon_list = array();
65  if($emoticon_dirs)
66  {
67  foreach($emoticon_dirs as $emoticon)
68  {
69  if(preg_match("/^([a-z0-9\_]+)$/i", $emoticon)) $emoticon_list[] = $emoticon;
70  }
71  }
72  Context::set('emoticon_list', $emoticon_list);
73  // The first emoticon image files in the directory Wanted
74  $emoticons = $this->getEmoticons($emoticon_list[0]);
75  Context::set('emoticons', $emoticons);
76  // Pre-compiled source code to compile template return to
77  $tpl_path = $this->component_path.'tpl';
78  $tpl_file = 'popup.html';
79 
80  $oTemplate = &TemplateHandler::getInstance();
81  return $oTemplate->compile($tpl_path, $tpl_file);
82  }
83 
87  function transHTML($xml_obj)
88  {
89  $src = $xml_obj->attrs->src;
90  $alt = $xml_obj->attrs->alt;
91 
92  if(!$alt)
93  {
94  $tmp_arr = explode('/',$src);
95  $alt = array_pop($tmp_arr);
96  }
97 
98  $src = str_replace(array('&','"'), array('&amp;','&qout;'), $src);
99  if(!$alt) $alt = $src;
100 
101  $attr_output = array();
102  $attr_output = array("src=\"".$src."\"");
103 
104  if($alt)
105  {
106  $attr_output[] = "alt=\"".$alt."\"";
107  }
108 
109  $code = sprintf("<img %s style=\"border:0px\" />", implode(" ",$attr_output));
110 
111  return $code;
112  }
113 }
114 /* End of file emoticon.class.php */
115 /* Location: ./modules/editor/components/emoticon/emoticon.class.php */
__construct($editor_sequence, $component_path)
editor_sequence and components out of the path
$output
Definition: ko.install.php:193
add($key, $val)
set($key, $val, $set_to_get_vars=0)
transHTML($xml_obj)
Emoticon of the path were added to solve the problem. (06/09/2007 Benny)
getPopupContent()
popup window to display in popup window request is to add content
getEmoticonList()
Returns a list of emoticons file.
getEmoticons($path)
Likely to be recursively emoticons will search all the files to a subdirectory. 8000 gaekkajineun ran...
Emoticons image connected components.
readDir($path, $filter= '', $to_lower=FALSE, $concat_prefix=FALSE)