/** * Provides a mechanism for choosing one or more artefacts from a list of them. * * @param Pieform $form The form to render the element for * @param array $element The element to render * @return string The HTML for the element */ function pieform_element_artefactchooser(Pieform $form, $element) { global $USER, $pagination_js; $value = $form->get_value($element); $element['offset'] = param_integer('offset', 0); list($html, $pagination, $count) = View::build_artefactchooser_data($element, $form->get_property('viewgroup'), $form->get_property('viewinstitution')); $smarty = smarty_core(); $smarty->assign('datatable', $element['name'] . '_data'); $smarty->assign('artefacts', $html); $smarty->assign('pagination', $pagination['html']); $formname = $form->get_name(); $smarty->assign('blockinstance', substr($formname, strpos($formname, '_') + 1)); // Save the pagination javascript for later, when it is asked for. This is // messy, but can't be helped until Pieforms goes to a more OO way of // managing stuff. $pagination_js = $pagination['javascript']; $baseurl = View::make_base_url(); $smarty->assign('browseurl', $baseurl); $smarty->assign('searchurl', $baseurl . '&s=1'); $smarty->assign('searchable', !empty($element['search'])); return $smarty->fetch('form/artefactchooser.tpl'); }
<?php /** * * @package mahara * @subpackage core * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('JSON', 1); require dirname(dirname(__FILE__)) . '/init.php'; require_once 'view.php'; require_once 'form/elements/artefactchooser.php'; $extradata = json_decode(param_variable('extradata')); safe_require('blocktype', $extradata->blocktype); $data = pieform_element_artefactchooser_set_attributes(call_static_method(generate_class_name('blocktype', $extradata->blocktype), 'artefactchooser_element', $extradata->value)); $data['offset'] = param_integer('offset', 0); list($html, $pagination, $count, $offset, $artefactdata) = View::build_artefactchooser_data($data, $extradata->group, $extradata->institution); json_reply(false, array('message' => null, 'data' => array('tablerows' => $html, 'pagination' => $pagination['html'], 'pagination_js' => $pagination['javascript'], 'count' => $count, 'results' => $count . ' ' . ($count == 1 ? get_string('result') : get_string('results')), 'offset' => $offset, 'artefactdata' => $artefactdata)));