Esempio n. 1
0
 /**
  * Constructor
  *
  * @param string $elementName Element name
  * @param mixed $elementLabel Label(s) for an element
  * @param array $options Options to control the element's display
  * @param mixed $attributes Either a typical HTML attribute string or an associative array.
  */
 public function __construct($elementName = null, $elementLabel = null, $options = array(), $attributes = null)
 {
     $validoptions = array();
     if (!empty($options)) {
         // Only execute it when the element was created and $options has values set by user.
         // In onQuickFormEvent() we make sure that $options is not empty even if developer left it empty.
         $showstandard = core_tag_tag::BOTH_STANDARD_AND_NOT;
         if (isset($options['showstandard'])) {
             $showstandard = $options['showstandard'];
         } else {
             if (isset($options['display'])) {
                 debugging('Option "display" is deprecated, each tag area can be configured to show standard tags or not ' . 'by admin or manager. If it is necessary for the developer to override it, please use "showstandard" option', DEBUG_DEVELOPER);
                 if ($options['display'] === self::NOOFFICIAL) {
                     $showstandard = core_tag_tag::HIDE_STANDARD;
                 } else {
                     if ($options['display'] === self::ONLYOFFICIAL) {
                         $showstandard = core_tag_tag::STANDARD_ONLY;
                     }
                 }
             } else {
                 if (!empty($options['component']) && !empty($options['itemtype'])) {
                     $showstandard = core_tag_area::get_showstandard($options['component'], $options['itemtype']);
                 }
             }
         }
         $this->tagsoptions = $options;
         $this->showstandard = $showstandard != core_tag_tag::HIDE_STANDARD;
         if ($this->showstandard) {
             $validoptions = $this->load_standard_tags();
         }
         // Option 'tags' allows us to type new tags.
         $attributes['tags'] = $showstandard != core_tag_tag::STANDARD_ONLY;
         $attributes['multiple'] = 'multiple';
         $attributes['placeholder'] = get_string('entertags', 'tag');
         $attributes['showsuggestions'] = $this->showstandard;
     }
     parent::__construct($elementName, $elementLabel, $validoptions, $attributes);
 }