OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / include / addons / bloglib / blogLib.php
1 <?php
2 /**
3  * Eコマースメール連携クラス
4  *
5  * PHP versions 5
6  *
7  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8  *
9  * @package    Magic3 Framework
10  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11  * @copyright  Copyright 2006-2010 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: blogLib.php 3629 2010-09-25 01:22:57Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once(dirname(__FILE__) . '/blogLibDb.php');
17
18 class blogLib
19 {
20         private $db;    // DB接続オブジェクト
21         private $blogId = '';   // ブログID
22         private $templateId = '';       // テンプレートID
23         
24         /**
25          * コンストラクタ
26          */
27         function __construct()
28         {
29                 // DBオブジェクト作成
30                 $this->db = new blogLibDb();
31         }
32         /**
33          * 初期化
34          *
35          * @return なし
36          */
37         function _initData()
38         {
39                 global $gEnvManager;
40                 global $gRequestManager;
41                 static $init = false;
42                 
43                 if ($init) return;
44                 
45                 $langId = $gEnvManager->getDefaultLanguage();
46         
47                 // 記事IDからブログID、テンプレートIDを取得
48                 $entryId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BLOG_ENTRY_ID);
49                 if (empty($entryId)) $entryId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT);            // 略式ブログ記事ID
50                 if (!empty($entryId)){
51                         $ret = $this->db->getEntryItem($entryId, $langId, $row);
52                         if ($ret){
53                                 $this->templateId = $row['bl_template_id'];
54                                 $this->blogId = $row['bl_id'];; // ブログID
55                         }
56                 } else {
57                         // ブログIDからテンプレートIDを取得
58                         $blogId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BLOG_ID);
59                         if (empty($blogId)) $blogId = $gRequestManager->trimValueOf(M3_REQUEST_PARAM_BLOG_ID_SHORT);            // 略式ブログID
60                         if (!empty($blogId)){
61                                 $ret = $this->db->getBlogInfoById($blogId, $row);
62                                 if ($ret){
63                                         $this->templateId = $row['bl_template_id'];
64                                         $this->blogId = $row['bl_id'];; // ブログID
65                                 }
66                         }
67                 }
68                 $init = true;           // 初期化完了
69         }
70         /**
71          * URLパラメータからオプションのテンプレートを取得
72          *
73          * @return string                                               テンプレートID
74          */
75         function getOptionTemplate()
76         {
77                 // 初期化
78                 $this->_initData();
79                 
80                 return $this->templateId;
81         }
82         /**
83          * 現在のブログIDを取得
84          *
85          * @return string                                       ブログID
86          */
87         function getBlogId()
88         {
89                 // 初期化
90                 $this->_initData();
91                 
92                 return $this->blogId;
93         }
94 }
95 ?>