';
+
+ for ($i = 1; $i <= 5; $i++) {
+ $blockrowsetting = $layoutrow . $i;
+ $blockrowvalue = $themesettings->$blockrowsetting;
+ if ($blockrowvalue != '0-0-0-0') {
+ $blockrows[] = $blockrowvalue;
+ }
+ }
+
+ foreach ($blockrows as $blockrow) {
+ $blocksequence[] = '+'; // Row start.
+ $vals = explode('-', $blockrow);
+ foreach ($vals as $val) {
+ if ($val > 0) {
+ $blocksequence[] = $val; // Block width.
+ $blockspacescount++;
+ }
+ }
+ $blocksequence[] = '-'; // Row end.
+ }
+ }
+
+ $blockspacesexceeded = false;
+ $blockcount = 0;
+ foreach ($blockcontents as $bc) {
+ if ($bc instanceof block_contents) {
+ if (!$editing) {
+ if (!empty($blocksequence[$blocksequencecount])) {
+ if ($blocksequence[$blocksequencecount] == '+') {
+ $content .= '
';
+ $blocksequencecount++;
+ }
+ $bc->attributes['class'] .= ' col-'.$blocksequence[$blocksequencecount]; // Will be a number.
+ } else {
+ if ((!$blockspacesexceeded) && ($blockcount >= $blockspacescount)) {
+ $blockspacesexceeded = true;
+ html_writer::tag(
+ 'p',
+ get_string('flexibleblocksoverflow', 'theme_adaptable'),
+ ['class' => 'block-region-overflow col-12 text-center font-italic font-weight-bold']
+ );
+ $content .= '
';
+ if (is_siteadmin()) {
+ $content .= html_writer::tag(
+ 'p',
+ get_string('flexibleblocksoverflow', 'theme_adaptable'),
+ ['class' => 'block-region-overflow col-12 text-center font-italic font-weight-bold']
+ );
+ }
+ }
+ $bc->attributes['class'] .= ' col-4';
+ }
+ $bc->attributes['notitle'] = true;
+ }
+ $content .= $this->block($bc, $region);
+ $lastblock = $bc->title;
+ $blockcount++;
+ if ((!$editing) && (!$blockspacesexceeded)) {
+ $blocksequencecount++;
+ // Could be a end of row next.
+ if ($blocksequence[$blocksequencecount] == '-') {
+ $content .= '
';
+ $blocksequencecount++;
+ }
+ }
+ } else if ($bc instanceof block_move_target) {
+ $content .= $this->block_move_target($bc, $zones, $lastblock, $region);
+ } else {
+ throw new coding_exception(
+ 'Unexpected type of thing (' . get_class($bc) . ') found in list of block contents.');
+ }
+ }
+
+ if (!$editing) {
+ if ($blockspacesexceeded) {
+ $content .= '
'; // End of flexible-blocks-overflow.
+ }
+ $content .= '