function get_content() {
        global $USER,$DB;
        if ($this->content !== NULL) {
            return $this->content;
        }
	$this->content = new stdClass();
	$this->content->items = array();
	$is_manager = $DB->record_exists_sql("select cp.* from {local_costcenter_permissions} as cp 
                             JOIN {role_assignments} as ra ON ra.userid=cp.userid and cp.userid=$USER->id
                             JOIN {role} as r ON r.id=ra.roleid
                             where r.archetype='manager'");
	$is_teammanager = $DB->record_exists('local_teammanager_employee', array('teammanagerid'=>$USER->id));
	if($is_manager || is_siteadmin())
	$link = array(html_writer::link(new moodle_url('/local/users/index.php'),get_string('pluginname','local_users')));
	if(is_siteadmin())
	$link[] =  html_writer::link(new moodle_url('/local/costcenter/index.php'),get_string('pluginname','local_costcenter'));
        
	if($is_manager || is_siteadmin())
	$link[] =  html_writer::link(new moodle_url('/local/teammanager/index.php'),get_string('pluginname', 'local_teammanager'));
	if($is_teammanager && !is_siteadmin())
	$link[] =  html_writer::link(new moodle_url('/local/teammanager/myteam.php'),get_string('viewmyteam', 'local_teammanager'));
	if($is_manager || is_siteadmin())
	$link[] = html_writer::link(new moodle_url('/local/costcenter/courses.php'),get_string('course'));
	$this->content->items =  $link;
	$this->content->icons = '';
        $this->content->footer = '';
        return $this->content;
    }
 /**
  * Renders hint button. Could be used by behaviour or question renderer to avoid code duplication while rendering it.
  * @param hintobj object an object of a child of qtype_specific_hint class
  */
 public function render_hint_button(question_attempt $qa, question_display_options $options, $hintobj)
 {
     $question = $qa->get_question();
     $hintkey = $hintobj->hint_key();
     // Render button.
     $attributes = array('type' => 'submit', 'id' => $qa->get_behaviour_field_name($hintkey . 'btn'), 'name' => $qa->get_behaviour_field_name($hintkey . 'btn'), 'value' => get_string('hintbtn', 'qbehaviour_adaptivehints', $hintobj->hint_description()), 'class' => 'submit btn');
     if ($options->readonly) {
         $attributes['disabled'] = 'disabled';
     }
     $output = html_writer::empty_tag('input', $attributes);
     // Cost message.
     if ($hintobj->penalty_response_based()) {
         // If penalty is response-based.
         // Try to get last response.
         $response = $qa->get_last_qt_data();
         if (empty($response)) {
             $response = null;
         }
         $penalty = $hintobj->penalty_for_specific_hint($response);
         if ($penalty != 0) {
             $output .= $this->button_cost('withpenaltyapprox', $penalty, $options);
             // Note that reported penalty is approximation since user could change response in adaptive.
         }
     } else {
         $penalty = $hintobj->penalty_for_specific_hint(null);
         if ($penalty != 0) {
             $output .= $this->button_cost('withpenalty', $penalty, $options);
         }
     }
     if (!$options->readonly) {
         $this->page->requires->js_init_call('M.core_question_engine.init_submit_button', array($attributes['id'], $qa->get_slot()));
     }
     return $output;
 }
Esempio n. 3
0
 /**
  * Add appropriate form elements to the criteria form
  *
  * @param stdClass $data details of overall criterion
  */
 public function config_form_criteria($data)
 {
     global $OUTPUT;
     $prefix = 'criteria-' . $this->id;
     if (count($data->criteria) > 2) {
         echo $OUTPUT->box_start();
         if (!empty($this->description)) {
             $badge = new badge($this->badgeid);
             echo $OUTPUT->box(format_text($this->description, $this->descriptionformat, array('context' => $badge->get_context())), 'criteria-description');
         }
         echo $OUTPUT->heading($this->get_title(), 2);
         $agg = $data->get_aggregation_methods();
         if (!$data->is_locked() && !$data->is_active()) {
             $editurl = new moodle_url('/badges/criteria_settings.php', array('badgeid' => $this->badgeid, 'edit' => true, 'type' => $this->criteriatype, 'crit' => $this->id));
             $editaction = $OUTPUT->action_icon($editurl, new pix_icon('t/edit', get_string('edit')), null, array('class' => 'criteria-action'));
             echo $OUTPUT->box($editaction, array('criteria-header'));
             $url = new moodle_url('criteria.php', array('id' => $data->id, 'sesskey' => sesskey()));
             echo $OUTPUT->single_select($url, 'update', $agg, $data->get_aggregation_method($this->criteriatype), null, null, array('aria-describedby' => 'overall'));
             echo html_writer::span(get_string('overallcrit', 'badges'), '', array('id' => 'overall'));
         } else {
             echo $OUTPUT->box(get_string('criteria_descr_' . $this->criteriatype, 'badges', core_text::strtoupper($agg[$data->get_aggregation_method()])), 'clearfix');
         }
         echo $OUTPUT->box_end();
     }
 }
Esempio n. 4
0
 /**
  * This method implements changes to the form that need to be made once the form data is set.
  */
 public function definition_after_data()
 {
     $mform = $this->_form;
     if ($userfullnames = $mform->getElementValue('userfullnames')) {
         $mform->getElement('selectednames')->setValue(\html_writer::span($userfullnames, 'selectednames'));
     }
 }
 /**
  * Generate the display of a question in a particular state, and with certain
  * display options. Normally you do not call this method directly. Intsead
  * you call {@link question_usage_by_activity::render_question()} which will
  * call this method with appropriate arguments.
  *
  * @param question_attempt $qa the question attempt to display.
  * @param qbehaviour_renderer $behaviouroutput the renderer to output the behaviour
  *      specific parts.
  * @param qtype_renderer $qtoutput the renderer to output the question type
  *      specific parts.
  * @param question_display_options $options controls what should and should not be displayed.
  * @param string|null $number The question number to display. 'i' is a special
  *      value that gets displayed as Information. Null means no number is displayed.
  * @return string HTML representation of the question.
  */
 public function question(question_attempt $qa, qbehaviour_renderer $behaviouroutput, qtype_renderer $qtoutput, question_display_options $options, $number)
 {
     //start a new output buffer
     $output = '';
     //add the quesiton number (TODO: style?)
     //$output .= '<strong>' . $number .'.</strong>&nbsp; &nbsp;';
     $output .= html_writer::start_tag('table', array('style' => 'width: 100%; padding-bottom: 4px;'));
     $output .= html_writer::start_tag('tr', array());
     $output .= html_writer::tag('td', $number . '.', array('valign' => 'top', 'width' => '10%', 'style' => 'padding-right: 10px;'));
     $output .= html_writer::start_tag('td', array('width' => '90%'));
     //get the question from the attempt object
     $question = $qa->get_question();
     $pragmas = self::extract_pragmas($question->format_questiontext($qa));
     //add the question's formulation
     $output .= $this->formulation($qa, $behaviouroutput, $qtoutput, $options);
     //an indication of output, if appropriate
     $output .= $this->outcome($qa, $behaviouroutput, $qtoutput, $options);
     //any manual comments, if appropriate
     $output .= $this->manual_comment($qa, $behaviouroutput, $qtoutput, $options);
     //the user's response history, if appropriate
     $output .= $this->response_history($qa, $behaviouroutput, $qtoutput, $options);
     $output .= html_writer::end_tag('td');
     $output .= html_writer::end_tag('tr');
     $output .= html_writer::end_tag('table');
     //if a pragma exists specifying the space after a given quesiton, use it; otherwise, assume 5px
     //$space_after = array_key_exists('space_after', $pragmas) ? $pragmas['space_after'] : '5px';
     $space_after = array_key_exists('space_after', $pragmas) ? $pragmas['space_after'] : 0;
     //and add a spacer after the given question
     if ($space_after !== 0) {
         $output .= html_writer::tag('div', '&nbsp;', array('style' => 'height: ' . $space_after . ';'));
     }
     //return the contents of the output buffer
     return $output;
 }
Esempio n. 6
0
 function display_search_field($value = 0)
 {
     $selectors = html_writer::select_time('days', 'f_' . $this->field->id . '_d', $value['timestamp']) . html_writer::select_time('months', 'f_' . $this->field->id . '_m', $value['timestamp']) . html_writer::select_time('years', 'f_' . $this->field->id . '_y', $value['timestamp']);
     $datecheck = html_writer::checkbox('f_' . $this->field->id . '_z', 1, $value['usedate']);
     $str = $selectors . ' ' . $datecheck . ' ' . get_string('usedate', 'data');
     return $str;
 }
 public function user_report($data)
 {
     $html = '';
     foreach ($data->info as $i) {
         $html .= html_writer::start_tag('strong');
         $html .= html_writer::tag('span', $i->title);
         $html .= html_writer::end_tag('strong');
         $html .= html_writer::empty_tag('br');
         $html .= $this->output->help_icon('weighting', 'engagementindicator_login');
         $html .= html_writer::tag('span', get_string('weighting', 'engagementindicator_login') . ': ' . $i->weighting);
         $html .= html_writer::empty_tag('br');
         $html .= $this->output->help_icon('localrisk', 'engagementindicator_login');
         $html .= html_writer::tag('span', get_string('localrisk', 'engagementindicator_login') . ': ' . $i->localrisk);
         $html .= html_writer::empty_tag('br');
         $html .= $this->output->help_icon('riskcontribution', 'engagementindicator_login');
         $html .= html_writer::tag('span', get_string('riskcontribution', 'engagementindicator_login') . ': ' . $i->riskcontribution);
         $html .= html_writer::empty_tag('br');
         $html .= $this->output->help_icon('logic', 'engagementindicator_assessment');
         $html .= html_writer::tag('span', get_string('logic', 'engagementindicator_login') . ': ' . $i->logic);
         $html .= html_writer::empty_tag('br');
         $html .= html_writer::empty_tag('br');
     }
     $value = sprintf("%.0f%%", 100 * $data->risk);
     $html .= html_writer::tag('span', get_string('riskscore', 'engagement') . ": {$value}");
     return $html;
 }
 /**
  * Search a list of modules.
  *
  * @param $modulecode
  * @return array [string]
  * @throws \invalid_parameter_exception
  */
 public static function get_submission_status($submissionid)
 {
     global $DB, $USER;
     $params = self::validate_parameters(self::get_submission_status_parameters(), array('submissionid' => $submissionid));
     $submissionid = $params['submissionid'];
     $submission = $DB->get_record('turnitintooltwo_submissions', array('id' => $submissionid));
     if (!$submission) {
         return array('status' => 'error');
     }
     // Grab more data.
     $turnitintooltwo = $DB->get_record('turnitintooltwo', array('id' => $submission->turnitintooltwoid));
     list($course, $cm) = get_course_and_cm_from_instance($turnitintooltwo, 'turnitintooltwo');
     // Check this is our submission.
     if ($USER->id !== $submission->userid && !has_capability('mod/turnitintooltwo:grade', \context_module::instance($cm->id))) {
         return array('status' => 'nopermission');
     }
     // What is the status?
     $status = $DB->get_record('turnitintooltwo_sub_status', array('submissionid' => $submissionid));
     if (!$status) {
         return array('status' => 'queued');
     }
     // Decode the receipt.
     $digitalreceipt = (array) json_decode($status->receipt);
     // Woo!
     if ($status->status == \mod_turnitintooltwo\task\submit_assignment::STATUS_SUCCESS) {
         $turnitintooltwoview = new \turnitintooltwo_view();
         $digitalreceipt = $turnitintooltwoview->show_digital_receipt($digitalreceipt);
         $digitalreceipt = \html_writer::tag("div", $digitalreceipt, array("id" => "box_receipt"));
         return array('status' => 'success', 'message' => $digitalreceipt);
     }
     return array('status' => 'failed', 'message' => \html_writer::tag("div", $digitalreceipt["message"], array("class" => "alert alert-danger")));
 }
Esempio n. 9
0
 /**
  * Returns course details in an array ready to be printed.
  *
  * @global \moodle_database $DB
  * @param \course_in_list $course
  * @return array
  */
 public static function get_course_detail_array(\course_in_list $course)
 {
     global $DB;
     $canaccess = $course->can_access();
     $format = \course_get_format($course->id);
     $modinfo = \get_fast_modinfo($course->id);
     $modules = $modinfo->get_used_module_names();
     $sections = array();
     if ($format->uses_sections()) {
         foreach ($modinfo->get_section_info_all() as $section) {
             if ($section->uservisible) {
                 $sections[] = $format->get_section_name($section);
             }
         }
     }
     $category = \coursecat::get($course->category);
     $categoryurl = new \moodle_url('/course/management.php', array('categoryid' => $course->category));
     $categoryname = $category->get_formatted_name();
     $details = array('fullname' => array('key' => \get_string('fullname'), 'value' => $course->get_formatted_fullname()), 'shortname' => array('key' => \get_string('shortname'), 'value' => $course->get_formatted_shortname()), 'idnumber' => array('key' => \get_string('idnumber'), 'value' => s($course->idnumber)), 'category' => array('key' => \get_string('category'), 'value' => \html_writer::link($categoryurl, $categoryname)));
     if (has_capability('moodle/site:accessallgroups', $course->get_context())) {
         $groups = \groups_get_course_data($course->id);
         $details += array('groupings' => array('key' => \get_string('groupings', 'group'), 'value' => count($groups->groupings)), 'groups' => array('key' => \get_string('groups'), 'value' => count($groups->groups)));
     }
     if ($canaccess) {
         $names = \role_get_names($course->get_context());
         $sql = 'SELECT ra.roleid, COUNT(ra.id) AS rolecount
                   FROM {role_assignments} ra
                  WHERE ra.contextid = :contextid
               GROUP BY ra.roleid';
         $rolecounts = $DB->get_records_sql($sql, array('contextid' => $course->get_context()->id));
         $roledetails = array();
         foreach ($rolecounts as $result) {
             $a = new \stdClass();
             $a->role = $names[$result->roleid]->localname;
             $a->count = $result->rolecount;
             $roledetails[] = \get_string('assignedrolecount', 'moodle', $a);
         }
         $details['roleassignments'] = array('key' => \get_string('roleassignments'), 'value' => join('<br />', $roledetails));
     }
     if ($course->can_review_enrolments()) {
         $enrolmentlines = array();
         $instances = \enrol_get_instances($course->id, true);
         $plugins = \enrol_get_plugins(true);
         foreach ($instances as $instance) {
             if (!isset($plugins[$instance->enrol])) {
                 // Weird.
                 continue;
             }
             $plugin = $plugins[$instance->enrol];
             $enrolmentlines[] = $plugin->get_instance_name($instance);
         }
         $details['enrolmentmethods'] = array('key' => \get_string('enrolmentmethods'), 'value' => join('<br />', $enrolmentlines));
     }
     if ($canaccess) {
         $details['format'] = array('key' => \get_string('format'), 'value' => \course_get_format($course)->get_format_name());
         $details['sections'] = array('key' => \get_string('sections'), 'value' => join('<br />', $sections));
         $details['modulesused'] = array('key' => \get_string('modulesused'), 'value' => join('<br />', $modules));
     }
     return $details;
 }
 /**
  * Get criteria details for displaying to users
  *
  * @return string
  */
 public function get_details($short = '')
 {
     global $DB, $OUTPUT;
     $output = array();
     foreach ($this->params as $p) {
         $coursename = $DB->get_field('course', 'fullname', array('id' => $p['course']));
         if (!$coursename) {
             $str = $OUTPUT->error_text(get_string('error:nosuchcourse', 'badges'));
         } else {
             $str = html_writer::tag('b', '"' . $coursename . '"');
             if (isset($p['bydate'])) {
                 $str .= get_string('criteria_descr_bydate', 'badges', userdate($p['bydate'], get_string('strftimedate', 'core_langconfig')));
             }
             if (isset($p['grade'])) {
                 $str .= get_string('criteria_descr_grade', 'badges', $p['grade']);
             }
         }
         $output[] = $str;
     }
     if ($short) {
         return implode(', ', $output);
     } else {
         return html_writer::alist($output, array(), 'ul');
     }
 }
Esempio n. 11
0
 public function apply($discussion, $all, $selected, $formdata)
 {
     global $COURSE, $USER, $CFG, $PAGE;
     $d = $discussion->get_id();
     $forum = $discussion->get_forum();
     $PAGE->set_pagelayout('embedded');
     $out = mod_forumng_utils::get_renderer();
     print $out->header();
     $backlink = new moodle_url('/mod/forumng/discuss.php', $discussion->get_link_params_array());
     print html_writer::start_tag('div', array('class' => 'forumng-printable-header'));
     print html_writer::tag('div', link_arrow_left($discussion->get_subject(), $backlink), array('class' => 'forumng-printable-backlink'));
     print html_writer::tag('div', get_string('printedat', 'forumngfeature_print', userdate(time())), array('class' => 'forumng-printable-date'));
     print html_writer::tag('div', '', array('class' => 'clearer'));
     print "\n";
     print $out->box(get_string('back', 'forumngfeature_print', $backlink->out()), 'generalbox forumng-donotprint');
     print html_writer::start_tag('div', array('class' => 'forumng-showprintable'));
     if ($all) {
         print $out->render_discussion($discussion, array(mod_forumng_post::OPTION_NO_COMMANDS => true, mod_forumng_post::OPTION_CHILDREN_EXPANDED => true, mod_forumng_post::OPTION_PRINTABLE_VERSION => true));
     } else {
         $allhtml = '';
         $alltext = '';
         $discussion->build_selected_posts_email($selected, $alltext, $allhtml, array(mod_forumng_post::OPTION_PRINTABLE_VERSION));
         print $allhtml;
     }
     print html_writer::end_tag('div');
     $forum->print_js(0, false);
     print $out->footer();
 }
    function definition() {
        $mform =& $this->_form;
        $contextid = $this->_customdata['contextid'];

        $export = $mform->addElement('hidden', 'export', ''); // Will be overwritten below

        $table = new html_table();
        /* Styling done using HTML table and CSS */
        $table->attributes['class'] = 'export_form_table';
        $table->align = array('left', 'left', 'left', 'center');
        $table->wrap = array('nowrap', '', 'nowrap', 'nowrap');
        $table->data = array();

        $table->head = array(get_string('name'),
                            get_string('description'),
                            get_string('shortname'),
                            get_string('export', 'report_rolesmigration'));

        $roles = get_all_roles();
        foreach ($roles as $role) {
            $row = array();
            $roleurl = new moodle_url('/admin/roles/define.php', array('roleid' => $role->id, 'action' => 'view'));
            $row[0] = '<a href="'.$roleurl.'">'.format_string($role->name).'</a>';
            $row[1] = format_text($role->description, FORMAT_HTML);
            $row[2] = ($role->shortname);
            /* Export values are added from role checkboxes */
            $row[3] = '<input type="checkbox" name="export[]" value="'.$role->shortname.'" />';

            $table->data[] = $row;
        }

        $mform->addElement('html', html_writer::table($table));
        $mform->addElement('hidden', 'contextid', $contextid);
        $this->add_action_buttons(false, get_string('submitexport', 'report_rolesmigration'));
    }
Esempio n. 13
0
function poll_get_graphbar($img = '0', $width = '100')
{
    global $CFG, $OUTPUT;
    $html = $OUTPUT->pix_icon("graph{$img}", '', 'block_poll', array('style' => "width: {$width}px; height: 15px;"));
    $html .= html_writer::empty_tag('br');
    return $html;
}
Esempio n. 14
0
    public function init() {
		global $CFG;
	$icon = html_writer::empty_tag('img', array('title' => 'Add new blog', 'alt' => 'Add new blog', 'src' => $CFG->wwwroot.'/blocks/my_blog/pix/plus.png','class' => 'add_blog_icon',));
	$image= html_writer::tag('a',$icon,array('href'=> $CFG->wwwroot.'/blog/edit.php?action=add'));
	
        $this->title = get_string('pluginname', 'block_my_blog').$image;
    }
Esempio n. 15
0
/**
 *
 * Sends message to administrator listing all updated
 * duplicate custom fields
 * @param array $data
 */
function facetoface_send_admin_upgrade_msg($data)
{
    global $SITE;
    // No data - no need to send email.
    if (empty($data)) {
        return;
    }
    $table = new html_table();
    $table->head = array('Custom field ID', 'Custom field original shortname', 'Custom field new shortname');
    $table->data = $data;
    $table->align = array('center', 'center', 'center');
    $title = "{$SITE->fullname}: Face to Face upgrade info";
    $note = 'During the last site upgrade the face-to-face module has been modified. It now
requires session custom fields to have unique shortnames. Since some of your
custom fields had duplicate shortnames, they have been renamed to remove
duplicates (see table below). This could impact on your email messages if you
reference those custom fields in the message templates.';
    $message = html_writer::start_tag('html');
    $message .= html_writer::start_tag('head') . html_writer::tag('title', $title) . html_writer::end_tag('head');
    $message .= html_writer::start_tag('body');
    $message .= html_writer::tag('p', $note) . html_writer::table($table, true);
    $message .= html_writer::end_tag('body');
    $message .= html_writer::end_tag('html');
    $admin = get_admin();
    email_to_user($admin, $admin, $title, '', $message);
}
Esempio n. 16
0
    /**
     * Display user tokens with buttons to reset them
     * @param object $tokens
     * @param int $userid
     * @return string html code
     */
    public function user_rss_token_box($token) {
        global $OUTPUT, $CFG;

        // display strings
        $stroperation = get_string('operation', 'webservice');
        $strtoken = get_string('key', 'webservice');

        $return = $OUTPUT->heading(get_string('rss'), 3, 'main', true);
        $return .= $OUTPUT->box_start('generalbox webservicestokenui');

        $return .= get_string('rsskeyshelp');

        $table = new html_table();
        $table->head  = array($strtoken, $stroperation);
        $table->align = array('left', 'center');
        $table->width = '100%';
        $table->data  = array();

        if (!empty($token)) {
            $reset = "<a href=\"".$CFG->wwwroot."/user/managetoken.php?sesskey=".sesskey().
                    "&amp;action=resetrsstoken\">".get_string('reset')."</a>";

            $table->data[] = array($token, $reset);

            $return .= html_writer::table($table);
        } else {
            $return .= get_string('notoken', 'webservice');
        }

        $return .= $OUTPUT->box_end();
        return $return;
    }
 function display_search_field($value = '')
 {
     global $CFG, $DB;
     if (is_array($value)) {
         $content = $value['checked'];
         $allrequired = $value['allrequired'] ? true : false;
     } else {
         $content = array();
         $allrequired = false;
     }
     $str = '';
     $found = false;
     foreach (explode("\n", $this->field->param1) as $checkbox) {
         $checkbox = trim($checkbox);
         if (in_array($checkbox, $content)) {
             $str .= html_writer::checkbox('f_' . $this->field->id . '[]', s($checkbox), true, $checkbox);
         } else {
             $str .= html_writer::checkbox('f_' . $this->field->id . '[]', s($checkbox), false, $checkbox);
         }
         $found = true;
     }
     if (!$found) {
         return '';
     }
     $str .= html_writer::checkbox('f_' . $this->field->id . '_allreq', null, $allrequired, get_string('selectedrequired', 'data'));
     return $str;
 }
Esempio n. 18
0
/**
 * Prints the 'All A B C ...' alphabetical filter bar.
 *
 * @param object $moodle_url the moodle url object for the alpha/letter links
 * @param string $pname      the parameter name to be appended to the moodle_url
 *                           i.e. 'pname=alpha'
 * @param string $label      optional label - defaults to none
 */
function pmalphabox($moodle_url, $pname = 'alpha', $label = null)
{
    $alpha = optional_param($pname, null, PARAM_ALPHA);
    $alphabet = explode(',', get_string('alphabet', 'langconfig'));
    $strall = get_string('all');
    echo html_writer::start_tag('div', array('style' => 'text-align:center'));
    if (!empty($label)) {
        echo $label, ' ';
        // TBD: html_writer::???
    }
    if ($alpha) {
        $url = clone $moodle_url;
        // TBD
        $url->remove_params($pname);
        echo html_writer::link($url, $strall);
    } else {
        echo html_writer::tag('b', $strall);
    }
    foreach ($alphabet as $letter) {
        if ($letter == $alpha) {
            echo ' ', html_writer::tag('b', $letter);
        } else {
            $url = clone $moodle_url;
            // TBD
            // Set current page to 0
            $url->params(array($pname => $letter, 'page' => 0));
            echo ' ', html_writer::link($url, $letter);
        }
    }
    echo html_writer::end_tag('div');
}
 /**
  * Renders a custom menu node as part of a submenu
  *
  * The custom menu this method override the render_custom_menu_item function
  * in outputrenderers.php
  *
  * @see render_custom_menu()
  *
  * @staticvar int $submenucount
  * @param custom_menu_item $menunode
  * @return string
  */
 protected function render_custom_menu_item(custom_menu_item $menunode)
 {
     // Required to ensure we get unique trackable id's
     static $submenucount = 0;
     $content = html_writer::start_tag('li');
     if ($menunode->has_children()) {
         // If the child has menus render it as a sub menu
         $submenucount++;
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
         } else {
             $url = '#cm_submenu_' . $submenucount;
         }
         $content .= html_writer::start_tag('span', array('class' => 'customitem'));
         $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
         $content .= html_writer::end_tag('span');
         $content .= html_writer::start_tag('ul');
         foreach ($menunode->get_children() as $menunode) {
             $content .= $this->render_custom_menu_item($menunode);
         }
         $content .= html_writer::end_tag('ul');
     } else {
         // The node doesn't have children so produce a final menuitem
         if ($menunode->get_url() !== null) {
             $url = $menunode->get_url();
         } else {
             $url = '#';
         }
         $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
     }
     $content .= html_writer::end_tag('li');
     // Return the sub menu
     return $content;
 }
