Generate a menu link for answers pop-up

@param string $tokenId
@param boolean $plusLabel Show plus instead of label
@return \MUtil_Html_AElement
551284
public function getTokenShowLink($tokenId, $plusLabel)
    {
        $menuItem = $this->_getShowMenuItem();

        if ($plusLabel) {
            $link = $menuItem->toActionLink(
                    \MUtil_Html::create()->strong($this->_('+')),
                    [
                        'gto_id_token' => $tokenId,
                        \Gems_Model::ID_TYPE => 'token',
                    ]
                    );
        } else {
            $link = $menuItem->toActionLinkLower([
                'gto_id_token' => $tokenId,
                \Gems_Model::ID_TYPE => 'token',
            ]);
        }

        if ($link) {
            $link->title = sprintf($this->_('Inspect token %s'), strtoupper($tokenId));
        }

        return $link;
    }
38683
function insert_token(item) {
          var $this_token = $($(input).data("settings").tokenFormatter(item));
          var readonly = item.readonly === true ? true : false;

          if(readonly) $this_token.addClass($(input).data("settings").classes.tokenReadOnly);

          $this_token.addClass($(input).data("settings").classes.token).insertBefore(input_token);

          // The 'delete token' button
          if(!readonly) {
            $("<span>" + $(input).data("settings").deleteText + "</span>")
                .addClass($(input).data("settings").classes.tokenDelete)
                .appendTo($this_token)
                .click(function () {
                    if (!$(input).data("settings").disabled) {
                        delete_token($(this).parent());
                        hidden_input.change();
                        return false;
                    }
                });
          }

          // Store data on the token
          var token_data = item;
          $.data($this_token.get(0), "tokeninput", item);

          // Save this token for duplicate checking
          saved_tokens = saved_tokens.slice(0,selected_token_index).concat([token_data]).concat(saved_tokens.slice(selected_token_index));
          selected_token_index++;

          // Update the hidden input
          update_hidden_input(saved_tokens, hidden_input);

          token_count += 1;

          // Check the token limit
          if($(input).data("settings").tokenLimit !== null && token_count >= $(input).data("settings").tokenLimit) {
              input_box.hide();
              hide_dropdown();
          }

          return $this_token;
      }
895634
public function findNextTokenPosition($tokenId, $apos = null) {
		if ($apos === null) {
			$pos = $this->getCurrentPosition();
		} else {
			$pos = $apos;
		}
		$pos += 1; // Start from the token following the current position

		$nbTokens = count($this->tokens);
		while ($pos < $nbTokens) {
			$token = $this->tokens[$pos];

			if ($tokenId === $token->id) {
				return $pos;
			}

			$pos ++;
		}

		return null;
	}
1137781
public static function btn($tag, $label, $htmlOptions = array())
    {
        ArrayHelper::addValue('class', 'button', $htmlOptions);

        $icon = ArrayHelper::removeValue($htmlOptions, 'icon');
        if (isset($icon))
            $label = Icon::icon($icon) . '&nbsp;' . $label;

        return \CHtml::tag($tag, $htmlOptions, $label);
    }
832190
public function substitute($label, $token_values, $language, $options = array()) {
//        Logger::instance()->debug("Substituting $label in " . $language->locale);
        $token_value = $this->tokenValue($token_values, $language, $options);
        return str_replace($this->full_name, $token_value, $label);
    }
1261029
public function renderInline(Token $token) {
        $label = $token->get('label', '');
        $url = $token->get('url', '');
        $title = $token->get('title', '');

        if (empty($title)) {
            return "[$label]($url)";
        }

        return "[$label]($url \"$title\")";
    }
427101
public function getExampleFormMarkup()
    {
        $label = Widget::Label($this->get('label'));
        $label->appendChild(Widget::Textarea('fields['.$this->get('element_name').']', (int)$this->get('size'), 50));

        return $label;
    }
390773
public function getHtml($nodeId, $level, $storeId = null)
    {
        $classes = $level == 0 ? 'level-top' : '';
        $node = $this->nodes[$nodeId];
        $url = $this->getCategoryUrl($nodeId, $storeId);
        $title = $node->getTitle();

        return <<<HTML
<a href="$url" class="$classes" role="menuitem"><span>$title</span></a>
HTML;
    }
