PhoenixLecture  2.0.0
Set of tools to make lectures
platexobj_menu.h File Reference
+ Include dependency graph for platexobj_menu.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

PString platexobj_menuToHtml (const PFullMenu &menu, const PString &currentLink, bool isBibliography)
 Convert a PFullMenu to html. More...
 
PString platexobj_menuToHtmlChapter (const PFullMenu &menu, const PString &currentLink, const PString &indentation)
 
PFullMenu platexobj_toMenu (const PLatexObj &obj, const PLatexObj &mainPageLink)
 Convert a PLatexObj into a menu. More...
 
void platexobj_toMenuAll (PFullMenu &menu, const PLatexObj &obj)
 Convert a PLatexObj into a menu. More...
 

Function Documentation

◆ platexobj_menuToHtml()

PString platexobj_menuToHtml ( const PFullMenu menu,
const PString currentLink,
bool  isBibliography 
)

Convert a PFullMenu to html.

Parameters
menu: PFullMenu to be converted
currentLink: link of the current menu
isBibliography: true if there is a bibliography, false if not
Returns
corresponding html

Definition at line 132 of file platexobj_menu.cpp.

132  {
133  PFullMenu expandedMenu(menu);
134  platexobj_makeExpandMenu(expandedMenu, currentLink);
135 
136  PString body(""), indentation("\t\t");
137  body += indentation+"<nav id=\"sidebar\" class=\"sidebar\" aria-label=\"Table of contents\">\n";
138  body += indentation+"\t<div class=\"sidebar-scrollbox\">\n";
139  body += indentation+"\t\t<ol class=\"chapter\">\n";
140  body += indentation + "\t\t\t<li class=\"chapter-item \"><a href=\"index.html\">"+menu.getMainPageLink()+"</a></li>\n";
141  const std::vector<PFullMenu> & vecSubMenu = expandedMenu.getVecSubMenu();
142  for(std::vector<PFullMenu>::const_iterator it(vecSubMenu.begin()); it != vecSubMenu.end(); ++it){
143  body += platexobj_menuToHtmlChapter(*it, indentation+"\t\t\t");
144  }
145  if(isBibliography){
146  body += indentation + "\t\t\t<li class=\"chapter-item \"><a href=\"bibliography.html\">Bibliography</a></li>\n";
147  }
148 
149  body += indentation+"\t\t</ol>\n";
150  body += indentation+"\t</div>\n";
151  body += indentation+"\t<div id=\"sidebar-resize-handle\" class=\"sidebar-resize-handle\"></div>\n";
152  body += indentation+"</nav>\n";
153  return body;
154 }
Full menu of all site.
Definition: PLatexObj.h:168
const PString & getMainPageLink() const
Gets the mainPageLink of the PFullMenu.
Definition: PLatexObj.cpp:813
Extends the std::string.
Definition: PString.h:16
PString platexobj_menuToHtmlChapter(const PFullMenu &menu, const PString &indentation)
Convert a PFullMenu to html.
void platexobj_makeExpandMenu(PFullMenu &menu, const PString &currentLink)
Update menus which are supposed to be extended.

References PFullMenu::getMainPageLink(), PFullMenu::getVecSubMenu(), platexobj_makeExpandMenu(), and platexobj_menuToHtmlChapter().

Referenced by platexobj_theme_update_var().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ platexobj_menuToHtmlChapter()

PString platexobj_menuToHtmlChapter ( const PFullMenu menu,
const PString currentLink,
const PString indentation 
)

◆ platexobj_toMenu()

PFullMenu platexobj_toMenu ( const PLatexObj obj,
const PLatexObj mainPageLink 
)

Convert a PLatexObj into a menu.

Parameters
obj: PLatexObj to be used
mainPageLink: main page link if updated
Returns
PFullMenu

Definition at line 48 of file platexobj_menu.cpp.

48  {
49  PFullMenu menu;
50  platexobj_toMenuAll(menu, obj);
51  if(mainPageLink.getType() == PLatexType::BOOKMAINPAGELINK){
52  PString textMainPage(platexobj_text(mainPageLink.getVecContent()));
53  if(textMainPage != ""){
54  menu.setMainPageLink(textMainPage);
55  }else{
56  menu.setMainPageLink("Main Page");
57  }
58  }else{
59  menu.setMainPageLink("Main Page");
60  }
61  return menu;
62 }
void setMainPageLink(const PString &mainPageLink)
Sets the mainPageLink of the PFullMenu.
Definition: PLatexObj.cpp:722
const std::vector< PLatexObj > & getVecContent() const
Gets the vecContent of the PLatexObj.
Definition: PLatexObj.cpp:410
const PLatexType::PLatexType & getType() const
Gets the type of the PLatexObj.
Definition: PLatexObj.cpp:298
@ BOOKMAINPAGELINK
Definition: PLatexType.h:65
void platexobj_toMenuAll(PFullMenu &menu, const PLatexObj &obj)
Convert a PLatexObj into a menu.
PString platexobj_text(const std::vector< PLatexObj > &vecObj)
Convert a PLatexObj in text.

