-
Notifications
You must be signed in to change notification settings - Fork 0
/
tbtrack.pages.inc
115 lines (96 loc) · 3.22 KB
/
tbtrack.pages.inc
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
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* @file tbtrack module page callback define here
*/
/**
* default report for product ranking
*/
function tbtrack_ranking_product_report_default($node) {
if ($node->type != 'products') {
drupal_set_message(t('Sorry, current node is not a product'));
drupal_goto('node/' . $node->nid);
}
$output = array();
$product = entity_metadata_wrapper('node', $node->nid);
foreach (array_keys(tbtrack_get_platform_info()) as $platform) {
$output['ranking ' . $platform]['#post_render'] = array('_tbtrack_add_div');
$output['ranking ' . $platform]['title'] = array(
'#markup' => t('Information for platform !platform', array('!platform' => $platform)),
'#post_render' => array('_tbtrack_add_div'),
);
$variables = array(
'#type' => TBTRACK_RANKING_TABLE_TYPE_ALL,
'#product' => $product,
'#platform' => $platform,
);
$output['ranking ' . $platform]['avg table'] = tbtrack_ranking_build_table($variables);
$output['ranking ' . $platform]['avg table'] = tbtrack_ranking_build_table($variables);
}
return $output;
}
/**
* platform report for product ranking
*/
function tbtrack_ranking_product_report_platform($node, $platform) {
if ($node->type != 'products') {
drupal_set_message(t('Sorry, current node is not a product'));
drupal_goto('node/' . $node->nid);
}
$output = array();
$product = entity_metadata_wrapper('node', $node->nid);
$variables = array(
'#product' => $product,
'#platform' => $platform,
);
$variables['#type'] = TBTRACK_RANKING_TABLE_TYPE_ALL;
$output['tables']['all'] = tbtrack_ranking_build_table($variables);
$variables['#type'] = TBTRACK_RANKING_TABLE_TYPE_AVG;
$output['tables']['avg'] = tbtrack_ranking_build_table($variables);
$output['tables']['keywords'] = array(
'#type' => 'form',
'#title' => t('Keywords history'),
'#attributes' => array(
'classes' => array(
'product-keywords-wrapper',
)
),
);
$variables['#type'] = TBTRACK_RANKING_TABLE_TYPE_KEYWORD;
foreach ($product->field_keywords->value() as $keyword) {
$keyword_table = array();
$keyword_table = array(
'#title' => $keyword->name,
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$variables['#keyword'] = $keyword;
$keyword_table['table'] = tbtrack_ranking_build_table($variables);
$keyword_table['extends'] = array(
'#type' => 'container',
'#attributes' => array(
'classes' => array('keywords-extends-report')
)
);
$keyword_extends = module_invoke_all('tbtrack_ranking_keyword_report_platform', $variables);
if (is_array($keyword_extends)) {
foreach($keyword_extends as $key => $extend) {
$keyword_table['extends'][$key] = $extend;
}
}
$output['tables']['keywords'][$keyword->tid] = $keyword_table;
}
$extends = module_invoke_all('tbtrack_ranking_product_report_platform', $variables);
$output['extends'] = array(
'#type' => 'container',
'#attributes' => array(
'classes' => array('extends-report')
)
);
if (is_array($extends)) {
foreach($extends as $key => $extend) {
$output['extends'][$key] = $extend;
}
}
return $output;
}