XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
integration_search.model.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
9 {
15  function init()
16  {
17  }
18 
31  function getDocuments($target, $module_srls_list, $search_target, $search_keyword, $page=1, $list_count = 20)
32  {
33  if(is_array($module_srls_list)) $module_srls_list = implode(',',$module_srls_list);
34 
35  $args = new stdClass();
36  if($target == 'exclude')
37  {
38  $module_srls_list .= ',0'; // exclude 'trash'
39  if ($module_srls_list{0} == ',') $module_srls_list = substr($module_srls_list, 1);
40  $args->exclude_module_srl = $module_srls_list;
41  }
42  else
43  {
44  $args->module_srl = $module_srls_list;
45  $args->exclude_module_srl = '0'; // exclude 'trash'
46  }
47 
48  $args->page = $page;
49  $args->list_count = $list_count;
50  $args->page_count = 10;
51  $args->search_target = $search_target;
52  $args->search_keyword = $search_keyword;
53  $args->sort_index = 'list_order';
54  $args->order_type = 'asc';
55  $args->statusList = array('PUBLIC');
56  if(!$args->module_srl) unset($args->module_srl);
57  // Get a list of documents
58  $oDocumentModel = getModel('document');
59 
60  return $oDocumentModel->getDocumentList($args);
61  }
62 
74  function getComments($target, $module_srls_list, $search_keyword, $page=1, $list_count = 20)
75  {
76  $args = new stdClass();
77 
78  if(is_array($module_srls_list))
79  {
80  if (count($module_srls_list) > 0) $module_srls = implode(',',$module_srls_list);
81  }
82  else
83  {
84  if($module_srls_list)
85  {
86  $module_srls = $module_srls_list;
87  }
88  }
89  if($target == 'exclude') $args->exclude_module_srl = $module_srls;
90  else $args->module_srl = $module_srls;
91 
92  $args->page = $page;
93  $args->list_count = $list_count;
94  $args->page_count = 10;
95  $args->search_target = 'content';
96  $args->search_keyword = $search_keyword;
97  $args->sort_index = 'list_order';
98  $args->order_type = 'asc';
99  // Get a list of documents
100  $oCommentModel = getModel('comment');
101  $output = $oCommentModel->getTotalCommentList($args);
102  if(!$output->toBool()|| !$output->data) return $output;
103  return $output;
104  }
105 
118  function getTrackbacks($target, $module_srls_list, $search_target = "title", $search_keyword, $page=1, $list_count = 20)
119  {
120  $oTrackbackModel = getAdminModel('trackback');
121  if(!$oTrackbackModel) return new BaseObject();
122  $args = new stdClass();
123 
124  if(is_array($module_srls_list)) $module_srls = implode(',',$module_srls_list);
125  else $module_srls = $module_srls_list;
126  if($target == 'exclude') $args->exclude_module_srl = $module_srls;
127  else $args->module_srl = $module_srls;
128  $args->page = $page;
129  $args->list_count = $list_count;
130  $args->page_count = 10;
131  $args->search_target = $search_target;
132  $args->search_keyword = $search_keyword;
133  $args->sort_index = 'list_order';
134  $args->order_type = 'asc';
135  // Get a list of documents
136  $output = $oTrackbackModel->getTotalTrackbackList($args);
137  if(!$output->toBool()|| !$output->data) return $output;
138  return $output;
139  }
140 
153  function _getFiles($target, $module_srls_list, $search_keyword, $page, $list_count, $direct_download = 'Y')
154  {
155  $args = new stdClass();
156 
157  if(is_array($module_srls_list)) $module_srls = implode(',',$module_srls_list);
158  else $module_srls = $module_srls_list;
159  if($target == 'exclude') $args->exclude_module_srl = $module_srls;
160  else $args->module_srl = $module_srls;
161  $args->page = $page;
162  $args->list_count = $list_count;
163  $args->page_count = 10;
164  $args->search_target = 'filename';
165  $args->search_keyword = $search_keyword;
166  $args->sort_index = 'files.file_srl';
167  $args->order_type = 'desc';
168  $args->isvalid = 'Y';
169  $args->direct_download = $direct_download=='Y'?'Y':'N';
170  // Get a list of documents
171  $oFileAdminModel = getAdminModel('file');
172  $output = $oFileAdminModel->getFileList($args);
173  if(!$output->toBool() || !$output->data) return $output;
174 
175  $list = array();
176  foreach($output->data as $key => $val)
177  {
178  $obj = new stdClass;
179  $obj->filename = $val->source_filename;
180  $obj->download_count = $val->download_count;
181  if(substr($val->download_url,0,2)=='./') $val->download_url = substr($val->download_url,2);
182  $obj->download_url = Context::getRequestUri().$val->download_url;
183  $obj->target_srl = $val->upload_target_srl;
184  $obj->file_size = $val->file_size;
185  // Images
186  if(preg_match('/\.(jpg|jpeg|gif|png)$/i', $val->source_filename))
187  {
188  $obj->type = 'image';
189 
190  $thumbnail_path = sprintf('files/thumbnails/%s',getNumberingPath($val->file_srl, 3));
191  if(!is_dir($thumbnail_path)) FileHandler::makeDir($thumbnail_path);
192  $thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, 120, 120, 'crop');
193  $thumbnail_url = Context::getRequestUri().$thumbnail_file;
194  if(!file_exists($thumbnail_file)) FileHandler::createImageFile($val->uploaded_filename, $thumbnail_file, 120, 120, 'jpg', 'crop');
195  $obj->src = sprintf('<img src="%s" alt="%s" width="%d" height="%d" />', $thumbnail_url, htmlspecialchars($obj->filename, ENT_COMPAT | ENT_HTML401, 'UTF-8', false), 120, 120);
196  }
197  else
198  {
199  $obj->type = 'binary';
200  $obj->src = '';
201  }
202 
203  $list[] = $obj;
204  $target_list[] = $val->upload_target_srl;
205  }
206  $output->data = $list;
207 
208  $oDocumentModel = getModel('document');
209  $document_list = $oDocumentModel->getDocuments($target_list);
210  if($document_list) foreach($document_list as $key => $val)
211  {
212  foreach($output->data as $k => $v)
213  {
214  if($v->target_srl== $val->document_srl)
215  {
216  $output->data[$k]->url = $val->getPermanentUrl();
217  $output->data[$k]->regdate = $val->getRegdate("Y-m-d H:i");
218  $output->data[$k]->nick_name = $val->getNickName();
219  }
220  }
221  }
222 
223  $oCommentModel = getModel('comment');
224  $comment_list = $oCommentModel->getComments($target_list);
225  if($comment_list) foreach($comment_list as $key => $val)
226  {
227  foreach($output->data as $k => $v)
228  {
229  if($v->target_srl== $val->comment_srl)
230  {
231  $output->data[$k]->url = $val->getPermanentUrl();
232  $output->data[$k]->regdate = $val->getRegdate("Y-m-d H:i");
233  $output->data[$k]->nick_name = $val->getNickName();
234  }
235  }
236  }
237 
238  return $output;
239  }
240 
252  function getImages($target, $module_srls_list, $search_keyword, $page=1, $list_count = 20)
253  {
254  return $this->_getFiles($target, $module_srls_list, $search_keyword, $page, $list_count);
255  }
256 
268  function getFiles($target, $module_srls_list, $search_keyword, $page=1, $list_count = 20)
269  {
270  return $this->_getFiles($target, $module_srls_list, $search_keyword, $page, $list_count, 'N');
271  }
272 }
273 /* End of file integration_search.model.php */
274 /* Location: ./modules/integration_search/integration_search.model.php */
getNumberingPath($no, $size=3)
Definition: func.inc.php:1081
$obj
Definition: ko.install.php:262
$output
Definition: ko.install.php:193
getTrackbacks($target, $module_srls_list, $search_target="title", $search_keyword, $page=1, $list_count=20)
getDocuments($target, $module_srls_list, $search_target, $search_keyword, $page=1, $list_count=20)
$args
Definition: ko.install.php:185
_getFiles($target, $module_srls_list, $search_keyword, $page, $list_count, $direct_download= 'Y')
getAdminModel($module_name)
Definition: func.inc.php:156
$oDocumentModel
Definition: ko.install.php:259
makeDir($path_string)
getComments($target, $module_srls_list, $search_keyword, $page=1, $list_count=20)
createImageFile($source_file, $target_file, $resize_width=0, $resize_height=0, $target_type= '', $thumbnail_type= 'crop', $thumbnail_transparent=FALSE)
getRequestUri($ssl_mode=FOLLOW_REQUEST_SSL, $domain=null)
getModel($module_name)
Definition: func.inc.php:145
getImages($target, $module_srls_list, $search_keyword, $page=1, $list_count=20)
high class of the module module
Definition: module.class.php:8
getFiles($target, $module_srls_list, $search_keyword, $page=1, $list_count=20)