185978
protected function render_add_button($courseid) {
        global $CFG;

        $button = \html_writer::tag('button', get_string('addrule', 'tool_monitor'), ['class' => 'btn btn-primary']);
        $addurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/edit.php', array('courseid' => $courseid));
        return \html_writer::link($addurl, $button);
    }
243028
private function _identifyTokens($tokenText, $tokenID) {
		// Split the data up by newlines
		// To correctly handle T_NEW_LINE inside comments and HTML
		$splitData = preg_split('#(\r\n|\n|\r)#', $tokenText, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
		foreach ($splitData as $data) {

			$tokenInfo = new TokenInfo();
			$tokenInfo->text = $data;
			$tokenInfo->position = $this->tokenNumber;
			$tokenInfo->line = $this->lineNumber;

			if ($data === "\r\n" || $data === "\n" || $data === "\r") {
				// This is a new line token
				$tokenInfo->id = T_NEW_LINE;
				$this->lineNumber ++;
			} else if ($data === "\t") {
				// This is a tab token
				$tokenInfo->id = T_TAB;
			} else {
				// Any other token
				$tokenInfo->id = $tokenID;
			}

			$this->tokenNumber ++;

			// Added detections
			if ($tokenInfo->id === T_UNKNOWN) {
				switch ($tokenInfo->text) {
					case ";":
						$tokenInfo->id = T_SEMICOLON;
						break;
					case "{":
						$tokenInfo->id = T_BRACES_OPEN;
						break;
					case "}":
						$tokenInfo->id = T_BRACES_CLOSE;
						break;
					case "(":
						$tokenInfo->id = T_PARENTHESIS_OPEN;
						break;
					case ")":
						$tokenInfo->id = T_PARENTHESIS_CLOSE;
						break;
					case ",":
						$tokenInfo->id = T_COMMA;
						break;
					case "=":
						$tokenInfo->id = T_EQUAL;
						break;
					case ".":
						$tokenInfo->id = T_CONCAT;
						break;
					case ":":
						$tokenInfo->id = T_COLON;
						break;
					case "-":
						$tokenInfo->id = T_MINUS;
						break;
					case "+":
						$tokenInfo->id = T_PLUS;
						break;
					case ">":
						$tokenInfo->id = T_IS_GREATER;
						break;
					case "<":
						$tokenInfo->id = T_IS_SMALLER;
						break;
					case "*":
						$tokenInfo->id = T_MULTIPLY;
						break;
					case "/":
						$tokenInfo->id = T_DIVIDE;
						break;
					case "?":
						$tokenInfo->id = T_QUESTION_MARK;
						break;
					case "%":
						$tokenInfo->id = T_MODULO;
						break;
					case "!":
						$tokenInfo->id = T_EXCLAMATION_MARK;
						break;
					case "&":
						$tokenInfo->id = T_AMPERSAND;
						break;
					case "[":
						$tokenInfo->id = T_SQUARE_BRACKET_OPEN;
						break;
					case "]":
						$tokenInfo->id = T_SQUARE_BRACKET_CLOSE;
						break;
					case "@":
						$tokenInfo->id = T_AROBAS;
						break;
					case '"':
						$tokenInfo->id = T_QUOTE;
						break;
					case '$':
						$tokenInfo->id = T_DOLLAR;
						break;
					default:
				}
			}

			$this->newTokens[] = $tokenInfo;
		}

		return $this->newTokens;
	}
204154
public static function render( $url, $label, $targetId, $class = NULL )
	{
		$attributes	= array(
			'href'		=> "#".$targetId,
			'class'		=> $class,
			'onclick'	=> "ahah('".$url."','".$targetId."');",
		);
		return UI_HTML_Tag::create( 'a', $label, $attributes );
	}
219471
public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null)
    {
        $name = $this->get('element_name');
        $value = null;

        // New entry
        if (empty($data) && is_null($flagWithError) && !is_null($this->get('pre_populate'))) {
            $prepopulate = $this->get('pre_populate');

            $date = self::parseDate($prepopulate);
            $date = $date['start'];
            $value = $this->formatDate($date);

            // Error entry, display original data
        } elseif (!is_null($flagWithError)) {
            $value = $_POST['fields'][$name];

            // Empty entry
        } elseif (isset($data['value'])) {
            $value = $this->formatDate($data['value']);
        }

        $label = Widget::Label($this->get('label'));

        if ($this->get('required') !== 'yes') {
            $label->appendChild(new XMLElement('i', __('Optional')));
        }

        // Input
        $label->appendChild(Widget::Input("fields{$fieldnamePrefix}[{$name}]", $value));
        $label->setAttribute('class', 'date');

        // Calendar
        if ($this->get('calendar') === 'yes') {
            $wrapper->setAttribute('data-interactive', 'data-interactive');

            $ul = new XMLElement('ul');
            $ul->setAttribute('class', 'suggestions');
            $ul->setAttribute('data-field-id', $this->get('id'));
            $ul->setAttribute('data-search-types', 'date');

            $calendar = new XMLElement('li');
            $calendar->appendChild(Widget::Calendar(($this->get('time') === 'yes')));
            $ul->appendChild($calendar);

            $label->appendChild($ul);
        }

        // Wrap label in error
        if (!is_null($flagWithError)) {
            $label = Widget::Error($label, $flagWithError);
        }
        $wrapper->appendChild($label);
    }
