Renders HTML to show course module availability information (for someone who isn't allowed
to see the activity itself, or for staff)

@param cm_info $mod
@param array $displayoptions
@return string
766546
public function course_section_cm_availability(cm_info $mod, $displayoptions = array()) {
        global $CFG;
        $output = '';
        if (!$mod->is_visible_on_course_page()) {
            return $output;
        }
        if (!$mod->uservisible) {
            // this is a student who is not allowed to see the module but might be allowed
            // to see availability info (i.e. "Available from ...")
            if (!empty($mod->availableinfo)) {
                $formattedinfo = \core_availability\info::format_info(
                        $mod->availableinfo, $mod->get_course());
                $output = $this->availability_info($formattedinfo, 'isrestricted');
            }
            return $output;
        }
        // this is a teacher who is allowed to see module but still should see the
        // information that module is not available to all/some students
        $modcontext = context_module::instance($mod->id);
        $canviewhidden = has_capability('moodle/course:viewhiddenactivities', $modcontext);
        if ($canviewhidden && !$mod->visible) {
            // This module is hidden but current user has capability to see it.
            // Do not display the availability info if the whole section is hidden.
            if ($mod->get_section_info()->visible) {
                $output .= $this->availability_info(get_string('hiddenfromstudents'), 'ishidden');
            }
        } else if ($mod->is_stealth()) {
            // This module is available but is normally not displayed on the course page
            // (this user can see it because they can manage it).
            $output .= $this->availability_info(get_string('hiddenoncoursepage'), 'isstealth');
        }
        if ($canviewhidden && !empty($CFG->enableavailability)) {
            // Display information about conditional availability.
            // Don't add availability information if user is not editing and activity is hidden.
            if ($mod->visible || $this->page->user_is_editing()) {
                $hidinfoclass = 'isrestricted isfullinfo';
                if (!$mod->visible) {
                    $hidinfoclass .= ' hide';
                }
                $ci = new \core_availability\info_module($mod);
                $fullinfo = $ci->get_full_information();
                if ($fullinfo) {
                    $formattedinfo = \core_availability\info::format_info(
                            $fullinfo, $mod->get_course());
                    $output .= $this->availability_info($formattedinfo, $hidinfoclass);
                }
            }
        }
        return $output;
    }
1175560
public static function modalHeader($content, $htmlOptions = array())
    {
        self::addCssClass('modal-header', $htmlOptions);
        $closeOptions = TbArray::popValue('closeOptions', $htmlOptions, array());
        $closeOptions['dismiss'] = 'modal';
        $headingOptions = TbArray::popValue('headingOptions', $htmlOptions, array());
        $closeLabel = TbArray::popValue('closeLabel', $htmlOptions, self::CLOSE_TEXT);
        $closeButton = self::closeButton($closeLabel, $closeOptions);
        self::addCssClass('modal-title', $headingOptions);
        $header = self::tag('h4', $headingOptions, $content);
        return self::tag('div', $htmlOptions, $closeButton . $header);
    }
