<?php
// +---------------------------------------------+
// |     Copyright 2003-2005 weenCompany         |
// |     http://www.weentech.com                 |
// |     This file may not be redistributed.     |
// +---------------------------------------------+

if(!defined('TABLE_PREFIX'))
  define('TABLE_PREFIX', '');

if(!defined('IN_WEENCOMPANY'))
  die('File not found!');


// ############################### MODULE DETAILS ##############################

$uniqueid       = 17;
$modulename     = '產品模塊';
$version        = '2.0';
$modulepath     = 'm17_products/imagegallery.php';
$settingspath   = 'm17_products/m17_settings.php';
$authorname     = 'weencompany';
$authorlink     = 1;
$modulesettings = '27';


// ############################### INSTALL MODULE ##############################

if($installtype == 'install')
{
  $DB->query("CREATE TABLE " . TABLE_PREFIX . "m17_products (
  imageid       INT(10)      UNSIGNED NOT NULL              AUTO_INCREMENT,
  sectionid     INT(10)      UNSIGNED NOT NULL DEFAULT 0,
  activated     TINYINT(1)            NOT NULL DEFAULT 0,
  ordernum    INT(10)       UNSIGNED NOT NULL DEFAULT 0,
  filename      VARCHAR(32)           NOT NULL DEFAULT '',
  thumbname     VARCHAR(32)           NOT NULL DEFAULT '',
  isautothumb   TINYINT(1)            NOT NULL DEFAULT 1,
  allowsmilies  TINYINT(1)            NOT NULL DEFAULT 0,
  allowcomments TINYINT(1)            NOT NULL DEFAULT 0,
  showauthor    TINYINT(1)            NOT NULL DEFAULT 0,
  author        VARCHAR(64)           NOT NULL DEFAULT '',
  title         VARCHAR(128)          NOT NULL DEFAULT '',
  description   TEXT,
  specification   TEXT,
  priceship   TEXT,
  viewcount     INT(10)      UNSIGNED NOT NULL DEFAULT 0,
  datecreated   INT(10)      UNSIGNED NOT NULL DEFAULT 0,
  moduleid      INT(10)       UNSIGNED NOT NULL DEFAULT " . $uniqueid .",
  aorp          TINYINT(1)    NOT NULL DEFAULT 1,
  KEY imageid (imageid)
  ) TYPE=MyISAM;" );


  $DB->query("CREATE TABLE " . TABLE_PREFIX . "m17_sections (
  sectionid     INT(10)      UNSIGNED NOT NULL              AUTO_INCREMENT,
  parentid      INT(10)      UNSIGNED NOT NULL DEFAULT 0,
  activated     TINYINT(1)            NOT NULL DEFAULT 0,
  ordernum    INT(10)       UNSIGNED NOT NULL DEFAULT 0,
  name          VARCHAR(128)          NOT NULL DEFAULT '',
  description   TEXT                  NOT NULL,
  sorting       VARCHAR(32)           NOT NULL DEFAULT '',
  imageid       INT(10)      UNSIGNED NULL,
  datecreated   INT(10)      UNSIGNED NOT NULL DEFAULT 0,
  KEY sectionid (sectionid)
  ) TYPE=MyISAM;" );

  $DB->query("INSERT INTO " . TABLE_PREFIX . "m" . $uniqueid . "_sections VALUES (NULL, 0, 1, 1, '產品', '', '時間(降序)', NULL, " . time() . ")");

  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '基本設置',              '彈出方式',                         '是否點擊產品縮圖, 直接彈出窗口顯示大圖片和產品信息:', 'yesno', '0', 1) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '基本設置',              '每行產品數',             '每行顯示的產品數量:', 'text', '4', 2) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '基本設置',              '每頁產品數',                      '每頁顯示的產品數量:', 'text', '12', 3) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '基本設置',              '郵件通知',                   '會員提交產品圖片及說明後, 按此郵箱地址通知管理員:<br />\r\n多個信箱可用英文逗號隔開, 不希望收到通知, 請留空.', 'text', '', 4) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '基本設置',              '自動發佈',                  '是否允許會員提交產品圖片後不經審核自動發佈?', 'yesno', '0', 5) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '基本設置',              '顯示點擊率',                     '是否顯示產品的點擊次數?', 'yesno', '1', 6) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '基本設置',              '顯示評論數',                  '是否顯示產品的評論條數?', 'yesno', '1', 7) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '基本設置',              '顯示跳轉',                    '是否顯示產品類別下拉跳轉欄?', 'yesno', '1', 8) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '基本設置',              '顯示導航',                    '是否顯示產品類別水平導航欄?', 'yesno', '1', 9) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '基本設置',              '類別排序',                   '產品分類目錄的排序方式:',                      '<select name=\\\\\"settings[\$setting[settingid]]\\\\\">\r\n
  <option value=\\\\\"0\\\\\" \".iif(\$setting[value]==\"0\", \"selected\", \"\").\">時間(降序)</option>\r\n
  <option value=\\\\\"1\\\\\" \".iif(\$setting[value]==\"1\", \"selected\", \"\").\">時間(升序)</option>\r\n
  <option value=\\\\\"2\\\\\" \".iif(\$setting[value]==\"2\", \"selected\", \"\").\">編號(降序)</option>\r\n
  <option value=\\\\\"3\\\\\" \".iif(\$setting[value]==\"3\", \"selected\", \"\").\">編號(升序)</option>\r\n
  </select>', '2', 10) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '基本設置', '居中顯示', '窗口中是否居中顯示產品圖片?', 'yesno', '1', 11) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '基本設置', 'TinyMCE編輯器', '後臺管理中編輯產品描述時是否啟用TinyMCE中文編輯器?<br />注: 此項設置僅當系統基本設置中啟用了TinyMCE編輯器時才有效.', 'yesno', '1', 12) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '基本設置', '驗證碼', '會員提交產品時, 是否需要填寫驗證碼?', 'yesno', '1', 13) ");

  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '縮圖設置',    '自動縮圖',                       '是否在上傳產品大圖時自動生成縮圖?<br />注: 自動生成縮圖僅當產品圖片為jpg或png圖片時有效. 選擇\"否\", 則需上傳大圖時同時上傳縮圖.', 'yesno', '1', 1)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '縮圖設置',    '縮圖最大寬度',                  '自動生成縮圖的最大寬度(像素):', 'text', '100', 2) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '縮圖設置',    '縮圖最大高度',                 '自動生成縮圖的最大高度(像素):', 'text', '100', 3) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '縮圖設置',    '方形縮圖',                '是否拉伸大圖自動生成方形縮圖?', 'yesno', '0', 4) ");

  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '中圖設置',      '自動中圖',                '是否在上傳產品大圖時自動生成中圖?<br />注: 自動生成中圖僅當產品圖片為jpg或png類型時有效, 選擇\"否\", 將無法創建中圖(系統不提供上傳中圖功能).', 'yesno', '1', 1) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '中圖設置',      '大圖保持原始',                 '上傳的產品大圖是否保持原始尺寸?<br />如果此項設置為\"否\", 且\"自動中圖\"設置為\"是\", 則僅顯示產品中圖, 且刪除原上傳圖片.', 'yesno', '1', 2) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '中圖設置',      '中圖最大寬度',                    '自動生成中圖的最大寬度(像素):', 'text', '400', 3) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '中圖設置',      '中圖最大高度',                   '自動生成中圖的最大高度(像素):', 'text', '400', 4) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '中圖設置',      '方型中圖',                   '是否拉伸大圖自動生成方形中圖?', 'yesno', '0', 5) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '縮圖設置', '縮圖邊框', '是否顯示縮圖邊框?', 'yesno', '1', 5) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '中圖設置', '中圖邊框', '是否顯示中圖邊框?', 'yesno', '1', 6) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '類別設置', '分類統計', '是否顯示類別的產品數量統計? <br />如果網站訪問速度太慢或有大量產品, 建議選\"否\".', 'yesno', '1', 1) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '類別設置', '顯示方式', '是否以圖片方式顯類別? <br />選擇\"否\", 則僅顯示類別名稱.', 'yesno', '1', 2) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '類別設置', '每行類別數', '每行顯示的產品類別數, 設置為\"1\"表示縱向排列:', 'text', '5', 3) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '類別設置', '圖片邊框', '當類別以圖片方式顯示時, 是否顯示圖片邊框?', 'yesno', '1', 4) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '類別設置', '顯示類別', '是否顯示產品類別的下屬分類別?', 'yesno', '1', 5) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '類別設置', '根類別顯示所有產品', '是否在產品模塊的根類別下顯示所有產品? 此時進入產品頁面將顯示所有產品; 選擇否, 僅顯示根類別下的產品.', 'yesno', '0', 6) ");
  
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '邊框設置', '邊框顏色', '圖片邊框的顏色:<br />默認顏色: #606E9B', 'text', '#606E9B', 1) ");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "modulesettings VALUES (NULL, $uniqueid, '邊框設置', '邊框間隙', '圖片與邊框之間的間隙(像素):<br />默認間隙: 3', 'text', '3', 2) ");

  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'sections',                '分類:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'no_gif_support',          '網站已開啟自動縮圖功能, 僅支持jpg和png圖片格式!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'previous_images',         '&laquo; 上一頁', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'more_images',             '下一頁 &raquo;', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'submitted_by',            '來自:', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'submit_an_image',         '提交產品到此類別.', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'submitting_image',        '提交產品', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'your_name',               '您的姓名:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'description',             '產品描述:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'thumbnail',               '產品縮圖:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'image',                   '產品圖片:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'submit_image',            '提交產品', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'image_title',             '產品名稱:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'enter_title',             '請輸入產品名稱!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'enter_author',            '請輸入您的姓名!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'select_image',            '請選擇產品圖片!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'select_thumbnail',        '請選擇產品縮圖', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'enter_description',       '請輸入產品描述!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'image_submitted',         '謝謝! 產品提交成功.', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'previous_image',          '&laquo; 上一個', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'next_image',              '下一個 &raquo;',     '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'invalid_image_type',      '無效的圖片類型!', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'views',                   '查看次數:', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'jump_to',                 '跳轉到...', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'comments',                '個評論', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'comment',                '評論', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'image2',                '個產品', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'images',                '個產品', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'images2',                '產品列表:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'specification',               '技術規格:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'priceship',               '價格及運輸:', '', '', '', '', 1, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'descriptiontitle',               '基本信息', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'specificationtitle',               '技術規格', '', '', '', '', 0, 0, 0)");
  $DB->query("INSERT INTO " . TABLE_PREFIX . "phrases VALUES (NULL, $uniqueid, 'priceshiptitle',               '價格及運輸', '', '', '', '', 0, 0, 0)");

}


// ############################### UPGRADE MODULE ##############################

if($installtype == 'upgrade')
{
  if($currentversion == '2.0')
  {
    // example:
    // UpdateModuleVersion(17, 2.1);
    // $currentversion = 2.1;
  }
}


// ############################## UNINSTALL MODULE #############################

if($installtype == 'uninstall')
{
  $DB->query("DROP TABLE IF EXISTS " . TABLE_PREFIX . "m17_products");
  $DB->query("DROP TABLE IF EXISTS " . TABLE_PREFIX . "m17_sections");
}

?>
