[ Index ]

PHP Cross Reference of Nuke-Evolution v2.0.5

title

Body

[close]

/blocks/ -> block-Modules.php (source)

   1  <?php
   2  /*=======================================================================
   3   Nuke-Evolution Basic: Enhanced PHP-Nuke Web Portal System
   4   =======================================================================*/
   5  
   6  /************************************************************************/
   7  /* PHP-NUKE: Web Portal System                                          */
   8  /* ===========================                                          */
   9  /*                                                                      */
  10  /* Copyright (c) 2002 by Francisco Burzi                                */
  11  /* http://phpnuke.org                                                   */
  12  /*                                                                      */
  13  /* This program is free software. You can redistribute it and/or modify */
  14  /* it under the terms of the GNU General Public License as published by */
  15  /* the Free Software Foundation; either version 2 of the License.       */
  16  /************************************************************************/
  17  
  18  /*****[CHANGES]**********************************************************
  19  -=[Base]=-
  20        Nuke Patched                             v3.1.0       06/26/2005
  21   ************************************************************************/
  22  
  23  if(!defined('NUKE_EVO')) exit;
  24  
  25  function moduleblock_get_active() {
  26      global $db, $prefix, $cache;
  27  
  28      $out = array();
  29      if(!($result = $db->sql_query("SELECT * FROM `".$prefix."_modules` WHERE `active`='1' AND `inmenu`='1' AND `cat_id`<>0 ORDER BY `cat_id`, `pos` ASC"))) {
  30          return '';
  31      }
  32      while ($row = $db->sql_fetchrow($result)) {
  33          $out[$row['cat_id']][] = $row;
  34      }
  35      $db->sql_freeresult($result);
  36      return $out;
  37  }
  38  
  39  function moduleblock_get_cats() {
  40      global $db, $prefix, $cache;
  41      static $cats;
  42      $use = (isset($_POST['save']) || (isset($_GET['area']) && $_GET['area'] == 'block')) ? 0 : 1;
  43      if (isset($cats) && is_array($cats) && $use) return $cats;
  44  
  45      if((($cats = $cache->load('module_cats', 'config')) === false) || !isset($cats) || !$use) {
  46          $cats = array();
  47          if(!($result = $db->sql_query("SELECT * FROM `".$prefix."_modules_cat` ORDER BY `pos` ASC"))) {
  48              return '';
  49          }
  50          while ($row = $db->sql_fetchrow($result)) {
  51              $cats[] = $row;
  52          }
  53          $db->sql_freeresult($result);
  54          $cache->save('module_cats', 'config', $cats);
  55      }
  56  
  57      return $cats;
  58  }
  59  
  60  function moduleblock_image($name) {
  61      global $Default_Theme;
  62  
  63      if(empty($name)) return '';
  64  
  65      if (substr($name,0,strlen('http://')) == 'http://') return $name;
  66  
  67      if(file_exists(NUKE_IMAGES_DIR.'blocks/modules/'.$name)) {
  68          return 'images/blocks/modules/'.$name;
  69      }
  70      if(!empty($Default_Theme)) {
  71          if(file_exists(NUKE_THEMES_DIR.$Default_Theme.'/images/'.$name)) {
  72              return 'themes/'.$Default_Theme.'/images/'.$name;
  73          }
  74      }
  75  
  76      return '';
  77  }
  78  
  79  function moduleblock_display() {
  80      global $moduleblock_active, $moduleblock_cats, $content, $plus_minus_images, $module_collapse, $userinfo;
  81  
  82      if(!is_array($moduleblock_active) || !is_array($moduleblock_cats)) return;
  83  
  84      $c_image = ($module_collapse) ? "&nbsp;&nbsp;<img src=\"".$plus_minus_images['minus']."\" class=\"showstate\" name=\"minus\" width=\"9\" height=\"9\" border=\"0\" onclick=\"expandcontent(this, 'moduleblock0')\" alt=\"\" style=\"cursor: pointer;\" />" : '';
  85      //Home
  86      $content .= "<img src=\"images/blocks/modules/icon_home.gif\" alt=\""._HOME."\"><span style=\"font-weight: bold;\">"._HOME."</span>".$c_image."<br />\n";
  87      $content .= ($module_collapse) ? "<div id=\"moduleblock0\" class=\"switchcontent\">\n" : '';
  88      $content .= "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"index.php\">"._HOME."</a>\n";
  89      $content .= ($module_collapse) ? "</div>\n" : '<br />';
  90  
  91      foreach ($moduleblock_cats as $cat) {
  92          if(isset($cat['cid']) && is_integer(intval($cat['cid']))) {
  93              if (!isset($moduleblock_active[intval($cat['cid'])])) continue;
  94              $mod_array = $moduleblock_active[intval($cat['cid'])];
  95              if(is_array($mod_array)) {
  96                  $img = moduleblock_image($cat['image']);
  97                  $img = (!empty($img)) ? "<img src=\"".$img."\" alt=\"\">" : '';
  98                  $c_image = ($module_collapse) ? "&nbsp;&nbsp;<img src=\"".$plus_minus_images['minus']."\" class=\"showstate\" name=\"minus\" width=\"9\" height=\"9\" border=\"0\" onclick=\"expandcontent(this, 'moduleblock".$cat['cid']."')\" alt=\"\" style=\"cursor: pointer;\" />" : '';
  99                  $content .= $img."<span style=\"font-weight: bold;\">".$cat['name']."</span>".$c_image."<br />\n";
 100                  $content .= ($module_collapse) ? "<div id=\"moduleblock".$cat['cid']."\" class=\"switchcontent\">\n" : '';
 101                  foreach ($mod_array as $module) {
 102                      if ($module['view'] >= 2 && !is_mod_admin($module['name'])) {
 103                          if ($module['view'] == 2 && is_user()) {
 104                              continue;
 105                          } elseif ($module['view'] == 3 && !is_user()) {
 106                              continue;
 107                          } elseif ($module['view'] == 4) {
 108                              continue;
 109                          } elseif ($module['view'] == 6) {
 110                              $groups = (!empty($module['groups'])) ? $groups = explode('-', $module['groups']) : '';
 111                              $ingroup = false;
 112                              if(is_array($groups)){
 113                                  foreach ($groups as $group) {
 114                                       if (isset($userinfo['groups'][$group])) {
 115                                           $ingroup = true;
 116                                       }
 117                                  }
 118                                  if (!$ingroup) continue;
 119                              }
 120                          }
 121                      }
 122                      if(substr($module['title'],0,3) == '~l~') {
 123                          $content .= "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"".$module['custom_title']."\">".substr($module['title'],3)."</a><br />\n";
 124                      } else {
 125                          $content .= "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"modules.php?name=".$module['title']."\">".$module['custom_title']."</a><br />\n";
 126                      }
 127                  }
 128                  $content .= ($module_collapse) ? "</div>\n" : "";
 129              }
 130          }
 131      }
 132  }
 133  
 134  function moduleblock_get_inactive() {
 135      global $db, $prefix, $cache;
 136  
 137      if(!($result = $db->sql_query("SELECT * FROM `".$prefix."_modules` WHERE (`active`='0' OR `inmenu`='0' OR `cat_id`='0') AND `title` NOT LIKE '~l~%' ORDER BY `custom_title` ASC"))) {
 138          return '';
 139      }
 140      while ($row = $db->sql_fetchrow($result)) {
 141          $out[] = $row;
 142      }
 143      $db->sql_freeresult($result);
 144      return $out;
 145  }
 146  
 147  function moduleblock_get_inactive_links() {
 148      global $db, $prefix, $cache;
 149      static $links;
 150      $use = (isset($_POST['save']) || (isset($_GET['area']) && $_GET['area'] == 'block')) ? 0 : 1;
 151      if (isset($links) && is_array($links) && $use) return $links;
 152  
 153      if ((($links = $cache->load('module_links', 'config')) === false) || !isset($links) || !$use) {
 154          $links = '';
 155          if(!($result = $db->sql_query("SELECT * FROM `".$prefix."_modules` WHERE (`active`=0 OR `cat_id`='0') AND `title` LIKE '~l~%' ORDER BY `title` ASC"))) {
 156              return '';
 157          }
 158          while ($row = $db->sql_fetchrow($result)) {
 159              $links[] = $row;
 160          }
 161          $db->sql_freeresult($result);
 162          if(!empty($links) && is_array($links)) {
 163              $cache->save('module_links', 'config', $links);
 164          } else {
 165              $cache->delete('module_links', 'config');
 166          }
 167      }
 168      return $links;
 169  }
 170  
 171  function moduleblock_display_inactive() {
 172      global $moduleblock_invisible, $moduleblock_invisible_links, $content;
 173  
 174      $content .= "<hr />\n";
 175      $content .= "<div align=\"center\">\n";
 176  
 177      $content .= "<select name=\"name\" onchange=\"top.location.href=this.options[this.selectedIndex].value\">\n";
 178      $content .= "<option value=''>"._MORE."</option>\n";
 179      $content .= "<optgroup label=\""._INVISIBLEMODULES."\">\n";
 180      if(is_array($moduleblock_invisible)) {
 181          foreach ($moduleblock_invisible as $module) {
 182              if ($module['active']) {
 183                  $one = 1;
 184                  $content .= "<option value=\"modules.php?name=".$module['title']."\">".$module['custom_title']."</option>\n";
 185              } else {
 186                  $moduleblock_inactive[] = $module;
 187              }
 188          }
 189          if(!$one) $content .= "<option value=''>"._NONE."</option>\n";
 190      } else {
 191          $content .= "<option value=''>"._NONE."</option>\n";
 192      }
 193      $content .= "</optgroup>\n";
 194  
 195      $content .= "<optgroup label=\""._NOACTIVEMODULES."\">\n";
 196      if(is_array($moduleblock_inactive)) {
 197          foreach ($moduleblock_inactive as $module) {
 198              $content .= "<option value=\"modules.php?name=".$module['title']."\">".$module['custom_title']."</option>\n";
 199          }
 200      } else {
 201          $content .= "<option value=''>"._NONE."</option>\n";
 202      }
 203      $content .= "</optgroup>\n";
 204  
 205      $content .= "<optgroup label=\""._INACTIVE_LINKS."\">\n";
 206      if(is_array($moduleblock_invisible_links)) {
 207          foreach ($moduleblock_invisible_links as $link) {
 208              $content .= "<option value=\"".$link['custom_title']."\" target=\"_blank\">".substr($link['title'],3)."</option>\n";
 209          }
 210      } else {
 211          $content .= "<option value=''>"._NONE."</option>\n";
 212      }
 213      $content .= "</optgroup>\n";
 214      $content .= "</select>\n";
 215      $content .= "</div>\n";
 216  }
 217  
 218  global $prefix, $db, $language, $currentlang, $nukeurl, $content, $moduleblock_active, $moduleblock_cats;
 219  
 220  $content = '';
 221  $main_module = main_module();
 222  
 223  $moduleblock_active = moduleblock_get_active();
 224  $moduleblock_cats = moduleblock_get_cats();
 225  moduleblock_display();
 226  
 227  if(is_admin()) {
 228      global $moduleblock_invisible, $moduleblock_invisible_links;
 229      $moduleblock_invisible = moduleblock_get_inactive();
 230      $moduleblock_invisible_links = moduleblock_get_inactive_links();
 231      moduleblock_display_inactive();
 232  }
 233  
 234  ?>


Generated: Wed Jun 6 11:38:01 2007 Cross-referenced by PHPXref 0.7