Development of plugin - PUBLICATIONS

Development of plugin - PUBLICATIONS

by Андрей Тюфтин -
Number of replies: 10

Sorry for such number of posts..

I hope this, in my module is the last. 

The last step. 

And I really need your help, dear users and developers of Moodle! Thus, it remains to do the search parameters using filters. Here is an example how it looks like: 



What works: add a new record and sort by column. Tried to understand the sorting by alphabet..but didn't find how and where to add! But for me now it's not the point. Now we have to make a workable search filters. Did example as admin/user.php, the filters were taken from the folder user/filters. Very slowly, but understand..now stuck. Out the error:

Debug info: 
Error code: invalidid 
$a contents:

Stack trace:
  • line 463 of \lib\setuplib.php: moodle_exception thrown
  • line 68 of \mod\public\view.php: call to print_error()

As I understand the issue with the conclusion, the module does not know how to return back to the page..looked through all the $baseurl - everywhere in the function is the value of $baseurl=null - that is, the return on the current page. 
Here. 
Who can help deal with this?... 
The module is attached.

In advance huge thanks to everyone who responds!!!
Average of ratings: -
In reply to Андрей Тюфтин

Re: Development of plugin - PUBLICATIONS

by Андрей Тюфтин -

Attach the updated plugin. Try to make filters. All is confused..Do everything according to the example of filters for users. All that is connected with filters in folder *filter* and of course in view.php. I do not know( the Latest features added to sql after the comment //functions..

You have no idea how I need your help, friends...rescue..

In reply to Андрей Тюфтин

Re: Development of plugin - PUBLICATIONS

by dawn alderson -

Andrew, I am happy to look for a needle in a haystack-I just systemise my efforts-LOL!

If I can help-I will. But, there are others who are more able than me! Keep going-plugin is much needed.

Dawn

In reply to dawn alderson

Re: Development of plugin - PUBLICATIONS

by Андрей Тюфтин -

suggested another, more simple solution - I will try)

Your help - your support, thank you, Dawn!)

If you need help, won't necessarily ;)

In reply to Андрей Тюфтин

Re: Development of plugin - PUBLICATIONS

by dawn alderson -

oh don't be silly! I need nothing back from you....your broken English has been a delight to work with-you have made me think triple-dom...a good thing!

Now, get the plugin through.  Davo is there too...he has a switched on brain, so ask your questions-fast is good :0)

Dawn 

In reply to Андрей Тюфтин

Re: Development of plugin - PUBLICATIONS

by Darko Miletić -

You might want to consider using flexible_table in place of html_table. flexible table has fully support for sorting, paging and exporting. You have a decent example of what can be done in mod_feedback module in [moodle]/mod/feedback/show_entries.php

Just search for the line containing this new flexible_table



In reply to Darko Miletić

Re: Development of plugin - PUBLICATIONS

by Андрей Тюфтин -

Hi, Darko! Yes, I have a table made with Flexible_table. Export I have to do..but how? Can you give an example?


the previous link with the plugin is not working. added new.

In reply to Андрей Тюфтин

Re: Development of plugin - PUBLICATIONS

by Darko Miletić -

Add this to your table code:

/// table code
$table->is_downloadable(true);
$table->show_download_buttons_at(array(TABLE_P_BOTTOM));
$download = optional_param('download', '', PARAM_ALPHA);
$table->is_downloading($download);
///
$table->setup();
/// add data


The formats available by default are tsv, csv, ods, excel, xhtml

In reply to Darko Miletić

Re: Development of plugin - PUBLICATIONS

by Андрей Тюфтин -

does not work( form element shows, but does not work( here's the code:



if (!$entries = $DB->get_records('public_entries', array(), 'concept ASC')) { print_error('moduledoesnotexist', 'error'); } $baseurl = new moodle_url('../public/view.php', array ('id'=>$id)); $tablecolumns = array('concept', 'authors', 'phouse', 'year', 'stranic', 'typep', 'definition',''); $tableheaders = array($strconcept, $strauthors, $strphouse, $stryear, $strstranic, $strtypep, $strdefinition, ''); $table = new flexible_table('public-showentry-list'); $table->define_columns($tablecolumns); $table->define_headers($tableheaders); $table->define_baseurl($baseurl); $table->set_attribute('class', 'admintable generaltable'); $table->sortable(true, 'lastname', SORT_DESC); $table->set_attribute('cellspacing', '0'); $table->set_attribute('id', 'public_entries'); $table->set_attribute('class', 'generaltable generaltable'); $table->set_control_variables(array( TABLE_VAR_SORT => 'ssort', TABLE_VAR_IFIRST => 'sifirst', TABLE_VAR_ILAST => 'silast', TABLE_VAR_PAGE => 'spage' )); $table->no_sorting('definition'); $table->no_sorting(''); //add $table->is_downloadable(true); $table->show_download_buttons_at(array(TABLE_P_BOTTOM)); $download = optional_param('download', '', PARAM_ALPHA); $table->is_downloading($download); // $table->setup(); if ($table->get_sql_sort()) { $sort = 'ORDER BY '. $table->get_sql_sort(); } else { $sort = ''; } list($where, $params) = $table->get_sql_where(); if ($where) { $where = 'WHERE '. $where; } $allusernames = get_all_user_name_fields(true, 'u'); $query = " SELECT pu.concept, pu.authors, pu.phouse, pu.year, pu.stranic, pu.typep, pu.definition, u.id AS owner, $allusernames FROM {public_entries} pu LEFT JOIN {user} u ON u.id = pu.userid $where GROUP BY pu.concept, pu.authors, pu.phouse, pu.year, pu.stranic, pu.typep $sort"; $table->initialbars(true); require_once("lib.php"); if ($entries = $DB->get_records_sql($query, $params, $table->get_page_start(), $table->get_page_size())) { foreach ($entries as $entry) { $vstrentri = $entry->concept; $params = array('id' => $entry->owner); $ownerlink = new moodle_url($CFG->wwwroot . '/user/view.php', $params); $owner = html_writer::link($ownerlink, fullname($entry)); $vphouse = $entry->phouse; $vyear = $entry->year; $vstranic = $entry->stranic; $vtypep = $entry->typep; $vdefinition = $entry->definition; $editentries = $ikonki; $data = array( $vstrentri, $owner, $vphouse, $vyear, $vstranic, $vtypep, $vdefinition, ); $table->add_data($data); } } $table->print_html();

In reply to Андрей Тюфтин

Re: Development of plugin - PUBLICATIONS

by Darko Miletić -

Here is a working example:

require('config.php');
require_once($CFG->dirroot.'/lib/tablelib.php');

$PAGE->set_context(context_system::instance());
$PAGE->set_url('/yotest.php');
$ptitle = 'Test page';
$PAGE->set_title($ptitle);
$PAGE->set_heading($ptitle);

$download = optional_param('download', '', PARAM_ALPHA);

if (empty($download)) {
    echo $OUTPUT->header();
}

$table = new flexible_table('mytableid');
$table->define_columns(array('username', 'email', 'firstname', 'lastname'));
$table->define_headers(array('username', 'email', 'firstname', 'lastname'));
$table->define_baseurl($PAGE->url->out_omit_querystring());
$table->set_attribute('class', 'generaltable');
$table->sortable(true, 'username', SORT_DESC);
if (empty($download)) {
    $total = $DB->count_records('user', array('deleted' => 0));
    $table->pagesize(10, $total);
}
$table->setup();

$table->show_download_buttons_at(array(TABLE_P_BOTTOM));
$table->is_downloading($download, 'exported_data', 'Data title');

$records = $DB->get_recordset('user', array('deleted' => 0), $table->get_sql_sort(),
                              'username, email, firstname, lastname',
                              $table->get_page_start(), $table->get_page_size());
$table->start_output();
foreach ($records as $row) {
    $table->add_data((array)$row);
}
$table->finish_output();

if (empty($download)) {
    echo $OUTPUT->footer();
}