Changeset 11104

Show
Ignore:
Timestamp:
07/06/07 14:34:36 (2 years ago)
Author:
sirping
Message:

Barebone version of the new help menu

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.core/constants.php

    r4682 r11104  
    226226 
    227227/** 
     228 * Identifier for a help toolbar for a request context. 
     229 * 
     230 * @see midcom_services_toolbars 
     231 */ 
     232define ('MIDCOM_TOOLBAR_HELP', 105); 
     233 
     234/** 
    228235 * Identifier for a custom objcet toolbar. 
    229236 * 
  • trunk/midcom/midcom.core/midcom/config/midcom_config.php

    r5614 r11104  
    422422$GLOBALS['midcom_config_default']['toolbars_view_style_class'] = 'midcom_toolbar view_toolbar'; 
    423423$GLOBALS['midcom_config_default']['toolbars_view_style_id'] = null; 
     424$GLOBALS['midcom_config_default']['toolbars_help_style_class'] = 'midcom_toolbar help_toolbar'; 
     425$GLOBALS['midcom_config_default']['toolbars_help_style_id'] = null; 
    424426$GLOBALS['midcom_config_default']['toolbars_object_style_class'] = 'midcom_toolbar object_toolbar'; 
    425427$GLOBALS['midcom_config_default']['toolbars_css_path'] = MIDCOM_STATIC_URL . "/Javascript_protoToolkit/styles/protoToolbar.css"; 
  • trunk/midcom/midcom.core/midcom/services/toolbars.php

    r6179 r11104  
    212212                $GLOBALS['midcom_config']['toolbars_host_style_id'] 
    213213            ); 
     214        $this->_toolbars[$context_id][MIDCOM_TOOLBAR_HELP] = 
     215            new midcom_helper_toolbar 
     216            ( 
     217                $GLOBALS['midcom_config']['toolbars_help_style_class'], 
     218                $GLOBALS['midcom_config']['toolbars_help_style_id'] 
     219            ); 
    214220        $this->add_topic_management_commands($this->_toolbars[$context_id][MIDCOM_TOOLBAR_NODE], $context_id); 
    215221        $this->add_host_management_commands($this->_toolbars[$context_id][MIDCOM_TOOLBAR_HOST], $context_id); 
     222        $this->add_help_management_commands($this->_toolbars[$context_id][MIDCOM_TOOLBAR_HELP], $context_id); 
    216223    } 
    217224 
     
    558565         
    559566         
     567    } 
     568 
     569 
     570 
     571    /** 
     572     * Adds the Help management commands to the specified toolbar. 
     573     * 
     574     * Repeated calls to the same toolbar are intercepted accordingly. 
     575     * 
     576     * @todo This is an intermediate implementation to link to the current proof-of-concept 
     577     *     Folder management code. This needs adaption to Aegir2! 
     578     * @todo Better privilege checks 
     579     * @todo Localize 
     580     * 
     581     * @param midcom_helper_toolbar $toolbar A reference to the toolbar to use. 
     582     * @param int $context_id The context to use (the topic is drawn from there). This defaults 
     583     *     to the currently active context. 
     584     */ 
     585    function add_help_management_commands(&$toolbar, $context_id = null) 
     586    { 
     587        if (array_key_exists('midcom_service_toolbars_bound_to_help', $toolbar->customdata)) 
     588        { 
     589            // We already processed this toolbar, skipping further adds. 
     590            return; 
     591        } 
     592        else 
     593        { 
     594            $toolbar->customdata['midcom_service_toolbars_bound_to_help'] = true; 
     595        } 
     596 
     597        $calling_componentname = $_MIDCOM->get_context_data($context_id, MIDCOM_CONTEXT_COMPONENT); 
     598        $has_documentation_file = true;  
     599        if ($has_documentation_file) 
     600        { 
     601            $toolbar->add_item 
     602            ( 
     603                 array 
     604                 ( 
     605                     MIDCOM_TOOLBAR_URL => "{$_MIDGARD['self']}midcom-exec-midcom/showhelp.php?c=$calling_componentname", 
     606                     MIDCOM_TOOLBAR_LABEL => $_MIDCOM->i18n->get_string('Show help page', 'midcom'), 
     607                     MIDCOM_TOOLBAR_ACCESSKEY => 'h', 
     608                     MIDCOM_TOOLBAR_OPTIONS => array('target' => '_blank'), 
     609                 ) 
     610            ); 
     611        } 
     612        else 
     613        { 
     614            $toolbar->add_item 
     615            ( 
     616                 array 
     617                 ( 
     618                     MIDCOM_TOOLBAR_URL => "{$_MIDGARD['self']}midcom-exec-midcom/showhelp.php?c=$calling_componentname", 
     619                     MIDCOM_TOOLBAR_LABEL => $_MIDCOM->i18n->get_string('Create help page', 'midcom'), 
     620                     MIDCOM_TOOLBAR_ACCESSKEY => 'h', 
     621                     MIDCOM_TOOLBAR_OPTIONS => array('target' => '_blank'), 
     622                 ) 
     623            ); 
     624        } 
     625 
     626 
     627 
     628        $toolbar->add_item 
     629        ( 
     630            array 
     631            ( 
     632                MIDCOM_TOOLBAR_URL => "http://www.midgard-project.org/discussion", 
     633                MIDCOM_TOOLBAR_LABEL => $_MIDCOM->i18n->get_string('User forum', 'midcom'), 
     634                MIDCOM_TOOLBAR_OPTIONS => array('target' => '_blank'), 
     635            ) 
     636        ); 
     637        $toolbar->add_item 
     638        ( 
     639            array 
     640            ( 
     641                MIDCOM_TOOLBAR_URL => "http://www.midgard-project.org/documentation", 
     642                MIDCOM_TOOLBAR_LABEL => $_MIDCOM->i18n->get_string('Online docs', 'midcom'), 
     643                MIDCOM_TOOLBAR_OPTIONS => array('target' => '_blank'), 
     644            ) 
     645        ); 
     646        $toolbar->add_item 
     647        ( 
     648            array 
     649            ( 
     650                MIDCOM_TOOLBAR_URL => "{$_MIDGARD['self']}midcom-exec-midcom/about-component.php?c=$calling_componentname", 
     651                MIDCOM_TOOLBAR_LABEL => $_MIDCOM->i18n->get_string('About component', 'midcom'), 
     652                MIDCOM_TOOLBAR_OPTIONS => array('target' => '_blank'), 
     653            ) 
     654        ); 
     655        $toolbar->add_item 
     656        ( 
     657            array 
     658            ( 
     659                MIDCOM_TOOLBAR_URL => "{$_MIDGARD['self']}midcom-exec-midcom/about.php", 
     660                MIDCOM_TOOLBAR_LABEL => $_MIDCOM->i18n->get_string('About Midgard', 'midcom'), 
     661                MIDCOM_TOOLBAR_OPTIONS => array('target' => '_blank'), 
     662            ) 
     663        ); 
    560664    } 
    561665 
     
    792896        return $this->_render_toolbar(MIDCOM_TOOLBAR_HOST, $context_id); 
    793897    } 
     898     
     899    /** 
     900     * Renders the help toolbar for the indicated context. If the toolbar is undefined, 
     901     * an empty string is returned. If you want to show the toolbar directly, look for 
     902     * the show_xxx_toolbar methods. 
     903     * 
     904     * @param int $context_id The context to retrieve the node toolbar for, this 
     905     *     defaults to the current context. 
     906     * @return string The rendered toolbar 
     907     * @see midcom_helper_toolbar::render() 
     908     */ 
     909    function render_help_toolbar($context_id = null) 
     910    { 
     911        return $this->_render_toolbar(MIDCOM_TOOLBAR_HELP, $context_id); 
     912    } 
    794913 
    795914    /** 
     
    842961        } 
    843962        echo $this->render_view_toolbar(); 
     963    } 
     964 
     965    /** 
     966     * Displays the help toolbar for the indicated context. If the toolbar is undefined, 
     967     * an empty string is returned. 
     968     * 
     969     * @param int $context_id The context to retrieve the node toolbar for, this 
     970     *     defaults to the current context. 
     971     * @see midcom_helper_toolbar::render() 
     972     */ 
     973    function show_help_toolbar($context_id = null) 
     974    { 
     975        if ($this->_centralized_mode) 
     976        { 
     977            return; 
     978        } 
     979        echo $this->render_help_toolbar(); 
    844980    } 
    845981 
     
    8791015        echo $this->render_host_toolbar(); 
    8801016        echo "        </div>\n"; 
     1017        echo "        <div id=\"item-help\" class=\"item\">\n"; 
     1018        echo "            <span class=\"toolbar_list_class help\">". $_MIDCOM->i18n->get_string('Help', 'midcom') . "</span>\n"; 
     1019        echo $this->render_help_toolbar(); 
     1020        echo "        </div>\n"; 
    8811021        echo "    </div>\n"; 
    8821022        echo "     <div class=\"dragbar\"></div>\n";