void CommentableObjectViewer::_createLastPosts() { // Calcola il numero di posts totali uint32 total_posts = getEntity()->getChildsCount(getDatabase(), portalObjectTypePost); // Calcola il numero di risposte da visualizzare uint32 posts_count = utils::min<uint32>(total_posts, getSkin()->getPagerItems()); // Carica i posts shared_ptr<EntitiesEntities> posts = getEntity()->getChilds(getDatabase(), portalObjectTypePost, RangeUint32(total_posts - posts_count, posts_count)); if(posts->empty() == false) { shared_ptr<PostViewer> posts_viewer(OS_NEW PostViewer()); getControls()->add(posts_viewer); // Scorre gli ultimi posts dal pi recente for(EntitiesEntities::reverse_iterator i = posts->rbegin(); i != posts->rend(); ++i) { posts_viewer->addPost(posts->get(getDatabase(), *i)); } } }
void CommentableObjectViewer::renderPosts(shared_ptr<XMLPortalExporter> exporter) { if(getObject() == nullptr || getObject()->allowChild(portalObjectTypePost) == false) return; // Calcola il numero totale di posts uint32 total_posts = getEntity()->getChildsCount(getDatabase(), portalObjectTypePost); if(total_posts == 0) return; // Numero di posts da visualizzare per pagina uint32 posts_to_show = getSkin()->getPagerItems(); // Inizializza l'offset di estrazione uint32 offset = conversions::from_utf16<uint32>(getRequest()->getUrlParam(OS_URL_PARAM_OFFSET)); // Corregge l'offset se necessario adjustOffset(total_posts, posts_to_show, offset); objects_posts_list posts; // Estrae le risposte nell'intervallo richiesto shared_ptr<EntitiesEntities> post_childs = getEntity()->getChilds(getDatabase(), portalObjectTypePost, RangeUint32(offset, posts_to_show)); for(EntitiesEntities::iterator i = post_childs->begin(); i != post_childs->end(); ++i) { // Carica la riposta corrente shared_ptr<EntitiesEntity> post_entity = post_childs->get(getDatabase(), *i); if(post_entity != nullptr) { // Calcola la revisione corrente della risposta shared_ptr<ObjectsPost> current_post = objects_post_cast(post_entity->getCurrent()); if(current_post != nullptr) posts.push_back(current_post); } } if(posts.empty() == false) { shared_ptr<XMLNode> posts_node = exporter->getNode(OS_PORTAL_OBJECT_POST_GROUPNAME); for(objects_posts_list::const_iterator i = posts.begin(); i != posts.end(); ++i) { shared_ptr<XMLPortalExporter> postExporter(OS_NEW XMLPortalExporter(posts_node->addChild(OS_PORTAL_OBJECT_POST_TYPENAME), exporter->getPage(), exporter->getMode())); renderPost(postExporter, *i); } } createPager(getSkin(), exporter->getRoot(), total_posts, posts_to_show, offset); }
void DocumentationViewer::_render(shared_ptr<EntitiesEntity> entity, shared_ptr<XMLPortalExporter> exporter, uint32 level, uint32 levelMax, bool withTexts, bool forContent) { if(entity == nullptr) return; if(levelMax == 0) // Disabled. return; if(forContent) exporter->setMode(XMLPortalExporter::emFull); else exporter->setMode(XMLPortalExporter::emLite); entity->exportXML(exporter); bool exportTexts = withTexts; // I testi giĆ comparsi sopra non compaiono nel sottoindice. if( (exportTexts) && (forContent == false) ) exportTexts = (level > 0); // Esporta gli oggetti testo if(exportTexts) { shared_ptr<EntitiesEntities> texts = entity->getChilds(getDatabase(), portalObjectTypeText, RangeUint32(0, 0), EntitiesEntity::coPositionAsc); if(texts != nullptr && texts->empty() == false) { shared_ptr<XMLNode> nodeTexts = exporter->getRoot()->addChild(_S("texts")); for(EntitiesEntities::const_iterator i = texts->begin(); i != texts->end(); ++i) { exporter->getPage()->getPortal()->getEntity(exporter->getDatabase(), *i)->exportXML(exporter->createChild<XMLPortalExporter>(nodeTexts->addChild(_S("text")))); } } } bool exportSections = true; if(levelMax != static_cast<uint32>(-1)) { if(forContent) exportSections = (level<(levelMax-1)); else exportSections = (level<=(levelMax-1)); } // Crea un nodo delle sotto-sezioni if(exportSections) { shared_ptr<EntitiesEntities> subSections = entity->getChilds(getDatabase(), portalObjectTypeSection, RangeUint32(0, 0), EntitiesEntity::coPositionAsc); if(subSections != nullptr && subSections->empty() == false) { shared_ptr<XMLNode> nodeSubSections = exporter->getRoot()->addChild(_S("sections")); for(EntitiesEntities::const_iterator i = subSections->begin(); i != subSections->end(); ++i) { _render(exporter->getPage()->getPortal()->getEntity(getDatabase(), *i), exporter->createChild<XMLPortalExporter>(nodeSubSections->addChild(_S("section"))), level +1, levelMax, withTexts, forContent); } } } }