YaWK  24.1
Yet another WebKit
YAWK\WIDGETS\SUBMENU\EMBED\submenu Class Reference

Submenu widget - embed any menu on any page in any position. More...

+ Inheritance diagram for YAWK\WIDGETS\SUBMENU\EMBED\submenu:

Public Member Functions

 __construct ($db)
 Load all widget settings from database and fill object. More...
 
 displaySubMenu ($db, $menuID)
 display any subMenu (used by widgets to get any menu in any position) More...
 
 drawMenu ($db)
 
 drawSidebarEnd ()
 draw sidebar end More...
 
 drawSidebarStart ()
 draw sidebar start More...
 
 init ($db)
 Init submenu widget and call a function for demo purpose. More...
 
- Public Member Functions inherited from YAWK\widget
 getHeading ($heading, $subtext)
 Get widget heading and subtext, return headline. More...
 
 getWidgetSettingsArray ($db)
 Get widget settings and return it as array. More...
 
 printObject ()
 Print all object data. More...
 

Public Attributes

string int $menuID = ''
 
bool $showMenuName = false
 
string $sidebar = 'false'
 
string $subMenuClass
 
string $submenuHeading = ''
 
string $subMenuItemClass
 
string $submenuSubtext = ''
 
 $widget = ''
 
- Public Attributes inherited from YAWK\widget
 $data
 
 $date_publish
 
 $date_unpublish
 
 $folder
 
 $id
 
 $marginBottom
 
 $marginTop
 
 $name
 
 $pageID
 
 $position
 
 $published
 
 $sort
 
 $widgetTitle
 
 $widgetType
 

Additional Inherited Members

- Static Public Member Functions inherited from YAWK\widget
static getAllSettingsIntoArray ($db, $widgetID)
 Returns an array with all widget settings data. More...
 
static getAllWidgetTypes ($db)
 Return all widget types as associative array. More...
 
static getCurrentWidgetPath ($db)
 return current widget path More...
 
static getFacebookLikeBox ()
 return the facebook likebox widget More...
 
static getLoginBox ()
 return the user login box widget More...
 
static loadWidgetsOfPage ($db, $page)
 Returns an array of all widgets that are linked with given page->id. More...
 

Detailed Description

Submenu widget - embed any menu on any page in any position.

Empty submenu Widget - for development and demo purpose

If you want to embed any menu on any page in any position, this should be the widget of your choice! It can handle every menu that you have created before within YaWK's menu system.

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Version
1.0.0

Definition at line 19 of file submenu.php.

Constructor & Destructor Documentation

◆ __construct()

YAWK\WIDGETS\SUBMENU\EMBED\submenu::__construct (   $db)

Load all widget settings from database and fill object.

Parameters
object$dbDatabase Object

Load all widget settings on object init.

Definition at line 43 of file submenu.php.