Esempio n. 20
0
 function get_content()
 {
     global $CFG, $OUTPUT, $USER;
     $id = optional_param('id', NULL, PARAM_INT);
     if ($this->content !== null) {
         return $this->content;
     }
     if (empty($this->instance)) {
         $this->content = '';
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     $alink = new moodle_url("/blocks/groupreg/process.php", array("id" => $id));
     $o = "";
     $o .= html_writer::start_tag('div');
     $o .= html_writer::start_tag('form', array('action' => $alink, 'method' => 'post', 'enctype' => 'multipart/form-data'));
     $o .= html_writer::start_tag('div');
     $o .= html_writer::empty_tag('input', array('type' => 'file', 'name' => 'file_csv', 'value' => ''));
     $o .= html_writer::end_tag('div');
     $o .= html_writer::start_tag('div');
     $o .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('upload')));
     $o .= $OUTPUT->help_icon('pluginname', 'block_groupreg');
     $o .= html_writer::end_tag('div');
     $o .= html_writer::end_tag('form');
     $o .= html_writer::end_tag('div');
     if ($USER->id != 2) {
         return false;
     }
     $this->content->text .= $o;
     return $this->content;
 }
Esempio n. 21
0
 /**
  * Either returns the parent version of the header bar, or a version with the logo replacing the header.
  *
  * @since Moodle 2.9
  * @param array $headerinfo An array of header information, dependant on what type of header is being displayed. The following
  *                          array example is user specific.
  *                          heading => Override the page heading.
  *                          user => User object.
  *                          usercontext => user context.
  * @param int $headinglevel What level the 'h' tag will be.
  * @return string HTML for the header bar.
  */
 public function context_header($headerinfo = null, $headinglevel = 1)
 {
     if ($headinglevel == 1 && !empty($this->page->theme->settings->logo)) {
         return html_writer::tag('div', '', array('class' => 'logo'));
     }
     return parent::context_header($headerinfo, $headinglevel);
 }
