Proyectos de Subversion Moodle

Rev

Rev 1 | Rev 966 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 965
Línea 29... Línea 29...
29
 * cesa_notes block.
29
 * cesa_notes block.
30
 *
30
 *
31
 * @package    block_cesa_notes
31
 * @package    block_cesa_notes
32
 * 
32
 * 
33
 */
33
 */
34
class block_cesa_notes extends block_base {
34
class block_cesa_notes extends block_base
-
 
35
{
Línea 35... Línea 36...
35
 
36
 
-
 
37
    public function init()
36
    public function init() {
38
    {
37
        $this->title = get_string('pluginname', 'block_cesa_notes');
39
        $this->title = get_string('pluginname', 'block_cesa_notes');
Línea 38... Línea 40...
38
    }
40
    }
-
 
41
 
39
 
42
    public function has_config()
40
    public function has_config() {
43
    {
Línea 41... Línea 44...
41
        return true;
44
        return true;
-
 
45
    }
42
    }
46
 
43
 
47
    public function applicable_formats()
Línea 44... Línea 48...
44
    public function applicable_formats() {
48
    {
-
 
49
        return array('all' => true);
45
        return array('all' => true);
50
    }
46
    }
51
 
Línea 47... Línea 52...
47
 
52
    public function instance_allow_multiple()
-
 
53
    {
48
    public function instance_allow_multiple() {
54
        return false;
49
        return false;
55
    }
50
    }
56
 
51
 
57
    public function hide_header()
52
    public function hide_header() {
58
    {
Línea 59... Línea 65...
59
    /**
65
    /**
60
     * The content object.
66
     * The content object.
61
     *
67
     *
62
     * @return stdObject
68
     * @return stdObject
63
     */
69
     */
64
    public function get_content() {
70
    public function get_content()
-
 
71
    {
65
        global $CFG, $PAGE;
72
        global $CFG, $PAGE;
66
        
73
 
67
        static $jscount = 0;
74
        static $jscount = 0;
68
        if ($this->content !== null) {
75
        if ($this->content !== null) {
69
            return $this->content;
76
            return $this->content;
70
        } else {
77
        } else {
71
            $this->content = new \stdClass();
78
            $this->content = new \stdClass();
72
        }
79
        }
Línea 73... Línea 80...
73
 
80
 
74
        if (!isloggedin() or isguestuser()) {
81
        if (!isloggedin() or isguestuser()) {
75
            return '';      // Never useful unless you are logged in as real users
82
            return '';      // Never useful unless you are logged in as real users
76
        }
83
        }
77
        
84
 
78
        if (!in_array($PAGE->context->contextlevel, array(CONTEXT_COURSE, CONTEXT_SYSTEM, CONTEXT_MODULE, CONTEXT_USER))) {
85
        if (!in_array($PAGE->context->contextlevel, array(CONTEXT_COURSE, CONTEXT_SYSTEM, CONTEXT_MODULE, CONTEXT_USER))) {
79
            return '';
86
            return '';
80
        }
87
        }
81
        
88
 
82
        $this->content = new stdClass();
89
        $this->content = new stdClass();
83
        $this->content->footer = '';
90
        $this->content->footer = '';
84
        $this->content->text = '';
91
        $this->content->text = '';
85
        if (empty($this->instance)) {
92
        if (empty($this->instance)) {
86
            return $this->content;
-
 
87
        }        
-
 
88
        
-
 
89
        $this->content = new stdClass();
-
 
90
        $this->content->text = '';
-
 
91
        if ($PAGE->user_is_editing()) {
-
 
92
            $this->content->text = '<div class="inline-cesa_notes-opener">'.get_string('showcesa_notes', 'block_cesa_notes').'</div>';
93
            return $this->content;
-
 
94
        }
-
 
95
 
-
 
96
        $this->content = new stdClass();
-
 
97
        $this->content->text = '<div class="inline-cesa_notes-opener">' . get_string('showcesa_notes', 'block_cesa_notes') . '</div>';
93
        }
98
 
94
        $this->content->footer = '';
99
        $this->content->footer = '';
95
        
100
 
96
        if ($jscount == 0) {
101
        if ($jscount == 0) {
97
            $this->block_cesa_notes_get_required_javascript();
102
            $this->block_cesa_notes_get_required_javascript();
98
            $jscount++;
103
            $jscount++;
99
        }
104
        }
100
        return $this->content;
105
        return $this->content;
Línea 101... Línea 106...
101
    }
106
    }
102
 
107
 
103
    /*
108
    /*
104
     * load JS that requires into the page.
109
     * load JS that requires into the page.
-
 
110
     */
105
     */
111
    private function block_cesa_notes_get_required_javascript()
106
    private function block_cesa_notes_get_required_javascript() {
112
    {
107
        global $PAGE, $CFG; 
113
        global $PAGE, $CFG;
108
        list($context, $course, $cm) = get_context_info_array($PAGE->context->id);
114
        list($context, $course, $cm) = get_context_info_array($PAGE->context->id);
109
        $config = get_config('block_cesa_notes');
115
        $config = get_config('block_cesa_notes');
110
        
116
 
111
        $mm = new block_cesa_notes_manager();
117
        $mm = new block_cesa_notes_manager();
-
 
118
        $currenttabindex = $mm->get_current_tab($context, $PAGE);
112
        $currenttabindex = $mm->get_current_tab($context, $PAGE);
119
        $arguments = array(
113
        $arguments = array( 'arg'=> array(
120
            'arg' => array(
114
            'instanceid' => $this->instance->id,
121
                'instanceid' => $this->instance->id,
115
            'editing' => ($PAGE->user_is_editing()),
122
                'editing' => ($PAGE->user_is_editing()),
116
            'editingicon_pos' => ($PAGE->user_is_editing()) ? 'cesa_notes-pos-inline' : $config->icondisplayposition,
123
                'editingicon_pos' => ($PAGE->user_is_editing()) ? 'cesa_notes-pos-inline' : $config->icondisplayposition,
117
            'maxallowedcharacters' => $config->characterlimit,
124
                'maxallowedcharacters' => $config->characterlimit,
118
            'contextid' => $context->id,
125
                'contextid' => $context->id,
119
            'maxallowedcharacters_warning' => get_string('notmorethan', 'block_cesa_notes', $config->characterlimit),
126
                'maxallowedcharacters_warning' => get_string('notmorethan', 'block_cesa_notes', $config->characterlimit),
120
            'contextareas' => $mm->get_available_contextareas(),
127
                'contextareas' => $mm->get_available_contextareas(),
121
            'currenttabindex' => ($currenttabindex == null ? 'site' : $currenttabindex),
128
                'currenttabindex' => ($currenttabindex == null ? 'site' : $currenttabindex),
122
            'perpage' => $config->cesa_notesperpage,
129
                'perpage' => $config->cesa_notesperpage,
123
            ),
130
            ),
124
        );
131
        );
125
        $PAGE->requires->string_for_js('charactersleft', 'block_cesa_notes');
132
        $PAGE->requires->string_for_js('charactersleft', 'block_cesa_notes');
Línea 136... Línea 143...
136
        $PAGE->requires->string_for_js('nothingtodisplay', 'block_cesa_notes');
143
        $PAGE->requires->string_for_js('nothingtodisplay', 'block_cesa_notes');
137
        $PAGE->requires->string_for_js('cesa_notessavedundertab', 'block_cesa_notes');
144
        $PAGE->requires->string_for_js('cesa_notessavedundertab', 'block_cesa_notes');
138
        $PAGE->requires->string_for_js('cancel', 'moodle');
145
        $PAGE->requires->string_for_js('cancel', 'moodle');
139
        $this->page->requires->js_call_amd('block_cesa_notes/cesa_notesblock', 'init', $arguments);
146
        $this->page->requires->js_call_amd('block_cesa_notes/cesa_notesblock', 'init', $arguments);
140
    }
147
    }
141
}
-
 
142
148
}
-
 
149