plugin default > base $objQuery =& SC_Query_Ex::getSingletonInstance(); $where = 'operation_name Like ? AND del_flg = 0 AND enable = 1'; $arrApiConfig = $objQuery->getRow('*', 'dtb_api_config', $where, array($operation_name)); if (SC_Utils_Ex::isBlank($arrApiConfig)) { $objApi = SC_Api_Utils_Ex::loadApiOperation($operation_name); if (is_object($objApi)) { $arrApiConfig = $objApi->getDefaultConfig(); } if (!SC_Utils_Ex::isBlank($arrApiConfig)) { // デフォルト設定がロード出来た場合は自動で設定に反映 $arrData = $arrApiConfig; $arrData['update_date'] = 'CURRENT_TIMESTAMP'; $arrData['api_config_id'] = $objQuery->nextVal('dtb_api_config_api_config_id'); $objQuery->insert('dtb_api_config', $arrData); } else { // ロード出来ない場合はAPI_Defaultを適用 $operation_name = 'Default'; $objApi = SC_Api_Utils_Ex::loadApiOperation($operation_name); $arrApiConfig = $objApi->getDefaultConfig(); } } return $arrApiConfig; } /** * APIログ * * @param text $msg 出力文字列 * @param text $operation_name @ @rturn void */ public function printApiLog($msg, $start_time = '' , $operation_name = '') { if (!SC_Utils_Ex::isBlank($operation_name)) { $msg = 'API_' . $operation_name . ':' . $msg; } if (!SC_Utils_Ex::isBlank($start_time)) { $msg = '(RequestId:' . $start_time . ')' . $msg; } GC_Utils_Ex::gfPrintLog($msg, DATA_REALDIR . self::API_LOGFILE, self::API_DEBUG_MODE); } /** * APIオペレーションに対応したAPIクラスをインスタンス化 * * @param string $operation_name オペレーション名 * @param array $arrParam リクエストパラメーター * @return object APIオペレーションクラスオブジェクト */ public function loadApiOperation($operation_name, $arrParam = array()) { // API_UPLOADのほうが優先 // API_UPLOAD > API_CLASS_EX > API_CLASS if (file_exists(API_UPLOAD_REALDIR . $operation_name . '.php')) { $api_operation_file = API_UPLOAD_REALDIR . $operation_name . '.php'; $api_class_name = 'API_' . $operation_name; } elseif (file_exists(API_CLASS_EX_REALDIR . $operation_name . '_Ex.php')) { $api_operation_file = API_CLASS_EX_REALDIR . $operation_name . '_Ex.php'; $api_class_name = 'API_' . $operation_name . '_Ex'; } elseif (file_exists(API_CLASS_REALDIR . $operation_name . '.php')) { $api_operation_file = API_CLASS_REALDIR . $operation_name . '.php'; $api_class_name = 'API_' . $operation_name; } else { return false; } require_once $api_operation_file; $objApiOperation = new $api_class_name ($arrParam); return $objApiOperation; } /** * API Operationファイル一覧 * * @return array $arrFiles */ public function getApiDirFiles() { $arrFiles = array(); // Core API ディレクトリ if (is_dir(API_CLASS_EX_REALDIR)) { if ($dh = opendir(API_CLASS_EX_REALDIR)) { while (($file_name = readdir($dh)) !== false) { if ($file_name != '.' && $file_name != '..' && substr($file_name, -4) == '.php') { $arrFiles[] = API_CLASS_EX_REALDIR . $file_name; } } closedir($dh); } } // downaloads APIディレクトリ (for Plugin) if (is_dir(API_UPLOAD_REALDIR)) { if ($dh = opendir(API_UPLOAD_REALDIR)) { while (($file_name = readdir($dh)) !== false) { if ($file_name != '.' && $file_name != '..' && substr($file_name, -4) == '.php') { $arrFiles[] = API_UPLOAD_REALDIR . $file_name; } } closedir($dh); } } return $arrFiles; } public function sendResponseJson($response_outer_name, &$arrResponse) { header('Content-Type: application/json; charset=UTF-8'); $arrResponse['response_name'] = $response_outer_name; echo SC_Utils_Ex::jsonEncode($arrResponse); } public function sendResponsePhp($response_outer_name, &$arrResponse) { header('Content-Type: application/php; charset=UTF-8'); $arrResponse['response_name'] = $response_outer_name; echo serialize($arrResponse); } public function sendResponseXml($response_outer_name, &$arrResponse) { require_once 'XML/Serializer.php'; $options = array( 'mode' => 'simplexml', 'indent' => "\t", 'linebreak' => "\n", 'typeHints' => false, 'addDecl' => true, 'encoding' => 'UTF-8', 'rootName' => $response_outer_name, 'rootAttributes' => array('xmlns' => self::API_XMLNS . ECCUBE_VERSION, 'xml:lang' => self::API_XML_LANG), 'defaultTagName' => 'Response', 'attributesArray' => '_attributes' ); $objSerializer = new XML_Serializer($options); $ret = $objSerializer->serialize($arrResponse); $xml = $objSerializer->getSerializedData(); header('Content-Type: text/xml; charset=UTF-8'); echo $xml; } }