Example #1
0
 /**
  * Displays action bar.
  */
 public function body()
 {
     $this->help('ActionBar basics', 'main');
     $icons = Base_ActionBarCommon::get();
     //sort
     usort($icons, array($this, 'compare'));
     //translate
     foreach ($icons as &$i) {
         $description = $i['description'];
         if ($i['description']) {
             $t = Utils_TooltipCommon::open_tag_attrs($description);
         } else {
             $t = '';
         }
         $i['open'] = '<a ' . $i['action'] . ' ' . $t . '>';
         $i['close'] = '</a>';
         $i['helpID'] = 'ActionBar_' . $i['icon'];
         if (strpos($i['icon'], '/') !== false && file_exists($i['icon'])) {
             $i['icon_url'] = $i['icon'];
             unset($i['icon']);
         }
         //if (isset(Base_ActionBarCommon::$available_icons[$i['icon']]))
         //	$i['icon'] = Base_ThemeCommon::get_template_file('Base_ActionBar','icons/'.$i['icon'].'.png');
     }
     $launcher = array();
     if (Base_AclCommon::is_user()) {
         $opts = Base_Menu_QuickAccessCommon::get_options();
         if (!empty($opts)) {
             self::$launchpad = array();
             foreach ($opts as $k => $v) {
                 if (Base_ActionBarCommon::$quick_access_shortcuts && Base_User_SettingsCommon::get(Base_Menu_QuickAccessCommon::module_name(), $v['name'] . '_d')) {
                     $ii = array();
                     $trimmed_label = trim(substr(strrchr($v['label'], ':'), 1));
                     $ii['label'] = $trimmed_label ? $trimmed_label : $v['label'];
                     $ii['description'] = $v['label'];
                     $arr = $v['link'];
                     if (isset($arr['__url__'])) {
                         $ii['open'] = '<a href="' . $arr['__url__'] . '" target="_blank">';
                     } else {
                         $ii['open'] = '<a ' . Base_MenuCommon::create_href($this, $arr) . '>';
                     }
                     $ii['close'] = '</a>';
                     if (isset($v['link']['__icon__'])) {
                         $icon = Base_ThemeCommon::get_template_file($v['module'], $v['link']['__icon__']);
                     } else {
                         $icon = Base_ThemeCommon::get_template_file($v['module'], 'icon.png');
                     }
                     if (!$icon) {
                         $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'default_icon.png');
                     }
                     $ii['icon'] = $icon;
                     $launcher[] = $ii;
                 }
                 if (Base_User_SettingsCommon::get(Base_Menu_QuickAccessCommon::module_name(), $v['name'] . '_l')) {
                     $ii = array();
                     $trimmed_label = trim(substr(strrchr($v['label'], ':'), 1));
                     $ii['label'] = $trimmed_label ? $trimmed_label : $v['label'];
                     $ii['description'] = $v['label'];
                     $arr = $v['link'];
                     if (isset($arr['__url__'])) {
                         $ii['open'] = '<a href="' . $arr['__url__'] . '" target="_blank" onClick="actionbar_launchpad_deactivate()">';
                     } else {
                         $ii['open'] = '<a onClick="actionbar_launchpad_deactivate();' . Base_MenuCommon::create_href_js($this, $arr) . '" href="javascript:void(0)">';
                     }
                     $ii['close'] = '</a>';
                     if (isset($v['link']['__icon__'])) {
                         $icon = Base_ThemeCommon::get_template_file($v['module'], $v['link']['__icon__']);
                     } else {
                         $icon = Base_ThemeCommon::get_template_file($v['module'], 'icon.png');
                     }
                     if (!$icon) {
                         $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'default_icon.png');
                     }
                     $ii['icon'] = $icon;
                     self::$launchpad[] = $ii;
                 }
             }
         }
     }
     //display
     $th = $this->pack_module(Base_Theme::module_name());
     $th->assign('icons', $icons);
     $th->assign('launcher', array_reverse($launcher));
     $th->display();
 }
Example #2
0
 private function build_menu(&$menu, &$m, $prefix = '')
 {
     foreach ($m as $k => $arr) {
         if ($k == '__split__') {
             $menu->add_split();
         } else {
             $icon = null;
             if (array_key_exists('__icon_small__', $arr)) {
                 $icon = Base_ThemeCommon::get_template_file($arr['parent_module'], $arr['__icon_small__']);
                 unset($arr['__icon_small__']);
                 unset($arr['__icon__']);
             } else {
                 if (array_key_exists('__icon__', $arr)) {
                     $icon = Base_ThemeCommon::get_template_file($arr['parent_module'], $arr['__icon__']);
                     unset($arr['__icon__']);
                 } else {
                     if (isset($arr['parent_module']) && is_string($arr['parent_module'])) {
                         $icon = Base_ThemeCommon::get_template_file($arr['parent_module'], 'icon-small.png');
                     }
                 }
             }
             if (!$icon) {
                 if (array_key_exists('__submenu__', $arr)) {
                     $icon = Base_ThemeCommon::get_template_file('Base_Menu', 'folder.png');
                 } else {
                     $icon = Base_ThemeCommon::get_template_file('Base_Menu', 'element.png');
                 }
             }
             unset($arr['parent_module']);
             if (array_key_exists('__description__', $arr)) {
                 $description = "'" . $arr['__description__'] . "'";
                 unset($arr['__description__']);
             } else {
                 $description = 'null';
             }
             if (array_key_exists('__url__', $arr)) {
                 $url = $arr['__url__'];
                 unset($arr['__url__']);
                 if (array_key_exists('__target__', $arr)) {
                     $target = $arr['__target__'];
                     unset($arr['__target__']);
                 } else {
                     $target = '_blank';
                 }
             } else {
                 $url = null;
             }
             $label = _V($k);
             // ****** Menu - translate labels
             if (array_key_exists('__submenu__', $arr)) {
                 unset($arr['__submenu__']);
                 $menu->begin_submenu($label, $icon, $prefix . $k);
                 $this->build_menu($menu, $arr, $prefix . $k . '_');
                 $menu->end_submenu();
             } else {
                 if ($url) {
                     $menu->add_link($label, $url, $icon, $target, $prefix . $k);
                 } else {
                     $menu->add_link($label, 'javascript:' . Base_MenuCommon::create_href_js($this, $arr), $icon, '', $prefix . $k);
                 }
             }
         }
     }
 }