当前位置: 首页>>代码示例>>PHP>>正文


PHP make_categories_list函数代码示例

本文整理汇总了PHP中make_categories_list函数的典型用法代码示例。如果您正苦于以下问题:PHP make_categories_list函数的具体用法?PHP make_categories_list怎么用?PHP make_categories_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了make_categories_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_course_categories

 /**
  * Returns an array of course categories
  * @return array of course categories
  */
 function get_course_categories()
 {
     $displaylist = array();
     $parentlist = array();
     make_categories_list($displaylist, $parentlist);
     return array(0 => get_string('anycategory', 'filters')) + $displaylist;
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:11,代码来源:courserole.php

示例2: definition

 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $category = $this->_customdata;
     // get list of categories to use as parents, with site as the first one
     $options = array(get_string('top'));
     $parents = array();
     if ($category->id) {
         // Editing an existing category.
         make_categories_list($options, $parents, 'moodle/category:manage', $category->id);
         $strsubmit = get_string('savechanges');
     } else {
         // Making a new category
         make_categories_list($options, $parents, 'moodle/category:manage');
         $strsubmit = get_string('createcategory');
     }
     $mform->addElement('select', 'parent', get_string('parentcategory'), $options);
     $mform->addElement('text', 'name', get_string('categoryname'), array('size' => '30'));
     $mform->addRule('name', get_string('required'), 'required', null);
     $mform->addElement('htmleditor', 'description', get_string('description'));
     $mform->setType('description', PARAM_RAW);
     if (!empty($CFG->allowcategorythemes)) {
         $themes = array();
         $themes[''] = get_string('forceno');
         $themes += get_list_of_themes();
         $mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
     }
     $mform->setHelpButton('description', array('writing', 'richtext2'), false, 'editorhelpbutton');
     $mform->addElement('hidden', 'id', 0);
     $mform->setType('id', PARAM_INT);
     $mform->setDefault('id', $category->id);
     $this->add_action_buttons(true, $strsubmit);
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:34,代码来源:editcategory_form.php

示例3: get_course_categories

 /**
  * Returns an array of course categories
  * @return array of course categories
  */
 function get_course_categories() {
     global $CFG;
     require_once($CFG->dirroot.'/course/lib.php');
     $displaylist = array();
     $parentlist = array();
     make_categories_list($displaylist, $parentlist);
     return array(0=> get_string('anycategory', 'filters')) + $displaylist;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:12,代码来源:courserole.php

示例4: definition

 public function definition()
 {
     $mform =& $this->_form;
     // General settings -------------------------------------------------------------
     /// Adding the "general" fieldset, where all the common settings are showed
     $mform->addElement('header', 'general', get_string('general', 'form'));
     /// Adding the standard "name" field
     $mform->addElement('text', 'name', get_string('subcoursename', 'subcourse'), array('size' => '64'));
     $mform->setType('name', PARAM_TEXT);
     $mform->addRule('name', null, 'required', null, 'client');
     /// Adding the optional "intro" and "introformat" pair of fields
     $this->add_intro_editor(true, get_string('subcourseintro', 'subcourse'));
     // Subcourse information --------------------------------------------------------
     $mform->addElement('header', 'subcoursefieldset', get_string('refcourse', 'subcourse'));
     /// Referenced course selector
     $mycourses = subcourse_available_courses();
     $catlist = array();
     $catparents = array();
     make_categories_list($catlist, $catparents);
     $options = array();
     foreach ($mycourses as $mycourse) {
         if (empty($options[$catlist[$mycourse->category]])) {
             $options[$catlist[$mycourse->category]] = array();
         }
         $courselabel = $mycourse->fullname . ' (' . $mycourse->shortname . ')';
         $options[$catlist[$mycourse->category]][$mycourse->id] = $courselabel;
         if (empty($mycourse->visible)) {
             $hiddenlabel = ' ' . get_string('hiddencourse', 'subcourse');
             $options[$catlist[$mycourse->category]][$mycourse->id] .= $hiddenlabel;
         }
     }
     unset($mycourse);
     /**
      * @var $refcourseelement HTML_QuickForm_input
      */
     $refcourseelement = $mform->addElement('selectgroups', 'refcourse', get_string('refcourselabel', 'subcourse'), $options);
     $mform->addHelpButton('refcourse', 'refcourse', 'subcourse');
     // Option to add a meta course enrolment to the other course.
     /**
      * @var $addmetaelement HTML_QuickForm_input
      */
     $addmetaelement = $mform->addElement('checkbox', 'addmeta', get_string('addmeta', 'subcourse'));
     // If there is a meta enrolment already, we don't want to allow people to delete it as we
     // may cause problems. Force them to delete the whole subcourse if they want to do this
     if (!empty($this->current->id)) {
         $metaexists = subcourse_meta_exists($this->current->course, $this->current->refcourse);
         if ($metaexists) {
             $mform->setDefault('addmeta', 'checked');
             $refcourseelement->updateAttributes(array('disabled' => true));
             $addmetaelement->updateAttributes(array('disabled' => true));
         }
     }
     // add standard elements, common to all modules
     $this->standard_coursemodule_elements();
     // add standard buttons, common to all modules
     $this->add_action_buttons();
 }
开发者ID:nadavkav,项目名称:moodle-mod_subcourse,代码行数:57,代码来源:mod_form.php

示例5: definition

 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $category = $this->_customdata;
     $this->_category = $category;
     $mform->addElement('header', 'general', get_string('categorycurrentcontents', '', format_string($category->name)));
     $displaylist = array();
     $parentlist = array();
     $children = array();
     make_categories_list($displaylist, $parentlist);
     unset($displaylist[$category->id]);
     foreach ($displaylist as $catid => $unused) {
         // remove all children of $category
         if (isset($parentlist[$catid]) and in_array($category->id, $parentlist[$catid])) {
             $children[] = $catid;
             unset($displaylist[$catid]);
             continue;
         }
         if (!has_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $catid))) {
             unset($displaylist[$catid]);
         }
     }
     $candeletecontent = true;
     foreach ($children as $catid) {
         $context = get_context_instance(CONTEXT_COURSECAT, $catid);
         if (!has_capability('moodle/category:delete', $context)) {
             $candeletecontent = false;
             break;
         }
     }
     $options = array();
     if ($displaylist) {
         $options[0] = get_string('move');
     }
     if ($candeletecontent) {
         $options[1] = get_string('delete');
     }
     if (empty($options)) {
         print_error('nocategorydelete', 'error', 'index.php', format_string($category->name));
     }
     $mform->addElement('select', 'fulldelete', get_string('categorycontents'), $options);
     $mform->disabledIf('newparent', 'fulldelete', 'eq', '1');
     $mform->setDefault('newparent', 0);
     if ($displaylist) {
         $mform->addElement('select', 'newparent', get_string('movecategorycontentto'), $displaylist);
         if (in_array($category->parent, $displaylist)) {
             $mform->setDefault('newparent', $category->parent);
         }
     }
     $mform->addElement('hidden', 'delete');
     $mform->addElement('hidden', 'sure');
     $mform->setDefault('sure', md5(serialize($category)));
     //--------------------------------------------------------------------------------
     $this->add_action_buttons(true, get_string('delete'));
 }
