Hook: Link Parser

@param   array $pObj Object

@return  void
777975
public function hook_linkParse(array &$pObj)
    {
        if (!$this->checkIfSitemapIndexingIsEnabled('typolink')) {
            return;
        }

        // Check
        if (empty($pObj['finalTagParts']) || empty($pObj['conf']) || empty($pObj['finalTagParts']['url'])) {
            // no valid link
            return;
        }

        // Init link information
        $linkConf = $pObj['conf'];
        $linkUrl  = $pObj['finalTagParts']['url'];
        list($linkPageUid, $linkType) = $this->parseLinkConf($pObj);
        $linkUrl = $this->processLinkUrl($linkUrl);

        if ($linkType === null || empty($linkPageUid)) {
            // no valid link
            return;
        }

        // check blacklisting
        if (GeneralUtility::checkUrlForBlacklisting($linkUrl, $this->blacklistConf)) {
            return;
        }

        // ####################################
        //  Init
        // ####################################

        $addParameters = array();
        if (!empty($linkConf['additionalParams'])) {
            parse_str($linkConf['additionalParams'], $addParameters);
        }

        // #####################################
        // Check if link is cacheable
        // #####################################
        $isValid = false;

        // check if conf is valid
        if (!empty($linkConf['useCacheHash'])) {
            $isValid = true;
        }

        // check for typical typo3 params
        $addParamsCache = $addParameters;
        unset($addParamsCache['L']);
        unset($addParamsCache['type']);

        if (empty($addParamsCache)) {
            $isValid = true;
        }

        if (!$isValid) {
            // page is not cacheable, skip it
            return;
        }

        // #####################################
        // Rootline
        // #####################################
        $rootline = GeneralUtility::getRootLine($linkPageUid);

        if (empty($rootline)) {
            return;
        }

        // #####################################
        // Page settings
        // #####################################

        // Fetch sysLanguage
        if (isset($addParameters['L'])) {
            $pageLanguage = (int)$addParameters['L'];
        } else {
            $pageLanguage = (int)GeneralUtility::getLanguageId();
        }

        if (!$this->checkIfTranslationExists($linkPageUid, $pageLanguage)) {
            //translation does not exist => don't index
            return;
        }

        // Index link
        $pageData = $this->generateSitemapPageData($linkUrl, $linkPageUid, $rootline, $pageLanguage, $linkType);
        if (!empty($pageData)) {
            SitemapUtility::index($pageData);
        }
    }
14001
private void processLinks(JsonParser jsonParser) throws IOException {

        LOG.info("@odata.bind tag found - start parsing");

        final String fullLinkFieldName = jsonParser.getText();
        final String key = fullLinkFieldName.substring(0, fullLinkFieldName.indexOf(ODATA_BIND));
        JsonToken token = jsonParser.nextToken();
        if (token != JsonToken.START_ARRAY) {
            // Single link
            links.put(key, processLink(jsonParser));
        } else {
            // Array of links
            final List<String> linksList = new ArrayList<>();
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                linksList.add(processLink(jsonParser));
            }
            this.links.put(key, linksList);

        }
    }
45141
public function appendLink($key, $href, array $meta=[]) {
		$this->ensureLinksObject();
		$this->links->append($key, $href, $meta);
	}
655678
public static Response createLinksHandler(ParaObject pobj, String id2) {
		try (final Metrics.Context context = Metrics.time(null, RestUtils.class, "links", "create")) {
			if (id2 != null && pobj != null) {
				String linkid = pobj.link(id2);
				if (linkid == null) {
					return getStatusResponse(Response.Status.BAD_REQUEST, "Failed to create link.");
				} else {
					return Response.ok(linkid, MediaType.TEXT_PLAIN_TYPE).build();
				}
			} else {
				return getStatusResponse(Response.Status.BAD_REQUEST, "Parameters 'type' and 'id' are missing.");
			}
		}
	}
665214
public function bind(PbjxEvent $pbjxEvent): void
    {
        $request = $pbjxEvent->getMessage();
        $query = trim((string)$request->get('q'));
        if (empty($query)) {
            return;
        }

        $parsedQuery = $this->queryParser->parse($query);
        $request
            ->set('q', $query)
            ->addToSet('fields_used', $parsedQuery->getFieldsUsed())
            ->set('parsed_query_json', json_encode($parsedQuery));
    }
106572
public static function wiki_parser_link_callback($link, $options) {
        $l = urlencode($link);
        if(!empty($options['anchor'])) {
            $l .= "#".urlencode($options['anchor']);
        }
        return array('content' => $link, 'url' => "http://".$l);
    }
421751
public function handleArguments(array $argv): void
    {
        parent::handleArguments($argv);

        if (Get::value('sugaredDebug', $this->arguments, false)) {
            $this->logDebug('Parsed arguments', $this->arguments);
        }

        $this->addListeners();
    }