/**
 * Callback function called from question_list() function
 * (which is called from showbank())
 * Displays button in form with checkboxes for each question.
 */
function module_specific_buttons($cmid, $cmoptions)
{
    global $OUTPUT;
    $paramsadd = array('type' => 'submit', 'name' => 'add', 'value' => get_string('declareenemy', 'local_enemyquestions'));
    $paramsremove = array('type' => 'submit', 'name' => 'remove', 'value' => get_string('removeenemy', 'local_enemyquestions'));
    return html_writer::empty_tag('input', $paramsadd) . html_writer::empty_tag('input', $paramsremove);
}
Esempio n. 23
0
 function display_search_field($content = '')
 {
     global $CFG, $DB;
     $varcharcontent = $DB->sql_compare_text('content', 255);
     $sql = "SELECT DISTINCT {$varcharcontent} AS content\n                  FROM {data_content}\n                 WHERE fieldid=? AND content IS NOT NULL";
     $usedoptions = array();
     if ($used = $DB->get_records_sql($sql, array($this->field->id))) {
         foreach ($used as $data) {
             $value = $data->content;
             if ($value === '') {
                 continue;
             }
             $usedoptions[$value] = $value;
         }
     }
     $options = array();
     foreach (explode("\n", $this->field->param1) as $option) {
         $option = trim($option);
         if (!isset($usedoptions[$option])) {
             continue;
         }
         $options[$option] = $option;
     }
     if (!$options) {
         // oh, nothing to search for
         return '';
     }
     $return = html_writer::label(get_string('namemenu', 'data'), 'menuf_' . $this->field->id, false, array('class' => 'accesshide'));
     $return .= html_writer::select($options, 'f_' . $this->field->id, $content);
     return $return;
 }