535995
protected function getLinksFromDocument( $document, $onlyWithLabel = FALSE )
	{
		$baseUrl	= $this->getBaseUrl( $document );
		$links		= array();
		$nodes		= $document->getElementsByTagName( "a" );
		foreach( $nodes as $node )
		{
			$ref	= $node->getAttribute( 'href' );
			$ref	= trim( preg_replace( "@^\./@", "", $ref ) );
			if( strlen( $ref ) ){
				$base	= $document->getElementsByTagName( "base" );
	//			remark( $ref );
				if( preg_match( "@^(#|mailto:|javascript:)@", $ref ) )
					continue;
				if( $base->length && preg_match( "@^\.\./@", $ref ) )
					continue;
				if( preg_match( "@^\.?/@", $ref ) )
					$ref	= $baseUrl.$ref;
				else if( preg_match( "@^\./@", $ref ) )
					$ref	= preg_replace( "@^\./@", "", $ref );
				if( !preg_match( "@^https?://@", $ref ) )
					$ref	= $baseUrl.$ref;
				$label	= trim( strip_tags( $node->nodeValue ) );
				if( $node->hasAttribute( 'title' ) )
					$label	= trim( strip_tags( $node->getAttribute( 'title' ) ) );
				if( $onlyWithLabel && !strlen( $label ) )
					continue;
				$links[$ref]	= $label;
			}
		}
		return $links;
	}
1113160
public function renderLabel(Nette\Forms\IControl $control)
	{
		/** @noinspection PhpUndefinedMethodInspection */
		$controlLabel = $control->getLabel();
		if ($controlLabel instanceof Html && $controlLabel->getName() == 'label') {
			// the control has already provided us with the element, no need to create our own
			$controlLabel = $this->configElem(Cnf::label, $controlLabel);
			// just configure it to suit our needs

			$labelHtml = $controlLabel;
		} elseif ($controlLabel === NULL) {
			return Html::el();
		} else {
			// the control doesn't give us <label>, se we'll create our own
			$labelHtml = $this->getElem(Cnf::label);
			if ($controlLabel) {
				$labelHtml->setHtml($controlLabel);
			}
		}

		return $labelHtml;
	}
1114760
public function html_with_label($with_script=1)
	{
		$s = $this->html();
    if ( !empty($s) ){
			if ( BBN_IS_DEV ){
        $title = str_replace('"', '', print_r (bbn\str::make_readable($this->cfg), true));
			}
			else if ( isset($this->attr['title']) ){
				$title = $this->attr['title'];
			}
      else{
				$title = isset($this->label) ? $this->label : '';
			}
      if ( !isset($this->cfg['field']) || $this->cfg['field'] !== 'hidden' ){
  			$s = '<label class="bbn-form-label" title="'.$title.'" for="'.$this->attr['id'].'">'.$this->label.'</label><div class="bbn-form-field">'.$s.'</div>';
      }
		}
		return $s;
	}
