@caijinlin
2016-05-31T11:17:12.000000Z
字数 4519
阅读 732
cf配置指南
下面以机构名wddemo示例:
切换显示模板
//检查是否有类型_机构的css文件
protected function extra_css_file()
{
$file_name = SUBDOMAIN . "_" . PROJECT_TYPE . ".css";
//覆盖css,调试加载我们需要的机构css
$file_name = 'wddemo_together.css';
$relative_path = "/dist/css/customize/" . $file_name;
$full_path = WWW_ROOT . $relative_path;
if (is_file($full_path)) {
$this->extra_css_file = $relative_path;
}
}
切换加载css
protected function getTemplateFilePath($templateFile)
{
$subdomain = SUBDOMAIN;
//转到我们需要显示的机构模板下面
$subdomain = 'wddemo';
//分享里面没有区分type
if (MODULE_NAME !== 'Share' && MODULE_NAME !== 'UserBind')
{
$page_type = ucfirst(PROJECT_TYPE);
$templateFile = C("TMPL_FILE_DEPR") . $page_type . C("TMPL_FILE_DEPR") . $subdomain . C('TMPL_FILE_DEPR') . $templateFile;
} else {
$templateFile = C("TMPL_FILE_DEPR") . $subdomain . C('TMPL_FILE_DEPR') . $templateFile;
}
$dest = TMPL_PATH . GROUP_NAME . C("TMPL_FILE_DEPR") . MODULE_NAME . $templateFile . '.html';
if (!is_file($dest)) {
/**
*@todo 从主题中找
*/
$templateFile = str_replace($subdomain, 'default', $templateFile);
$dest = TMPL_PATH . GROUP_NAME . C("TMPL_FILE_DEPR") . MODULE_NAME . $templateFile . '.html';
//都找不到
if (!is_file($dest)) {
return false;
}
}
return $dest;
}
配置机构的一些默认配置,现提供了如下脚本配置(暂时放在lingxi_cf CommonAction下面)
/**
* cf定制配置option脚本
* 这些配置都是用户是不能编辑的,其它不包含在这里的配置大多数应该能通过灵析后台配置实现
* 注意:!!!执行脚本前,自行加入以下各个配置的值到option_value中
* 如果还有其它配置可自行按照如下格式加入
* 不需要执行且采用灵析默认的配置可以注释掉
* 各个配置的格式请看column_type
* 各个配置需要注意的请看append_tip
* @param 传入token 使用 Crypt::en($subdomain . '.' . $team_id)生成
* @todo 各个配置的值写在option_value中
*/
public function customize_cf_option()
{
$token = Crypt::de(htmlspecialchars(I('token')));
$token_array = explode('.', $token);
$subdomain = $token_array[0];
$teamId = $token_array[1];
if (!$teamId || !$subdomain) {
die(dump('参数不全'));
}
if (D('DomainDbs')->where('id = %d', $teamId)->getField('subdomain') != $subdomain) {
die(dump('invalid prarams'));
}
$options = array(
'dashboard_menu' => array(
'display_name' => '个人中心导航菜单',
'option_value' => '',
'column_type' => 'json',
'append_tip' => '目前包括六种[profile => 我的资料, footprint => 我的足迹, donate_list => 我的捐赠, user_project_list => 我的一起捐, event_list => 身体力行榜, legal => 捐赠免税]',
),
'dashboard_url_prefix' => array(
'display_name' => '个人中心链接',
'option_value' => '',
'column_type' => 'text',
'append_tip' => '*和个人中心导航菜单相对应(比如/cf/user_dashboard/donate_list)',
),
'dashboard_header_logo_url' => array(
'display_name' => '个人中心顶部logo图片',
'option_value' => '',
'column_type' => 'text',
'append_tip' => '',
),
'dashboard_footer_logo_url' => array(
'display_name' => '个人中心底部logo图片',
'option_value' => '',
'column_type' => 'text',
'append_tip' => '*机构没有底部logo需要设置为false',
),
'cf_html_title' => array(
'display_name' => '网页标题',
'option_value' => '',
'column_type' => 'text',
'append_tip' => '',
),
'dashboard_has_footprint_tip' => array(
'display_name' => '有支持记录提示',
'option_value' => '',
'column_type' => 'text',
'append_tip' => '',
),
'dashboard_empty_footprint_tip' => array(
'display_name' => '无支持记录提示',
'option_value' => '',
'column_type' => 'text',
'append_tip' => '',
),
'wx_default_share_img' => array(
'display_name' => '微信默认分享图(120*120)',
'option_value' => '',
'column_type' => 'text',
'append_tip' => '',
),
'fundraising_header_bg' => array(
'display_name' => '发起一起捐页面顶部头图',
'option_value' => '',
'column_type' => 'text',
'append_tip' => 'fundraising页面头图',
),
'together_detail_header_bg' => array(
'display_name' => '一起捐详情页面顶部头图',
'option_value' => '',
'column_type' => 'text',
'append_tip' => 'together_detail页面头图',
),
'together_success_header_bg' => array(
'display_name' => '定制捐成功页面顶部头图',
'option_value' => '',
'column_type' => 'text',
'append_tip' => 'return_success页面头图',
),
'certificate_donate_project' => array(
'display_name' => '捐赠项目证书(非单次证书)',
'option_value' => '',
'column_type' => 'json',
'append_tip' => '*参考其它机构的值(需要熟悉七牛api各个参数表示含义,可以通过common.php generate_test_certificate函数生成json格式数据)',
),
);
$optionNames = array_keys($options);
$optionKeys = D('Cf/CFOptionKeys')->where(array('option_name' => array('in', $optionNames)))->field('id, option_name')->select();
foreach ($optionKeys as $key => $value)
{
$data['key_id'] = $value['id'];
$data['team_id'] = $teamId;
$data['subdomain'] = $subdomain;
$data['project_id'] = 0;
$data['option_value'] = $options[$value['option_name']]['option_value'];
$data['create_time'] = $data['update_time'] = date('Y-m-d H:i:s');
D('Cf/CFOptions')->add($data);
dump(D('Cf/CFOptions')->getlastsql());
}
}