/**
  * 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']));
 }
Esempio n. 2
0
 /**
  * @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);
 }
Esempio n. 3
0
 /**
  * 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);
 }
Esempio n. 4
0
 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);
 }
 /**
  * @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>";
 }
 /**
  * @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);
 }
Esempio n. 7
0
 /**
  * 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;
 }
 /**
  * @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);
 }
Esempio n. 9
0
 /**
  * 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)));
 }
Esempio n. 10
0
/**
 * 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 '';
    }
}
Esempio n. 11
0
 /**
  * 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;
 }
 /**
  * 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;
 }
Esempio n. 13
0
    /**
     * 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;
    }
Esempio n. 14
0
 /**
  * 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;
 }
Esempio n. 15
0
 /**
  * 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'];
     }
 }
	/**
	 * Includes the JavaScript required for the timeline and eventline formats.
	 * 
	 * @since 1.5.3
	 */
	protected function includeJS() {
		SMWOutputs::requireHeadItem( SMW_HEADER_STYLE );

		// MediaWiki 1.17 introduces the Resource Loader.
		$realFunction = array( 'SMWOutputs', 'requireResource' );
		if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) && is_callable( $realFunction ) ) {
			SMWOutputs::requireResource( 'ext.srf.timeline' );
		}
		else {
			global $srfgScriptPath;
			SMWOutputs::requireHeadItem(
				'smw_tlhelper',
				'<script type="text/javascript" src="' . $srfgScriptPath . 
					'/Timeline/SRF_timeline.js"></script>'
			);
			SMWOutputs::requireHeadItem(
				'smw_tl',
				'<script type="text/javascript" src="' . $srfgScriptPath . 
					'/Timeline/SimileTimeline/timeline-api.js"></script>'
			);			
		}		
	}