691448
protected function createSubMenu(Manialink $manialink, Frame $frame, ParentItem $parentItem, $displayLevel)
    {

        if ($displayLevel > 0) {
            return;
        }

        $posX = $displayLevel * (-160.0 / 3);
        $posY = ($displayLevel * (-100.0 / 3)) * 0.5;
        $scale = (0.5 / ($displayLevel + 1)) + 0.5;

        $contentFrame = new Frame();
        $contentFrame->setScale($scale);
        $contentFrame->setPosition($posX, $posY);


        if ($displayLevel > 0) {
            $overlay = new Quad();
            $overlay->setSize(60, 120);
            $overlay->setPosition(-30, 0);
            $overlay->setStyles("Bgs1", "BgDialogBlur");

            $action = $this->actionFactory->createManialinkAction(
                $manialink,
                [$this, 'callbackItemClick'],
                ['item' => $parentItem]
            );


            $contentFrame->addChild($overlay);
            $overlay->setAction($action);
        }

        /* TITLE */
        $titleLabel = $this->uiFactory->createLabel($parentItem->getLabelId(), Label::TYPE_TITLE);
        $titleLabel->setTextSize(9)
            ->setSize(60, 12)
            ->setPosition(0, 0)
            ->setTranslate(true)
            ->setTextColor('fff')
            ->setHorizontalAlign("center");

        $contentFrame->addChild($titleLabel);

        $titleLine = $this->uiFactory->createLine(-60 * $scale, -12);
        $titleLine->setLength(120 * $scale);
        $titleLine->setStroke(0.33)->setColor('fff');

        $contentFrame->addChild($titleLine);

        $posY = -30;
        $delay = 0;

        // generate back button
        $path = explode("/", $parentItem->getPath());
        array_shift($path);

        $path = array_reverse($path);
        array_shift($path);
        $path = array_reverse($path);
        
        if ($path && count($path) >= 0) {
            $rootItem = $this->menuItemProvider->getRootItem();
            $backItem = $rootItem->getChild(implode("/", $path));

            $button = $this->uiFactory->createLabel("expansion_menu.menu_back");
            $button->setScale(1.5);
            $this->animation->addAnimation($button, 'scale="1"', 300, $delay, Animation::ElasticOut);
            $delay += 50;

            $button->setPosition(0, $posY);
            $button->setSize(50, 8);
            $button->setTranslate(true);
            $button->setTextSize(4);
            $button->setAlign("center", "center2");
            $button->addClass('menuItem');
            $button->setTextColor("aaa");
            $button->setTextPrefix("⏴ ");
            $action = $this->actionFactory->createManialinkAction(
                $manialink,
                [$this, 'callbackItemClick'],
                ['item' => $backItem, 'ml' => $manialink]
            );
            $button->setAction($action);
            $contentFrame->addChild($button);
            $posY -= 12;
        }


        foreach ($parentItem->getChilds() as $item) {
            if ($item->isVisibleFor($manialink->getUserGroup())) {
                $button = $this->uiFactory->createLabel($item->getLabelId());
                $button->setScale(1.5);
                $this->animation->addAnimation($button, 'scale="1"', 300, $delay, Animation::ElasticOut);
                $delay += 50;

                $button->setPosition(0, $posY);
                $button->setSize(50, 8);
                $button->setTranslate(true);
                $button->setTextSize(4);
                $button->setAlign("center", "center2");
                $button->addClass('menuItem');
                if ($item instanceof $parentItem) {
                    $button->setTextPrefix("⏵ ");
                }
                if ($displayLevel == 0) {
                    $action = $this->actionFactory->createManialinkAction(
                        $manialink,
                        [$this, 'callbackItemClick'],
                        ['item' => $item, 'ml' => $manialink]
                    );
                    $button->setAction($action);
                }

                $contentFrame->addChild($button);
                $posY -= 12;
            }
        }
        $frame->addChild($contentFrame);
    }
467507
public function hyperlink($label, $url, $options=array())
    {
        if (is_null($label) || $label === false) $label = $url;

        $options    = $this->getOptions($options);
        $attributes = $this->filterValidAttributes($options);

        return '<a href="'.$url.'"'.$this->Html->attributes($attributes).'>'.$this->Html->entities($label).'</a>';
    }