Esempio n. 24
0
 /**
  * Render a series of section links.
  *
  * @param stdClass $course The course we are rendering for.
  * @param array $sections An array of section objects to render.
  * @param bool|int The section to provide a jump to link for.
  * @return string The HTML to display.
  */
 public function render_section_links(stdClass $course, array $sections, $jumptosection = false)
 {
     $html = html_writer::start_tag('ol', array('class' => 'inline-list'));
     foreach ($sections as $section) {
         $attributes = array();
         if (!$section->visible) {
             $attributes['class'] = 'dimmed';
         }
         $html .= html_writer::start_tag('li');
         $sectiontext = $section->section;
         if ($section->highlight) {
             $sectiontext = html_writer::tag('strong', $sectiontext);
         }
         $html .= html_writer::link(course_get_url($course, $section->section), $sectiontext, $attributes);
         $html .= html_writer::end_tag('li') . ' ';
     }
     $html .= html_writer::end_tag('ol');
     if ($jumptosection && isset($sections[$jumptosection])) {
         if ($course->format == 'weeks') {
             $linktext = new lang_string('jumptocurrentweek', 'block_section_links');
         } else {
             if ($course->format == 'topics') {
                 $linktext = new lang_string('jumptocurrenttopic', 'block_section_links');
             }
         }
         $attributes = array();
         if (!$sections[$jumptosection]->visible) {
             $attributes['class'] = 'dimmed';
         }
         $html .= html_writer::link(course_get_url($course, $jumptosection), $linktext, $attributes);
     }
     return $html;
 }
