Repo: 根据左右位置分组链接

@param NavLink $links
@return array
967291
protected function groupBySide($links)
    {
        $data = ['left' => [], 'right' => []];

        /** @var NavLink $link */
        foreach ($links as $link) {
            $data[$link['side']][] = $link;
        }

        return $data;
    }
710932
public function getSharesResourceLink($resourceLink)
    {

        $shares = array();

        $sql = sprintf('SELECT consumer_pk, resource_link_pk, share_approved ' .
                       "FROM {$this->dbTableNamePrefix}" . DataConnector::RESOURCE_LINK_TABLE_NAME . ' ' .
                       'WHERE (primary_resource_link_pk = %d) ' .
                       'ORDER BY consumer_pk',
                       $resourceLink->getRecordId());
        $rsShare = mysql_query($sql);
        if ($rsShare) {
            while ($row = mysql_fetch_object($rsShare)) {
                $share = new ToolProvider\ResourceLinkShare();
                $share->resourceLinkId = intval($row->resource_link_pk);
                $share->approved = (intval($row->share_approved) === 1);
                $shares[] = $share;
            }
        }

        return $shares;

    }
207613
public function hasLink( $link, &$linkDetail = null )
    {

        $links = $this->__get('links');

        if( isset($links[$link])) {
            $linkDetail = $links[$link];
            return $link;
        }

        foreach( $links as $via => $linkDetail ){
            if( in_array( $link, $linkDetail->foreignEntities ) ) {
                return $via;
            }
        }

        return false;

    }
720548
private function getAttributes( $nav )
	{
		$result = array();

		$attrNav = $nav->CloneInstance();
		$flag = $attrNav->MoveToFirstAttribute();

		if ( $flag )
		{
			do
			{
				$result[ $attrNav->getName() ] = trim( $attrNav->getValue() );
				$flag = $attrNav->MoveToNext( XPathNodeType::Attribute );
			}
			while ( $flag );
		}

		return $result;
	}
1225696
public function setBreacrumbLinks($links) {
        if(is_array($links) && !empty($links)) {
            $this->links = $links;
        }
        return $this;
    }
1303545
protected function stripLinkBase($link)
    {
        // Trim baseURL
        $link = preg_replace('/^' . preg_quote(Director::baseURL(), '/') .'/', '', $link);

        // Trim link_base
        if ($linkBase = Config::inst()->get('DocumentationViewer', 'link_base')) {
            $link = preg_replace('/^' . preg_quote($linkBase, '/') .'\/?/', '', $link);
        }

        return $link;
    }
1103911
protected function renderLinks($links)
    {
        $html = '';
        $navLink = wei()->navLink;

        /** @var NavLink $link */
        foreach ($links as $link) {
            $url = $link['subLinks'] ? 'javascript:;' : $this->linkTo->getUrl($link['linkTo']);
            $html .= '<a href="' . $url . '" class="js-header-nav-item hm-nav-link d-flex flex-center">';

            // 显示图标
            if ($navLink->displayIcon($link)) {
                if ($link['icon'] == 'image') {
                    $html .= '<img class="hm-nav-icon" src="' . $link['image'] . '">';
                } elseif ($link['icon'] == 'font') {
                    $html .= '<i class="hm-nav-icon ' . $link['font'] . '"></i>';
                } else {
                    $html .= '<i class="hm-nav-icon iconfont">' . $link['customFont'] . '</i>';
                }
            }

            // 显示文本
            if ($navLink->displayText($link)) {
                $html .= $link['name'];
            }

            $html .= '</a>';

            // 渲染子链接
            if ($link['subLinks']) {
                $html .= '<dl class="hm-nav-menu">';
                foreach ($link['subLinks'] as $subLink) {
                    $html .= '<dd><a href="' . $this->linkTo->getUrl($subLink['linkTo']) . '">';
                    $html .= $subLink['name'] . '</a></dd>';
                }
                $html .= '</dl>';
            }
        }

        return $html;
    }
628145
public function version($link = null)
    {
        $cursor = $this->getMaster()->executeCommand(
            $this->getDbName(),
            new Command(['buildInfo' => 1])
        );

        $cursor->setTypeMap(['root' => 'array', 'document' => 'array']);
        $info = current($cursor->toArray());
        return $info['version'];
    }
664273
public function setLinks(array $links)
    {
        foreach ($links as &$href) {
            $href = ['href' => $href];
        }

        $this->links = $links;
    }
1050221
public function merge(self $link)
    {
        $this->parameters = array_replace(
            $link->getParameters(),
            $this->parameters
        );

        $this->metadata = array_replace(
            $link->getMetadata(),
            $this->metadata
        );
    }
820296
public function transform($link, array $params = array())
    {
        $facade = $this->newFacade();

        $facade->name = $link['name'];
        $facade->link = $link['link'];

        return $facade;
    }
261442
protected function serializeLink(LinkInterface $link)
    {
        if (!$link->metaInformation()->isEmpty()) {
            return [
                'href' => $link->href(),
                'meta' => $link->metaInformation()->all(),
            ];
        }

        return $link->href();
    }
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);
    }
533519
public static function getRssLink($link = '')
    {
        while (stristr($link, 'http') != $link) {
            $link = substr($link, 1);
        }
        $link = esc_url(strip_tags($link));

        return $link;
    }
309312
private function resolveQsen($link)
    {
        if (!$this->isFqsen($link)) {
            $typeCollection = new TypeCollection(array($link), $this->createDocBlockContext());

            // only a single element reference is allowed!
            $link = $typeCollection[0];
        }

        return $link;
    }
64776
public static function getLinkName($issueLink)
    {
        $linkName = null;

        if (isset($issueLink['outwardIssue'])) {
            if (isset($issueLink['outwardIssue']['key'], $issueLink['type']['outward'])) {
                $linkName = $issueLink['type']['outward'];
            }
        } elseif (isset($issueLink['inwardIssue'], $issueLink['type']['inward'])) {
            if (isset($issueLink['inwardIssue']['key'])) {
                $linkName = $issueLink['type']['inward'];
            }
        }

        return $linkName;
    }
84563
public function sortByKeys($links, $keys)
    {
        if (! is_null($keys)) {
            $links = $links->keyBy('id');

            $sortedLinks = [];
            foreach ($keys as $key) {
                $sortedLinks[] = $links[$key];
            }

            return collect($sortedLinks);
        }

        return $links;
    }