示例#1
0
文件: sbm.php 项目: 64kbytes/stayinba
 function display($sidebar)
 {
     global $k2sbm_registered_modules, $k2sbm_current_module, $k2sbm_module_index;
     static $k2sbm_count_id;
     // Get the base module details
     $base_module = $k2sbm_registered_modules[$this->type];
     // Check that the function exists & that this module is to be displayed
     if (function_exists($base_module['callback'])) {
         if ($this->canDisplay()) {
             $k2sbm_current_module = $this;
             $id = K2SBM::name_to_id($this->name);
             $k2sbm_count_id[$id]++;
             $id = $id . ($k2sbm_count_id[$id] > 1 ? '-' . $k2sbm_count_id[$id] : '');
             if (strstr($id, '%') !== false) {
                 $id = str_replace('%', '-', $id);
             }
             if (preg_match('/[0-9\\-]/', $first_char = $id[0])) {
                 $id = 'module' . ($first_char != '-' ? '-' : '') . $id;
             }
             // Call the display callback
             $params[0] = array('before_module' => sprintf($sidebar->before_module, $id, $this->css_class($k2sbm_module_index++, $base_module['css_class'])), 'after_module' => $sidebar->after_module);
             // Allow the user to hide the title, simplest method is to unset the title elements
             if ($this->output['show_title']) {
                 $params[0]['before_title'] = $sidebar->before_title;
                 $params[0]['title'] = $this->name;
                 $params[0]['after_title'] = $sidebar->after_title;
             } else {
                 $params[0]['before_title'] = '';
                 $params[0]['title'] = '';
                 $params[0]['after_title'] = '';
             }
             $params[0]['before_widget'] = $params[0]['before_module'];
             $params[0]['after_widget'] = $params[0]['after_module'];
             call_user_func_array($base_module['callback'], $params);
             // Update options in any PHP < 5
             if (version_compare(PHP_VERSION, '5.0') < 0) {
                 foreach ($k2sbm_current_module->options as $key => $value) {
                     $this->update_option($key, $value);
                 }
             }
             $k2sbm_current_module = false;
             return true;
         }
     } else {
         // Remove this module - it dosn't exist properly
         K2SBM::remove_module($sidebar->id, $this->id);
     }
     return false;
 }