+ last content mgmt. imp.

This commit is contained in:
kelson42 2011-05-09 17:18:44 +00:00
parent 49dd576a8a
commit 67d0340d77
2 changed files with 27 additions and 1 deletions

View File

@ -59,6 +59,28 @@ namespace kiwix {
}
bool Library::addBook(const Book &book) {
/* Try to find it */
std::vector<kiwix::Book>::iterator itr;
for ( itr = this->books.begin(); itr != this->books.end(); ++itr ) {
if (itr->id == book.id) {
if (itr->path.empty())
itr->path = book.path;
if (itr->url.empty())
itr->url = book.url;
if (itr->indexPath.empty()) {
itr->indexPath = book.indexPath;
itr->indexType = book.indexType;
}
return false;
}
}
/* otherwise */
this->books.push_back(book);
return true;
}

View File

@ -32,7 +32,10 @@ namespace kiwix {
bool Manager::parseXmlDom(const pugi::xml_document &doc, const bool readOnly) {
pugi::xml_node libraryNode = doc.child("library");
library.current = libraryNode.attribute("current").value();
if (strlen(libraryNode.attribute("current").value()))
library.current = libraryNode.attribute("current").value();
string libraryVersion = libraryNode.attribute("version").value();
for (pugi::xml_node bookNode = libraryNode.child("book"); bookNode; bookNode = bookNode.next_sibling("book")) {
@ -294,6 +297,7 @@ namespace kiwix {
if (mode == LASTOPEN) {
std::sort(library.books.begin(), library.books.end(), kiwix::Book::sortByLastOpen);
for ( itr = library.books.begin(); itr != library.books.end(); ++itr ) {
if (!itr->last.empty())
this->bookIdList.push_back(itr->id);
}
} else if (mode == REMOTE) {