Esempio n. 1
0
 /**
  * Constructor.
  *
  * @param stdClass $cohort
  */
 public function __construct($cohort)
 {
     $cohortcontext = \context::instance_by_id($cohort->contextid);
     $editable = has_capability('moodle/cohort:manage', $cohortcontext);
     $displayvalue = format_string($cohort->name, true, array('context' => $cohortcontext));
     parent::__construct('core_cohort', 'cohortname', $cohort->id, $editable, $displayvalue, $cohort->name, new lang_string('editcohortname', 'cohort'), new lang_string('newnamefor', 'cohort', $displayvalue));
 }
Esempio n. 2
0
 /**
  * Constructor.
  *
  * @param stdClass $cohort
  */
 public function __construct($cohort)
 {
     $cohortcontext = \context::instance_by_id($cohort->contextid);
     $editable = has_capability('moodle/cohort:manage', $cohortcontext);
     $displayvalue = s($cohort->idnumber);
     // All idnumbers are plain text.
     parent::__construct('core_cohort', 'cohortidnumber', $cohort->id, $editable, $displayvalue, $cohort->idnumber, new lang_string('editcohortidnumber', 'cohort'), new lang_string('newidnumberfor', 'cohort', $displayvalue));
 }
Esempio n. 3
0
 /**
  * Constructor.
  *
  * @param stdClass|core_tag $tag
  */
 public function __construct($tag)
 {
     $editable = has_capability('moodle/tag:manage', context_system::instance());
     $edithint = new lang_string('editname', 'core_tag');
     $editlabel = new lang_string('newnamefor', 'core_tag', $tag->rawname);
     $value = $tag->rawname;
     $displayvalue = html_writer::link(core_tag_tag::make_url($tag->tagcollid, $tag->rawname), core_tag_tag::make_display_name($tag));
     parent::__construct('core_tag', 'tagname', $tag->id, $editable, $displayvalue, $value, $edithint, $editlabel);
 }
Esempio n. 4
0
 /**
  * Export this data so it can be used as the context for a mustache template.
  *
  * @param \renderer_base $output
  * @return \stdClass
  */
 public function export_for_template(\renderer_base $output)
 {
     if ($this->value) {
         $this->displayvalue = $output->pix_icon('i/checked', get_string('yes'));
     } else {
         $this->displayvalue = $output->pix_icon('i/unchecked', get_string('no'));
     }
     return parent::export_for_template($output);
 }
Esempio n. 5
0
 /**
  * Export this data so it can be used as the context for a mustache template (core/inplace_editable).
  *
  * @param renderer_base $output typically, the renderer that's calling this function
  * @return array data context for a mustache template
  */
 public function export_for_template(\renderer_base $output)
 {
     global $PAGE;
     $courserenderer = $PAGE->get_renderer('core', 'course');
     $this->displayvalue = $courserenderer->course_section_cm_name_title($this->cm, $this->displayoptions);
     if (strval($this->displayvalue) === '') {
         $this->editable = false;
     }
     return parent::export_for_template($output);
 }
Esempio n. 6
0
 /**
  * Constructor.
  *
  * @param \stdClass $tagarea
  */
 public function __construct($tagarea)
 {
     $tagcollections = \core_tag_collection::get_collections_menu(true);
     $editable = count($tagcollections) > 1 && empty($tagarea->locked) && has_capability('moodle/tag:manage', context_system::instance());
     $areaname = core_tag_area::display_name($tagarea->component, $tagarea->itemtype);
     $edithint = new lang_string('edittagcollection', 'core_tag');
     $editlabel = new lang_string('changetagcoll', 'core_tag', $areaname);
     $value = $tagarea->tagcollid;
     parent::__construct('core_tag', 'tagareacollection', $tagarea->id, $editable, null, $value, $edithint, $editlabel);
     $this->set_type_select($tagcollections);
 }
Esempio n. 7
0
 /**
  * Constructor.
  *
  * @param \stdClass $tagcoll
  */
 public function __construct($tagcoll)
 {
     $editable = has_capability('moodle/tag:manage', context_system::instance());
     $edithint = new lang_string('editcollname', 'core_tag');
     $value = $tagcoll->name;
     $name = \core_tag_collection::display_name($tagcoll);
     $editlabel = new lang_string('newcollnamefor', 'core_tag', $name);
     $manageurl = new moodle_url('/tag/manage.php', array('tc' => $tagcoll->id));
     $displayvalue = html_writer::link($manageurl, $name);
     parent::__construct('core_tag', 'tagcollname', $tagcoll->id, $editable, $displayvalue, $value, $edithint, $editlabel);
 }
