Turn the objects link text into a link to the element it refers to.

@return ProgramElementDoc
551193
function &_resolveLink()
    {
        $phpdoctor = $this->_root->phpdoctor();
        $matches = array();
        $return = NULL;
        $packageRegex = '[a-zA-Z0-9_\x7f-\xff .\\\\-]+';
        $labelRegex = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
        $regex = '/^\\\\?(?:('.$packageRegex.')[.\\\\])?(?:('.$labelRegex.')(?:#|::))?\$?('.$labelRegex.')(?:\(\))?$/';
        if (preg_match($regex, $this->_link, $matches)) {
            $packageName = $matches[1];
            $className = $matches[2];
            $elementName = $matches[3];

            if ($packageName) { // get package
                $package =& $this->_root->packageNamed($packageName);
                if (!$package) {
                    return $return;
                }
            }
            if ($className) { // get class
                if (isset($package)) {
                    $classes =& $package->allClasses();
                } else {
                    $classes =& $this->_root->classes();
                }
                if ($classes) {
                    foreach ($classes as $key => $class) {
                        if ($class->name() == $className) {
                            break;
                        }
                    }
                    $class =& $classes[$key];
                }
            }
            if ($elementName) { // get element
                if (isset($class)) { // from class
                    $methods =& $class->methods();
                    if ($methods) {
                        foreach ($methods as $key => $method) {
                            if ($method->name() == $elementName) {
                                $element =& $methods[$key];
                                break;
                            }
                        }
                    }
                    if (!isset($element)) {
                        $fields =& $class->fields();
                        if ($fields) {
                            foreach ($fields as $key => $field) {
                                if ($field->name() == $elementName) {
                                    $element =& $fields[$key];
                                    break;
                                }
                            }
                        }
                    }
                } elseif (isset($package)) { // from package
                    $classes =& $package->allClasses();
                    foreach ($classes as $key => $class) {
                        if ($class->name() == $elementName) {
                            $element =& $classes[$key];
                            break;
                        }
                        $methods =& $class->methods();
                        if ($methods) {
                            foreach ($methods as $key => $method) {
                                if ($method->name() == $elementName) {
                                    $element =& $methods[$key];
                                    break 2;
                                }
                            }
                        }
                        if (!isset($element)) {
                            $fields =& $class->fields();
                            if ($fields) {
                                foreach ($fields as $key => $field) {
                                    if ($field->name() == $elementName) {
                                        $element =& $fields[$key];
                                        break 2;
                                    }
                                }
                            }
                        }
                    }
                    if (!isset($element)) {
                        $functions =& $package->functions();
                        if ($functions) {
                            foreach ($functions as $key => $function) {
                                if ($function->name() == $elementName) {
                                    $element =& $functions[$key];
                                    break;
                                }
                            }
                        }
                        if (!isset($element)) {
                            $globals =& $package->globals();
                            if ($globals) {
                                foreach ($globals as $key => $global) {
                                    if ($global->name() == $elementName) {
                                        $element =& $globals[$key];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                } else { // from anywhere
                    $classes =& $this->_root->classes();
                    if ($classes) {
                        foreach ($classes as $key => $class) {
                            if ($class->name() == $elementName) {
                                $element =& $classes[$key];
                                break;
                            }
                            $methods =& $class->methods();
                            if ($methods) {
                                foreach ($methods as $key => $method) {
                                    if ($method->name() == $elementName) {
                                        $element =& $methods[$key];
                                        break 2;
                                    }
                                }
                            }
                            if (!isset($element)) {
                                $fields =& $class->fields();
                                if ($fields) {
                                    foreach ($fields as $key => $field) {
                                        if ($field->name() == $elementName) {
                                            $element =& $fields[$key];
                                            break 2;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (!isset($element)) {
                        $functions =& $this->_root->functions();
                        if ($functions) {
                            foreach ($functions as $key => $function) {
                                if ($function->name() == $elementName) {
                                    $element =& $functions[$key];
                                    break;
                                }
                            }
                        }
                        if (!isset($element)) {
                            $globals =& $this->_root->globals();
                            if ($globals) {
                                foreach ($globals as $key => $global) {
                                    if ($global->name() == $elementName) {
                                        $element =& $globals[$key];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            $return =& $element;
        }

        return $return;
    }
125965
private function createSecondLink()
    {
        $content = '';
        $content .=
            "<a href='".$this->currentPageUrl.'/'.$this->lastPageMinusOne."'>$this->lastPageMinusOne</a>";
        $content .=
            "<a href='".$this->currentPageUrl.'/'.$this->lastPage."'>$this->lastPage</a>";

        return $content;
    }
1299727
public function toString()
    {
        $items = $this->data;

        $attachedBaseLib = false;
        $return = array('file' => '', 'script' => '');
        foreach ($items as $item) {
            if ($item['mode'] == 'file' && isset($item['attributes']['src'])) {
                // looking for duplicated base library
                if ($item['attributes']['src'] == $this->getBaseLibrary() && !$attachedBaseLib) {
                    $attachedBaseLib = true;
                } elseif ($item['attributes']['src'] == $this->getBaseLibrary()) {
                    // we have attached base library before
                    continue;
                }
            }

            $return[$item['mode']] .= PHP_EOL.
                $this->startElement().$this->writeAttributes($item['attributes']).$this->endElement().
                (($item['mode'] == 'script') ? $this->overrideScript($item['content']) : '').
                $this->startElement(true).$this->endElement()
            ;
        }

        $return = $return['file'].PHP_EOL.
            $return['script'].PHP_EOL;

        return $return;
    }
738413
protected function getNextLink()
    {
        if(!($sCall = $this->xPaginator->getNextCall()))
        {
            return '';
        }
        return $this->xTemplate->render('pagination::links/next',
            ['call' => $sCall, 'text' => $this->xPaginator->getNextText()]);
    }
1238844
protected function getOptions()
	{
		$options = array();

		$select = new HtmlSelect;

		// Try to inject the text object into the field
		try
		{
			$select->setText($this->getText());
		}
		catch (\RuntimeException $exception)
		{
			// A Text object was not set, ignore the error and try to continue processing
		}

		/** @var \SimpleXMLElement $option */
		foreach ($this->element->children() as $option)
		{
			// Only add <option /> elements.
			if ($option->getName() != 'option')
			{
				continue;
			}

			$text = $this->translateOptions
				? $this->getText()->alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname))
				: trim((string) $option);

			// Create a new option object based on the <option /> element.
			$tmp = $select->option((string) $option['value'], $text, 'value', 'text', ((string) $option['disabled'] == 'true'));

			// Set some option attributes.
			$tmp->class = (string) $option['class'];

			// Set some JavaScript option attributes.
			$tmp->onclick = (string) $option['onclick'];

			// Add the option object to the result set.
			$options[] = $tmp;
		}

		reset($options);

		return $options;
	}
1123888
public function getDescription()
    {
        if ($this->description && strpos(strtolower((string) $this->description), '{@inheritdoc}') === false) {
            return $this->description;
        }

        $parentElement = $this->getInheritedElement();
        if ($parentElement instanceof self) {
            $parentDescription = $parentElement->getDescription();

            return $this->description
                ? str_ireplace('{@inheritdoc}', $parentDescription, $this->description)
                : $parentDescription;
        }

        return $this->description;
    }
205097
def link(text, link_func):
    """"""
    def object_formatter(v, c, m, p):
        """Format object view link."""
        return Markup('<a href="{0}">{1}</a>'.format(
            link_func(m), text))
    return object_formatter
453881
protected function getLink()
    {
        if ($this->link_value === null) {
            $link = $this->link;
        } elseif (is_array($this->link_value)) {
            $link_values = array();

            foreach ($this->link_value as $value) {
                $link_values[] = urlencode($value);
            }

            $link = vsprintf($this->link, $link_values);
        } else {
            $link_value = urlencode($this->link_value);
            $link = sprintf($this->link, $link_value);
        }

        return $link;
    }
1091088
public function Link()
    {
        $link = '';
        switch ($this->type) {
            case 'Internal' :
                if ($this->internal && ($page = SiteTree::get()->byID($this->internal))) {
                    $link = $page->Link();
                }
                break;
            case 'External' :
                $link = $this->external;
                break;
            case 'Email' :
                $link = $this->email ? 'mailto:' . $this->email : '';
                break;
            case 'File' :
                if ($this->file) {
                    $link = File::get()->byID($this->file)->Filename;
                }
                break;
            case 'DataObject':
                if ($do = $this->getDO()) {
                    $link = $do->Link();
                }
                break;
        }

        if ($this->extra) {
            //added a query string, but no ? to start it
            if (strpos($this->extra, '=' !== false && strpos($this->extra, '?' === false))) {
                $link .= '?';
            }

            $link .= $this->extra;
        }

        if ($this->anchor) {
            $link .= '#' . $this->anchor;
        }

        return $link;
    }
647545
protected function getLinks()
	{
		$html = '';

		if (is_array($this->window['first'])) {
			$html .= $this->getUrlLinks($this->window['first']);
		}

		if (is_array($this->window['slider'])) {
			$html .= $this->getDots();
			$html .= $this->getUrlLinks($this->window['slider']);
		}

		if (is_array($this->window['last'])) {
			$html .= $this->getDots();
			$html .= $this->getUrlLinks($this->window['last']);
		}

		return $html;
	}
709452
private function getLinksDeclaration()
    {

        // we got a max instances allowed in normality tags
        $links = $this->entity->pgClass->getLinks();
        foreach( $links as &$link ) {
            $link = $link->toArray();
        }
        $links = json_encode( $links );
        $links = Php::varExport( $links, true );

        $this->class->classComponents[] = new VariableDeclaration(
            'links',
            new SFormatf( <<<'PHP'
                /**
                 * Link information for this relation
                 * @var array
                 */
                protected $links = %s;
PHP
                , $links
            )
        );

    }
1269224
public function toHtml()
    {
        if (config('talk.oembed.enabled')) {
            $parsedUrl = parse_url(config('talk.oembed.url'));
            $this->driver->addProvider(
                $parsedUrl['host'],
                Adapter::class,
                [
                    'api_key' => config('talk.oembed.key'),
                ]
            );
        }

        $result = $this->driver->autoEmbed($this->string);

        return $result;
    }
1045686
public function getLinkA() {
		if($this->reverse()->isPolymorphic())
			return $this->reverse()->get('as').'_id';
		else
			return $this->reverse()->getName().'_id';
	}
471980
def _get_link(element: Element) -> Optional[str]:
    
    link = get_text(element, 'link')
    if link is not None:
        return link

    guid = get_child(element, 'guid')
    if guid is not None and guid.attrib.get('isPermaLink') == 'true':
        return get_text(element, 'guid')

    return None
164919
public function link($link, $text=null, $title=null, $popup=false, $class=null) {
		if (is_null($text)) {
			// if no text is given, we use the text originally provided by the user
			$text = $link;
		}

		// deal with internal and (slightly) malformed links
		$link = $this->getLink($link);

		$attributes = $this->getHtmlAttributes(array(
			'title'=>$title,
			'target'=>$this->isTrue($popup)?"blank":null,
			'class'=>$class
		));

		return "<a href='$link'$attributes>$text</a>";
	}
40382
public function getParsedDescription()
    {
        if (null === $this->parsedDescription) {
            $description = new Description($this->description, $this->docblock);
            $this->parsedDescription = $description->getParsedContents();
        }
        return $this->parsedDescription;
    }
979633
public function getTextAsLink()
    {
        $html = '';
        if($this->type == self::TYPE_CALL)
        {
            $html .= Html::a($this->text,'tel:'.$this->text,['target' => '_blank']);
        }
        else
        {
            $html .= $this->text;
        }
        return $html;
    }