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


PHP SMWOutputs::requireResource方法代码示例

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


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

示例1: getResultText

 /**
  * Return serialised results in specified format.
  * Implemented by subclasses.
  */
 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     $html = '';
     $id = uniqid();
     // build an array of article IDs contained in the result set
     $objects = array();
     foreach ($res->getResults() as $key => $object) {
         $objects[] = array($object->getTitle()->getArticleId());
         $html .= $key . ': ' . $object->getSerialization() . "<br>\n";
     }
     // build an array of data about the printrequests
     $printrequests = array();
     foreach ($res->getPrintRequests() as $key => $printrequest) {
         $data = $printrequest->getData();
         if ($data instanceof SMWPropertyValue) {
             $name = $data->getDataItem()->getKey();
         } else {
             $name = null;
         }
         $printrequests[] = array($printrequest->getMode(), $printrequest->getLabel(), $name, $printrequest->getOutputFormat(), $printrequest->getParameters());
     }
     // write out results and query params into JS arrays
     // Define the srf_filtered_values array
     SMWOutputs::requireScript('srf_slideshow', Html::inlineScript('srf_slideshow = {};'));
     SMWOutputs::requireScript('srf_slideshow' . $id, Html::inlineScript('srf_slideshow["' . $id . '"] = ' . json_encode(array($objects, $this->params['template'], $this->params['delay'] * 1000, $this->params['height'], $this->params['width'], $this->params['nav controls'], $this->params['effect'], json_encode($printrequests))) . ';'));
     SMWOutputs::requireResource('ext.srf.slideshow');
     if ($this->params['nav controls']) {
         SMWOutputs::requireResource('jquery.ui.slider');
     }
     return Html::element('div', array('id' => $id, 'class' => 'srf-slideshow ' . $id . ' ' . $this->params['class']));
 }
开发者ID:cicalese,项目名称:SemanticResultFormats,代码行数:35,代码来源:SRF_SlideShow.php

