/** * Отдает 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 . ');'); }
function AddFav($backto, $backto2, $message_id, $user_id, $om, $undo, $priority = 0) { $objResponse = new xajaxResponse(); if (get_uid(false) != $user_id) { return $objResponse; } $sort = $_COOKIE['commune_fav_order'] != '' ? $_COOKIE['commune_fav_order'] : 'date'; if (commune::AddFav($message_id, $user_id, $undo, $priority)) { if (!$undo) { $objResponse->assign($backto, 'src', commune::getStarByPR($priority)); //$objResponse->assign($backto, "onclick", 'return true;'); $msg = commune::GetMessage($message_id); $favs = commune::GetFavorites($user_id, NULL, $sort, $msg['commune_id']); $objResponse->assign('favBlock', 'innerHTML', __commPrntFavs($favs, $user_id, $om)); $objResponse->script("{$backto}.setAttribute('on',1);"); } else { $objResponse->assign($backto, 'src', '/images/bookmarks/bsw.png'); //$objResponse->assign($backto, "onclick", "ShowFavFloat({$msg_id}, {$user_id}, {$om})"); $objResponse->remove($backto2); $objResponse->script("\n {$backto}.setAttribute('on',0);\n if(favBlock.innerHTML.match(/<LI[^>]*>/i)==null)\n favBlock.innerHTML = 'Нет закладок';\n "); } } $objResponse->script('communeObj.initFavs();'); return $objResponse; }
$js_file_utf8[] = '/scripts/ckedit/ckeditor.js'; $js_file = array_merge($js_file, array('comment_form.js')); break; case 'Editdraft': $commune_output = 'tpl.topic_form.php'; $js_file_utf8[] = '/scripts/ckedit/ckeditor.js'; $js_file = array_merge($js_file, array('comment_form.js')); break; default: if (isset($_GET['om']) && $_GET['om'] == '0') { header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . e_url('om')); exit(0); } if ($mode == 'Back') { if ($top_id && ($mess = commune::GetMessage($top_id))) { $om = __paramInit('int', 'om', 'om', commune::OM_TH_NEW); $page = ceil(commune::GetTopMessagePosition($top_id, $uid, $om) / (double) commune::MAX_TOP_ON_PAGE); $page = $mess['pos'] !== NULL ? 1 : $page; header("Location: /commune/?id={$mess['commune_id']}" . ($om ? "&om={$om}" : '') . "&page={$page}" . ($rating ? '&rating=' . $rating : '')); } else { header('Location: /commune/'); } exit; } if (!$id) { // дополнительный параметр сортировки if ($_GET['sub_om']) { $sub_om = $_GET['sub_om']; setcookie("commune_{$om}_ord", $sub_om, strtotime('+10 years')); } else {
<?php $message_id = $top_id; if (!$action) { $action = 'Create.post'; } $title = ''; $msgtext = ''; $attach = ''; $youtube_link = ''; $user_login = ''; // Чтобы в него загрузить картинку. $pos = NULL; $close_comments = NULL; $is_private = NULL; $category = 0; $mess = commune::GetMessage(intval($message_id)); if ($request) { // do... $parent_id = $request['parent_id']; $title = htmlspecialchars(stripslashes($request['title'])); $category_id = $request['category_id']; $msgtext = stripslashes($request['msgtext']); $attach = $request['attach']; $youtube_link = $request['youtube_link']; $user_login = $request['user_login']; $pos = $request['pos']; $close_comments = $request['close_comments'] ? true : false; $is_private = $request['is_private'] ? true : false; $question = stripslashes($request['question']); $multiple = $request['multiple']; } elseif ($action == 'Edit.post') {
/** * Рисует форму для создания/редактирования комментария. * * Пользователь создает комментарий. * 1. Вызывается данная форма с пустыми полями, подставляется под сообщение, * которое комментируется. При этом удаляется со страницы ранее вызванная форма, * если таковая была. * 2. Пользователь заполняет поля, вызывается POST. POST несет: * - id (ид. сообщества); * - action = do.Create.post; * - top_id; * - parent_id; * - om (закладка); * - title; * - msgtext; * - file; * Остальные поля NULL. * * 3. POST-запрос обрабатывается и: * - в случае успеха выдает текущую страницу (страницу с текущей темой), * движок прыгает на новый комментарий. * - в случае неудачи, обработчик возвращает объект $request (почти тот же $_POST, * только малость измененный) и $alert. Страница проверяет наличие $request и если * он не NULL и $request['message_id'] совпадает id текущего комментария, то * выводит данную форму под этим комментарием, заполняя ее данными из $request * и выдает ошибки через $alert. * Пользователь редактирует комментарий. * 1. AJAX-ом вызывается данная форма, $action='Edit.post'. Форма заполняется атрибутами редактируемого сообщения, * взятыми AJAX-ом из базы. * 2. Пользователь заполняет поля, вызывается POST. POST несет все параметры, action = do.Edit.post; * * @param integer $id ид. сообщества. * @param integer $om для поддержания параметров навигации. * @param integer $page страница * @param string $action тип операции при субмите. * @param integer $top_id ид. топа (не темы, а корневого сообщения в теме). Используется только когда $site=='Topic'. * @param integer $message_id если указан, значит это сообщение редактируется. * @param integer $parent_id комментируем данное сообщение (создаем новое). * @param string $request возвращается при ошибке при совершении операции. * @param string $alert ошибки операции. * @param string $site режим вывода. * @param integer $mod админ, модер и т.д. * @return string */ function __commPrntCommentForm($id, $om, $page = NULL, $action = NULL, $top_id = NULL, $message_id = NULL, $parent_id = NULL, $request = NULL, $alert = NULL, $site = NULL, $mod = NULL, $cat = 0, $draft_id = 0) { if (!$action) { $action = 'Create.post'; } $title = ''; $msgtext = ''; $attach = ''; $youtube_link = ''; $user_login = ''; // Чтобы в него загрузить картинку. $pos = NULL; $close_comments = NULL; $is_private = NULL; $category = 0; $mess = commune::GetMessage(intval($message_id)); if ($request) { // do... $parent_id = $request['parent_id']; $title = __htmlchars($request['title']); $category_id = $request['category_id']; $msgtext = __htmlchars($request['msgtext']); $attach = $request['attach']; $youtube_link = $request['youtube_link']; $user_login = $request['user_login']; $pos = $request['pos']; $close_comments = $request['close_comments'] ? true : false; $is_private = $request['is_private'] ? true : false; $question = __htmlchars($request['question']); $multiple = $request['multiple']; } else { if ($action == 'Edit.post') { // Edit.post if ($mess) { $parent_id = $mess['parent_id']; $title = $mess['title']; $category_id = $mess['category_id']; $msgtext = htmlspecialchars($mess['msgtext']); $attach = $mess['attach']; $youtube_link = $mess['youtube_link']; $user_login = $mess['user_login']; $pos = $mess['pos']; $close_comments = $mess['close_comments'] == 't' ? true : false; $is_private = $mess['is_private'] == 't' ? true : false; $question = $mess['question']; $multiple = $mess['multiple'] == 't' ? 1 : 0; } } } $answers = array(); $exists = isset($request['answers_exists']) && is_array($request['answers_exists']) ? $request['answers_exists'] : array(); if ($mess['question'] != '') { for ($i = 0; $i < count($mess['answers']); $i++) { $ok = !isset($request['question']); for ($j = 0; $j < count($exists); $j++) { if (!empty($exists[$mess['answers'][$i]['id']])) { $ok = TRUE; break; } } if ($ok) { $answers[] = array('id' => $mess['answers'][$i]['id'], 'answer' => $exists[$mess['answers'][$i]['id']] ? __htmlchars($exists[$mess['answers'][$i]['id']]) : $mess['answers'][$i]['answer']); } } } if (isset($request['answers']) && is_array($request['answers'])) { foreach ($request['answers'] as $answer) { $answers[] = array('id' => 0, 'answer' => __htmlchars($answer)); } } if (!$answers) { $answers[] = array('id' => 0, 'answer' => ''); } $h = $site == 'Topic' ? 'H1' : 'H2'; $header = !$message_id ? $site == 'Topic' ? 'Комментировать' : 'Создать новое сообщение' : 'Редактировать'; $button = !$message_id ? $site == 'Topic' ? 'Комментировать' : 'Создать' : 'Сохранить'; $tah = $site == 'Topic' ? '150' : '200'; $action = str_replace('do.', '', $action); $anchor = ''; if ($site != 'Topic') { if ($alert) { $anchor = $action == 'Edit.post' ? 'o' . ($message_id ? $message_id : $parent_id) : 'o'; } else { $anchor = 'bottom'; } } else { if ($alert) { $anchor = 'op'; } } $pt = $site == 'Topic' ? '25' : '0'; $pb = $site == 'Topic' ? '25' : '0'; $iid = mt_rand(1, 50000); $sub_cat = commune::getCategories($id, true); ob_start(); include TPL_COMMUNE_PATH . '/tpl.comment_form_new.php'; $str = ob_get_contents(); ob_end_clean(); return $str; }