[Svn-src-all:818] [version-2_5-dev 19705] #627(ソース整形・ソースコメントの改善)
nanasess
admin @ mail.ec-cube.net
2010年 12月 2日 (木) 18:14:39 JST
Subversion committed to /home/svn/open 19705
http://svn.ec-cube.net/open_trac/changeset/19705
┌────────────────────────────┐
│更新者 : nanasess │
│更新日時: 2010-12-02 18:14:39 +0900 (木, 02 12月 2010)│
└────────────────────────────┘
Log:
--------------------------------------------------------
#627(ソース整形・ソースコメントの改善)
* 仮定義の関数名を修正
* フォーマットを修正
Changed: [U:修正,A:追加,D:削除]
--------------------------------------------------------
U branches/version-2_5-dev/data/class/SC_Display.php
U branches/version-2_5-dev/data/class/SC_Response.php
U branches/version-2_5-dev/data/class/SC_SmartphoneUserAgent.php
U branches/version-2_5-dev/data/class/pages/LC_Page.php
U branches/version-2_5-dev/data/class/pages/admin/LC_Page_Admin.php
変更: branches/version-2_5-dev/data/class/SC_Display.php
===================================================================
--- branches/version-2_5-dev/data/class/SC_Display.php 2010-12-02 00:04:13 UTC (rev 19704)
+++ branches/version-2_5-dev/data/class/SC_Display.php 2010-12-02 09:14:39 UTC (rev 19705)
@@ -1,5 +1,32 @@
<?php
-// TODO GPLのあれ
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * Http コンテンツ出力を制御するクラス.
+ *
+ * @author Ryuichi Tokugami
+ * @version $Id$
+ */
class SC_Display{
var $response;
@@ -8,43 +35,41 @@
var $autoSet;
- /**
- *
- * @var SC_View
- */
+ /** SC_View インスタンス */
var $view;
-
+
var $deviceSeted = false;
-
- // TODO php4を捨てたときに ここのコメントアウトを外してね。
+
/*
- * const('MOBILE',1);
- * const('SMARTPHONE',2);
- * const('PC',4);
- * const('ADMIN',8);
- */
- function SC_Display($setPrevURL=true,$autoGenerateHttpHeaders = true){
- require_once(CLASS_EX_PATH."/SC_Response_Ex.php");
+ * TODO php4を捨てたときに ここのコメントアウトを外してね。
+ * const('MOBILE',1);
+ * const('SMARTPHONE',2);
+ * const('PC',4);
+ * const('ADMIN',8);
+ */
+
+ function SC_Display($hasPrevURL = true, $autoGenerateHttpHeaders = true) {
+ require_once(CLASS_EX_PATH . "SC_Response_Ex.php");
$this->response = new SC_Response_Ex();
$this->autoSet = $autoGenerateHttpHeaders;
- if ($setPrevURL) {
+ if ($hasPrevURL) {
$this->setPrevURL();
}
}
-
+
function setPrevURL(){
+ // TODO SC_SiteSession で実装した方が良さげ
$objCartSess = new SC_CartSession();
$objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
-
}
-
- // TODO このメソッドは、レスポンスを返すためのメソッドです。名前を絶対に変えましょう。
/**
- *
- * @param $page LC_Page
- */
- function hoge($page, $is_admin = false){
+ * LC_Page のパラメータを, テンプレートに設定し, 出力の準備を行う.
+ *
+ * @param LC_Page $page LC_Page インスタンス
+ * @param $is_admin boolean 管理画面を扱う場合 true
+ */
+ function prepare($page, $is_admin = false){
if(!$this->deviceSeted || !is_null($this->view)){
$device = ($is_admin) ? 8 : $this->detectDevice();
$this->setDevice($device);
@@ -52,19 +77,32 @@
$this->assignobj($page);
$this->response->setResposeBody($this->view->getResponse($page->getTemplate()));
}
-
+
+ /**
+ * リダイレクトを行う.
+ *
+ * SC_Response::sendRedirect() のラッパーです.
+ */
function redirect($location){
$this->response->sendRedirect($location);
}
-
+
+ /**
+ * リロードを行う.
+ *
+ * SC_Response::reload() のラッパーです.
+ */
function reload($queryString = array(), $removeQueryString = false){
$this->response->reload($queryString, $removeQueryString);
}
-
- function noAction(){
+
+ function noAction(){
return;
}
-
+
+ /**
+ * ヘッダを追加する.
+ */
function addHeader($name, $value){
$this->response->addHeader($name, $value);
}
@@ -74,7 +112,7 @@
* Enter description here ...
*/
function setDevice($device=4){
-
+
switch ($device){
case 1:
$this->response->setContentType("text/html");
@@ -91,9 +129,11 @@
}
$this->deviceSeted = true;
}
-
+
+ /**
+ * SC_View インスタンスを設定する.
+ */
function setView($view){
-
$this->view = $view;
}
@@ -134,6 +174,4 @@
function assignarray($array){
$this->view->assignarray($array);
}
-
-
}
変更: branches/version-2_5-dev/data/class/SC_Response.php
===================================================================
--- branches/version-2_5-dev/data/class/SC_Response.php 2010-12-02 00:04:13 UTC (rev 19704)
+++ branches/version-2_5-dev/data/class/SC_Response.php 2010-12-02 09:14:39 UTC (rev 19705)
@@ -1,14 +1,36 @@
<?php
-// TODO GPLのあれ
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * HttpResponse を扱うクラス.
+ *
+ * @author Ryuichi Tokugami
+ * @version $Id$
+ */
class SC_Response{
/**
- *
- * @var HTTP_Response
- */
- var $http;
- /**
- * コンテンツタイフ
+ * コンテンツタイプ
* Enter description here ...
* @var unknown_type
*/
@@ -18,48 +40,48 @@
var $header = array();
var $statusTexts = array(
- '100' => 'Continue',
- '101' => 'Switching Protocols',
- '200' => 'OK',
- '201' => 'Created',
- '202' => 'Accepted',
- '203' => 'Non-Authoritative Information',
- '204' => 'No Content',
- '205' => 'Reset Content',
- '206' => 'Partial Content',
- '300' => 'Multiple Choices',
- '301' => 'Moved Permanently',
- '302' => 'Found',
- '303' => 'See Other',
- '304' => 'Not Modified',
- '305' => 'Use Proxy',
- '306' => '(Unused)',
- '307' => 'Temporary Redirect',
- '400' => 'Bad Request',
- '401' => 'Unauthorized',
- '402' => 'Payment Required',
- '403' => 'Forbidden',
- '404' => 'Not Found',
- '405' => 'Method Not Allowed',
- '406' => 'Not Acceptable',
- '407' => 'Proxy Authentication Required',
- '408' => 'Request Timeout',
- '409' => 'Conflict',
- '410' => 'Gone',
- '411' => 'Length Required',
- '412' => 'Precondition Failed',
- '413' => 'Request Entity Too Large',
- '414' => 'Request-URI Too Long',
- '415' => 'Unsupported Media Type',
- '416' => 'Requested Range Not Satisfiable',
- '417' => 'Expectation Failed',
- '500' => 'Internal Server Error',
- '501' => 'Not Implemented',
- '502' => 'Bad Gateway',
- '503' => 'Service Unavailable',
- '504' => 'Gateway Timeout',
- '505' => 'HTTP Version Not Supported',
- );
+ '100' => 'Continue',
+ '101' => 'Switching Protocols',
+ '200' => 'OK',
+ '201' => 'Created',
+ '202' => 'Accepted',
+ '203' => 'Non-Authoritative Information',
+ '204' => 'No Content',
+ '205' => 'Reset Content',
+ '206' => 'Partial Content',
+ '300' => 'Multiple Choices',
+ '301' => 'Moved Permanently',
+ '302' => 'Found',
+ '303' => 'See Other',
+ '304' => 'Not Modified',
+ '305' => 'Use Proxy',
+ '306' => '(Unused)',
+ '307' => 'Temporary Redirect',
+ '400' => 'Bad Request',
+ '401' => 'Unauthorized',
+ '402' => 'Payment Required',
+ '403' => 'Forbidden',
+ '404' => 'Not Found',
+ '405' => 'Method Not Allowed',
+ '406' => 'Not Acceptable',
+ '407' => 'Proxy Authentication Required',
+ '408' => 'Request Timeout',
+ '409' => 'Conflict',
+ '410' => 'Gone',
+ '411' => 'Length Required',
+ '412' => 'Precondition Failed',
+ '413' => 'Request Entity Too Large',
+ '414' => 'Request-URI Too Long',
+ '415' => 'Unsupported Media Type',
+ '416' => 'Requested Range Not Satisfiable',
+ '417' => 'Expectation Failed',
+ '500' => 'Internal Server Error',
+ '501' => 'Not Implemented',
+ '502' => 'Bad Gateway',
+ '503' => 'Service Unavailable',
+ '504' => 'Gateway Timeout',
+ '505' => 'HTTP Version Not Supported',
+ );
/**
@@ -68,17 +90,19 @@
*/
var $encoding;
- function SC_Response(){
+ function SC_Response() {
}
- function response(){
+ /**
+ * レスポンス出力を書き込む.
+ */
+ function write() {
$this->sendHeader();
-
echo $this->body;
}
- function sendHeader(){
- // HTTPのヘッタ
+ function sendHeader() {
+ // HTTPのヘッダ
// header('HTTP/1.1 '.$this->statuscode.' '.$this->statusTexts[$this->statuscode]);
foreach ($this->header as $name => $head){
header($name.': '.$head);
@@ -86,7 +110,7 @@
}
- function setContentType($contentType){
+ function setContentType($contentType) {
$this->header['Content-Type'] = $contentType;
}
@@ -94,24 +118,19 @@
$this->body = $body;
}
- /* function addDateHdeader($name, $date){
- *
- * }
- */
-
- function addHeader($name, $value){
+ function addHeader($name, $value) {
$this->header[$name] = $value;
}
- function containsHeader($name){
+ function containsHeader($name) {
return isset($this->header[$name]);
}
- function sendError($errorcode){
+ function sendError($errorcode) {
header('HTTP/1.1 '.$errorcode.' '.$this->statusTexts[$errorcode]);
}
- function sendRedirect($location){
+ function sendRedirect($location) {
if (preg_match("/(" . preg_quote(SITE_URL, '/')
. "|" . preg_quote(SSL_URL, '/') . ")/", $location)) {
@@ -151,11 +170,11 @@
$this->sendRedirect($netURL->getURL());
}
- function setHeader($headers){
+ function setHeader($headers) {
$this->header = $headers;
}
- function setStatus($sc = 202){
+ function setStatus($sc = 202) {
$this->statuscode = $sc;
}
変更: branches/version-2_5-dev/data/class/SC_SmartphoneUserAgent.php
===================================================================
--- branches/version-2_5-dev/data/class/SC_SmartphoneUserAgent.php 2010-12-02 00:04:13 UTC (rev 19704)
+++ branches/version-2_5-dev/data/class/SC_SmartphoneUserAgent.php 2010-12-02 09:14:39 UTC (rev 19705)
@@ -23,8 +23,9 @@
require_once(dirname(__FILE__) . '/../module/Net/UserAgent/Mobile.php');
/**
- * スマートフォンの情報を扱うクラス
+ * スマートフォンの情報を扱うクラス.
*
+ * @auther Yu Nobira
*/
class SC_SmartphoneUserAgent {
@@ -88,6 +89,7 @@
: SPHONE_SITE_URL
;
+ // XXX サニタイズ必要?
$url .= (preg_match('|^' . URL_DIR . '(.*)$|', $_SERVER['REQUEST_URI'], $matches))
? $matches[1]
: ''
変更: branches/version-2_5-dev/data/class/pages/LC_Page.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/LC_Page.php 2010-12-02 00:04:13 UTC (rev 19704)
+++ branches/version-2_5-dev/data/class/pages/LC_Page.php 2010-12-02 09:14:39 UTC (rev 19705)
@@ -125,8 +125,8 @@
// post-prosess処理(暫定的)
//$this->objPlugin->process($this);
- $this->objDisplay->hoge($this);
- $this->objDisplay->response->response();
+ $this->objDisplay->prepare($this);
+ $this->objDisplay->response->write();
}
/**
@@ -135,14 +135,14 @@
* @return void
*/
function sendResponseCSV($file_name, $data) {
- $this->objDisplay->hoge($this);
+ $this->objDisplay->prepare($this);
$this->objDisplay->addHeader("Content-disposition", "attachment; filename=${file_name}");
$this->objDisplay->addHeader("Content-type", "application/octet-stream; name=${file_name}");
$this->objDisplay->addHeader("Cache-Control", "");
$this->objDisplay->addHeader("Pragma", "");
$this->objDisplay->response->body = $data;
- $this->objDisplay->response->response();
+ $this->objDisplay->response->write();
exit;
}
変更: branches/version-2_5-dev/data/class/pages/admin/LC_Page_Admin.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/LC_Page_Admin.php 2010-12-02 00:04:13 UTC (rev 19704)
+++ branches/version-2_5-dev/data/class/pages/admin/LC_Page_Admin.php 2010-12-02 09:14:39 UTC (rev 19705)
@@ -48,8 +48,8 @@
$this->objDisplay = new SC_Display();
// プラグインクラス生成
- #$this->objPlagin = new SC_Helper_Plugin_Ex();
- #$this->objPlagin->preProcess($this);
+ // $this->objPlagin = new SC_Helper_Plugin_Ex();
+ // $this->objPlagin->preProcess($this);
}
/**
@@ -66,11 +66,10 @@
* @return void
*/
function sendResponse() {
- $this->objDisplay->hoge($this, true);
- $this->objDisplay->response->response();
+ $this->objDisplay->prepare($this, true);
+ $this->objDisplay->response->write();
}
-
/**
* デストラクタ.
*
Svn-src-all メーリングリストの案内