<?php

/*
  PHP version 5
  Copyright (c) 2002-2018 ECISP.CN、EarcLink.COM
  警告：这不是一个免费的软件，请在许可范围内使用，请尊重知识产权，侵权必究，举报有奖
  作者：黄祥云 E-mail:6326420@qq.com  QQ:6326420 TEL:18665655030

 */
namespace application;
class ESPCMS_PublicDB {
    public static function get_formType($key = false) {
        $formType = array(
            0 => array('key' => 'string', 'name' => '单行文本', 'class' => 'text', 'alter' => 'VARCHAR', 'varlong' => '250'),
            1 => array('key' => 'text', 'name' => '多行文本', 'class' => 'textarea', 'alter' => 'TEXT', 'varlong' => '250'),
            2 => array('key' => 'editor', 'name' => '编辑器', 'class' => 'textarea', 'alter' => 'TEXT', 'varlong' => '250'),
            3 => array('key' => 'htmltext', 'name' => 'HTML文本', 'class' => 'textarea', 'alter' => 'TEXT', 'varlong' => '250'),
            4 => array('key' => 'int', 'name' => ' 整数类型', 'class' => 'text', 'alter' => 'INT', 'varlong' => '11'),
            5 => array('key' => 'float', 'name' => ' 小数类型', 'class' => 'text', 'alter' => 'FLOAT', 'varlong' => '11'),
            6 => array('key' => 'date', 'name' => '日期类型', 'class' => 'text', 'alter' => 'INT', 'varlong' => '11'),
            7 => array('key' => 'time', 'name' => '时间类型', 'class' => 'text', 'alter' => 'INT', 'varlong' => '11'),
            8 => array('key' => 'datetime', 'name' => '日期时间类型', 'class' => 'text', 'alter' => 'INT', 'varlong' => '11'),
            9 => array('key' => 'img', 'name' => '图片附件', 'class' => 'text', 'alter' => 'VARCHAR', 'varlong' => '80'),
            10 => array('key' => 'addon', 'name' => '文件附件', 'class' => 'text', 'alter' => 'VARCHAR', 'varlong' => '80'),
            11 => array('key' => 'video', 'name' => '视频附件', 'class' => 'text', 'alter' => 'VARCHAR', 'varlong' => '80'),
            12 => array('key' => 'select', 'name' => '下拉框', 'class' => 'select', 'alter' => 'VARCHAR', 'varlong' => '250'),
            13 => array('key' => 'radio', 'name' => '单选框', 'class' => 'radio', 'alter' => 'VARCHAR', 'varlong' => '250'),
            14 => array('key' => 'checkbox', 'name' => '多选框', 'class' => 'checkbox', 'alter' => 'VARCHAR', 'varlong' => '250'),
            15 => array('key' => 'selectinput', 'name' => '复合选项关联输入框', 'class' => 'text', 'alter' => 'VARCHAR', 'varlong' => '250'),
            16 => array('key' => 'decimal', 'name' => '价格', 'class' => 'text', 'alter' => 'FLOAT', 'varlong' => '50'),
        );
        return !espcms_ismatches($key) ? $formType : $formType[$key];
    }
    public static function get_validatetype() {
        $validatetype[] = array('name' => '长度限制', 'value' => '^.{2,200}$');
        $validatetype[] = array('name' => '数字', 'value' => '^[0-9.-]+$');
        $validatetype[] = array('name' => '整数', 'value' => '^[0-9-]+$');
        $validatetype[] = array('name' => '小写字母', 'value' => '^[a-z]+$');
        $validatetype[] = array('name' => '数字+字母', 'value' => '^[0-9a-z]+$');
        $validatetype[] = array('name' => 'E-mail', 'value' => '^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$');
        $validatetype[] = array('name' => 'QQ', 'value' => '^[0-9]{5,20}$');
        $validatetype[] = array('name' => '超级链接', 'value' => '^http:\/\//$');
        $validatetype[] = array('name' => '手机号码', 'value' => '^(1)[0-9]{10}$');
        $validatetype[] = array('name' => '电话号码', 'value' => '^[0-9-]{6,13}$');
        $validatetype[] = array('name' => '邮政编码', 'value' => '^[0-9]{6}$');
        return $validatetype;
    }
    public static function get_typelist_style($id = false) {
        $page_style[] = array('id' => '{tid}_{pageid}', 'name' => 'dirname/1000');
        $page_style[] = array('id' => '{tid}_list_{pageid}', 'name' => 'dirname/1000_list');
        $page_style[] = array('id' => '{dirname}_list_{pageid}', 'name' => 'dirname/dirname_list');
        foreach ($page_style as $key => $value) {
            if ($id == $value['id']) {
                $page_style[$key]['selected'] = 'selected';
            }
        }
        return $page_style;
    }
    public static function get_suburlist_style($id = false) {
        $page_style[] = array('id' => '{sid}_{pageid}', 'name' => 'dirname/1000');
        $page_style[] = array('id' => '{sid}_list_{pageid}', 'name' => 'dirname/1000_list');
        $page_style[] = array('id' => '{dirname}_list_{pageid}', 'name' => 'dirname/dirname_list');
        foreach ($page_style as $key => $value) {
            if ($id == $value['id']) {
                $page_style[$key]['selected'] = 'selected';
            }
        }
        return $page_style;
    }
    public static function get_read_style($id = false) {
        $page_style[] = array('id' => '{did}', 'name' => 'dirname/1');
        $page_style[] = array('id' => '{datetime}{did}', 'name' => 'dirname/201101010101251');
        $page_style[] = array('id' => '{data}/{did}', 'name' => 'dirname/20110101/1');
        $page_style[] = array('id' => '{y}/{m}/{d}/{did}', 'name' => 'dirname/2011/01/01/1');
        $page_style[] = array('id' => '{y}/{m}{d}/{did}', 'name' => 'dirname/2011/0101/1');
        foreach ($page_style as $key => $value) {
            if ($id == $value['id']) {
                $page_style[$key]['selected'] = 'selected';
            }
        }
        return $page_style;
    }
    public static function get_member_formType($key = false, $id = false) {
        $formType[] = array('key' => 'string', 'name' => '单行文本', 'class' => 'text', 'alter' => 'VARCHAR', 'varlong' => '250');
        $formType[] = array('key' => 'text', 'name' => '多行文本', 'class' => 'textarea', 'alter' => 'TEXT', 'varlong' => '250');
        $formType[] = array('key' => 'int', 'name' => ' 整数类型', 'class' => 'text', 'alter' => 'INT', 'varlong' => '11');
        $formType[] = array('key' => 'float', 'name' => ' 小数类型', 'class' => 'text', 'alter' => 'FLOAT', 'varlong' => '11');
        $formType[] = array('key' => 'date', 'name' => '日期类型', 'class' => 'text', 'alter' => 'INT', 'varlong' => '11');
        $formType[] = array('key' => 'datetime', 'name' => '日期时间类型', 'class' => 'text', 'alter' => 'INT', 'varlong' => '11');
        $formType[] = array('key' => 'img', 'name' => '图片附件', 'class' => 'text', 'alter' => 'VARCHAR', 'varlong' => '80');
        $formType[] = array('key' => 'addon', 'name' => '文件附件', 'class' => 'text', 'alter' => 'VARCHAR', 'varlong' => '80');
        $formType[] = array('key' => 'select', 'name' => '下拉框', 'class' => 'select', 'alter' => 'VARCHAR', 'varlong' => '250');
        $formType[] = array('key' => 'radio', 'name' => '单选框', 'class' => 'radio', 'alter' => 'VARCHAR', 'varlong' => '250');
        $formType[] = array('key' => 'checkbox', 'name' => '多选框', 'class' => 'checkbox', 'alter' => 'VARCHAR', 'varlong' => '250');
        foreach ($formType as $key => $value) {
            if ($key == $value['key']) {
                $formType[$key]['selected'] = 'selected';
            }
        }
        return espcms_ismatches($id) ? $formType[$id] : $formType;
    }
    public static function get_templates_key($key = false, $read = array()) {
        $replacemail['order'][] = array('name' => '收件人', 'title' => '[%consignee%]', 'content' => $read["consignee"]);
        $replacemail['order'][] = array('name' => '收件E-mail', 'title' => '[%email%]', 'content' => $read["email"]);
        $replacemail['order'][] = array('name' => '所在省', 'title' => '[%province%]', 'content' => $read['province']);
        $replacemail['order'][] = array('name' => '所在城市', 'title' => '[%city%]', 'content' => $read['city']);
        $replacemail['order'][] = array('name' => '所在区域', 'title' => '[%district%]', 'content' => $read['district']);
        $replacemail['order'][] = array('name' => '收件地址', 'title' => '[%address%]', 'content' => $read["address"]);
        $replacemail['order'][] = array('name' => '收件邮编', 'title' => '[%zipcode%]', 'content' => $read["zipcode"]);
        $replacemail['order'][] = array('name' => '收件人手机', 'title' => '[%mobile%]', 'content' => $read["mobile"]);
        $replacemail['order'][] = array('name' => '收件人电话', 'title' => '[%tel%]', 'content' => $read["tel"]);
        $replacemail['order'][] = array('name' => '订单编号', 'title' => '[%ordersn%]', 'content' => $read["ordersn"]);
        $replacemail['order'][] = array('name' => '订单金额', 'title' => '[%orderamount%]', 'content' => $read["orderamount"]);
        $replacemail['order'][] = array('name' => '订单时间', 'title' => '[%time%]', 'content' => $read["addtime"]);
        $replacemail['order'][] = array('name' => '订单备注内容', 'title' => '[%content%]', 'content' => $read["content"]);
        $replacemail['order'][] = array('name' => '付款时间', 'title' => '[%paytime%]', 'content' => $read["paytime"]);
        $replacemail['order'][] = array('name' => '发货时间', 'title' => '[%shippingtime%]', 'content' => $read["shippingtime"]);
        $replacemail['order'][] = array('name' => '邮寄费用', 'title' => '[%shippingmoney%]', 'content' => $read["shippingmoney"]);
        $replacemail['order'][] = array('name' => '支付手续费', 'title' => '[%paymoney%]', 'content' => $read["paymoney"]);
        $replacemail['order'][] = array('name' => '商品费用', 'title' => '[%productmoney%]', 'content' => $read["productmoney"]);
        $replacemail['order'][] = array('name' => '折扣', 'title' => '[%discount%]', 'content' => $read["discount"]);
        $replacemail['order'][] = array('name' => '支付方式名称', 'title' => '[%payname%]', 'content' => $read['payname']);
        $replacemail['order'][] = array('name' => '发货方式名称', 'title' => '[%shippingname%]', 'content' => $read['shippingname']);
        $replacemail['order'][] = array('name' => '物流单号', 'title' => '[%shippingsn%]', 'content' => $read["shippingsn"]);
        $replacemail['order'][] = array('name' => '支付单号', 'title' => '[%paysn%]', 'content' => $read["paysn"]);
        $replacemail['enquiry'][] = array('name' => '询价编号', 'title' => '[%enquirysn%]', 'content' => $read["enquirysn"]);
        $replacemail['enquiry'][] = array('name' => '询价联系人', 'title' => '[%linkman%]', 'content' => $read["linkman"]);
        $replacemail['enquiry'][] = array('name' => 'E-mail', 'title' => '[%email%]', 'content' => $read["email"]);
        $replacemail['enquiry'][] = array('name' => '所在省', 'title' => '[%province%]', 'content' => $read['province']);
        $replacemail['enquiry'][] = array('name' => '所在城市', 'title' => '[%city%]', 'content' => $read['city']);
        $replacemail['enquiry'][] = array('name' => '所在区域', 'title' => '[%district%]', 'content' => $read['district']);
        $replacemail['enquiry'][] = array('name' => '联系人地址', 'title' => '[%address%]', 'content' => $read["address"]);
        $replacemail['enquiry'][] = array('name' => '联系人邮编', 'title' => '[%zipcode%]', 'content' => $read["zipcode"]);
        $replacemail['enquiry'][] = array('name' => '联系人手机', 'title' => '[%mobile%]', 'content' => $read["mobile"]);
        $replacemail['enquiry'][] = array('name' => '联系人电话', 'title' => '[%tel%]', 'content' => $read["tel"]);
        $replacemail['enquiry'][] = array('name' => '询价提交时间', 'title' => '[%entime%]', 'content' => $read["addtime"]);
        $replacemail['enquiry'][] = array('name' => '询价备注内容', 'title' => '[%content%]', 'content' => $read["content"]);
        $replacemail['member'][] = array('name' => '会员用户名', 'title' => '[%m_username%]', 'content' => $read["username"]);
        $replacemail['member'][] = array('name' => '会员E-mail', 'title' => '[%m_email%]', 'content' => $read["email"]);
        $replacemail['member'][] = array('name' => '密码保护问题', 'title' => '[%question%]', 'content' => $read["question"]);
        $replacemail['member'][] = array('name' => '密码保护答案', 'title' => '[%answer%]', 'content' => $read["answer"]);
        $replacemail['member'][] = array('name' => '会员注册时间', 'title' => '[%m_time%]', 'content' => $read["addtime"]);
        $replacemail['member'][] = array('name' => '激活链接地址', 'title' => '[%checklink%]', 'content' => $read['checklink']);
        $replacemail['member'][] = array('name' => '会员等级', 'title' => '[%rankname%]', 'content' => $read["rankname"]);
        $replacemail['member'][] = array('name' => '会员新密码', 'title' => '[%newpassword%]', 'content' => $read['newpassword']);
        $replacemail['formsmanage'][] = array('name' => '表单主题', 'title' => '[%formgroupname%]', 'content' => $read["formgroupname"]);
        $replacemail['formsmanage'][] = array('name' => '回复内容', 'title' => '[%recontent%]', 'content' => $read["recontent"]);
        $replacemail['formsmanage'][] = array('name' => '表单发布时间', 'title' => '[%f_time%]', 'content' => $read["addtime"]);
        $replacemail['bbsemanage'][] = array('name' => '留言论坛主题', 'title' => '[%b_title%]', 'content' => $read["title"]);
        $replacemail['bbsemanage'][] = array('name' => '留言论坛姓名', 'title' => '[%b_username%]', 'content' => $read["addname"]);
        $replacemail['bbsemanage'][] = array('name' => '留言论坛邮箱', 'title' => '[%b_email%]', 'content' => $read["email"]);
        $replacemail['bbsemanage'][] = array('name' => '留言提交时间', 'title' => '[%b_time%]', 'content' => $read["addtime"]);
        $replacemail['bbsemanage'][] = array('name' => '留言回复时间', 'title' => '[%b_retime%]', 'content' => $read["retime"]);
        $replacemail['bbsemanage'][] = array('name' => '留言链接地址', 'title' => '[%forumlink%]', 'content' => $read['forumlink']);
        $replacemail['other'][] = array('name' => '当前详细时间', 'title' => '[%nowtime%]', 'content' => $read['nowtime']);
        $replacemail['other'][] = array('name' => '当前日期', 'title' => '[%nowdate%]', 'content' => $read['nowdate']);
        $replacemail['other'][] = array('name' => '验证码', 'title' => '[%idcode%]', 'content' => $read['idcode']);
        return $key ? $replacemail[$key] : $replacemail;
    }
}