Esempio n. 17
0
 /**
  * Creates the query form in order to quickly switch to a specific article.
  *
  * @return A string containing the HTML for the form
  */
 private function queryForm()
 {
     SMWOutputs::requireResource('ext.smw.browse');
     $title = SpecialPage::getTitleFor('Browse');
     return '  <form name="smwbrowse" action="' . htmlspecialchars($title->getLocalURL()) . '" method="get">' . "\n" . '    <input type="hidden" name="title" value="' . $title->getPrefixedText() . '"/>' . wfMessage('smw_browse_article')->text() . "<br />\n" . '    <input type="text" name="article" id="page_input_box" value="' . htmlspecialchars($this->articletext) . '" />' . "\n" . '    <input type="submit" value="' . wfMessage('smw_browse_go')->text() . "\"/>\n" . "  </form>\n";
 }
 /**
  * Creates the HTML for the query form for this special page.
  *
  * @return string  HTML for the query form
  */
 private function queryForm()
 {
     SMWOutputs::requireResource('ext.smw.property');
     $spectitle = SpecialPage::getTitleFor('SearchByProperty');
     $html = '<form name="searchbyproperty" action="' . htmlspecialchars($spectitle->getLocalURL()) . '" method="get">' . "\n" . '<input type="hidden" name="title" value="' . $spectitle->getPrefixedText() . '"/>';
     $html .= wfMessage('smw_sbv_property')->text() . ' <input type="text" id="property_box" name="property" value="' . htmlspecialchars($this->propertystring) . '" />' . "&#160;&#160;&#160;\n";
     $html .= wfMessage('smw_sbv_value')->text() . ' <input type="text" name="value" value="' . htmlspecialchars($this->valuestring) . '" />' . "\n";
     $html .= '<input type="submit" value="' . wfMessage('smw_sbv_submit')->text() . "\"/>\n</form>\n";
     return $html;
 }
	/**
	 * Creates the JS needed for adding auto-completion to queryForm(). Uses the
	 * MW API to fetch suggestions.
	 */
	private static function addAutoComplete() {
		SMWOutputs::requireResource( 'jquery.ui.autocomplete' );

		$javascript_autocomplete_text = <<<END
<script type="text/javascript">
jQuery(document).ready(function(){
	jQuery("#page_input_box").autocomplete({
		minLength: 3,
		source: function(request, response) {
			jQuery.getJSON(wgScriptPath+'/api.php?action=opensearch&limit=10&namespace=0&format=jsonfm&search='+request.term, function(data){
				response(data[1]);
			});
		}
	});
});
</script>

END;

		SMWOutputs::requireScript( 'smwAutocompleteSpecialBrowse', $javascript_autocomplete_text );
	}
 /**
  * Special features for Type:Code formatting.
  */
 protected function getCodeDisplay($value, $scroll = false)
 {
     SMWOutputs::requireResource('ext.smw.style');
     $result = str_replace(array('<', '>', ' ', '[', '{', '=', "'", ':', "\n"), array('&lt;', '&gt;', '&#160;', '&#x005B;', '&#x007B;', '&#x003D;', '&#x0027;', '&#58;', "<br />"), $value);
     if ($scroll) {
         $result = "<div style=\"height:5em; overflow:auto;\">{$result}</div>";
     }
     return "<div class=\"smwpre\">{$result}</div>";
 }
 /**
  * Prepare bar/line chart specific data and parameters
  *
  * Data can be an array of y values, or an array of [label, value] pairs;
  * While labels are used only on the first series with labels on
  * subsequent series being ignored
  *
  *  @since 1.8
  *
  * @param array $rawdata label => value
  * @return array
  */
 private function prepareBarData($rawdata)
 {
     // Init
     $total = 0;
     $mode = 'single';
     // Find min and max values to determine the graphs axis parameter
     $maxValue = count($rawdata) == 0 ? 0 : max($rawdata);
     if ($this->params['min'] === false) {
         $minValue = count($rawdata) == 0 ? 0 : min($rawdata);
     } else {
         $minValue = $this->params['min'];
     }
     // Get number ticks
     $data['numbersticks'] = SRFjqPlot::getNumbersTicks($minValue, $maxValue);
     // Reorganize the data in accordance with the bar/line chart req.
     foreach ($rawdata as $key => $value) {
         if ($value >= $this->params['min']) {
             $data['series'][] = array($key, $value);
             $total = $total + $value;
         }
     }
     // Bar/line module
     SMWOutputs::requireResource('ext.srf.jqplot.bar');
     // Highlighter plugin
     if ($this->params['highlighter']) {
         SMWOutputs::requireResource('ext.srf.jqplot.highlighter');
     }
     // Pointlabels plugin
     if (in_array($this->params['datalabels'], array('value', 'label', 'percent'))) {
         SMWOutputs::requireResource('ext.srf.jqplot.pointlabels');
     }
     return array('data' => array($data['series']), 'ticks' => $data['numbersticks'], 'labels' => array_keys($data['series']), 'numbers' => array_values($data['series']), 'max' => $maxValue, 'total' => $total, 'mode' => $mode, 'series' => array(), 'renderer' => $this->params['charttype'], 'parameters' => $this->addCommonOptions());
 }
