当前位置: 首页>>代码示例>>PHP>>正文


PHP SMWQueryProcessor::getResultFromFunctionParams方法代码示例

本文整理汇总了PHP中SMWQueryProcessor::getResultFromFunctionParams方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWQueryProcessor::getResultFromFunctionParams方法的具体用法?PHP SMWQueryProcessor::getResultFromFunctionParams怎么用?PHP SMWQueryProcessor::getResultFromFunctionParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SMWQueryProcessor的用法示例。


在下文中一共展示了SMWQueryProcessor::getResultFromFunctionParams方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doProcessQueryFor

 private function doProcessQueryFor($query, $sep = ",")
 {
     $query = str_replace(array("&lt;", "&gt;", "sep=;"), array("<", ">", "sep={$sep};"), $query);
     $params = explode(";", $query);
     $f = str_replace(";", "|", $params[0]);
     $params[0] = $this->parser->replaceVariables($f);
     if ($this->debugFlag) {
         error_log(implode("|", $params));
     }
     $values = $this->getFormattedValuesFrom($sep, QueryProcessor::getResultFromFunctionParams($params, SMW_OUTPUT_WIKI));
     return json_encode(array("values" => $values, "count" => count($values)));
 }
开发者ID:paladox,项目名称:SemanticFormsSelect,代码行数:12,代码来源:ApiRequestProcessor.php

示例2: getSemanticInternalObjects

 /**
  * 
  * Retrieve all internal objects and their properties.
  * @param String $pagename
  * @param String $internalproperty
  * @return an array. Each element is an associative array and represents an internal object.
  * 
  * E.G: {{#ptest:Chross|Is a parameter in an application}}
  * 
  */
 public static function getSemanticInternalObjects($pagename, $internalproperty, $namespace = NS_MAIN)
 {
     $params = array("[[{$internalproperty}::{$pagename}]]", "format=list", "link=none", "headers=hide", "sep=;", "limit=5000");
     $result = SMWQueryProcessor::getResultFromFunctionParams($params, SMW_OUTPUT_WIKI);
     $result = trim($result);
     $sios = array();
     if ($result) {
         $sios = explode(";", $result);
     }
     $ret = array();
     foreach ($sios as $sio) {
         #remove namespace prefix.
         $sio = preg_replace("/^[^:]+:/", "", $sio);
         $sio = str_replace(" ", "_", $sio);
         #remove fragment to -
         #$sio=str_replace("#", "-23", $sio);
         array_push($ret, self::loadSemanticProperties($sio, $namespace, true));
     }
     return $ret;
 }
开发者ID:kghbln,项目名称:semanticaccesscontrol,代码行数:30,代码来源:SMWUtil.php

示例3: render

 /**
  * Method for handling the ask parser function.
  * 
  * @since 1.5.3
  * 
  * @param Parser $parser
  */
 public static function render(Parser &$parser)
 {
     global $smwgQEnabled, $smwgIQRunningNumber, $wgTitle;
     if ($smwgQEnabled) {
         $smwgIQRunningNumber++;
         $params = func_get_args();
         array_shift($params);
         // We already know the $parser ...
         $result = SMWQueryProcessor::getResultFromFunctionParams($params, SMW_OUTPUT_WIKI);
     } else {
         $result = smwfEncodeMessages(array(wfMessage('smw_iq_disabled')->inContentLanguage()->text()));
     }
     if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) {
         global $wgOut;
         SMWOutputs::commitToOutputPage($wgOut);
     } else {
         SMWOutputs::commitToParser($parser);
     }
     return $result;
 }
开发者ID:nischayn22,项目名称:SemanticMediawiki,代码行数:27,代码来源:SMW_Ask.php

示例4: __construct

 public function __construct(&$results, SMWPrintRequest $printRequest, SRFFiltered &$queryPrinter)
 {
     global $wgParser;
     parent::__construct($results, $printRequest, $queryPrinter);
     if (!defined('Maps_VERSION') || version_compare(Maps_VERSION, '1.0', '<')) {
         throw new FatalError('You need to have the <a href="http://www.mediawiki.org/wiki/Extension:Maps">Maps</a> extension version 1.0 or higher installed in order to use the distance filter.<br />');
     }
     MapsGeocoders::init();
     $params = $this->getActualParameters();
     if (array_key_exists('distance filter origin', $params)) {
         $origin = MapsGeocoders::attemptToGeocode($wgParser->recursiveTagParse($params['distance filter origin']));
     } else {
         $origin = array('lat' => '0', 'lon' => '0');
     }
     if (array_key_exists('distance filter unit', $params)) {
         $this->mUnit = MapsDistanceParser::getValidUnit($wgParser->recursiveTagParse($params['distance filter unit']));
     } else {
         $this->mUnit = MapsDistanceParser::getValidUnit();
     }
     // Is the real position stored in a property?
     if (array_key_exists('distance filter property', $params)) {
         $property = trim($wgParser->recursiveTagParse($params['distance filter property']));
         $locations = array();
     } else {
         $property = null;
         $locations = null;
     }
     $targetLabel = $printRequest->getLabel();
     foreach ($this->getQueryResults() as $id => $filteredItem) {
         $row = $filteredItem->getValue();
         // $filteredItem is of class SRF_Filtered_Item
         // $row is an array of SMWResultArray
         foreach ($row as $field) {
             // $field is an SMWResultArray
             $label = $field->getPrintRequest()->getLabel();
             if ($label === $targetLabel) {
                 $field->reset();
                 $dataValue = $field->getNextDataValue();
                 // only use first value
                 if ($dataValue !== false) {
                     $posText = $dataValue->getShortText(SMW_OUTPUT_WIKI, false);
                     if ($property === null) {
                         // position is directly given
                         $pos = MapsGeocoders::attemptToGeocode($posText);
                     } else {
                         // position is given in a property of a page
                         // if we used this page before, just look up the coordinates
                         if (array_key_exists($posText, $locations)) {
                             $pos = $locations[$posText];
                         } else {
                             // query the position's page for the coordinates or address
                             $posText = SMWQueryProcessor::getResultFromFunctionParams(array($posText, '?' . $property), SMW_OUTPUT_WIKI, SMWQueryProcessor::INLINE_QUERY, true);
                             //
                             if ($posText !== '') {
                                 // geocode
                                 $pos = MapsGeocoders::attemptToGeocode($posText);
                             } else {
                                 $pos = array('lat' => '0', 'lon' => '0');
                             }
                             // store coordinates in case we need them again
                             $locations[$posText] = $pos;
                         }
                     }
                     if (is_array($pos)) {
                         $distance = round(MapsGeoFunctions::calculateDistance($origin, $pos) / MapsDistanceParser::getUnitRatio($this->mUnit));
                         if ($distance > $this->mMaxDistance) {
                             $this->mMaxDistance = $distance;
                         }
                     } else {
                         $distance = -1;
                     }
                 } else {
                     $distance = -1;
                     // no location given
                 }
                 $filteredItem->setData('distance-filter', $distance);
                 break;
             }
         }
     }
     if (array_key_exists('distance filter max distance', $params) && is_numeric($maxDist = trim($wgParser->recursiveTagParse($params['distance filter max distance'])))) {
         // this assignation ^^^ is ugly, but intentional
         $this->mMaxDistance = $maxDist;
     } else {
         if ($this->mMaxDistance > 1) {
             $base = pow(10, floor(log10($this->mMaxDistance)));
             $this->mMaxDistance = ceil($this->mMaxDistance / $base) * $base;
         }
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:90,代码来源:SRF_FF_Distance.php

示例5: select

 public function select($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args)
 {
     global $wgScriptSelectCount, $sfgFieldNum, $wgUser;
     $selectField = array();
     $values = null;
     $staticvalue = false;
     if (array_key_exists("query", $other_args)) {
         $query = $other_args["query"];
         $query = str_replace(array("~", "(", ")"), array("=", "[", "]"), $query);
         $selectField["query"] = $query;
         if (strpos($query, '@@@@') === false) {
             $params = explode(";", $query);
             $params[0] = $this->parser->replaceVariables($params[0]);
             $values = QueryProcessor::getResultFromFunctionParams($params, SMW_OUTPUT_WIKI);
             $staticvalue = true;
         }
     } elseif (array_key_exists("function", $other_args)) {
         $query = $other_args["function"];
         $query = '{{#' . $query . '}}';
         $query = str_replace(array("~", "(", ")"), array("=", "[", "]"), $query);
         $selectField["function"] = $query;
         if (strpos($query, '@@@@') === false) {
             $f = str_replace(";", "|", $query);
             $values = $this->parser->replaceVariables($f);
             $staticvalue = true;
         }
     }
     $data = array();
     if ($staticvalue) {
         $values = explode(",", $values);
         $values = array_map("trim", $values);
         $values = array_unique($values);
     } else {
         if ($wgScriptSelectCount == 0) {
             Output::addModule('ext.sf_select.scriptselect');
         }
         $wgScriptSelectCount++;
         $data["selectismultiple"] = array_key_exists("part_of_multiple", $other_args);
         $index = strpos($input_name, "[");
         $data['selecttemplate'] = substr($input_name, 0, $index);
         // Does hit work for multiple template?
         $index = strrpos($input_name, "[");
         $data['selectfield'] = substr($input_name, $index + 1, strlen($input_name) - $index - 2);
         $valueField = array();
         $data["valuetemplate"] = array_key_exists("sametemplate", $other_args) ? $data['selecttemplate'] : $other_args["template"];
         $data["valuefield"] = $other_args["field"];
         $data['selectrm'] = array_key_exists('rmdiv', $other_args);
         $data['label'] = array_key_exists('label', $other_args);
         $data['sep'] = array_key_exists('sep', $other_args) ? $other_args["sep"] : ',';
         if (array_key_exists("query", $selectField)) {
             $data['selectquery'] = $selectField['query'];
         } else {
             $data['selectfunction'] = $selectField['function'];
         }
         self::$data[] = $data;
     }
     $extraatt = "";
     $is_list = false;
     // TODO This needs clean-up
     if (array_key_exists('is_list', $other_args) && $other_args['is_list'] == true) {
         $is_list = true;
     }
     if ($is_list) {
         $extraatt = ' multiple="multiple" ';
     }
     if (array_key_exists("size", $other_args)) {
         $extraatt .= " size=\"{$other_args['size']}\"";
     }
     $classes = array();
     if ($is_mandatory) {
         $classes[] = "mandatoryField";
     }
     if (array_key_exists("class", $other_args)) {
         $classes[] = $other_args['class'];
     }
     if ($classes) {
         $cstr = implode(" ", $classes);
         $extraatt .= " class=\"{$cstr}\"";
     }
     $inname = $input_name;
     if ($is_list) {
         $inname .= '[]';
     }
     // TODO Use Html::
     $spanextra = $is_mandatory ? 'mandatoryFieldSpan' : '';
     $ret = "<span class=\"inputSpan {$spanextra}\"><select name='{$inname}' id='input_{$sfgFieldNum}' {$extraatt}>";
     $curvalues = null;
     if ($cur_value) {
         if ($cur_value === 'current user') {
             $cur_value = $wgUser->getName();
         }
         if (is_array($cur_value)) {
             $curvalues = $cur_value;
         } else {
             $curvalues = array_map("trim", explode(",", $cur_value));
         }
     } else {
         $curvalues = array();
     }
     // TODO handle empty value case.
//.........这里部分代码省略.........
开发者ID:paladox,项目名称:SemanticFormsSelect,代码行数:101,代码来源:SemanticFormsSelect.php


注:本文中的SMWQueryProcessor::getResultFromFunctionParams方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。