| | 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 | ); |
|---|
| | 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 | } |
|---|