Esempio n. 22
0
 /**
  * Add resource definitions
  *
  * @since 1.8
  *
  * @param array $data
  *
  * @return string
  */
 protected function addResources()
 {
     // RL module
     switch ($this->params['charttype']) {
         case 'bubble':
             SMWOutputs::requireResource('ext.srf.jqplot.bubble');
             break;
         case 'donut':
             SMWOutputs::requireResource('ext.srf.jqplot.donut');
             break;
         case 'scatter':
         case 'line':
         case 'bar':
             SMWOutputs::requireResource('ext.srf.jqplot.bar');
             break;
     }
     // Trendline plugin
     if (in_array($this->params['trendline'], array('exp', 'linear'))) {
         SMWOutputs::requireResource('ext.srf.jqplot.trendline');
     }
     // Cursor plugin
     if (in_array($this->params['cursor'], array('zoom', 'tooltip'))) {
         SMWOutputs::requireResource('ext.srf.jqplot.cursor');
     }
     // Highlighter plugin
     if ($this->params['highlighter']) {
         SMWOutputs::requireResource('ext.srf.jqplot.highlighter');
     }
     // Enhancedlegend plugin
     if ($this->params['chartlegend']) {
         SMWOutputs::requireResource('ext.srf.jqplot.enhancedlegend');
     }
     // gridview plugin
     if (in_array($this->params['gridview'], array('tabs'))) {
         SMWOutputs::requireResource('ext.srf.util.grid');
     }
     // Pointlabels plugin
     if (in_array($this->params['datalabels'], array('value', 'label', 'percent'))) {
         SMWOutputs::requireResource('ext.srf.jqplot.pointlabels');
     }
 }
    /**
     * Create the search form.
     *
     * @return string HTML code for search form
     */
    protected function makeForm()
    {
        SMWOutputs::requireResource('jquery');
        $specTitle = $this->getTitle();
        $formatBox = $this->getFormatSelectBoxSep('broadtable');
        $result = '<div class="smwqcerrors">' . $this->getErrorsHtml() . '</div>';
        $formParameters = array('name' => 'qc', 'id' => 'smwqcform', 'action' => htmlspecialchars($specTitle->getLocalURL()), 'method' => 'get');
        $result .= Html::openElement('form', $formParameters) . "\n" . Html::hidden('title', $specTitle->getPrefixedText()) . wfMsg('smw_qc_query_help') . $this->getQueryFormBox() . '<div class="smwqcsortbox">' . $this->getPoSortFormBox() . '</div>';
        // Control to show/hide additional options:
        $result .= '<div class="smwqcformatas">' . Html::element('strong', array(), wfMsg('smw_ask_format_as')) . $formatBox[0] . '<span id="show_additional_options" style="display:inline;">' . '<a href="#addtional" rel="nofollow" onclick="' . "jQuery('#additional_options').show('blind');" . "document.getElementById('show_additional_options').style.display='none';" . "document.getElementById('hide_additional_options').style.display='inline';" . '">' . wfMsg('smw_qc_show_addnal_opts') . '</a></span>' . '<span id="hide_additional_options" style="display:none"><a href="#" rel="nofollow" onclick="' . "jQuery('#additional_options').hide('blind');;" . "document.getElementById('hide_additional_options').style.display='none';" . "document.getElementById('show_additional_options').style.display='inline';" . '">' . wfMsg('smw_qc_hide_addnal_opts') . '</a></span>' . '</div>';
        // Controls for additional options:
        $result .= '<div id="additional_options" style="display:none">' . $this->getOtherParametersBox() . '<fieldset><legend>' . wfMsg('smw_qc_formatopt') . "</legend>\n" . $formatBox[1] . "</fieldset>\n" . '</div>';
        // end of hidden additional options
        // Submit button and documentation link:
        $result .= '<br/><input type="submit" value="' . wfMsg('smw_ask_submit') . '"/><br/>' . '<a href="' . htmlspecialchars(wfMsg('smw_ask_doculink')) . '">' . wfMsg('smw_ask_help') . '</a>';
        // Control for showing #ask syntax of query:
        if ($this->uiCore->getQueryString() !== '') {
            // only show if query given
            $result .= ' | <a name="show-embed-code" id="show-embed-code" href="##" rel="nofollow">' . wfMsg('smw_ask_show_embed') . '</a>' . '<div id="embed-code-dialog">' . $this->getAskEmbedBox() . '</div>';
            SMWOutputs::requireResource('jquery.ui.autocomplete');
            SMWOutputs::requireResource('jquery.ui.dialog');
            SMWOutputs::requireResource('ext.smw.style');
            $javascriptText = <<<EOT
<script type="text/javascript">
\tjQuery( document ).ready( function(){
\t\tjQuery( '#embed-code-dialog' ).dialog( {
\t\t\tautoOpen:false,
\t\t\tmodal: true,
\t\t\tbuttons: {
\t\t\t\tOk: function(){
\t\t\t\t\tjQuery( this ).dialog( "close" );
\t\t\t\t}
\t\t\t}
\t\t} );
\t\tjQuery( '#show-embed-code' ).bind( 'click', function(){
\t\t\tjQuery( '#embed-code-dialog' ).dialog( "open" );
\t\t} );
\t} );
</script>
EOT;
            SMWOutputs::requireScript('smwToggleAskSyntaxQC', $javascriptText);
        }
        $result .= '<input type="hidden" name="eq" value="no"/>' . "\n</form><br/>";
        return $result;
    }
	/**
	 * 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 ) {
			global $wgParser;
			
			$params = $this->params;
			
			$queryHandler = new SMQueryHandler( $res, $outputmode );
			$queryHandler->setShowSubject( $params['showtitle'] );
			$queryHandler->setTemplate( $params['template'] );
			
			$this->handleMarkerData( $params, $queryHandler->getLocations() );
			$locationAmount = count( $params['locations'] );
			
			if ( $params['forceshow'] || $locationAmount > 0 ) {
				// We can only take care of the zoom defaulting here, 
				// as not all locations are available in whats passed to Validator.
				if ( $params['zoom'] === false && $locationAmount <= 1 ) {
					$params['zoom'] = $this->service->getDefaultZoom();
				}
				
				$mapName = $this->service->getMapId();
				
				// MediaWiki 1.17 does not play nice with addScript, so add the vars via the globals hook.
				if ( version_compare( $GLOBALS['wgVersion'], '1.18', '<' ) ) {
					$GLOBALS['egMapsGlobalJSVars'] += $this->service->getConfigVariables();
				}
				
				SMWOutputs::requireHeadItem(
					$mapName,
					$this->service->getDependencyHtml() . 
					$configVars = Skin::makeVariablesScript( $this->service->getConfigVariables() )
				);
				
				foreach ( $this->service->getResourceModules() as $resourceModule ) {
					SMWOutputs::requireResource( $resourceModule );
				}
				
				$result = $this->getMapHTML( $params, $wgParser, $mapName ) . $this->getJSON( $params, $wgParser, $mapName );
				
				return array(
					$result,
					'noparse' => true, 
					'isHTML' => true
				);				
			}
			else {
				return '';
			}
		}
		else {
			return $this->fatalErrorMsg;
		}
	}
    /**
     * Creates the JS needed for adding auto-completion to queryForm(). Uses the
     * MW API to fetch suggestions.
     *
     */
    protected static function addAutoComplete()
    {
        SMWOutputs::requireResource('jquery.ui.autocomplete');
        $javascript_autocomplete_text = <<<END
<script type="text/javascript">
jQuery(document).ready(function(){
\tjQuery("#property_box").autocomplete({
\t\tminLength: 2,
\t\tsource: function(request, response) {
\t\t\tjQuery.getJSON(wgScriptPath+'/api.php?action=opensearch&limit=10&namespace='+wgNamespaceIds['property']+'&format=jsonfm&search='+request.term, function(data){
\t\t\t\t//remove the word 'Property:' from returned data
\t\t\t\tfor(i=0;i<data[1].length;i++) data[1][i]=data[1][i].substr(data[1][i].indexOf(':')+1);
\t\t\t\tresponse(data[1]);
\t\t\t});
\t\t}
\t});
});
</script>

END;
        SMWOutputs::requireScript('smwAutocompleteSpecialSearchByProperty', $javascript_autocomplete_text);
    }
