"",
"result" => "",
"form" => "",
"qredit" => "",
"dialog" => "",
);
session_regenerate_id(true); //session_idを更新する
//----------------------------
// request parameter
//----------------------------
$qID = isset($_REQUEST["q_id"]) ? $_REQUEST["q_id"] : REQ_NON;
$qTaskID = isset($_REQUEST["q_task_id"]) ? $_REQUEST["q_task_id"] : REQ_NON;
$qMode = isset($_REQUEST["q_mode"]) ? $_REQUEST["q_mode"] : REQ_NON;
//----------------------------
// judge post
//----------------------------
//----------------------------
// set types
//----------------------------
Util::setType($qID, "int");
Util::setType($qTaskID, "int");
Util::setType($qMode, "int");
//----------------------------
// Auth-Before validate
//----------------------------
if ( $result === RES_OK ){
if ( ! Validate::isNumeric($qID) ){
$result = RES_NG;
$gResult->push("{$WORD($wk, 1)}");
}
if ( ! Validate::inKeyArray($qMode, Document::QREDIT_MODE_TABLE()) ){
$result = RES_NG;
$gResult->push("{$WORD($wk, 2)}");
}
}
//----------------------------
// Auth
//----------------------------
if ( $result === RES_OK ){
$auth = Auth::instance("document");
if( ! $auth->processEditor($qID, NULL) ){
$result = RES_NG;
$gResult->push("{$WORD($wk, 3)}");
}
}
//----------------------------
// Auth-After validate
//----------------------------
if ( $result === RES_OK ){
if ( ! Validate::isNumeric($qTaskID) ){
$qTaskID = NULL;
}
}
//----------------------------
// function
//----------------------------
//----------------------------
// process
//----------------------------
if ( $result === RES_OK ){
DAO::begin();
$objDAODocument = DAO::instance("document");
$objDAOTaskDocument = DAO::instance("task_document");
$objDAOUser = DAO::instance("user");
$objViewDocument = View::instance("document");
// セッションID登録 --------------------
if ( $result === RES_OK ){
$resDAOUser = $objDAOUser->register(User::get("id"), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, session_id());
$result = $resDAOUser["result"];
if ( $result !== RES_OK ){
$result = RES_NG;
$gResult->push("{$WORD($wk, 4)}");
}
}
// 文書取得 --------------------
if ( $result === RES_OK ){
$objDAODocument->setAuth($auth);
$resDAODocument = $objDAODocument->get($qID, array_keys(DAO::T_DOCUMENT_STATE_VALID_TABLE()));
$result = $resDAODocument["result"];
if ( $result === RES_OK ){
$dataDocument = $resDAODocument["data"][0];
// プロジェクトID
$projectID = $dataDocument["t_project_id"];
// タイトル
$title = $dataDocument["t_document_title"];
// テキスト
$arrHtml["qredit"] = $objViewDocument->qredit($qMode, $dataDocument);
} else {
$result = RES_NG;
$gResult->push("{$WORD($wk, 5)}");
}
}
// 文書関連タスクID取得 --------------------
if ( $result === RES_OK ){
$resDAOTaskDocument = $objDAOTaskDocument->get(NULL, $qID);
$result = $resDAOTaskDocument["result"];
if ( $result === RES_OK ){
foreach ( $resDAOTaskDocument["data"] as $dataTaskDocument ){
$arrTaskID[] = $dataTaskDocument["t_task_id"];
}
} else {
$gResult->push("{$WORD($wk, 6)}");
}
}
DAO::end($result);
}
//----------------------------
// menu
//----------------------------
{
// menu ----------------------------------------------------------------
$arrMenu = array();
if ( $result === RES_OK ){
$loaderIcon = "";
// ボタン(一時保存)
$arrMenu[] = Printer::link("{$WORD($wk, 7)} {$loaderIcon}", "editor-button", "icon-hdd", NULL, NULL, NULL, array("id"=>"btnTemporarySave"), FALSE);
// ボタン(翻訳確定)
$arrMenu[] = Printer::link("{$WORD($wk, 8)} {$loaderIcon}", "editor-button", "icon-ok-circle", NULL, NULL, NULL, array("id"=>"btnEditSave"), FALSE);
// ボタン(修正確定)
$arrMenu[] = Printer::link("{$WORD($wk, 9)} {$loaderIcon}", "editor-button", "icon-ok-circle", NULL, NULL, NULL, array("id"=>"btnCorrectSave"), FALSE);
// ボタン(用語)
//$arrMenu[] = Printer::link("{$WORD($wk, 10)}", "btn btn-xs btn-default", "icon-plus", NULL, NULL, "minhon.qredit.showTermForm();");
}
// ボタン(閉じる)
$arrMenu[] = Printer::link("{$WORD($wk, 11)}", NULL, "icon-remove", NULL, NULL, NULL, array("id" => "btnClose"));
// title ---------------------------------------------------------------
$objViewDocument = View::instance("document");
$arrHtml["title"] = $objViewDocument->editorHeader($dataDocument, $arrMenu);
// form ----------------------------------------------------------------
$arrControl = array();
$arrAction = array();
if ( $result === RES_OK ){
// フォーム(token)
$arrControl[] = array(
"id" => NULL,
"name" => NULL,
"form" => Printer::input("hidden", "q_token_qredit", "q_token_qredit", Util::token("q_token_qredit")),
);
$arrHtml["form"] = Printer::form("form_qredit", "form_qredit", NULL, "post", $arrControl, $arrAction);
}
// dialog ----------------------------------------------------------------
$arrHtml["dialog"] .= <<< HTML