本文整理匯總了PHP中flexible_table::set_control_variables方法的典型用法代碼示例。如果您正苦於以下問題:PHP flexible_table::set_control_variables方法的具體用法?PHP flexible_table::set_control_variables怎麽用?PHP flexible_table::set_control_variables使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類flexible_table
的用法示例。
在下文中一共展示了flexible_table::set_control_variables方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($baseurl->out());
if (!isset($hiddenfields['lastaccess'])) {
$table->sortable(true, 'lastaccess', SORT_DESC);
} else {
$table->sortable(true, 'firstname', SORT_ASC);
}
$table->no_sorting('roles');
$table->no_sorting('groups');
$table->no_sorting('groupings');
$table->no_sorting('select');
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'participants');
$table->set_attribute('class', 'generaltable generalbox');
$table->set_control_variables(array(TABLE_VAR_SORT => 'ssort', TABLE_VAR_HIDE => 'shide', TABLE_VAR_SHOW => 'sshow', TABLE_VAR_IFIRST => 'sifirst', TABLE_VAR_ILAST => 'silast', TABLE_VAR_PAGE => 'spage'));
$table->setup();
list($esql, $params) = get_enrolled_sql($context, null, $currentgroup, true);
$joins = array("FROM {user} u");
$wheres = array();
$userfields = array('username', 'email', 'city', 'country', 'lang', 'timezone', 'maildisplay');
$mainuserfields = user_picture::fields('u', $userfields);
$extrasql = get_extra_user_fields_sql($context, 'u', '', $userfields);
if ($isfrontpage) {
$select = "SELECT {$mainuserfields}, u.lastaccess{$extrasql}";
$joins[] = "JOIN ({$esql}) e ON e.id = u.id";
// Everybody on the frontpage usually.
if ($accesssince) {
$wheres[] = get_user_lastaccess_sql($accesssince);
}
} else {
示例2: StdClass
//.........這裏部分代碼省略.........
$this->filteredsql = str_replace('<%%PARAMS%%>', '', $this->filteredsql);
// needed to prepare for filter range prefetch
}
$sort = optional_param('tsort' . $this->instance->id, @$this->config->defaultsort, PARAM_TEXT);
if (!empty($sort)) {
// do not sort if already sorted in explained query
if (!preg_match('/ORDER\\s+BY/si', $this->sql)) {
$this->filteredsql .= " ORDER BY {$sort}";
}
}
$this->filteredsql = $this->protect($this->filteredsql);
// ######### GETTING RESULTS
$countres = $this->count_records($error);
// if too many results, we force paging mode
if (empty($this->config->pagesize) && $countres > $CFG->block_dashboard_big_result_threshold && !empty($this->config->bigresult)) {
$text .= '<span class="error">' . get_string('toomanyrecordsusepaging', 'block_dashboard') . '</span><br/>';
$this->config->pagesize = $CFG->block_dashboard_big_result_threshold;
$rpage = 0;
}
// getting real results including page and offset
if (!empty($this->config->pagesize)) {
$offset = $rpage * $this->config->pagesize;
} else {
$offset = '';
}
try {
$results = $this->fetch_dashboard_data($this->filteredsql, @$this->config->pagesize, $offset);
} catch (Exception $e) {
return get_string('invalidorobsoletequery', 'block_dashboard', $this->config->query);
}
if ($results) {
$table = new flexible_table('mod-dashboard' . $this->instance->id);
$instancecontrolvars = array(TABLE_VAR_PAGE => 'rpage' . $this->instance->id, TABLE_VAR_SORT => 'tsort' . $this->instance->id, TABLE_VAR_HIDE => 'thide' . $this->instance->id, TABLE_VAR_SHOW => 'tshow' . $this->instance->id);
$table->set_control_variables($instancecontrolvars);
// use full not to collide with flexipage paging
$tablecolumns = array();
$tableheaders = array();
foreach ($this->output as $field => $label) {
$tablecolumns[] = $field;
$tableheaders[] = $label;
}
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$filterquerystringadd = isset($filterquerystring) ? "&{$filterquerystring}" : '';
if (@$this->config->inblocklayout) {
$table->define_baseurl($CFG->wwwroot . '/course/view.php?id=' . $COURSE->id . $coursepage . $filterquerystringadd);
} else {
$table->define_baseurl($CFG->wwwroot . '/blocks/dashboard/view.php?id=' . $COURSE->id . '&blockid=' . $this->instance->id . $coursepage . $filterquerystringadd);
}
if (!empty($this->config->sortable)) {
$table->sortable(true, $this->config->xaxisfield, SORT_DESC);
}
//sorted by xaxisfield by default
$table->collapsible(true);
$table->initialbars(true);
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'dashboard' . $this->instance->id);
$table->set_attribute('class', 'dashboard');
$table->set_attribute('width', '100%');
foreach ($this->output as $field => $label) {
$table->column_class($field, $field);
}
$table->setup();
/*
$where = $table->get_sql_where();
$sortsql = $table->get_sql_sort();