Esempio n. 26
0
 /**
  * This function creates wiki text suitable for rendering a Factbox for a given
  * SMWSemanticData object that holds all relevant data. It also checks whether the
  * given setting of $showfactbox requires displaying the given data at all.
  * 
  * @param SMWSemanticData $semdata
  * @param boolean $showfactbox
  * 
  * @return string
  */
 public static function getFactboxText(SMWSemanticData $semdata, $showfactbox = SMW_FACTBOX_NONEMPTY)
 {
     global $wgContLang;
     wfProfileIn('SMWFactbox::printFactbox (SMW)');
     switch ($showfactbox) {
         case SMW_FACTBOX_HIDDEN:
             // never show
             wfProfileOut('SMWFactbox::printFactbox (SMW)');
             return '';
         case SMW_FACTBOX_SPECIAL:
             // show only if there are special properties
             if (!$semdata->hasVisibleSpecialProperties()) {
                 wfProfileOut('SMWFactbox::printFactbox (SMW)');
                 return '';
             }
             break;
         case SMW_FACTBOX_NONEMPTY:
             // show only if non-empty
             if (!$semdata->hasVisibleProperties()) {
                 wfProfileOut('SMWFactbox::printFactbox (SMW)');
                 return '';
             }
             break;
             // case SMW_FACTBOX_SHOWN: // just show ...
     }
     // actually build the Factbox text:
     $text = '';
     if (wfRunHooks('smwShowFactbox', array(&$text, $semdata))) {
         $subjectDv = SMWDataValueFactory::newDataItemValue($semdata->getSubject(), null);
         SMWOutputs::requireResource('ext.smw.style');
         $rdflink = SMWInfolink::newInternalLink(wfMessage('smw_viewasrdf')->inContentLanguage()->text(), $wgContLang->getNsText(NS_SPECIAL) . ':ExportRDF/' . $subjectDv->getWikiValue(), 'rdflink');
         $browselink = SMWInfolink::newBrowsingLink($subjectDv->getText(), $subjectDv->getWikiValue(), 'swmfactboxheadbrowse');
         $text .= '<div class="smwfact">' . '<span class="smwfactboxhead">' . wfMessage('smw_factbox_head', $browselink->getWikiText())->inContentLanguage()->text() . '</span>' . '<span class="smwrdflink">' . $rdflink->getWikiText() . '</span>' . '<table class="smwfacttable">' . "\n";
         foreach ($semdata->getProperties() as $propertyDi) {
             $propertyDv = SMWDataValueFactory::newDataItemValue($propertyDi, null);
             if (!$propertyDi->isShown()) {
                 // showing this is not desired, hide
                 continue;
             } elseif ($propertyDi->isUserDefined()) {
                 // user defined property
                 $propertyDv->setCaption(preg_replace('/[ ]/u', '&#160;', $propertyDv->getWikiValue(), 2));
                 /// NOTE: the preg_replace is a slight hack to ensure that the left column does not get too narrow
                 $text .= '<tr><td class="smwpropname">' . $propertyDv->getShortWikiText(true) . '</td><td class="smwprops">';
             } elseif ($propertyDv->isVisible()) {
                 // predefined property
                 $text .= '<tr><td class="smwspecname">' . $propertyDv->getShortWikiText(true) . '</td><td class="smwspecs">';
             } else {
                 // predefined, internal property
                 continue;
             }
             $propvalues = $semdata->getPropertyValues($propertyDi);
             $valuesHtml = array();
             foreach ($propvalues as $dataItem) {
                 $dataValue = SMWDataValueFactory::newDataItemValue($dataItem, $propertyDi);
                 if ($dataValue->isValid()) {
                     $valuesHtml[] = $dataValue->getLongWikiText(true) . $dataValue->getInfolinkText(SMW_OUTPUT_WIKI);
                 }
             }
             $text .= $GLOBALS['wgLang']->listToText($valuesHtml);
             $text .= '</td></tr>';
         }
         $text .= '</table></div>';
     }
     wfProfileOut('SMWFactbox::printFactbox (SMW)');
     return $text;
 }
