-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcck.example.php
42 lines (37 loc) · 1.18 KB
/
cck.example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* @file
*
* CCK生成 field_config
*/
exit;
//载入框架和配置文件
require_once dirname(__DIR__) . '/Pyramid/Pyramid.php';
require_once dirname(__DIR__) . '/config.php';
auto_field_config();
function auto_field_config() {
$connect = db_getconnection();
$schemas = db_schema()->getSchema();
$fields = db_select('field_config','f')
->fields('f')
->execute()
->fetchAll();
foreach ($fields as $v) {
$field = $connect->replacePrefix('{'.'data_' . $v->field_name.'}');
if (isset($schemas[$field])) {
$config = array();
foreach ($schemas[$field] as $k => $vv) {
if (in_array($k, array('entity_type', 'entity_id', 'delta'))) {
continue;
}
$config[str_replace($v->field_name.'_', '', $k)] = $vv;
}
$data = array('columns' => $config,);
db_update('field_config')
->fields(array('data' => serialize($data),))
->condition('id', $v->id)
->execute();
}
}
echo 'done!';
}