175345
private function parseComposerLoader(): void
    {
        // get composer autoload map
        $map = $this->loader->getPrefixes();
        if (Any::isArray($map)) {
            // get all available apps root dirs by psr loader for apps
            if (array_key_exists('Apps\\', $map)) {
                foreach ($map['Apps\\'] as $appPath) {
                    $this->appRoots[] = $appPath;
                }
            }

            // get Widgets map
            if (array_key_exists('Widgets\\', $map)) {
                // get all available root dirs by psr loader for widgets
                foreach ($map['Widgets\\'] as $widgetPath) {
                    $this->widgetRoots[] = $widgetPath;
                }
            }
        }

        // set default root path if not found anything else
        if (count($this->appRoots) < 1) {
            $this->appRoots = [root];
        }

        if (count($this->widgetRoots) < 1) {
            $this->widgetRoots = [root];
        }
    }
259466
public function linkToMany($model, $link): void
    {
        Relations::setRelations($this->model, $model, [$link]);
    }
756682
public static function doParse($src, $src_links, $options)
    {
        $parser = new Parser($options);
        return $parser->parse($src, $src_links);
    }
663037
public function parseToObj($parser)
	{
        /** @var CheckoutApi_Lib_RespondObj $respondObj */
        $respondObj = CheckoutApi_Lib_Factory::getInstance('CheckoutApi_Lib_RespondObj');

		if($parser && is_string ($parser)) {
			$encoding = mb_detect_encoding($parser);
			
			if($encoding =="ASCII") {
				$parser = iconv('ASCII', 'UTF-8', $parser);
			}else {
				$parser =  mb_convert_encoding($parser, "UTF-8", $encoding);
			}
			
			$jsonObj = json_decode($parser,true);
			$jsonObj['rawOutput'] = $parser;

			$respondObj->setConfig($jsonObj);


		}
        $respondObj->setConfig($this->getResourceInfo());
		return $respondObj;
	}
560460
protected function parseLink()
    {
        if ($this->type != '[') {
            return $this;
        }
        
        $this->consume();
        $url = $this->consume('T_URL');
        $this->consume(']');
        
        return new AST\Link($url);
    }
487111
public function appendLinkObject($key, LinkObject $linkObject) {
		$this->ensureLinksObject();
		$this->links->appendLinkObject($key, $linkObject);
	}
1184665
public function plugin_row_meta( $links, $file ) {
		$regex_pattern = '/<a href="(.*)">(.*)<\/a>/';
		$repo          = dirname( $file );

		/*
		 * Sanity check for some commercial plugins.
		 */
		if ( ! isset( $links[2] ) ) {
			return $links;
		}

		preg_match( $regex_pattern, $links[2], $matches );

		/*
		 * Remove 'Visit plugin site' link in favor or 'View details' link.
		 */
		if ( array_key_exists( $repo, $this->config ) ) {
			if ( null !== $repo ) {
				unset( $links[2] );
				$links[] = sprintf(
					'<a href="%s" class="thickbox">%s</a>',
					esc_url(
						add_query_arg(
							[
								'tab'       => 'plugin-information',
								'plugin'    => $repo,
								'TB_iframe' => 'true',
								'width'     => 600,
								'height'    => 550,
							],
							network_admin_url( 'plugin-install.php' )
						)
					),
					esc_html__( 'View details', 'github-updater' )
				);
			}
		}

		return $links;
	}
1355783
public function parseObjectElement(array $objectElement, ParsingDispatcher $parsingDispatcher)
    {
        if ($this->isEmbeddedObject($objectElement)) {
            $parsingDispatcher->parse(
                $objectElement,
                $objectElement['_media-type']
            );
        }

        return $objectElement['_href'];
    }
911209
public function generateUrl($oObj)
    {
        if (empty($oObj->breadcrumbs)) {
            return null;
        }

        $aBreadcrumbs = json_decode($oObj->breadcrumbs);
        if (is_null($aBreadcrumbs)) {
            return null;
        }

        $aUrl   = arrayExtractProperty($aBreadcrumbs, 'slug');
        $aUrl[] = $oObj->slug;

        $sUrl       = implode('/', $aUrl);
        $sNamespace = defined('static::NESTED_URL_NAMESPACE') ? addTrailingSlash(static::NESTED_URL_NAMESPACE) : '';

        return $sNamespace . $sUrl;
    }
214928
static function links($object, $params = array())
	{
		self::_target_class_parse($params);

		if(empty($params['order']))
			$params['order'] = 'sort_order';

		if(is_object($object))
		{
			$params['from_class'] = $object->extends_class_id();
			$params['from_id']    = $object->id();
		}
		else
		{
			$params['from_class'] = class_name_to_id($object);
		}

		if($to = @$params['to'])
		{
			if(is_object($to))
			{
				$params['to_class'] = $to->extends_class_id();
				$params['to_id']    = $to->id();
			}
			elseif($to)
			{
				$params['to_class'] = class_name_to_id($to);
			}

			unset($params['to']);
		}

		return bors_find_all('bors_link', $params);
	}