This repository was archived by the owner on Sep 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripture.admin.inc
More file actions
112 lines (93 loc) · 3.01 KB
/
scripture.admin.inc
File metadata and controls
112 lines (93 loc) · 3.01 KB
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
<?php
/*
* ADMIN PAGE CALLBACKS
* Three different strategies for page callbacks: http://www.drupalcoder.com/blog/how-to-define-page-callbacks-that-you-dont-want-to-render-using-page-template-in-drupal.html
* Build the callbacks using renderable arrays. Good reading on renderable arrays:
* - https://www.drupal.org/node/930760
* - http://cocoate.com/ddbook/scary-render-array
* - http://drupal.stackexchange.com/questions/11438/how-to-nest-elements-in-a-render-array
*/
/**
* Page callback for admin/structure/scripture[/status]
* summarize what is going on in the Scripture db tables
*/
function scripture_callback_status() {
$content = array();
$translations = scripture_get_translations();
$translation_rows = array();
foreach ($translations as $id => $translation) {
$books = scripture_get_books($id);
$translation_rows[] = array(
$translation->name,
count($books),
);
}
$content['summary'] = array(
'#prefix' => '<h2>' . t('Summary') . '</h2>',
'#theme' => 'table',
'#rows' => array(
array(
t('Number of translations'),
count($translations)
),
)
);
$content['translations'] = array(
'#prefix' => '<h2>' . t('Translations') . '</h2>',
'#theme' => 'table',
'#header' => array(
t('Translation'),
t('Number of books'),
),
'#rows' => $translation_rows
);
$content['TODO'] = array(
'#prefix' => '<h2>TODO</h2>',
'#markup' => 'TODO: display any other required statistics here',
);
return $content;
}
/**
* Page callback for admin/structure/scripture/translations
*/
function scripture_callback_translations() {
$form = array();
$translations = scripture_get_translations();
foreach ($translations as $abbr => &$t) {
$t = "{$t->abbr} / {$t->lang} / {$t->name}";
}
$form['scripture_default_translation'] = array(
'#type' => 'select',
'#title' => t('Default translation'),
'#options' => $translations,
'#description' => t('Choose the default translation to use when none is specified.'),
'#required' => true,
'#default_value' => array(
variable_get('scripture_default_translation', NULL)
)
);
return system_settings_form($form);
}
/**
* Page callback for admin/structure/scripture/translations
*/
function scripture_callback_queries() {
$form = array();
$form['scripture_match_quality_weight_query'] = array(
'#type' => 'textfield',
'#size' => 3,
'#title' => t('Query match quality weight'),
'#description' => t('The relative importance of search results covering the entire query.'),
'#required' => true,
'#default_value' => 1,
);
$form['scripture_match_quality_weight_entity'] = array(
'#type' => 'textfield',
'#size' => 3,
'#title' => t('Entity match quality weight'),
'#description' => t('The relative importance of the query covering the entire range of verses in the search results.'),
'#required' => true,
'#default_value' => 1,
);
return system_settings_form($form);
}