Esempio n. 27
0
 /**
  * Prepare data for the output
  *
  * @since 1.8
  *
  * @param array $data
  * @param array $options
  *
  * @return string
  */
 protected function getFormatOutput($data, $options)
 {
     // The generated ID is to distinguish similar instances of the same
     // printer that can appear within the same page
     static $statNr = 0;
     $ID = 'srf-boilerplate-' . ++$statNr;
     // or use the PHP uniqid() to generate an unambiguous ID
     // $ID = uniqid();
     // Used to set that the output and being treated as HTML (opposed to plain wiki text)
     $this->isHTML = true;
     // Correct escaping is vital to minimize possibilites of malicious code snippets
     // and also a coherent string evalution therefore it is recommended
     // that data transferred to the JS plugin is JSON encoded
     // Assign the ID to make a data instance readly available and distinguishable
     // from other content within the same page
     $requireHeadItem = array($ID => FormatJson::encode($data));
     SMWOutputs::requireHeadItem($ID, Skin::makeVariablesScript($requireHeadItem));
     // Add resource definitions that has been registered with SRF_Resource.php
     // Resource definitions contain scripts, styles, messages etc.
     // SMWOutputs::requireResource( 'ext.srf.boilerplate.namespace' );
     SMWOutputs::requireResource('ext.srf.boilerplate.simple');
     // Prepares an HTML element showing a rotating spinner indicating that something
     // will appear at this placeholder. The element will be visible as for as
     // long as jquery is not loaded and the JS plugin did not hide/removed the element.
     $processing = SRFUtils::htmlProcessingElement();
     // Add two elements a outer wrapper that is assigned a class which the JS plugin
     // can select and will fetch all instances of the same result printer and an innner
     // container which is set invisible (display=none) for as long as the JS plugin
     // holds the content hidden. It is normally the place where the "hard work"
     // is done hidden from the user until it is ready.
     // The JS plugin can prepare the output within this container without presenting
     // unfinished visual content, to avoid screen clutter and improve user experience.
     return Html::rawElement('div', array('class' => 'srf-boilerplate'), $processing . Html::element('div', array('id' => $ID, 'class' => 'container', 'style' => 'display:none;'), null));
 }
Esempio n. 28
0
 /**
  * Create special highlighting for hinting at special properties.
  */
 protected function highlightText($text)
 {
     if ($this->m_dataitem->isUserDefined()) {
         return $text;
     } else {
         SMWOutputs::requireResource('ext.smw.style');
         return smwfContextHighlighter(array('context' => 'inline', 'class' => 'smwbuiltin', 'type' => 'property', 'title' => $text, 'content' => wfMessage('smw_isspecprop')->inContentLanguage()->text()));
     }
 }
Esempio n. 29
0
/**
 * Provide a consistent interface for context hightlighting.
 *
 * Escaping should be dealt with before calling this function to ensure proper
 * handling of html encoded strings
 *
 * @var options
 * context = described as either inline or persitent
 * title   = a text or null
 * class   = assigned class which will control if an icon is displayed or not
 * type    = identifies the entity type
 * content = ...
 *
 * @since 1.8
 *
 * @param array options
 *
 * @return string
 */
function smwfContextHighlighter(array $options)
{
    // Load RL module
    SMWOutputs::requireResource('ext.smw.tooltips');
    // Tooltip
    return Html::rawElement('span', array('class' => $options['context'] === 'inline' ? 'smwttinline' : 'smwttpersist', 'data-type' => $options['type'], 'data-context' => $options['context']), Html::rawElement('span', array('class' => $options['class']), $options['title']) . Html::rawElement('span', array('class' => 'smwttcontent'), $options['content']));
}
Esempio n. 30
0
 /**
  * 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.
  *
  * @param string $value
  * @param boolean $abbreviate should the code box be limited vertically?
  * @return string
  */
 protected function getCodeDisplay($value, $abbreviate)
 {
     SMWOutputs::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 />"), $value);
     if ($abbreviate) {
         $result = "<div style=\"height:5em; overflow:auto;\">{$result}</div>";
     }
     return "<div class=\"smwpre\">{$result}</div>";
 }