1343500
public function get_single_discussion_posts_renderer(int $displaymode = null, bool $readonly = false) : posts_renderer {
        $exportedpostssorter = $this->entityfactory->get_exported_posts_sorter();

        switch ($displaymode) {
            case FORUM_MODE_THREADED:
                $template = 'mod_forum/forum_discussion_threaded_posts';
                break;
            case FORUM_MODE_NESTED:
                $template = 'mod_forum/forum_discussion_nested_posts';
                break;
            default;
                $template = 'mod_forum/forum_discussion_posts';
                break;
        }

        return new posts_renderer(
            $this->rendererbase,
            $this->builderfactory->get_exported_posts_builder(),
            $template,
            // Post process the exported posts for our template. This function will add the "replies"
            // and "hasreplies" properties to the exported posts. It will also sort them into the
            // reply tree structure if the display mode requires it.
            function($exportedposts, $forums) use ($displaymode, $readonly, $exportedpostssorter) {
                $forum = array_shift($forums);
                $seenfirstunread = false;
                $postcount = count($exportedposts);
                $exportedposts = array_map(
                    function($exportedpost) use ($forum, $readonly, $seenfirstunread) {
                        if ($forum->get_type() == 'single' && !$exportedpost->hasparent) {
                            // Remove the author from any posts that don't have a parent.
                            unset($exportedpost->author);
                            unset($exportedpost->html['authorsubheading']);
                        }

                        $exportedpost->firstpost = false;
                        $exportedpost->readonly = $readonly;
                        $exportedpost->hasreplycount = false;
                        $exportedpost->hasreplies = false;
                        $exportedpost->replies = [];

                        $exportedpost->isfirstunread = false;
                        if (!$seenfirstunread && $exportedpost->unread) {
                            $exportedpost->isfirstunread = true;
                            $seenfirstunread = true;
                        }

                        return $exportedpost;
                    },
                    $exportedposts
                );

                if ($displaymode === FORUM_MODE_NESTED || $displaymode === FORUM_MODE_THREADED) {
                    $sortedposts = $exportedpostssorter->sort_into_children($exportedposts);
                    $sortintoreplies = function($nestedposts) use (&$sortintoreplies) {
                        return array_map(function($postdata) use (&$sortintoreplies) {
                            [$post, $replies] = $postdata;
                            $sortedreplies = $sortintoreplies($replies);
                            // Set the parent author name on the replies. This is used for screen
                            // readers to help them identify the structure of the discussion.
                            $sortedreplies = array_map(function($reply) use ($post) {
                                if (isset($post->author)) {
                                    $reply->parentauthorname = $post->author->fullname;
                                } else {
                                    // The only time the author won't be set is for a single discussion
                                    // forum. See above for where it gets unset.
                                    $reply->parentauthorname = get_string('firstpost', 'mod_forum');
                                }
                                return $reply;
                            }, $sortedreplies);
                            $post->replies = $sortedreplies;
                            $post->hasreplies = !empty($post->replies);
                            return $post;
                        }, $nestedposts);
                    };
                    // Set the "replies" property on the exported posts.
                    $exportedposts = $sortintoreplies($sortedposts);
                } else if ($displaymode === FORUM_MODE_FLATNEWEST || $displaymode === FORUM_MODE_FLATOLDEST) {
                    $exportedfirstpost = array_shift($exportedposts);
                    $exportedfirstpost->replies = $exportedposts;
                    $exportedfirstpost->hasreplies = true;
                    $exportedposts = [$exportedfirstpost];
                }

                if (!empty($exportedposts)) {
                    // Need to identify the first post so that we can use it in behat tests.
                    $exportedposts[0]->firstpost = true;
                    $exportedposts[0]->hasreplycount = true;
                    $exportedposts[0]->replycount = $postcount - 1;
                }

                return $exportedposts;
            }
        );
    }
773821
public function display() {
        global $PAGE, $COURSE;

        $this->require_definition_after_data();

        $config = new stdClass;
        if ($this->uistage->get_ui() instanceof import_ui) {
            $config->title = get_string('confirmcancelimport', 'backup');
        } else if ($this->uistage->get_ui() instanceof restore_ui) {
            $config->title = get_string('confirmcancelrestore', 'backup');
        } else {
            $config->title = get_string('confirmcancel', 'backup');
        }
        $config->question = get_string('confirmcancelquestion', 'backup');
        $config->yesLabel = $config->title;
        $config->noLabel = get_string('confirmcancelno', 'backup');
        $config->closeButtonTitle = get_string('close', 'editor');
        $PAGE->requires->yui_module(
            'moodle-backup-confirmcancel',
            'M.core_backup.confirmcancel.watch_cancel_buttons',
            array($config)
        );

        // Get list of module types on course.
        $modinfo = get_fast_modinfo($COURSE);
        $modnames = $modinfo->get_used_module_names(true);
        $PAGE->requires->yui_module('moodle-backup-backupselectall', 'M.core_backup.backupselectall',
                array($modnames));
        $PAGE->requires->strings_for_js(array('select', 'all', 'none'), 'moodle');
        $PAGE->requires->strings_for_js(array('showtypes', 'hidetypes'), 'backup');

        parent::display();
    }
1259478
public function summary_page($attemptobj, $displayoptions) {
        $output = '';
        $output .= $this->header();
        $output .= $this->heading(format_string($attemptobj->get_quiz_name()));
        $output .= $this->heading(get_string('summaryofattempt', 'quiz'), 3);
        $output .= $this->summary_table($attemptobj, $displayoptions);
        $output .= $this->summary_page_controls($attemptobj);
        $output .= $this->footer();
        return $output;
    }
728515
public function outputModule($module, $args = array(), $moduleSettings = array(), $echo = true)
    {
        if (!isset($args['id'])) {
            $args['id'] = 'no-id';
        }

        if (!is_object($module)) {
            return false;
        }

        $class = \Modularity\ModuleManager::$classes[$module->post_type];
        $module = new $class($module, $args);
        $module = $this->fillMissingParams($module, $moduleSettings);

        if (!$echo || !isset($moduleSettings['cache_ttl'])) {
            $moduleSettings['cache_ttl'] = 0;
        }

        $cache = new \Modularity\Helper\Cache($module->ID, array($module, $args['id']), $moduleSettings['cache_ttl']);

        if (empty($moduleSettings['cache_ttl']) || $cache->start()) {
            $moduleMarkup = $this->getModuleMarkup($module, $args);

            if (isset($module->columnWidth) && !empty($module->columnWidth)) {
                $moduleMarkup .= apply_filters('Modularity/Display/AfterModule', '</div>', $args, $module->post_type, $module->ID);
            } elseif (isset($this->options[$args['id']]['after_module']) && !empty($this->options[$args['id']]['after_module'])) {
                $moduleMarkup .= apply_filters('Modularity/Display/AfterModule', '</div>', $args, $module->post_type, $module->ID);
            } elseif (isset($args['after_widget'])) {
                $moduleMarkup .= apply_filters('Modularity/Display/AfterModule', $args['after_widget'], $args, $module->post_type, $module->ID);
            }

            $moduleMarkup = apply_filters('Modularity/Display/Markup', $moduleMarkup, $module);
            $moduleMarkup = apply_filters('Modularity/Display/' . $module->post_type . '/Markup', $moduleMarkup, $module);

            if (!$echo) {
                return $moduleMarkup;
            }

            echo $moduleMarkup;

            if (!empty($moduleSettings['cache_ttl'])) {
                $cache->stop();
            }
        }

        return true;
    }
504469
public String getDisplayForModule(CmsModule module) {

        String name = module.getNiceName();
        String group = module.getGroup();
        String version = module.getVersion().getVersion();
        String display = name;
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(group)) {
            display = group + ": " + display;
        }
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(version)) {
            display += " (" + version + ")";
        }
        return display;
    }
1009884
public function renderToolModulesAction()
    {
        $translator      = $this->getServiceLocator()->get('translator');
        $moduleSvc       =  $this->getServiceLocator()->get('ModulesService');
        $coreTool        =  $this->getServiceLocator()->get('MelisCoreTool');
        $modules         = $moduleSvc->getAllModules();

        $melisKey = $this->params()->fromRoute('melisKey', '');
        $noAccessPrompt = '';

        if(!$this->hasAccess('meliscore_tool_user_module_management')) {
            $noAccessPrompt = $translator->translate('tr_tool_no_access');
        }

        $request = $this->getRequest();
        $domain = isset($get['domain']) ? $get['domain'] : null;
        $scheme = isset($get['scheme']) ? $get['scheme'] : null;
        $melisKey = $this->params()->fromRoute('melisKey', '');
        $netStatus = $coreTool->isConnected();

        $view = new ViewModel();
        $view->melisKey = $melisKey;
        $view->modules = serialize($modules);
        $view->scheme  = $scheme;
        $view->domain  = $domain;
        $view->netStatus  = $netStatus;

        return $view;
    }
1326447
protected String htmlModule(CmsModule module, int pos) {

        StringBuffer html = new StringBuffer(256);
        html.append("\t<tr>\n");
        html.append("\t\t<td style='vertical-align: top;'>\n");
        html.append("\t\t\t<input type='checkbox' name='availableModules' value='");
        html.append(module.getName());
        html.append("' checked='checked' onClick=\"checkModuleDependencies('");
        html.append(module.getName());
        html.append("');\">\n");
        html.append("\t\t</td>\n");
        html.append("\t\t<td style='vertical-align: top; width: 100%; padding-top: 4px;'>\n\t\t\t");
        html.append(getDisplayForModule(module));
        html.append("\n\t\t</td>\n");
        html.append("\t\t<td style='vertical-align: top; text-align: right;'>\n");
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(module.getDescription())) {
            html.append("\t\t\t");
            html.append(getHtmlHelpIcon("" + pos, ""));
        }
        html.append("\t\t</td>\n");
        html.append("\t</tr>\n");
        return html.toString();
    }
676489
protected function display_mode() {

		// Get timestamp
		$timestamp  = mktime( 0, 0, 0, $this->month, 1, $this->year );
		$max_day    = date_i18n( 't', $timestamp );
		$this_month = getdate( $timestamp );
		$start_day  = $this_month['wday'];

		// Loop through days of the month
		for ( $i = 0; $i < ( $max_day + $start_day ); $i++ ) {

			// New row
			if ( ( $i % 7 ) === 0  ) {
				$this->get_row_start();
			}

			// Pad day
			if ( $i < $start_day ) {
				$this->get_row_pad( $i, $start_day );

			// Month day
			} else {
				$this->get_row_cell( $i, $start_day );
			}

			if ( ( $i % 7 ) === 6 ) {
				$this->get_row_end();
			}
		}
	}
1315846
public static function modalFooter($content, $htmlOptions = array())
    {
        self::addCssClass('modal-footer', $htmlOptions);
        return self::tag('div', $htmlOptions, $content);
    }
889746
public function display($content, $options = [])
    {
        if (!empty($options['form'])) {
            $view = !empty($options['view']) ? $options['view'] : '';
            return FormWrap::view($this->_block, $options, $this->displayView($view, '-form'));
        }

        $options = $options + ['random' => false, 'repeated_view' => true];
        $options['repeater_id'] = $content;
        $repeaterRows = PageBlockRepeaterData::loadRepeaterData($content, $options['version'], $options['random']);
        return $this->_renderDisplayView($options, $repeaterRows);
    }
1073109
public function display_options($options, $coursemoduleid, $vertical = false, $multiple = false) {
        $layoutclass = 'horizontal';
        if ($vertical) {
            $layoutclass = 'vertical';
        }
        $target = new moodle_url('/mod/choice/view.php');
        $attributes = array('method'=>'POST', 'action'=>$target, 'class'=> $layoutclass);
        $disabled = empty($options['previewonly']) ? array() : array('disabled' => 'disabled');

        $html = html_writer::start_tag('form', $attributes);
        $html .= html_writer::start_tag('ul', array('class' => 'choices list-unstyled unstyled'));

        $availableoption = count($options['options']);
        $choicecount = 0;
        foreach ($options['options'] as $option) {
            $choicecount++;
            $html .= html_writer::start_tag('li', array('class'=>'option'));
            if ($multiple) {
                $option->attributes->name = 'answer[]';
                $option->attributes->type = 'checkbox';
            } else {
                $option->attributes->name = 'answer';
                $option->attributes->type = 'radio';
            }
            $option->attributes->id = 'choice_'.$choicecount;
            $option->attributes->class = 'mx-1';

            $labeltext = $option->text;
            if (!empty($option->attributes->disabled)) {
                $labeltext .= ' ' . get_string('full', 'choice');
                $availableoption--;
            }

            $html .= html_writer::empty_tag('input', (array)$option->attributes + $disabled);
            $html .= html_writer::tag('label', $labeltext, array('for'=>$option->attributes->id));
            $html .= html_writer::end_tag('li');
        }
        $html .= html_writer::tag('li','', array('class'=>'clearfloat'));
        $html .= html_writer::end_tag('ul');
        $html .= html_writer::tag('div', '', array('class'=>'clearfloat'));
        $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
        $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'action', 'value'=>'makechoice'));
        $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'id', 'value'=>$coursemoduleid));

        if (empty($options['previewonly'])) {
            if (!empty($options['hascapability']) && ($options['hascapability'])) {
                if ($availableoption < 1) {
                    $html .= html_writer::tag('label', get_string('choicefull', 'choice'));
                } else {
                    $html .= html_writer::empty_tag('input', array(
                        'type' => 'submit',
                        'value' => get_string('savemychoice', 'choice'),
                        'class' => 'btn btn-primary'
                    ));
                }

                if (!empty($options['allowupdate']) && ($options['allowupdate'])) {
                    $url = new moodle_url('view.php',
                            array('id' => $coursemoduleid, 'action' => 'delchoice', 'sesskey' => sesskey()));
                    $html .= html_writer::link($url, get_string('removemychoice', 'choice'), array('class' => 'ml-1'));
                }
            } else {
                $html .= html_writer::tag('label', get_string('havetologin', 'choice'));
            }
        }

        $html .= html_writer::end_tag('ul');
        $html .= html_writer::end_tag('form');

        return $html;
    }
934774
public function accessible_skipto_links($displaycategorylisting, $displaycourselisting, $displaycoursedetail) {
        $html = html_writer::start_div('skiplinks accesshide');
        $url = new moodle_url($this->page->url);
        if ($displaycategorylisting) {
            $url->set_anchor('category-listing');
            $html .= html_writer::link($url, get_string('skiptocategorylisting'), array('class' => 'skip'));
        }
        if ($displaycourselisting) {
            $url->set_anchor('course-listing');
            $html .= html_writer::link($url, get_string('skiptocourselisting'), array('class' => 'skip'));
        }
        if ($displaycoursedetail) {
            $url->set_anchor('course-detail');
            $html .= html_writer::link($url, get_string('skiptocoursedetails'), array('class' => 'skip'));
        }
        $html .= html_writer::end_div();
        return $html;
    }
1249715
public void setDisplayMode(final DisplayMode displayMode) {
		getOrCreateComponentModel().displayMode = displayMode == null ? DisplayMode.OPEN_NEW_WINDOW : displayMode;
	}
789548
public function convertToDisplay($params=array())
    {
        $description ="";
        if (isset($params['text'])) {
            $description = $params['text'];


            $description = stripslashes($this->BBversHTML(htmlspecialchars($description)));//nl2br


            if(isset($params['type'])&& $params['type']=='commentaire'){
            	$so = new StringObject();
            	$description = $so->replaceUrl($description);
            }

            //$description = str_replace(array("\n\r", "\r\n", "\r", "\n"), "<br>", $description);
            /*$description = str_replace("\n\r", "--hop1--", $description);
            $description = str_replace("\r\n", "--hop2--", $description);
            $description = str_replace("\r", "--hop3--", $description);
            $description = str_replace("\n", "--hop4--", $description);*/

            $description = nl2br($description);

            $description = str_replace("###serveur###",  $this->getNomServeur(),  $description);

            $description = preg_replace("#\\[url=\"http\\://(.+)\"\\](.+)\\[/url\\]#isU", "<a href=\"http://\\1\">\\2</a>", $description);
            $description = preg_replace("#\\[url=&quot;http\\://(.+)&quot;\\](.+)\\[/url\\]#isU", "<a href=\"http://\\1\">\\2</a>", $description);
            $description = preg_replace("#\\[url=\\'http\\://(.+)\\'\\](.+)\\[/url\\]#isU", "<a href=\"http://\\1\">\\2</a>", $description);
            $description = preg_replace("#\\[url\=http\\://(.+)\\](.+)\\[/url\\]#isU", "<a href=\"http://\\1\">\\2</a>", $description);


            $description = preg_replace("#\\[url=\"(.+)\"\\](.+)\\[/url\\]#isU", "<a href=\"\\1\">\\2</a>", $description);
            $description = preg_replace("#\\[url=\\'(.+)\\'\\](.+)\\[/url\\]#isU", "<a href=\"\\1\">\\2</a>", $description);
            $description = preg_replace("#\\[url=(.+)\\](.+)\\[/url\\]#isU", "<a href=\"\\1\">\\2</a>", $description);

            //$description = preg_replace("#\\[url=\"(.+)\"\\](.+)\\[/url\\]#isU", "<a href='\\1'>\\2</a>", $description);
            $description = preg_replace("#\\[url\\](.+)\\[/url\\]#isU", "<a href=\"\">\\1</a>", $description);
            $description = preg_replace("#\\[url=\\](.+)\\[/url\\]#isU", "<a href=\"\">\\1</a>", $description);


            $description = preg_replace("#\\[urlExterne\\=\"http\\:\\/\\/(.+)\"\\](.+)\\[\\/urlExterne\\]#isU", "<a href=\"http://\\1\" target=\"_blank\" id='debug1'>\\2</a>", $description);
            $description = preg_replace("#\\[urlExterne\\=\\'http\\://(.+)\\'\\](.+)\\[/urlExterne\\]#isU", "<a href=\"http://\\1\" target=\"_blank\" id='debug2'>\\2</a>", $description);
            $description = preg_replace("#\\[urlExterne\\=http\\:\\/\\/(.+)\\](.+)\\[\\/urlExterne\\]#isU", "<a href=\"http://\\1\" target=\"_blank\" id='debug3'>\\2</a>", $description);

            $description = preg_replace("#\\[urlExterne\\=\"(.+)\"\\](.+)\\[/urlExterne\\]#isU", "<a href=\"\\1\" target=\"_blank\">\\2</a>", $description);
            $description = preg_replace("#\\[urlExterne\\=\\'(.+)\\'\\](.+)\\[/urlExterne\\]#isU", "<a href=\"\\1\" target=\"_blank\">\\2</a>", $description);
            $description = preg_replace("#\\[urlExterne\\=(.+)\\](.+)\\[/urlExterne\\]#isU", "<a href=\"\\1\" target=\"_blank\">\\2</a>", $description);

            $description = preg_replace("#\\[urlExterne\\](.+)\\[/urlExterne\\]#isU", "<a href=\"\" target=\"_blank\">\\1</a>", $description);
            $description = preg_replace("#\\[urlExterne=\\](.+)\\[/urlExterne\\]#isU", "<a href=\"\" target=\"_blank\">\\1</a>", $description);
            $description = preg_replace("#\\[iframe\\=(.+)\\](.+)\\[/iframe\\]#isU", "<iframe src=\"\\1\" width='425' height='349'>\\2</iframe>", $description);
            $description = preg_replace("#\\[lang\\=(.+)\\](.+)\\[/lang\\]#isU", "<span lang=\"\\1\">\\2</span>",  $description);

            $description = ($description);
        } else {
        	$this->messages->addError("Problème de conversion du texte, aucun texte spécifié pour la fonction convertToDisplay");
        	$this->messages->display();
            //echo "<br>attention le parametre 'text' n'est pas defini dans la fonction convertToDisplay.<br>";
            return false;
        }


        return $description;
    }
1343398
public function display($content, $options = [])
    {
        if (!empty($options['meta']) || !empty($options['pageBuilder'])) {
            $content = preg_replace_callback(
                '/{{\s*\$(?P<block>\w*)\s*}}/',
                function ($matches) {
                    return str_replace('"', "'", strip_tags(PageBuilder::block($matches['block'])));
                },
                $content
            );
            $content = str_replace('%page_name%', PageBuilder::pageName(), $content);
            $content = str_replace('%site_name%', config('coaster::site.name'), $content);
        }
        if (!empty($options['meta'])) {
            $content = trim(str_replace(PHP_EOL, ' ', $content));
            $content = preg_replace('/\s+/', ' ', $content);
            $content = htmlentities(strip_tags(html_entity_decode($content, ENT_QUOTES, 'UTF-8')));
            $content = StringHelper::cutString($content);
        }
        return parent::display($content, $options);
    }