Esempio n. 25
0
function block_advance_print_page($advance, $return = false)
{
    //add page title
    global $OUTPUT, $COURSE;
    $display = $OUTPUT->heading($advance->pagetitle);
    $display .= $OUTPUT->box_start();
    //date display
    if ($advance->displaydate) {
        $display .= html_writer::start_tag('div', array('class' => 'advance displaydate'));
        $display .= userdate($advance->displaydate);
        $display .= html_writer::end_tag('div');
    }
    //display text
    $display .= clean_text($advance->displaytext);
    //close the box
    $display .= $OUTPUT->box_end();
    //display picture
    if ($advance->displaypicture) {
        $display .= $OUTPUT->box_start();
        $images = block_advance_images();
        $display .= $images[$advance->picture];
        $display .= html_writer::start_tag('p');
        $display .= clean_text($advance->description);
        $display .= html_writer::end_tag('p');
        $display .= $OUTPUT->box_end();
    }
    //display it
    if ($return) {
        return $display;
    } else {
        echo $display;
    }
}
Esempio n. 26
0
    /**
     * Either returns the parent version of the header bar, or a version with the logo replacing the header.
     *
     * @since Moodle 2.9
     * @param array $headerinfo An array of header information, dependant on what type of header is being displayed. The following
     *                          array example is user specific.
     *                          heading => Override the page heading.
     *                          user => User object.
     *                          usercontext => user context.
     * @param int $headinglevel What level the 'h' tag will be.
     * @return string HTML for the header bar.
     */
    public function context_header($headerinfo = null, $headinglevel = 1) {

        if ($this->should_render_logo($headinglevel)) {
            return html_writer::tag('div', '', array('class' => 'logo'));
        }
        return parent::context_header($headerinfo, $headinglevel);
    }
 public function display_browse_field($recordid, $template)
 {
     global $DB, $CFG;
     if ($content = $DB->get_record('data_content', array('fieldid' => $this->field->id, 'recordid' => $recordid))) {
         if (empty($content->content)) {
             return false;
         }
         $options = explode("\n", $this->field->param1);
         $options = array_map('trim', $options);
         $contentarray = explode('##', $content->content);
         $str = '';
         foreach ($contentarray as $line) {
             if (!in_array($line, $options)) {
                 // Somebody edited the field definition.
                 continue;
             }
             $params = array("f_{$this->field->id}" => $line, 'd' => $this->data->id, 'advanced' => 1);
             $url = new moodle_url('/mod/data/view.php', $params);
             $link = html_writer::link($url, $line);
             $str .= $link . "<br />\n";
         }
         return $str;
     }
     return false;
 }
Esempio n. 28
-1
    /**
     * Internal function - creates htmls structure suitable for YUI tree.
     */
    protected function htmllize_tree($tree, $dir) {
        global $CFG;

        if (empty($dir['subdirs']) and empty($dir['files'])) {
            return '';
        }
        $result = '<ul>';
        foreach ($dir['subdirs'] as $subdir) {
            $image = $this->output->pix_icon(file_folder_icon(24), $subdir['dirname'], 'moodle');
            $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')).
                    html_writer::tag('span', s($subdir['dirname']), array('class' => 'fp-filename'));
            $filename = html_writer::tag('div', $filename, array('class' => 'fp-filename-icon'));
            $result .= html_writer::tag('li', $filename. $this->htmllize_tree($tree, $subdir));
        }
        foreach ($dir['files'] as $file) {
            $filename = $file->get_filename();
            $url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(),
                    $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $filename, false);
            if (file_extension_in_typegroup($filename, 'web_image')) {
                $image = $url->out(false, array('preview' => 'tinyicon', 'oid' => $file->get_timemodified()));
                $image = html_writer::empty_tag('img', array('src' => $image));
            } else {
                $image = $this->output->pix_icon(file_file_icon($file, 24), $filename, 'moodle');
            }
            $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')).
                    html_writer::tag('span', $filename, array('class' => 'fp-filename'));
            $filename = html_writer::tag('span',
                    html_writer::link($url->out(false, array('forcedownload' => 1)), $filename),
                    array('class' => 'fp-filename-icon'));
            $result .= html_writer::tag('li', $filename);
        }
        $result .= '</ul>';

        return $result;
    }
