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


PHP coursecat::get_formatted_name方法代码示例

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


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

示例1: print_category_edit

/**
 * Recursive function to print all the categories ready for editing.
 *
 * @param html_table $table The table to add data to.
 * @param coursecat $category The category to render
 * @param int $depth The depth of the category.
 * @param bool $up True if this category can be moved up.
 * @param bool $down True if this category can be moved down.
 */
function print_category_edit(html_table $table, coursecat $category, $depth = -1, $up = false, $down = false) {
    global $OUTPUT;

    static $str = null;

    if (is_null($str)) {
        $str = new stdClass;
        $str->edit = new lang_string('edit');
        $str->delete = new lang_string('delete');
        $str->moveup = new lang_string('moveup');
        $str->movedown = new lang_string('movedown');
        $str->edit = new lang_string('editthiscategory');
        $str->hide = new lang_string('hide');
        $str->show = new lang_string('show');
        $str->cohorts = new lang_string('cohorts', 'cohort');
        $str->spacer = $OUTPUT->spacer().' ';
    }

    if ($category->id) {

        $categorycontext = context_coursecat::instance($category->id);

        $attributes = array();
        $attributes['class'] = $category->visible ? '' : 'dimmed';
        $attributes['title'] = $str->edit;
        $categoryurl = new moodle_url('/course/manage.php', array('categoryid' => $category->id, 'sesskey' => sesskey()));
        $categoryname = $category->get_formatted_name();
        $categorypadding = str_repeat('      ', $depth);
        $categoryname = $categorypadding . html_writer::link($categoryurl, $categoryname, $attributes);

        $icons = array();
        if (has_capability('moodle/category:manage', $categorycontext)) {
            // Edit category.
            $icons[] = $OUTPUT->action_icon(
                new moodle_url('/course/editcategory.php', array('id' => $category->id)),
                new pix_icon('t/edit', $str->edit, 'moodle', array('class' => 'iconsmall')),
                null, array('title' => $str->edit)
            );
            // Delete category.
            $icons[] = $OUTPUT->action_icon(
                new moodle_url('/course/manage.php', array('deletecat' => $category->id, 'sesskey' => sesskey())),
                new pix_icon('t/delete', $str->delete, 'moodle', array('class' => 'iconsmall')),
                null, array('title' => $str->delete)
            );
            // Change visibility.
            if (!empty($category->visible)) {
                $icons[] = $OUTPUT->action_icon(
                    new moodle_url('/course/manage.php', array('hidecat' => $category->id, 'sesskey' => sesskey())),
                    new pix_icon('t/hide', $str->hide, 'moodle', array('class' => 'iconsmall')),
                    null, array('title' => $str->hide)
                );
            } else {
                $icons[] = $OUTPUT->action_icon(
                    new moodle_url('/course/manage.php', array('showcat' => $category->id, 'sesskey' => sesskey())),
                    new pix_icon('t/show', $str->show, 'moodle', array('class' => 'iconsmall')),
                    null, array('title' => $str->show)
                );
            }
            // Cohorts.
            if (has_any_capability(array('moodle/cohort:manage', 'moodle/cohort:view'), $categorycontext)) {
                $icons[] = $OUTPUT->action_icon(
                    new moodle_url('/cohort/index.php', array('contextid' => $categorycontext->id)),
                    new pix_icon('t/cohort', $str->cohorts, 'moodle', array('class' => 'iconsmall')),
                    null, array('title' => $str->cohorts)
                );
            }
            // Move up/down.
            if ($up) {
                $icons[] = $OUTPUT->action_icon(
                    new moodle_url('/course/manage.php', array('moveupcat' => $category->id, 'sesskey' => sesskey())),
                    new pix_icon('t/up', $str->moveup, 'moodle', array('class' => 'iconsmall')),
                    null, array('title' => $str->moveup)
                );
            } else {
                $icons[] = $str->spacer;
            }
            if ($down) {
                $icons[] = $OUTPUT->action_icon(
                    new moodle_url('/course/manage.php', array('movedowncat' => $category->id, 'sesskey' => sesskey())),
                    new pix_icon('t/down', $str->movedown, 'moodle', array('class' => 'iconsmall')),
                    null, array('title' => $str->movedown)
                );
            } else {
                $icons[] = $str->spacer;
            }
        }

        $actions = '';
        if (has_capability('moodle/category:manage', $categorycontext)) {
            $popupurl = new moodle_url('/course/manage.php', array('movecat' => $category->id, 'sesskey' => sesskey()));
            $tempdisplaylist = array(0 => get_string('top')) + coursecat::make_categories_list('moodle/category:manage', $category->id);
//.........这里部分代码省略.........
开发者ID:number33,项目名称:moodle,代码行数:101,代码来源:manage.php

示例2: course_listing

 /**
  * Renders a course listing.
  *
  * @param coursecat $category The currently selected category. This is what the listing is focused on.
  * @param course_in_list $course The currently selected course.
  * @param int $page The page being displayed.
  * @param int $perpage The number of courses to display per page.
  * @return string
  */
 public function course_listing(coursecat $category = null, course_in_list $course = null, $page = 0, $perpage = 20)
 {
     if ($category === null) {
         $html = html_writer::start_div('select-a-category');
         $html .= html_writer::tag('h3', get_string('courses'));
         $html .= $this->output->notification(get_string('selectacategory'), 'notifymessage');
         $html .= html_writer::end_div();
         return $html;
     }
     $page = max($page, 0);
     $perpage = max($perpage, 2);
     $totalcourses = $category->coursecount;
     $totalpages = ceil($totalcourses / $perpage);
     if ($page > $totalpages - 1) {
         $page = $totalpages - 1;
     }
     $options = array('offset' => $page * $perpage, 'limit' => $perpage);
     $courseid = isset($course) ? $course->id : null;
     $class = '';
     if ($page === 0) {
         $class .= ' firstpage';
     }
     if ($page + 1 === (int) $totalpages) {
         $class .= ' lastpage';
     }
     $html = html_writer::start_div('course-listing' . $class, array('data-category' => $category->id, 'data-page' => $page, 'data-totalpages' => $totalpages, 'data-totalcourses' => $totalcourses, 'data-canmoveoutof' => $category->can_move_courses_out_of() && $category->can_move_courses_into()));
     $html .= html_writer::tag('h3', $category->get_formatted_name());
     $html .= $this->course_listing_actions($category, $course, $perpage);
     $html .= $this->listing_pagination($category, $page, $perpage);
     $html .= html_writer::start_tag('ul', array('class' => 'ml'));
     foreach ($category->get_courses($options) as $listitem) {
         $html .= $this->course_listitem($category, $listitem, $courseid);
     }
     $html .= html_writer::end_tag('ul');
     $html .= $this->listing_pagination($category, $page, $perpage, true);
     $html .= $this->course_bulk_actions($category);
     $html .= html_writer::end_div();
     return $html;
 }
开发者ID:eamador,项目名称:moodle-course-custom-fields,代码行数:48,代码来源:management_renderer.php

示例3: 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


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