45  {
46  // load this widget settings from db
47  $this->widget = new widget();
48  $settings = $this->widget->getWidgetSettingsArray($db);
49  foreach ($settings as $property => $value) {
50  $this->$property = $value;
51  }
52 
53  // set sidebar property
54  if (isset($this->widget->data['sidebar'])){
55  $this->sidebar = $this->widget->data['sidebar'];
56  }
57  else {
58  $this->sidebar = 'false';
59  }
60 
61  // check if sidebar is set
62  if ($this->sidebar === 'true')
63  { // include sidebar js
64  echo '<script src="system/widgets/submenu/sidebar.js" type="text/javascript"></script>';
65  // include sidebar css
66  echo '<link rel="stylesheet" href="system/widgets/submenu/sidebar.css">';
67  }
68 
69  // check if menu obj is set
70  if (!isset($menu))
71  {
72  require_once 'system/classes/menu.php';
73  $menu = new \YAWK\menu();
74  }
if(isset($_POST['save'])) $settings
$value

References $db, $settings, $value, and YAWK\widget\getWidgetSettingsArray().

Member Function Documentation

◆ displaySubMenu()

YAWK\WIDGETS\SUBMENU\EMBED\submenu::displaySubMenu (   $db,
  $menuID 
)

display any subMenu (used by widgets to get any menu in any position)

Version
1.0.0
Parameters
object$dbdatabase
int$menuIDthe menuID to get data
Parameters
db$db

Definition at line 122 of file submenu.php.

124  { /** @param db $db */
125 
126  // check if menu name should be displayed
127  if ($this->showMenuName)
128  { // get menu name from db
129  $menuName = "<li class=\"list-group-item\"><b>".\YAWK\menu::getMenuNameByID($db, $menuID)."</b><li>";
130  }
131  else
132  { // don't show menu name
133  $menuName = '';
134  }
135 
136  // get menu entries and draw navbar
137  $res = $db->query("SELECT * FROM {menu}
138  WHERE published = 1
139  AND menuID = '".$menuID."'
140  ORDER by sort, title");
141 
142  $subMenuItem = '';
143  $subMenuClass = '';
144  $subMenuItemClass = '';
145  while ($row = mysqli_fetch_assoc($res))
146  {
147  // check if target is set
148  if (!empty($row['target']))
149  { // target is set
150  $row['target'] = ' target="'.$row['target'].'"';
151  }
152  else
153  { // target is not set
154  $row['target'] = '';
155  }
156 
157  // check if subMenu class is set
158  if (!empty($this->subMenuClass)){
159  $subMenuClass = ' class="'.$this->subMenuClass.'"';
160  }
161  else
162  { // subMenuClass is not set
163  $subMenuClass = '';
164  }
165 
166  // check if subMenuItem class is set
167  if (!empty($this->subMenuItemClass)){
168  $submenuItemClass = ' class="'.$this->subMenuItemClass.'"';
169  }
170  else
171  { // subMenuItemClass is not set
172  $subMenuItemClass = '';
173  }
174 
175  // check if icon is set
176  if (isset($row['icon']))
177  { // set icon markup
178  $icon = '<i class="'.$row["icon"].' text-muted"></i>';
179  }
180  else
181  { // no icon set
182  $icon = "";
183  }
184 
185  // add menu item to menu
186  $subMenuItem .= '<li class="list-group-item hvr-grow"><small>'.$icon.'&nbsp;&nbsp;<a href="'.$row['href'].'"'.$subMenuItemClass.$row['target'].'>'.$row['text'].'</a></small></li>';
187  }
188 
189  // if sidebar is set, start sidebar markup
190  if ($this->sidebar === 'true') { // include sidebar js
191  echo '<button class="openbtn" id="openSubmenuBtn">☰</button>';
192  // wrap menu in sidebar (start)
193  $this->drawSidebarStart();
194  }
195 
196  // draw subMenu
197  echo '<div id="subMenu"'.$subMenuClass.'>
198  <ul class="list-group" style="cursor:pointer;">'.$menuName.' ';
199  echo ' '.$subMenuItem.'</ul>
200  </div>';
201 
202  // if sidebar is set, close sidebar
203  if ($this->sidebar === 'true')
204  { // wrap menu in sidebar (end)
205  $this->drawSidebarEnd();
206  }
drawSidebarEnd()
draw sidebar end
Definition: submenu.php:104
drawSidebarStart()
draw sidebar start
Definition: submenu.php:93
if(!isset($page)) if(!isset($db)) if(!isset($lang)) if(isset($_GET['toggleItem'])) if(isset($_GET['del']) &&($_GET['del']==="1")) if(isset($_POST['changetitle'])) if(isset($_POST['changeLanguage'])) if(isset($_POST['add'])) else if(isset($_POST['save'])) else $menuName
Definition: menu-edit.php:217

References $db, YAWK\WIDGETS\SUBMENU\EMBED\submenu\$menuID, $menuName, $res, YAWK\WIDGETS\SUBMENU\EMBED\submenu\$subMenuClass, YAWK\WIDGETS\SUBMENU\EMBED\submenu\$subMenuItemClass, YAWK\WIDGETS\SUBMENU\EMBED\submenu\drawSidebarEnd(), and YAWK\WIDGETS\SUBMENU\EMBED\submenu\drawSidebarStart().

Referenced by YAWK\WIDGETS\SUBMENU\EMBED\submenu\drawMenu().

◆ drawMenu()

YAWK\WIDGETS\SUBMENU\EMBED\submenu::drawMenu (   $db)

Definition at line 109 of file submenu.php.

111  {
112  $this->displaySubMenu($db, $this->menuID);
displaySubMenu($db, $menuID)
display any subMenu (used by widgets to get any menu in any position)
Definition: submenu.php:122

References $db, and YAWK\WIDGETS\SUBMENU\EMBED\submenu\displaySubMenu().

Referenced by YAWK\WIDGETS\SUBMENU\EMBED\submenu\init().

◆ drawSidebarEnd()

YAWK\WIDGETS\SUBMENU\EMBED\submenu::drawSidebarEnd ( )

draw sidebar end

If $this->sidebar is set to true, this function will be called after menu entry and closes the wrapping menu sidebar div.

Returns
void

Definition at line 104 of file submenu.php.

105  : void
106  {
107  echo '</div>';

Referenced by YAWK\WIDGETS\SUBMENU\EMBED\submenu\displaySubMenu().

◆ drawSidebarStart()

YAWK\WIDGETS\SUBMENU\EMBED\submenu::drawSidebarStart ( )

draw sidebar start

If $this->sidebar is set to true, this function will be called before menu entry and wrap the menu in a sidebar div.

Returns
void

Definition at line 93 of file submenu.php.

94  : void
95  {
96  echo '<div id="mySidebar" class="sidebar shadow"><a href="javascript:void(0)" class="btn btn-default" onclick="closeNav()">x</a>';

Referenced by YAWK\WIDGETS\SUBMENU\EMBED\submenu\displaySubMenu().

◆ init()

YAWK\WIDGETS\SUBMENU\EMBED\submenu::init (   $db)

Init submenu widget and call a function for demo purpose.

submenu Widget Init

Definition at line 80 of file submenu.php.

82  {
83  // draw headline
84  echo $this->getHeading($this->submenuHeading, $this->submenuSubtext);
85  $this->drawMenu($db);
getHeading($heading, $subtext)
Get widget heading and subtext, return headline.
Definition: widget.php:669

References $db, YAWK\WIDGETS\SUBMENU\EMBED\submenu\drawMenu(), and YAWK\widget\getHeading().

Member Data Documentation

◆ $menuID

string int YAWK\WIDGETS\SUBMENU\EMBED\submenu::$menuID = ''

Definition at line 28 of file submenu.php.

Referenced by YAWK\WIDGETS\SUBMENU\EMBED\submenu\displaySubMenu().

◆ $showMenuName

bool YAWK\WIDGETS\SUBMENU\EMBED\submenu::$showMenuName = false

Definition at line 36 of file submenu.php.

◆ $sidebar

string YAWK\WIDGETS\SUBMENU\EMBED\submenu::$sidebar = 'false'

Definition at line 34 of file submenu.php.

◆ $subMenuClass

string YAWK\WIDGETS\SUBMENU\EMBED\submenu::$subMenuClass

Definition at line 30 of file submenu.php.

Referenced by YAWK\WIDGETS\SUBMENU\EMBED\submenu\displaySubMenu().

◆ $submenuHeading

string YAWK\WIDGETS\SUBMENU\EMBED\submenu::$submenuHeading = ''

Definition at line 24 of file submenu.php.

◆ $subMenuItemClass

string YAWK\WIDGETS\SUBMENU\EMBED\submenu::$subMenuItemClass

Definition at line 32 of file submenu.php.

Referenced by YAWK\WIDGETS\SUBMENU\EMBED\submenu\displaySubMenu().

◆ $submenuSubtext

string YAWK\WIDGETS\SUBMENU\EMBED\submenu::$submenuSubtext = ''

Definition at line 26 of file submenu.php.

◆ $widget

YAWK\WIDGETS\SUBMENU\EMBED\submenu::$widget = ''

Definition at line 22 of file submenu.php.


The documentation for this class was generated from the following file: