Builds Output Code by loading a Template or with built-in Template.
@access		protected
@param		string		$heading		Table Row of Heading
@param		string		$weekdays		Table Row of Weekdays
@param		string		$weeks			Table Rows of Weeks
@return		string
436384
protected function getCode( $heading, $weekdays, $weeks )
	{
		if( $template = $this->getOption( 'template' ) )
		{
			$options	= $this->getOptions();
			require( $template );
		}
		else
		{
			$clearFix	= UI_HTML_Tag::create( 'div', "", array( 'style' => 'clear: both' ) );
			$content	= UI_HTML_Tag::create( 'div', $heading.$weekdays.$weeks.$clearFix, array( 'class' => 'calendar' ) );
		}
		return $content;
	}
976147
function(workingDate, html) {

        var startDay = this.cfg.getProperty(DEF_CFG.START_WEEKDAY.key);

        this.preMonthDays = workingDate.getDay();
        if (startDay > 0) {
            this.preMonthDays -= startDay;
        }
        if (this.preMonthDays < 0) {
            this.preMonthDays += 7;
        }

        this.monthDays = DateMath.findMonthEnd(workingDate).getDate();
        this.postMonthDays = Calendar.DISPLAY_DAYS-this.preMonthDays-this.monthDays;


        workingDate = DateMath.subtract(workingDate, DateMath.DAY, this.preMonthDays);
    
        var weekNum,
            weekClass,
            weekPrefix = "w",
            cellPrefix = "_cell",
            workingDayPrefix = "wd",
            dayPrefix = "d",
            cellRenderers,
            renderer,
            t = this.today,
            cfg = this.cfg,
            todayYear = t.getFullYear(),
            todayMonth = t.getMonth(),
            todayDate = t.getDate(),
            useDate = cfg.getProperty(DEF_CFG.PAGEDATE.key),
            hideBlankWeeks = cfg.getProperty(DEF_CFG.HIDE_BLANK_WEEKS.key),
            showWeekFooter = cfg.getProperty(DEF_CFG.SHOW_WEEK_FOOTER.key),
            showWeekHeader = cfg.getProperty(DEF_CFG.SHOW_WEEK_HEADER.key),
            mindate = cfg.getProperty(DEF_CFG.MINDATE.key),
            maxdate = cfg.getProperty(DEF_CFG.MAXDATE.key),
            yearOffset = this.Locale.YEAR_OFFSET;

        if (mindate) {
            mindate = DateMath.clearTime(mindate);
        }
        if (maxdate) {
            maxdate = DateMath.clearTime(maxdate);
        }

        html[html.length] = '<tbody class="m' + (useDate.getMonth()+1) + ' ' + this.Style.CSS_BODY + '">';

        var i = 0,
            tempDiv = document.createElement("div"),
            cell = document.createElement("td");

        tempDiv.appendChild(cell);

        var cal = this.parent || this;

        for (var r=0;r<6;r++) {
            weekNum = DateMath.getWeekNumber(workingDate, startDay);
            weekClass = weekPrefix + weekNum;

            // Local OOM check for performance, since we already have pagedate
            if (r !== 0 && hideBlankWeeks === true && workingDate.getMonth() != useDate.getMonth()) {
                break;
            } else {
                html[html.length] = '<tr class="' + weekClass + '">';

                if (showWeekHeader) { html = this.renderRowHeader(weekNum, html); }

                for (var d=0; d < 7; d++){ // Render actual days

                    cellRenderers = [];

                    this.clearElement(cell);
                    cell.className = this.Style.CSS_CELL;
                    cell.id = this.id + cellPrefix + i;

                    if (workingDate.getDate()  == todayDate && 
                        workingDate.getMonth()  == todayMonth &&
                        workingDate.getFullYear() == todayYear) {
                        cellRenderers[cellRenderers.length]=cal.renderCellStyleToday;
                    }

                    var workingArray = [workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()];
                    this.cellDates[this.cellDates.length] = workingArray; // Add this date to cellDates

                    // Local OOM check for performance, since we already have pagedate
                    if (workingDate.getMonth() != useDate.getMonth()) {
                        cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth;
                    } else {
                        Dom.addClass(cell, workingDayPrefix + workingDate.getDay());
                        Dom.addClass(cell, dayPrefix + workingDate.getDate());

                        for (var s=0;s<this.renderStack.length;++s) {

                            renderer = null;

                            var rArray = this.renderStack[s],
                                type = rArray[0],
                                month,
                                day,
                                year;

                            switch (type) {
                                case Calendar.DATE:
                                    month = rArray[1][1];
                                    day = rArray[1][2];
                                    year = rArray[1][0];

                                    if (workingDate.getMonth()+1 == month && workingDate.getDate() == day && workingDate.getFullYear() == year) {
                                        renderer = rArray[2];
                                        this.renderStack.splice(s,1);
                                    }
                                    break;
                                case Calendar.MONTH_DAY:
                                    month = rArray[1][0];
                                    day = rArray[1][1];

                                    if (workingDate.getMonth()+1 == month && workingDate.getDate() == day) {
                                        renderer = rArray[2];
                                        this.renderStack.splice(s,1);
                                    }
                                    break;
                                case Calendar.RANGE:
                                    var date1 = rArray[1][0],
                                        date2 = rArray[1][1],
                                        d1month = date1[1],
                                        d1day = date1[2],
                                        d1year = date1[0],
                                        d1 = DateMath.getDate(d1year, d1month-1, d1day),
                                        d2month = date2[1],
                                        d2day = date2[2],
                                        d2year = date2[0],
                                        d2 = DateMath.getDate(d2year, d2month-1, d2day);

                                    if (workingDate.getTime() >= d1.getTime() && workingDate.getTime() <= d2.getTime()) {
                                        renderer = rArray[2];

                                        if (workingDate.getTime()==d2.getTime()) { 
                                            this.renderStack.splice(s,1);
                                        }
                                    }
                                    break;
                                case Calendar.WEEKDAY:
                                    var weekday = rArray[1][0];
                                    if (workingDate.getDay()+1 == weekday) {
                                        renderer = rArray[2];
                                    }
                                    break;
                                case Calendar.MONTH:
                                    month = rArray[1][0];
                                    if (workingDate.getMonth()+1 == month) {
                                        renderer = rArray[2];
                                    }
                                    break;
                            }

                            if (renderer) {
                                cellRenderers[cellRenderers.length]=renderer;
                            }
                        }

                    }

                    if (this._indexOfSelectedFieldArray(workingArray) > -1) {
                        cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected; 
                    }

                    if ((mindate && (workingDate.getTime() < mindate.getTime())) ||
                        (maxdate && (workingDate.getTime() > maxdate.getTime()))
                    ) {
                        cellRenderers[cellRenderers.length]=cal.renderOutOfBoundsDate;
                    } else {
                        cellRenderers[cellRenderers.length]=cal.styleCellDefault;
                        cellRenderers[cellRenderers.length]=cal.renderCellDefault; 
                    }

                    for (var x=0; x < cellRenderers.length; ++x) {
                        if (cellRenderers[x].call(cal, workingDate, cell) == Calendar.STOP_RENDER) {
                            break;
                        }
                    }

                    workingDate.setTime(workingDate.getTime() + DateMath.ONE_DAY_MS);
                    // Just in case we crossed DST/Summertime boundaries
                    workingDate = DateMath.clearTime(workingDate);

                    if (i >= 0 && i <= 6) {
                        Dom.addClass(cell, this.Style.CSS_CELL_TOP);
                    }
                    if ((i % 7) === 0) {
                        Dom.addClass(cell, this.Style.CSS_CELL_LEFT);
                    }
                    if (((i+1) % 7) === 0) {
                        Dom.addClass(cell, this.Style.CSS_CELL_RIGHT);
                    }

                    var postDays = this.postMonthDays; 
                    if (hideBlankWeeks && postDays >= 7) {
                        var blankWeeks = Math.floor(postDays/7);
                        for (var p=0;p<blankWeeks;++p) {
                            postDays -= 7;
                        }
                    }
                    
                    if (i >= ((this.preMonthDays+postDays+this.monthDays)-7)) {
                        Dom.addClass(cell, this.Style.CSS_CELL_BOTTOM);
                    }
    
                    html[html.length] = tempDiv.innerHTML;
                    i++;
                }
    
                if (showWeekFooter) { html = this.renderRowFooter(weekNum, html); }
    
                html[html.length] = '</tr>';
            }
        }
    
        html[html.length] = '</tbody>';
    
        return html;
    }
67940
function(html) {

        html[html.length] = '<tr class="' + this.Style.CSS_WEEKDAY_ROW + '">';

        if (this.cfg.getProperty(DEF_CFG.SHOW_WEEK_HEADER.key)) {
            html[html.length] = '<th>&#160;</th>';
        }

        for(var i=0;i < this.Locale.LOCALE_WEEKDAYS.length; ++i) {
            html[html.length] = '<th class="' + this.Style.CSS_WEEKDAY_CELL + '">' + this.Locale.LOCALE_WEEKDAYS[i] + '</th>';
        }

        if (this.cfg.getProperty(DEF_CFG.SHOW_WEEK_FOOTER.key)) {
            html[html.length] = '<th>&#160;</th>';
        }

        html[html.length] = '</tr>';

        return html;
    }
680570
public function setDayOfWeek($dayOfWeek)
    {
        if (!preg_match(self::$_regex['dayOfWeek'], $dayOfWeek)) {
            throw new \InvalidArgumentException(sprintf('DayOfWeek "%s" is incorect', $dayOfWeek));
        }

        $this->dayOfWeek = $dayOfWeek;

        return $this->generateHash();
    }
439341
protected function get_weeks(renderer_base $output) {
        $weeks = [];
        $alldays = $this->get_days();

        $daysinweek = count($this->related['type']->get_weekdays());

        // Calculate which day number is the first, and last day of the week.
        $firstdayofweek = $this->firstdayofweek;

        // The first week is special as it may have padding at the beginning.
        $day = reset($alldays);
        $firstdayno = $day['wday'];

        $prepadding = ($firstdayno + $daysinweek - $firstdayofweek) % $daysinweek;
        $daysinfirstweek = $daysinweek - $prepadding;
        $days = array_slice($alldays, 0, $daysinfirstweek);
        $week = new week_exporter($this->calendar, $days, $prepadding, ($daysinweek - count($days) - $prepadding), $this->related);
        $weeks[] = $week->export($output);

        // Now chunk up the remaining day. and turn them into weeks.
        $daychunks = array_chunk(array_slice($alldays, $daysinfirstweek), $daysinweek);
        foreach ($daychunks as $days) {
            $week = new week_exporter($this->calendar, $days, 0, ($daysinweek - count($days)), $this->related);
            $weeks[] = $week->export($output);
        }

        return $weeks;
    }
1066236
public function setDaysExcluded(array $weekDays)
    {
        foreach ($weekDays as $wday) {
            DateBuilder::validateDayOfWeek($wday);
        }

        $this->setValue('excludeDays', $weekDays);
    }
379604
public function panel($headingHtml, $bodyHtml = null, $footerHtml = null, $options = array()) {
		$defaults = array(
			'class' => 'panel-default', 'headingOptions' => array(), 'footerOptions' => array(), 'bodyOptions' => array(),
			'wrapHeading' => true, 'wrapFooter' => true, 'wrapBody' => true
		);
		if ($this->_blockRendering) {
			$options = $bodyHtml;
		}
		$options = Hash::merge($defaults, $options);
		$options = $this->addClass($options, 'panel');

		if (!$this->_blockRendering) {
			$heading = $options['wrapHeading'] ? $this->panelHeading($headingHtml, $options['headingOptions']) : $headingHtml;
                        $footer = $options['wrapFooter'] && $footerHtml ? $this->panelFooter($footerHtml, $options['footerOptions']) : $footerHtml;
			$body = $options['wrapBody'] ? $this->panelBody($bodyHtml, $options['bodyOptions']) : $bodyHtml;
			$html = $heading . $body . $footer;
		} else {
			$html = $headingHtml;
		}

		unset($options['headingOptions'], $options['footerOptions'], $options['bodyOptions'], $options['wrapFooter'], $options['wrapHeading'], $options['wrapBody']);
		return $this->tag('div', $html, $options);
	}
11394
public void setWeekDays(SortedSet<WeekDay> weekDays) {

        final SortedSet<WeekDay> newWeekDays = null == weekDays ? new TreeSet<WeekDay>() : weekDays;
        SortedSet<WeekDay> currentWeekDays = m_model.getWeekDays();
        if (!currentWeekDays.equals(newWeekDays)) {
            conditionallyRemoveExceptionsOnChange(new Command() {

                public void execute() {

                    m_model.setWeekDays(newWeekDays);
                    onValueChange();
                }
            }, !newWeekDays.containsAll(m_model.getWeekDays()));
        }
    }
291788
public function withHeadings($headings = null)
    {
        $headings = \is_array($headings) ? $headings : \func_get_args();

        if (0 === count($headings)) {
            $this->headingCallback = $this->autoHeading();
        } else {
            $this->headingCallback = function () use ($headings) {
                return $headings;
            };
        }

        return $this;
    }
154717
function print_headers() {
        global $CFG, $OUTPUT, $PAGE;

        echo html_writer::start_tag('thead');
        echo html_writer::start_tag('tr');
        foreach ($this->columns as $column => $index) {

            $icon_hide = '';
            if ($this->is_collapsible) {
                $icon_hide = $this->show_hide_link($column, $index);
            }

            $primarysortcolumn = '';
            $primarysortorder  = '';
            if (reset($this->prefs['sortby'])) {
                $primarysortcolumn = key($this->prefs['sortby']);
                $primarysortorder  = current($this->prefs['sortby']);
            }

            switch ($column) {

                case 'fullname':
                    // Check the full name display for sortable fields.
                    if (has_capability('moodle/site:viewfullnames', $PAGE->context)) {
                        $nameformat = $CFG->alternativefullnameformat;
                    } else {
                        $nameformat = $CFG->fullnamedisplay;
                    }

                    if ($nameformat == 'language') {
                        $nameformat = get_string('fullnamedisplay');
                    }

                    $requirednames = order_in_string(get_all_user_name_fields(), $nameformat);

                    if (!empty($requirednames)) {
                        if ($this->is_sortable($column)) {
                            // Done this way for the possibility of more than two sortable full name display fields.
                            $this->headers[$index] = '';
                            foreach ($requirednames as $name) {
                                $sortname = $this->sort_link(get_string($name),
                                        $name, $primarysortcolumn === $name, $primarysortorder);
                                $this->headers[$index] .= $sortname . ' / ';
                            }
                            $helpicon = '';
                            if (isset($this->helpforheaders[$index])) {
                                $helpicon = $OUTPUT->render($this->helpforheaders[$index]);
                            }
                            $this->headers[$index] = substr($this->headers[$index], 0, -3). $helpicon;
                        }
                    }
                break;

                case 'userpic':
                    // do nothing, do not display sortable links
                break;

                default:
                    if ($this->is_sortable($column)) {
                        $helpicon = '';
                        if (isset($this->helpforheaders[$index])) {
                            $helpicon = $OUTPUT->render($this->helpforheaders[$index]);
                        }
                        $this->headers[$index] = $this->sort_link($this->headers[$index],
                                $column, $primarysortcolumn == $column, $primarysortorder) . $helpicon;
                    }
            }

            $attributes = array(
                'class' => 'header c' . $index . $this->column_class[$column],
                'scope' => 'col',
            );
            if ($this->headers[$index] === NULL) {
                $content = '&nbsp;';
            } else if (!empty($this->prefs['collapse'][$column])) {
                $content = $icon_hide;
            } else {
                if (is_array($this->column_style[$column])) {
                    $attributes['style'] = $this->make_styles_string($this->column_style[$column]);
                }
                $helpicon = '';
                if (isset($this->helpforheaders[$index]) && !$this->is_sortable($column)) {
                    $helpicon  = $OUTPUT->render($this->helpforheaders[$index]);
                }
                $content = $this->headers[$index] . $helpicon . html_writer::tag('div',
                        $icon_hide, array('class' => 'commands'));
            }
            echo html_writer::tag('th', $content, $attributes);
        }

        echo html_writer::end_tag('tr');
        echo html_writer::end_tag('thead');
    }
1164817
public static function heroUnit($heading, $content, $htmlOptions = array())
    {
        self::addCssClass('hero-unit', $htmlOptions);
        $headingOptions = TbArray::popValue('headingOptions', $htmlOptions, array());
        $output = self::openTag('div', $htmlOptions);
        $output .= self::tag('h1', $headingOptions, $heading);
        $output .= $content;
        $output .= '</div>';
        return $output;
    }
417587
public function output_html($data, $query='') {
        global $OUTPUT;

        // The order matters very much because of the implied numeric keys.
        $days = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
        $context = (object) [
            'name' => $this->get_full_name(),
            'id' => $this->get_id(),
            'days' => array_map(function($index) use ($days, $data) {
                return [
                    'index' => $index,
                    'label' => get_string($days[$index], 'calendar'),
                    'checked' => in_array($index, $data)
                ];
            }, array_keys($days))
        ];

        $element = $OUTPUT->render_from_template('core_admin/setting_special_calendar_weekend', $context);

        return format_admin_setting($this, $this->visiblename, $element, $this->description, false, '', NULL, $query);

    }
660503
public function daysOfWeek($daysOfWeek)
  {
    // Check for empty, string or no value
    if (empty($daysOfWeek) || is_string($daysOfWeek) === false || strlen($daysOfWeek) < 3) {

      // Return with a null parse
      return null;
    }

    // Separate days of the week by comma
    $daysOfWeek = explode(',', $daysOfWeek);

    // Allowed values
    $allowedValues = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];

    // Make sure each day of week
    foreach ($daysOfWeek as $dayOfWeek) {

      // Is an allowed value
      if (in_array($dayOfWeek, $allowedValues) === false) {

        // Otherwise return with a null parse
        return null;
      }
    }

    // Return days of the week
    return $daysOfWeek;
  }
450932
public final void setWeekDay(WeekDay weekDay) {

        SortedSet<WeekDay> wds = new TreeSet<>();
        if (null != weekDay) {
            wds.add(weekDay);
        }
        setWeekDays(wds);

    }
749696
public function weeks($startDay = 'Monday')
    {
        if (!isset($this->weeks[$startDay])) {
            $this->weeks[$startDay] = array();
            $keepWeeking = true;
            $weekPoint = clone $this->firstDay();

            while ($keepWeeking) {
                $candidateWeek = new Week($weekPoint, $startDay);
                if ($candidateWeek->weekStart() <= $this->lastDay()) {
                    $candidateWeek->setContainingMonth($this);
                    $this->weeks[$startDay][] = $candidateWeek;
                    $weekPoint->modify('+1 week');
                } else {
                    $keepWeeking = false;
                }
            }
        }
        return $this->weeks[$startDay];
    }
863625
public function generate($headings)
    {
        /** @var Entry $previous */
        $root = $previous = new RootEntry();
        foreach ($headings as $heading) {
            if ($heading->getLevel() < $previous->getLevel()) {
                $parent = $previous;
                do {
                    $parent = $parent->getParent();
                } while ($heading->getLevel() <= $parent->getLevel() && $parent->getLevel() != 0);

                $parent->addChild($heading);
                $previous = $heading;
                continue;
            }


            if ($heading->getLevel() > $previous->getLevel()) {
                $previous->addChild($heading);
                $previous = $heading;
                continue;
            }

            //if ($heading->getLevel() == $previous->getLevel()) {
            $previous->getParent()->addChild($heading);
            $previous = $heading;
            continue;
            //}
        }

        return $root;
    }
1287411
protected function writeTable(array $headers, array $rows)
    {
        $columnCount = count($headers);
        $rowCount = count($rows) + 1;
        $columns = array_fill(0, $columnCount, 0);
        $tables = [];

        foreach (array_merge([$headers], $rows) as $row) {
            $i = -1;
            $newRow = [];
            foreach ($row as $col) {
                $newRow[++$i] = StringParser::create($col)->getParsed();
                $newRow[$i]['len'] = 0;
                foreach ($newRow[$i] as $part) {
                    $newRow[$i]['len'] += strlen($part['original']);
                }
                $columns[$i] = max($columns[$i], $newRow[$i]['len']);
            }
            $tables[] = $newRow;
        }

        $i = -1;
        $line = str_repeat('-', array_sum($columns) + $columnCount + 2);
        foreach ($tables as $row) {
            if (++$i === 0) {
                echo $line . PHP_EOL;
            }
            $j = -1;
            foreach ($row as $col) {
                ++$j;
                $len = array_pop($col);
                foreach ($col as $part) {
                    echo ' ' . $part['colored'];
                    echo str_repeat(' ', $columns[$j] - $len + 1);
                }
            }

            if ($i === 0) {
                echo PHP_EOL;
                echo $line;
            }

            echo PHP_EOL;
            if ($i === $rowCount - 1) {
                echo $line . PHP_EOL;
            }
        }
    }