function definition() { global $USER, $CFG; $mform = $this->_form; $mform->addElement('header', 'createuserandpass', get_string('createuserandpass'), ''); $mform->addElement('text', 'username', get_string('username'), 'maxlength="100" size="12"'); $mform->setType('username', PARAM_NOTAGS); $mform->addRule('username', get_string('missingusername'), 'required', null, 'server'); if (!empty($CFG->passwordpolicy)) { $mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy()); } $mform->addElement('passwordunmask', 'password', get_string('password'), 'maxlength="32" size="12"'); $mform->setType('password', PARAM_RAW); $mform->addRule('password', get_string('missingpassword'), 'required', null, 'server'); $mform->addElement('header', 'supplyinfo', get_string('supplyinfo'), ''); $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="25"'); $mform->setType('email', PARAM_RAW_TRIMMED); $mform->addRule('email', get_string('missingemail'), 'required', null, 'server'); $mform->addElement('text', 'email2', get_string('emailagain'), 'maxlength="100" size="25"'); $mform->setType('email2', PARAM_RAW_TRIMMED); $mform->addRule('email2', get_string('missingemail'), 'required', null, 'server'); $namefields = useredit_get_required_name_fields(); foreach ($namefields as $field) { $mform->addElement('text', $field, get_string($field), 'maxlength="100" size="30"'); $mform->setType($field, PARAM_TEXT); $stringid = 'missing' . $field; if (!get_string_manager()->string_exists($stringid, 'moodle')) { $stringid = 'required'; } $mform->addRule($field, get_string($stringid), 'required', null, 'server'); } $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="20"'); $mform->setType('city', PARAM_TEXT); if (!empty($CFG->defaultcity)) { $mform->setDefault('city', $CFG->defaultcity); } $country = get_string_manager()->get_list_of_countries(); $default_country[''] = get_string('selectacountry'); $country = array_merge($default_country, $country); $mform->addElement('select', 'country', get_string('country'), $country); if (!empty($CFG->country)) { $mform->setDefault('country', $CFG->country); } else { $mform->setDefault('country', ''); } if ($this->signup_captcha_enabled()) { $mform->addElement('recaptcha', 'recaptcha_element', get_string('security_question', 'auth'), array('https' => $CFG->loginhttps)); $mform->addHelpButton('recaptcha_element', 'recaptcha', 'auth'); } profile_signup_fields($mform); if (!empty($CFG->sitepolicy)) { $mform->addElement('header', 'policyagreement', get_string('policyagreement'), ''); $mform->setExpanded('policyagreement'); $mform->addElement('static', 'policylink', '', '<a href="' . $CFG->sitepolicy . '" onclick="this.target=\'_blank\'">' . get_String('policyagreementclick') . '</a>'); $mform->addElement('checkbox', 'policyagreed', get_string('policyaccept')); $mform->addRule('policyagreed', get_string('policyagree'), 'required', null, 'server'); } // buttons $this->add_action_buttons(true, get_string('createaccount')); }
public function get_error_message($args) { if (strlen($this->errorstring) && get_string_manager()->string_exists($this->errorstring, 'local_moodlecheck')) { return get_string($this->errorstring, 'local_moodlecheck', $args); } else { if (get_string_manager()->string_exists('error_' . $this->code, 'local_moodlecheck')) { return get_string('error_' . $this->code, 'local_moodlecheck', $args); } else { if (isset($args['line'])) { // do not dump line number, it will be included in the final message unset($args['line']); } if (is_array($args)) { $args = ': ' . print_r($args, true); } else { if ($args !== true && $args !== null) { $args = ': ' . $args; } else { $args = ''; } } return $this->get_name() . '. Error' . $args; } } }
/** * Default get description method. * * @return string description of the store. */ public function get_description() { if (get_string_manager()->string_exists('pluginname_desc', $this->component)) { return get_string('pluginname_desc', $this->component); } return $this->store; }
public function definition() { global $CFG, $PAGE, $DB; $context = context_system::instance(); $mform =& $this->_form; $strrequired = get_string('required'); $mform->addElement('hidden', 'id', $this->classroomid); $mform->addElement('hidden', 'companyid', $this->companyid); $mform->setType('id', PARAM_INT); $mform->setType('companyid', PARAM_INT); // Then show the fields about where this block appears. $mform->addElement('header', 'header', get_string('classroom', 'block_iomad_company_admin')); $mform->addElement('text', 'name', get_string('classroom_name', 'block_iomad_company_admin'), 'maxlength="100" size="50"'); $mform->setType('name', PARAM_NOTAGS); $mform->addRule('name', $strrequired, 'required', null, 'client'); $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="50"'); $mform->addRule('address', $strrequired, 'required', null, 'client'); $mform->setType('address', PARAM_NOTAGS); $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="50"'); $mform->addRule('city', $strrequired, 'required', null, 'client'); $mform->setType('city', PARAM_NOTAGS); $mform->addElement('text', 'postcode', get_string('postcode', 'block_iomad_commerce'), 'maxlength="20" size="20"'); $mform->addRule('postcode', $strrequired, 'required', null, 'client'); $mform->setType('postcode', PARAM_NOTAGS); $choices = get_string_manager()->get_list_of_countries(); $choices = array('' => get_string('selectacountry') . '...') + $choices; $mform->addElement('select', 'country', get_string('selectacountry'), $choices); $mform->addRule('country', $strrequired, 'required', null, 'client'); $mform->addElement('text', 'capacity', get_string('classroom_capacity', 'block_iomad_company_admin')); $mform->addRule('capacity', $strrequired, 'required', null, 'client'); $mform->setType('capacity', PARAM_INTEGER); $this->add_action_buttons(); }
/** * Function to be called for CSS postprocess, this function replace all * CSS tags for their values in the setting page. * @param String $css * @param Object $theme * @return String $css - final CSS of the theme */ function theme_archaius_process_css($css, $theme) { $customcss = theme_archaius_check_css_setting($theme->settings->customcss); $css = theme_archaius_replace_tag_css($css, $customcss, '[[setting:customcss]]'); $themecolor = theme_archaius_check_css_setting($theme->settings->themecolor); $css = theme_archaius_replace_tag_css($css, $themecolor, '[[setting:themecolor]]'); $bgcolor = theme_archaius_check_css_setting($theme->settings->bgcolor); $css = theme_archaius_replace_tag_css($css, $bgcolor, '[[setting:bgcolor]]'); $page_header_text_color = theme_archaius_check_css_setting($theme->settings->headertextcolor); $css = theme_archaius_replace_tag_css($css, $page_header_text_color, '[[setting:headertextcolor]]'); $page_footer_text_color = theme_archaius_check_css_setting($theme->settings->footertextcolor); $css = theme_archaius_replace_tag_css($css, $page_footer_text_color, '[[setting:footertextcolor]]'); $headercolor = theme_archaius_check_css_setting($theme->settings->headercolor); $css = theme_archaius_replace_tag_css($css, $headercolor, '[[setting:headercolor]]'); $currentcolor = theme_archaius_check_css_setting($theme->settings->currentcolor); $css = theme_archaius_replace_tag_css($css, $currentcolor, '[[setting:currentcolor]]'); $currentcustommenucolor = theme_archaius_check_css_setting($theme->settings->currentcustommenucolor); $css = theme_archaius_replace_tag_css($css, $currentcustommenucolor, '[[setting:currentcustommenucolor]]'); $custommenucolor = theme_archaius_check_css_setting($theme->settings->custommenucolor); $css = theme_archaius_replace_tag_css($css, $custommenucolor, '[[setting:custommenucolor]]'); $slideshowheight = theme_archaius_check_css_setting($theme->settings->slideshowheight); $css = theme_archaius_set_slideshowheight($css, $slideshowheight); $css = theme_archaius_set_css_font_replacement($css); $css = theme_archaius_set_login_background_image($css); $css = theme_archaius_set_login_box_width($css); $langs = get_string_manager()->get_list_of_translations(); if (count($langs) > 1) { $css = theme_archaius_set_custommenu_last_child($css, 'right', '6%'); } else { $css = theme_archaius_set_custommenu_last_child($css, 'left', '0'); } return $css; }
protected function render_custom_menu(custom_menu $menu) { $langs = get_string_manager()->get_list_of_translations(); $haslangmenu = $this->lang_menu() != ''; if (!$menu->has_children() && !$haslangmenu) { return ''; } if ($haslangmenu) { $strlang = get_string('language'); $currentlang = current_language(); if (isset($langs[$currentlang])) { $currentlang = $langs[$currentlang]; } else { $currentlang = $strlang; } $this->language = $menu->add($currentlang, new moodle_url('#'), $strlang, 10000); foreach ($langs as $langtype => $langname) { $this->language->add($langname, new moodle_url($this->page->url, array('lang' => $langtype)), $langname); } } $children = $menu->get_children(); if (count($children) == 0) { return false; } $content = ''; foreach ($menu->get_children() as $item) { $content .= $this->render_custom_menu_item($item, 1); } return $content; }
/** * Returns the all public properties from a object * as an array to use as column names. * * @param array $array - an associative array with data defined * @return array */ public static function get_columns($array) { if (!is_array($array)) { return false; } $columns = array_keys($array); $new_columns = array(); if (isset(datamap::$post_process_columns) && !empty(datamap::$post_process_columns)) { $mapped_columns = datamap::$post_process_columns; } else { $mapped_columns = datamap::$columns; } foreach ($columns as $value) { $newvalue = ""; if (isset($mapped_columns[$value])) { $newvalue = $mapped_columns[$value]; } else { $newvalue = $value; } if (datamap::$config['columns_get_string']) { if (get_string_manager()->string_exists($value, 'report_cleanreport')) { $newvalue = get_string($newvalue, 'report_cleanreport'); } } $new_columns[] = $newvalue; } return $new_columns; }
protected function render_custom_menu(custom_menu $menu) { global $CFG; // TODO: eliminate this duplicated logic, it belongs in core, not // here. See MDL-39565. $addlangmenu = true; $langs = get_string_manager()->get_list_of_translations(); if (count($langs) < 2 or empty($CFG->langmenu) or $this->page->course != SITEID and !empty($this->page->course->lang)) { $addlangmenu = false; } if (!$menu->has_children() && $addlangmenu === false) { return ''; } if ($addlangmenu) { $strlang = get_string('language'); $currentlang = current_language(); if (isset($langs[$currentlang])) { $currentlang = $langs[$currentlang]; } else { $currentlang = $strlang; } $this->language = $menu->add($currentlang, new moodle_url('#'), $strlang, 10000); foreach ($langs as $langtype => $langname) { $this->language->add($langname, new moodle_url($this->page->url, array('lang' => $langtype)), $langname); } } $content = '<ul class="nav">'; foreach ($menu->get_children() as $item) { $content .= $this->render_custom_menu_item($item, 1); } return $content . '</ul>'; }
/** * Define this form - called by the parent constructor */ public function definition() { global $COURSE, $USER; $mform = $this->_form; $params = $this->_customdata; $choices = get_string_manager()->get_list_of_countries(); $choices = array('' => get_string('selectacountry') . '...') + $choices; $mform->addElement('select', 'country', 'Country for E-signature', $choices); $mform->setDefault('country', 'SE'); if (isset($_SESSION['assign' . $params['cm']]['signedtoken']) && $_SESSION['assign' . $params['cm']]['signedtoken']) { $mform->addElement('static', 'description', '', get_string('esignalreadyadded', 'assignfeedback_esign')); } else { $mform->addElement('static', 'description', '', get_string('addesignforall', 'assignfeedback_esign')); } $mform->addRule('country', get_string('selectacountry'), 'required', '', 'client', false, false); $mform->addElement('hidden', 'id', $params['cm']); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'action', 'viewpluginpage'); $mform->setType('action', PARAM_ALPHA); $mform->addElement('hidden', 'pluginaction', 'addesign'); $mform->setType('pluginaction', PARAM_ALPHA); $mform->addElement('hidden', 'plugin', 'esign'); $mform->setType('plugin', PARAM_PLUGIN); $mform->addElement('hidden', 'pluginsubtype', 'assignfeedback'); $mform->setType('pluginsubtype', PARAM_PLUGIN); if (isset($_SESSION['assign' . $params['cm']]['signedtoken']) && $_SESSION['assign' . $params['cm']]['signedtoken']) { $this->add_action_buttons(true, get_string('updateesign', 'assignfeedback_esign')); } else { $this->add_action_buttons(true, get_string('addesign', 'assignfeedback_esign')); } }
function definition_after_data() { global $CFG, $DB, $OUTPUT; $mform =& $this->_form; $userid = $mform->getElementValue('id'); // if language does not exist, use site default lang if ($langsel = $mform->getElementValue('lang')) { $lang = reset($langsel); // check lang exists if (!get_string_manager()->translation_exists($lang, false)) { $lang_el =& $mform->getElement('lang'); $lang_el->setValue($CFG->lang); } } if ($user = $DB->get_record('user', array('id' => $userid))) { // remove description if (empty($user->description) && !empty($CFG->profilesforenrolledusersonly) && !$DB->record_exists('role_assignments', array('userid' => $userid))) { $mform->removeElement('description_editor'); } // print picture $context = context_user::instance($user->id, MUST_EXIST); $fs = get_file_storage(); $hasuploadedpicture = $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.png') || $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.jpg'); if (!empty($user->picture) && $hasuploadedpicture) { $imagevalue = $OUTPUT->user_picture($user, array('courseid' => SITEID, 'size' => 64)); } else { $imagevalue = get_string('none'); } $imageelement = $mform->getElement('currentpicture'); $imageelement->setValue($imagevalue); if ($mform->elementExists('deletepicture') && !$hasuploadedpicture) { $mform->removeElement('deletepicture'); } /// disable fields that are locked by auth plugins $fields = get_user_fieldnames(); $authplugin = get_auth_plugin($user->auth); foreach ($fields as $field) { if (!$mform->elementExists($field)) { continue; } $configvariable = 'field_lock_' . $field; if (isset($authplugin->config->{$configvariable})) { if ($authplugin->config->{$configvariable} === 'locked') { $mform->hardFreeze($field); $mform->setConstant($field, $user->{$field}); } else { if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->{$field} != '') { $mform->hardFreeze($field); $mform->setConstant($field, $user->{$field}); } } } } /// Next the customisable profile fields profile_definition_after_data($mform, $user->id); } else { profile_definition_after_data($mform, 0); } }
/** * Returns location information * @param string $ip * @return array */ function iplookup_find_location($ip) { global $CFG; $info = array('city' => null, 'country' => null, 'longitude' => null, 'latitude' => null, 'error' => null, 'note' => '', 'title' => array()); if (!empty($CFG->geoip2file) and file_exists($CFG->geoip2file)) { $reader = new GeoIp2\Database\Reader($CFG->geoip2file); $record = $reader->city($ip); if (empty($record)) { $info['error'] = get_string('iplookupfailed', 'error', $ip); return $info; } $info['city'] = core_text::convert($record->city->name, 'iso-8859-1', 'utf-8'); $info['title'][] = $info['city']; $countrycode = $record->country->isoCode; $countries = get_string_manager()->get_list_of_countries(true); if (isset($countries[$countrycode])) { // Prefer our localized country names. $info['country'] = $countries[$countrycode]; } else { $info['country'] = $record->country->names['en']; } $info['title'][] = $info['country']; $info['longitude'] = $record->location->longitude; $info['latitude'] = $record->location->latitude; $info['note'] = get_string('iplookupmaxmindnote', 'admin'); return $info; } else { require_once $CFG->libdir . '/filelib.php'; if (strpos($ip, ':') !== false) { // IPv6 is not supported by geoplugin.net. $info['error'] = get_string('invalidipformat', 'error'); return $info; } $ipdata = download_file_content('http://www.geoplugin.net/json.gp?ip=' . $ip); if ($ipdata) { $ipdata = preg_replace('/^geoPlugin\\((.*)\\)\\s*$/s', '$1', $ipdata); $ipdata = json_decode($ipdata, true); } if (!is_array($ipdata)) { $info['error'] = get_string('cannotgeoplugin', 'error'); return $info; } $info['latitude'] = (double) $ipdata['geoplugin_latitude']; $info['longitude'] = (double) $ipdata['geoplugin_longitude']; $info['city'] = s($ipdata['geoplugin_city']); $countrycode = $ipdata['geoplugin_countryCode']; $countries = get_string_manager()->get_list_of_countries(true); if (isset($countries[$countrycode])) { // prefer our localized country names $info['country'] = $countries[$countrycode]; } else { $info['country'] = s($ipdata['geoplugin_countryName']); } $info['note'] = get_string('iplookupgeoplugin', 'admin'); $info['title'][] = $info['city']; $info['title'][] = $info['country']; return $info; } }
/** * @return string the name of this question type in the user's language. * You should not need to override this method, the default behaviour should be fine. */ public function local_name() { if (get_string_manager()->string_exists('pluginname', $this->plugin_name())) { return get_string('pluginname', $this->plugin_name()); } else { return get_string($this->name(), $this->plugin_name()); } }
public function init_display_name() { if (get_string_manager()->string_exists('pluginname', $this->component)) { $this->displayname = get_string('pluginname', $this->component); } else { $this->displayname = get_string('modulename', $this->component); } }
/** * Set parameters for this plugin. * * @return array The JSON encoding of the installed languages. */ function atto_multilang2_params_for_js() { $languages = json_encode(get_string_manager()->get_list_of_translations()); $capability = get_capability(); $highlight = get_config('atto_multilang2', 'highlight') === '1' ? true : false; $css = get_config('atto_multilang2', 'customcss'); return array('languages' => $languages, 'capability' => $capability, 'highlight' => $highlight, 'css' => $css); }
public function init_display_name() { if (!get_string_manager()->string_exists('filtername', $this->component)) { $this->displayname = '[filtername,' . $this->component . ']'; } else { $this->displayname = get_string('filtername', $this->component); } }
/** * Display name */ public function init_display_name() { if (!get_string_manager()->string_exists('dataformat', $this->component)) { $this->displayname = '[dataformat,' . $this->component . ']'; } else { $this->displayname = get_string('dataformat', $this->component); } }
/** * Gets the content of an e-mail from language strings * * Looks for the language string email_$template_$format and replaces the parameter values. * * @param template the template's identified * @param string $format tthe mail format ('subject', 'html' or 'plain') * @param infomap a hash containing pairs of parm => data to replace in template * @return a fully resolved template where all data has been injected */ function scheduler_compile_mail_template($template, $format, $infomap, $module = 'scheduler', $lang = null) { $params = array(); foreach ($infomap as $key => $value) { $params[strtolower($key)] = $value; } $mailstr = get_string_manager()->get_string("email_{$template}_{$format}", $module, $params, $lang); return $mailstr; }
protected function specific_definition($mform) { $mform->addElement('header', 'configheader', get_string('messagesettings', 'block_cancelcourse')); $lang = array_merge(array('' => get_string('none', 'block_cancelcourse')), get_string_manager()->get_list_of_translations()); //var_dump($lang); $mform->addElement('select', 'config_language', get_string('config_language', 'block_cancelcourse'), $lang); $mform->addElement('text', 'config_profname', get_string('config_profname', 'block_cancelcourse')); $mform->setType('config_profname', PARAM_NOTAGS); }
/** * Get form elements for the grading page * * @param stdClass|null $grade * @param MoodleQuickForm $mform * @param stdClass $data * @return bool true if elements were added to the form */ public function get_form_elements($grade, MoodleQuickForm $mform, stdClass $data) { $choices = get_string_manager()->get_list_of_countries(); $choices = array('' => get_string('selectacountry') . '...') + $choices; $mform->addElement('select', 'country', 'Country for E-signature', $choices); $mform->addElement('static', 'description', '', get_string('savechanges', 'assignfeedback_esign')); $mform->setDefault('country', 'SE'); $mform->addRule('country', get_string('selectacountry'), 'required', '', 'client', false, false); return true; }
protected function definition() { global $OUTPUT; $mform = $this->_form; $defaultcategory = $this->_customdata['defaultcategory']; $contexts = $this->_customdata['contexts']; // Choice of import format, with help icons. $mform->addElement('header', 'fileformat', get_string('fileformat', 'question')); $fileformatnames = get_import_export_formats('import'); $radioarray = array(); $separators = array(); foreach ($fileformatnames as $shortname => $fileformatname) { $radioarray[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname); $separator = ''; if (get_string_manager()->string_exists('pluginname_help', 'qformat_' . $shortname)) { $separator .= $OUTPUT->help_icon('pluginname', 'qformat_' . $shortname); } $separator .= '<br>'; $separators[] = $separator; } $radioarray[] = $mform->createElement('static', 'makelasthelpiconshowup', ''); $mform->addGroup($radioarray, "formatchoices", '', $separators, false); $mform->addRule("formatchoices", null, 'required', null, 'client'); // Import options. $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('questioncategory', 'category', get_string('importcategory', 'question'), compact('contexts')); $mform->setDefault('category', $defaultcategory); $mform->addHelpButton('category', 'importcategory', 'question'); $categorygroup = array(); $categorygroup[] = $mform->createElement('checkbox', 'catfromfile', '', get_string('getcategoryfromfile', 'question')); $categorygroup[] = $mform->createElement('checkbox', 'contextfromfile', '', get_string('getcontextfromfile', 'question')); $mform->addGroup($categorygroup, 'categorygroup', '', '', false); $mform->disabledIf('categorygroup', 'catfromfile', 'notchecked'); $mform->setDefault('catfromfile', 1); $mform->setDefault('contextfromfile', 1); $matchgrades = array(); $matchgrades['error'] = get_string('matchgradeserror', 'question'); $matchgrades['nearest'] = get_string('matchgradesnearest', 'question'); $mform->addElement('select', 'matchgrades', get_string('matchgrades', 'question'), $matchgrades); $mform->addHelpButton('matchgrades', 'matchgrades', 'question'); $mform->setDefault('matchgrades', 'error'); $mform->addElement('selectyesno', 'stoponerror', get_string('stoponerror', 'question')); $mform->setDefault('stoponerror', 1); $mform->addHelpButton('stoponerror', 'stoponerror', 'question'); // The file to import $mform->addElement('header', 'importfileupload', get_string('importquestions', 'question')); $mform->addElement('filepicker', 'newfile', get_string('import')); $mform->addRule('newfile', null, 'required', null, 'client'); // Submit button. $mform->addElement('submit', 'submitbutton', get_string('import')); // Set a template for the format select elements $renderer = $mform->defaultRenderer(); $template = "{help} {element}\n"; $renderer->setGroupElementTemplate($template, 'format'); }
function definition() { global $CFG, $DB; $mform =& $this->_form; // this hack is needed for different settings of each subtype if (!empty($this->_instance)) { if ($ass = $DB->get_record('assignment', array('id' => $this->_instance))) { $type = $ass->assignmenttype; } else { print_error('invalidassignment', 'assignment'); } } else { $type = required_param('type', PARAM_ALPHA); } $mform->addElement('hidden', 'assignmenttype', $type); $mform->setType('assignmenttype', PARAM_ALPHA); $mform->setDefault('assignmenttype', $type); $mform->addElement('hidden', 'type', $type); $mform->setType('type', PARAM_ALPHA); $mform->setDefault('type', $type); require_once $CFG->dirroot . '/mod/assignment/type/' . $type . '/assignment.class.php'; $assignmentclass = 'assignment_' . $type; $assignmentinstance = new $assignmentclass(); //------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); // $mform->addElement('static', 'statictype', get_string('assignmenttype', 'assignment'), get_string('type'.$type,'assignment')); $mform->addElement('text', 'name', get_string('assignmentname', 'assignment'), array('size' => '64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $this->add_intro_editor(true, get_string('description', 'assignment')); $mform->addElement('date_time_selector', 'timeavailable', get_string('availabledate', 'assignment'), array('optional' => true)); $mform->setDefault('timeavailable', time()); $mform->addElement('date_time_selector', 'timedue', get_string('duedate', 'assignment'), array('optional' => true)); $mform->setDefault('timedue', time() + 7 * 24 * 3600); $ynoptions = array(0 => get_string('no'), 1 => get_string('yes')); if ($assignmentinstance->supports_lateness()) { $mform->addElement('select', 'preventlate', get_string('preventlate', 'assignment'), $ynoptions); $mform->setDefault('preventlate', 0); } // hack to support pluggable assignment type titles if (get_string_manager()->string_exists('type' . $type, 'assignment')) { $typetitle = get_string('type' . $type, 'assignment'); } else { $typetitle = get_string('type' . $type, 'assignment_' . $type); } $this->standard_grading_coursemodule_elements(); $mform->addElement('header', 'typedesc', $typetitle); $assignmentinstance->setup_elements($mform); $this->standard_coursemodule_elements(); $this->add_action_buttons(); }
public function __construct($course, $section, $onsectionpage = false) { if (course_can_delete_section($course, $section)) { if (get_string_manager()->string_exists('deletesection', 'format_' . $course->format)) { $this->title = get_string('deletesection', 'format_' . $course->format); } else { $this->title = get_string('deletesection'); } $this->url = new moodle_url('/course/editsection.php', array('id' => $section->id, 'sr' => $onsectionpage ? $section->section : 0, 'delete' => 1)); } }
public function init_display_name() { if (get_string_manager()->string_exists('pluginname', 'block_' . $this->name)) { $this->displayname = get_string('pluginname', 'block_' . $this->name); } else { if (($block = block_instance($this->name)) !== false) { $this->displayname = $block->get_title(); } else { parent::init_display_name(); } } }
/** * Test get_component_strings */ public function test_get_component_strings() { global $USER; $this->resetAfterTest(true); $stringmanager = get_string_manager(); $wsstrings = $stringmanager->load_component_strings('webservice', current_language()); $componentstrings = core_external::get_component_strings('webservice'); $this->assertEquals(count($componentstrings), count($wsstrings)); foreach ($wsstrings as $name => $string) { $this->assertEquals($string, $componentstrings[$name]); } }
/** * Extend the form definition after the data has been parsed. */ public function definition_after_data() { global $CFG, $DB, $OUTPUT; $mform = $this->_form; // If language does not exist, use site default lang. if ($langsel = $mform->getElementValue('lang')) { $lang = reset($langsel); // Check lang exists. if (!get_string_manager()->translation_exists($lang, false)) { $langel =& $mform->getElement('lang'); $langel->setValue($CFG->lang); } } }
public function definition() { global $CFG, $USER; $mform =& $this->_form; $mform->addElement('header', 'header', get_string('purchaser_details', 'block_iomad_commerce')); $strrequired = get_string('required'); $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="50"'); $mform->addRule('firstname', $strrequired, 'required', null, 'client'); $mform->setType('firstname', PARAM_NOTAGS); $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="50"'); $mform->addRule('lastname', $strrequired, 'required', null, 'client'); $mform->setType('lastname', PARAM_NOTAGS); $mform->addElement('text', 'company', get_string('company', 'block_iomad_company_admin'), 'maxlength="40" size="50"'); $mform->addRule('company', $strrequired, 'required', null, 'client'); $mform->setType('company', PARAM_NOTAGS); $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="50"'); $mform->addRule('address', $strrequired, 'required', null, 'client'); $mform->setType('address', PARAM_NOTAGS); $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="50"'); $mform->addRule('city', $strrequired, 'required', null, 'client'); $mform->setType('city', PARAM_NOTAGS); $mform->addElement('text', 'postcode', get_string('postcode', 'block_iomad_commerce'), 'maxlength="20" size="20"'); $mform->addRule('postcode', $strrequired, 'required', null, 'client'); $mform->setType('postcode', PARAM_NOTAGS); $choices = get_string_manager()->get_list_of_countries(); $choices = array('' => get_string('selectacountry') . '...') + $choices; $mform->addElement('select', 'country', get_string('selectacountry'), $choices); $mform->addRule('country', $strrequired, 'required', null, 'client'); $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="50"'); $mform->addRule('email', $strrequired, 'required', null, 'client'); $mform->setType('email', PARAM_NOTAGS); $mform->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="50"'); $mform->setType('phone1', PARAM_NOTAGS); $mform->addElement('header', 'header', get_string('payment_options', 'block_iomad_commerce')); $choices = array(); foreach (get_enabled_payment_providers() as $p) { $choices[$p] = get_payment_provider_displayname($p); } if (!$choices) { $mform->addElement('html', '<div class="alert">' . get_string('noproviders', 'block_iomad_commerce') . '</div>'); } else { $mform->addElement('select', 'paymentprovider', get_string('paymentprovider', 'block_iomad_commerce'), $choices); $mform->addRule('paymentprovider', $strrequired, 'required', null, 'client'); } $mform->addElement('hidden', 'userid', $USER->id); $mform->setType('userid', PARAM_INT); $this->add_action_buttons(true, get_string('continue')); }
protected function definition() { $mform = $this->_form; $defaultcategory = $this->_customdata['defaultcategory']; $contexts = $this->_customdata['contexts']; // Choice of format, with help. $mform->addElement('header', 'fileformat', get_string('fileformat', 'question')); $fileformatnames = get_import_export_formats('export'); $radioarray = array(); $i = 0 ; foreach ($fileformatnames as $shortname => $fileformatname) { $currentgrp1 = array(); $currentgrp1[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname); $mform->addGroup($currentgrp1, "formathelp[$i]", ' ', array('<br />'), false); if (get_string_manager()->string_exists('pluginname_help', 'qformat_' . $shortname)) { $mform->addHelpButton("formathelp[$i]", 'pluginname', 'qformat_' . $shortname); } $i++ ; } $mform->addRule("formathelp[0]", null, 'required', null, 'client'); // Export options. $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('questioncategory', 'category', get_string('exportcategory', 'question'), compact('contexts')); $mform->setDefault('category', $defaultcategory); $mform->addHelpButton('category', 'exportcategory', 'question'); $categorygroup = array(); $categorygroup[] = $mform->createElement('checkbox', 'cattofile', '', get_string('tofilecategory', 'question')); $categorygroup[] = $mform->createElement('checkbox', 'contexttofile', '', get_string('tofilecontext', 'question')); $mform->addGroup($categorygroup, 'categorygroup', '', '', false); $mform->disabledIf('categorygroup', 'cattofile', 'notchecked'); $mform->setDefault('cattofile', 1); $mform->setDefault('contexttofile', 1); // Set a template for the format select elements $renderer = $mform->defaultRenderer(); $template = "{help} {element}\n"; $renderer->setGroupElementTemplate($template, 'format'); // Submit buttons. $this->add_action_buttons(false, get_string('exportquestions', 'question')); }
function get_combined_country_info() { global $CFG, $DB; list($confirmedwhere, $confirmedparams) = local_hub_stats_get_confirmed_sql('r', 'pub'); $countries = get_string_manager()->get_list_of_countries(); $sql = "SELECT r.countrycode as country, COUNT('x') AS totalcount, SUM( CASE WHEN privacy = 'named' or privacy = 'linked' THEN 1 ELSE 0 END ) AS publiccount\n FROM {hub_site_directory} r\n WHERE {$confirmedwhere}\n GROUP BY r.countrycode\n HAVING (COUNT('x')) > 0\n ORDER BY (COUNT('x')) DESC"; $resultingcountries = $DB->get_records_sql($sql, $confirmedparams); $countryarray = array(); $countryarray['00'] = new stdClass(); $countryarray['00']->countrycode = '00'; $countryarray['00']->country = 'Unknown'; $countryarray['00']->totalcount = 0; $countryarray['00']->publiccount = 0; $countryarray['00']->privatecount = 0; $totalpublic = 0; $totalprivate = 0; $totalcountries = 0; foreach ($resultingcountries as $country) { if (array_key_exists($country->country, $countries)) { $countryarray[$country->country] = new stdClass(); $countryarray[$country->country]->countrycode = $country->country; $countryarray[$country->country]->country = $countries[$country->country]; $countryarray[$country->country]->totalcount = $country->totalcount; $countryarray[$country->country]->publiccount = $country->publiccount; $countryarray[$country->country]->privatecount = $country->totalcount - $country->publiccount; } else { $countryarray['00']->totalcount += $country->totalcount; $countryarray['00']->publiccount += $country->publiccount; $countryarray['00']->privatecount += $country->totalcount - $country->publiccount; } $totalpublic += $country->publiccount; $totalprivate += $country->totalcount - $country->publiccount; if ($country->country != '') { $totalcountries++; } } //$countryarray[] = array_shift($countryarray); array_shift($countryarray); $countryarray['TOTAL'] = new stdClass(); $countryarray['TOTAL']->public = $totalpublic; $countryarray['TOTAL']->private = $totalprivate; $countryarray['TOTAL']->total = $totalpublic + $totalprivate; $countryarray['TOTAL']->countries = $totalcountries; return $countryarray; }
/** * This test is a built-in validation of deprecated.txt files in lang locations. * * It will fail if the string in the wrong format or non-existing (mistyped) string was deprecated. */ public function test_validate_deprecated_strings_files() { global $CFG; $stringman = get_string_manager(); $teststringman = testable_core_string_manager::instance($CFG->langotherroot, $CFG->langlocalroot, array()); $allstrings = $teststringman->get_all_deprecated_strings(); foreach ($allstrings as $string) { if (!preg_match('/^(.*),(.*)$/', $string, $matches) || clean_param($matches[2], PARAM_COMPONENT) !== $matches[2]) { $this->fail('String "' . $string . '" appearing in one of the lang/en/deprecated.txt files does not have correct syntax'); } list($pluginttype, $pluginname) = core_component::normalize_component($matches[2]); if ($matches[2] !== $pluginttype . '_' . $pluginname) { $this->fail('String "' . $string . '" appearing in one of the lang/en/deprecated.txt files does not have normalised component name'); } if (!$stringman->string_exists($matches[1], $matches[2])) { $this->fail('String "' . $string . '" appearing in one of the lang/en/deprecated.txt files does not exist'); } } }
function definition_after_data() { global $USER, $CFG, $DB, $OUTPUT; $mform =& $this->_form; if ($userid = $mform->getElementValue('id')) { $user = $DB->get_record('user', array('id' => $userid)); } else { $user = false; } // if language does not exist, use site default lang if ($langsel = $mform->getElementValue('lang')) { $lang = reset($langsel); // check lang exists if (!get_string_manager()->translation_exists($lang, false)) { $lang_el =& $mform->getElement('lang'); $lang_el->setValue($CFG->lang); } } // user can not change own auth method if ($userid == $USER->id) { $mform->hardFreeze('auth'); $mform->hardFreeze('preference_auth_forcepasswordchange'); } // admin must choose some password and supply correct email if (!empty($USER->newadminuser)) { $mform->addRule('newpassword', get_string('required'), 'required', null, 'client'); } // require password for new users if ($userid == -1) { $mform->addRule('newpassword', get_string('required'), 'required', null, 'client'); } // print picture if (!empty($CFG->gdversion)) { $image_el =& $mform->getElement('currentpicture'); if ($user and $user->picture) { $image_el->setValue($OUTPUT->user_picture($user, array('courseid' => SITEID))); } else { $image_el->setValue(get_string('none')); } } /// Next the customisable profile fields profile_definition_after_data($mform, $userid); }