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


PHP coursecat::has_children方法代码示例

本文整理汇总了PHP中coursecat::has_children方法的典型用法代码示例。如果您正苦于以下问题:PHP coursecat::has_children方法的具体用法?PHP coursecat::has_children怎么用?PHP coursecat::has_children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在coursecat的用法示例。


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

示例1: definition

 /**
  * Defines the form.
  */
 public function definition()
 {
     $mform = $this->_form;
     $this->coursecat = $this->_customdata;
     $categorycontext = context_coursecat::instance($this->coursecat->id);
     $categoryname = $this->coursecat->get_formatted_name();
     // Check permissions, to see if it OK to give the option to delete
     // the contents, rather than move elsewhere.
     $candeletecontent = $this->coursecat->can_delete_full();
     // Get the list of categories we might be able to move to.
     $displaylist = $this->coursecat->move_content_targets_list();
     // Now build the options.
     $options = array();
     if ($displaylist) {
         $options[0] = get_string('movecontentstoanothercategory');
     }
     if ($candeletecontent) {
         $options[1] = get_string('deleteallcannotundo');
     }
     if (empty($options)) {
         print_error('youcannotdeletecategory', 'error', 'index.php', $categoryname);
     }
     // Now build the form.
     $mform->addElement('header', 'general', get_string('categorycurrentcontents', '', $categoryname));
     // Describe the contents of this category.
     $contents = '';
     if ($this->coursecat->has_children()) {
         $contents .= '<li>' . get_string('subcategories') . '</li>';
     }
     if ($this->coursecat->has_courses()) {
         $contents .= '<li>' . get_string('courses') . '</li>';
     }
     if (question_context_has_any_questions($categorycontext)) {
         $contents .= '<li>' . get_string('questionsinthequestionbank') . '</li>';
     }
     if (!empty($contents)) {
         $mform->addElement('static', 'emptymessage', get_string('thiscategorycontains'), html_writer::tag('ul', $contents));
     } else {
         $mform->addElement('static', 'emptymessage', '', get_string('deletecategoryempty'));
     }
     // 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($this->coursecat->parent, $displaylist)) {
             $mform->setDefault('newparent', $this->coursecat->parent);
         }
         $mform->disabledIf('newparent', 'fulldelete', 'eq', '1');
     }
     $mform->addElement('hidden', 'categoryid', $this->coursecat->id);
     $mform->setType('categoryid', PARAM_ALPHANUM);
     $mform->addElement('hidden', 'action', 'deletecategory');
     $mform->setType('action', PARAM_ALPHANUM);
     $mform->addElement('hidden', 'sure');
     // This gets set by default to ensure that if the user changes it manually we can detect it.
     $mform->setDefault('sure', md5(serialize($this->coursecat)));
     $mform->setType('sure', PARAM_ALPHANUM);
     $this->add_action_buttons(true, get_string('delete'));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:68,代码来源:deletecategory_form.php

