"", "result" => "", ); //---------------------------- // request parameter //---------------------------- $qProjectID = isset($_SESSION["project_id"]) ? $_SESSION["project_id"] : REQ_NON; $qKind = isset($_REQUEST["q_kind"]) ? $_REQUEST["q_kind"] : REQ_NON; $qID = isset($_REQUEST["q_id"]) ? $_REQUEST["q_id"] : REQ_NON; //---------------------------- // judge post //---------------------------- //---------------------------- // set types //---------------------------- Util::setType($qProjectID, "int"); Util::setType($qKind, "string"); Util::setType($qID, "int"); //---------------------------- // Auth-Before validate //---------------------------- if ( $result === RES_OK ){ if ( ! Validate::inKeyArray($qKind, Term::KIND_TABLE()) ){ $result = RES_NG; $gResult->push("{$WORD($wk, 1)}"); } if ( ! Validate::isNumeric($qID) ){ $result = RES_NG; $gResult->push("{$WORD($wk, 2)}"); } if ( ! Validate::isNumeric($qProjectID) ){ $result = RES_NG; $gResult->push("{$WORD($wk, 3)}"); } } //---------------------------- // Auth //---------------------------- if ( $result === RES_OK ){ $auth = Auth::instance("term_root", $qKind); if ( ! $auth->processExport($qID, $qProjectID) ){ $result = RES_NG; $gResult->push("{$WORD($wk, 4)}"); } } //---------------------------- // Auth-After validate //---------------------------- if ( $result === RES_OK ){ } //---------------------------- // function //---------------------------- //---------------------------- // process //---------------------------- if ( $result === RES_OK ){ $objDAOTerm = DAO::instance("term", $qKind); if ( $result === RES_OK ){ if ( ($pathFile = tempnam(Setting::get("PATH_DATA_TMP"), "ex")) === FALSE ){ $result = RES_NG; } } if ( ($fp = fopen($pathFile, "w")) === FALSE ){ $result = RES_NG; } if ( $result === RES_OK ){ $offset = 0; while ( TRUE ){ $resDAOTerm = $objDAOTerm->get($qID, NULL, HTML_LIMIT_SPAN, $offset); $result = $resDAOTerm["result"]; if ( $result === RES_OK ){ foreach ( $resDAOTerm["data"] as $dataTerm ){ $termTextS = $dataTerm["t_term_text_s"]; $termTextT = $dataTerm["t_term_text_t"]; $termTextS = preg_replace("/(\r|\n|\r\n)/", "", $termTextS); $termTextT = preg_replace("/(\r|\n|\r\n)/", "", $termTextT); fwrite($fp, "{$termTextS}\t{$termTextT}\r\n"); } } else { if ( $result === RES_NO_DATA ){ $result = RES_OK; } break; } $offset += HTML_LIMIT_SPAN; } fclose($fp); } if ( $result === RES_OK ){ header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"term_{$qID}.tsv\""); header("Content-Length: " . filesize($pathFile)); echo file_get_contents($pathFile); unlink($pathFile); exit(); } // 結果 -------------------- if ( $result !== RES_OK ){ $gResult->push("{$WORD($wk, 5)}"); } } //---------------------------- // menu //---------------------------- { // title --------------------------------------------------------------- $title = "{$WORD($wk, 6)}"; // form ---------------------------------------------------------------- // アクション(OK) $arrHtml["form"] = Printer::link("OK", "btn btn-default", NULL, NULL, "/content/project/"); // result -------------------------------------------------------------- $arrHtml["result"] = $gResult->string(TRUE, $result); } ?>