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


PHP SMWOutputs::requireScript方法代码示例

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


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

    /**
     * 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);
    }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:27,代码来源:SMW_SpecialSearchByProperty.php

示例3: addAutoComplete

	/**
	 * 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 );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:25,代码来源:SMW_SpecialBrowse.php

示例4: 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

示例5: makeForm

    /**
     * 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;
    }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:50,代码来源:SMW_SpecialQueryCreator.php

示例6: 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

示例7: setStartMenu

	/**
	 * Creates the JS needed for 
	 */
	private static function setStartMenu(){
		SMWOutputs::requireResource( 'jquery.ui.autocomplete' );

		$javascript_autocomplete_text = <<<END
<script type="text/javascript">
jQuery(document).ready(function(){
	var xxx="hallo";
	echo "xxx=".xxx;
	druck = window.open ('', 'fenster', xxx);
	druck.print();
	
});
</script>

END;

		SMWOutputs::requireScript( 'smwAutocompleteSpecialBrowse', $javascript_autocomplete_text );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:21,代码来源:SWB_SpecialBrowseWiki.php

示例8: 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 = explode(',', $filter);
             $filtersForPrintout = array_map('trim', $filtersForPrintout);
             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 = '';
     $viewHandlers = array();
     $viewElements = array();
     foreach ($this->mViews as $viewName) {
         if (array_key_exists($viewName, $this->mViewTypes)) {
             // generate unique id
             $viewid = uniqid();
             $view = new $this->mViewTypes[$viewName]($viewid, $result, $this->mParams, $this);
             $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-{$viewName} {$viewid}"), $view->getResultText());
             $viewHandlers[$viewName] = null;
             $viewElements[$viewName][] = $viewid;
         }
     }
     // wrap views in a div
     $viewHtml = Html::rawElement('div', array('class' => 'filtered-views'), $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) . ', "filterhandlers" : ' . json_encode($filterHandlers) . ', "filterdata" : ' . json_encode($filterData) . '}};'));
     SMWOutputs::requireResource('ext.srf.filtered');
     // wrap all in a div
     $html = Html::rawElement('div', array('class' => 'filtered ' . $id), $filterHtml . $viewHtml);
     return $html;
 }
开发者ID:rduecyg,项目名称:OU,代码行数:74,代码来源:SRF_Filtered.php


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