예제 #1
0
 public static function get_installed_applets_html()
 {
     $colors = Base_DashboardCommon::get_available_colors();
     $app_cap = ModuleManager::call_common_methods('applet_caption');
     asort($app_cap);
     $app_info = ModuleManager::call_common_methods('applet_info');
     $html = '';
     foreach ($app_cap as $name => $cap) {
         if (!$cap) {
             continue;
         }
         $th = Base_ThemeCommon::init_smarty();
         $id = str_replace('_', '-', $name);
         if (!isset($app_info[$name])) {
             $app_info[$name] = '';
         }
         $th->assign('content', '<div class="content" style="padding:4px;" id="dashboard_applet_content_' . $id . '">' . $app_info[$name] . '</div>');
         $th->assign('handle_class', 'handle');
         $th->assign('caption', $cap);
         $th->assign('color', $colors[0]['class']);
         $remove_button = Base_DashboardCommon::get_remove_applet_button($id, false);
         $th->assign('remove', $remove_button);
         $th->assign('__link', array('remove' => Base_ThemeCommon::parse_links('remove', $remove_button)));
         //print('<xmp>'.self::get_remove_applet_button(null, false).'</xmp><br>');
         $th->assign('actions', array());
         $th->assign('config_mode', true);
         $html .= '<div class="applet" searchkey="' . strtolower($cap ? $cap : $name) . ';' . strtolower($app_info[$name]) . '" id="ab_item_' . 'new_' . $id . '">';
         ob_start();
         Base_ThemeCommon::display_smarty($th, 'Base_Dashboard', 'default');
         $html .= ob_get_clean();
         $html .= '</div>';
     }
     return $html;
 }
예제 #2
0
 public function display_dashboard($tab_id)
 {
     //		Base_ActionBarCommon::add('add',__('Add applet'),$this->create_callback_href(array($this,'applets_list'),$tab_id));
     $default_dash = $this->get_module_variable('default');
     $colors = Base_DashboardCommon::get_available_colors();
     $applets = array(0 => array(), 1 => array(), 2 => array());
     $config_mode = $this->get_module_variable('config_mode', false);
     if ($default_dash || !Base_DashboardCommon::has_permission_to_manage_applets()) {
         $ret = DB::Execute('SELECT col,id,module_name,color FROM base_dashboard_default_applets WHERE tab=%d ORDER BY col,pos', array($tab_id));
     } else {
         $ret = DB::Execute('SELECT col,id,module_name,color FROM base_dashboard_applets WHERE user_login_id=%d AND tab=%d ORDER BY pos', array(Base_AclCommon::get_user(), $tab_id));
     }
     while ($row = $ret->FetchRow()) {
         $applets[$row['col']][] = $row;
     }
     print '<div id="dashboard" style="width: 100%;">';
     for ($j = 0; $j < 3; $j++) {
         print '<div id="dashboard_applets_' . $tab_id . '_' . $j . '" style="width:33%;min-height:200px;padding-bottom:10px;vertical-align:top;display:inline-block">';
         foreach ($applets[$j] as $row) {
             if (!is_callable(array($row['module_name'] . 'Common', 'applet_caption'))) {
                 continue;
             }
             $cap = call_user_func(array($row['module_name'] . 'Common', 'applet_caption'));
             if (!$cap || ModuleManager::is_installed($row['module_name']) == -1) {
                 //if its invalid entry
                 continue;
             }
             $m = $this->init_module($row['module_name'], null, $row['id']);
             $opts = array();
             $opts['title'] = $cap;
             $opts['toggle'] = true;
             $opts['href'] = null;
             $opts['go'] = false;
             $opts['go_function'] = 'body';
             $opts['go_arguments'] = array();
             $opts['go_constructor_arguments'] = array();
             $opts['actions'] = array();
             $opts['id'] = $row['id'];
             $th = $this->init_module(Base_Theme::module_name());
             if ($config_mode || !$m) {
                 $content = '';
             } else {
                 $content = $this->get_html_of_module($m, array($this->get_values($row['id'], $row['module_name']), &$opts, $row['id']), 'applet');
             }
             $th->assign('content', '<div class="content">' . $content . '</div>');
             $th->assign('handle_class', 'handle');
             $th->assign('fixed', !($default_dash || Base_DashboardCommon::has_permission_to_manage_applets()));
             if ($opts['toggle'] && !$config_mode) {
                 $th->assign('toggle', '<a class="toggle" ' . Utils_TooltipCommon::open_tag_attrs(__('Toggle')) . '>=</a>');
             }
             foreach ($opts['actions'] as $k => $v) {
                 if (!$v) {
                     unset($opts['actions'][$k]);
                 }
             }
             if ($opts['go']) {
                 $opts['href'] = $this->create_main_href($row['module_name'], $opts['go_function'], $opts['go_arguments'], $opts['go_constructor_arguments']);
             }
             if ($opts['href']) {
                 $th->assign('href', '<a class="href" ' . Utils_TooltipCommon::open_tag_attrs(__('Fullscreen')) . ' ' . $opts['href'] . '>G</a>');
             }
             if ($default_dash || Base_DashboardCommon::has_permission_to_manage_applets()) {
                 $th->assign('remove', Base_DashboardCommon::get_remove_applet_button($row['id'], $default_dash));
                 if (!$config_mode) {
                     $th->assign('configure', '<a class="configure" ' . Utils_TooltipCommon::open_tag_attrs(__('Configure')) . ' ' . $this->create_callback_href(array($this, 'configure_applet'), array($row['id'], $row['module_name'])) . '>c</a>');
                 }
             }
             $th->assign('caption', $opts['title']);
             $th->assign('color', $colors[$row['color']]['class']);
             $th->assign('actions', $opts['actions']);
             $th->assign('config_mode', $config_mode);
             print '<div class="applet" id="ab_item_' . $row['id'] . '">';
             $th->display();
             print '</div>';
         }
         print '</div>';
     }
     print '</div>';
 }