示例2: getFormatOutput

 /**
  * @see SMWResultPrinter::getFormatOutput
  *
  * @since 1.8
  *
  * @param array $data label => value
  * @return string
  */
 protected function getFormatOutput(array $data)
 {
     // Object count
     static $statNr = 0;
     $d3chartID = 'd3-chart-' . ++$statNr;
     $this->isHTML = true;
     // Reorganize the raw data
     foreach ($data as $name => $value) {
         if ($value >= $this->params['min']) {
             $dataObject[] = array('label' => $name, 'value' => $value);
         }
     }
     // Ensure right conversion
     $width = strstr($this->params['width'], "%") ? $this->params['width'] : $this->params['width'] . 'px';
     // Prepare transfer objects
     $d3data = array('data' => $dataObject, 'parameters' => array('colorscheme' => $this->params['colorscheme'] ? $this->params['colorscheme'] : null, 'charttitle' => $this->params['charttitle'], 'charttext' => $this->params['charttext'], 'datalabels' => $this->params['datalabels']));
     // Encoding
     $requireHeadItem = array($d3chartID => FormatJson::encode($d3data));
     SMWOutputs::requireHeadItem($d3chartID, Skin::makeVariablesScript($requireHeadItem));
     // RL module
     $resource = 'ext.srf.d3.chart.' . $this->params['charttype'];
     SMWOutputs::requireResource($resource);
     // Chart/graph placeholder
     $chart = Html::rawElement('div', array('id' => $d3chartID, 'class' => 'container', 'style' => 'display:none;'), null);
     // Processing placeholder
     $processing = SRFUtils::htmlProcessingElement($this->isHTML);
     // Beautify class selector
     $class = $this->params['charttype'] ? '-' . $this->params['charttype'] : '';
     $class = $this->params['class'] ? $class . ' ' . $this->params['class'] : $class . ' d3-chart-common';
     // D3 wrappper
     return Html::rawElement('div', array('class' => 'srf-d3-chart' . $class, 'style' => "width:{$width}; height:{$this->params['height']}px;"), $processing . $chart);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:40,代码来源:SRF_D3Chart.php

示例3: getFormatOutput

 /**
  * Prepare data output
  *
  * @since 1.8
  *
  * @param array $data label => value
  */
 protected function getFormatOutput(array $data)
 {
     //Init
     $dataObject = array();
     static $statNr = 0;
     $chartID = 'sparkline-' . $this->params['charttype'] . '-' . ++$statNr;
     $this->isHTML = true;
     // Prepare data array
     foreach ($data as $key => $value) {
         if ($value >= $this->params['min']) {
             $dataObject['label'][] = $key;
             $dataObject['value'][] = $value;
         }
     }
     $dataObject['charttype'] = $this->params['charttype'];
     // Encode data objects
     $requireHeadItem = array($chartID => FormatJson::encode($dataObject));
     SMWOutputs::requireHeadItem($chartID, Skin::makeVariablesScript($requireHeadItem));
     // RL module
     SMWOutputs::requireResource('ext.srf.sparkline');
     // Processing placeholder
     $processing = SRFUtils::htmlProcessingElement(false);
     // Chart/graph placeholder
     $chart = Html::rawElement('div', array('id' => $chartID, 'class' => 'container', 'style' => "display:none;"), null);
     // Beautify class selector
     $class = $this->params['class'] ? ' ' . $this->params['class'] : '';
     // Chart/graph wrappper
     return Html::rawElement('span', array('class' => 'srf-sparkline' . $class), $processing . $chart);
 }
开发者ID:yusufchang,项目名称:app,代码行数:36,代码来源:SRF_Sparkline.php

示例4: getResultText

 public function getResultText(SMWQueryResult $results, $outputmode)
 {
     global $wgUser, $wgParser;
     $ig = new ImageGallery();
     $ig->setShowBytes(false);
     $ig->setShowFilename(false);
     $ig->setParser($wgParser);
     $ig->setCaption($this->mIntro);
     // set caption to IQ header
     if ($this->params['galleryformat'] == 'carousel') {
         static $carouselNr = 0;
         // Set attributes for jcarousel
         $dataAttribs = array('wrap' => 'both', 'vertical' => 'false', 'rtl' => 'false');
         // Use perrow parameter to determine the scroll sequence.
         if (empty($this->params['perrow'])) {
             $dataAttribs['scroll'] = 1;
             // default 1
         } else {
             $dataAttribs['scroll'] = $this->params['perrow'];
             $dataAttribs['visible'] = $this->params['perrow'];
         }
         $attribs = array('id' => 'carousel' . ++$carouselNr, 'class' => 'jcarousel jcarousel-skin-smw', 'style' => 'display:none;');
         foreach ($dataAttribs as $name => $value) {
             $attribs['data-' . $name] = $value;
         }
         $ig->setAttributes($attribs);
         // Load javascript module
         SMWOutputs::requireResource('ext.srf.jcarousel');
     }
     // In case galleryformat = carousel, perrow should not be set
     if ($this->params['perrow'] !== '' && $this->params['galleryformat'] !== 'carousel') {
         $ig->setPerRow($this->params['perrow']);
     }
     if ($this->params['widths'] !== '') {
         $ig->setWidths($this->params['widths']);
     }
     if ($this->params['heights'] !== '') {
         $ig->setHeights($this->params['heights']);
     }
     $printReqLabels = array();
     foreach ($results->getPrintRequests() as $printReq) {
         $printReqLabels[] = $printReq->getLabel();
     }
     if ($this->params['imageproperty'] !== '' && in_array($this->params['imageproperty'], $printReqLabels)) {
         $this->addImageProperties($results, $ig, $this->params['imageproperty'], $this->params['captionproperty']);
     } else {
         $this->addImagePages($results, $ig);
     }
     return array($ig->toHTML(), 'nowiki' => true, 'isHTML' => true);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:50,代码来源:SRF_Gallery.php

示例5: doFormatFinalOutputFor

 /**
  * @see StringValueFormatter::doFormatFinalOutputFor
  */
 protected function doFormatFinalOutputFor($type, $linker)
 {
     $abbreviate = $type === self::WIKI_LONG || $type === self::HTML_LONG;
     $text = $this->dataValue->getDataItem()->getString();
     // Escape and wrap values of type Code. The result is escaped to be
     // HTML-safe (it will also work in wiki context). The result will
     // contain mark-up that must not be escaped again.
     Outputs::requireResource('ext.smw.style');
     // This disables all active wiki and HTML markup:
     $result = str_replace(array('<', '>', ' ', '[', '{', '=', "'", ':', "\n"), array('&lt;', '&gt;', '&#160;', '&#x005B;', '&#x007B;', '&#x003D;', '&#x0027;', '&#58;', "<br />"), $text);
     if ($abbreviate) {
         $result = "<div style=\"height:5em; overflow:auto;\">{$result}</div>";
     }
     return "<div class=\"smwpre\">{$result}</div>";
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:18,代码来源:CodeStringValueFormatter.php

示例6: getResultText

 /**
  * @see SMWResultPrinter::getResultText
  *
  * @param SMWQueryResult $res
  * @param $outputMode
  *
  * @return string
  */
 protected function getResultText(SMWQueryResult $res, $outputMode)
 {
     // Initialize
     static $statNr = 0;
     // Get results from SMWListResultPrinter
     $result = parent::getResultText($res, $outputMode);
     // Count widgets
     $widgetID = 'pagewidget-' . ++$statNr;
     // Container items
     $result = Html::rawElement('div', array('id' => $widgetID, 'class' => 'container', 'data-embedonly' => $this->params['embedonly'], 'style' => 'display:none;'), $result);
     // Placeholder
     $processing = SRFUtils::htmlProcessingElement($this->isHTML);
     // RL module
     SMWOutputs::requireResource('ext.srf.pagewidget.carousel');
     // Beautify class selector
     $class = $this->params['class'] ? ' ' . $this->params['class'] : '';
     // Wrap results
     return Html::rawElement('div', array('class' => 'srf-pagewidget' . $class), $processing . $result);
 }
开发者ID:cicalese,项目名称:SemanticResultFormats,代码行数:27,代码来源:SRF_PageWidget.php

示例7: render

 /**
  * Method for handling the ask concept function.
  * 
  * @todo The possible use of this in an HTML or Specal page context needs to be revisited. The code mentions it, but can this actually happen?
  * @todo The escaping of symbols in concept queries needs to be revisited.
  * 
  * @since 1.5.3
  * 
  * @param Parser $parser
  */
 public static function render(Parser &$parser)
 {
     global $wgContLang, $wgTitle;
     $title = $parser->getTitle();
     $pconc = new SMWDIProperty('_CONC');
     if ($title->getNamespace() != SMW_NS_CONCEPT) {
         $result = smwfEncodeMessages(array(wfMsgForContent('smw_no_concept_namespace')));
         SMWOutputs::commitToParser($parser);
         return $result;
     } elseif (count(SMWParseData::getSMWdata($parser)->getPropertyValues($pconc)) > 0) {
         $result = smwfEncodeMessages(array(wfMsgForContent('smw_multiple_concepts')));
         SMWOutputs::commitToParser($parser);
         return $result;
     }
     // process input:
     $params = func_get_args();
     array_shift($params);
     // We already know the $parser ...
     // Use first parameter as concept (query) string.
     $concept_input = str_replace(array('&gt;', '&lt;'), array('>', '<'), array_shift($params));
     // second parameter, if any, might be a description
     $concept_docu = array_shift($params);
     // NOTE: the str_replace above is required in MediaWiki 1.11, but not in MediaWiki 1.14
     $query = SMWQueryProcessor::createQuery($concept_input, SMWQueryProcessor::getProcessedParams(array('limit' => 20, 'format' => 'list')), SMWQueryProcessor::CONCEPT_DESC);
     $concept_text = $query->getDescription()->getQueryString();
     if (!is_null(SMWParseData::getSMWData($parser))) {
         $diConcept = new SMWDIConcept($concept_text, $concept_docu, $query->getDescription()->getQueryFeatures(), $query->getDescription()->getSize(), $query->getDescription()->getDepth());
         SMWParseData::getSMWData($parser)->addPropertyObjectValue($pconc, $diConcept);
     }
     // display concept box:
     $rdflink = SMWInfolink::newInternalLink(wfMsgForContent('smw_viewasrdf'), $wgContLang->getNsText(NS_SPECIAL) . ':ExportRDF/' . $title->getPrefixedText(), 'rdflink');
     SMWOutputs::requireResource('ext.smw.style');
     // TODO: escape output, preferably via Html or Xml class.
     $result = '<div class="smwfact"><span class="smwfactboxhead">' . wfMsgForContent('smw_concept_description', $title->getText()) . (count($query->getErrors()) > 0 ? ' ' . smwfEncodeMessages($query->getErrors()) : '') . '</span>' . '<span class="smwrdflink">' . $rdflink->getWikiText() . '</span>' . '<br />' . ($concept_docu ? "<p>{$concept_docu}</p>" : '') . '<pre>' . str_replace('[', '&#x005B;', $concept_text) . "</pre>\n</div>";
     if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) {
         global $wgOut;
         SMWOutputs::commitToOutputPage($wgOut);
     } else {
         SMWOutputs::commitToParser($parser);
     }
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:52,代码来源:SMW_Concept.php

示例8: getResultText

 /**
  * @see SMWResultPrinter::getResultText
  *
  * @param SMWQueryResult $res
  * @param array $params
  * @param $outputmode
  *
  * @return string
  */
 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     // Initialize
     static $statNr = 0;
     //$this->isHTML = true;
     // Set output type for the parent
     $this->mFormat = $this->params['listtype'] == 'ordered' || $this->params['listtype'] == 'ol' ? 'ol' : 'ul';
     // Get results from SMWListResultPrinter
     $result = parent::getResultText($res, $outputmode);
     // Count widgets
     $listwidgetID = 'listwidget-' . ++$statNr;
     // OL/UL container items
     $result = Html::rawElement('div', array('id' => $listwidgetID, 'class' => 'container', 'style' => 'display:none; position: relative; margin-bottom:5px; margin-top:5px;'), $result);
     // Placeholder
     $processing = SRFUtils::htmlProcessingElement($this->isHTML);
     // RL module
     $resource = 'ext.srf.listwidget.' . $this->params['widget'];
     SMWOutputs::requireResource($resource);
     // Wrap results
     return Html::rawElement('div', array('class' => 'srf-listwidget ' . htmlspecialchars($this->params['class']), 'data-listtype' => $this->mFormat, 'data-widget' => $this->params['widget'], 'data-pageitems' => $this->params['pageitems']), $processing . $result);
 }
开发者ID:cicalese,项目名称:SemanticResultFormats,代码行数:30,代码来源:SRF_ListWidget.php

示例9: getResultText

 /**
  * Return serialised results in specified format
  *
  * @param SMWQueryResult $results
  * @param $outputmode
  *
  * @return string
  */
 public function getResultText(SMWQueryResult $results, $outputmode)
 {
     // Check output conditions
     if ($this->params['widget'] == 'sphere' && $this->params['link'] !== 'all' && $this->params['template'] === '') {
         return $results->addErrors(array(wfMessage('srf-error-option-link-all', 'sphere')->inContentLanguage()->text()));
     }
     // Template support
     $this->hasTemplates = $this->params['template'] !== '';
     // Prioritize HTML setting
     $this->isHTML = $this->params['widget'] !== '';
     $this->isHTML = $this->params['template'] === '';
     $outputmode = SMW_OUTPUT_HTML;
     // Sphere widget
     if ($this->params['widget'] === 'sphere') {
         SMWOutputs::requireResource('ext.srf.tagcloud.sphere');
     }
     // Wordcloud widget
     if ($this->params['widget'] === 'wordcloud') {
         SMWOutputs::requireResource('ext.srf.tagcloud.wordcloud');
     }
     return $this->getTagCloud($this->getTagSizes($this->getTags($results, $outputmode)));
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:SRF_TagCloud.php

示例10: smwfEncodeMessages

/**
 * Formats an array of message strings so that it appears as a tooltip.
 * $icon should be one of: 'warning' (default), 'info'.
 *
 * @param array $messages
 * @param string $icon Acts like an enum. Callers must ensure safety, since this value is used directly in the output.
 * @param string $seperator
 * @param boolean $escape Should the messages be escaped or not (ie when they already are)
 *
 * @return string
 */
function smwfEncodeMessages(array $messages, $icon = 'warning', $seperator = ' <!--br-->', $escape = true)
{
    if (count($messages) > 0) {
        SMWOutputs::requireResource('ext.smw.tooltips');
        if ($escape) {
            $messages = array_map('htmlspecialchars', $messages);
        }
        if (count($messages) == 1) {
            $errorList = $messages[0];
        } else {
            foreach ($messages as &$message) {
                $message = '<li>' . $message . '</li>';
            }
            $errorList = '<ul>' . implode($seperator, $messages) . '</ul>';
        }
        return '<span class="smwttpersist">' . '<span class="smwtticon">' . htmlspecialchars($icon) . '.png</span>' . '<span class="smwttcontent">' . $errorList . '</span>' . '</span>';
    } else {
        return '';
    }
}
开发者ID:yusufchang,项目名称:app,代码行数:31,代码来源:SMW_GlobalFunctions.php

示例11: getSlideshowWidget

 /**
  * Init slideshow widget
  *
  * @since 1.8
  *
  * @return string
  */
 private function getSlideshowWidget()
 {
     $attribs = array('id' => uniqid(), 'class' => $this->getImageOverlay(), 'style' => 'display:none;', 'data-nav-control' => $this->params['navigation']);
     SMWOutputs::requireResource('ext.srf.gallery.slideshow');
     return $attribs;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:SRF_Gallery.php

示例12: getText

 /**
  * Returns a suitable text string for displaying this link in HTML or wiki, depending
  * on whether $outputformat is SMW_OUTPUT_WIKI or SMW_OUTPUT_HTML.
  *
  * The parameter $linker controls linking of values such as titles and should
  * be some Linker object (for HTML output). Some default linker will be created
  * if needed and not provided.
  */
 public function getText($outputformat, $linker = null)
 {
     if ($this->mStyle !== false) {
         SMWOutputs::requireResource('ext.smw.style');
         $start = "<span class=\"{$this->mStyle}\">";
         $end = '</span>';
     } else {
         $start = '';
         $end = '';
     }
     if ($this->mInternal) {
         if (count($this->mParams) > 0) {
             $titletext = $this->mTarget . '/' . self::encodeParameters($this->mParams);
         } else {
             $titletext = $this->mTarget;
         }
         $title = Title::newFromText($titletext);
         if (!is_null($title)) {
             if ($outputformat == SMW_OUTPUT_WIKI) {
                 $link = "[[{$titletext}|{$this->mCaption}]]";
             } else {
                 // SMW_OUTPUT_HTML, SMW_OUTPUT_FILE
                 $link = $this->getLinker($linker)->link($title, $this->mCaption);
             }
         } else {
             // Title creation failed, maybe illegal symbols or too long; make a direct URL link
             // (only possible if offending target parts belong to some parameter
             //  that can be separated from title text,
             //  e.g. as in Special:Bla/il<leg>al -> Special:Bla&p=il&lt;leg&gt;al)
             $title = Title::newFromText($this->mTarget);
             if (!is_null($title)) {
                 if ($outputformat == SMW_OUTPUT_WIKI) {
                     $link = '[' . $title->getFullURL(self::encodeParameters($this->mParams, false)) . " {$this->mCaption}]";
                 } else {
                     // SMW_OUTPUT_HTML, SMW_OUTPUT_FILE
                     $link = $this->getLinker($linker)->link($title, $this->mCaption, array(), self::encodeParameters($this->mParams, false));
                 }
             } else {
                 return '';
                 // the title was bad, normally this would indicate a software bug
             }
         }
     } else {
         $target = $this->getURL();
         if ($outputformat == SMW_OUTPUT_WIKI) {
             $link = "[{$target} {$this->mCaption}]";
         } else {
             // SMW_OUTPUT_HTML, SMW_OUTPUT_FILE
             $link = '<a href="' . htmlspecialchars($target) . "\">{$this->mCaption}</a>";
         }
     }
     return $start . $link . $end;
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:61,代码来源:SMW_Infolink.php

示例13: getFormatSelectBoxSep

    /**
     * Creates form elements for choosing the result-format and their
     * associated format.
     *
     * The drop-down list and the format options are returned seperately as
     * elements of an array.Use in conjunction with processFormatOptions() to
     * supply formats options using ajax. Also, use its complement
     * processFormatSelectBox() to decode form data sent by these elements.
     * UI's may overload these methods to change behaviour or form
     * parameters.
     *
     * @param string $defaultFormat The default format which remains selected in the form
     * @return array The first element contains the format selector, while the second contains the Format options
     */
    protected function getFormatSelectBoxSep($defaultFormat = 'broadtable')
    {
        global $smwgResultFormats;
        SMWOutputs::requireResource('jquery');
        // checking argument
        $defFormat = 'broadtable';
        if (array_key_exists($defaultFormat, $smwgResultFormats)) {
            $defFormat = $defaultFormat;
        }
        $printer = SMWQueryProcessor::getResultPrinter($defFormat, SMWQueryProcessor::SPECIAL_PAGE);
        $url = $this->getTitle()->getLocalURL("showformatoptions=' + this.value + '");
        foreach ($this->uiCore->getParameters() as $param => $value) {
            if ($param !== 'format') {
                $url .= '&params[' . Xml::escapeJsString($param) . ']=' . Xml::escapeJsString($value);
            }
        }
        // @todo FIXME: i18n: Hard coded parentheses.
        $result[0] = "\n" . '<select id="formatSelector" name="p[format]" onChange="JavaScript:updateOtherOptions(\'' . $url . '\')">' . "\n" . '<option value="' . $defFormat . '">' . $printer->getName() . ' (' . wfMessage('smw_ask_defaultformat')->text() . ')</option>' . "\n";
        $formats = array();
        foreach (array_keys($smwgResultFormats) as $format) {
            // Special formats "count" and "debug" currently not supported.
            if ($format != $defFormat && $format != 'count' && $format != 'debug') {
                $printer = SMWQueryProcessor::getResultPrinter($format, SMWQueryProcessor::SPECIAL_PAGE);
                $formats[$format] = $printer->getName();
            }
        }
        natcasesort($formats);
        $params = $this->uiCore->getParameters();
        foreach ($formats as $format => $name) {
            $result[0] .= '<option value="' . $format . '"' . ($params['format'] == $format ? ' selected' : '') . '>' . $name . "</option>\n";
        }
        $result[0] .= "</select>";
        $result[0] .= "\n";
        $result[] .= '<div id="other_options"> ' . $this->showFormatOptions($params['format'], $params) . ' </div>';
        // BEGIN: add javascript for updating formating options by ajax
        $javascript = <<<END
<script type="text/javascript">
function updateOtherOptions(strURL) {
\tjQuery.ajax({ url: strURL, context: document.body, success: function(data){
\t\tjQuery("#other_options").html(data);
\t}});
}
</script>
END;
        SMWOutputs::requireScript('smwUpdateOptionsQueryUI', $javascript);
        // END: add javascript for updating formating options by ajax
        return $result;
    }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:62,代码来源:SMW_QueryUI.php

示例14: getResultText

 /**
  * Return serialised results in specified format.
  */
 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     // collect the query results in an array
     $result = array();
     while ($row = $res->getNext()) {
         $result[uniqid()] = new SRF_Filtered_Item($row, $this);
     }
     $resourceModules = array();
     // prepare filter data for inclusion in HTML and  JS
     $filterHtml = '';
     $filterHandlers = array();
     $filterData = array();
     foreach ($res->getPrintRequests() as $printRequest) {
         $filter = $printRequest->getParameter('filter');
         if ($filter) {
             $filtersForPrintout = array_map('trim', explode(',', $filter));
             foreach ($filtersForPrintout as $filterName) {
                 if (array_key_exists($filterName, $this->mFilterTypes)) {
                     $filter = new $this->mFilterTypes[$filterName]($result, $printRequest, $this);
                     $resourceModules = $filter->getResourceModules();
                     if (is_array($resourceModules)) {
                         array_walk($resourceModules, 'SMWOutputs::requireResource');
                     } elseif (is_string($resourceModules)) {
                         SMWOutputs::requireResource($resourceModules);
                     }
                     $printRequestHash = md5($printRequest->getHash());
                     $filterHtml .= Html::rawElement('div', array('class' => "filtered-{$filterName} {$printRequestHash}"), $filter->getResultText());
                     $filterHandlers[$filterName] = null;
                     $filterData[$filterName][$printRequestHash] = $filter->getJsData();
                 }
             }
         }
     }
     // wrap filters in a div
     $filterHtml = Html::rawElement('div', array('class' => 'filtered-filters'), $filterHtml);
     // prepare view data for inclusion in HTML and  JS
     $viewHtml = '';
     $viewSelectorsHtml = '';
     $viewHandlers = array();
     $viewElements = array();
     // will contain the id of the html element to be used by the view
     $viewData = array();
     foreach ($this->mViews as $viewName) {
         // cut off the selector label (if one was specified) from the actual view name
         $viewnameComponents = explode('=', $viewName, 2);
         $viewName = trim($viewnameComponents[0]);
         if (array_key_exists($viewName, $this->mViewTypes)) {
             // generate unique id
             $viewid = uniqid();
             $view = new $this->mViewTypes[$viewName]($viewid, $result, $this->mParams, $this);
             if (count($viewnameComponents) > 1) {
                 // a selector label was specified in the wiki text
                 $viewSelectorLabel = trim($viewnameComponents[1]);
             } else {
                 // use the default selector label
                 $viewSelectorLabel = $view->getSelectorLabel();
             }
             $resourceModules = $view->getResourceModules();
             if (is_array($resourceModules)) {
                 array_walk($resourceModules, 'SMWOutputs::requireResource');
             } elseif (is_string($resourceModules)) {
                 SMWOutputs::requireResource($resourceModules);
             }
             $viewHtml .= Html::rawElement('div', array('class' => "filtered-view filtered-{$viewName} filtered-view-id{$viewid}"), $view->getResultText());
             $viewSelectorsHtml .= Html::rawElement('div', array('class' => "filtered-view-selector filtered-{$viewName} filtered-view-id{$viewid}"), $viewSelectorLabel);
             $viewHandlers[$viewName] = null;
             $viewElements[$viewName][] = $viewid;
             $viewData[$viewName] = $view->getJsData();
         }
     }
     // more than one view?
     if (count($viewData) > 1) {
         // wrap views in a div
         $viewHtml = Html::rawElement('div', array('class' => 'filtered-views', 'style' => 'display:none'), Html::rawElement('div', array('class' => 'filtered-views-selectors-container'), $viewSelectorsHtml) . Html::rawElement('div', array('class' => 'filtered-views-container'), $viewHtml));
     } else {
         // wrap views in a div
         $viewHtml = Html::rawElement('div', array('class' => 'filtered-views', 'style' => 'display:none'), Html::rawElement('div', array('class' => 'filtered-views-container'), $viewHtml));
     }
     // Define the srf_filtered_values array
     SMWOutputs::requireScript('srf_filtered_values', Html::inlineScript('srf_filtered_values = {};'));
     $resultAsArray = array();
     foreach ($result as $id => $value) {
         $resultAsArray[$id] = $value->getArrayRepresentation();
     }
     $id = uniqid();
     SMWOutputs::requireScript('srf_filtered_values' . $id, Html::inlineScript('srf_filtered_values["' . $id . '"] = { "values":' . json_encode($resultAsArray) . ', "data": {' . ' "viewhandlers" : ' . json_encode($viewHandlers) . ', "viewelements" : ' . json_encode($viewElements) . ', "viewdata" : ' . json_encode($viewData) . ', "filterhandlers" : ' . json_encode($filterHandlers) . ', "filterdata" : ' . json_encode($filterData) . ', "sorthandlers" : ' . json_encode(array()) . ', "sorterdata" : ' . json_encode(array()) . '}};'));
     SMWOutputs::requireResource('ext.srf.filtered');
     // wrap all in a div
     if ($this->mFiltersOnTop) {
         $html = Html::rawElement('div', array('class' => 'filtered ' . $id), $filterHtml . $viewHtml);
     } else {
         $html = Html::rawElement('div', array('class' => 'filtered ' . $id), $viewHtml . $filterHtml);
     }
     return $html;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:98,代码来源:SRF_Filtered.php

示例15: getResultText

 /**
  * Builds up and returns the HTML for the map, with the queried coordinate data on it.
  *
  * @param SMWQueryResult $res
  * @param $outputmode
  * 
  * @return array or string
  */
 public final function getResultText(SMWQueryResult $res, $outputmode)
 {
     if ($this->fatalErrorMsg !== false) {
         return $this->fatalErrorMsg;
     }
     /**
      * @var Parser $wgParser
      */
     global $wgParser;
     $params = $this->params;
     $queryHandler = new SMQueryHandler($res, $outputmode);
     $queryHandler->setLinkStyle($params['link']);
     $queryHandler->setHeaderStyle($params['headers']);
     $queryHandler->setShowSubject($params['showtitle']);
     $queryHandler->setTemplate($params['template']);
     $queryHandler->setHideNamespace($params['hidenamespace']);
     $queryHandler->setActiveIcon($params['activeicon']);
     $this->handleMarkerData($params, $queryHandler);
     $locationAmount = count($params['locations']);
     if ($locationAmount > 0) {
         // We can only take care of the zoom defaulting here,
         // as not all locations are available in whats passed to Validator.
         if ($this->fullParams['zoom']->wasSetToDefault() && $locationAmount > 1) {
             $params['zoom'] = false;
         }
         $mapName = $this->service->getMapId();
         SMWOutputs::requireHeadItem($mapName, $this->service->getDependencyHtml() . ($configVars = Skin::makeVariablesScript($this->service->getConfigVariables())));
         foreach ($this->service->getResourceModules() as $resourceModule) {
             SMWOutputs::requireResource($resourceModule);
         }
         if (array_key_exists('source', $params)) {
             unset($params['source']);
         }
         return $this->getMapHTML($params, $wgParser, $mapName);
     } else {
         return $params['default'];
     }
 }
开发者ID:hangya,项目名称:SemanticMaps,代码行数:46,代码来源:SM_MapPrinter.php


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