Esempio n. 8
0
 /**
  * Constructor.
  *
  * @param \stdClass $tagarea
  */
 public function __construct($tagarea)
 {
     $editable = has_capability('moodle/tag:manage', context_system::instance());
     $edithint = new lang_string('editisstandard', 'core_tag');
     $value = $tagarea->showstandard;
     $areaname = core_tag_area::display_name($tagarea->component, $tagarea->itemtype);
     $editlabel = new lang_string('changeshowstandard', 'core_tag', $areaname);
     parent::__construct('core_tag', 'tagareashowstandard', $tagarea->id, $editable, null, $value, $edithint, $editlabel);
     $standardchoices = array(core_tag_tag::BOTH_STANDARD_AND_NOT => get_string('standardsuggest', 'tag'), core_tag_tag::STANDARD_ONLY => get_string('standardforce', 'tag'), core_tag_tag::HIDE_STANDARD => get_string('standardhide', 'tag'));
     $this->set_type_select($standardchoices);
 }
Esempio n. 9
0
 /**
  * Export this data so it can be used as the context for a mustache template.
  *
  * @param \renderer_base $output
  * @return \stdClass
  */
 public function export_for_template(\renderer_base $output)
 {
     if ($this->value) {
         $this->edithint = get_string('resetflag', 'core_tag');
         $this->displayvalue = $output->pix_icon('i/flagged', $this->edithint) . " ({$this->value})";
     } else {
         $this->edithint = get_string('flagasinappropriate', 'core_tag');
         $this->displayvalue = $output->pix_icon('i/unflagged', $this->edithint);
     }
     return parent::export_for_template($output);
 }
Esempio n. 10
0
 /**
  * Export this data so it can be used as the context for a mustache template.
  *
  * @param \renderer_base $output
  * @return \stdClass
  */
 public function export_for_template(\renderer_base $output)
 {
     if ($this->value) {
         $this->edithint = get_string('settypedefault', 'core_tag');
         $this->displayvalue = $output->pix_icon('i/checked', $this->edithint);
     } else {
         $this->edithint = get_string('settypestandard', 'core_tag');
         $this->displayvalue = $output->pix_icon('i/unchecked', $this->edithint);
     }
     return parent::export_for_template($output);
 }
Esempio n. 11
0
 /**
  * Export this data so it can be used as the context for a mustache template.
  *
  * @param \renderer_base $output
  * @return \stdClass
  */
 public function export_for_template(\renderer_base $output)
 {
     if ($this->value) {
         $this->edithint = get_string('disable');
         $this->displayvalue = $output->pix_icon('i/hide', get_string('disable'));
     } else {
         $this->edithint = get_string('enable');
         $this->displayvalue = $output->pix_icon('i/show', get_string('enable'));
     }
     return parent::export_for_template($output);
 }
Esempio n. 12
0
 /**
  * Constructor.
  *
  * @param \stdClass $tagarea
  */
 public function __construct($tagarea)
 {
     if (!empty($tagarea->locked)) {
         // If the tag collection for the current tag area is locked, display the
         // name of the collection without possibility to edit it.
         $tagcoll = \core_tag_collection::get_by_id($tagarea->tagcollid);
         parent::__construct('core_tag', 'tagareacollection', $tagarea->id, false, \core_tag_collection::display_name($tagcoll), $tagarea->tagcollid);
         return;
     }
     $tagcollections = \core_tag_collection::get_collections_menu(true);
     $editable = count($tagcollections) > 1 && has_capability('moodle/tag:manage', context_system::instance());
     $areaname = core_tag_area::display_name($tagarea->component, $tagarea->itemtype);
     $edithint = new lang_string('edittagcollection', 'core_tag');
     $editlabel = new lang_string('changetagcoll', 'core_tag', $areaname);
     $value = $tagarea->tagcollid;
     parent::__construct('core_tag', 'tagareacollection', $tagarea->id, $editable, null, $value, $edithint, $editlabel);
     $this->set_type_select($tagcollections);
 }
Esempio n. 13
0
 /**
  * Renders element for inline editing of any value
  *
  * @param \core\output\inplace_editable $element
  * @return string
  */
 public function render_inplace_editable(\core\output\inplace_editable $element)
 {
     return $this->render_from_template('core/inplace_editable', $element->export_for_template($this));
 }