XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
integration_search.view.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
9 {
14  var $target_mid = array();
19  var $skin = 'default';
20 
26  function init()
27  {
28  }
29 
35  function IS()
36  {
37  $oFile = getClass('file');
38  $oModuleModel = getModel('module');
39  $logged_info = Context::get('logged_info');
40 
41  // Check permissions
42  if(!$this->grant->access) return new BaseObject(-1,'msg_not_permitted');
43 
44  $config = $oModuleModel->getModuleConfig('integration_search');
45  if(!$config) $config = new stdClass;
46  if(!$config->skin)
47  {
48  $config->skin = 'default';
49  $template_path = sprintf('%sskins/%s', $this->module_path, $config->skin);
50  }
51  else
52  {
53  //check theme
54  $config_parse = explode('|@|', $config->skin);
55  if (count($config_parse) > 1)
56  {
57  $template_path = sprintf('./themes/%s/modules/integration_search/', $config_parse[0]);
58  }
59  else
60  {
61  $template_path = sprintf('%sskins/%s', $this->module_path, $config->skin);
62  }
63  }
64  // Template path
66  $skin_vars = ($config->skin_vars) ? unserialize($config->skin_vars) : new stdClass;
67  Context::set('module_info', $skin_vars);
68 
69  $target = $config->target;
70  if(!$target) $target = 'include';
71 
72  if(empty($config->target_module_srl))
73  $module_srl_list = array();
74  else
75  $module_srl_list = explode(',',$config->target_module_srl);
76 
77  // https://github.com/xpressengine/xe-core/issues/1522
78  // 검색 대상을 지정하지 않았을 때 검색 제한
79  if($target === 'include' && !count($module_srl_list))
80  {
81  $oMessageObject = ModuleHandler::getModuleInstance('message');
82  $oMessageObject->setError(-1);
83  $oMessageObject->setMessage('msg_not_enabled');
84  $oMessageObject->dispMessage();
85  $this->setTemplatePath($oMessageObject->getTemplatePath());
86  $this->setTemplateFile($oMessageObject->getTemplateFile());
87  return;
88  }
89 
90  // Set a variable for search keyword
91  $is_keyword = Context::get('is_keyword');
92  // Set page variables
93  $page = (int)Context::get('page');
94  if(!$page) $page = 1;
95  // Search by search tab
96  $where = Context::get('where');
97  // Create integration search model object
98  if($is_keyword)
99  {
100  $oIS = getModel('integration_search');
101  switch($where)
102  {
103  case 'document' :
104  $search_target = Context::get('search_target');
105  if(!in_array($search_target, array('title','content','title_content','tag'))) $search_target = 'title';
106  Context::set('search_target', $search_target);
107 
108  $output = $oIS->getDocuments($target, $module_srl_list, $search_target, $is_keyword, $page, 10);
109  Context::set('output', $output);
110  $this->setTemplateFile("document", $page);
111  break;
112  case 'comment' :
113  $output = $oIS->getComments($target, $module_srl_list, $is_keyword, $page, 10);
114  Context::set('output', $output);
115  $this->setTemplateFile("comment", $page);
116  break;
117  case 'trackback' :
118  $search_target = Context::get('search_target');
119  if(!in_array($search_target, array('title','url','blog_name','excerpt'))) $search_target = 'title';
120  Context::set('search_target', $search_target);
121 
122  $output = $oIS->getTrackbacks($target, $module_srl_list, $search_target, $is_keyword, $page, 10);
123  Context::set('output', $output);
124  $this->setTemplateFile("trackback", $page);
125  break;
126  case 'multimedia' :
127  $output = $oIS->getImages($target, $module_srl_list, $is_keyword, $page,20);
128  Context::set('output', $output);
129  $this->setTemplateFile("multimedia", $page);
130  break;
131  case 'file' :
132  $output = $oIS->getFiles($target, $module_srl_list, $is_keyword, $page, 20);
133  Context::set('output', $output);
134  $this->setTemplateFile("file", $page);
135  break;
136  default :
137  $output['document'] = $oIS->getDocuments($target, $module_srl_list, 'title', $is_keyword, $page, 5);
138  $output['comment'] = $oIS->getComments($target, $module_srl_list, $is_keyword, $page, 5);
139  $output['trackback'] = $oIS->getTrackbacks($target, $module_srl_list, 'title', $is_keyword, $page, 5);
140  $output['multimedia'] = $oIS->getImages($target, $module_srl_list, $is_keyword, $page, 5);
141  $output['file'] = $oIS->getFiles($target, $module_srl_list, $is_keyword, $page, 5);
142  Context::set('search_result', $output);
143  Context::set('search_target', 'title');
144  $this->setTemplateFile("index", $page);
145  break;
146  }
147  }
148  else
149  {
150  $this->setTemplateFile("no_keywords");
151  }
152 
153  $security = new Security();
154  $security->encodeHTML('is_keyword', 'search_target', 'where', 'page');
155  }
156 }
157 /* End of file integration_search.view.php */
158 /* Location: ./modules/integration_search/integration_search.view.php */
setTemplateFile($filename)
$oModuleModel
Definition: ko.install.php:236
& getModuleInstance($module, $type= 'view', $kind= '')
$template_path
a path of directory where template files reside
$output
Definition: ko.install.php:193
set($key, $val, $set_to_get_vars=0)
getModel($module_name)
Definition: func.inc.php:145
getClass($module_name)
Definition: func.inc.php:189