source: branches/comu-ver2/patches/GoogleAnalytics_plugin.patch @ 18230

Revision 18230, 22.0 KB checked in by nanasess, 15 years ago (diff)
  • html/user_data/plugins/plugin_menu.tpl

     
     1<ul id="navi-plugin-menu" class="level1"> 
     2</ul> 
     3<script type="text/javascript"> 
     4//<![CDATA[ 
     5var host = (("https:" == document.location.protocol) ? "<!--{$smarty.const.SSL_URL}-->" : "<!--{$smarty.const.SITE_URL}-->"); 
     6var pluginURL = host + '<!--{$smarty.const.USER_DIR}--><!--{$smarty.const.PLUGIN_DIR}-->'; 
     7$(function(){ 
     8        $.ajax({ 
     9    url: pluginURL + 'plugins.xml', 
     10    type: 'GET', 
     11    dataType: 'xml', 
     12    timeout: 2000, 
     13    error: function(){ 
     14        alert("xmlファイルの読み込みに失敗しました"); 
     15    }, 
     16    success: function(xml){ 
     17        $(xml).find("plugin").each(function(){ 
     18            var item_text = $(this).find("name").text(); 
     19            var item_path = $(this).find("path").text(); 
     20 
     21            $("<li id='navi-plugin-index'></li>") 
     22               .html("<a href='javascript:;'><span>" + item_text + "</span></a>") 
     23               .appendTo('ul#navi-plugin-menu') 
     24               .click(function() { 
     25                   win03(pluginURL + item_path  
     26                          + '/index.php', 'plugins', '800','600'); 
     27                   return false; 
     28               }); 
     29        }); 
     30        $("li.plugin_menu").html(""); 
     31    } 
     32    }); 
     33}); 
     34//]]> 
     35</script> 
  • html/user_data/plugins/plugins.xml

     
     1<?xml version="1.0" encoding="utf-8"?> 
     2<plugins> 
     3  <plugin> 
     4    <name>Google Analytics</name> 
     5    <path>google_analytics</path> 
     6  </plugin> 
     7</plugins> 
  • html/user_data/plugins/google_analytics/sql/delete.sql

     
     1DELETE FROM dtb_bloc WHERE bloc_name = 'Google Analytics'; 
     2DELETE FROM dtb_blocposition WHERE bloc_id = (SELECT bloc_id FROM dtb_bloc WHERE bloc_name = 'Google Analytics'); 
  • html/user_data/plugins/google_analytics/sql/insert.sql

     
     1INSERT INTO dtb_bloc (bloc_name, tpl_path, filename, php_path, del_flg) VALUES ('Google Analytics', 'user_data/plugins/google_analytics/tpl/ga.tpl', 'google_analytics', 'user_data/plugins/google_analytics/ga.php', 1); 
     2 No newline at end of file 
  • html/user_data/plugins/google_analytics/tpl/ga.tpl

     
     1<script type="text/javascript"> 
     2var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); 
     3document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); 
     4</script> 
     5<script type="text/javascript"> 
     6try { 
     7var pageTracker = _gat._getTracker("UA-<!--{$smarty.const.GA_UA}-->"); 
     8pageTracker._trackPageview(); 
     9} catch(err) {}</script> 
  • html/user_data/plugins/google_analytics/tpl/index.tpl

     
     1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     2<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"> 
     3 
     4<head> 
     5<meta http-equiv="content-type" content="application/xhtml+xml; charset=<!--{$smarty.const.CHAR_CODE}-->" /> 
     6<meta http-equiv="content-script-type" content="text/javascript" /> 
     7<meta http-equiv="content-style-type" content="text/css" /> 
     8<link rel="stylesheet" href="<!--{$TPL_DIR}-->css/admin_contents.css" type="text/css" media="all" /> 
     9<script type="text/javascript" src="<!--{$TPL_DIR}-->js/css.js"></script> 
     10<script type="text/javascript" src="<!--{$TPL_DIR}-->js/navi.js"></script> 
     11<script type="text/javascript" src="<!--{$TPL_DIR}-->js/win_op.js"></script> 
     12<script type="text/javascript" src="<!--{$TPL_DIR}-->js/site.js"></script> 
     13<script type="text/javascript" src="<!--{$TPL_DIR}-->js/jquery.js"></script> 
     14<script type="text/javascript" src="<!--{$TPL_DIR}-->js/admin.js"></script> 
     15<title><!--{$tpl_subtitle}--></title> 
     16<script type="text/javascript"> 
     17 
     18</script> 
     19<style type="text/css"> 
     20@charset "UTF-8"; 
     21</style> 
     22</head> 
     23 
     24<body onload="<!--{$tpl_onload}-->" class="authority_0" style="min_width: 400px"> 
     25<noscript> 
     26  <p>JavaScript を有効にしてご利用下さい.</p> 
     27</noscript> 
     28 
     29<div id="container"> 
     30<a name="top"></a> 
     31<!--▼CONTENTS--> 
     32<h1>Google Analytics Plugin</h1> 
     33<div id="contents" class="clear-block"> 
     34  <form method="post" action="index.php"> 
     35    <div id="system" class="contents-main"> 
     36      <table class="list"> 
     37    <tr> 
     38      <th>ウェブ プロパティ ID</th> 
     39      <td>UA-<input type="text" name="ga_ua" value="<!--{$smarty.const.GA_UA}-->" /></td> 
     40    </tr> 
     41      </table> 
     42      <div class="btn addnew"> 
     43    <input type="hidden" name="mode" value="register" /> 
     44    <button type="submit"><span>この内容で登録する</span></button> 
     45      </div> 
     46    </div> 
     47  </form> 
     48</div> 
     49<!--▲CONTENTS--> 
     50</div> 
     51</body> 
     52</html> 
  • html/user_data/plugins/google_analytics/require.php

     
     1<?php 
     2/* 
     3 * EC-CUBE 本体で, このプラグインの関数を使用したい場合は, ここで require する 
     4 */ 
     5require_once(PLUGIN_PATH . "google_analytics/classes/pages/ga_config.php"); 
     6?> 
     7 No newline at end of file 
  • html/user_data/plugins/google_analytics/classes/pages/ga_config.php

     
     1<?php 
     2define('GA_UA', ''); 
     3?> 
  • html/user_data/plugins/google_analytics/classes/pages/LC_Page_FrontParts_Bloc_GoogleAnalytics.php

     
     1<?php 
     2/* 
     3 * This file is part of EC-CUBE 
     4 * 
     5 * Copyright(c) 2000-2009 LOCKON CO.,LTD. All Rights Reserved. 
     6 * 
     7 * http://www.lockon.co.jp/ 
     8 * 
     9 * This program is free software; you can redistribute it and/or 
     10 * modify it under the terms of the GNU General Public License 
     11 * as published by the Free Software Foundation; either version 2 
     12 * of the License, or (at your option) any later version. 
     13 * 
     14 * This program is distributed in the hope that it will be useful, 
     15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     17 * GNU General Public License for more details. 
     18 * 
     19 * You should have received a copy of the GNU General Public License 
     20 * along with this program; if not, write to the Free Software 
     21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
     22 */ 
     23 
     24// {{{ requires 
     25require_once CLASS_PATH . "pages/LC_Page.php"; 
     26 
     27/** 
     28 * Google Analytics プラグインを制御するクラス. 
     29 * 
     30 * @package Page 
     31 * @author Kentaro Ohkouchi 
     32 * @version $Id$ 
     33 */ 
     34class LC_Page_FrontParts_Bloc_GoogleAnalytics extends LC_Page { 
     35 
     36    // }}} 
     37    // {{{ functions 
     38 
     39    /** 
     40     * Page を初期化する. 
     41     * 
     42     * @return void 
     43     */ 
     44    function init() { 
     45        parent::init(); 
     46        $this->tpl_mainpage = USER_PATH . 'plugins/google_analytics/tpl/ga.tpl'; 
     47        $this->tpl_subtitle = "Google Analytics Plugin"; 
     48    } 
     49 
     50    /** 
     51     * Page のプロセス. 
     52     * 
     53     * @return void 
     54     */ 
     55    function process() { 
     56        $objView = new SC_SiteView(); 
     57        $objView->assignobj($this); 
     58        $objView->display($this->tpl_mainpage); 
     59    } 
     60 
     61    /** 
     62     * デストラクタ. 
     63     * 
     64     * @return void 
     65     */ 
     66    function destroy() { 
     67        parent::destroy(); 
     68    } 
     69} 
     70?> 
     71 No newline at end of file 
  • html/user_data/plugins/google_analytics/classes/pages/LC_Page_Admin_GoogleAnalytics.php

     
     1<?php 
     2/* 
     3 * This file is part of EC-CUBE 
     4 * 
     5 * Copyright(c) 2000-2009 LOCKON CO.,LTD. All Rights Reserved. 
     6 * 
     7 * http://www.lockon.co.jp/ 
     8 * 
     9 * This program is free software; you can redistribute it and/or 
     10 * modify it under the terms of the GNU General Public License 
     11 * as published by the Free Software Foundation; either version 2 
     12 * of the License, or (at your option) any later version. 
     13 * 
     14 * This program is distributed in the hope that it will be useful, 
     15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     17 * GNU General Public License for more details. 
     18 * 
     19 * You should have received a copy of the GNU General Public License 
     20 * along with this program; if not, write to the Free Software 
     21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
     22 */ 
     23 
     24// {{{ requires 
     25require_once CLASS_PATH . "pages/LC_Page.php"; 
     26 
     27/** 
     28 * Google Analytics プラグインの管理画面を制御するクラス. 
     29 * 
     30 * @package Page 
     31 * @author Kentaro Ohkouchi 
     32 * @version $Id$ 
     33 */ 
     34class LC_Page_Admin_GoogleAnalytics extends LC_Page { 
     35 
     36    // }}} 
     37    // {{{ functions 
     38 
     39    /** 
     40     * Page を初期化する. 
     41     * 
     42     * @return void 
     43     */ 
     44    function init() { 
     45        parent::init(); 
     46        $this->tpl_mainpage = PLUGIN_PATH . 'google_analytics/tpl/index.tpl'; 
     47        $this->tpl_subtitle = "Google Analytics Plugin"; 
     48 
     49        if (empty($_POST["mode"])) { 
     50            $_POST["mode"] = ""; 
     51        } 
     52 
     53        if (empty($_GET["mode"])) { 
     54            $_GET["mode"] = ""; 
     55        } 
     56    } 
     57 
     58    /** 
     59     * Page のプロセス. 
     60     * 
     61     * POST パラメータ "mode" が register の場合は登録処理を行う. 
     62     * 登録処理の後, 自ページをリロードし, GET パラメータ "mode" を付与する. 
     63     * 登録に成功し, GET パラメータ "mode" の値が success の場合は 
     64     * 「登録に成功しました」というメッセージをポップアップで表示する. 
     65     * 登録に失敗し, GET パラメータ "mode" の値が failure の場合は 
     66     * 「登録に失敗しました」というメッセージをポップアップで表示する. 
     67     * 
     68     * TODO Transaction Token を使用する 
     69     * 
     70     * @return void 
     71     */ 
     72    function process() { 
     73        // 認証可否の判定 
     74        SC_Utils_Ex::sfIsSuccess(new SC_Session()); 
     75 
     76        switch ($_POST["mode"]) { 
     77        case "register": 
     78            if ($this->register($_POST['ga_ua'])) { 
     79                $this->reload(array("mode" => "success")); 
     80                exit; 
     81            } else { 
     82                $this->reload(array("mode" => "failure")); 
     83                exit; 
     84            } 
     85            break; 
     86 
     87          default: 
     88        } 
     89 
     90        switch ($_GET["mode"]) { 
     91        case "success": 
     92            $this->tpl_onload .= "window.alert('登録に成功しました。');"; 
     93            break; 
     94 
     95        case "failure": 
     96            $this->tpl_onload .= "window.alert('登録に失敗しました。');"; 
     97            break; 
     98 
     99          default: 
     100        } 
     101 
     102        $objView = new SC_AdminView(); 
     103        $objView->assignobj($this); 
     104        $objView->display($this->tpl_mainpage); 
     105    } 
     106 
     107    /** 
     108     * UA の登録を行う. 
     109     * 
     110     * classes/pages/ga_config.php を読み込み, ウェブプロパティID の文字列 
     111     * を定数として書き出す. 
     112     * 
     113     * @param string ウェブプロパティID の文字列 
     114     * @return boolean 登録に成功した場合 true; 失敗した場合 false; 
     115     */ 
     116    function register($ua) { 
     117        $data = "<?php\ndefine('GA_UA', '"  
     118            . htmlspecialchars($ua, ENT_QUOTES) . "');\n?>\n"; 
     119 
     120        $configFile = PLUGIN_PATH . "google_analytics/classes/pages/ga_config.php"; 
     121        $handle = fopen($configFile, "w"); 
     122        if (!$handle) { 
     123            return false; 
     124        } 
     125        // ファイルの内容を書き出す. 
     126        if (fwrite($handle, $data) === false) { 
     127            return false; 
     128        } 
     129        return true; 
     130    } 
     131 
     132    /** 
     133     * デストラクタ. 
     134     * 
     135     * @return void 
     136     */ 
     137    function destroy() { 
     138        parent::destroy(); 
     139    } 
     140} 
     141?> 
     142 No newline at end of file 
  • html/user_data/plugins/google_analytics/ga.php

     
     1<?php 
     2// {{{ requires 
     3require_once(PLUGIN_PATH . "google_analytics/classes/pages/LC_Page_FrontParts_Bloc_GoogleAnalytics.php"); 
     4 
     5// }}} 
     6// {{{ generate page 
     7 
     8$objPage = new LC_Page_FrontParts_Bloc_GoogleAnalytics(); 
     9register_shutdown_function(array($objPage, "destroy")); 
     10$objPage->init(); 
     11$objPage->process(); 
     12?> 
     13 No newline at end of file 
  • html/user_data/plugins/google_analytics/index.php

     
     1<?php 
     2/* 
     3 * This file is part of EC-CUBE 
     4 * 
     5 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. 
     6 * 
     7 * http://www.lockon.co.jp/ 
     8 * 
     9 * This program is free software; you can redistribute it and/or 
     10 * modify it under the terms of the GNU General Public License 
     11 * as published by the Free Software Foundation; either version 2 
     12 * of the License, or (at your option) any later version. 
     13 * 
     14 * This program is distributed in the hope that it will be useful, 
     15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     17 * GNU General Public License for more details. 
     18 * 
     19 * You should have received a copy of the GNU General Public License 
     20 * along with this program; if not, write to the Free Software 
     21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
     22 */ 
     23// {{{ requires 
     24require_once("../../../admin/require.php"); 
     25require_once(USER_PATH . 'plugins/google_analytics/classes/pages/LC_Page_Admin_GoogleAnalytics.php'); 
     26 
     27// }}} 
     28// {{{ generate page 
     29 
     30$objPage = new LC_Page_Admin_GoogleAnalytics(); 
     31register_shutdown_function(array($objPage, 'destroy')); 
     32$objPage->init(); 
     33$objPage->process(); 
     34?> 
     35 No newline at end of file 
  • html/install/sql/insert_data.sql

     
    11141114INSERT INTO mtb_constants VALUES ('OSTORE_E_C_BATCH_ERR', '"2010"', 522, 'オーナーズストア通信エラーコード'); 
    11151115INSERT INTO mtb_constants VALUES ('OPTION_FAVOFITE_PRODUCT', '1', 523, 'お気に入り商品登録(有効:1 無効:0)'); 
    11161116INSERT INTO mtb_constants VALUES ('IMAGE_RENAME', 'true', 525, '画像リネーム設定(商品画像のみ)(true:リネームする、false:リネームしない)'); 
     1117INSERT INTO mtb_constants VALUES ('PLUGIN_DIR', '"plugins/"', 600, 'プラグインディレクトリ'); 
     1118INSERT INTO mtb_constants VALUES ('PLUGIN_PATH', 'USER_PATH . PLUGIN_DIR', 601, 'プラグイン保存先'); 
     1119INSERT INTO mtb_constants VALUES ('PLUGIN_URL', 'USER_URL . PLUGIN_DIR', 602, 'プラグイン URL'); 
    11171120 
    11181121INSERT INTO dtb_module (module_id,module_code,module_name,update_date,create_date) VALUES (0,0,'patch',now(),now()); 
  • data/Smarty/templates/default/admin/main_frame.tpl

     
    113113        <a><span>OWNERS STORE</span></a> 
    114114        <!--{include file="`$smarty.const.TEMPLATE_ADMIN_DIR`ownersstore/subnavi.tpl"}--> 
    115115    </li> 
     116    <li id="navi-plugin" class="<!--{if $tpl_mainno eq "plugin"}-->on<!--{/if}-->"> 
     117      <a><span>プラグイン設定</span></a> 
     118      <!--{include file="`$smarty.const.PLUGIN_PATH`plugin_menu.tpl"}--> 
     119    </li> 
    116120</ul> 
    117121<div style="clear: both;"></div> 
    118122<!--{* ▲NAVI *}--> 
  • data/require_plugin.php

     
    11<?php 
    2   /* 
    3    * プラグインを require するためのファイル 
    4    */ 
     2/* 
     3 * This file is part of EC-CUBE 
     4 * 
     5 * Copyright(c) 2000-2009 LOCKON CO.,LTD. All Rights Reserved. 
     6 * 
     7 * http://www.lockon.co.jp/ 
     8 * 
     9 * This program is free software; you can redistribute it and/or 
     10 * modify it under the terms of the GNU General Public License 
     11 * as published by the Free Software Foundation; either version 2 
     12 * of the License, or (at your option) any later version. 
     13 * 
     14 * This program is distributed in the hope that it will be useful, 
     15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     17 * GNU General Public License for more details. 
     18 * 
     19 * You should have received a copy of the GNU General Public License 
     20 * along with this program; if not, write to the Free Software 
     21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
     22 */ 
     23 
     24// load plugins 
     25/* ----------------------------------------------------------------------------- 
     26 * TODO PHP4 でも使えるように, XML パーサーをファクトリークラスで実装する 
     27 * ----------------------------------------------------------------------------*/ 
     28if (version_compare("5", PHP_VERSION, "<")) { 
     29    $plugins = file_get_contents(USER_PATH . "plugins/plugins.xml"); 
     30    $xml = new SimpleXMLElement($plugins); 
     31    foreach ($xml->plugin as $plugin) { 
     32     
     33        $requireFile = USER_PATH . "plugins/" . $plugin->path . "/require.php"; 
     34        if (file_exists($requireFile)) { 
     35            require_once($requireFile); 
     36        } 
     37    } 
     38} 
    539?> 
  • data/mtb_constants_init.php

     
    670670define('OPTION_FAVOFITE_PRODUCT','1'); 
    671671/** 画像リネーム設定(商品画像のみ) */ 
    672672define('IMAGE_RENAME', true); 
     673/** プラグインディレクトリ */ 
     674define("PLUGIN_DIR", "plugins/"); 
     675/** プラグイン保存先 */ 
     676define("PLUGIN_PATH", USER_PATH . PLUGIN_DIR); 
     677/** プラグイン URL */ 
     678define("PLUGIN_URL", USER_URL . PLUGIN_DIR); 
    673679?> 
  • data/require_base.php

     
    7878require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_Session_Ex.php"); 
    7979require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_Mail_Ex.php"); 
    8080require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_Mobile_Ex.php"); 
    81 include_once(DATA_PATH . "require_plugin.php"); 
    8281 
    8382// セッションハンドラ開始 
    8483$objSession = new SC_Helper_Session_Ex(); 
     
    9190$sessionFactory = SC_SessionFactory::getInstance(); 
    9291$sessionFactory->initSession(); 
    9392 
     93// プラグインを読み込む 
     94include_once(DATA_PATH . "require_plugin.php"); 
     95 
    9496// 絵文字変換 (除去) フィルターを組み込む。 
    9597ob_start(array('SC_MobileEmoji', 'handler')); 
    9698?> 
  • data/class/pages/LC_Page.php

     
    8282     */ 
    8383    function init() { 
    8484        $this->tpl_authority = $_SESSION['authority']; 
     85        // XXX すべてのページで宣言するべき 
     86        $layout = new SC_Helper_PageLayout_Ex(); 
     87        $layout->sfGetPageLayout($this, false); 
    8588    } 
    8689 
    8790    /** 
  • data/class/helper/SC_Helper_PageLayout.php

     
    6161            $objPage->tpl_mainpage = USER_PATH . "templates/preview/" 
    6262                . TEMPLATE_NAME . "/" . $arrPageData[0]['filename'] . ".tpl"; 
    6363        } 
    64                  
    65         foreach($arrPageData[0] as $key => $val) { 
    66             $debug_message.= "arrPageData[$key]:" . $val . "\n"; 
     64 
     65        if (!empty($arrPageData[0])) { 
     66            foreach($arrPageData[0] as $key => $val) { 
     67                $debug_message.= "arrPageData[$key]:" . $val . "\n"; 
     68            } 
    6769        } 
    6870         
    6971        $debug_message.= "TEMPLATE_NAME:".TEMPLATE_NAME . "\n"; 
Note: See TracBrowser for help on using the repository browser.