1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5/**
6 * Class ilUIHookPluginGUI
7 *
8 * @author  Alex Killing <alex.killing@gmx.de>
9 */
10class ilUIHookPluginGUI
11{
12
13    /**
14     * @var ilUserInterfaceHookPlugin
15     */
16    protected $plugin_object = null;
17    public const UNSPECIFIED = '';
18    public const KEEP = '';
19    public const REPLACE = 'r';
20    public const APPEND = 'a';
21    public const PREPEND = 'p';
22
23
24    /**
25     * @param ilUserInterfaceHookPlugin $a_val
26     */
27    final public function setPluginObject($a_val)
28    {
29        $this->plugin_object = $a_val;
30    }
31
32
33    /**
34     * @return ilUserInterfaceHookPlugin
35     */
36    final public function getPluginObject()
37    {
38        return $this->plugin_object;
39    }
40
41
42    /**
43     * @param string $a_comp component
44     * @param string $a_part string that identifies the part of the UI that is handled
45     * @param array  $a_par  array of parameters (depend on $a_comp and $a_part)
46     *
47     * @return array array with entries "mode" => modification mode, "html" => your html
48     * @deprecated Note this method is deprecated. There are several issues with hacking into already rendered html
49     *             as provided here:
50     *             - The generation of html might be performed twice (especially if REPLACE is used).
51     *             - There is limited access to data used to generate the original html. If needed this data needs to be gathered again.
52     *             - If an element inside the html needs to be changed, some crude string replace magic is needed.
53     *
54     *
55     * Modify HTML output of GUI elements. Modifications modes are:
56     * - ilUIHookPluginGUI::KEEP (No modification)
57     * - ilUIHookPluginGUI::REPLACE (Replace default HTML with your HTML)
58     * - ilUIHookPluginGUI::APPEND (Append your HTML to the default HTML)
59     * - ilUIHookPluginGUI::PREPEND (Prepend your HTML to the default HTML)
60     *
61     */
62    public function getHTML($a_comp, $a_part, $a_par = array())
63    {
64        return array('mode' => self::KEEP, 'html' => '');
65    }
66
67
68    /**
69     * @param string $a_comp component
70     * @param string $a_part string that identifies the part of the UI that is handled
71     * @param array  $a_par  array of parameters (depend on $a_comp and $a_part)
72     *
73     * @deprecated Note this method is deprecated. User Interface components are migrated towards the UIComponents and
74     *             Global Screen which do not make use of the mechanism provided here. Make use of the extension possibilities provided
75     *             by Global Screen and UI Components instead.
76     *
77     * In ILIAS 6.0 still working for working for:
78     * - $a_comp="Services/Ini" ; $a_part="init_style"
79     * - $a_comp="" ; $a_part="tabs"
80     * - $a_comp="" ; $a_part="sub_tabs"
81     *
82     * Allows to modify user interface objects before they generate their output.
83     *
84     */
85    public function modifyGUI($a_comp, $a_part, $a_par = array())
86    {
87    }
88
89
90    /**
91     * @param string    default html
92     * @param string    response from plugin
93     *
94     * @return    string    modified html
95     * @deprecated Reason, see getHTML
96     *
97     * Modify HTML based on default html and plugin response
98     *
99     */
100    final public function modifyHTML($a_def_html, $a_resp)
101    {
102        switch ($a_resp['mode']) {
103            case self::REPLACE:
104                $a_def_html = $a_resp['html'];
105                break;
106            case self::APPEND:
107                $a_def_html .= $a_resp['html'];
108                break;
109            case self::PREPEND:
110                $a_def_html = $a_resp['html'] . $a_def_html;
111                break;
112        }
113
114        return $a_def_html;
115    }
116
117
118    /**
119     * Goto script hook
120     *
121     * Can be used to interfere with the goto script behaviour
122     */
123    public function gotoHook()
124    {
125    }
126
127
128    /**
129     * Goto script hook
130     *
131     * Can be used to interfere with the goto script behaviour
132     */
133    public function checkGotoHook($a_target)
134    {
135        return array('target' => false);
136    }
137}
138