-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtbtrack.api.php
101 lines (92 loc) · 2.4 KB
/
tbtrack.api.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* @file
* Hooks provided by the tbtrack module.
*/
/**
* Registers your module as an list of platform
*/
function hook_tbtrack_platform_info() {
return array(
'tmall' => array(
'title' => 'TMall',
// if your module will implements ranking for platform
'ranking' => array(
'search uri' => array(
'host' => '',
'path' => '',
),
'selector callback' => '',
),
),
'taobao' => array(
'title' => 'Taobao',
'search uri' => array(
'host' => '',
'path' => '',
),
'selector callback' => '',
),
);
}
/**
* Registers your module as an list of platform attach params
*/
function hook_tbtrack_platform_attach_params() {
return array(
'ranking' => array(
'search host' => array(
'#required' => TRUE,
'#default_value' => 'http://taobao.com',
),
'search path' => array(
'#default_value' => '/search',
'#required' => TRUE,
),
'selector callback' => array(
'#required' => TRUE,
),
),
);
}
/**
* The hook implements for append everything to product node content
* @param node entity $node
* @param string $view_mode
* @param string $platform platform name
*/
function hook_tbtrack_product_node_view($node, $view_mode, $platform) {
$result = db_select('tbtrack_ranking', 'r')->fields('r')
->condition('product_id', $product->{$platform['field']}->value())
->condition('platform', $name)
->execute();
$rows = array();
while ($record = $result->fetchAssoc()) {
$rows[$record['rid']] = array(
'keyword' => $record['keyword'],
'ranking' => $record['ranking'],
'created' => format_date($record['created'], 'short'),
);
}
$node->content['ranking'][$name . ' table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('No content available.'),
);
}
/**
* The hook implements for append everything to product ranking platform report
* @param array $variables
* @param string $platform platform name
*/
function hook_tbtrack_ranking_product_report_platform(&$variables) {
// build yourself array for rander
$output['title'] = array('#markup' => 'Hello world');
}
/**
* The hook implements for append everything to keyword ranking report
* @param array $variables
*/
function hook_tbtrack_ranking_keyword_report_platform(&$variables) {
}