开发者ID:r007,项目名称:PMoodle,代码行数:56,代码来源:delete_category_form.php

示例6: definition

 function definition()
 {
     global $USER, $CFG;
     $mform =& $this->_form;
     $mform->addElement('header', '', get_string('coursefield', 'block_configurable_reports'), '');
     $options = array(get_string('top'));
     $parents = array();
     make_categories_list($options, $parents);
     $mform->addElement('select', 'categoryid', get_string('category'), $options);
     // buttons
     $this->add_action_buttons(true, get_string('add'));
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:12,代码来源:form.php

示例7: definition

 function definition()
 {
     global $DB, $USER, $CFG;
     require_once $CFG->dirroot . '/course/lib.php';
     $mform =& $this->_form;
     $mform->addElement('header', '', get_string('coursefield', 'report_configreports'), '');
     $options = array(get_string('top'));
     $parents = array();
     make_categories_list($options, $parents);
     $mform->addElement('select', 'categoryid', get_string('category'), $options);
     $mform->addElement('checkbox', 'includesubcats', get_string('includesubcats', 'report_configreports'));
     // buttons
     $this->add_action_buttons(true, get_string('add'));
 }
开发者ID:nickkoeppen,项目名称:moodle-report_configreports,代码行数:14,代码来源:form.php

示例8: definition

 function definition()
 {
     global $CFG, $DB;
     $mform =& $this->_form;
     $category = $this->_customdata['category'];
     $editoroptions = $this->_customdata['editoroptions'];
     // get list of categories to use as parents, with site as the first one
     $options = array();
     if (has_capability('moodle/category:manage', get_system_context()) || $category->parent == 0) {
         $options[0] = get_string('top');
     }
     $parents = array();
     if ($category->id) {
         // Editing an existing category.
         make_categories_list($options, $parents, 'moodle/category:manage', $category->id);
         if (empty($options[$category->parent])) {
             $options[$category->parent] = $DB->get_field('course_categories', 'name', array('id' => $category->parent));
         }
         $strsubmit = get_string('savechanges');
     } else {
         // Making a new category
         make_categories_list($options, $parents, 'moodle/category:manage');
         $strsubmit = get_string('createcategory');
     }
     $mform->addElement('select', 'parent', get_string('parentcategory'), $options);
     $mform->addElement('text', 'name', get_string('categoryname'), array('size' => '30'));
     $mform->addRule('name', get_string('required'), 'required', null);
     $mform->addElement('text', 'idnumber', get_string('idnumbercoursecategory'), 'maxlength="100"  size="10"');
     $mform->addHelpButton('idnumber', 'idnumbercoursecategory');
     $mform->addElement('editor', 'description_editor', get_string('description'), null, $editoroptions);
     $mform->setType('description_editor', PARAM_RAW);
     if (!empty($CFG->allowcategorythemes)) {
         $themes = array('' => get_string('forceno'));
         $allthemes = get_list_of_themes();
         foreach ($allthemes as $key => $theme) {
             if (empty($theme->hidefromselector)) {
                 $themes[$key] = get_string('pluginname', 'theme_' . $theme->name);
             }
         }
         $mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
     }
     $mform->addElement('static', 'label1', 'No of subject', '<div id="noofsubject"></div>');
     $mform->addElement('static', 'label1', 'Course Selection', '<div id="basic-modal"><a href="#" class="basic">View All</a></div>');
     $mform->addElement('hidden', 'id', 0);
     $mform->setType('id', PARAM_INT);
     $mform->setDefault('id', $category->id);
     $this->add_action_buttons(true, $strsubmit);
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:48,代码来源:editcategory_form.php

示例9: definition

    function definition() {
        global $CFG, $DB;
        $mform =& $this->_form;
        $category = $this->_customdata['category'];
        $editoroptions = $this->_customdata['editoroptions'];

        // get list of categories to use as parents, with site as the first one
        $options = array();
        if (has_capability('moodle/category:manage', get_system_context()) || $category->parent == 0) {
            $options[0] = get_string('top');
        }
        $parents = array();
        if ($category->id) {
            // Editing an existing category.
            make_categories_list($options, $parents, 'moodle/category:manage', $category->id);
            if (empty($options[$category->parent])) {
                $options[$category->parent] = $DB->get_field('course_categories', 'name', array('id'=>$category->parent));
            }
            $strsubmit = get_string('savechanges');
        } else {
            // Making a new category
            make_categories_list($options, $parents, 'moodle/category:manage');
            $strsubmit = get_string('createcategory');
        }

        $mform->addElement('select', 'parent', get_string('parentcategory'), $options);
        $mform->addElement('text', 'name', get_string('categoryname'), array('size'=>'30'));
        $mform->addRule('name', get_string('required'), 'required', null);
        $mform->addElement('editor', 'description_editor', get_string('description'), null, $editoroptions);
        $mform->setType('description_editor', PARAM_RAW);
        if (!empty($CFG->allowcategorythemes)) {
            $themes = array(''=>get_string('forceno'));
            $allthemes = get_list_of_themes();
            foreach ($allthemes as $key=>$theme) {
                $themes[$key] = $theme->name;
            }
            $mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
        }

        $mform->addElement('hidden', 'id', 0);
        $mform->setType('id', PARAM_INT);
        $mform->setDefault('id', $category->id);

        $this->add_action_buttons(true, $strsubmit);
    }
开发者ID:nuckey,项目名称:moodle,代码行数:45,代码来源:editcategory_form.php

示例10: execute

 function execute($data, $user, $courseid)
 {
     if (isset($data->includesubcats)) {
         if ($category = get_record('course_categories', 'id', $data->categoryid)) {
             make_categories_list($options, $parents, '', 0, $category);
         } else {
             make_categories_list($options, $parents);
         }
         unset($options[$data->categoryid]);
         return array_keys($options);
     } else {
         $categories = get_records('course_categories', 'parent', $data->categoryid);
         if ($categories) {
             return array_keys($categories);
         }
     }
     return array();
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:18,代码来源:plugin.class.php

示例11: execute

 function execute($data, $user, $courseid)
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/course/lib.php';
     if (isset($data->includesubcats)) {
         if ($category = $DB->get_record('course_categories', array('id' => $data->categoryid))) {
             make_categories_list($options, $parents, '', 0, $category);
         } else {
             make_categories_list($options, $parents);
         }
         unset($options[$data->categoryid]);
         return array_keys($options);
     } else {
         $categories = $DB->get_records('course_categories', array('parent' => $data->categoryid));
         if ($categories) {
             return array_keys($categories);
         }
     }
     return array();
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:20,代码来源:plugin.class.php

示例12: get_category_options

 protected function get_category_options($currentcontextid)
 {
     $displaylist = array();
     $parentlist = array();
     make_categories_list($displaylist, $parentlist, 'moodle/cohort:manage');
     $options = array();
     $syscontext = context_system::instance();
     if (has_capability('moodle/cohort:manage', $syscontext)) {
         $options[$syscontext->id] = print_context_name($syscontext);
     }
     foreach ($displaylist as $cid => $name) {
         $context = context_coursecat::instance($cid);
         $options[$context->id] = $name;
     }
     // always add current - this is not likely, but if the logic gets changed it might be a problem
     if (!isset($options[$currentcontextid])) {
         $context = get_context_instance_by_id($currentcontextid, MUST_EXIST);
         $options[$context->id] = print_context_name($syscontext);
     }
     return $options;
 }
开发者ID:nigeli,项目名称:moodle,代码行数:21,代码来源:edit_form.php

示例13: definition

 function definition()
 {
     global $CFG, $DB, $USER;
     $mform =& $this->_form;
     if ($pending = $DB->get_records('course_request', array('requester' => $USER->id))) {
         $mform->addElement('header', 'pendinglist', get_string('coursespending'));
         $list = array();
         foreach ($pending as $cp) {
             $list[] = format_string($cp->fullname);
         }
         $list = implode(', ', $list);
         $mform->addElement('static', 'pendingcourses', get_string('courses'), $list);
     }
     $mform->addElement('header', 'coursedetails', get_string('courserequestdetails'));
     $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"');
     $mform->addHelpButton('fullname', 'fullnamecourse');
     $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
     $mform->setType('fullname', PARAM_TEXT);
     $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"');
     $mform->addHelpButton('shortname', 'shortnamecourse');
     $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
     $mform->setType('shortname', PARAM_TEXT);
     if (!empty($CFG->requestcategoryselection)) {
         $displaylist = array();
         $parentlist = array();
         make_categories_list($displaylist, $parentlist, '');
         $mform->addElement('select', 'category', get_string('category'), $displaylist);
         $mform->setDefault('category', $CFG->defaultrequestcategory);
         $mform->addHelpButton('category', 'category');
     }
     $mform->addElement('editor', 'summary_editor', get_string('summary'), null, course_request::summary_editor_options());
     $mform->addHelpButton('summary_editor', 'coursesummary');
     $mform->setType('summary_editor', PARAM_RAW);
     $mform->addElement('header', 'requestreason', get_string('courserequestreason'));
     $mform->addElement('textarea', 'reason', get_string('courserequestsupport'), array('rows' => '15', 'cols' => '50'));
     $mform->addRule('reason', get_string('missingreqreason'), 'required', null, 'client');
     $mform->setType('reason', PARAM_TEXT);
     $this->add_action_buttons(true, get_string('requestcourse'));
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:39,代码来源:request_form.php

示例14: definition

 function definition()
 {
     global $CFG, $DB;
     $mform =& $this->_form;
     $category = $this->_customdata;
     $categorycontext = context_coursecat::instance($category->id);
     $this->_category = $category;
     /// Check permissions, to see if it OK to give the option to delete
     /// the contents, rather than move elsewhere.
     /// Are there any subcategories of this one, can they be deleted?
     $candeletecontent = true;
     $tocheck = get_child_categories($category->id);
     $containscategories = !empty($tocheck);
     $categoryids = array($category->id);
     while (!empty($tocheck)) {
         $checkcat = array_pop($tocheck);
         $childcategoryids[] = $checkcat->id;
         $tocheck = $tocheck + get_child_categories($checkcat->id);
         $chcontext = context_coursecat::instance($checkcat->id);
         if ($candeletecontent && !has_capability('moodle/category:manage', $chcontext)) {
             $candeletecontent = false;
         }
     }
     /// Are there any courses in here, can they be deleted?
     list($test, $params) = $DB->get_in_or_equal($categoryids);
     $containedcourses = $DB->get_records_sql("SELECT id,1 FROM {course} c WHERE c.category {$test}", $params);
     $containscourses = false;
     if ($containedcourses) {
         $containscourses = true;
         foreach ($containedcourses as $courseid => $notused) {
             if ($candeletecontent && !can_delete_course($courseid)) {
                 $candeletecontent = false;
                 break;
             }
         }
     }
     /// Are there any questions in the question bank here?
     $containsquestions = question_context_has_any_questions($categorycontext);
     /// Get the list of categories we might be able to move to.
     $testcaps = array();
     if ($containscourses) {
         $testcaps[] = 'moodle/course:create';
     }
     if ($containscategories || $containsquestions) {
         $testcaps[] = 'moodle/category:manage';
     }
     $displaylist = array();
     $notused = array();
     if (!empty($testcaps)) {
         make_categories_list($displaylist, $notused, $testcaps, $category->id);
     }
     /// Now build the options.
     $options = array();
     if ($displaylist) {
         $options[0] = get_string('movecontentstoanothercategory');
     }
     if ($candeletecontent) {
         $options[1] = get_string('deleteallcannotundo');
     }
     /// Now build the form.
     $mform->addElement('header', 'general', get_string('categorycurrentcontents', '', format_string($category->name, true, array('context' => $categorycontext))));
     if ($containscourses || $containscategories || $containsquestions) {
         if (empty($options)) {
             print_error('youcannotdeletecategory', 'error', 'index.php', format_string($category->name, true, array('context' => $categorycontext)));
         }
         /// Describe the contents of this category.
         $contents = '<ul>';
         if ($containscategories) {
             $contents .= '<li>' . get_string('subcategories') . '</li>';
         }
         if ($containscourses) {
             $contents .= '<li>' . get_string('courses') . '</li>';
         }
         if ($containsquestions) {
             $contents .= '<li>' . get_string('questionsinthequestionbank') . '</li>';
         }
         $contents .= '</ul>';
         $mform->addElement('static', 'emptymessage', get_string('thiscategorycontains'), $contents);
         /// Give the options for what to do.
         $mform->addElement('select', 'fulldelete', get_string('whattodo'), $options);
         if (count($options) == 1) {
             $optionkeys = array_keys($options);
             $option = reset($optionkeys);
             $mform->hardFreeze('fulldelete');
             $mform->setConstant('fulldelete', $option);
         }
         if ($displaylist) {
             $mform->addElement('select', 'newparent', get_string('movecategorycontentto'), $displaylist);
             if (in_array($category->parent, $displaylist)) {
                 $mform->setDefault('newparent', $category->parent);
             }
             $mform->disabledIf('newparent', 'fulldelete', 'eq', '1');
         }
     } else {
         $mform->addElement('hidden', 'fulldelete', 1);
         $mform->setType('fulldelete', PARAM_INT);
         $mform->addElement('static', 'emptymessage', '', get_string('deletecategoryempty'));
     }
     $mform->addElement('hidden', 'delete');
     $mform->setType('delete', PARAM_ALPHANUM);
//.........这里部分代码省略.........
开发者ID:JP-Git,项目名称:moodle,代码行数:101,代码来源:delete_category_form.php

示例15: print_whole_category_list2

function print_whole_category_list2($category = NULL, $displaylist = NULL, $parentslist = NULL, $depth = -1, $showcourses = true)
{
    global $CFG;
    // maxcategorydepth == 0 meant no limit
    if (!empty($CFG->maxcategorydepth) && $depth >= $CFG->maxcategorydepth) {
        return;
    }
    if (!$displaylist) {
        make_categories_list($displaylist, $parentslist);
    }
    if ($category) {
        if ($category->visible or has_capability('moodle/category:viewhiddencategories', get_context_instance(CONTEXT_SYSTEM))) {
            print_category_info2($category, $depth, $showcourses);
        } else {
            return;
            // Don't bother printing children of invisible categories
        }
    } else {
        $category->id = "0";
    }
    if ($categories = get_child_categories($category->id)) {
        // Print all the children recursively
        $countcats = count($categories);
        $count = 0;
        $first = true;
        $last = false;
        foreach ($categories as $cat) {
            $count++;
            if ($count == $countcats) {
                $last = true;
            }
            $up = $first ? false : true;
            $down = $last ? false : true;
            $first = false;
            print_whole_category_list2($cat, $displaylist, $parentslist, $depth + 1, $showcourses);
        }
    }
}
开发者ID:nustlms,项目名称:moodle-block_custom_reports,代码行数:38,代码来源:audit.php


注:本文中的make_categories_list函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。