|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
|
3
|
|
|
/** |
|
4
|
|
|
* documentModel class |
|
5
|
|
|
* model class of the module document |
|
6
|
|
|
* |
|
7
|
|
|
* @author NAVER ([email protected]) |
|
8
|
|
|
* @package /modules/document |
|
9
|
|
|
* @version 0.1 |
|
10
|
|
|
*/ |
|
11
|
|
|
class documentModel extends document |
|
12
|
|
|
{ |
|
13
|
|
|
private $documentConfig = NULL; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Initialization |
|
17
|
|
|
* @return void |
|
18
|
|
|
*/ |
|
19
|
|
|
function init() |
|
20
|
|
|
{ |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* document checked the permissions on the session values |
|
25
|
|
|
* @param int $document_srl |
|
26
|
|
|
* @return void |
|
27
|
|
|
*/ |
|
28
|
|
|
function isGranted($document_srl) |
|
29
|
|
|
{ |
|
30
|
|
|
return $_SESSION['own_document'][$document_srl]; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Return document extra information from database |
|
35
|
|
|
* @param array $documentSrls |
|
36
|
|
|
* @return object |
|
37
|
|
|
*/ |
|
38
|
|
|
function getDocumentExtraVarsFromDB($documentSrls) |
|
39
|
|
|
{ |
|
40
|
|
|
if(!is_array($documentSrls) || count($documentSrls) == 0) |
|
41
|
|
|
{ |
|
42
|
|
|
return new Object(-1, 'msg_invalid_request'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
$args = new stdClass(); |
|
46
|
|
|
$args->document_srl = $documentSrls; |
|
47
|
|
|
$output = executeQueryArray('document.getDocumentExtraVars', $args); |
|
48
|
|
|
return $output; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Extra variables for each article will not be processed bulk select and apply the macro city |
|
53
|
|
|
* @return void |
|
54
|
|
|
*/ |
|
55
|
|
|
function setToAllDocumentExtraVars() |
|
56
|
|
|
{ |
|
57
|
|
|
static $checked_documents = array(); |
|
58
|
|
|
$_document_list = &$GLOBALS['XE_DOCUMENT_LIST']; |
|
59
|
|
|
|
|
60
|
|
|
// XE XE_DOCUMENT_LIST all documents that the object referred to the global variable settings |
|
61
|
|
|
if(count($_document_list) <= 0) return; |
|
62
|
|
|
|
|
63
|
|
|
// Find all called the document object variable has been set extension |
|
64
|
|
|
$document_srls = array(); |
|
65
|
|
|
foreach($_document_list as $key => $val) |
|
66
|
|
|
{ |
|
67
|
|
|
if(!$val->document_srl || $checked_documents[$val->document_srl]) continue; |
|
68
|
|
|
$checked_documents[$val->document_srl] = true; |
|
69
|
|
|
$document_srls[] = $val->document_srl; |
|
70
|
|
|
} |
|
71
|
|
|
// If the document number, return detected |
|
72
|
|
|
if(!count($document_srls)) return; |
|
73
|
|
|
// Expand variables mijijeongdoen article about a current visitor to the extension of the language code, the search variable |
|
74
|
|
|
//$obj->document_srl = implode(',',$document_srls); |
|
75
|
|
|
$output = $this->getDocumentExtraVarsFromDB($document_srls); |
|
76
|
|
|
if($output->toBool() && $output->data) |
|
77
|
|
|
{ |
|
78
|
|
|
foreach($output->data as $key => $val) |
|
79
|
|
|
{ |
|
80
|
|
|
if(!isset($val->value)) continue; |
|
81
|
|
|
if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value); |
|
|
|
|
|
|
82
|
|
|
$extra_vars[$val->document_srl][$val->var_idx][$val->lang_code] = trim($val->value); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
$user_lang_code = Context::getLangType(); |
|
87
|
|
|
for($i=0,$c=count($document_srls);$i<$c;$i++) |
|
88
|
|
|
{ |
|
89
|
|
|
$document_srl = $document_srls[$i]; |
|
90
|
|
|
unset($vars); |
|
91
|
|
|
|
|
92
|
|
|
if(!$_document_list[$document_srl] || !is_object($_document_list[$document_srl]) || !$_document_list[$document_srl]->isExists()) continue; |
|
93
|
|
|
$module_srl = $_document_list[$document_srl]->get('module_srl'); |
|
94
|
|
|
$extra_keys = $this->getExtraKeys($module_srl); |
|
95
|
|
|
$vars = $extra_vars[$document_srl]; |
|
96
|
|
|
$document_lang_code = $_document_list[$document_srl]->get('lang_code'); |
|
97
|
|
|
// Expand the variable processing |
|
98
|
|
|
if(count($extra_keys)) |
|
99
|
|
|
{ |
|
100
|
|
|
foreach($extra_keys as $idx => $key) |
|
101
|
|
|
{ |
|
102
|
|
|
$extra_keys[$idx] = clone($key); |
|
103
|
|
|
$val = $vars[$idx]; |
|
104
|
|
|
if(isset($val[$user_lang_code])) $v = $val[$user_lang_code]; |
|
105
|
|
|
else if(isset($val[$document_lang_code])) $v = $val[$document_lang_code]; |
|
106
|
|
|
else if(isset($val[0])) $v = $val[0]; |
|
107
|
|
|
else $v = null; |
|
108
|
|
|
$extra_keys[$idx]->value = $v; |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
unset($evars); |
|
113
|
|
|
$evars = new ExtraVar($module_srl); |
|
114
|
|
|
$evars->setExtraVarKeys($extra_keys); |
|
115
|
|
|
// Title Processing |
|
116
|
|
|
if($vars[-1][$user_lang_code]) $_document_list[$document_srl]->add('title',$vars[-1][$user_lang_code]); |
|
117
|
|
|
// Information processing |
|
118
|
|
|
if($vars[-2][$user_lang_code]) $_document_list[$document_srl]->add('content',$vars[-2][$user_lang_code]); |
|
119
|
|
|
|
|
120
|
|
|
if($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code]) |
|
121
|
|
|
{ |
|
122
|
|
|
unset($checked_documents[$document_srl]); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
$GLOBALS['XE_EXTRA_VARS'][$document_srl] = $evars->getExtraVars(); |
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* Import Document |
|
131
|
|
|
* @param int $document_srl |
|
132
|
|
|
* @param bool $is_admin |
|
133
|
|
|
* @param bool $load_extra_vars |
|
134
|
|
|
* @param array $columnList |
|
135
|
|
|
* @return documentItem |
|
136
|
|
|
*/ |
|
137
|
|
|
function getDocument($document_srl=0, $is_admin = false, $load_extra_vars=true, $columnList = array()) |
|
138
|
|
|
{ |
|
139
|
|
|
if(!$document_srl) return new documentItem(); |
|
140
|
|
|
|
|
141
|
|
|
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
142
|
|
|
{ |
|
143
|
|
|
$oDocument = new documentItem($document_srl, $load_extra_vars, $columnList); |
|
144
|
|
|
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
|
145
|
|
|
if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
146
|
|
|
} |
|
147
|
|
|
if($is_admin) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->setGrant(); |
|
148
|
|
|
|
|
149
|
|
|
return $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* Bringing multiple documents (or paging) |
|
154
|
|
|
* @param array|string $document_srls |
|
155
|
|
|
* @param bool $is_admin |
|
156
|
|
|
* @param bool $load_extra_vars |
|
157
|
|
|
* @param array $columnList |
|
158
|
|
|
* @return array value type is documentItem |
|
159
|
|
|
*/ |
|
160
|
|
|
function getDocuments($document_srls, $is_admin = false, $load_extra_vars=true, $columnList = array()) |
|
161
|
|
|
{ |
|
162
|
|
|
if(is_array($document_srls)) |
|
163
|
|
|
{ |
|
164
|
|
|
$list_count = count($document_srls); |
|
165
|
|
|
$document_srls = implode(',',$document_srls); |
|
166
|
|
|
} |
|
167
|
|
|
else |
|
168
|
|
|
{ |
|
169
|
|
|
$list_count = 1; |
|
170
|
|
|
} |
|
171
|
|
|
$args = new stdClass(); |
|
172
|
|
|
$args->document_srls = $document_srls; |
|
173
|
|
|
$args->list_count = $list_count; |
|
174
|
|
|
$args->order_type = 'asc'; |
|
175
|
|
|
|
|
176
|
|
|
$output = executeQuery('document.getDocuments', $args, $columnList); |
|
177
|
|
|
$document_list = $output->data; |
|
178
|
|
|
if(!$document_list) return; |
|
179
|
|
|
if(!is_array($document_list)) $document_list = array($document_list); |
|
180
|
|
|
|
|
181
|
|
|
$document_count = count($document_list); |
|
|
|
|
|
|
182
|
|
View Code Duplication |
foreach($document_list as $key => $attribute) |
|
183
|
|
|
{ |
|
184
|
|
|
$document_srl = $attribute->document_srl; |
|
185
|
|
|
if(!$document_srl) continue; |
|
186
|
|
|
|
|
187
|
|
|
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
188
|
|
|
{ |
|
189
|
|
|
$oDocument = null; |
|
|
|
|
|
|
190
|
|
|
$oDocument = new documentItem(); |
|
191
|
|
|
$oDocument->setAttribute($attribute, false); |
|
192
|
|
|
if($is_admin) $oDocument->setGrant(); |
|
193
|
|
|
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
$result[$attribute->document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
|
|
|
|
|
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
200
|
|
|
|
|
201
|
|
|
$output = null; |
|
202
|
|
|
if(count($result)) |
|
203
|
|
|
{ |
|
204
|
|
|
foreach($result as $document_srl => $val) |
|
|
|
|
|
|
205
|
|
|
{ |
|
206
|
|
|
$output[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
|
207
|
|
|
} |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
return $output; |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
/** |
|
214
|
|
|
* Module_srl value, bringing the list of documents |
|
215
|
|
|
* @param object $obj |
|
216
|
|
|
* @param bool $except_notice |
|
217
|
|
|
* @param bool $load_extra_vars |
|
218
|
|
|
* @param array $columnList |
|
219
|
|
|
* @return Object |
|
220
|
|
|
*/ |
|
221
|
|
|
function getDocumentList($obj, $except_notice = false, $load_extra_vars=true, $columnList = array()) |
|
222
|
|
|
{ |
|
223
|
|
|
$sort_check = $this->_setSortIndex($obj, $load_extra_vars); |
|
224
|
|
|
$obj->sort_index = $sort_check->sort_index; |
|
225
|
|
|
$obj->isExtraVars = $sort_check->isExtraVars; |
|
226
|
|
|
unset($obj->use_alternate_output); |
|
227
|
|
|
$obj->columnList = $columnList; |
|
228
|
|
|
// Call trigger (before) |
|
229
|
|
|
// This trigger can be used to set an alternative output using a different search method |
|
230
|
|
|
$output = ModuleHandler::triggerCall('document.getDocumentList', 'before', $obj); |
|
231
|
|
|
if($output instanceof Object && !$output->toBool()) |
|
232
|
|
|
{ |
|
233
|
|
|
return $output; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
// If an alternate output is set, use it instead of running the default queries |
|
237
|
|
|
$use_alternate_output = (isset($obj->use_alternate_output) && $obj->use_alternate_output instanceof Object); |
|
238
|
|
|
if (!$use_alternate_output) |
|
239
|
|
|
{ |
|
240
|
|
|
$this->_setSearchOption($obj, $args, $query_id, $use_division); |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
if ($use_alternate_output) |
|
244
|
|
|
{ |
|
245
|
|
|
$output = $obj->use_alternate_output; |
|
246
|
|
|
unset($obj->use_alternate_output); |
|
247
|
|
|
} |
|
248
|
|
|
elseif ($sort_check->isExtraVars && substr_count($obj->search_target,'extra_vars')) |
|
249
|
|
|
{ |
|
250
|
|
|
$query_id = 'document.getDocumentListWithinExtraVarsExtraSort'; |
|
251
|
|
|
$args->sort_index = str_replace('documents.','',$args->sort_index); |
|
|
|
|
|
|
252
|
|
|
$output = executeQueryArray($query_id, $args); |
|
253
|
|
|
} |
|
254
|
|
|
elseif ($sort_check->isExtraVars) |
|
255
|
|
|
{ |
|
256
|
|
|
$output = executeQueryArray($query_id, $args); |
|
|
|
|
|
|
257
|
|
|
} |
|
258
|
|
|
else |
|
259
|
|
|
{ |
|
260
|
|
|
// document.getDocumentList query execution |
|
261
|
|
|
// Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because |
|
262
|
|
|
$groupByQuery = array('document.getDocumentListWithinComment' => 1, 'document.getDocumentListWithinTag' => 1, 'document.getDocumentListWithinExtraVars' => 1); |
|
263
|
|
|
if(isset($groupByQuery[$query_id])) |
|
264
|
|
|
{ |
|
265
|
|
|
$group_args = clone($args); |
|
266
|
|
|
$group_args->sort_index = 'documents.'.$args->sort_index; |
|
267
|
|
|
$output = executeQueryArray($query_id, $group_args); |
|
268
|
|
|
if(!$output->toBool()||!count($output->data)) return $output; |
|
269
|
|
|
|
|
270
|
|
|
foreach($output->data as $key => $val) |
|
271
|
|
|
{ |
|
272
|
|
|
if($val->document_srl) $target_srls[] = $val->document_srl; |
|
|
|
|
|
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
$page_navigation = $output->page_navigation; |
|
276
|
|
|
$keys = array_keys($output->data); |
|
277
|
|
|
$virtual_number = $keys[0]; |
|
278
|
|
|
|
|
279
|
|
|
$target_args = new stdClass(); |
|
280
|
|
|
$target_args->document_srls = implode(',',$target_srls); |
|
|
|
|
|
|
281
|
|
|
$target_args->list_order = $args->sort_index; |
|
282
|
|
|
$target_args->order_type = $args->order_type; |
|
283
|
|
|
$target_args->list_count = $args->list_count; |
|
284
|
|
|
$target_args->page = 1; |
|
285
|
|
|
$output = executeQueryArray('document.getDocuments', $target_args); |
|
286
|
|
|
$output->page_navigation = $page_navigation; |
|
287
|
|
|
$output->total_count = $page_navigation->total_count; |
|
288
|
|
|
$output->total_page = $page_navigation->total_page; |
|
289
|
|
|
$output->page = $page_navigation->cur_page; |
|
290
|
|
|
} |
|
291
|
|
|
else |
|
292
|
|
|
{ |
|
293
|
|
|
$output = executeQueryArray($query_id, $args, $columnList); |
|
294
|
|
|
} |
|
295
|
|
|
} |
|
296
|
|
|
// Return if no result or an error occurs |
|
297
|
|
|
if(!$output->toBool()||!count($output->data)) return $output; |
|
298
|
|
|
$idx = 0; |
|
|
|
|
|
|
299
|
|
|
$data = $output->data; |
|
300
|
|
|
unset($output->data); |
|
301
|
|
|
|
|
302
|
|
|
if(!isset($virtual_number)) |
|
303
|
|
|
{ |
|
304
|
|
|
$keys = array_keys($data); |
|
305
|
|
|
$virtual_number = $keys[0]; |
|
306
|
|
|
} |
|
307
|
|
|
|
|
308
|
|
|
if($except_notice) |
|
309
|
|
|
{ |
|
310
|
|
|
foreach($data as $key => $attribute) |
|
311
|
|
|
{ |
|
312
|
|
|
if($attribute->is_notice == 'Y') $virtual_number --; |
|
313
|
|
|
} |
|
314
|
|
|
} |
|
315
|
|
|
|
|
316
|
|
|
foreach($data as $key => $attribute) |
|
317
|
|
|
{ |
|
318
|
|
|
if($except_notice && $attribute->is_notice == 'Y') continue; |
|
319
|
|
|
$document_srl = $attribute->document_srl; |
|
320
|
|
|
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
321
|
|
|
{ |
|
322
|
|
|
$oDocument = null; |
|
|
|
|
|
|
323
|
|
|
$oDocument = new documentItem(); |
|
324
|
|
|
$oDocument->setAttribute($attribute, false); |
|
325
|
|
|
if($is_admin) $oDocument->setGrant(); |
|
|
|
|
|
|
326
|
|
|
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
$output->data[$virtual_number] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
|
330
|
|
|
$virtual_number--; |
|
331
|
|
|
} |
|
332
|
|
|
|
|
333
|
|
|
if($load_extra_vars) $this->setToAllDocumentExtraVars(); |
|
334
|
|
|
|
|
335
|
|
|
if(count($output->data)) |
|
336
|
|
|
{ |
|
337
|
|
|
foreach($output->data as $number => $document) |
|
338
|
|
|
{ |
|
339
|
|
|
$output->data[$number] = $GLOBALS['XE_DOCUMENT_LIST'][$document->document_srl]; |
|
340
|
|
|
} |
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
// Call trigger (after) |
|
344
|
|
|
// This trigger can be used to modify search results |
|
345
|
|
|
ModuleHandler::triggerCall('document.getDocumentList', 'after', $output); |
|
346
|
|
|
return $output; |
|
347
|
|
|
} |
|
348
|
|
|
|
|
349
|
|
|
/** |
|
350
|
|
|
* Module_srl value, bringing the document's gongjisa Port |
|
351
|
|
|
* @param object $obj |
|
352
|
|
|
* @param array $columnList |
|
353
|
|
|
* @return object|void |
|
354
|
|
|
*/ |
|
355
|
|
|
function getNoticeList($obj, $columnList = array()) |
|
356
|
|
|
{ |
|
357
|
|
|
$args = new stdClass(); |
|
358
|
|
|
$args->module_srl = $obj->module_srl; |
|
359
|
|
|
$args->category_srl= $obj->category_srl; |
|
360
|
|
|
$output = executeQueryArray('document.getNoticeList', $args, $columnList); |
|
361
|
|
|
if(!$output->toBool()||!$output->data) return; |
|
362
|
|
|
|
|
363
|
|
View Code Duplication |
foreach($output->data as $key => $val) |
|
364
|
|
|
{ |
|
365
|
|
|
$document_srl = $val->document_srl; |
|
366
|
|
|
if(!$document_srl) continue; |
|
367
|
|
|
|
|
368
|
|
|
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) |
|
369
|
|
|
{ |
|
370
|
|
|
$oDocument = null; |
|
|
|
|
|
|
371
|
|
|
$oDocument = new documentItem(); |
|
372
|
|
|
$oDocument->setAttribute($val, false); |
|
373
|
|
|
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
|
374
|
|
|
} |
|
375
|
|
|
$result->data[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
|
|
|
|
|
|
376
|
|
|
} |
|
377
|
|
|
$this->setToAllDocumentExtraVars(); |
|
378
|
|
|
|
|
379
|
|
|
foreach($result->data as $document_srl => $val) |
|
380
|
|
|
{ |
|
381
|
|
|
$result->data[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]; |
|
382
|
|
|
} |
|
383
|
|
|
|
|
384
|
|
|
return $result; |
|
385
|
|
|
} |
|
386
|
|
|
|
|
387
|
|
|
/** |
|
388
|
|
|
* Function to retrieve the key values of the extended variable document |
|
389
|
|
|
* $Form_include: writing articles whether to add the necessary extensions of the variable input form |
|
390
|
|
|
* @param int $module_srl |
|
391
|
|
|
* @return array |
|
392
|
|
|
*/ |
|
393
|
|
|
function getExtraKeys($module_srl) |
|
394
|
|
|
{ |
|
395
|
|
|
if(!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl])) |
|
396
|
|
|
{ |
|
397
|
|
|
$keys = false; |
|
398
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
|
399
|
|
|
if($oCacheHandler->isSupport()) |
|
400
|
|
|
{ |
|
401
|
|
|
$object_key = 'module_document_extra_keys:' . $module_srl; |
|
402
|
|
|
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
|
403
|
|
|
$keys = $oCacheHandler->get($cache_key); |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
$oExtraVar = ExtraVar::getInstance($module_srl); |
|
407
|
|
|
|
|
408
|
|
|
if($keys === false) |
|
409
|
|
|
{ |
|
410
|
|
|
$obj = new stdClass(); |
|
411
|
|
|
$obj->module_srl = $module_srl; |
|
412
|
|
|
$obj->sort_index = 'var_idx'; |
|
413
|
|
|
$obj->order = 'asc'; |
|
414
|
|
|
$output = executeQueryArray('document.getDocumentExtraKeys', $obj); |
|
415
|
|
|
|
|
416
|
|
|
// correcting index order |
|
417
|
|
|
$isFixed = FALSE; |
|
418
|
|
|
if(is_array($output->data)) |
|
419
|
|
|
{ |
|
420
|
|
|
$prevIdx = 0; |
|
421
|
|
|
foreach($output->data as $no => $value) |
|
422
|
|
|
{ |
|
423
|
|
|
// case first |
|
424
|
|
|
if($prevIdx == 0 && $value->idx != 1) |
|
425
|
|
|
{ |
|
426
|
|
|
$args = new stdClass(); |
|
427
|
|
|
$args->module_srl = $module_srl; |
|
428
|
|
|
$args->var_idx = $value->idx; |
|
429
|
|
|
$args->new_idx = 1; |
|
430
|
|
|
executeQuery('document.updateDocumentExtraKeyIdx', $args); |
|
431
|
|
|
executeQuery('document.updateDocumentExtraVarIdx', $args); |
|
432
|
|
|
$prevIdx = 1; |
|
433
|
|
|
$isFixed = TRUE; |
|
434
|
|
|
continue; |
|
435
|
|
|
} |
|
436
|
|
|
|
|
437
|
|
|
// case others |
|
438
|
|
|
if($prevIdx > 0 && $prevIdx + 1 != $value->idx) |
|
439
|
|
|
{ |
|
440
|
|
|
$args = new stdClass(); |
|
441
|
|
|
$args->module_srl = $module_srl; |
|
442
|
|
|
$args->var_idx = $value->idx; |
|
443
|
|
|
$args->new_idx = $prevIdx + 1; |
|
444
|
|
|
executeQuery('document.updateDocumentExtraKeyIdx', $args); |
|
445
|
|
|
executeQuery('document.updateDocumentExtraVarIdx', $args); |
|
446
|
|
|
$prevIdx += 1; |
|
447
|
|
|
$isFixed = TRUE; |
|
448
|
|
|
continue; |
|
449
|
|
|
} |
|
450
|
|
|
|
|
451
|
|
|
$prevIdx = $value->idx; |
|
452
|
|
|
} |
|
453
|
|
|
} |
|
454
|
|
|
|
|
455
|
|
|
if($isFixed) |
|
456
|
|
|
{ |
|
457
|
|
|
$output = executeQueryArray('document.getDocumentExtraKeys', $obj); |
|
458
|
|
|
} |
|
459
|
|
|
|
|
460
|
|
|
$oExtraVar->setExtraVarKeys($output->data); |
|
461
|
|
|
$keys = $oExtraVar->getExtraVars(); |
|
462
|
|
|
if(!$keys) $keys = array(); |
|
|
|
|
|
|
463
|
|
|
|
|
464
|
|
|
if($oCacheHandler->isSupport()) |
|
465
|
|
|
{ |
|
466
|
|
|
$oCacheHandler->put($cache_key, $keys); |
|
|
|
|
|
|
467
|
|
|
} |
|
468
|
|
|
} |
|
469
|
|
|
|
|
470
|
|
|
|
|
471
|
|
|
$GLOBALS['XE_EXTRA_KEYS'][$module_srl] = $keys; |
|
472
|
|
|
} |
|
473
|
|
|
|
|
474
|
|
|
return $GLOBALS['XE_EXTRA_KEYS'][$module_srl]; |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
/** |
|
478
|
|
|
* A particular document to get the value of the extra variable function |
|
479
|
|
|
* @param int $module_srl |
|
480
|
|
|
* @param int $document_srl |
|
481
|
|
|
* @return array |
|
482
|
|
|
*/ |
|
483
|
|
|
function getExtraVars($module_srl, $document_srl) |
|
|
|
|
|
|
484
|
|
|
{ |
|
485
|
|
|
if(!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl])) |
|
486
|
|
|
{ |
|
487
|
|
|
// Extended to extract the values of variables set |
|
488
|
|
|
$oDocument = $this->getDocument($document_srl, false); |
|
489
|
|
|
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument; |
|
490
|
|
|
$this->setToAllDocumentExtraVars(); |
|
491
|
|
|
} |
|
492
|
|
|
if(is_array($GLOBALS['XE_EXTRA_VARS'][$document_srl])) ksort($GLOBALS['XE_EXTRA_VARS'][$document_srl]); |
|
493
|
|
|
return $GLOBALS['XE_EXTRA_VARS'][$document_srl]; |
|
494
|
|
|
} |
|
495
|
|
|
|
|
496
|
|
|
/** |
|
497
|
|
|
* Show pop-up menu of the selected posts |
|
498
|
|
|
* Printing, scrap, recommendations and negative, reported the Add Features |
|
499
|
|
|
* @return void |
|
500
|
|
|
*/ |
|
501
|
|
|
function getDocumentMenu() |
|
502
|
|
|
{ |
|
503
|
|
|
// Post number and the current login information requested Wanted |
|
504
|
|
|
$document_srl = Context::get('target_srl'); |
|
505
|
|
|
$mid = Context::get('cur_mid'); |
|
|
|
|
|
|
506
|
|
|
$logged_info = Context::get('logged_info'); |
|
507
|
|
|
$act = Context::get('cur_act'); |
|
|
|
|
|
|
508
|
|
|
// to menu_list "pyosihalgeul, target, url" put into an array |
|
509
|
|
|
$menu_list = array(); |
|
510
|
|
|
// call trigger |
|
511
|
|
|
ModuleHandler::triggerCall('document.getDocumentMenu', 'before', $menu_list); |
|
|
|
|
|
|
512
|
|
|
|
|
513
|
|
|
$oDocumentController = getController('document'); |
|
514
|
|
|
// Members must be a possible feature |
|
515
|
|
|
if($logged_info->member_srl) |
|
516
|
|
|
{ |
|
517
|
|
|
$oDocumentModel = getModel('document'); |
|
518
|
|
|
$columnList = array('document_srl', 'module_srl', 'member_srl', 'ipaddress'); |
|
519
|
|
|
$oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
|
520
|
|
|
$module_srl = $oDocument->get('module_srl'); |
|
521
|
|
|
$member_srl = $oDocument->get('member_srl'); |
|
522
|
|
|
if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
523
|
|
|
|
|
524
|
|
|
$oModuleModel = getModel('module'); |
|
525
|
|
|
$document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
526
|
|
View Code Duplication |
if($document_config->use_vote_up!='N' && $member_srl!=$logged_info->member_srl) |
|
527
|
|
|
{ |
|
528
|
|
|
// Add a Referral Button |
|
529
|
|
|
$url = sprintf("doCallModuleAction('document','procDocumentVoteUp','%s')", $document_srl); |
|
530
|
|
|
$oDocumentController->addDocumentPopupMenu($url,'cmd_vote','','javascript'); |
|
531
|
|
|
} |
|
532
|
|
|
|
|
533
|
|
View Code Duplication |
if($document_config->use_vote_down!='N' && $member_srl!=$logged_info->member_srl) |
|
534
|
|
|
{ |
|
535
|
|
|
// Add button to negative |
|
536
|
|
|
$url= sprintf("doCallModuleAction('document','procDocumentVoteDown','%s')", $document_srl); |
|
537
|
|
|
$oDocumentController->addDocumentPopupMenu($url,'cmd_vote_down','','javascript'); |
|
538
|
|
|
} |
|
539
|
|
|
|
|
540
|
|
|
// Adding Report |
|
541
|
|
|
$url = sprintf("doCallModuleAction('document','procDocumentDeclare','%s')", $document_srl); |
|
542
|
|
|
$oDocumentController->addDocumentPopupMenu($url,'cmd_declare','','javascript'); |
|
543
|
|
|
|
|
544
|
|
|
// Add Bookmark button |
|
545
|
|
|
$url = sprintf("doCallModuleAction('member','procMemberScrapDocument','%s')", $document_srl); |
|
546
|
|
|
$oDocumentController->addDocumentPopupMenu($url,'cmd_scrap','','javascript'); |
|
547
|
|
|
} |
|
548
|
|
|
// Add print button |
|
549
|
|
|
$url = getUrl('','module','document','act','dispDocumentPrint','document_srl',$document_srl); |
|
550
|
|
|
$oDocumentController->addDocumentPopupMenu($url,'cmd_print','','printDocument'); |
|
551
|
|
|
// Call a trigger (after) |
|
552
|
|
|
ModuleHandler::triggerCall('document.getDocumentMenu', 'after', $menu_list); |
|
553
|
|
View Code Duplication |
if($this->grant->manager) |
|
|
|
|
|
|
554
|
|
|
{ |
|
555
|
|
|
$str_confirm = Context::getLang('confirm_move'); |
|
556
|
|
|
$url = sprintf("if(!confirm('%s')) return; var params = new Array(); params['document_srl']='%s'; params['mid']=current_mid;params['cur_url']=current_url; exec_xml('document', 'procDocumentAdminMoveToTrash', params)", $str_confirm, $document_srl); |
|
557
|
|
|
$oDocumentController->addDocumentPopupMenu($url,'cmd_trash','','javascript'); |
|
558
|
|
|
} |
|
559
|
|
|
|
|
560
|
|
|
// If you are managing to find posts by ip |
|
561
|
|
View Code Duplication |
if($logged_info->is_admin == 'Y') |
|
562
|
|
|
{ |
|
563
|
|
|
$oDocumentModel = getModel('document'); |
|
564
|
|
|
$oDocument = $oDocumentModel->getDocument($document_srl); //before setting document recycle |
|
565
|
|
|
|
|
566
|
|
|
if($oDocument->isExists()) |
|
567
|
|
|
{ |
|
568
|
|
|
// Find a post equivalent to ip address |
|
569
|
|
|
$url = getUrl('','module','admin','act','dispDocumentAdminList','search_target','ipaddress','search_keyword',$oDocument->getIpAddress()); |
|
570
|
|
|
$oDocumentController->addDocumentPopupMenu($url,'cmd_search_by_ipaddress',$icon_path,'TraceByIpaddress'); |
|
|
|
|
|
|
571
|
|
|
|
|
572
|
|
|
$url = sprintf("var params = new Array(); params['ipaddress_list']='%s'; exec_xml('spamfilter', 'procSpamfilterAdminInsertDeniedIP', params, completeCallModuleAction)", $oDocument->getIpAddress()); |
|
573
|
|
|
$oDocumentController->addDocumentPopupMenu($url,'cmd_add_ip_to_spamfilter','','javascript'); |
|
574
|
|
|
} |
|
575
|
|
|
} |
|
576
|
|
|
// Changing the language of pop-up menu |
|
577
|
|
|
$menus = Context::get('document_popup_menu_list'); |
|
578
|
|
|
$menus_count = count($menus); |
|
579
|
|
View Code Duplication |
for($i=0;$i<$menus_count;$i++) |
|
580
|
|
|
{ |
|
581
|
|
|
$menus[$i]->str = Context::getLang($menus[$i]->str); |
|
582
|
|
|
} |
|
583
|
|
|
// Wanted to finally clean pop-up menu list |
|
584
|
|
|
$this->add('menus', $menus); |
|
585
|
|
|
} |
|
586
|
|
|
|
|
587
|
|
|
/** |
|
588
|
|
|
* The total number of documents that are bringing |
|
589
|
|
|
* @param int $module_srl |
|
590
|
|
|
* @param object $search_obj |
|
591
|
|
|
* @return int |
|
592
|
|
|
*/ |
|
593
|
|
|
function getDocumentCount($module_srl, $search_obj = NULL) |
|
594
|
|
|
{ |
|
595
|
|
|
if(is_null($search_obj)) $search_obj = new stdClass(); |
|
596
|
|
|
$search_obj->module_srl = $module_srl; |
|
597
|
|
|
|
|
598
|
|
|
$output = executeQuery('document.getDocumentCount', $search_obj); |
|
599
|
|
|
// Return total number of |
|
600
|
|
|
$total_count = $output->data->count; |
|
601
|
|
|
return (int)$total_count; |
|
602
|
|
|
} |
|
603
|
|
|
|
|
604
|
|
|
/** |
|
605
|
|
|
* the total number of documents that are bringing |
|
606
|
|
|
* @param object $search_obj |
|
607
|
|
|
* @return array |
|
608
|
|
|
*/ |
|
609
|
|
|
function getDocumentCountByGroupStatus($search_obj = NULL) |
|
610
|
|
|
{ |
|
611
|
|
|
$output = executeQuery('document.getDocumentCountByGroupStatus', $search_obj); |
|
612
|
|
|
if(!$output->toBool()) return array(); |
|
613
|
|
|
|
|
614
|
|
|
return $output->data; |
|
615
|
|
|
} |
|
616
|
|
|
|
|
617
|
|
|
function getDocumentExtraVarsCount($module_srl, $search_obj = NULL) |
|
618
|
|
|
{ |
|
619
|
|
|
// Additional search options |
|
620
|
|
|
$args->module_srl = $module_srl; |
|
|
|
|
|
|
621
|
|
|
|
|
622
|
|
|
$args->category_srl = $search_obj->category_srl; |
|
623
|
|
|
$args->var_idx = $search_obj->s_var_idx; |
|
624
|
|
|
$args->var_eid = $search_obj->s_var_eid; |
|
625
|
|
|
$args->var_value = $search_obj->s_var_value; |
|
626
|
|
|
$args->var_lang_code = Context::getLangType(); |
|
627
|
|
|
|
|
628
|
|
|
$output = executeQuery('document.getDocumentExtraVarsCount', $args); |
|
629
|
|
|
// Return total number of |
|
630
|
|
|
$total_count = $output->data->count; |
|
631
|
|
|
return (int)$total_count; |
|
632
|
|
|
} |
|
633
|
|
|
|
|
634
|
|
|
/** |
|
635
|
|
|
* Import page of the document, module_srl Without throughout .. |
|
636
|
|
|
* @param documentItem $oDocument |
|
637
|
|
|
* @param object $opt |
|
638
|
|
|
* @return int |
|
639
|
|
|
*/ |
|
640
|
|
|
function getDocumentPage($oDocument, $opt) |
|
641
|
|
|
{ |
|
642
|
|
|
$sort_check = $this->_setSortIndex($opt, TRUE); |
|
643
|
|
|
$opt->sort_index = $sort_check->sort_index; |
|
644
|
|
|
$opt->isExtraVars = $sort_check->isExtraVars; |
|
645
|
|
|
|
|
646
|
|
|
$this->_setSearchOption($opt, $args, $query_id, $use_division); |
|
647
|
|
|
|
|
648
|
|
|
if($sort_check->isExtraVars) |
|
649
|
|
|
{ |
|
650
|
|
|
return 1; |
|
651
|
|
|
} |
|
652
|
|
|
else |
|
653
|
|
|
{ |
|
654
|
|
|
if($sort_check->sort_index === 'list_order' || $sort_check->sort_index === 'update_order') |
|
655
|
|
|
{ |
|
656
|
|
View Code Duplication |
if($args->order_type === 'desc') |
|
657
|
|
|
{ |
|
658
|
|
|
$args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
659
|
|
|
} |
|
660
|
|
|
else |
|
661
|
|
|
{ |
|
662
|
|
|
$args->{$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
663
|
|
|
} |
|
664
|
|
|
} |
|
665
|
|
View Code Duplication |
elseif($sort_check->sort_index === 'regdate') |
|
666
|
|
|
{ |
|
667
|
|
|
|
|
668
|
|
|
if($args->order_type === 'asc') |
|
669
|
|
|
{ |
|
670
|
|
|
$args->{'rev_' . $sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
671
|
|
|
} |
|
672
|
|
|
else |
|
673
|
|
|
{ |
|
674
|
|
|
$args->{$sort_check->sort_index} = $oDocument->get($sort_check->sort_index); |
|
675
|
|
|
} |
|
676
|
|
|
|
|
677
|
|
|
} |
|
678
|
|
|
else |
|
679
|
|
|
{ |
|
680
|
|
|
return 1; |
|
681
|
|
|
} |
|
682
|
|
|
} |
|
683
|
|
|
|
|
684
|
|
|
// Guhanhu total number of the article search page |
|
685
|
|
|
$output = executeQuery($query_id . 'Page', $args); |
|
686
|
|
|
$count = $output->data->count; |
|
687
|
|
|
$page = (int)(($count-1)/$opt->list_count)+1; |
|
688
|
|
|
return $page; |
|
689
|
|
|
} |
|
690
|
|
|
|
|
691
|
|
|
/** |
|
692
|
|
|
* Imported Category of information |
|
693
|
|
|
* @param int $category_srl |
|
694
|
|
|
* @param array $columnList |
|
695
|
|
|
* @return object |
|
696
|
|
|
*/ |
|
697
|
|
|
function getCategory($category_srl, $columnList = array()) |
|
698
|
|
|
{ |
|
699
|
|
|
$args =new stdClass(); |
|
700
|
|
|
$args->category_srl = $category_srl; |
|
701
|
|
|
$output = executeQuery('document.getCategory', $args, $columnList); |
|
702
|
|
|
|
|
703
|
|
|
$node = $output->data; |
|
704
|
|
|
if(!$node) return; |
|
705
|
|
|
|
|
706
|
|
|
if($node->group_srls) |
|
707
|
|
|
{ |
|
708
|
|
|
$group_srls = explode(',',$node->group_srls); |
|
709
|
|
|
unset($node->group_srls); |
|
710
|
|
|
$node->group_srls = $group_srls; |
|
711
|
|
|
} |
|
712
|
|
|
else |
|
713
|
|
|
{ |
|
714
|
|
|
unset($node->group_srls); |
|
715
|
|
|
$node->group_srls = array(); |
|
716
|
|
|
} |
|
717
|
|
|
return $node; |
|
718
|
|
|
} |
|
719
|
|
|
|
|
720
|
|
|
/** |
|
721
|
|
|
* Check whether the child has a specific category |
|
722
|
|
|
* @param int $category_srl |
|
723
|
|
|
* @return bool |
|
724
|
|
|
*/ |
|
725
|
|
|
function getCategoryChlidCount($category_srl) |
|
726
|
|
|
{ |
|
727
|
|
|
$args = new stdClass(); |
|
728
|
|
|
$args->category_srl = $category_srl; |
|
729
|
|
|
$output = executeQuery('document.getChildCategoryCount',$args); |
|
730
|
|
|
if($output->data->count > 0) return true; |
|
731
|
|
|
return false; |
|
732
|
|
|
} |
|
733
|
|
|
|
|
734
|
|
|
/** |
|
735
|
|
|
* Bringing the Categories list the specific module |
|
736
|
|
|
* Speed and variety of categories, considering the situation created by the php script to include a list of the must, in principle, to use |
|
737
|
|
|
* @param int $module_srl |
|
738
|
|
|
* @param array $columnList |
|
739
|
|
|
* @return array |
|
740
|
|
|
*/ |
|
741
|
|
|
function getCategoryList($module_srl, $columnList = array()) |
|
742
|
|
|
{ |
|
743
|
|
|
// Category of the target module file swollen |
|
744
|
|
|
$filename = sprintf("%sfiles/cache/document_category/%s.php", _XE_PATH_, $module_srl); |
|
745
|
|
|
// If the target file to the cache file regeneration category |
|
746
|
|
|
if(!file_exists($filename)) |
|
747
|
|
|
{ |
|
748
|
|
|
$oDocumentController = getController('document'); |
|
749
|
|
|
if(!$oDocumentController->makeCategoryFile($module_srl)) return array(); |
|
750
|
|
|
} |
|
751
|
|
|
|
|
752
|
|
|
include($filename); |
|
753
|
|
|
|
|
754
|
|
|
// Cleanup of category |
|
755
|
|
|
$document_category = array(); |
|
756
|
|
|
$this->_arrangeCategory($document_category, $menu->list, 0); |
|
|
|
|
|
|
757
|
|
|
return $document_category; |
|
758
|
|
|
} |
|
759
|
|
|
|
|
760
|
|
|
/** |
|
761
|
|
|
* Category within a primary method to change the array type |
|
762
|
|
|
* @param array $document_category |
|
763
|
|
|
* @param array $list |
|
764
|
|
|
* @param int $depth |
|
765
|
|
|
* @return void |
|
766
|
|
|
*/ |
|
767
|
|
|
function _arrangeCategory(&$document_category, $list, $depth) |
|
768
|
|
|
{ |
|
769
|
|
|
if(!count($list)) return; |
|
770
|
|
|
$idx = 0; |
|
771
|
|
|
$list_order = array(); |
|
772
|
|
|
foreach($list as $key => $val) |
|
773
|
|
|
{ |
|
774
|
|
|
$obj = new stdClass; |
|
775
|
|
|
$obj->mid = $val['mid']; |
|
776
|
|
|
$obj->module_srl = $val['module_srl']; |
|
777
|
|
|
$obj->category_srl = $val['category_srl']; |
|
778
|
|
|
$obj->parent_srl = $val['parent_srl']; |
|
779
|
|
|
$obj->title = $obj->text = $val['text']; |
|
780
|
|
|
$obj->description = $val['description']; |
|
781
|
|
|
$obj->expand = $val['expand']=='Y'?true:false; |
|
782
|
|
|
$obj->color = $val['color']; |
|
783
|
|
|
$obj->document_count = $val['document_count']; |
|
784
|
|
|
$obj->depth = $depth; |
|
785
|
|
|
$obj->child_count = 0; |
|
786
|
|
|
$obj->childs = array(); |
|
787
|
|
|
$obj->grant = $val['grant']; |
|
788
|
|
|
|
|
789
|
|
|
if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true; |
|
790
|
|
|
else $selected = false; |
|
791
|
|
|
|
|
792
|
|
|
$obj->selected = $selected; |
|
793
|
|
|
|
|
794
|
|
|
$list_order[$idx++] = $obj->category_srl; |
|
795
|
|
|
// If you have a parent category of child nodes apply data |
|
796
|
|
|
if($obj->parent_srl) |
|
797
|
|
|
{ |
|
798
|
|
|
$parent_srl = $obj->parent_srl; |
|
799
|
|
|
$document_count = $obj->document_count; |
|
800
|
|
|
$expand = $obj->expand; |
|
801
|
|
|
if($selected) $expand = true; |
|
802
|
|
|
|
|
803
|
|
|
while($parent_srl) |
|
804
|
|
|
{ |
|
805
|
|
|
$document_category[$parent_srl]->document_count += $document_count; |
|
806
|
|
|
$document_category[$parent_srl]->childs[] = $obj->category_srl; |
|
807
|
|
|
$document_category[$parent_srl]->child_count = count($document_category[$parent_srl]->childs); |
|
808
|
|
|
if($expand) $document_category[$parent_srl]->expand = $expand; |
|
809
|
|
|
|
|
810
|
|
|
$parent_srl = $document_category[$parent_srl]->parent_srl; |
|
811
|
|
|
} |
|
812
|
|
|
} |
|
813
|
|
|
|
|
814
|
|
|
$document_category[$key] = $obj; |
|
815
|
|
|
|
|
816
|
|
|
if(count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth+1); |
|
817
|
|
|
} |
|
818
|
|
|
$document_category[$list_order[0]]->first = true; |
|
819
|
|
|
$document_category[$list_order[count($list_order)-1]]->last = true; |
|
820
|
|
|
} |
|
821
|
|
|
|
|
822
|
|
|
/** |
|
823
|
|
|
* Wanted number of documents belonging to category |
|
824
|
|
|
* @param int $module_srl |
|
825
|
|
|
* @param int $category_srl |
|
826
|
|
|
* @return int |
|
827
|
|
|
*/ |
|
828
|
|
|
function getCategoryDocumentCount($module_srl, $category_srl) |
|
829
|
|
|
{ |
|
830
|
|
|
$args = new stdClass; |
|
831
|
|
|
$args->module_srl = $module_srl; |
|
832
|
|
|
$args->category_srl = $category_srl; |
|
833
|
|
|
$output = executeQuery('document.getCategoryDocumentCount', $args); |
|
834
|
|
|
return (int)$output->data->count; |
|
835
|
|
|
} |
|
836
|
|
|
|
|
837
|
|
|
/** |
|
838
|
|
|
* Xml cache file of the document category return information |
|
839
|
|
|
* @param int $module_srl |
|
840
|
|
|
* @return string |
|
841
|
|
|
*/ |
|
842
|
|
View Code Duplication |
function getCategoryXmlFile($module_srl) |
|
|
|
|
|
|
843
|
|
|
{ |
|
844
|
|
|
$xml_file = sprintf('files/cache/document_category/%s.xml.php',$module_srl); |
|
845
|
|
|
if(!file_exists($xml_file)) |
|
846
|
|
|
{ |
|
847
|
|
|
$oDocumentController = getController('document'); |
|
848
|
|
|
$oDocumentController->makeCategoryFile($module_srl); |
|
849
|
|
|
} |
|
850
|
|
|
return $xml_file; |
|
851
|
|
|
} |
|
852
|
|
|
|
|
853
|
|
|
/** |
|
854
|
|
|
* Php cache files in the document category return information |
|
855
|
|
|
* @param int $module_srl |
|
856
|
|
|
* @return string |
|
857
|
|
|
*/ |
|
858
|
|
View Code Duplication |
function getCategoryPhpFile($module_srl) |
|
|
|
|
|
|
859
|
|
|
{ |
|
860
|
|
|
$php_file = sprintf('files/cache/document_category/%s.php',$module_srl); |
|
861
|
|
|
if(!file_exists($php_file)) |
|
862
|
|
|
{ |
|
863
|
|
|
$oDocumentController = getController('document'); |
|
864
|
|
|
$oDocumentController->makeCategoryFile($module_srl); |
|
865
|
|
|
} |
|
866
|
|
|
return $php_file; |
|
867
|
|
|
} |
|
868
|
|
|
|
|
869
|
|
|
/** |
|
870
|
|
|
* Imported post monthly archive status |
|
871
|
|
|
* @param object $obj |
|
872
|
|
|
* @return object |
|
873
|
|
|
*/ |
|
874
|
|
View Code Duplication |
function getMonthlyArchivedList($obj) |
|
|
|
|
|
|
875
|
|
|
{ |
|
876
|
|
|
if($obj->mid) |
|
877
|
|
|
{ |
|
878
|
|
|
$oModuleModel = getModel('module'); |
|
879
|
|
|
$obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
|
880
|
|
|
unset($obj->mid); |
|
881
|
|
|
} |
|
882
|
|
|
// Module_srl passed the array may be a check whether the array |
|
883
|
|
|
$args = new stdClass; |
|
884
|
|
|
if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
885
|
|
|
else $args->module_srl = $obj->module_srl; |
|
886
|
|
|
|
|
887
|
|
|
$output = executeQuery('document.getMonthlyArchivedList', $args); |
|
888
|
|
|
if(!$output->toBool()||!$output->data) return $output; |
|
889
|
|
|
|
|
890
|
|
|
if(!is_array($output->data)) $output->data = array($output->data); |
|
891
|
|
|
|
|
892
|
|
|
return $output; |
|
893
|
|
|
} |
|
894
|
|
|
|
|
895
|
|
|
/** |
|
896
|
|
|
* Bringing a month on the status of the daily posts |
|
897
|
|
|
* @param object $obj |
|
898
|
|
|
* @return object |
|
899
|
|
|
*/ |
|
900
|
|
View Code Duplication |
function getDailyArchivedList($obj) |
|
|
|
|
|
|
901
|
|
|
{ |
|
902
|
|
|
if($obj->mid) |
|
903
|
|
|
{ |
|
904
|
|
|
$oModuleModel = getModel('module'); |
|
905
|
|
|
$obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
|
906
|
|
|
unset($obj->mid); |
|
907
|
|
|
} |
|
908
|
|
|
// Module_srl passed the array may be a check whether the array |
|
909
|
|
|
$args = new stdClass; |
|
910
|
|
|
if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl); |
|
911
|
|
|
else $args->module_srl = $obj->module_srl; |
|
912
|
|
|
$args->regdate = $obj->regdate; |
|
913
|
|
|
|
|
914
|
|
|
$output = executeQuery('document.getDailyArchivedList', $args); |
|
915
|
|
|
if(!$output->toBool()) return $output; |
|
916
|
|
|
|
|
917
|
|
|
if(!is_array($output->data)) $output->data = array($output->data); |
|
918
|
|
|
|
|
919
|
|
|
return $output; |
|
920
|
|
|
} |
|
921
|
|
|
|
|
922
|
|
|
/** |
|
923
|
|
|
* Get a list for a particular module |
|
924
|
|
|
* @return void|Object |
|
925
|
|
|
*/ |
|
926
|
|
|
function getDocumentCategories() |
|
927
|
|
|
{ |
|
928
|
|
|
if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
929
|
|
|
$module_srl = Context::get('module_srl'); |
|
930
|
|
|
$categories= $this->getCategoryList($module_srl); |
|
931
|
|
|
$lang = Context::get('lang'); |
|
932
|
|
|
// No additional category |
|
933
|
|
|
$output = "0,0,{$lang->none_category}\n"; |
|
934
|
|
|
if($categories) |
|
|
|
|
|
|
935
|
|
|
{ |
|
936
|
|
|
foreach($categories as $category_srl => $category) |
|
937
|
|
|
{ |
|
938
|
|
|
$output .= sprintf("%d,%d,%s\n",$category_srl, $category->depth,$category->title); |
|
939
|
|
|
} |
|
940
|
|
|
} |
|
941
|
|
|
$this->add('categories', $output); |
|
942
|
|
|
} |
|
943
|
|
|
|
|
944
|
|
|
/** |
|
945
|
|
|
* Wanted to set document information |
|
946
|
|
|
* @return object |
|
947
|
|
|
*/ |
|
948
|
|
|
function getDocumentConfig() |
|
949
|
|
|
{ |
|
950
|
|
|
if($this->documentConfig === NULL) |
|
951
|
|
|
{ |
|
952
|
|
|
$oModuleModel = getModel('module'); |
|
953
|
|
|
$config = $oModuleModel->getModuleConfig('document'); |
|
954
|
|
|
|
|
955
|
|
|
if (!$config) |
|
956
|
|
|
{ |
|
957
|
|
|
$config = new stdClass(); |
|
958
|
|
|
} |
|
959
|
|
|
$this->documentConfig = $config; |
|
960
|
|
|
} |
|
961
|
|
|
return $this->documentConfig; |
|
962
|
|
|
} |
|
963
|
|
|
|
|
964
|
|
|
/** |
|
965
|
|
|
* Common:: Module extensions of variable management |
|
966
|
|
|
* Expansion parameter management module in the document module instance, when using all the modules available |
|
967
|
|
|
* @param int $module_srl |
|
968
|
|
|
* @return string |
|
969
|
|
|
*/ |
|
970
|
|
|
function getExtraVarsHTML($module_srl) |
|
971
|
|
|
{ |
|
972
|
|
|
// Bringing existing extra_keys |
|
973
|
|
|
$extra_keys = $this->getExtraKeys($module_srl); |
|
974
|
|
|
Context::set('extra_keys', $extra_keys); |
|
975
|
|
|
$security = new Security(); |
|
976
|
|
|
$security->encodeHTML('extra_keys..'); |
|
977
|
|
|
|
|
978
|
|
|
// Get information of module_grants |
|
979
|
|
|
$oTemplate = &TemplateHandler::getInstance(); |
|
980
|
|
|
return $oTemplate->compile($this->module_path.'tpl', 'extra_keys'); |
|
981
|
|
|
} |
|
982
|
|
|
|
|
983
|
|
|
/** |
|
984
|
|
|
* Common:: Category parameter management module |
|
985
|
|
|
* @param int $module_srl |
|
986
|
|
|
* @return string |
|
987
|
|
|
*/ |
|
988
|
|
|
function getCategoryHTML($module_srl) |
|
989
|
|
|
{ |
|
990
|
|
|
$category_xml_file = $this->getCategoryXmlFile($module_srl); |
|
991
|
|
|
|
|
992
|
|
|
Context::set('category_xml_file', $category_xml_file); |
|
993
|
|
|
|
|
994
|
|
|
Context::loadJavascriptPlugin('ui.tree'); |
|
995
|
|
|
|
|
996
|
|
|
// Get a list of member groups |
|
997
|
|
|
$oMemberModel = getModel('member'); |
|
998
|
|
|
$group_list = $oMemberModel->getGroups($module_info->site_srl); |
|
|
|
|
|
|
999
|
|
|
Context::set('group_list', $group_list); |
|
1000
|
|
|
|
|
1001
|
|
|
$security = new Security(); |
|
1002
|
|
|
$security->encodeHTML('group_list..title'); |
|
1003
|
|
|
|
|
1004
|
|
|
// Get information of module_grants |
|
1005
|
|
|
$oTemplate = &TemplateHandler::getInstance(); |
|
1006
|
|
|
return $oTemplate->compile($this->module_path.'tpl', 'category_list'); |
|
1007
|
|
|
} |
|
1008
|
|
|
|
|
1009
|
|
|
/** |
|
1010
|
|
|
* Certain categories of information, return the template guhanhu |
|
1011
|
|
|
* Manager on the page to add information about a particular menu from the server after compiling tpl compiled a direct return html |
|
1012
|
|
|
* @return void|Object |
|
1013
|
|
|
*/ |
|
1014
|
|
|
function getDocumentCategoryTplInfo() |
|
1015
|
|
|
{ |
|
1016
|
|
|
$oModuleModel = getModel('module'); |
|
1017
|
|
|
$oMemberModel = getModel('member'); |
|
|
|
|
|
|
1018
|
|
|
// Get information on the menu for the parameter settings |
|
1019
|
|
|
$module_srl = Context::get('module_srl'); |
|
1020
|
|
|
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
|
1021
|
|
|
// Check permissions |
|
1022
|
|
|
$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
|
1023
|
|
|
if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
1024
|
|
|
|
|
1025
|
|
|
$category_srl = Context::get('category_srl'); |
|
1026
|
|
|
$category_info = $this->getCategory($category_srl); |
|
1027
|
|
|
if(!$category_info) |
|
1028
|
|
|
{ |
|
1029
|
|
|
return new Object(-1, 'msg_invalid_request'); |
|
1030
|
|
|
} |
|
1031
|
|
|
|
|
1032
|
|
|
$this->add('category_info', $category_info); |
|
1033
|
|
|
} |
|
1034
|
|
|
|
|
1035
|
|
|
/** |
|
1036
|
|
|
* Return docuent data by alias |
|
1037
|
|
|
* @param string $mid |
|
1038
|
|
|
* @param string $alias |
|
1039
|
|
|
* @return int|void |
|
1040
|
|
|
*/ |
|
1041
|
|
|
function getDocumentSrlByAlias($mid, $alias) |
|
1042
|
|
|
{ |
|
1043
|
|
|
if(!$mid || !$alias) return null; |
|
1044
|
|
|
$site_module_info = Context::get('site_module_info'); |
|
1045
|
|
|
$args = new stdClass; |
|
1046
|
|
|
$args->mid = $mid; |
|
1047
|
|
|
$args->alias_title = $alias; |
|
1048
|
|
|
$args->site_srl = $site_module_info->site_srl; |
|
1049
|
|
|
$output = executeQuery('document.getDocumentSrlByAlias', $args); |
|
1050
|
|
|
if(!$output->data) return null; |
|
1051
|
|
|
else return $output->data->document_srl; |
|
1052
|
|
|
} |
|
1053
|
|
|
|
|
1054
|
|
|
/** |
|
1055
|
|
|
* Return docuent number by document title |
|
1056
|
|
|
* @param int $module_srl |
|
1057
|
|
|
* @param string $title |
|
1058
|
|
|
* @return int|void |
|
1059
|
|
|
*/ |
|
1060
|
|
|
function getDocumentSrlByTitle($module_srl, $title) |
|
1061
|
|
|
{ |
|
1062
|
|
|
if(!$module_srl || !$title) return null; |
|
1063
|
|
|
$args = new stdClass; |
|
1064
|
|
|
$args->module_srl = $module_srl; |
|
1065
|
|
|
$args->title = $title; |
|
1066
|
|
|
$output = executeQuery('document.getDocumentSrlByTitle', $args); |
|
1067
|
|
|
if(!$output->data) return null; |
|
1068
|
|
|
else |
|
1069
|
|
|
{ |
|
1070
|
|
|
if(is_array($output->data)) return $output->data[0]->document_srl; |
|
1071
|
|
|
return $output->data->document_srl; |
|
1072
|
|
|
} |
|
1073
|
|
|
} |
|
1074
|
|
|
|
|
1075
|
|
|
/** |
|
1076
|
|
|
* Return docuent's alias |
|
1077
|
|
|
* @param int $document_srl |
|
1078
|
|
|
* @return string|void |
|
1079
|
|
|
*/ |
|
1080
|
|
|
function getAlias($document_srl) |
|
1081
|
|
|
{ |
|
1082
|
|
|
if(!$document_srl) return null; |
|
1083
|
|
|
$args = new stdClass; |
|
1084
|
|
|
$args->document_srl = $document_srl; |
|
1085
|
|
|
$output = executeQueryArray('document.getAliases', $args); |
|
1086
|
|
|
|
|
1087
|
|
|
if(!$output->data) return null; |
|
1088
|
|
|
else return $output->data[0]->alias_title; |
|
1089
|
|
|
} |
|
1090
|
|
|
|
|
1091
|
|
|
/** |
|
1092
|
|
|
* Return document's history list |
|
1093
|
|
|
* @param int $document_srl |
|
1094
|
|
|
* @param int $list_count |
|
1095
|
|
|
* @param int $page |
|
1096
|
|
|
* @return object |
|
1097
|
|
|
*/ |
|
1098
|
|
|
function getHistories($document_srl, $list_count, $page) |
|
1099
|
|
|
{ |
|
1100
|
|
|
$args = new stdClass; |
|
1101
|
|
|
$args->list_count = $list_count; |
|
1102
|
|
|
$args->page = $page; |
|
1103
|
|
|
$args->document_srl = $document_srl; |
|
1104
|
|
|
$output = executeQueryArray('document.getHistories', $args); |
|
1105
|
|
|
return $output; |
|
1106
|
|
|
} |
|
1107
|
|
|
|
|
1108
|
|
|
/** |
|
1109
|
|
|
* Return document's history |
|
1110
|
|
|
* @param int $history_srl |
|
1111
|
|
|
* @return object |
|
1112
|
|
|
*/ |
|
1113
|
|
|
function getHistory($history_srl) |
|
1114
|
|
|
{ |
|
1115
|
|
|
$args = new stdClass; |
|
1116
|
|
|
$args->history_srl = $history_srl; |
|
1117
|
|
|
$output = executeQuery('document.getHistory', $args); |
|
1118
|
|
|
return $output->data; |
|
1119
|
|
|
} |
|
1120
|
|
|
|
|
1121
|
|
|
/** |
|
1122
|
|
|
* Module_srl value, bringing the list of documents |
|
1123
|
|
|
* @param object $obj |
|
1124
|
|
|
* @return object |
|
1125
|
|
|
*/ |
|
1126
|
|
|
function getTrashList($obj) |
|
1127
|
|
|
{ |
|
1128
|
|
|
// Variable check |
|
1129
|
|
|
$args = new stdClass; |
|
1130
|
|
|
$args->category_srl = $obj->category_srl?$obj->category_srl:null; |
|
1131
|
|
|
$args->sort_index = $obj->sort_index; |
|
1132
|
|
|
$args->order_type = $obj->order_type?$obj->order_type:'desc'; |
|
1133
|
|
|
$args->page = $obj->page?$obj->page:1; |
|
1134
|
|
|
$args->list_count = $obj->list_count?$obj->list_count:20; |
|
1135
|
|
|
$args->page_count = $obj->page_count?$obj->page_count:10; |
|
1136
|
|
|
// Search options |
|
1137
|
|
|
$search_target = $obj->search_target; |
|
1138
|
|
|
$search_keyword = $obj->search_keyword; |
|
1139
|
|
|
if($search_target && $search_keyword) |
|
1140
|
|
|
{ |
|
1141
|
|
|
switch($search_target) |
|
1142
|
|
|
{ |
|
1143
|
|
|
case 'title' : |
|
1144
|
|
View Code Duplication |
case 'content' : |
|
1145
|
|
|
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1146
|
|
|
$args->{"s_".$search_target} = $search_keyword; |
|
1147
|
|
|
$use_division = true; |
|
|
|
|
|
|
1148
|
|
|
break; |
|
1149
|
|
View Code Duplication |
case 'title_content' : |
|
1150
|
|
|
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1151
|
|
|
$args->s_title = $search_keyword; |
|
1152
|
|
|
$args->s_content = $search_keyword; |
|
1153
|
|
|
break; |
|
1154
|
|
View Code Duplication |
case 'user_id' : |
|
1155
|
|
|
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1156
|
|
|
$args->s_user_id = $search_keyword; |
|
1157
|
|
|
$args->sort_index = 'documents.'.$args->sort_index; |
|
1158
|
|
|
break; |
|
1159
|
|
|
case 'user_name' : |
|
1160
|
|
|
case 'nick_name' : |
|
1161
|
|
|
case 'email_address' : |
|
1162
|
|
View Code Duplication |
case 'homepage' : |
|
1163
|
|
|
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1164
|
|
|
$args->{"s_".$search_target} = $search_keyword; |
|
1165
|
|
|
break; |
|
1166
|
|
|
case 'is_notice' : |
|
1167
|
|
|
case 'is_secret' : |
|
1168
|
|
|
if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
1169
|
|
|
elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
1170
|
|
|
break; |
|
1171
|
|
|
case 'member_srl' : |
|
1172
|
|
|
case 'readed_count' : |
|
1173
|
|
|
case 'voted_count' : |
|
1174
|
|
|
case 'blamed_count' : |
|
1175
|
|
|
case 'comment_count' : |
|
1176
|
|
|
case 'trackback_count' : |
|
1177
|
|
|
case 'uploaded_count' : |
|
1178
|
|
|
$args->{"s_".$search_target} = (int)$search_keyword; |
|
1179
|
|
|
break; |
|
1180
|
|
|
case 'regdate' : |
|
1181
|
|
|
case 'last_update' : |
|
1182
|
|
|
case 'ipaddress' : |
|
1183
|
|
|
case 'tag' : |
|
1184
|
|
|
$args->{"s_".$search_target} = $search_keyword; |
|
1185
|
|
|
break; |
|
1186
|
|
|
} |
|
1187
|
|
|
} |
|
1188
|
|
|
|
|
1189
|
|
|
$output = executeQueryArray('document.getTrashList', $args); |
|
1190
|
|
|
if($output->data) |
|
1191
|
|
|
{ |
|
1192
|
|
|
foreach($output->data as $key => $attribute) |
|
1193
|
|
|
{ |
|
1194
|
|
|
$oDocument = null; |
|
|
|
|
|
|
1195
|
|
|
$oDocument = new documentItem(); |
|
1196
|
|
|
$oDocument->setAttribute($attribute, false); |
|
1197
|
|
|
$attribute = $oDocument; |
|
1198
|
|
|
} |
|
1199
|
|
|
} |
|
1200
|
|
|
return $output; |
|
1201
|
|
|
} |
|
1202
|
|
|
|
|
1203
|
|
|
/** |
|
1204
|
|
|
* vote up, vote down member list in Document View page |
|
1205
|
|
|
* @return void|Object |
|
1206
|
|
|
*/ |
|
1207
|
|
|
function getDocumentVotedMemberList() |
|
1208
|
|
|
{ |
|
1209
|
|
|
$args = new stdClass; |
|
1210
|
|
|
$document_srl = Context::get('document_srl'); |
|
1211
|
|
|
if(!$document_srl) return new Object(-1,'msg_invalid_request'); |
|
1212
|
|
|
|
|
1213
|
|
|
$point = Context::get('point'); |
|
1214
|
|
|
if($point != -1) $point = 1; |
|
1215
|
|
|
|
|
1216
|
|
|
$oDocumentModel = getModel('document'); |
|
1217
|
|
|
$columnList = array('document_srl', 'module_srl'); |
|
1218
|
|
|
$oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList); |
|
1219
|
|
|
$module_srl = $oDocument->get('module_srl'); |
|
1220
|
|
|
if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
1221
|
|
|
|
|
1222
|
|
|
$oModuleModel = getModel('module'); |
|
1223
|
|
|
$document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
1224
|
|
View Code Duplication |
if($point == -1) |
|
1225
|
|
|
{ |
|
1226
|
|
|
if($document_config->use_vote_down!='S') return new Object(-1, 'msg_invalid_request'); |
|
1227
|
|
|
$args->below_point = 0; |
|
1228
|
|
|
} |
|
1229
|
|
|
else |
|
1230
|
|
|
{ |
|
1231
|
|
|
if($document_config->use_vote_up!='S') return new Object(-1, 'msg_invalid_request'); |
|
1232
|
|
|
$args->more_point = 0; |
|
1233
|
|
|
} |
|
1234
|
|
|
|
|
1235
|
|
|
$args->document_srl = $document_srl; |
|
1236
|
|
|
|
|
1237
|
|
|
$output = executeQueryArray('document.getVotedMemberList',$args); |
|
1238
|
|
|
if(!$output->toBool()) return $output; |
|
1239
|
|
|
|
|
1240
|
|
|
$oMemberModel = getModel('member'); |
|
1241
|
|
View Code Duplication |
if($output->data) |
|
1242
|
|
|
{ |
|
1243
|
|
|
foreach($output->data as $k => $d) |
|
1244
|
|
|
{ |
|
1245
|
|
|
$profile_image = $oMemberModel->getProfileImage($d->member_srl); |
|
1246
|
|
|
$output->data[$k]->src = $profile_image->src; |
|
1247
|
|
|
} |
|
1248
|
|
|
} |
|
1249
|
|
|
|
|
1250
|
|
|
$this->add('voted_member_list',$output->data); |
|
1251
|
|
|
} |
|
1252
|
|
|
|
|
1253
|
|
|
/** |
|
1254
|
|
|
* Return status name list |
|
1255
|
|
|
* @return array |
|
1256
|
|
|
*/ |
|
1257
|
|
|
function getStatusNameList() |
|
1258
|
|
|
{ |
|
1259
|
|
|
global $lang; |
|
1260
|
|
|
if(!isset($lang->status_name_list)) |
|
1261
|
|
|
return array_flip($this->getStatusList()); |
|
1262
|
|
|
else return $lang->status_name_list; |
|
1263
|
|
|
} |
|
1264
|
|
|
|
|
1265
|
|
|
/** |
|
1266
|
|
|
* Setting sort index |
|
1267
|
|
|
* @param object $obj |
|
1268
|
|
|
* @param bool $load_extra_vars |
|
1269
|
|
|
* @return object |
|
1270
|
|
|
*/ |
|
1271
|
|
|
function _setSortIndex($obj, $load_extra_vars) |
|
1272
|
|
|
{ |
|
1273
|
|
|
$sortIndex = $obj->sort_index; |
|
1274
|
|
|
$isExtraVars = false; |
|
1275
|
|
|
if(!in_array($sortIndex, array('list_order','regdate','last_update','update_order','readed_count','voted_count','blamed_count','comment_count','trackback_count','uploaded_count','title','category_srl'))) |
|
1276
|
|
|
{ |
|
1277
|
|
|
// get module_srl extra_vars list |
|
1278
|
|
|
if ($load_extra_vars) |
|
1279
|
|
|
{ |
|
1280
|
|
|
$extra_args = new stdClass(); |
|
1281
|
|
|
$extra_args->module_srl = $obj->module_srl; |
|
1282
|
|
|
$extra_output = executeQueryArray('document.getGroupsExtraVars', $extra_args); |
|
1283
|
|
|
if (!$extra_output->data || !$extra_output->toBool()) |
|
1284
|
|
|
{ |
|
1285
|
|
|
$sortIndex = 'list_order'; |
|
1286
|
|
|
} |
|
1287
|
|
|
else |
|
1288
|
|
|
{ |
|
1289
|
|
|
$check_array = array(); |
|
1290
|
|
|
foreach($extra_output->data as $val) |
|
1291
|
|
|
{ |
|
1292
|
|
|
$check_array[] = $val->eid; |
|
1293
|
|
|
} |
|
1294
|
|
|
if(!in_array($sortIndex, $check_array)) $sortIndex = 'list_order'; |
|
1295
|
|
|
else $isExtraVars = true; |
|
1296
|
|
|
} |
|
1297
|
|
|
} |
|
1298
|
|
|
else |
|
1299
|
|
|
$sortIndex = 'list_order'; |
|
1300
|
|
|
} |
|
1301
|
|
|
$returnObj = new stdClass(); |
|
1302
|
|
|
$returnObj->sort_index = $sortIndex; |
|
1303
|
|
|
$returnObj->isExtraVars = $isExtraVars; |
|
1304
|
|
|
|
|
1305
|
|
|
return $returnObj; |
|
1306
|
|
|
} |
|
1307
|
|
|
|
|
1308
|
|
|
/** |
|
1309
|
|
|
* 게시물 목록의 검색 옵션을 Setting함(2011.03.08 - cherryfilter) |
|
1310
|
|
|
* page변수가 없는 상태에서 page 값을 알아오는 method(getDocumentPage)는 검색하지 않은 값을 return해서 검색한 값을 가져오도록 검색옵션이 추가 됨. |
|
1311
|
|
|
* 검색옵션의 중복으로 인해 private method로 별도 분리 |
|
1312
|
|
|
* @param object $searchOpt |
|
1313
|
|
|
* @param object $args |
|
1314
|
|
|
* @param string $query_id |
|
1315
|
|
|
* @param bool $use_division |
|
1316
|
|
|
* @return void |
|
1317
|
|
|
*/ |
|
1318
|
|
|
function _setSearchOption($searchOpt, &$args, &$query_id, &$use_division) |
|
1319
|
|
|
{ |
|
1320
|
|
|
// Variable check |
|
1321
|
|
|
$args = new stdClass(); |
|
1322
|
|
|
$args->category_srl = $searchOpt->category_srl?$searchOpt->category_srl:null; |
|
1323
|
|
|
$args->order_type = $searchOpt->order_type; |
|
1324
|
|
|
$args->page = $searchOpt->page?$searchOpt->page:1; |
|
1325
|
|
|
$args->list_count = $searchOpt->list_count?$searchOpt->list_count:20; |
|
1326
|
|
|
$args->page_count = $searchOpt->page_count?$searchOpt->page_count:10; |
|
1327
|
|
|
$args->start_date = $searchOpt->start_date?$searchOpt->start_date:null; |
|
1328
|
|
|
$args->end_date = $searchOpt->end_date?$searchOpt->end_date:null; |
|
1329
|
|
|
$args->member_srl = $searchOpt->member_srl; |
|
1330
|
|
|
|
|
1331
|
|
|
$logged_info = Context::get('logged_info'); |
|
1332
|
|
|
|
|
1333
|
|
|
$args->sort_index = $searchOpt->sort_index; |
|
1334
|
|
|
|
|
1335
|
|
|
// Check the target and sequence alignment |
|
1336
|
|
|
$orderType = array('desc' => 1, 'asc' => 1); |
|
1337
|
|
|
if(!isset($orderType[$args->order_type])) $args->order_type = 'asc'; |
|
1338
|
|
|
|
|
1339
|
|
|
// If that came across mid module_srl instead of a direct module_srl guhaejum |
|
1340
|
|
|
if($searchOpt->mid) |
|
1341
|
|
|
{ |
|
1342
|
|
|
$oModuleModel = getModel('module'); |
|
1343
|
|
|
$args->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
|
|
|
|
|
|
1344
|
|
|
unset($searchOpt->mid); |
|
1345
|
|
|
} |
|
1346
|
|
|
|
|
1347
|
|
|
// Module_srl passed the array may be a check whether the array |
|
1348
|
|
|
if(is_array($searchOpt->module_srl)) $args->module_srl = implode(',', $searchOpt->module_srl); |
|
1349
|
|
|
else $args->module_srl = $searchOpt->module_srl; |
|
1350
|
|
|
|
|
1351
|
|
|
// Except for the test module_srl |
|
1352
|
|
|
if(is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl); |
|
1353
|
|
|
else $args->exclude_module_srl = $searchOpt->exclude_module_srl; |
|
1354
|
|
|
|
|
1355
|
|
|
// only admin document list, temp document showing |
|
1356
|
|
|
if($searchOpt->statusList) $args->statusList = $searchOpt->statusList; |
|
1357
|
|
|
else |
|
1358
|
|
|
{ |
|
1359
|
|
|
if($logged_info->is_admin == 'Y' && !$searchOpt->module_srl) |
|
1360
|
|
|
$args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'), $this->getConfigStatus('temp')); |
|
1361
|
|
|
else |
|
1362
|
|
|
$args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public')); |
|
1363
|
|
|
} |
|
1364
|
|
|
|
|
1365
|
|
|
// Category is selected, further sub-categories until all conditions |
|
1366
|
|
|
if($args->category_srl) |
|
1367
|
|
|
{ |
|
1368
|
|
|
$category_list = $this->getCategoryList($args->module_srl); |
|
1369
|
|
|
$category_info = $category_list[$args->category_srl]; |
|
1370
|
|
|
$category_info->childs[] = $args->category_srl; |
|
1371
|
|
|
$args->category_srl = implode(',',$category_info->childs); |
|
1372
|
|
|
} |
|
1373
|
|
|
|
|
1374
|
|
|
// Used to specify the default query id (based on several search options to query id modified) |
|
1375
|
|
|
$query_id = 'document.getDocumentList'; |
|
1376
|
|
|
|
|
1377
|
|
|
// If the search by specifying the document division naeyonggeomsaekil processed for |
|
1378
|
|
|
$use_division = false; |
|
1379
|
|
|
|
|
1380
|
|
|
// Search options |
|
1381
|
|
|
$search_target = $searchOpt->search_target; |
|
1382
|
|
|
$search_keyword = $searchOpt->search_keyword; |
|
1383
|
|
|
|
|
1384
|
|
|
if($search_target && $search_keyword) |
|
1385
|
|
|
{ |
|
1386
|
|
|
switch($search_target) |
|
1387
|
|
|
{ |
|
1388
|
|
|
case 'title' : |
|
1389
|
|
View Code Duplication |
case 'content' : |
|
1390
|
|
|
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1391
|
|
|
$args->{"s_".$search_target} = $search_keyword; |
|
1392
|
|
|
$use_division = true; |
|
1393
|
|
|
break; |
|
1394
|
|
View Code Duplication |
case 'title_content' : |
|
1395
|
|
|
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1396
|
|
|
$args->s_title = $search_keyword; |
|
1397
|
|
|
$args->s_content = $search_keyword; |
|
1398
|
|
|
$use_division = true; |
|
1399
|
|
|
break; |
|
1400
|
|
View Code Duplication |
case 'user_id' : |
|
1401
|
|
|
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1402
|
|
|
$args->s_user_id = $search_keyword; |
|
1403
|
|
|
$args->sort_index = 'documents.'.$args->sort_index; |
|
1404
|
|
|
break; |
|
1405
|
|
|
case 'user_name' : |
|
1406
|
|
|
case 'nick_name' : |
|
1407
|
|
|
case 'email_address' : |
|
1408
|
|
View Code Duplication |
case 'homepage' : |
|
1409
|
|
|
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
|
1410
|
|
|
$args->{"s_".$search_target} = $search_keyword; |
|
1411
|
|
|
break; |
|
1412
|
|
|
case 'is_notice' : |
|
1413
|
|
|
if($search_keyword=='N') $args->{"s_".$search_target} = 'N'; |
|
1414
|
|
|
elseif($search_keyword=='Y') $args->{"s_".$search_target} = 'Y'; |
|
1415
|
|
|
else $args->{"s_".$search_target} = ''; |
|
1416
|
|
|
break; |
|
1417
|
|
|
case 'is_secret' : |
|
1418
|
|
|
if($search_keyword=='N') $args->statusList = array($this->getConfigStatus('public')); |
|
1419
|
|
|
elseif($search_keyword=='Y') $args->statusList = array($this->getConfigStatus('secret')); |
|
1420
|
|
|
elseif($search_keyword=='temp') $args->statusList = array($this->getConfigStatus('temp')); |
|
1421
|
|
|
break; |
|
1422
|
|
|
case 'member_srl' : |
|
1423
|
|
|
case 'readed_count' : |
|
1424
|
|
|
case 'voted_count' : |
|
1425
|
|
|
case 'comment_count' : |
|
1426
|
|
|
case 'trackback_count' : |
|
1427
|
|
|
case 'uploaded_count' : |
|
1428
|
|
|
$args->{"s_".$search_target} = (int)$search_keyword; |
|
1429
|
|
|
break; |
|
1430
|
|
|
case 'blamed_count' : |
|
1431
|
|
|
$args->{"s_".$search_target} = (int)$search_keyword * -1; |
|
1432
|
|
|
break; |
|
1433
|
|
|
case 'regdate' : |
|
1434
|
|
|
case 'last_update' : |
|
1435
|
|
|
case 'ipaddress' : |
|
1436
|
|
|
$args->{"s_".$search_target} = $search_keyword; |
|
1437
|
|
|
break; |
|
1438
|
|
|
case 'comment' : |
|
1439
|
|
|
$args->s_comment = $search_keyword; |
|
1440
|
|
|
$query_id = 'document.getDocumentListWithinComment'; |
|
1441
|
|
|
$use_division = true; |
|
1442
|
|
|
break; |
|
1443
|
|
|
case 'tag' : |
|
1444
|
|
|
$args->s_tags = str_replace(' ','%',$search_keyword); |
|
1445
|
|
|
$query_id = 'document.getDocumentListWithinTag'; |
|
1446
|
|
|
break; |
|
1447
|
|
|
case 'extra_vars': |
|
1448
|
|
|
$args->var_value = str_replace(' ', '%', $search_keyword); |
|
1449
|
|
|
$query_id = 'document.getDocumentListWithinExtraVars'; |
|
1450
|
|
|
break; |
|
1451
|
|
|
default : |
|
1452
|
|
View Code Duplication |
if(strpos($search_target,'extra_vars')!==false) { |
|
1453
|
|
|
$args->var_idx = substr($search_target, strlen('extra_vars')); |
|
1454
|
|
|
$args->var_value = str_replace(' ','%',$search_keyword); |
|
1455
|
|
|
$args->sort_index = 'documents.'.$args->sort_index; |
|
1456
|
|
|
$query_id = 'document.getDocumentListWithExtraVars'; |
|
1457
|
|
|
} |
|
1458
|
|
|
break; |
|
1459
|
|
|
} |
|
1460
|
|
|
} |
|
1461
|
|
|
|
|
1462
|
|
|
if ($searchOpt->isExtraVars) |
|
1463
|
|
|
{ |
|
1464
|
|
|
$query_id = 'document.getDocumentListExtraSort'; |
|
1465
|
|
|
} |
|
1466
|
|
|
else |
|
1467
|
|
|
{ |
|
1468
|
|
|
/** |
|
1469
|
|
|
* list_order asc sort of division that can be used only when |
|
1470
|
|
|
*/ |
|
1471
|
|
|
if($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false; |
|
1472
|
|
|
|
|
1473
|
|
|
/** |
|
1474
|
|
|
* If it is true, use_division changed to use the document division |
|
1475
|
|
|
*/ |
|
1476
|
|
|
if($use_division) |
|
1477
|
|
|
{ |
|
1478
|
|
|
// Division begins |
|
1479
|
|
|
$division = (int)Context::get('division'); |
|
1480
|
|
|
|
|
1481
|
|
|
// order by list_order and (module_srl===0 or module_srl may count), therefore case table full scan |
|
1482
|
|
|
if($args->sort_index == 'list_order' && ($args->exclude_module_srl === '0' || count(explode(',', $args->module_srl)) > 5)) |
|
1483
|
|
|
{ |
|
1484
|
|
|
$listSqlID = 'document.getDocumentListUseIndex'; |
|
|
|
|
|
|
1485
|
|
|
$divisionSqlID = 'document.getDocumentDivisionUseIndex'; |
|
1486
|
|
|
} |
|
1487
|
|
|
else |
|
1488
|
|
|
{ |
|
1489
|
|
|
$listSqlID = 'document.getDocumentList'; |
|
|
|
|
|
|
1490
|
|
|
$divisionSqlID = 'document.getDocumentDivision'; |
|
1491
|
|
|
} |
|
1492
|
|
|
|
|
1493
|
|
|
// If you do not value the best division top |
|
1494
|
|
View Code Duplication |
if(!$division) |
|
1495
|
|
|
{ |
|
1496
|
|
|
$division_args = new stdClass(); |
|
1497
|
|
|
$division_args->module_srl = $args->module_srl; |
|
1498
|
|
|
$division_args->exclude_module_srl = $args->exclude_module_srl; |
|
1499
|
|
|
$division_args->list_count = 1; |
|
1500
|
|
|
$division_args->sort_index = $args->sort_index; |
|
1501
|
|
|
$division_args->order_type = $args->order_type; |
|
1502
|
|
|
$division_args->statusList = $args->statusList; |
|
1503
|
|
|
|
|
1504
|
|
|
$output = executeQuery($divisionSqlID, $division_args, array('list_order')); |
|
1505
|
|
|
if($output->data) |
|
1506
|
|
|
{ |
|
1507
|
|
|
$item = array_pop($output->data); |
|
1508
|
|
|
$division = $item->list_order; |
|
1509
|
|
|
} |
|
1510
|
|
|
$division_args = null; |
|
|
|
|
|
|
1511
|
|
|
} |
|
1512
|
|
|
|
|
1513
|
|
|
// The last division |
|
1514
|
|
|
$last_division = (int)Context::get('last_division'); |
|
1515
|
|
|
|
|
1516
|
|
|
// Division after division from the 5000 value of the specified Wanted |
|
1517
|
|
View Code Duplication |
if(!$last_division) |
|
1518
|
|
|
{ |
|
1519
|
|
|
$last_division_args = new stdClass(); |
|
1520
|
|
|
$last_division_args->module_srl = $args->module_srl; |
|
1521
|
|
|
$last_division_args->exclude_module_srl = $args->exclude_module_srl; |
|
1522
|
|
|
$last_division_args->list_count = 1; |
|
1523
|
|
|
$last_division_args->sort_index = $args->sort_index; |
|
1524
|
|
|
$last_division_args->order_type = $args->order_type; |
|
1525
|
|
|
$last_division_args->list_order = $division; |
|
1526
|
|
|
$last_division_args->page = 5001; |
|
1527
|
|
|
|
|
1528
|
|
|
$output = executeQuery($divisionSqlID, $last_division_args, array('list_order')); |
|
1529
|
|
|
if($output->data) |
|
1530
|
|
|
{ |
|
1531
|
|
|
$item = array_pop($output->data); |
|
1532
|
|
|
$last_division = $item->list_order; |
|
1533
|
|
|
} |
|
1534
|
|
|
} |
|
1535
|
|
|
|
|
1536
|
|
|
// Make sure that after last_division article |
|
1537
|
|
|
if($last_division) |
|
1538
|
|
|
{ |
|
1539
|
|
|
$last_division_args = new stdClass(); |
|
1540
|
|
|
$last_division_args->module_srl = $args->module_srl; |
|
1541
|
|
|
$last_division_args->exclude_module_srl = $args->exclude_module_srl; |
|
1542
|
|
|
$last_division_args->list_order = $last_division; |
|
1543
|
|
|
$output = executeQuery('document.getDocumentDivisionCount', $last_division_args); |
|
1544
|
|
|
if($output->data->count<1) $last_division = null; |
|
1545
|
|
|
} |
|
1546
|
|
|
|
|
1547
|
|
|
$args->division = $division; |
|
1548
|
|
|
$args->last_division = $last_division; |
|
1549
|
|
|
Context::set('division', $division); |
|
1550
|
|
|
Context::set('last_division', $last_division); |
|
1551
|
|
|
} |
|
1552
|
|
|
} |
|
1553
|
|
|
} |
|
1554
|
|
|
|
|
1555
|
|
|
/** |
|
1556
|
|
|
* Get the total number of Document in corresponding with member_srl. |
|
1557
|
|
|
* @param int $member_srl |
|
1558
|
|
|
* @return int |
|
1559
|
|
|
*/ |
|
1560
|
|
|
function getDocumentCountByMemberSrl($member_srl) |
|
1561
|
|
|
{ |
|
1562
|
|
|
$args = new stdClass(); |
|
1563
|
|
|
$args->member_srl = $member_srl; |
|
1564
|
|
|
$output = executeQuery('document.getDocumentCountByMemberSrl', $args); |
|
1565
|
|
|
return (int) $output->data->count; |
|
1566
|
|
|
} |
|
1567
|
|
|
|
|
1568
|
|
|
/** |
|
1569
|
|
|
* Get document list of the doc in corresponding woth member_srl. |
|
1570
|
|
|
* @param int $member_srl |
|
1571
|
|
|
* @param array $columnList |
|
1572
|
|
|
* @param int $page |
|
1573
|
|
|
* @param bool $is_admin |
|
1574
|
|
|
* @param int $count |
|
1575
|
|
|
* @return object |
|
1576
|
|
|
*/ |
|
1577
|
|
View Code Duplication |
function getDocumentListByMemberSrl($member_srl, $columnList = array(), $page = 0, $is_admin = FALSE, $count = 0 ) |
|
|
|
|
|
|
1578
|
|
|
{ |
|
1579
|
|
|
$args = new stdClass(); |
|
1580
|
|
|
$args->member_srl = $member_srl; |
|
1581
|
|
|
$args->list_count = $count; |
|
1582
|
|
|
$output = executeQuery('document.getDocumentListByMemberSrl', $args, $columnList); |
|
1583
|
|
|
$document_list = $output->data; |
|
1584
|
|
|
|
|
1585
|
|
|
if(!$document_list) return array(); |
|
1586
|
|
|
if(!is_array($document_list)) $document_list = array($document_list); |
|
1587
|
|
|
|
|
1588
|
|
|
return $document_list; |
|
1589
|
|
|
} |
|
1590
|
|
|
|
|
1591
|
|
|
function getDocumentExtraImagePath() |
|
1592
|
|
|
{ |
|
1593
|
|
|
$documentConfig = getModel('document')->getDocumentConfig(); |
|
|
|
|
|
|
1594
|
|
|
if(Mobile::isFromMobilePhone()) |
|
1595
|
|
|
{ |
|
1596
|
|
|
$iconSkin = $documentConfig->micons; |
|
1597
|
|
|
} |
|
1598
|
|
|
else |
|
1599
|
|
|
{ |
|
1600
|
|
|
$iconSkin = $documentConfig->icons; |
|
1601
|
|
|
} |
|
1602
|
|
|
$path = sprintf('%s%s',getUrl(), "modules/document/tpl/icons/$iconSkin/"); |
|
1603
|
|
|
|
|
1604
|
|
|
return $path; |
|
1605
|
|
|
} |
|
1606
|
|
|
} |
|
1607
|
|
|
/* End of file document.model.php */ |
|
1608
|
|
|
/* Location: ./modules/document/document.model.php */ |
|
1609
|
|
|
|
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArrayis initialized the first time when the foreach loop is entered. You can also see that the value of thebarkey is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.