本文整理汇总了PHP中SMWQueryResult::getQueryLink方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWQueryResult::getQueryLink方法的具体用法?PHP SMWQueryResult::getQueryLink怎么用?PHP SMWQueryResult::getQueryLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWQueryResult
的用法示例。
在下文中一共展示了SMWQueryResult::getQueryLink方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getResultText
protected function getResultText(SMWQueryResult $res, $outputmode)
{
global $wgSitename;
$result = '';
if ($outputmode == SMW_OUTPUT_FILE) {
// make file
if ($this->m_title == '') {
$this->m_title = $wgSitename;
}
$items = array();
while ($row = $res->getNext()) {
$items[] = $this->getItemForResultRow($row)->text();
}
$result = implode('', $items);
} else {
// just make link to export
if ($this->getSearchLabel($outputmode)) {
$label = $this->getSearchLabel($outputmode);
} else {
$label = wfMsgForContent('srf_bibtex_link');
}
$link = $res->getQueryLink($label);
$link->setParameter('bibtex', 'format');
if ($this->getSearchLabel(SMW_OUTPUT_WIKI) != '') {
$link->setParameter($this->getSearchLabel(SMW_OUTPUT_WIKI), 'searchlabel');
}
$result .= $link->getText($outputmode, $this->mLinker);
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
// yes, our code can be viewed as HTML if requested, no more parsing needed
}
return $result;
}
示例2: getResultText
protected function getResultText(SMWQueryResult $res, $outputmode)
{
$result = '';
if ($outputmode == SMW_OUTPUT_FILE) {
// make CSV file
$csv = fopen('php://temp', 'r+');
if ($this->mShowHeaders) {
$header_items = array();
foreach ($res->getPrintRequests() as $pr) {
$header_items[] = $pr->getLabel();
}
fputcsv($csv, $header_items, $this->m_sep);
}
while ($row = $res->getNext()) {
$row_items = array();
foreach ($row as $field) {
$growing = array();
while (($object = $field->getNextDataValue()) !== false) {
$growing[] = Sanitizer::decodeCharReferences($object->getWikiValue());
}
$row_items[] = implode(',', $growing);
}
fputcsv($csv, $row_items, $this->m_sep);
}
rewind($csv);
$result .= stream_get_contents($csv);
} else {
// just make link to feed
if ($this->getSearchLabel($outputmode)) {
$label = $this->getSearchLabel($outputmode);
} else {
$label = wfMsgForContent('smw_csv_link');
}
$link = $res->getQueryLink($label);
$link->setParameter('csv', 'format');
$link->setParameter($this->m_sep, 'sep');
if (array_key_exists('mainlabel', $this->params) && $this->params['mainlabel'] !== false) {
$link->setParameter($this->params['mainlabel'], 'mainlabel');
}
$link->setParameter($this->mShowHeaders ? 'show' : 'hide', 'headers');
if (array_key_exists('limit', $this->params)) {
$link->setParameter($this->params['limit'], 'limit');
} else {
// use a reasonable default limit
$link->setParameter(100, 'limit');
}
$result .= $link->getText($outputmode, $this->mLinker);
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
// yes, our code can be viewed as HTML if requested, no more parsing needed
}
return $result;
}
示例3: getResultText
protected function getResultText( SMWQueryResult $res, $outputmode ) {
global $smwgIQRunningNumber;
$this->includeJS();
$isEventline = 'eventline' == $this->mFormat;
if ( !$isEventline && ( $this->m_tlstart == '' ) ) { // seek defaults
foreach ( $res->getPrintRequests() as $pr ) {
if ( ( $pr->getMode() == SMWPrintRequest::PRINT_PROP ) && ( $pr->getTypeID() == '_dat' ) ) {
$dataValue = $pr->getData();
$date_value = $dataValue->getDataItem()->getLabel();
if ( ( $this->m_tlend == '' ) && ( $this->m_tlstart != '' ) &&
( $this->m_tlstart != $date_value ) ) {
$this->m_tlend = $date_value;
} elseif ( ( $this->m_tlstart == '' ) && ( $this->m_tlend != $date_value ) ) {
$this->m_tlstart = $date_value;
}
}
}
}
// print header
$link = $res->getQueryLink( wfMsgForContent( 'srf-timeline-allresults' ) );
$result = "<div class=\"smwtimeline\" id=\"smwtimeline$smwgIQRunningNumber\" style=\"height: $this->m_tlsize\">";
$result .= '<span class="smwtlcomment">' . wfMsgForContent( 'srf-timeline-nojs' ) . ' ' . $link->getText( $outputmode, $this->mLinker ) . '</span>'; // note for people without JavaScript
foreach ( $this->m_tlbands as $band ) {
$result .= '<span class="smwtlband" style="display:none;">' . htmlspecialchars( $band ) . '</span>';
// just print any "band" given, the JavaScript will figure out what to make of it
}
// print all result rows
if ( ( $this->m_tlstart != '' ) || $isEventline ) {
$result .= $this->getEventsHTML( $res, $outputmode, $isEventline );
}
// no further results displayed ...
// print footer
$result .= '</div>';
// yes, our code can be viewed as HTML if requested, no more parsing needed
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
return $result;
}
示例4: getResultText
protected function getResultText(SMWQueryResult $res, $outputmode)
{
$result = '';
if ($outputmode == SMW_OUTPUT_FILE) {
$people = array();
$row = $res->getNext();
while ($row !== false) {
$people[] = new PersonPageValues($row[0]->getResultSubject());
$row = $res->getNext();
}
$printer = new Gedcom5FilePrinter();
$printer->addPeople($people);
$result = $printer->getFile();
} else {
// just make link
if ($this->getSearchLabel($outputmode)) {
$label = $this->getSearchLabel($outputmode);
} else {
$label = wfMsgForContent('semanticgenealogy-gedcomexport-link');
}
$link = $res->getQueryLink($label);
$link->setParameter('gedcom5', 'format');
if ($this->getSearchLabel(SMW_OUTPUT_WIKI) != '') {
$link->setParameter($this->getSearchLabel(SMW_OUTPUT_WIKI), 'searchlabel');
}
if (array_key_exists('limit', $this->m_params)) {
$link->setParameter($this->m_params['limit'], 'limit');
} else {
// use a reasonable default limit
$link->setParameter(20, 'limit');
}
$result .= $link->getText($outputmode, $this->mLinker);
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
// yes, our code can be viewed as HTML if requested, no more parsing needed
}
return $result;
}
示例5: getIcalLink
/**
* Returns html for a link to a query that returns the iCal.
*
* @since 1.5.2
*
* @param SMWQueryResult $res
* @param $outputmode
*
* @return string
*/
protected function getIcalLink(SMWQueryResult $res, $outputmode)
{
if ($this->getSearchLabel($outputmode)) {
$label = $this->getSearchLabel($outputmode);
} else {
$label = wfMessage('srf_icalendar_link')->inContentLanguage()->text();
}
$link = $res->getQueryLink($label);
$link->setParameter('icalendar', 'format');
if ($this->m_title !== '') {
$link->setParameter($this->m_title, 'title');
}
if ($this->m_description !== '') {
$link->setParameter($this->m_description, 'description');
}
if (array_key_exists('limit', $this->params)) {
$link->setParameter($this->params['limit'], 'limit');
} else {
// use a reasonable default limit
$link->setParameter(20, 'limit');
}
// yes, our code can be viewed as HTML if requested, no more parsing needed
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
return $link->getText($outputmode, $this->mLinker);
}
示例6: getResultText
//.........这里部分代码省略.........
$homeaddress = true;
}
break;
case "homeextendedaddress":
$value = $field->getNextDataValue();
if ($value !== false) {
$homeextendedaddress = $value->getShortWikiText();
$homeaddress = true;
}
break;
case "homestreet":
$value = $field->getNextDataValue();
if ($value !== false) {
$homestreet = $value->getShortWikiText();
$homeaddress = true;
}
break;
case "homelocality":
$value = $field->getNextDataValue();
if ($value !== false) {
$homelocality = $value->getShortWikiText();
$homeaddress = true;
}
break;
case "homeregion":
$value = $field->getNextDataValue();
if ($value !== false) {
$homeregion = $value->getShortWikiText();
$homeaddress = true;
}
break;
case "homepostalcode":
$value = $field->getNextDataValue();
if ($value !== false) {
$homepostalcode = $value->getShortWikiText();
$homeaddress = true;
}
break;
case "homecountry":
$value = $field->getNextDataValue();
if ($value !== false) {
$homecountry = $value->getShortWikiText();
$homeaddress = true;
}
break;
case "birthday":
if ($req->getTypeID() == "_dat") {
$value = $field->getNextDataValue();
if ($value !== false) {
$birthday = $value->getXMLSchemaDate();
}
}
break;
case "homepage":
if ($req->getTypeID() == "_uri") {
$value = $field->getNextDataValue();
if ($value !== false) {
$url = $value->getWikiValue();
}
}
break;
}
}
$pagetitle = $wikipage->getTitle();
if ($workaddress) {
$addresses[] = new SRFvCardAddress('WORK', $workpostofficebox, $workextendedaddress, $workstreet, $worklocality, $workregion, $workpostalcode, $workcountry);
}
if ($homeaddress) {
$addresses[] = new SRFvCardAddress('HOME', $homepostofficebox, $homeextendedaddress, $homestreet, $homelocality, $homeregion, $homepostalcode, $homecountry);
}
$items[] = new SRFvCardEntry($pagetitle, $prefix, $firstname, $lastname, $additionalname, $suffix, $fullname, $tels, $addresses, $emails, $birthday, $jobtitle, $role, $organization, $department, $category, $url, $note);
$row = $res->getNext();
}
foreach ($items as $item) {
$result .= $item->text();
}
} else {
// just make link to vcard
if ($this->getSearchLabel($outputmode)) {
$label = $this->getSearchLabel($outputmode);
} else {
$label = wfMessage('srf_vcard_link')->inContentLanguage()->text();
}
$link = $res->getQueryLink($label);
$link->setParameter('vcard', 'format');
if ($this->getSearchLabel(SMW_OUTPUT_WIKI) != '') {
$link->setParameter($this->getSearchLabel(SMW_OUTPUT_WIKI), 'searchlabel');
}
if (array_key_exists('limit', $this->m_params)) {
$link->setParameter($this->m_params['limit'], 'limit');
} else {
// use a reasonable default limit
$link->setParameter(20, 'limit');
}
$result .= $link->getText($outputmode, $this->mLinker);
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
// yes, our code can be viewed as HTML if requested, no more parsing needed
}
return $result;
}
示例7: getLinkToFile
/**
* Returns html for a link to a query that returns the DSV file.
*
* @since 1.6
*
* @param SMWQueryResult $res
* @param $outputmode
*
* @return string
*/
protected function getLinkToFile(SMWQueryResult $res, $outputmode)
{
if ($this->getSearchLabel($outputmode)) {
$label = $this->getSearchLabel($outputmode);
} else {
$label = wfMsgForContent('smw_dsv_link');
}
$link = $res->getQueryLink($label);
$link->setParameter('dsv', 'format');
$link->setParameter($this->separator, 'separator');
$link->setParameter($this->fileName, 'filename');
if (array_key_exists('mainlabel', $this->m_params) && $this->m_params['mainlabel'] !== false) {
$link->setParameter($this->m_params['mainlabel'], 'mainlabel');
}
$link->setParameter($this->mShowHeaders ? 'show' : 'hide', 'headers');
if (array_key_exists('limit', $this->m_params)) {
$link->setParameter($this->m_params['limit'], 'limit');
} else {
// Use a reasonable default limit
$link->setParameter(100, 'limit');
}
// yes, our code can be viewed as HTML if requested, no more parsing needed
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
return $link->getText($outputmode, $this->mLinker);
}
示例8: getKMLLink
/**
* Returns a link (HTML) pointing to a query that returns the actual KML file.
*
* @since 0.7.3
*
* @param SMWQueryResult $res
* @param integer $outputmode
*
* @return string
*/
protected function getKMLLink(SMWQueryResult $res, $outputmode)
{
$searchLabel = $this->getSearchLabel($outputmode);
$link = $res->getQueryLink($searchLabel ? $searchLabel : wfMessage('semanticmaps-kml-link')->inContentLanguage()->text());
$link->setParameter('kml', 'format');
$link->setParameter($this->params['linkabsolute'] ? 'yes' : 'no', 'linkabsolute');
$link->setParameter($this->params['pagelinktext'], 'pagelinktext');
if ($this->params['title'] !== '') {
$link->setParameter($this->params['title'], 'title');
}
if ($this->params['text'] !== '') {
$link->setParameter($this->params['text'], 'text');
}
if (array_key_exists('limit', $this->params)) {
$link->setParameter($this->params['limit'], 'limit');
} else {
// Use a reasonable default limit.
$link->setParameter(20, 'limit');
}
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
return $link->getText($outputmode, $this->mLinker);
}
示例9: getResultText
protected function getResultText(SMWQueryResult $res, $outputmode)
{
if ($outputmode == SMW_OUTPUT_FILE) {
// make RDF file
$serializer = $this->syntax == 'turtle' ? new SMWTurtleSerializer() : new SMWRDFXMLSerializer();
$serializer->startSerialization();
$serializer->serializeExpData(SMWExporter::getOntologyExpData(''));
while ($row = $res->getNext()) {
$subjectDi = reset($row)->getResultSubject();
$data = SMWExporter::makeExportDataForSubject($subjectDi);
foreach ($row as $resultarray) {
$printreq = $resultarray->getPrintRequest();
$property = null;
switch ($printreq->getMode()) {
case SMWPrintRequest::PRINT_PROP:
$property = $printreq->getData()->getDataItem();
break;
case SMWPrintRequest::PRINT_CATS:
$property = new SMWDIProperty('_TYPE');
break;
case SMWPrintRequest::PRINT_CCAT:
// not serialised right now
break;
case SMWPrintRequest::PRINT_THIS:
// ignored here (object is always included in export)
break;
}
if (!is_null($property)) {
SMWExporter::addPropertyValues($property, $resultarray->getContent(), $data, $subjectDi);
}
}
$serializer->serializeExpData($data);
}
$serializer->finishSerialization();
return $serializer->flushContent();
} else {
// just make link to feed
if ($this->getSearchLabel($outputmode)) {
$label = $this->getSearchLabel($outputmode);
} else {
$label = wfMsgForContent('smw_rdf_link');
}
$link = $res->getQueryLink($label);
$link->setParameter('rdf', 'format');
$link->setParameter($this->syntax, 'syntax');
if (array_key_exists('limit', $this->params)) {
$link->setParameter($this->params['limit'], 'limit');
} else {
// use a reasonable default limit
$link->setParameter(100, 'limit');
}
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
// yes, our code can be viewed as HTML if requested, no more parsing needed
return $link->getText($outputmode, $this->mLinker);
}
}
示例10: getResultText
protected function getResultText(SMWQueryResult $res, $outputmode)
{
global $wgServer, $wgScriptPath;
if ($outputmode == SMW_OUTPUT_FILE) {
// create detached JSON file
$itemstack = array();
// contains Items for the items section
$propertystack = array();
// contains Properties for the property section
// generate property section
foreach ($res->getPrintRequests() as $pr) {
if ($pr->getMode() != SMWPrintRequest::PRINT_THIS) {
if (array_key_exists($pr->getTypeID(), $this->types)) {
$propertystack[] = '"' . str_replace(" ", "_", strtolower($pr->getLabel())) . '" : { "valueType": "' . $this->types[$pr->getTypeID()] . '" }';
} else {
$propertystack[] = '"' . str_replace(" ", "_", strtolower($pr->getLabel())) . '" : { "valueType": "text" }';
}
}
}
$properties = "\"properties\": {\n\t\t" . implode(",\n\t\t", $propertystack) . "\n\t}";
// generate items section
while (($row = $res->getNext()) !== false) {
$rowsubject = false;
// the wiki page value that this row is about
$valuestack = array();
// contains Property-Value pairs to characterize an Item
$addedLabel = false;
foreach ($row as $field) {
$pr = $field->getPrintRequest();
if ($rowsubject === false && !$addedLabel) {
$valuestack[] = '"label": "' . $field->getResultSubject()->getTitle()->getFullText() . '"';
$addedLabel = true;
}
if ($pr->getMode() != SMWPrintRequest::PRINT_THIS) {
$values = array();
$jsonObject = array();
while (($dataValue = $field->getNextDataValue()) !== false) {
switch ($dataValue->getTypeID()) {
case '_geo':
$jsonObject[] = $dataValue->getDataItem()->getCoordinateSet();
$values[] = FormatJson::encode($dataValue->getDataItem()->getCoordinateSet());
break;
case '_num':
$jsonObject[] = $dataValue->getDataItem()->getNumber();
break;
case '_dat':
$jsonObject[] = $dataValue->getYear() . '-' . str_pad($dataValue->getMonth(), 2, '0', STR_PAD_LEFT) . '-' . str_pad($dataValue->getDay(), 2, '0', STR_PAD_LEFT) . ' ' . $dataValue->getTimeString();
break;
default:
$jsonObject[] = $dataValue->getShortText($outputmode, null);
}
}
if (!is_array($jsonObject) || count($jsonObject) > 0) {
$valuestack[] = '"' . str_replace(' ', '_', strtolower($pr->getLabel())) . '": ' . FormatJson::encode($jsonObject) . '';
}
}
}
if ($rowsubject !== false) {
// stuff in the page URI and some category data
$valuestack[] = '"uri" : "' . $wgServer . $wgScriptPath . '/index.php?title=' . $rowsubject->getPrefixedText() . '"';
$page_cats = smwfGetStore()->getPropertyValues($rowsubject, new SMWDIProperty('_INST'));
// TODO: set limit to 1 here
if (count($page_cats) > 0) {
$valuestack[] = '"type" : "' . reset($page_cats)->getShortHTMLText() . '"';
}
}
// create property list of item
$itemstack[] = "\t{\n\t\t\t" . implode(",\n\t\t\t", $valuestack) . "\n\t\t}";
}
$items = "\"items\": [\n\t" . implode(",\n\t", $itemstack) . "\n\t]";
// check whether a callback function is required
if (array_key_exists('callback', $this->params)) {
$result = htmlspecialchars($this->params['callback']) . "({\n\t" . $properties . ",\n\t" . $items . "\n})";
} else {
$result = "{\n\t" . $properties . ",\n\t" . $items . "\n}";
}
} else {
// just create a link that points to the JSON file
if ($this->getSearchLabel($outputmode)) {
$label = $this->getSearchLabel($outputmode);
} else {
$label = wfMsgForContent('smw_json_link');
}
$link = $res->getQueryLink($label);
if (array_key_exists('callback', $this->params)) {
$link->setParameter(htmlspecialchars($this->params['callback']), 'callback');
}
if ($this->getSearchLabel(SMW_OUTPUT_WIKI) !== '') {
// used as a file name
$link->setParameter($this->getSearchLabel(SMW_OUTPUT_WIKI), 'searchlabel');
}
if (array_key_exists('limit', $this->params)) {
$link->setParameter(htmlspecialchars($this->params['limit']), 'limit');
}
$link->setParameter('json', 'format');
$result = $link->getText($outputmode, $this->mLinker);
// yes, our code can be viewed as HTML if requested, no more parsing needed
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
}
return $result;
//.........这里部分代码省略.........
示例11: getResultText
protected function getResultText(SMWQueryResult $res, $outputmode)
{
global $smwgIQRunningNumber, $wgScriptPath, $wgGoogleMapsKey, $srfgScriptPath;
if (defined('MW_SUPPORTS_RESOURCE_MODULES')) {
SMWOutputs::requireHeadItem('exhibit-compat', Html::linkedScript("{$wgScriptPath}/common/wikibits.js"));
}
// //////////////////////////////
// ///////REMOTE STUFF///////////
// //////////////////////////////
$remote = false;
// in case the remote parameter is set, a link to the JSON export of the remote wiki is included in the header as data source for Exhibit
// this section creates the link
if (array_key_exists('remote', $this->m_params) && srfgExhibitRemote == true) {
$remote = true;
// fetch interwiki link
$dbr =& wfGetDB(DB_SLAVE);
$cl = $dbr->tableName('interwiki');
$dbres = $dbr->select($cl, 'iw_url', "iw_prefix='" . $this->m_params['remote'] . "'", __METHOD__, array());
$row = $dbr->fetchRow($dbres);
$extlinkpattern = $row[iw_url];
$dbr->freeResult($dbres);
$newheader = '<link rel="exhibit/data" type="application/jsonp" href="';
$link = $res->getQueryLink('JSON Link');
$link->setParameter('json', 'format');
if (array_key_exists('callback', $this->m_params)) {
// check if a special name for the callback function is set, if not stick with 'callback'
$callbackfunc = $this->m_params['callback'];
} else {
$callbackfunc = 'callback';
}
if (array_key_exists('limit', $this->m_params)) {
$link->setParameter($this->m_params['limit'], 'limit');
}
$link->setParameter($callbackfunc, 'callback');
$link = $link->getText(2, $this->mLinker);
list($link, $trash) = explode('|', $link);
$link = str_replace('[[:', '', $link);
$newheader .= str_replace('$1', $link, $extlinkpattern);
$newheader .= '" ex:jsonp-callback="' . $callbackfunc . '"';
$newheader .= '/>';
SMWOutputs::requireHeadItem('REMOTE', $newheader);
}
// the following variables indicate the use of special views
// the variable's values define the way Exhibit is called
$timeline = false;
$map = false;
/*The javascript file adopted from Wibbit uses a bunch of javascript variables in the header to store information about the Exhibit markup.
The following code sequence creates these variables*/
// prepare sources (the sources holds information about the table which contains the information)
$colstack = array();
foreach ($res->getPrintRequests() as $pr) {
$colstack[] = $this->encodePropertyName($pr->getLabel()) . ':' . (array_key_exists($pr->getTypeID(), $this->m_types) ? $this->m_types[$pr->getTypeID()] : 'text');
}
array_shift($colstack);
array_unshift($colstack, 'label');
if (SRFExhibit::$exhibitRunningNumber == 0) {
$sourcesrc = "var ex_sources = { source" . ($smwgIQRunningNumber - 1) . ": { id: 'querytable" . $smwgIQRunningNumber . "' , columns: '" . implode(',', $colstack) . "'.split(','), hideTable: '1', type: 'Item', label: 'Item', pluralLabel: 'Items' } };";
} else {
$sourcesrc = "sources.source" . $smwgIQRunningNumber . " = { id: 'querytable" . $smwgIQRunningNumber . "' , columns: '" . implode(',', $colstack) . "'.split(','), hideTable: '1', type: 'Item', label: 'Item', pluralLabel: 'Items' };";
}
$sourcesrc = "<script type=\"text/javascript\">" . $sourcesrc . "</script>";
// prepare facets
$facetcounter = 0;
if (array_key_exists('facets', $this->m_params)) {
$facets = explode(',', $this->m_params['facets']);
$facetstack = array();
$params = array('height');
$facparams = array();
foreach ($params as $param) {
if (array_key_exists($param, $this->m_params)) {
$facparams[] = 'ex:' . $param . '="' . $this->encodePropertyName($this->m_params[$param]) . '" ';
}
}
foreach ($facets as $facet) {
$facet = trim($facet);
$fieldcounter = 0;
if (strtolower($facet) == "search") {
// special facet (text search)
$facetstack[] = ' facet' . $facetcounter++ . ': { position : "right", innerHTML: \'ex:role="facet" ex:showMissing="false" ex:facetClass="TextSearch" ex:facetLabel="' . $facet . '"\'}';
} else {
// usual facet
foreach ($res->getPrintRequests() as $pr) {
if ($this->encodePropertyName($pr->getLabel()) == $this->encodePropertyName($facet)) {
switch ($pr->getTypeID()) {
case '_num':
$facetstack[] = ' facet' . $facetcounter++ . ': { position : "right", innerHTML: \'ex:role="facet" ex:showMissing="false" ex:expression=".' . $this->encodePropertyName($facet) . '" ex:facetLabel="' . $facet . '" ex:facetClass="Slider"\'}';
break;
default:
$facetstack[] = ' facet' . $facetcounter++ . ': { position : "right", innerHTML: \'ex:role="facet" ex:showMissing="false" ' . implode(" ", $facparams) . ' ex:expression=".' . $this->encodePropertyName($facet) . '" ex:facetLabel="' . $facet . '"\'}';
}
}
}
}
$fieldcounter++;
}
$facetstring = implode(',', $facetstack);
} else {
$facetstring = '';
}
$facetsrc = "var ex_facets = {" . $facetstring . " };";
//.........这里部分代码省略.........
示例12: getResultText
protected function getResultText(SMWQueryResult $res, $outputmode)
{
global $smwgIQRunningNumber, $wgSitename, $wgServer, $smwgRSSEnabled, $wgRequest;
$result = '';
if ($outputmode == SMW_OUTPUT_FILE) {
// make RSS feed
if (!$smwgRSSEnabled) {
return '';
}
if ($this->m_title === '') {
$this->m_title = $wgSitename;
}
if ($this->m_description === '') {
$this->m_description = wfMsg('smw_rss_description', $wgSitename);
}
// cast printouts into "items"
$items = array();
$row = $res->getNext();
while ($row !== false) {
$creators = array();
$dates = array();
$wikipage = $row[0]->getNextDataValue();
// get the object
foreach ($row as $field) {
// for now we ignore everything but creator and date, later we may
// add more things like geolocs, categories, and even a generic
// mechanism to add whatever you want :)
$req = $field->getPrintRequest();
if (strtolower($req->getLabel()) == 'creator') {
while ($entry = $field->getNextDataValue()) {
$creators[] = $entry->getShortWikiText();
}
} elseif (strtolower($req->getLabel()) == 'date' && $req->getTypeID() == '_dat') {
while ($entry = $field->getNextDataValue()) {
$dates[] = $entry->getXMLSchemaDate();
}
}
}
if ($wikipage instanceof SMWWikiPageValue) {
// this should rarely fail, but better be carful
///TODO: It would be more elegant to have type chekcs initially
$items[] = new SMWRSSItem($wikipage->getTitle(), $creators, $dates);
}
$row = $res->getNext();
}
$result .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$result .= "<rdf:RDF\n";
$result .= "\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n";
$result .= "\txmlns:content=\"http://purl.org/rss/1.0/modules/content/\"\n";
$result .= "\txmlns:admin=\"http://webns.net/mvcb/\"\n";
$result .= "\txmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n";
$result .= "\txmlns=\"http://purl.org/rss/1.0/\">\n";
$result .= "\t<channel rdf:about=\"" . str_replace('&', '&', $wgRequest->getFullRequestURL()) . "\">\n";
$result .= "\t\t<admin:generatorAgent rdf:resource=\"http://semantic-mediawiki.org/wiki/Special:URIResolver/Semantic_MediaWiki\"/>\n";
$result .= "\t\t<title>" . smwfXMLContentEncode($this->m_title) . "</title>\n";
$result .= "\t\t<link>{$wgServer}</link>\n";
$result .= "\t\t<description>" . smwfXMLContentEncode($this->m_description) . "</description>\n";
if (count($items) > 0) {
$result .= "\t\t<items>\n";
$result .= "\t\t\t<rdf:Seq>\n";
foreach ($items as $item) {
$result .= "\t\t\t\t<rdf:li rdf:resource=\"" . $item->uri() . "\"/>\n";
}
$result .= "\t\t\t</rdf:Seq>\n";
$result .= "\t\t</items>\n";
}
$result .= "\t</channel>\n";
foreach ($items as $item) {
$result .= $item->text();
}
$result .= '</rdf:RDF>';
} else {
// just make link to feed
if ($this->getSearchLabel($outputmode)) {
$label = $this->getSearchLabel($outputmode);
} else {
$label = wfMsgForContent('smw_rss_link');
}
$link = $res->getQueryLink($label);
$link->setParameter('rss', 'format');
if ($this->m_title !== '') {
$link->setParameter($this->m_title, 'title');
}
if ($this->m_description !== '') {
$link->setParameter($this->m_description, 'description');
}
if (array_key_exists('limit', $this->m_params)) {
$link->setParameter($this->m_params['limit'], 'limit');
} else {
// use a reasonable deafult limit (10 is suggested by RSS)
$link->setParameter(10, 'limit');
}
foreach ($res->getPrintRequests() as $printout) {
// overwrite given "sort" parameter with printout of label "date"
if ($printout->getMode() == SMWPrintRequest::PRINT_PROP && strtolower($printout->getLabel()) == "date" && $printout->getTypeID() == "_dat") {
$link->setParameter($printout->getData()->getWikiValue(), 'sort');
}
}
$result .= $link->getText($outputmode, $this->mLinker);
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
//.........这里部分代码省略.........
示例13: getKMLLink
/**
* Returns a link (HTML) pointing to a query that returns the actual KML file.
*
* @since 0.7.3
*
* @param SMWQueryResult $res
* @param integer $outputmode
*
* @return string
*/
protected function getKMLLink(SMWQueryResult $res, $outputmode)
{
$searchLabel = $this->getSearchLabel($outputmode);
$link = $res->getQueryLink($searchLabel ? $searchLabel : wfMessage('semanticmaps-kml-link')->inContentLanguage()->text());
$link->setParameter('kml', 'format');
$link->setParameter($this->params['linkabsolute'] ? 'yes' : 'no', 'linkabsolute');
$link->setParameter($this->params['pagelinktext'], 'pagelinktext');
if ($this->params['title'] !== '') {
$link->setParameter($this->params['title'], 'title');
}
if ($this->params['text'] !== '') {
$link->setParameter($this->params['text'], 'text');
}
// Fix for offset-error in getQueryLink()
// (getQueryLink by default sets offset to point to the next
// result set, fix by setting it to 0 if now explicitly set)
if (array_key_exists('offset', $this->params)) {
$link->setParameter($this->params['offset'], 'offset');
} else {
$link->setParameter(0, 'offset');
}
if (array_key_exists('limit', $this->params)) {
$link->setParameter($this->params['limit'], 'limit');
} else {
// Use a reasonable default limit.
$link->setParameter(20, 'limit');
}
$this->isHTML = $outputmode == SMW_OUTPUT_HTML;
return $link->getText($outputmode, $this->mLinker);
}