1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: 19: 20: 21: 22: 23: 24:
25:
26: global $area;
27: class ArticleForumRightBottom extends cGuiPage {
28:
29: private $_indentFactor = 20;
30:
31: protected $_collection;
32:
33: function __construct() {
34:
35:
36: echo <<<EOF
37: <script type="text/javascript">
38: reloadLeftBottom = 'main.php?area=user_forum';
39: reloadLeftBottom += '&frame=2';
40: parent.parent.left.left_bottom.location.href = reloadLeftBottom;
41: </script>
42: EOF;
43: $this->_collection = new ArticleForumCollection();
44: parent::__construct('right_bottom', 'user_forum');
45: $this->addStyle('right_bottom.css');
46: $this->addScript('location.js');
47: }
48:
49: protected function formatTimeString($timeStamp) {
50: $nullstring = '0';
51: if ($timeStamp == "0000-00-00 00:00:00") {
52: return array();
53: } else {
54: $ar = (date_parse($timeStamp));
55:
56:
57: (strlen($ar['day']) < 2) ? $ar['day'] = $nullstring . $ar['day'] : '';
58: (strlen($ar['month']) < 2) ? $ar['month'] = $nullstring . $ar['month'] : '';
59: (strlen($ar['minute']) < 2) ? $ar['minute'] = $nullstring . $ar['minute'] : '';
60: (strlen($ar['hour']) < 2) ? $ar['hour'] = $nullstring . $ar['hour'] : '';
61: }
62:
63: return $ar;
64: }
65:
66: 67: 68: 69: 70: 71: 72: 73:
74: protected function checkValidEmail($emailadr, $realname) {
75: $regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/';
76:
77: if (preg_match($regex, $emailadr)) {
78: $mail = new cHTMLLink();
79: $mail->setClass('emailactive');
80: $mail->setLink("mailto:" . $emailadr);
81: $mail->setContent($realname);
82: } else {
83: $mail = new cHTMLLink();
84: $mail->setLink('#');
85: $mail->setClass('emaildeactive');
86: $mail->setContent($realname);
87: }
88: return $mail;
89: }
90:
91: 92: 93: 94: 95: 96: 97: 98: 99: 100:
101: protected function buildOnlineButtonBackendListMode(&$key, &$cont, &$cfg) {
102: global $area;
103: $buttons = array();
104:
105: $id = $cont['id_user_forum'];
106:
107:
108: $online = new cHTMLLink();
109: if ($cont['online'] == 1) {
110: $online->setImage($cfg['path']['images'] . 'online.gif');
111: $online->setCustom('action', 'online_toggle');
112: $online->setAlt(UserForum::i18n('SETOFFLINE'));
113: } else {
114: $online->setImage($cfg['path']['images'] . 'offline.gif');
115: $online->setCustom('action', 'offline_toggle');
116: $online->setAlt(UserForum::i18n('SETONLINE'));
117: }
118:
119: $online->setCLink($area, 4, 'show_form');
120: $online->setTargetFrame('right_bottom');
121: $online->setStyle('margin-right:10px;');
122:
123: $online->setCustom('action', 'online_toggle');
124: $online->setCustom('idart', $cont['idart']);
125: $online->setCustom('id_user_forum', $cont['id_user_forum']);
126: $online->setCustom('idcat', $cont['idcat']);
127: $online->setCustom('online', $cont['online']);
128: $online->setAttribute('method', 'get');
129:
130:
131: $edit = new cHTMLButton("edit");
132: $edit->setImageSource($cfg['path']['images'] . 'but_todo.gif');
133: $edit->setEvent('click', "$('form[name=$id]').submit()");
134: $edit->setStyle('margin-right:10px; ');
135: $edit->setMode('image');
136: $edit->setAlt(UserForum::i18n('EDIT'));
137:
138: $message = UserForum::i18n('ALLDELETEFROMCATHIER');
139: $level = $cont['level'];
140: $keyy = $key;
141: $id = $cont['id_user_forum'];
142: $idacat = $cont['idcat'];
143: $idaart = $cont['idart'];
144:
145:
146: $deleteButton = '<a title="' . $cont['title'] . '" href="javascript:void(0)" onclick="showConfirmation("' . $message . '", function(){ deleteArticlesByIdRight(' . $level . ', ' . $keyy . ', ' . $id . ', ' . $idacat . ', ' . $idaart . '); });return false;"><img src="' . $cfg['path']['images'] . 'delete.gif" border="0" title="' . $message . '" alt="' . $message . '"></a>';
147:
148:
149: $buttons['online'] = $online;
150: $buttons['edit'] = $edit;
151: $buttons['delete'] = $deleteButton;
152:
153: return $buttons;
154: }
155:
156: 157: 158: 159: 160: 161:
162: protected function (&$result) {
163: $table = new cHTMLTable();
164: if (count($result) < 1) {
165: return new cHTMLTable();
166: }
167: $table->setCellPadding('100px');
168: global $area;
169: $table->updateAttributes(array(
170: "class" => "generic",
171: "cellspacing" => "0",
172: "cellpadding" => "2"
173: ));
174:
175: if (count($result > 0)) {
176: $tr = new cHTMLTableRow();
177: $th = new cHTMLTableHead();
178: $th->setContent(i18n("FORUM_POST", "user_forum"));
179: $th->setStyle('text-align: center');
180: $tr->appendContent($th);
181:
182: $th = new cHTMLTableHead();
183: $th->setContent(i18n("ACTIONS", "user_forum"));
184: $th->setStyle('widht:20px');
185: $th->setStyle('text-align: center');
186: $th->setAttribute('valign', 'top');
187: $tr->appendContent($th);
188:
189: $table->appendContent($tr);
190: }
191:
192: $menu = new cGuiMenu();
193: $cfg = cRegistry::getConfig();
194:
195: foreach ($result as $key => $cont) {
196:
197: $set = false;
198: $like = $cont['like'];
199: $dislike = $cont['dislike'];
200: $timestamp = $cont['timestamp'];
201:
202: $datearray = $this->formatTimeString($cont['timestamp']);
203: $date = (empty($datearray)) ? '' : $datearray['day'] . '.' . $datearray['month'] . '.' . $datearray['year'] . ' ' . UserForum::i18n("AT") . ' ' . $datearray['hour'] . ':' . $datearray['minute'] . ' ' . UserForum::i18n("CLOCK");
204:
205: $buttons = array();
206: $buttons = $this->buildOnlineButtonBackendListMode($key, $cont, $cfg);
207:
208: $online = $buttons['online'];
209: $edit = $buttons['edit'];
210: $delete = $buttons['delete'];
211:
212:
213: $tr = new cHTMLTableRow();
214: $trLike = new cHTMLTableRow();
215:
216: $likeButton = new cHTMLImage($cfg['path']['images'] . 'like.png');
217:
218: $dislikeButton = new cHTMLImage($cfg['path']['images'] . 'dislike.png');
219:
220:
221: $maili = $this->checkValidEmail($cont['email'], $cont['realname']);
222: $text = $cont['forum'];
223:
224: $timestamp = $cont['editedat'];
225:
226: $editarray = $this->formatTimeString($cont['editedat']);
227: $editdate = (empty($editarray)) ? '' : $editarray['day'] . '.' . $editarray['month'] . '.' . $editarray['year'] . ' ' . UserForum::i18n("AT") . ' ' . $editarray['hour'] . ':' . $editarray['minute'] . ' ' . UserForum::i18n("CLOCK");
228:
229: $userColl = new cApiUserCollection();
230: $user = $userColl->loadItem($cont['editedby'])->get('username');
231:
232: if (($cont['editedby'] != '') && ($cont['editedat'] != '') && $cont['editedat'] != "0000-00-00 00:00:00") {
233: $edit_information = (UserForum::i18n("EDITED") . $editdate . ' ' . UserForum::i18n("FROM") . $user);
234: $edit_information = "<em>$edit_information</em>";
235: } else {
236: $edit_information = "<br>";
237: }
238:
239: $tdEmpty = new cHTMLTableData();
240: $tdEmpty->appendContent($edit_information);
241: $tdLike = new cHTMLTableData();
242: $tdEmpty->setAttribute('valign', 'top');
243: $tdLike->setAttribute('valign', 'top');
244: $tdLike->setStyle('text-align: center');
245:
246:
247: $tdLike->appendContent($likeButton);
248: $tdLike->appendContent(" $like ");
249: $tdLike->appendContent($dislikeButton);
250: $tdLike->appendContent(" $dislike");
251:
252:
253: $trLike->appendContent($tdEmpty);
254: $trLike->appendContent($tdLike);
255:
256:
257: $form = new cHTMLForm($cont['id_user_forum']);
258: $form->setAttribute('action', 'main.php?' . "area=" . $area . '&frame=4');
259:
260: $tdForm = new cHTMLTableData();
261: $tdForm->setStyle('padding-left:' . $cont['level'] * $this->_indentFactor . 'px');
262:
263:
264: $tdButtons = new cHTMLTableData();
265: $tdButtons->setAttribute('valign', 'top');
266: $tdButtons->setStyle(' text-align: center');
267:
268: $tdButtons->appendContent($online);
269: $tdButtons->appendContent($edit);
270: $tdButtons->appendContent($delete);
271: $tdButtons->appendContent('<br>');
272: $tdButtons->appendContent('<br>');
273:
274:
275: $hiddenIdart = new cHTMLHiddenField('idart');
276: $hiddenIdcat = new cHTMLHiddenField('idcat');
277: $hiddenId_user_forum = new cHTMLHiddenField('id_user_forum');
278: $hiddenLike = new cHTMLHiddenField('like');
279: $hiddenDislike = new cHTMLHiddenField('dislike');
280: $hiddenName = new cHTMLHiddenField('realname');
281: $hiddenEmail = new cHTMLHiddenField('email');
282: $hiddenLevel = new cHTMLHiddenField('level');
283: $hiddenEditdat = new cHTMLHiddenField('editedat');
284: $hiddenEditedby = new cHTMLHiddenField('editedby');
285: $hiddenTimestamp = new cHTMLHiddenField('timestamp');
286: $hiddenForum = new cHTMLHiddenField('forum');
287: $hiddenOnline = new cHTMLHiddenField('online');
288: $hiddenMode = new cHTMLHiddenField('mode');
289: $hiddenKey = new cHTMLHiddenField('key');
290: $hiddenaction = new cHTMLHiddenField('action');
291:
292:
293: $hiddenIdart->setValue($cont['idart']);
294: $hiddenIdcat->setValue($cont['idcat']);
295: $hiddenId_user_forum->setValue($cont['id_user_forum']);
296: $hiddenLike->setValue($cont['like']);
297: $hiddenDislike->setValue($cont['dislike']);
298: $hiddenName->setValue(str_replace('\\', '', conHtmlSpecialChars($cont['realname'])));
299: $hiddenEmail->setValue(str_replace('\\', '', conHtmlSpecialChars($cont['email'])));
300: $hiddenLevel->setValue($cont['level']);
301: $hiddenEditdat->setValue($cont['editedat']);
302: $hiddenEditedby->setValue($cont['editedby']);
303: $hiddenTimestamp->setValue($date);
304: $hiddenForum->setValue(str_replace('\\', '', conHtmlSpecialChars($cont['forum'])));
305: $hiddenOnline->setValue($cont['online']);
306: $hiddenMode->setValue('edit');
307: $hiddenKey->setValue($key);
308: $hiddenaction->setValue('edit');
309:
310:
311: $form->appendContent($hiddenIdart);
312: $form->appendContent($hiddenIdcat);
313: $form->appendContent($hiddenId_user_forum);
314: $form->appendContent($hiddenLike);
315: $form->appendContent($hiddenDislike);
316: $form->appendContent($hiddenName);
317: $form->appendContent($hiddenEmail);
318: $form->appendContent($hiddenLevel);
319: $form->appendContent($hiddenForum);
320: $form->appendContent($hiddenEditdat);
321: $form->appendContent($hiddenEditedby);
322: $form->appendContent($hiddenTimestamp);
323: $form->appendContent($hiddenMode);
324: $form->appendContent($hiddenOnline);
325: $form->appendContent($hiddenKey);
326: $form->appendContent($hiddenaction);
327:
328:
329: $form->appendContent($date . " von " . str_replace('\\', '', $maili) . " <br><br>");
330: $form->appendContent((str_replace('\\', '', $text)) . "<br><br>");
331: $tdForm->setContent($form);
332: $tdForm->setAttribute('valign', 'top');
333: $tr->setContent($tdForm);
334: $tr->appendContent($tdButtons);
335: $tr->appendContent($trLike);
336: $table->appendContent($tr);
337: }
338: $this->appendContent($table);
339:
340: return $this;
341: }
342:
343: 344: 345: 346: 347: 348:
349: protected function ($post) {
350:
351: global $area;
352: $changes = 0;
353: $cfg = cRegistry::getConfig();
354: $idart = cRegistry::getArticleId();
355: $idcat = cRegistry::getCategoryId();
356: $menu = new cGuiMenu();
357: $tr = new cHTMLTableRow();
358:
359: $th = new cHTMLTableHead();
360: $th->setContent(UserForum::i18n("PARAMETER", "user_forum"));
361:
362: $th2 = new cHTMLTableHead();
363: $th2->setContent(UserForum::i18n("CONTENT", "user_forum"));
364: $th2->setStyle('widht:50px');
365: $th2->setAttribute('valign', 'top');
366: $tr->appendContent($th);
367: $tr->appendContent($th2);
368:
369:
370: $form1 = new cGuiTableForm("comment", "main.php?area=user_forum&frame=4", "post");
371: $form1->addHeader($tr);
372: $form1->setTableID("table");
373:
374: $user = new cApiUser();
375: $user->loadByPrimaryKey($post['editedby']);
376: $username = $user->getField('username');
377:
378: $id = $post['id_user_forum'];
379:
380: $likeButton = new cHTMLImage($cfg['path']['images'] . 'like.png');
381: $dislikeButton = new cHTMLImage($cfg['path']['images'] . 'dislike.png');
382:
383:
384: $name = new cHTMLTextBox("realname", str_replace('\\', '',(conHtmlSpecialChars($post['realname']))), 30, 255);
385: $email = new cHTMLTextBox("email", $post['email'], 30, 255);
386: $like = new cHTMLTextBox("like", $post['like'], 7, 7);
387: $dislike = new cHTMLTextBox("dislike", $post['dislike'], 7, 7);
388:
389: $text = str_replace("<br />", "\n", conHtmlSpecialChars($post['forum']));
390: $text = str_replace('\\', '', $text);
391:
392: $forum = new cHTMLTextArea("forum", $text);
393:
394: $datearray = $this->formatTimeString($post['timestamp']);
395: $date = (empty($datearray)) ? '' : $datearray['day'] . '.' . $datearray['month'] . '.' . $datearray['year'] . ' ' . UserForum::i18n("AT") . ' ' . $datearray['hour'] . ':' . $datearray['minute'] . ' ' . UserForum::i18n("CLOCK");
396:
397: $editedatearray = $this->formatTimeString($post['editedat']);
398: $editedat = (empty($editedatearray)) ? '' : $editedatearray['day'] . '.' . $editedatearray['month'] . '.' . $editedatearray['year'] . ' ' . UserForum::i18n("AT") . ' ' . $editedatearray['hour'] . ':' . $editedatearray['minute'] . ' ' . UserForum::i18n("CLOCK");
399:
400: $timestamp = new cHTMLTextBox("timestamp", $date, 30, 255);
401: $editedat = new cHTMLTextBox("editedat", $editedat, 30, 255);
402: $editedby = new cHTMLTextBox("editedby", $username, 30, 255);
403:
404: $editedat->setDisabled(true);
405: $timestamp->setDisabled(true);
406: $editedby->setDisabled(true);
407:
408: $form1->addCancel("main.php?area=user_forum&frame=4&action=back&idart=$idart&idcat=$idcat");
409: $form1->add(UserForum::i18n("USER"), $name, '');
410: $form1->add(UserForum::i18n("EMAIL"), $email, '');
411: $form1->add(UserForum::i18n("LIKE"), $like, '');
412: $form1->add(UserForum::i18n("DISLIKE"), $dislike, '');
413: $form1->add(UserForum::i18n("TIME"), $timestamp, '');
414: $form1->add(UserForum::i18n("EDITDAT"), $editedat, '');
415: $form1->add(UserForum::i18n("EDITEDBY"), $editedby, '');
416:
417: $onlineBox = new cHTMLCheckbox("onlineState", "");
418:
419: $onlineBox->setChecked(($post['online'] == 1) ? true : false);
420: $form1->add(UserForum::i18n("ONLINE"), $onlineBox, '');
421:
422: $idart = $post['idart'];
423: $idcat = $post['idcat'];
424:
425: $form1->add(UserForum::i18n("COMMENT"), $forum, '');
426:
427:
428: $form1->setVar("id_user_forum", $post['id_user_forum']);
429: $form1->setVar("idart", $post['idart']);
430: $form1->setVar("idcat", $post['idcat']);
431: $form1->setVar("action", 'update');
432: $form1->setVar("mode", "list");
433: $form1->setVar("activeChanges", $changes);
434:
435: $this->appendContent($form1);
436:
437: return $this;
438: }
439:
440: protected function getForum($id_cat, $id_art, $id_lang) {
441: $arrUsers = $this->_collection->getExistingforum($id_cat, $id_art, $id_lang);
442:
443: $arrforum = array();
444:
445: $this->_collection->getTreeLevel($id_cat, $id_art, $id_lang, $arrUsers, $arrforum);
446: $result = array();
447: $this->normalizeArray($arrforum, $result);
448: $ret = $this->getMenu($result);
449:
450: return $ret;
451: }
452:
453: protected function normalizeArray($arrforum, &$result, $level = 0) {
454: if (is_array($arrforum)) {
455: foreach ($arrforum as $key => $value) {
456: $value['level'] = $level;
457: unset($value['children']);
458: $result[$key] = $value;
459: $this->normalizeArray($arrforum[$key]['children'], $result, $level + 1);
460: }
461: }
462: }
463:
464: 465: 466: 467: 468: 469: 470: 471:
472: public function receiveData(&$get, &$post) {
473: if (isset($_REQUEST['action']) && $_REQUEST['action'] != NULL) {
474: $this->switchActions();
475: }
476: }
477:
478: 479: 480: 481: 482:
483: protected function switchActions() {
484: $lang = cRegistry::getLanguageId();
485: $idart = $_REQUEST['idart'];
486: $idcat = $_REQUEST['idcat'];
487: $action = $_REQUEST["action"];
488: $online = (isset($_REQUEST['onlineState'])) ? 1 : 0;
489:
490: switch ($action) {
491:
492:
493: case 'online_toggle':
494: $this->_collection->toggleOnlineState($_REQUEST['online'], $_REQUEST['id_user_forum']);
495: $this->getForum($idcat, $idart, $lang);
496: break;
497:
498: case 'deleteComment':
499: $this->_collection->deleteHierarchie($_REQUEST['key'], $_REQUEST['level'], $idart, $idcat, $lang);
500: $this->getForum($idcat, $idart, $lang);
501: break;
502:
503: case 'update':
504: $this->_collection->updateValues($_POST['id_user_forum'], $_POST['realname'], $_POST['email'], $_POST['like'], $_POST['dislike'], $_POST['forum'], $online, $_POST['onlineState']);
505: $this->getForum($idcat, $idart, $lang);
506: break;
507: case 'show_form':
508:
509: $this->getForum($idcat, $idart, $lang);
510: break;
511: case 'edit':
512:
513: $this->getEditModeMenu($_POST);
514: break;
515:
516: case 'back':
517: $this->getForum($idcat, $idart, $lang);
518: break;
519: case 'empty':
520:
521: break;
522: default:
523: $this->getForum($idcat, $idart, $lang);
524: throw new Exception('$_GET["action"] type ' . $_REQUEST["action"] . ' not implemented');
525: }
526: }
527:
528: }
529:
530: ?>