public static function import_cancel() { $moduleId = 'prmedia.treelikecomments'; // retrieve or init session storage $sessionStorage = $_SESSION['tlc_import_cancel']; if ($_REQUEST['start'] == 'Y') { $sessionStorage = array( 'processing_time' => time(), 'current_count' => 0, 'total_count' => CTreelikeForumImporter::getImportedCount() ); } // import cancel comments... $obComment = new CTreelikeComments; global $DB; $is_finish = true; $currentTime = time(); $rsCommentId = $DB->Query('SELECT COMMENT_ID FROM prmedia_treelike_comments_import_forum'); while ($arCommentId = $rsCommentId->Fetch()) { $is_finish = false; $commentId = intval($arCommentId['COMMENT_ID']); $obComment->Delete($commentId); CTreelikeForumImporter::removeImportedComment($commentId); $sessionStorage['current_count']++; // one step is one second if ($currentTime != time()) { break; } } if ($is_finish) { // go to finish step echo '<script>document.getElementsByClassName("wizard-next-button")[0].click();</script>'; CTreelikeForumImporter::clearCache(); return; } // progress message $text = GetMessage('PRMEDIA_WIZARDS_IMPORT_CANCEL_FORUM_PROGRESS_MESSAGE'); $arReplace = array( "#IMPORTED#" => $sessionStorage['current_count'], "#COUNT#" => $sessionStorage['total_count'], "#TIME#" => gmdate("i:s", time() - $sessionStorage['processing_time']) ); $progressMessage = str_replace(array_keys($arReplace), $arReplace, $text); CAdminMessage::ShowMessage(array( "TYPE" => "PROGRESS", "MESSAGE" => GetMessage('PRMEDIA_SS_DIST_CANCEL_PROGRESS_TITLE'), "DETAILS" => $progressMessage, "HTML" => true, "PROGRESS_VALUE" => $sessionStorage['current_count'], "PROGRESS_TOTAL" => $sessionStorage['total_count'] )); echo "<script>jsPrmediaCommentImporter.update();</script>"; $_SESSION['tlc_import_cancel'] = $sessionStorage; }
function ShowStep() { $content = str_replace('#FIRST_ELEMENT#', $_SESSION['tlc_import']['first_element'], GetMessage('PRMEDIA_TLC_IMPORT_FINAL_CONTENT')); $content = str_replace('#ACTUAL_COUNT#', $_SESSION['tlc_import']['actual_count'], $content); $content = str_replace('#COMMENTS#', CTreelikeForumImporter::getNumericSuffix(GetMessage('PRMEDIA_TLC_IMPORT_COMMENTS'), $_SESSION['tlc_import']['actual_count']), $content); $content = str_replace('#IMPORTED#', CTreelikeForumImporter::getNumericSuffix(GetMessage('PRMEDIA_TLC_IMPORT_IMPORTED'), $_SESSION['tlc_import']['actual_count']), $content); $this->content = $content; }
<? // prolog require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_admin_before.php'); // include required modules if (!CModule::IncludeModule('prmedia.treelikecomments')) { return false; } CTreelikeForumImporter::import_cancel(); ?>
<? // prolog require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_admin_before.php'); // include required modules if (!CModule::IncludeModule('prmedia.treelikecomments')) { return false; } CTreelikeForumImporter::import(); ?>