Esempio n. 29
-1
function blockqueries_tablecontent($sql){
     global $CFG, $USER, $PAGE, $DB;
     $blockqueries_displaycontent = array();
          $querieslists=$DB->get_records_sql($sql); 
          $data = array();
            foreach($querieslists as $querieslist){
              $row = array();
              $adminqueryid = $querieslist->id;
              $row[] = html_writer:: tag('p',$querieslist->subject,array());
              $comment_image = html_writer:: empty_tag('img',array('src'=>$CFG->wwwroot.'/pix/t/message.svg',"id"=>"showDialog$adminqueryid",'title'=>get_string('addacomment','block_queries'),'onclick'=>"mycommentpopupform($adminqueryid)",'class'=>'queries_iconclass'));
              $comment_popup = commenthtmlform($adminqueryid);
              $row[] = $comment_image.$comment_popup;
              $data[] = $row;
            }
          
          $table = new html_table();
          $table->head  = array(get_string('subjectt','block_queries'),get_string('comment','block_queries'));
          $table->width = '100%';
          $table->size = array('95%','5%');
          $table->align = array('left','center');
          $table->data  = $data;
         
          $blockqueries_displaycontent[] = html_writer::table($table);
          $blockqueries_displaycontent[] = html_writer:: tag('a',get_string('mypreviewqueries','block_queries'),array('href'=>$CFG->wwwroot.'/blocks/queries/display_queries.php'));
          $blockqueries_displaycontent = implode('',$blockqueries_displaycontent);
         
  return    $blockqueries_displaycontent;
}
Esempio n. 30
-2
 function attendance_alerts($userid)
 {
     global $DB;
     $sessions_sql = "SELECT ff.*, fsd.*, ffs.id AS sessid\n                           FROM {facetoface} as ff\n                           JOIN {facetoface_sessions} as ffs\n                             ON ffs.facetoface = ff.id\n                           JOIN {facetoface_sessions_dates} as fsd\n                             ON fsd.sessionid = ffs.id\n                          WHERE ff.trainerid = :traineeid\n                            AND ffs.attendence_status = :status\n                          LIMIT 5\n                        ";
     $sessions = $DB->get_records_sql($sessions_sql, array('traineeid' => $userid, 'status' => 0));
     if (empty($sessions)) {
         return get_string('nosessions', 'block_attendance');
     } else {
         $table = new html_table();
         $table->id = 'trainerfeedbak_batches';
         $table->width = '100%';
         $table->head = array(get_string('sessiondetails', 'block_attendance'), '');
         foreach ($sessions as $session) {
             $row = array();
             $sess_data = html_writer::start_tag('ul');
             $sess_data .= html_writer::tag('li', $session->name);
             $session_date = date('d/m/y', $session->timestart) . ' - ' . date('d/m/y', $session->timefinish);
             $sess_data .= html_writer::tag('li', $session_date);
             $sess_data .= html_writer::end_tag('ul');
             $row[] = $sess_data;
             $session_url = new moodle_url('/mod/facetoface/attendence.php', array('s' => $session->sessid));
             $row[] = html_writer::link($session_url, get_string('view'));
             $table->data[] = $row;
         }
         return html_writer::table($table);
     }
 }