示例2: get_category_listitem_actions

 /**
  * Returns an array of actions that can be performed upon a category being shown in a list.
  *
  * @param \coursecat $category
  * @return array
  */
 public static function get_category_listitem_actions(\coursecat $category)
 {
     global $PAGE;
     $baseurl = new \moodle_url('/course/management.php', array('categoryid' => $category->id, 'sesskey' => \sesskey()));
     $actions = array();
     // Edit.
     if ($category->can_edit()) {
         $actions['edit'] = array('url' => new \moodle_url('/course/editcategory.php', array('id' => $category->id)), 'icon' => new \pix_icon('t/edit', new \lang_string('edit')), 'string' => new \lang_string('edit'));
     }
     // Show/Hide.
     if ($category->can_change_visibility()) {
         // We always show both icons and then just toggle the display of the invalid option with CSS.
         $actions['hide'] = array('url' => new \moodle_url($baseurl, array('action' => 'hidecategory')), 'icon' => new \pix_icon('t/hide', new \lang_string('hide')), 'string' => new \lang_string('hide'));
         $actions['show'] = array('url' => new \moodle_url($baseurl, array('action' => 'showcategory')), 'icon' => new \pix_icon('t/show', new \lang_string('show')), 'string' => new \lang_string('show'));
     }
     // Move up/down.
     if ($category->can_change_sortorder()) {
         $actions['moveup'] = array('url' => new \moodle_url($baseurl, array('action' => 'movecategoryup')), 'icon' => new \pix_icon('t/up', new \lang_string('up')), 'string' => new \lang_string('up'));
         $actions['movedown'] = array('url' => new \moodle_url($baseurl, array('action' => 'movecategorydown')), 'icon' => new \pix_icon('t/down', new \lang_string('down')), 'string' => new \lang_string('down'));
     }
     if ($category->can_create_subcategory()) {
         $actions['createnewsubcategory'] = array('url' => new \moodle_url('/course/editcategory.php', array('parent' => $category->id)), 'icon' => new \pix_icon('i/withsubcat', new \lang_string('createnewsubcategory')), 'string' => new \lang_string('createnewsubcategory'));
     }
     // Resort.
     if ($category->can_resort_subcategories() && $category->has_children()) {
         $actions['resortbyname'] = array('url' => new \moodle_url($baseurl, array('action' => 'resortcategories', 'resort' => 'name')), 'icon' => new \pix_icon('t/sort', new \lang_string('sort')), 'string' => new \lang_string('resortsubcategoriesby', 'moodle', get_string('categoryname')));
         $actions['resortbynamedesc'] = array('url' => new \moodle_url($baseurl, array('action' => 'resortcategories', 'resort' => 'namedesc')), 'icon' => new \pix_icon('t/sort', new \lang_string('sort')), 'string' => new \lang_string('resortsubcategoriesbyreverse', 'moodle', get_string('categoryname')));
         $actions['resortbyidnumber'] = array('url' => new \moodle_url($baseurl, array('action' => 'resortcategories', 'resort' => 'idnumber')), 'icon' => new \pix_icon('t/sort', new \lang_string('sort')), 'string' => new \lang_string('resortsubcategoriesby', 'moodle', get_string('idnumbercoursecategory')));
         $actions['resortbyidnumberdesc'] = array('url' => new \moodle_url($baseurl, array('action' => 'resortcategories', 'resort' => 'idnumberdesc')), 'icon' => new \pix_icon('t/sort', new \lang_string('sort')), 'string' => new \lang_string('resortsubcategoriesbyreverse', 'moodle', get_string('idnumbercoursecategory')));
     }
     // Delete.
     if ($category->can_delete_full()) {
         $actions['delete'] = array('url' => new \moodle_url($baseurl, array('action' => 'deletecategory')), 'icon' => new \pix_icon('t/delete', new \lang_string('delete')), 'string' => new \lang_string('delete'));
     }
     // Assign roles.
     if ($category->can_review_roles()) {
         $actions['assignroles'] = array('url' => new \moodle_url('/admin/roles/assign.php', array('contextid' => $category->get_context()->id, 'returnurl' => $PAGE->url->out_as_local_url(false))), 'icon' => new \pix_icon('t/assignroles', new \lang_string('assignroles', 'role')), 'string' => new \lang_string('assignroles', 'role'));
     }
     // Permissions.
     if ($category->can_review_permissions()) {
         $actions['permissions'] = array('url' => new \moodle_url('/admin/roles/permissions.php', array('contextid' => $category->get_context()->id, 'returnurl' => $PAGE->url->out_as_local_url(false))), 'icon' => new \pix_icon('i/permissions', new \lang_string('permissions', 'role')), 'string' => new \lang_string('permissions', 'role'));
     }
     // Check permissions.
     if ($category->can_review_permissions()) {
         $actions['checkroles'] = array('url' => new \moodle_url('/admin/roles/check.php', array('contextid' => $category->get_context()->id, 'returnurl' => $PAGE->url->out_as_local_url(false))), 'icon' => new \pix_icon('i/checkpermissions', new \lang_string('checkpermissions', 'role')), 'string' => new \lang_string('checkpermissions', 'role'));
     }
     // Cohorts.
     if ($category->can_review_cohorts()) {
         $actions['cohorts'] = array('url' => new \moodle_url('/cohort/index.php', array('contextid' => $category->get_context()->id)), 'icon' => new \pix_icon('t/cohort', new \lang_string('cohorts', 'cohort')), 'string' => new \lang_string('cohorts', 'cohort'));
     }
     // Filters.
     if ($category->can_review_filters()) {
         $actions['filters'] = array('url' => new \moodle_url('/filter/manage.php', array('contextid' => $category->get_context()->id, 'return' => 'management')), 'icon' => new \pix_icon('i/filter', new \lang_string('filters', 'admin')), 'string' => new \lang_string('filters', 'admin'));
     }
     if ($category->can_restore_courses_into()) {
         $actions['restore'] = array('url' => new \moodle_url('/backup/restorefile.php', array('contextid' => $category->get_context()->id)), 'icon' => new \pix_icon('i/restore', new \lang_string('restorecourse', 'admin')), 'string' => new \lang_string('restorecourse', 'admin'));
     }
     return $actions;
 }
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:65,代码来源:helper.php


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