}
$region = $page->blocks->get_default_region();
- $weight = $DB->get_field_sql("SELECT MAX(weight) FROM {block_instances}
+ $weight = $DB->get_field_sql("SELECT MAX(defaultweight) FROM {block_instances}
WHERE contextid = ? AND defaultregion = ?", array($page->context->id, $region));
$pagetypepattern = $page->pagetype;
if (strpos($pagetypepattern, 'course-view') === 0) {
$strblocks = '<div class="title"><h2>';
$strblocks .= get_string('blocks');
$strblocks .= '</h2></div>';
+
$stradd = get_string('add');
foreach ($missingblocks as $blockid) {
$block = blocks_get_record($blockid);
$blockobject = block_instance($block->name);
- if ($blockobject === false) {
- continue;
- }
- if(!$blockobject->user_can_addto($page)) {
- continue;
+ if ($blockobject !== false && $blockobject->user_can_addto($page)) {
+ $menu[$block->id] = $blockobject->get_title();
}
- $menu[$block->id] = $blockobject->get_title();
}
- asort($menu);
+ asort($menu, SORT_LOCALE_STRING);
- $target = $page->url->out(array('sesskey' => sesskey(), 'blockaction' => 'add'));
+ $target = $page->url->out(false, array('sesskey' => sesskey(), 'blockaction' => 'add'));
$content = popup_form($target.'&blockid=', $menu, 'add_block', '', $stradd .'...', '', '', true);
print_side_block($strblocks, $content, NULL, NULL, NULL, array('class' => 'block_adminblock'));
}
/**
* Output url
*
- * @param boolean $noquerystring whether to output page params as a query string in the url.
+ * @param boolean $omitquerystring whether to output page params as a query string in the url.
* @param array $overrideparams params to add to the output url, these override existing ones with the same name.
* @return string url
*/
- public function out($noquerystring = false, $overrideparams = array()) {
+ public function out($omitquerystring = false, $overrideparams = array()) {
$uri = $this->scheme ? $this->scheme.':'.((strtolower($this->scheme) == 'mailto') ? '':'//'): '';
$uri .= $this->user ? $this->user.($this->pass? ':'.$this->pass:'').'@':'';
$uri .= $this->host ? $this->host : '';
$uri .= $this->port ? ':'.$this->port : '';
$uri .= $this->path ? $this->path : '';
- if (!$noquerystring) {
- $uri .= (count($this->params)||count($overrideparams)) ? '?'.$this->get_query_string($overrideparams) : '';
+ if (!$omitquerystring) {
+ $querystring = $this->get_query_string($overrideparams);
+ if ($querystring) {
+ $uri .= '?' . $querystring;
+ }
}
$uri .= $this->fragment ? '#'.$this->fragment : '';
return $uri;