Advertisement
Faguss

UserSpice 4.4.14 menus.php menu links localization

Jul 1st, 2019
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. <?php
  2. function _assert( $expr, $msg){ if( !$expr ) print "<br/><b>ASSERTION FAIL: </b>{$msg}<br>"; }
  3.  
  4. function prepareMenuTree($menuResults){
  5. /*
  6. Get instance of tree manager and build the tree
  7. */
  8. $treeManager = treeManager::get();
  9. $menuTree = $treeManager->getTree($menuResults, 'id','parent','display_order');
  10. /*
  11. Indent the tree
  12. */
  13. //$menuTree = $treeManager->slapTree($recordsTree, 1 ); //1 for indent count
  14.  
  15. return $menuTree;
  16. }
  17.  
  18. function prepareIndentedMenuTree($menuResults){
  19. /*
  20. Get instance of tree manager and build the tree
  21. */
  22. $treeManager = treeManager::get();
  23. $menuTree = $treeManager->getTree($menuResults, 'id','parent','display_order');
  24. /*
  25. Indent the tree
  26. */
  27. $menuIndentedTree = $treeManager->slapTree($menuTree, 1,'menu_title' ); //1 for indent count
  28.  
  29. return $menuIndentedTree;
  30. }
  31.  
  32. function prepareDropdownString($menuItem,$user_id){
  33. $itemString='';
  34. $itemString.='<li class="dropdown">';
  35. $itemString.='<a href="" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="'.$menuItem['icon_class'].'"></span> '.$menuItem['label'].' <span class="caret"></span></a>';
  36. $itemString.='<ul class="dropdown-menu">';
  37. foreach ($menuItem['children'] as $childItem){
  38. $authorizedGroups = array();
  39. foreach (fetchGroupsByMenu($childItem['id']) as $g) {
  40. $authorizedGroups[] = $g->group_id;
  41. }
  42. if($childItem['logged_in']==0 || (hasPerm($authorizedGroups,$user_id) || in_array(0,$authorizedGroups))) {
  43. $itemString.=prepareItemString($childItem,$user_id); }
  44. }
  45. $itemString.='</ul></li>';
  46. return $itemString;
  47. }
  48.  
  49. function prepareItemString($menuItem,$user_id){
  50. $itemString = '';
  51.  
  52. if ($menuItem['label']=='{{hr}}')
  53. $itemString = "<li class='divider'></li>";
  54. else
  55. if ($menuItem['link']=='users/verify_resend.php' || $menuItem['link']=='usersc/verify_resend.php') {
  56. $db = DB::getInstance();
  57. $query = $db->query("SELECT * FROM email");
  58. $results = $query->first();
  59. $email_act = $results->email_act;
  60.  
  61. if ($email_act == 1)
  62. $itemString.='<li><a href="'.US_URL_ROOT.$menuItem['link'].'"><span class="'.$menuItem['icon_class'].'"></span> '.$menuItem['label'].'</a></li>';
  63. } else
  64. if ($menuItem['link']=='users/join.php' || $menuItem['link']=='usersc/join.php') {
  65. $db = DB::getInstance();
  66. $query = $db->query("SELECT * FROM settings");
  67. $results = $query->first();
  68. $registration = $results->registration;
  69.  
  70. if ($registration == 1)
  71. $itemString .= '<li><a href="'.US_URL_ROOT.$menuItem['link'].'"><span class="'.$menuItem['icon_class'].'"></span> '.$menuItem['label'].'</a></li>';
  72. } else {
  73. if (substr($menuItem['label'],0,2)=="{{" && substr($menuItem['label'],-2,2)=="}}") {
  74. $key = substr($menuItem['label'],2,-2);
  75. if ($key == "username") {
  76. global $user;
  77. $menuItem['label'] = $user->data()->username;
  78. }
  79. else if ($key == "fname") {
  80. global $user;
  81. $menuItem['label'] = $user->data()->fname;
  82. }
  83. else
  84. $menuItem['label'] = lang($key);
  85. }
  86.  
  87. if (substr($menuItem['link'],0,4) == "http")
  88. $itemString.='<li><a href="'.$menuItem['link'].'"><span class="'.$menuItem['icon_class'].'"></span> '.html_entity_decode($menuItem['label']).'</a></li>';
  89. else
  90. $itemString.='<li><a href="'.US_URL_ROOT.$menuItem['link'].'"><span class="'.$menuItem['icon_class'].'"></span> '.html_entity_decode($menuItem['label']).'</a></li>';
  91. }
  92.  
  93. return $itemString;
  94. }
  95. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement