Skip to content

Commit

Permalink
MDL-38309 Substitute usage of print_tabs() with renderable tabtree
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Apr 15, 2013
1 parent c269b9d commit a5f82c5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 40 deletions.
3 changes: 1 addition & 2 deletions admin/roles/managetabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
$toprow[] = new tabobject('assign', new moodle_url('/admin/roles/allow.php', array('mode'=>'assign')), get_string('allowassign', 'role'));
$toprow[] = new tabobject('override', new moodle_url('/admin/roles/allow.php', array('mode'=>'override')), get_string('allowoverride', 'role'));
$toprow[] = new tabobject('switch', new moodle_url('/admin/roles/allow.php', array('mode'=>'switch')), get_string('allowswitch', 'role'));
$tabs = array($toprow);

print_tabs($tabs, $currenttab);
echo $OUTPUT->tabtree($toprow, $currenttab);

6 changes: 2 additions & 4 deletions badges/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ protected function render_badge_management(badge_management $badges) {
public function print_badge_tabs($badgeid, $context, $current = 'overview') {
global $DB;

$tabs = $row = array();
$row = array();

$row[] = new tabobject('overview',
new moodle_url('/badges/overview.php', array('id' => $badgeid)),
Expand Down Expand Up @@ -637,9 +637,7 @@ public function print_badge_tabs($badgeid, $context, $current = 'overview') {
);
}

$tabs[] = $row;

print_tabs($tabs, $current);
echo $this->tabtree($row, $current);
}

// Prints badge status box.
Expand Down
11 changes: 5 additions & 6 deletions group/tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@
* @copyright 2010 Petr Skoda (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$row = $tabs = array();
$row = array();
$row[] = new tabobject('groups',
$CFG->wwwroot.'/group/index.php?id='.$courseid,
new moodle_url('/group/index.php', array('id' => $courseid)),
get_string('groups'));

$row[] = new tabobject('groupings',
$CFG->wwwroot.'/group/groupings.php?id='.$courseid,
new moodle_url('/group/groupings.php', array('id' => $courseid)),
get_string('groupings', 'group'));

$row[] = new tabobject('overview',
$CFG->wwwroot.'/group/overview.php?id='.$courseid,
new moodle_url('/group/overview.php', array('id' => $courseid)),
get_string('overview', 'group'));
$tabs[] = $row;
echo '<div class="groupdisplay">';
print_tabs($tabs, $currenttab);
echo $OUTPUT->tabtree($row, $currenttab);
echo '</div>';
37 changes: 14 additions & 23 deletions mod/data/tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,28 @@

$context = context_module::instance($cm->id);

$inactive = NULL;
$activetwo = NULL;
$tabs = array();
$row = array();

$row[] = new tabobject('list', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id, get_string('list','data'));
$row[] = new tabobject('list', new moodle_url('/mod/data/view.php', array('d' => $data->id)), get_string('list','data'));

if (isset($record)) {
$row[] = new tabobject('single', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;rid='.$record->id, get_string('single','data'));
$row[] = new tabobject('single', new moodle_url('/mod/data/view.php', array('d' => $data->id, 'rid' => $record->id)), get_string('single','data'));
} else {
$row[] = new tabobject('single', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;mode=single', get_string('single','data'));
$row[] = new tabobject('single', new moodle_url('/mod/data/view.php', array('d' => $data->id, 'mode' => 'single')), get_string('single','data'));
}

// Add an advanced search tab.
$row[] = new tabobject('asearch', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;mode=asearch', get_string('search', 'data'));
$row[] = new tabobject('asearch', new moodle_url('/mod/data/view.php', array('d' => $data->id, 'mode' => 'asearch')), get_string('search', 'data'));

if (isloggedin()) { // just a perf shortcut
if (data_user_can_add_entry($data, $currentgroup, $groupmode, $context)) { // took out participation list here!
$addstring = empty($editentry) ? get_string('add', 'data') : get_string('editentry', 'data');
$row[] = new tabobject('add', $CFG->wwwroot.'/mod/data/edit.php?d='.$data->id, $addstring);
$row[] = new tabobject('add', new moodle_url('/mod/data/edit.php', array('d' => $data->id)), $addstring);
}
if (has_capability(DATA_CAP_EXPORT, $context)) {
// The capability required to Export database records is centrally defined in 'lib.php'
// and should be weaker than those required to edit Templates, Fields and Presets.
$row[] = new tabobject('export', $CFG->wwwroot.'/mod/data/export.php?d='.$data->id,
$row[] = new tabobject('export', new moodle_url('/mod/data/export.php', array('d' => $data->id)),
get_string('export', 'data'));
}
if (has_capability('mod/data:managetemplates', $context)) {
Expand All @@ -70,39 +67,33 @@
$defaultemplate = 'singletemplate';
}

$row[] = new tabobject('templates', $CFG->wwwroot.'/mod/data/templates.php?d='.$data->id.'&amp;mode='.$defaultemplate,
$templatestab = new tabobject('templates', new moodle_url('/mod/data/templates.php', array('d' => $data->id, 'mode' => $defaultemplate)),
get_string('templates','data'));
$row[] = new tabobject('fields', $CFG->wwwroot.'/mod/data/field.php?d='.$data->id,
$row[] = $templatestab;
$row[] = new tabobject('fields', new moodle_url('/mod/data/field.php', array('d' => $data->id)),
get_string('fields','data'));
$row[] = new tabobject('presets', $CFG->wwwroot.'/mod/data/preset.php?d='.$data->id,
$row[] = new tabobject('presets', new moodle_url('/mod/data/preset.php', array('d' => $data->id)),
get_string('presets', 'data'));
}
}

$tabs[] = $row;

if ($currenttab == 'templates' and isset($mode)) {

$inactive = array();
$inactive[] = 'templates';
if ($currenttab == 'templates' and isset($mode) && isset($templatestab)) {
$templatestab->inactive = true;
$templatelist = array ('listtemplate', 'singletemplate', 'asearchtemplate', 'addtemplate', 'rsstemplate', 'csstemplate', 'jstemplate');

$row = array();
$currenttab ='';
foreach ($templatelist as $template) {
$row[] = new tabobject($template, "templates.php?d=$data->id&amp;mode=$template", get_string($template, 'data'));
$templatestab->subtree[] = new tabobject($template, new moodle_url('/mod/data/templates.php', array('d' => $data->id, 'mode' => $template)), get_string($template, 'data'));
if ($template == $mode) {
$currenttab = $template;
}
}
if ($currenttab == '') {
$currenttab = $mode = 'singletemplate';
}
$tabs[] = $row;
$activetwo = array('templates');
}

// Print out the tabs and continue!
print_tabs($tabs, $currenttab, $inactive, $activetwo);
echo $OUTPUT->tabtree($row, $currenttab);


2 changes: 1 addition & 1 deletion mod/wiki/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

$renderer = $PAGE->get_renderer('mod_wiki');

$tabitems = array('view' => 'view', 'edit' => 'edit', 'comments' => 'comments', 'history' => 'history', 'map' => 'map', 'files' => 'files');
$tabitems = array('view' => 'view', 'edit' => 'edit', 'comments' => 'comments', 'history' => 'history', 'map' => 'map', 'files' => 'files', 'admin' => 'admin');

$options = array('activetab'=>'files');
echo $renderer->tabs($page, $tabitems, $options);
Expand Down
6 changes: 2 additions & 4 deletions mod/wiki/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,7 @@ public function wiki_info() {
}

public function tabs($page, $tabitems, $options) {
global $CFG;
$tabs = array();
$baseurl = $CFG->wwwroot . '/mod/wiki/';
$context = context_module::instance($this->page->cm->id);

$pageid = null;
Expand Down Expand Up @@ -281,15 +279,15 @@ public function tabs($page, $tabitems, $options) {
if ($tab == 'admin' && !has_capability('mod/wiki:managewiki', $context)) {
continue;
}
$link = $baseurl . $tab . '.php?pageid=' . $pageid;
$link = new moodle_url('/mod/wiki/'. $tab. '.php', array('pageid' => $pageid));
if ($linked == $tab) {
$tabs[] = new tabobject($tab, $link, get_string($tab, 'wiki'), '', true);
} else {
$tabs[] = new tabobject($tab, $link, get_string($tab, 'wiki'));
}
}

return print_tabs(array($tabs), $selected, $inactive, null, true);
return $this->tabtree($tabs, $selected, $inactive);
}

public function prettyview_link($page) {
Expand Down

0 comments on commit a5f82c5

Please sign in to comment.