PhoenixLecture  2.0.0
Set of tools to make lectures
platexobj_menu.cpp File Reference
#include "platexobj_html.h"
#include "platexobj_text.h"
#include "platexobj_menu.h"
+ Include dependency graph for platexobj_menu.cpp:

Go to the source code of this file.

Functions

bool platexobg_isMenuExtanded (const PFullMenu &menu, const PString &currentLink)
 Say if the current menu has to be extended. More...
 
void platexobj_makeExpandMenu (PFullMenu &menu, const PString &currentLink)
 Update menus which are supposed to be extended. More...
 
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 &indentation)
 Convert a PFullMenu to html. More...
 
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

◆ platexobg_isMenuExtanded()

bool platexobg_isMenuExtanded ( const PFullMenu menu,
const PString currentLink 
)

Say if the current menu has to be extended.

Parameters
menu: PFullMenu to be checked
currentLink: link of the menu to be expanded

Definition at line 104 of file platexobj_menu.cpp.

104  {
105  return menu.getLink() == currentLink;
106 }
const PString & getLink() const
Gets the link of the PFullMenu.
Definition: PLatexObj.cpp:771

References PFullMenu::getLink().

Referenced by platexobj_makeExpandMenu().

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

◆ platexobj_makeExpandMenu()

void platexobj_makeExpandMenu ( PFullMenu menu,
const PString currentLink 
)

Update menus which are supposed to be extended.

Parameters
menu: PFullMenu to be converted
currentLink: link of the current menu

Definition at line 112 of file platexobj_menu.cpp.

112  {
113  bool isFirstExtended(platexobg_isMenuExtanded(menu, currentLink)); //Check if the current section has to be expanded
114  menu.setIsFirstExpanded(isFirstExtended);
115  bool isExtended(isFirstExtended);
116  std::vector<PFullMenu> & vecSubMenu = menu.getVecSubMenu();
117  std::vector<PFullMenu>::iterator it(vecSubMenu.begin());
118  while(!isExtended && it != vecSubMenu.end()){
119  platexobj_makeExpandMenu(*it, currentLink);
120  isExtended = it->getIsExpanded();
121  ++it;
122  }
123  menu.setIsExpanded(isExtended);
124 }
void setIsFirstExpanded(bool isFirstExpanded)
Sets the isFirstExpanded of the PFullMenu.
Definition: PLatexObj.cpp:687
void setIsExpanded(bool isExpanded)
Sets the isExpanded of the PFullMenu.
Definition: PLatexObj.cpp:680
const std::vector< PFullMenu > & getVecSubMenu() const
Gets the vecSubMenu of the PFullMenu.
Definition: PLatexObj.cpp:799
void platexobj_makeExpandMenu(PFullMenu &menu, const PString &currentLink)
Update menus which are supposed to be extended.
bool platexobg_isMenuExtanded(const PFullMenu &menu, const PString &currentLink)
Say if the current menu has to be extended.

References PFullMenu::getVecSubMenu(), platexobg_isMenuExtanded(), PFullMenu::setIsExpanded(), and PFullMenu::setIsFirstExpanded().

Referenced by platexobj_menuToHtml().

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

◆ 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.

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 indentation 
)

Convert a PFullMenu to html.

Parameters
menu: PFullMenu to be converted
indentation: display indentation
Returns
corresponding html

Definition at line 69 of file platexobj_menu.cpp.

69  {
70  PString body(""), link(menu.getLink()), text(menu.getText());
71  PString displayList("");
72  if(menu.getIsSeparator()){
73  body += indentation + "<li class=\"chapter-item affix \"><li class=\"part-title\">"+text+"</li>\n";
74  }else{
75  if(menu.getIsExpanded()){
76  displayList = "expanded";
77  if(menu.getIsFirstExpanded()){
78  displayList += " active";
79  }
80  }
81  body += indentation + "<li class=\"chapter-item "+displayList+"\"><a href=\""+link+"\">"+text+"</a>";
82 
83  const std::vector<PFullMenu> & vecSubMenu = menu.getVecSubMenu();
84  if(vecSubMenu.size() != 0lu){
85  body += "<a class=\"toggle\"><div>❱</div></a></li>\n";
86  body += indentation + "<li>\n";
87  body += indentation + "\t<ol class=\"section\">\n";
88  for(std::vector<PFullMenu>::const_iterator it(vecSubMenu.begin()); it != vecSubMenu.end(); ++it){
89  body += platexobj_menuToHtmlChapter(*it, indentation + "\t\t");
90  }
91  body += indentation + "\t</ol>\n";
92  body += indentation + "</li>\n";
93  }else{
94  body += "</li>\n";
95  }
96  }
97  return body;
98 }
bool getIsSeparator() const
Gets the isSeparator of the PFullMenu.
Definition: PLatexObj.cpp:757
bool getIsExpanded() const
Gets the isExpanded of the PFullMenu.
Definition: PLatexObj.cpp:729
const PString & getText() const
Gets the text of the PFullMenu.
Definition: PLatexObj.cpp:785
bool getIsFirstExpanded() const
Gets the isFirstExpanded of the PFullMenu.
Definition: PLatexObj.cpp:743

References PFullMenu::getIsExpanded(), PFullMenu::getIsFirstExpanded(), PFullMenu::getIsSeparator(), PFullMenu::getLink(), PFullMenu::getText(), and PFullMenu::getVecSubMenu().

Referenced by platexobj_menuToHtml().

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

◆ 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< 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: