本文整理汇总了PHP中collatorlib类的典型用法代码示例。如果您正苦于以下问题:PHP collatorlib类的具体用法?PHP collatorlib怎么用?PHP collatorlib使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了collatorlib类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: activities_inuse
function activities_inuse($id) {
static $modnames = null;
global $DB, $CFG;
if ($modnames === null) {
$modnames = array(0 => array(), 1 => array());
if ($allmods = $DB->get_records("modules")) {
foreach ($allmods as $mod) {
if (file_exists("$CFG->dirroot/mod/$mod->name/lib.php") && $mod->visible) {
$modnames[0][$mod->name] = get_string("modulename", "$mod->name");
$modnames[1][$mod->name] = get_string("modulenameplural", "$mod->name");
}
}
collatorlib::asort($modnames[0]);
collatorlib::asort($modnames[1]);
}
}
$modnames = $modnames[(int) $plural];
$modulesinuse = array();
$modulesinuse[null] = '---------Select----------';
$dbmanager = $DB->get_manager();
foreach ($modnames as $module => $details) {
if ($dbmanager->table_exists($module) && $DB->record_exists($module, array('course' => $id))) {
$modulesinuse[$module] = $details;
}
}
return $modulesinuse;
}
开发者ID:anilch,项目名称:Personel,代码行数:27,代码来源:lib.php
示例2: cpm_userinfo
static public function cpm_userinfo($a,$b){ //Compare two userinfo fields
$field = self::$field;
$adata = $a->userinfo->$field;
$bdata = $b->userinfo->$field;
if($adata == $bdata) {
return self::cpm_userid($a,$b);
}
if(is_string($adata) && function_exists('collatorlib::compare')){
return (collatorlib::compare($adata, $bdata))*(self::$ascending);
}
if($adata < $bdata){
return self::$ascending;
}else{
return -self::$ascending;
}
}
开发者ID:kmahesh541,项目名称:mitclone,代码行数:16,代码来源:sub_list.php
示例3: get_content
function get_content()
{
global $CFG, $DB, $OUTPUT;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
$course = $this->page->course;
require_once $CFG->dirroot . '/course/lib.php';
$modinfo = get_fast_modinfo($course);
$modfullnames = array();
$archetypes = array();
foreach ($modinfo->cms as $cm) {
// Exclude activities which are not visible or have no link (=label)
if (!$cm->uservisible or !$cm->has_view()) {
continue;
}
if (array_key_exists($cm->modname, $modfullnames)) {
continue;
}
if (!array_key_exists($cm->modname, $archetypes)) {
$archetypes[$cm->modname] = plugin_supports('mod', $cm->modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
}
if ($archetypes[$cm->modname] == MOD_ARCHETYPE_RESOURCE) {
if (!array_key_exists('resources', $modfullnames)) {
$modfullnames['resources'] = get_string('resources');
}
} else {
$modfullnames[$cm->modname] = $cm->modplural;
}
}
collatorlib::asort($modfullnames);
foreach ($modfullnames as $modname => $modfullname) {
if ($modname === 'resources') {
$icon = '<img src="' . $OUTPUT->pix_url('f/html') . '" class="icon" alt="" /> ';
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/course/resources.php?id=' . $course->id . '">' . $icon . $modfullname . '</a>';
} else {
$icon = '<img src="' . $OUTPUT->pix_url('icon', $modname) . '" class="icon" alt="" /> ';
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/mod/' . $modname . '/index.php?id=' . $course->id . '">' . $icon . $modfullname . '</a>';
}
}
return $this->content;
}
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:46,代码来源:block_activity_modules.php
示例4: filter_get_all_installed
/**
* Get the names of all the filters installed in this Moodle.
*
* @global object
* @return array path => filter name from the appropriate lang file. e.g.
* array('mod/glossary' => 'Glossary Auto-linking', 'filter/tex' => 'TeX Notation');
* sorted in alphabetical order of name.
*/
function filter_get_all_installed()
{
global $CFG;
$filternames = array();
// TODO: deprecated since 2.2, will be out in 2.3, see MDL-29996
$filterlocations = array('mod', 'filter');
foreach ($filterlocations as $filterlocation) {
// TODO: move get_list_of_plugins() to get_plugin_list()
$filters = get_list_of_plugins($filterlocation);
foreach ($filters as $filter) {
// MDL-29994 - Ignore mod/data and mod/glossary filters forever, this will be out in 2.3
if ($filterlocation == 'mod' && ($filter == 'data' || $filter == 'glossary')) {
continue;
}
$path = $filterlocation . '/' . $filter;
if (is_readable($CFG->dirroot . '/' . $path . '/filter.php')) {
$strfiltername = filter_get_name($path);
$filternames[$path] = $strfiltername;
}
}
}
collatorlib::asort($filternames);
return $filternames;
}
开发者ID:raymondAntonio,项目名称:moodle,代码行数:32,代码来源:filterlib.php
示例5: get_all_mods
/**
* Returns a number of useful structures for course displays
*/
function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modnamesused)
{
global $CFG, $DB, $COURSE;
$mods = array();
// course modules indexed by id
$modnames = array();
// all course module names (except resource!)
$modnamesplural = array();
// all course module names (plural form)
$modnamesused = array();
// course module names used
if ($allmods = $DB->get_records("modules")) {
foreach ($allmods as $mod) {
if (!file_exists("{$CFG->dirroot}/mod/{$mod->name}/lib.php")) {
continue;
}
if ($mod->visible) {
$modnames[$mod->name] = get_string("modulename", "{$mod->name}");
$modnamesplural[$mod->name] = get_string("modulenameplural", "{$mod->name}");
}
}
collatorlib::asort($modnames);
} else {
print_error("nomodules", 'debug');
}
$course = $courseid == $COURSE->id ? $COURSE : $DB->get_record('course', array('id' => $courseid));
$modinfo = get_fast_modinfo($course);
if ($rawmods = $modinfo->cms) {
foreach ($rawmods as $mod) {
// Index the mods
if (empty($modnames[$mod->modname])) {
continue;
}
$mods[$mod->id] = $mod;
$mods[$mod->id]->modfullname = $modnames[$mod->modname];
if (!$mod->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE, $courseid))) {
continue;
}
// Check groupings
if (!groups_course_module_visible($mod)) {
continue;
}
$modnamesused[$mod->modname] = $modnames[$mod->modname];
}
if ($modnamesused) {
collatorlib::asort($modnamesused);
}
}
}
开发者ID:numbas,项目名称:moodle,代码行数:52,代码来源:lib.php
示例6: grade_get_categories_menu
/**
* Returns grade options for gradebook grade category menu
*
* @param int $courseid The course ID
* @param bool $includenew Include option for new category at array index -1
* @return array of grade categories in course
*/
function grade_get_categories_menu($courseid, $includenew = false)
{
$result = array();
if (!($categories = grade_category::fetch_all(array('courseid' => $courseid)))) {
//make sure course category exists
if (!grade_category::fetch_course_category($courseid)) {
debugging('Can not create course grade category!');
return $result;
}
$categories = grade_category::fetch_all(array('courseid' => $courseid));
}
foreach ($categories as $key => $category) {
if ($category->is_course_category()) {
$result[$category->id] = get_string('uncategorised', 'grades');
unset($categories[$key]);
}
}
if ($includenew) {
$result[-1] = get_string('newcategory', 'grades');
}
$cats = array();
foreach ($categories as $category) {
$cats[$category->id] = $category->get_name();
}
collatorlib::asort($cats);
return $result + $cats;
}
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:34,代码来源:gradelib.php
示例7: sort_records
/**
* Sorts list of records by several fields
*
* @param array $records array of stdClass objects
* @param array $sortfields assoc array where key is the field to sort and value is 1 for asc or -1 for desc
* @return int
*/
protected static function sort_records(&$records, $sortfields)
{
if (empty($records)) {
return;
}
// If sorting by course display name, calculate it (it may be fullname or shortname+fullname)
if (array_key_exists('displayname', $sortfields)) {
foreach ($records as $key => $record) {
if (!isset($record->displayname)) {
$records[$key]->displayname = get_course_display_name_for_list($record);
}
}
}
// sorting by one field - use collatorlib
if (count($sortfields) == 1) {
$property = key($sortfields);
if (in_array($property, array('sortorder', 'id', 'visible', 'parent', 'depth'))) {
$sortflag = collatorlib::SORT_NUMERIC;
} else {
if (in_array($property, array('idnumber', 'displayname', 'name', 'shortname', 'fullname'))) {
$sortflag = collatorlib::SORT_STRING;
} else {
$sortflag = collatorlib::SORT_REGULAR;
}
}
collatorlib::asort_objects_by_property($records, $property, $sortflag);
if ($sortfields[$property] < 0) {
$records = array_reverse($records, true);
}
return;
}
$records = coursecat_sortable_records::sort($records, $sortfields);
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:40,代码来源:coursecatlib.php
示例8: test_ksort
/**
* Tests the static ksort method
* @return void
*/
public function test_ksort()
{
$arr = array('b' => 'ab', 1 => 'aa', 0 => 'cc');
$result = collatorlib::ksort($arr);
$this->assertSame(array_keys($arr), array(0, 1, 'b'));
$this->assertSame(array_values($arr), array('cc', 'aa', 'ab'));
$this->assertTrue($result);
$obj = new stdClass();
$arr = array('1.1.1' => array(), '1.2' => $obj, '1.20.2' => null);
$result = collatorlib::ksort($arr, collatorlib::SORT_NATURAL);
$this->assertSame(array_keys($arr), array('1.1.1', '1.2', '1.20.2'));
$this->assertSame(array_values($arr), array(array(), $obj, null));
$this->assertTrue($result);
$a = array(2 => 'b', 1 => 'c');
$c =& $a;
$b =& $a;
collatorlib::ksort($b);
$this->assertSame($a, $b);
$this->assertSame($c, $b);
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:24,代码来源:textlib_test.php
示例9: get_listing
/**
* Get file listing
*
* @param string $path
* @param string $page
* @return mixed
*/
public function get_listing($fullpath = '', $page = '')
{
global $OUTPUT;
$ret = array();
$ret['list'] = array();
$ret['manage'] = self::MANAGE_URL;
$ret['dynload'] = true;
$crumbs = explode('/', $fullpath);
$path = array_pop($crumbs);
if (empty($path)) {
$type = 'folder';
$pathid = 0;
$pathname = get_string('pluginname', 'repository_boxnet');
} else {
list($type, $pathid, $pathname) = $this->split_part($path);
}
$ret['path'] = $this->build_breadcrumb($fullpath);
$folders = array();
$files = array();
if ($type == 'search') {
$result = $this->boxnetclient->search($pathname);
} else {
$result = $this->boxnetclient->get_folder_items($pathid);
}
foreach ($result->entries as $item) {
if ($item->type == 'folder') {
$folders[$item->name . ':' . $item->id] = array('title' => $item->name, 'path' => $fullpath . '/' . $this->build_part('folder', $item->id, $item->name), 'date' => strtotime($item->modified_at), 'thumbnail' => $OUTPUT->pix_url(file_folder_icon(64))->out(false), 'thumbnail_height' => 64, 'thumbnail_width' => 64, 'children' => array(), 'size' => $item->size);
} else {
$files[$item->name . ':' . $item->id] = array('title' => $item->name, 'source' => $this->build_part('file', $item->id, $item->name), 'size' => $item->size, 'date' => strtotime($item->modified_at), 'thumbnail' => $OUTPUT->pix_url(file_extension_icon($item->name, 64))->out(false), 'thumbnail_height' => 64, 'thumbnail_width' => 64, 'author' => $item->owned_by->name);
}
}
collatorlib::ksort($folders, core_collator::SORT_NATURAL);
collatorlib::ksort($files, core_collator::SORT_NATURAL);
$ret['list'] = array_merge($folders, $files);
$ret['list'] = array_filter($ret['list'], array($this, 'filter'));
return $ret;
}
开发者ID:covex-nn,项目名称:moodle,代码行数:44,代码来源:lib.php
示例10: workshop_print_recent_activity
//.........这里部分代码省略.........
} else {
// can see all submissions from all groups
$submissions[$activity->submissionid] = $s;
}
}
} while (0);
}
if ($activity->assessmentmodified > $timestart and empty($assessments[$activity->assessmentid])) {
$a = new stdclass();
$a->submissionid = $activity->submissionid;
$a->submissiontitle = $activity->submissiontitle;
$a->reviewerid = $activity->reviewerid;
$a->timemodified = $activity->assessmentmodified;
$a->cmid = $activity->cmid;
if ($activity->reviewerid == $USER->id || has_capability('mod/workshop:viewreviewernames', $context)) {
$a->reviewernamevisible = true;
} else {
$a->reviewernamevisible = false;
}
// the following do-while wrapper allows to break from deeply nested if-statements
do {
if ($a->reviewerid === $USER->id) {
// own assessments always visible
$assessments[$activity->assessmentid] = $a;
break;
}
if (has_capability('mod/workshop:viewallassessments', $context)) {
if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
if (isguestuser()) {
// shortcut - guest user does not belong into any group
break;
}
// this might be slow - show only submissions by users who share group with me in this cm
if (!$modinfo->get_groups($cm->groupingid)) {
break;
}
$reviewersgroups = groups_get_all_groups($course->id, $a->reviewerid, $cm->groupingid);
if (is_array($reviewersgroups)) {
$reviewersgroups = array_keys($reviewersgroups);
$intersect = array_intersect($reviewersgroups, $modinfo->get_groups($cm->groupingid));
if (empty($intersect)) {
break;
} else {
// can see all assessments and shares a group with the reviewer
$assessments[$activity->assessmentid] = $a;
break;
}
}
} else {
// can see all assessments from all groups
$assessments[$activity->assessmentid] = $a;
}
}
} while (0);
}
}
$rs->close();
$shown = false;
if (!empty($submissions)) {
$shown = true;
echo $OUTPUT->heading(get_string('recentsubmissions', 'workshop'), 3);
foreach ($submissions as $id => $submission) {
$link = new moodle_url('/mod/workshop/submission.php', array('id'=>$id, 'cmid'=>$submission->cmid));
if ($submission->authornamevisible) {
$author = $users[$submission->authorid];
} else {
$author = null;
}
print_recent_activity_note($submission->timemodified, $author, $submission->title, $link->out(), false, $viewfullnames);
}
}
if (!empty($assessments)) {
$shown = true;
echo $OUTPUT->heading(get_string('recentassessments', 'workshop'), 3);
collatorlib::asort_objects_by_property($assessments, 'timemodified');
foreach ($assessments as $id => $assessment) {
$link = new moodle_url('/mod/workshop/assessment.php', array('asid' => $id));
if ($assessment->reviewernamevisible) {
$reviewer = $users[$assessment->reviewerid];
} else {
$reviewer = null;
}
print_recent_activity_note($assessment->timemodified, $reviewer, $assessment->submissiontitle, $link->out(), false, $viewfullnames);
}
}
if ($shown) {
return true;
}
return false;
}
开发者ID:verbazend,项目名称:AWFA,代码行数:101,代码来源:lib.php
示例11: sesskey
}
if (!$blockobject) {
// ignore
$undeletable = '';
} else {
if (in_array($blockname, $undeletableblocktypes)) {
$undeletable = '<a href="blocks.php?unprotect=' . $blockid . '&sesskey=' . sesskey() . '" title="' . $strunprotect . '">' . '<img src="' . $OUTPUT->pix_url('t/unlock') . '" class="icon" alt="' . $strunprotect . '" /></a>';
} else {
$undeletable = '<a href="blocks.php?protect=' . $blockid . '&sesskey=' . sesskey() . '" title="' . $strprotect . '">' . '<img src="' . $OUTPUT->pix_url('t/unlock_gray') . '" class="icon" alt="' . $strprotect . '" /></a>';
}
}
$row = array('<span' . $class . '>' . $strblockname . '</span>', $blocklist, '<span' . $class . '>' . $version . '</span>', $visible, $undeletable, $delete, $settings);
$tablerows[] = array(strip_tags($strblockname), $row);
// first element will be used for sorting
}
collatorlib::asort($tablerows);
foreach ($tablerows as $row) {
$table->add_data($row[1]);
}
$table->print_html();
if (!empty($incompatible)) {
echo $OUTPUT->heading(get_string('incompatibleblocks', 'blockstable', 'admin'));
$table = new flexible_table('admin-blocks-incompatible');
$table->define_columns(array('block', 'delete'));
$table->define_headers(array($strname, $strdelete));
$table->define_baseurl($CFG->wwwroot . '/' . $CFG->admin . '/blocks.php');
$table->set_attribute('class', 'incompatibleblockstable generaltable');
$table->setup();
foreach ($incompatible as $block) {
$table->add_data(array($block->name, '<a href="blocks.php?delete=' . $block->id . '&sesskey=' . sesskey() . '">' . $strdelete . '</a>'));
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:31,代码来源:blocks.php
示例12: filter_set_global_state
/**
* Set the global activated state for a text filter.
*
* @param string $filtername The filter name, for example 'tex'.
* @param int $state One of the values TEXTFILTER_ON, TEXTFILTER_OFF or TEXTFILTER_DISABLED.
* @param int $move 1 means up, 0 means the same, -1 means down
*/
function filter_set_global_state($filtername, $state, $move = 0)
{
global $DB;
// Check requested state is valid.
if (!in_array($state, array(TEXTFILTER_ON, TEXTFILTER_OFF, TEXTFILTER_DISABLED))) {
throw new coding_exception("Illegal option '{$state}' passed to filter_set_global_state. " . "Must be one of TEXTFILTER_ON, TEXTFILTER_OFF or TEXTFILTER_DISABLED.");
}
if ($move > 0) {
$move = 1;
} else {
if ($move < 0) {
$move = -1;
}
}
if (strpos($filtername, 'filter/') === 0) {
//debugging("Old filtername '$filtername' parameter used in filter_set_global_state()", DEBUG_DEVELOPER);
$filtername = substr($filtername, 7);
} else {
if (strpos($filtername, '/') !== false) {
throw new coding_exception("Invalid filter name '{$filtername}' used in filter_set_global_state()");
}
}
$transaction = $DB->start_delegated_transaction();
$syscontext = context_system::instance();
$filters = $DB->get_records('filter_active', array('contextid' => $syscontext->id), 'sortorder ASC');
$on = array();
$off = array();
foreach ($filters as $f) {
if ($f->active == TEXTFILTER_DISABLED) {
$off[$f->filter] = $f;
} else {
$on[$f->filter] = $f;
}
}
// Update the state or add new record.
if (isset($on[$filtername])) {
$filter = $on[$filtername];
if ($filter->active != $state) {
$filter->active = $state;
$DB->update_record('filter_active', $filter);
if ($filter->active == TEXTFILTER_DISABLED) {
unset($on[$filtername]);
$off = array($filter->filter => $filter) + $off;
}
}
} else {
if (isset($off[$filtername])) {
$filter = $off[$filtername];
if ($filter->active != $state) {
$filter->active = $state;
$DB->update_record('filter_active', $filter);
if ($filter->active != TEXTFILTER_DISABLED) {
unset($off[$filtername]);
$on[$filter->filter] = $filter;
}
}
} else {
$filter = new stdClass();
$filter->filter = $filtername;
$filter->contextid = $syscontext->id;
$filter->active = $state;
$filter->sortorder = 99999;
$filter->id = $DB->insert_record('filter_active', $filter);
$filters[$filter->id] = $filter;
if ($state == TEXTFILTER_DISABLED) {
$off[$filter->filter] = $filter;
} else {
$on[$filter->filter] = $filter;
}
}
}
// Move only active.
if ($move != 0 and isset($on[$filter->filter])) {
$i = 1;
foreach ($on as $f) {
$f->newsortorder = $i;
$i++;
}
$filter->newsortorder = $filter->newsortorder + $move;
foreach ($on as $f) {
if ($f->id == $filter->id) {
continue;
}
if ($f->newsortorder == $filter->newsortorder) {
if ($move == 1) {
$f->newsortorder = $f->newsortorder - 1;
} else {
$f->newsortorder = $f->newsortorder + 1;
}
}
}
collatorlib::asort_objects_by_property($on, 'newsortorder', collatorlib::SORT_NUMERIC);
}
//.........这里部分代码省略.........
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:101,代码来源:filterlib.php
示例13: asort
/**
* Locale aware sorting, the key associations are kept, values are sorted alphabetically.
*
* @param array $arr array to be sorted (reference)
* @param int $sortflag One of Collator::SORT_REGULAR, Collator::SORT_NUMERIC, Collator::SORT_STRING
* @return void modifies parameter
*/
public static function asort(array &$arr, $sortflag = null)
{
debugging('textlib::asort has been superseeded by collatorlib::asort please upgrade your code to use that', DEBUG_DEVELOPER);
collatorlib::asort($arr, $sortflag);
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:12,代码来源:text.php
示例14: test_legacy_collatorlib
public function test_legacy_collatorlib()
{
$arr = array('b' => 'ab', 1 => 'aa', 0 => 'cc');
$result = collatorlib::asort($arr);
$this->assertSame(array('aa', 'ab', 'cc'), array_values($arr));
$this->assertSame(array(1, 'b', 0), array_keys($arr));
$this->assertTrue($result);
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:8,代码来源:collator_test.php
示例15: require_capability
}
$editingon = false;
}
if (!$category->visible) {
require_capability('moodle/category:viewhiddencategories', $context);
}
$canmanage = has_capability('moodle/category:manage', $context);
$sesskeyprovided = !empty($sesskey) && confirm_sesskey($sesskey);
// Process any category actions.
if ($canmanage && $resort && $sesskeyprovided) {
// Resort the category if requested
if ($courses = get_courses($category->id, '', 'c.id,c.fullname,c.sortorder')) {
collatorlib::asort_objects_by_property($courses, 'fullname', collatorlib::SORT_NATURAL);
$i = 1;
foreach ($courses as $course) {
$DB->set_field('course', 'sortorder', $category->sortorder+$i, array('id'=>$course->id));
$i++;
}
fix_course_sortorder(); // should not be needed
}
}
// Process any course actions.
if ($editingon && $sesskeyprovided) {
// Move a specified course to a new category
if (!empty($moveto) and $data = data_submitted()) {
// Some courses are being moved
开发者ID:ncsu-delta,项目名称:moodle,代码行数:31,代码来源:category.php
示例16: definition_after_data
public function definition_after_data()
{
global $CFG, $DB;
$mform = $this->_form;
$course = $this->_customdata['course'];
$context = context_course::instance($course->id);
if (!empty($CFG->enableavailability)) {
$mform->addElement('header', 'availabilityconditions', get_string('availabilityconditions', 'condition'));
$mform->setExpanded('availabilityconditions', false);
// String used by conditions more than once
$strcondnone = get_string('none', 'condition');
// Grouping conditions - only if grouping is enabled at site level
if (!empty($CFG->enablegroupmembersonly)) {
$options = array();
if ($groupings = $DB->get_records('groupings', array('courseid' => $course->id))) {
foreach ($groupings as $grouping) {
$options[$grouping->id] = format_string($grouping->name, true, array('context' => $context));
}
}
collatorlib::asort($options);
$options = array(0 => get_string('none')) + $options;
$mform->addElement('select', 'groupingid', get_string('groupingsection', 'group'), $options);
$mform->addHelpButton('groupingid', 'groupingsection', 'group');
}
// Available from/to defaults to midnight because then the display
// will be nicer where it tells users when they can access it (it
// shows only the date and not time).
$date = usergetdate(time());
$midnight = make_timestamp($date['year'], $date['mon'], $date['mday']);
// Date and time conditions.
$mform->addElement('date_time_selector', 'availablefrom', get_string('availablefrom', 'condition'), array('optional' => true, 'defaulttime' => $midnight));
$mform->addElement('date_time_selector', 'availableuntil', get_string('availableuntil', 'condition'), array('optional' => true, 'defaulttime' => $midnight));
// Conditions based on grades
$gradeoptions = array();
$items = grade_item::fetch_all(array('courseid' => $course->id));
$items = $items ? $items : array();
foreach ($items as $id => $item) {
$gradeoptions[$id] = $item->get_name();
}
asort($gradeoptions);
$gradeoptions = array(0 => $strcondnone) + $gradeoptions;
$grouparray = array();
$grouparray[] = $mform->createElement('select', 'conditiongradeitemid', '', $gradeoptions);
$grouparray[] = $mform->createElement('static', '', '', ' ' . get_string('grade_atleast', 'condition') . ' ');
$grouparray[] = $mform->createElement('text', 'conditiongrademin', '', array('size' => 3));
$grouparray[] = $mform->createElement('static', '', '', '% ' . get_string('grade_upto', 'condition') . ' ');
$grouparray[] = $mform->createElement('text', 'conditiongrademax', '', array('size' => 3));
$grouparray[] = $mform->createElement('static', '', '', '%');
$group = $mform->createElement('group', 'conditiongradegroup', get_string('gradecondition', 'condition'), $grouparray);
// Get full version (including condition info) of section object
$ci = new condition_info_section($this->_customdata['cs']);
$fullcs = $ci->get_full_section();
$count = count($fullcs->conditionsgrade) + 1;
// Grade conditions
$this->repeat_elements(array($group), $count, array('conditiongradegroup[conditiongrademin]' => array('type' => PARAM_RAW), 'conditiongradegroup[conditiongrademax]' => array('type' => PARAM_RAW)), 'conditiongraderepeats', 'conditiongradeadds', 2, get_string('addgrades', 'condition'), true);
$mform->addHelpButton('conditiongradegroup[0]', 'gradecondition', 'condition');
// Conditions based on user fields
$operators = condition_info::get_condition_user_field_operators();
$useroptions = condition_info::get_condition_user_fields(array('context' => $context));
asort($useroptions);
$useroptions = array(0 => $strcondnone) + $useroptions;
$grouparray = array();
$grouparray[] =& $mform->createElement('select', 'conditionfield', '', $useroptions);
$grouparray[] =& $mform->createElement('select', 'conditionfieldoperator', '', $operators);
$grouparray[] =& $mform->createElement('text', 'conditionfieldvalue');
$group = $mform->createElement('group', 'conditionfieldgroup', get_string('userfield', 'condition'), $grouparray);
$fieldcount = count($fullcs->conditionsfield) + 1;
$this->repeat_elements(array($group), $fieldcount, array('conditionfieldgroup[conditionfieldvalue]' => array('type' => PARAM_RAW)), 'conditionfieldrepeats', 'conditionfieldadds', 2, get_string('adduserfields', 'condition'), true);
$mform->addHelpButton('conditionfieldgroup[0]', 'userfield', 'condition');
// Conditions based on completion
$completion = new completion_info($course);
if ($completion->is_enabled()) {
$completionoptions = array();
$modinfo = get_fast_modinfo($course);
foreach ($modinfo->cms as $id => $cm) {
// Add each course-module if it:
// (a) has completion turned on
// (b) does not belong to current course-section
if ($cm->completion && $fullcs->id != $cm->section) {
$completionoptions[$id] = $cm->name;
}
}
asort($completionoptions);
$completionoptions = array(0 => $strcondnone) + $completionoptions;
$completionvalues = array(COMPLETION_COMPLETE => get_string('completion_complete', 'condition'), COMPLETION_INCOMPLETE => get_string('completion_incomplete', 'condition'), COMPLETION_COMPLETE_PASS => get_string('completion_pass', 'condition'), COMPLETION_COMPLETE_FAIL => get_string('completion_fail', 'condition'));
$grouparray = array();
$grouparray[] = $mform->createElement('select', 'conditionsourcecmid', '', $completionoptions);
$grouparray[] = $mform->createElement('select', 'conditionrequiredcompletion', '', $completionvalues);
$group = $mform->createElement('group', 'conditioncompletiongroup', get_string('completioncondition', 'condition'), $grouparray);
$count = count($fullcs->conditionscompletion) + 1;
$this->repeat_elements(array($group), $count, array(), 'conditioncompletionrepeats', 'conditioncompletionadds', 2, get_string('addcompletions', 'condition'), true);
$mform->addHelpButton('conditioncompletiongroup[0]', 'completionconditionsection', 'condition');
}
// Availability conditions - set up form values
if (!empty($CFG->enableavailability)) {
$num = 0;
foreach ($fullcs->conditionsgrade as $gradeitemid => $minmax) {
$groupelements = $mform->getElement('conditiongradegroup[' . $num . ']')->getElements();
$groupelements[0]->setValue($gradeitemid);
$groupelements[2]->setValue(is_null($minmax->min) ? '' : format_float($minmax->min, 5, true, true));
//.........这里部分代码省略.........
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:101,代码来源:editsection_form.php
示例17: get_listing
public function get_listing($path = '', $page = '') {
global $CFG, $OUTPUT;
$list = array();
$list['list'] = array();
// process breacrumb trail
$list['path'] = array(
array('name'=>get_string('root', 'repository_filesystem'), 'path'=>'')
);
$trail = '';
if (!empty($path)) {
$parts = explode('/', $path);
if (count($parts) > 1) {
foreach ($parts as $part) {
if (!empty($part)) {
$trail .= ('/'.$part);
$list['path'][] = array('name'=>$part, 'path'=>$trail);
}
}
} else {
$list['path'][] = array('name'=>$path, 'path'=>$path);
}
$this->root_path .= ($path.'/');
}
$list['manage'] = false;
$list['dynload'] = true;
$list['nologin'] = true;
$list['nosearch'] = true;
// retrieve list of files and directories and sort them
$fileslist = array();
$dirslist = array();
if ($dh = opendir($this->root_path)) {
while (($file = readdir($dh)) != false) {
if ( $file != '.' and $file !='..') {
if (is_file($this->root_path.$file)) {
$fileslist[] = $file;
} else {
$dirslist[] = $file;
}
}
}
}
collatorlib::asort($fileslist, collatorlib::SORT_STRING);
collatorlib::asort($dirslist, collatorlib::SORT_STRING);
// fill the $list['list']
foreach ($dirslist as $file) {
if (!empty($path)) {
$current_path = $path . '/'. $file;
} else {
$current_path = $file;
}
$list['list'][] = array(
'title' => $file,
'children' => array(),
'datecreated' => filectime($this->root_path.$file),
'datemodified' => filemtime($this->root_path.$file),
'thumbnail' => $OUTPUT->pix_url(file_folder_icon(90))->out(false),
'path' => $current_path
);
}
foreach ($fileslist as $file) {
$list['list'][] = array(
'title' => $file,
'source' => $path.'/'.$file,
'size' => filesize($this->root_path.$file),
'datecreated' => filectime($this->root_path.$file),
'datemodified' => filemtime($this->root_path.$file),
'thumbnail' => $OUTPUT->pix_url(file_extension_icon($file, 90))->out(false),
'icon' => $OUTPUT->pix_url(file_extension_icon($file, 24))->out(false)
);
}
$list['list'] = array_filter($list['list'], array($this, 'filter'));
return $list;
}
开发者ID:nigeli,项目名称:moodle,代码行数:73,代码来源:lib.php
示例18: get_list_of_translations
/**
* Returns localised list of installed translations
*
* @param bool $returnall return all or just enabled
* @return array moodle translation code => localised translation name
*/
public function get_list_of_translations($returnall = false)
{
global $CFG;
$languages = array();
if (!empty($CFG->langcache) and is_readable($this->menucache)) {
// try to re-use the cached list of all available languages
$cachedlist = json_decode(file_get_contents($this->menucache), true);
if (is_array($cachedlist) and !empty($cachedlist)) {
// the cache file is restored correctly
if (!$returnall and !empty($this->translist)) {
// return just enabled translations
foreach ($cachedlist as $langcode => $langname) {
if (in_array($langcode, $this->translist)) {
$languages[$langcode] = $langname;
}
}
return $languages;
} else {
// return all translations
return $cachedlist;
}
}
}
// the cached list of languages is not available, let us populate the list
if (!$returnall and !empty($this->translist)) {
// return only some translations
foreach ($this->translist as $lang) {
$lang = trim($lang);
//Just trim spaces to be a bit more permissive
if (strstr($lang, '_local') !== false) {
continue;
}
if (strstr($lang, '_utf8') !== false) {
continue;
}
if ($lang !== 'en' and !file_exists("{$this->otherroot}/{$lang}/langconfig.php")) {
// some broken or missing lang - can not switch to it anyway
continue;
}
$string = $this->load_component_strings('langconfig', $lang);
if (!empty($string['thislanguage'])) {
$languages[$lang] = $string['thislanguage'] . ' (' . $lang . ')';
}
unset($string);
}
} else {
// return all languages available in system
$langdirs = get_list_of_plugins('', '', $this->otherroot);
$langdirs = array_merge($langdirs, array("{$CFG->dirroot}/lang/en" => 'en'));
// Sort all
// Loop through all langs and get info
foreach ($langdirs as $lang) {
if (strstr($lang, '_local') !== false) {
continue;
}
if (strstr($lang, '_utf8') !== false) {
continue;
}
$string = $this->load_component_strings('langconfig', $lang);
if (!empty($string['thislanguage'])) {
$languages[$lang] = $string['thislanguage'] . ' (' . $lang . ')';
}
unset($string);
}
if (!empty($CFG->langcache) and !empty($this->menucache)) {
// cache the list so that it can be used next time
collatorlib::asort($languages);
check_dir_exists(dirname($this->menucache), true, true);
file_put_contents($this->menucache, json_encode($languages));
}
}
collatorlib::asort($languages);
return $languages;
}
开发者ID:nmicha, |
请发表评论