90
90
if (request->query.count ("remove")) {
91
size_t offset = abs (convert_to_int (request->query["remove"]));
91
size_t offset = static_cast<size_t>(abs (convert_to_int (request->query["remove"])));
92
92
vector <string> resources = request->database_config_user()->getPrintResources ();
93
93
if (!resources.empty () && (offset < resources.size ())) {
94
94
string remove = resources [offset];
101
101
string moveup = request->query ["moveup"];
102
102
string movedown = request->query ["movedown"];
103
103
if (!moveup.empty () || !movedown.empty ()) {
104
size_t move = convert_to_int (moveup + movedown);
104
size_t move = static_cast<size_t> (convert_to_int (moveup + movedown));
105
105
vector <string> resources = request->database_config_user()->getPrintResources ();
106
106
array_move_up_down (resources, move, !moveup.empty ());
107
107
request->database_config_user()->setPrintResources (resources);
123
123
// Set where to start from: Set book, chapter 1, verse 0.
124
124
Passage frompassage = request->database_config_user()->getPrintPassageFrom ();
125
frompassage.book = convert_to_int (frombook);
126
frompassage.chapter = 0;
127
frompassage.verse = "0";
125
frompassage.m_book = convert_to_int (frombook);
126
frompassage.m_chapter = 0;
127
frompassage.m_verse = "0";
128
128
request->database_config_user()->setPrintPassageFrom (frompassage);
129
129
// Check if ending book matches.
130
130
Passage topassage = request->database_config_user()->getPrintPassageTo ();
131
131
if (filter_passage_to_integer (topassage) < filter_passage_to_integer (frompassage)) {
132
132
// Set ending passage to a sensible value.
133
topassage.book = convert_to_int (frombook);
134
vector <int> chapters = request->database_bibles()->getChapters (bible, topassage.book);
135
topassage.chapter = frompassage.chapter;
136
if (!chapters.empty ()) topassage.chapter = chapters.back ();
137
vector <int> verses = usfm_get_verse_numbers (request->database_bibles()->getChapter (bible, topassage.book, topassage.chapter));
138
topassage.verse = frompassage.verse;
139
if (!verses.empty ()) topassage.verse = convert_to_string (verses.back ());
133
topassage.m_book = convert_to_int (frombook);
134
vector <int> chapters = request->database_bibles()->getChapters (bible, topassage.m_book);
135
topassage.m_chapter = frompassage.m_chapter;
136
if (!chapters.empty ()) topassage.m_chapter = chapters.back ();
137
vector <int> verses = filter::usfm::get_verse_numbers (request->database_bibles()->getChapter (bible, topassage.m_book, topassage.m_chapter));
138
topassage.m_verse = frompassage.m_verse;
139
if (!verses.empty ()) topassage.m_verse = convert_to_string (verses.back ());
140
140
request->database_config_user()->setPrintPassageTo (topassage);
148
148
if (fromchapter == "") {
149
149
Dialog_List dialog_list = Dialog_List ("print", translate("Select a chapter"), "", "");
150
150
Passage passage = request->database_config_user()->getPrintPassageFrom ();
151
vector <int> chapters = request->database_bibles()->getChapters (bible, passage.book);
151
vector <int> chapters = request->database_bibles()->getChapters (bible, passage.m_book);
152
152
for (auto & chapter : chapters) {
153
153
dialog_list.add_row (convert_to_string (chapter), "fromchapter", convert_to_string (chapter));
158
158
// Set which chapter to start from, and the verse also.
159
159
Passage frompassage = request->database_config_user()->getPrintPassageFrom ();
160
frompassage.chapter = convert_to_int (fromchapter);
161
frompassage.verse = "0";
160
frompassage.m_chapter = convert_to_int (fromchapter);
161
frompassage.m_verse = "0";
162
162
request->database_config_user()->setPrintPassageFrom (frompassage);
163
163
// Check if ending passage is sensible.
164
164
Passage topassage = request->database_config_user()->getPrintPassageTo ();
165
165
if (filter_passage_to_integer (topassage) < filter_passage_to_integer (frompassage)) {
166
166
// Set ending chapter / verse to sensible values.
167
topassage.chapter = convert_to_int (fromchapter);
168
vector <int> verses = usfm_get_verse_numbers (request->database_bibles()->getChapter (bible, topassage.book, topassage.chapter));
169
topassage.verse = frompassage.verse;
170
if (!verses.empty ()) topassage.verse = convert_to_string (verses.back ());
167
topassage.m_chapter = convert_to_int (fromchapter);
168
vector <int> verses = filter::usfm::get_verse_numbers (request->database_bibles()->getChapter (bible, topassage.m_book, topassage.m_chapter));
169
topassage.m_verse = frompassage.m_verse;
170
if (!verses.empty ()) topassage.m_verse = convert_to_string (verses.back ());
171
171
request->database_config_user()->setPrintPassageTo (topassage);
179
179
if (fromverse == "") {
180
180
Dialog_List dialog_list = Dialog_List ("print", translate("Select a verse"), "", "");
181
181
Passage passage = request->database_config_user()->getPrintPassageFrom ();
182
string usfm = request->database_bibles()->getChapter (bible, passage.book, passage.chapter);
183
vector <int> verses = usfm_get_verse_numbers (usfm);
182
string usfm = request->database_bibles()->getChapter (bible, passage.m_book, passage.m_chapter);
183
vector <int> verses = filter::usfm::get_verse_numbers (usfm);
184
184
for (auto & verse : verses) {
185
185
dialog_list.add_row (convert_to_string (verse), "fromverse", convert_to_string (verse));
191
191
Passage frompassage = request->database_config_user()->getPrintPassageFrom ();
192
frompassage.verse = fromverse;
192
frompassage.m_verse = fromverse;
193
193
request->database_config_user()->setPrintPassageFrom (frompassage);
194
194
// Sensible matching ending verse.
195
195
Passage topassage = request->database_config_user()->getPrintPassageTo ();
196
196
if (filter_passage_to_integer (topassage) < filter_passage_to_integer (frompassage)) {
197
vector <int> verses = usfm_get_verse_numbers (request->database_bibles()->getChapter (bible, topassage.book, topassage.chapter));
198
topassage.verse = frompassage.verse;
199
if (!verses.empty ()) topassage.verse = convert_to_string (verses.back ());
197
vector <int> verses = filter::usfm::get_verse_numbers (request->database_bibles()->getChapter (bible, topassage.m_book, topassage.m_chapter));
198
topassage.m_verse = frompassage.m_verse;
199
if (!verses.empty ()) topassage.m_verse = convert_to_string (verses.back ());
200
200
request->database_config_user()->setPrintPassageTo (topassage);
218
218
// Set ending passage.
219
219
Passage topassage = request->database_config_user()->getPrintPassageTo ();
220
topassage.book = convert_to_int (tobook);
221
topassage.chapter = 1;
222
topassage.verse = "0";
220
topassage.m_book = convert_to_int (tobook);
221
topassage.m_chapter = 1;
222
topassage.m_verse = "0";
223
223
request->database_config_user()->setPrintPassageTo (topassage);
224
224
// Check on matching starting book.
225
225
Passage frompassage = request->database_config_user()->getPrintPassageFrom ();
226
226
if (filter_passage_to_integer (topassage) < filter_passage_to_integer (frompassage)) {
227
227
// Set starting passage to a sensible value.
228
frompassage.book = convert_to_int (tobook);
229
frompassage.chapter = 0;
230
frompassage.verse = "0";
228
frompassage.m_book = convert_to_int (tobook);
229
frompassage.m_chapter = 0;
230
frompassage.m_verse = "0";
231
231
request->database_config_user()->setPrintPassageFrom (frompassage);
239
239
if (tochapter == "") {
240
240
Dialog_List dialog_list = Dialog_List ("print", translate("Select a chapter"), "", "");
241
241
Passage passage = request->database_config_user()->getPrintPassageTo ();
242
vector <int> chapters = request->database_bibles()->getChapters (bible, passage.book);
242
vector <int> chapters = request->database_bibles()->getChapters (bible, passage.m_book);
243
243
for (auto & chapter : chapters) {
244
244
dialog_list.add_row (convert_to_string (chapter), "tochapter", convert_to_string (chapter));
250
250
Passage topassage = request->database_config_user()->getPrintPassageTo ();
251
topassage.chapter = convert_to_int (tochapter);
252
topassage.verse = "0";
251
topassage.m_chapter = convert_to_int (tochapter);
252
topassage.m_verse = "0";
253
253
request->database_config_user()->setPrintPassageTo (topassage);
254
254
// Match starting passage.
255
255
Passage frompassage = request->database_config_user()->getPrintPassageFrom ();
256
256
if (filter_passage_to_integer (topassage) < filter_passage_to_integer (frompassage)) {
257
257
// Set starting passage to a sensible value.
258
frompassage.book = topassage.book;
259
frompassage.chapter = 0;
260
frompassage.verse = "0";
258
frompassage.m_book = topassage.m_book;
259
frompassage.m_chapter = 0;
260
frompassage.m_verse = "0";
261
261
request->database_config_user()->setPrintPassageFrom (frompassage);
269
269
if (toverse == "") {
270
270
Dialog_List dialog_list = Dialog_List ("print", translate("Select a verse"), "", "");
271
271
Passage passage = request->database_config_user()->getPrintPassageTo ();
272
string usfm = request->database_bibles()->getChapter (bible, passage.book, passage.chapter);
273
vector <int> verses = usfm_get_verse_numbers (usfm);
272
string usfm = request->database_bibles()->getChapter (bible, passage.m_book, passage.m_chapter);
273
vector <int> verses = filter::usfm::get_verse_numbers (usfm);
274
274
for (auto & verse : verses) {
275
275
dialog_list.add_row (convert_to_string (verse), "toverse", convert_to_string (verse));
280
280
// Set ending verse.
281
281
Passage topassage = request->database_config_user()->getPrintPassageTo ();
282
topassage.verse = toverse;
282
topassage.m_verse = toverse;
283
283
request->database_config_user()->setPrintPassageTo (topassage);
284
284
// Match starting verse.
285
285
Passage frompassage = request->database_config_user()->getPrintPassageFrom ();
286
286
if (filter_passage_to_integer (topassage) < filter_passage_to_integer (frompassage)) {
287
287
// Set starting passage to a sensible value.
288
frompassage.book = topassage.book;
289
frompassage.chapter = topassage.chapter;
290
frompassage.verse = "0";
288
frompassage.m_book = topassage.m_book;
289
frompassage.m_chapter = topassage.m_chapter;
290
frompassage.m_verse = "0";
291
291
request->database_config_user()->setPrintPassageFrom (frompassage);
309
309
Passage passage = request->database_config_user()->getPrintPassageFrom ();
310
view.set_variable ("from_book", Database_Books::getEnglishFromId (passage.book));
311
view.set_variable ("from_chapter", convert_to_string (passage.chapter));
312
view.set_variable ("from_verse", passage.verse);
310
view.set_variable ("from_book", Database_Books::getEnglishFromId (passage.m_book));
311
view.set_variable ("from_chapter", convert_to_string (passage.m_chapter));
312
view.set_variable ("from_verse", passage.m_verse);
313
313
passage = request->database_config_user()->getPrintPassageTo ();
314
view.set_variable ("to_book", Database_Books::getEnglishFromId (passage.book));
315
view.set_variable ("to_chapter", convert_to_string (passage.chapter));
316
view.set_variable ("to_verse", passage.verse);
314
view.set_variable ("to_book", Database_Books::getEnglishFromId (passage.m_book));
315
view.set_variable ("to_chapter", convert_to_string (passage.m_chapter));
316
view.set_variable ("to_verse", passage.m_verse);
319
319
page += view.render ("resource", "print");
325
325
void resource_print_job (string jobId, string user, string bible)
327
327
Webserver_Request request;
328
request.session_logic ()->setUsername (user);
328
request.session_logic ()->set_username (user);
331
331
Database_Jobs database_jobs = Database_Jobs ();
351
351
vector <int> chapters = request.database_bibles()->getChapters (bible, book);
352
352
for (auto & chapter : chapters) {
353
353
string usfm = request.database_bibles()->getChapter (bible, book, chapter);
354
vector <int> verses = usfm_get_verse_numbers (usfm);
354
vector <int> verses = filter::usfm::get_verse_numbers (usfm);
355
355
for (auto & verse : verses) {
356
356
int passage = filter_passage_to_integer (Passage ("", book, chapter, convert_to_string (verse)));
357
357
if ((passage >= ifrom) && (passage <= ito)) {