References PLatexType::BOOKMAINPAGELINK, PLatexObj::getType(), PLatexObj::getVecContent(), platexobj_text(), platexobj_toMenuAll(), and PFullMenu::setMainPageLink().

Referenced by processAllFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ platexobj_toMenuAll()

void platexobj_toMenuAll ( PFullMenu menu,
const PLatexObj obj 
)

Convert a PLatexObj into a menu.

Parameters
[out]menu: PFullMenu
obj: PLatexObj

Definition at line 17 of file platexobj_menu.cpp.

17  {
18  PString complextTitle(platexobj_text(obj.getComplexTitle()));
19  PString objTitle("<strong aria-hidden=\"true\">" + vecNumberToString(obj.getVecSecNumber()) + ".</strong> " + complextTitle); //Content of the section title
20  PLatexType::PLatexType type(obj.getType());
21  menu.setLink(obj.getLink());
22  if(type == PLatexType::PART){menu.setText(/*"Part " +*/ objTitle);}
23  else if(type == PLatexType::CHAPTER){menu.setText(/*"Chapter " +*/ objTitle);}
24  else if(type == PLatexType::SECTION){menu.setText(objTitle);}
25  else if(type == PLatexType::SUBSECTION){menu.setText(objTitle);}
26  else if(type == PLatexType::SUBSUBSECTION){menu.setText(objTitle);}
27  else if(type == PLatexType::FILE){menu.setText(obj.getName());}
28  else if(type == PLatexType::BOOKPARTSEPARATOR){
29  menu.setText(complextTitle);
30  menu.setIsSeparator(true);
31  }
32 
33  const std::vector<PLatexObj> & vecChildren = obj.getVecContent();
34  for(std::vector<PLatexObj>::const_iterator it(vecChildren.begin()); it != vecChildren.end(); ++it){
35  if(!isSectionOrSeparator(*it)){continue;}
36  PFullMenu subMenu;
37  platexobj_toMenuAll(subMenu, *it);
38  menu.getVecSubMenu().push_back(subMenu);
39  }
40 }
void setText(const PString &text)
Sets the text of the PFullMenu.
Definition: PLatexObj.cpp:708
void setLink(const PString &link)
Sets the link of the PFullMenu.
Definition: PLatexObj.cpp:701
void setIsSeparator(bool isSeparator)
Sets the isSeparator of the PFullMenu.
Definition: PLatexObj.cpp:694
const std::vector< PFullMenu > & getVecSubMenu() const
Gets the vecSubMenu of the PFullMenu.
Definition: PLatexObj.cpp:799
const std::vector< PLatexObj > & getComplexTitle() const
Gets the complexTitle of the PLatexObj.
Definition: PLatexObj.cpp:396
const PString & getName() const
Gets the name of the PLatexObj.
Definition: PLatexObj.cpp:326
const PString & getLink() const
Gets the link of the PLatexObj.
Definition: PLatexObj.cpp:368
const std::vector< long unsigned int > & getVecSecNumber() const
Gets the vecSecNumber of the PLatexObj.
Definition: PLatexObj.cpp:438
PLatexType
Type of the PLatexObj.
Definition: PLatexType.h:12
@ SUBSUBSECTION
Definition: PLatexType.h:54
@ BOOKPARTSEPARATOR
Definition: PLatexType.h:64
PString vecNumberToString(const std::vector< long unsigned int > &vecNb)
Convert a vector of numbers into a string.
bool isSectionOrSeparator(const PLatexObj &obj)
Say if the PLatexObj is a part, charpter, section, subsection, subsubsection or a book separator.

References PLatexType::BOOKPARTSEPARATOR, PLatexType::CHAPTER, PLatexType::FILE, PLatexObj::getComplexTitle(), PLatexObj::getLink(), PLatexObj::getName(), PLatexObj::getType(), PLatexObj::getVecContent(), PLatexObj::getVecSecNumber(), PFullMenu::getVecSubMenu(), isSectionOrSeparator(), PLatexType::PART, platexobj_text(), PLatexType::SECTION, PFullMenu::setIsSeparator(), PFullMenu::setLink(), PFullMenu::setText(), PLatexType::SUBSECTION, PLatexType::SUBSUBSECTION, and vecNumberToString().

Referenced by platexobj_toMenu().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: