function CreateCommentForm($backto, $top_id, $message_id, $commune_id, $om, $page = 0, $action = 'Create.post', $mod, $adv = 0, $draft_id = 0, $attachedfiles_session = '') { global $session; session_start(); commune::RestoreMarkedAttach($message_id); $objResponse = new xajaxResponse(); if ($action == 'Create.post') { // Комментируем сообщение. $objResponse->assign($backto, 'style.position', 'static'); $objResponse->assign($backto, 'innerHTML', __commPrntCommentForm($commune_id, $om, $page, $action, $top_id, NULL, $message_id, NULL, NULL, !$page ? 'Topic' : NULL, $mod)); } else { // Выводим форму с атрибутами сообщения. $objResponse->assign($backto, 'style.position', 'static'); $objResponse->assign($backto, 'innerHTML', __commPrntCommentForm($commune_id, $om, $page, $action, $top_id, $message_id, NULL, NULL, NULL, !$page ? 'Topic' : NULL, $mod, 0, $draft_id)); } $objResponse->script(" var editMsg = document.getElementById('{$backto}');\n if(__commLastOpenedForm!=editMsg) {\n try { \n if(!__commLastOpenedForm) {\n var ___acf = document.getElementById('idAlertedCommentForm');\n if(___acf && ___acf.parentNode)\n __commLastOpenedForm = ___acf.parentNode;\n }\n __commLastOpenedForm.innerHTML = ''; __commLastOpenedForm.style.position='absolute'; \n } catch(e) {}\n }\n __commLastOpenedForm = editMsg;\n __commLastOpenedForm.action = '{$action}';\n\t\n\tpoll.init('Commune', document.getElementById('" . $backto . "'), " . commune::POLL_ANSWERS_MAX . ", '" . $_SESSION['CommunePoll_Sess'] . "');\n\tif (document.getElementById('question')) maxChars('question', 'polls_error', " . commune::POLL_QUESTION_CHARS_MAX . ");\n\teditMsg.scrollIntoView(true);\n\t//new mAttach(document.getElementById('files_block'), " . (commune::MAX_FILES - $adv) . ");\n //mA = new mAttach2(document.getElementById('files_block'), " . (commune::MAX_FILES - $adv) . ", {p:'btn-add', m:'btn-del', nv:true});\n "); $js = "var attachedfiles_list = new Array();\n"; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php'; $attachedfiles = new attachedfiles($attachedfiles_session); $attachedfiles_tmpcomm_files = commune::getAttachedFiles($message_id); if ($attachedfiles_tmpcomm_files) { $attachedfiles_comm_files = array(); foreach ($attachedfiles_tmpcomm_files as $attachedfiles_comm_file) { $attachedfiles_comm_files[] = $attachedfiles_comm_file; } $attachedfiles->setFiles($attachedfiles_comm_files); } $attachedfiles_files = $attachedfiles->getFiles(); if ($attachedfiles_files) { $n = 0; foreach ($attachedfiles_files as $attachedfiles_file) { $js .= "attachedfiles_list[{$n}] = new Object;\n"; $js .= "attachedfiles_list[{$n}].id = '" . md5($attachedfiles_file['id']) . "';\n"; $js .= "attachedfiles_list[{$n}].name = '{$attachedfiles_file['orig_name']}';\n"; $js .= "attachedfiles_list[{$n}].path = '" . WDCPREFIX . "/{$attachedfiles_file['path']}{$attachedfiles_file['name']}';\n"; $js .= "attachedfiles_list[{$n}].size = '" . ConvertBtoMB($attachedfiles_file['size']) . "';\n"; $js .= "attachedfiles_list[{$n}].type = '{$attachedfiles_file['type']}';\n"; ++$n; } } $js .= "attachedFiles.init('attachedfiles', \n '" . $attachedfiles->getSession() . "',\n attachedfiles_list, \n '" . commune::MAX_FILES . "',\n '" . commune::MAX_FILE_SIZE . "',\n '" . implode(', ', $GLOBALS['disallowed_array']) . "',\n 'commune',\n '" . get_uid(false) . "'\n );"; $objResponse->script($js); $objResponse->call('initWysiwyg'); $objResponse->call('tawlTextareaInit'); if ($action != 'Create.post') { $objResponse->script('DraftInit(4);'); } return $objResponse; }
/** * Отдает HTML для Редактирование поста в сообществах * * @param object $objResponse xajaxResponse * @param string $rec_id идентификатор записи * @param string $rec_type тип записи * @param array $aParams дополнительные параметры с UID отправителя. остальные - опционально * @return string */ function _admEditCommunityPostParseForm(&$objResponse, $rec_id = '', $rec_type = '', $aParams = array()) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/commune.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php'; $mess = commune::GetMessage(intval($rec_id)); $answers = $mess['answers'] ? $mess['answers'] : array(array('id' => 0, 'answer' => '')); $sub_cat = commune::getCategories($mess['commune_id'], true); $uid = $_SESSION['uid']; $id = $mess['commune_id']; $top_id = $rec_id; $site = 'Topic'; $reloc = __commShaolin($error, $comm, $top, $restrict_type, $user_mod); $is_comm_admin = $user_mod & (commune::MOD_COMM_ADMIN | commune::MOD_COMM_MODERATOR); $is_author = $user_mod & commune::MOD_COMM_AUTHOR; $_SESSION['wysiwyg_inline_files'] = array(); // !!!TODO: что то сделать, когда будут готовы новые сообщества ob_start(); include_once $_SERVER['DOCUMENT_ROOT'] . '/user/adm_edit_tpl/community.php'; $sHtml = ob_get_contents(); ob_end_clean(); // аттачи $sAttach = getAttachedFilesJs(commune::getAttachedFiles($rec_id), commune::MAX_FILES, commune::MAX_FILE_SIZE, 'commune'); // опрос $sOnReady = "\n if(document.getElementById('adm_edit_msg')) document.getElementById('adm_edit_msg').value = (\$('adm_edit_msg_source')? \$('adm_edit_msg_source').value : null);\n parent.window['adm_edit_ckeditor'] = CKEDITOR.replace('adm_edit_msg');\n document.getElementById('adm_edit_question').value = document.getElementById('adm_edit_question_source').value;\n poll.init('Blogs', document.getElementById('div_adm_edit'), " . commune::POLL_ANSWERS_MAX . ", '" . $_SESSION['rand'] . "');\n maxChars('adm_edit_question', 'adm_edit_question_warn', " . commune::POLL_ANSWER_CHARS_MAX . ");"; $objResponse->assign('h4_adm_edit', 'innerHTML', 'Редактировать сообщение'); $objResponse->assign('div_adm_edit', 'innerHTML', $sHtml); $objResponse->script("\$('div_adm_reason').setStyle('display', 'none');"); $objResponse->script("adm_edit_content.editMenuItems = ['', 'Основное', 'Файлы', 'Опрос'];"); $objResponse->script('adm_edit_content.edit();'); $objResponse->script($sAttach); $objResponse->script($sOnReady); $objResponse->script('xajax_getAdmEditReasons(' . admin_log::ACT_ID_EDIT_COMMUNITY . ');'); }
$attachedfiles_session = $_POST['attachedfiles_session']; $attachedfiles = new attachedfiles($attachedfiles_session); if ($draft_id) { if (!$attachedfiles_session) { $attachedfiles_tmpdraft_files = drafts::getAttachedFiles($draft_id, 2); if ($attachedfiles_tmpdraft_files) { $attachedfiles_prj_files = array(); foreach ($attachedfiles_tmpdraft_files as $attachedfiles_draft_file) { $attachedfiles_draft_files[] = $attachedfiles_draft_file; } $attachedfiles->setFiles($attachedfiles_draft_files, 1); } } } else { if ($action == 'Edit.post' && !$alert) { $attachedfiles_tmpblog_files = commune::getAttachedFiles($top['id']); if ($attachedfiles_tmpblog_files) { $attachedfiles_blog_files = array(); foreach ($attachedfiles_tmpblog_files as $attachedfiles_blog_file) { $attachedfiles_blog_files[] = $attachedfiles_blog_file; } $attachedfiles->setFiles($attachedfiles_blog_files); } } } $attachedfiles_files = $attachedfiles->getFiles(); if ($attachedfiles_files) { $n = 0; foreach ($attachedfiles_files as $attachedfiles_file) { echo "attachedfiles_list[{$n}] = new Object;\n"; echo "attachedfiles_list[{$n}].id = '" . md5($attachedfiles_file['id']) . "';\n";