/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set et sw=2 ts=2: */ /*************************************************************************** * transactionhandler.cc * * Fri Dec 18 10:00:50 CET 2009 * Copyright 2009 Bent Bisballe Nyeng * deva@aasimon.org ****************************************************************************/ /* * This file is part of Pracro. * * Pracro is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Pracro is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pracro; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include "transactionhandler.h" #include "macroparser.h" #include "resumeparser.h" #include "templateparser.h" #include "templateheaderparser.h" #include "courseparser.h" #include "configuration.h" #include "luaquerymapper.h" #include "queryhandlerpentominos.h" #include "queryhandlerpracro.h" #include "xml_encode_decode.h" #include "widgetgenerator.h" #include "journal.h" static std::string error_box(std::string message) { std::string errorbox = "\n" "\n" " " + message + "\n" "\n"; return errorbox; } static std::string handleCommits(Transaction &transaction, Environment &env, Session &session) { std::string answer; if(transaction.commits.size() > 0) { Commits::iterator i = transaction.commits.begin(); while(i != transaction.commits.end()) { Commit &commit = *i; MacroParser mp(env.macrolist.getLatestVersion(commit.macro)); mp.parse(); Macro *macro = mp.getMacro(); std::string resume = resume_parser(*macro, commit); commit.fields["journal.resume"] = resume; session.commitMacro(transaction, commit, *macro); if(resume != "") { TemplateParser tp(env.templatelist.getLatestVersion(commit.templ)); tp.parse(); Template *templ = tp.getTemplate(); session.journal()->addEntry(transaction, commit, resume, templ); } i++; } } return answer; } static std::string handleRequest(Request &request, Environment &env, Session &session) { std::string answer; if(request.course == "" && request.templ == "" && request.macro == "") return ""; if(request.course != "" && request.templ == "" && request.macro == "") { CourseParser cp(env.courselist.getLatestVersion(request.course)); cp.parse(); Course *course = cp.getCourse(); answer += " name + "\" title=\"" + course->title + "\">\n"; std::vector< Template >::iterator ti = course->templates.begin(); while(ti != course->templates.end()) { std::string tname = ti->name; TemplateHeaderParser tp(env.templatelist.getLatestVersion(tname)); tp.parse(); Template *templ = tp.getTemplate(); answer += "