/** * Servicelinks are special kinds of infolinks that are created from * current parameters and in-wiki specification of URL templates. This * method adds the current property's servicelinks found in the * messages. The number and content of the parameters is depending on * the datatype, and the service link message is usually crafted with a * particular datatype in mind. */ public function addServiceLinks() { if ($this->mHasServiceLinks) { return; } if (!is_null($this->m_property)) { $propertyDiWikiPage = $this->m_property->getDiWikiPage(); } if (is_null($this->m_property) || is_null($propertyDiWikiPage)) { return; // no property known, or not associated with a page } $args = $this->getServiceLinkParams(); if ($args === false) { return; // no services supported } array_unshift($args, ''); // add a 0 element as placeholder $servicelinks = \SMW\StoreFactory::getStore()->getPropertyValues($propertyDiWikiPage, new SMWDIProperty('_SERV')); foreach ($servicelinks as $dataItem) { if (!$dataItem instanceof SMWDIBlob) { continue; } $args[0] = 'smw_service_' . str_replace(' ', '_', $dataItem->getString()); // messages distinguish ' ' from '_' // @todo FIXME: Use wfMessage/Message class here. $text = call_user_func_array('wfMsgForContent', $args); $links = preg_split("/[\n][\\s]?/u", $text); foreach ($links as $link) { $linkdat = explode('|', $link, 2); if (count($linkdat) == 2) { $this->addInfolink(SMWInfolink::newExternalLink($linkdat[0], trim($linkdat[1]))); } } } $this->mHasServiceLinks = true; }