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


PHP SFUtils类代码示例

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


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

示例1: getHTML

 public static function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args)
 {
     global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect;
     $checkbox_class = $is_mandatory ? 'mandatoryField' : 'createboxInput';
     $span_class = 'checkboxSpan';
     if (array_key_exists('class', $other_args)) {
         $span_class .= ' ' . $other_args['class'];
     }
     $input_id = "input_{$sfgFieldNum}";
     // get list delimiter - default is comma
     if (array_key_exists('delimiter', $other_args)) {
         $delimiter = $other_args['delimiter'];
     } else {
         $delimiter = ',';
     }
     $cur_values = SFUtils::getValuesArray($cur_value, $delimiter);
     if (($possible_values = $other_args['possible_values']) == null) {
         $possible_values = array();
     }
     $text = '';
     foreach ($possible_values as $key => $possible_value) {
         $cur_input_name = $input_name . '[' . $key . ']';
         if (array_key_exists('value_labels', $other_args) && is_array($other_args['value_labels']) && array_key_exists($possible_value, $other_args['value_labels'])) {
             $label = $other_args['value_labels'][$possible_value];
         } else {
             $label = $possible_value;
         }
         $checkbox_attrs = array('id' => $input_id, 'tabindex' => $sfgTabIndex, 'class' => $checkbox_class);
         if (in_array($possible_value, $cur_values)) {
             $checkbox_attrs['checked'] = 'checked';
         }
         if ($is_disabled) {
             $checkbox_attrs['disabled'] = 'disabled';
         }
         $checkbox_input = Html::input($cur_input_name, $possible_value, 'checkbox', $checkbox_attrs);
         // Make a span around each checkbox, for CSS purposes.
         $text .= "\t" . Html::rawElement('span', array('class' => $span_class), $checkbox_input . ' ' . $label) . "\n";
         $sfgTabIndex++;
         $sfgFieldNum++;
     }
     $outerSpanID = "span_{$sfgFieldNum}";
     $outerSpanClass = 'checkboxesSpan';
     if ($is_mandatory) {
         $outerSpanClass .= ' mandatoryFieldSpan';
     }
     if (array_key_exists('show on select', $other_args)) {
         $outerSpanClass .= ' sfShowIfChecked';
         foreach ($other_args['show on select'] as $div_id => $options) {
             if (array_key_exists($outerSpanID, $sfgShowOnSelect)) {
                 $sfgShowOnSelect[$outerSpanID][] = array($options, $div_id);
             } else {
                 $sfgShowOnSelect[$outerSpanID] = array(array($options, $div_id));
             }
         }
     }
     $text .= Html::hidden($input_name . '[is_list]', 1);
     $outerSpanAttrs = array('id' => $outerSpanID, 'class' => $outerSpanClass);
     $text = "\t" . Html::rawElement('span', $outerSpanAttrs, $text) . "\n";
     return $text;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:60,代码来源:SF_CheckboxesInput.php

示例2: uploadableHTML

 public static function uploadableHTML($input_id, $delimiter = null, $default_filename = null, $cur_value = '', $other_args = array())
 {
     $upload_window_page = SFUtils::getSpecialPage('UploadWindow');
     $query_string = "sfInputID={$input_id}";
     if ($delimiter != null) {
         $query_string .= "&sfDelimiter={$delimiter}";
     }
     if ($default_filename != null) {
         $query_string .= "&wpDestFile={$default_filename}";
     }
     $upload_window_url = $upload_window_page->getTitle()->getFullURL($query_string);
     $upload_label = wfMsg('upload');
     // We need to set the size by default.
     $style = "width:650 height:500";
     $cssClasses = array('sfFancyBox', 'sfUploadable');
     $showPreview = array_key_exists('image preview', $other_args);
     if ($showPreview) {
         $cssClasses[] = 'sfImagePreview';
     }
     $linkAttrs = array('href' => $upload_window_url, 'class' => implode(' ', $cssClasses), 'title' => $upload_label, 'rev' => $style, 'data-input-id' => $input_id);
     $text = "\t" . Html::element('a', $linkAttrs, $upload_label) . "\n";
     if ($showPreview) {
         $text .= Html::rawElement('div', array('id' => $input_id . '_imagepreview', 'class' => 'sfImagePreviewWrapper'), self::getPreviewImage($cur_value));
     }
     return $text;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:26,代码来源:SF_TextInput.php

示例3: setTypeAndPossibleValues

 function setTypeAndPossibleValues()
 {
     $proptitle = Title::makeTitleSafe(SMW_NS_PROPERTY, $this->mSemanticProperty);
     if ($proptitle === null) {
         return;
     }
     $store = smwfGetStore();
     // this returns an array of objects
     $allowed_values = SFUtils::getSMWPropertyValues($store, $proptitle, "Allows value");
     $label_formats = SFUtils::getSMWPropertyValues($store, $proptitle, "Has field label format");
     $propValue = SMWDIProperty::newFromUserLabel($this->mSemanticProperty);
     $this->mPropertyType = $propValue->findPropertyTypeID();
     foreach ($allowed_values as $allowed_value) {
         // HTML-unencode each value
         $this->mPossibleValues[] = html_entity_decode($allowed_value);
         if (count($label_formats) > 0) {
             $label_format = $label_formats[0];
             $prop_instance = SMWDataValueFactory::findTypeID($this->mPropertyType);
             $label_value = SMWDataValueFactory::newTypeIDValue($prop_instance, $wiki_value);
             $label_value->setOutputFormat($label_format);
             $this->mValueLabels[$wiki_value] = html_entity_decode($label_value->getWikiValue());
         }
     }
     // HACK - if there were any possible values, set the property
     // type to be 'enumeration', regardless of what the actual type is
     if (count($this->mPossibleValues) > 0) {
         $this->mPropertyType = 'enumeration';
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:29,代码来源:SF_TemplateField.php

示例4: setTypeAndPossibleValues

 function setTypeAndPossibleValues()
 {
     // The presence of "-" at the beginning of a property name
     // (which happens if SF tries to parse an inverse query)
     // leads to an error in SMW - just exit if that's the case.
     if (strpos($this->mSemanticProperty, '-') === 0) {
         return;
     }
     $proptitle = Title::makeTitleSafe(SMW_NS_PROPERTY, $this->mSemanticProperty);
     if ($proptitle === null) {
         return;
     }
     $store = SFUtils::getSMWStore();
     // this returns an array of objects
     $allowed_values = SFUtils::getSMWPropertyValues($store, $proptitle, "Allows value");
     $label_formats = SFUtils::getSMWPropertyValues($store, $proptitle, "Has field label format");
     $propValue = SMWDIProperty::newFromUserLabel($this->mSemanticProperty);
     $this->mPropertyType = $propValue->findPropertyTypeID();
     foreach ($allowed_values as $allowed_value) {
         // HTML-unencode each value
         $this->mPossibleValues[] = html_entity_decode($allowed_value);
         if (count($label_formats) > 0) {
             $label_format = $label_formats[0];
             $prop_instance = SMWDataValueFactory::findTypeID($this->mPropertyType);
             $label_value = SMWDataValueFactory::newTypeIDValue($prop_instance, $wiki_value);
             $label_value->setOutputFormat($label_format);
             $this->mValueLabels[$wiki_value] = html_entity_decode($label_value->getWikiValue());
         }
     }
     // HACK - if there were any possible values, set the property
     // type to be 'enumeration', regardless of what the actual type is
     if (count($this->mPossibleValues) > 0) {
         $this->mPropertyType = 'enumeration';
     }
 }
开发者ID:roland2025,项目名称:mediawiki-extensions-SemanticForms,代码行数:35,代码来源:SF_TemplateField.php

示例5: getPageHeader

 function getPageHeader()
 {
     global $wgUser;
     $sk = $wgUser->getSkin();
     $create_form_link = SFUtils::linkForSpecialPage($sk, 'CreateForm');
     $header = "<p>" . $create_form_link . ".</p>\n";
     $header .= '<p>' . wfMsg('sf_forms_docu') . "</p><br />\n";
     return $header;
 }
开发者ID:yusufchang,项目名称:app,代码行数:9,代码来源:SF_Forms.php

示例6: createMarkup

    function createMarkup()
    {
        $title = Title::makeTitle(SF_NS_FORM, $this->mFormName);
        $fs = SFUtils::getSpecialPage('FormStart');
        $form_start_url = SFUtils::titleURLString($fs->getTitle()) . "/" . $title->getPartialURL();
        $form_description = wfMsgForContent('sf_form_docu', $this->mFormName, $form_start_url);
        $form_input = "{{#forminput:form=" . $this->mFormName;
        if (!is_null($this->mAssociatedCategory)) {
            $form_input .= "|autocomplete on category=" . $this->mAssociatedCategory;
        }
        $form_input .= "}}\n";
        $text = <<<END
<noinclude>
{$form_description}


{$form_input}
</noinclude><includeonly>

END;
        if (!empty($this->mPageNameFormula) || !empty($this->mCreateTitle) || !empty($this->mEditTitle)) {
            $text .= "{{{info";
            if (!empty($this->mPageNameFormula)) {
                $text .= "|page name=" . $this->mPageNameFormula;
            }
            if (!empty($this->mCreateTitle)) {
                $text .= "|create title=" . $this->mCreateTitle;
            }
            if (!empty($this->mEditTitle)) {
                $text .= "|edit title=" . $this->mEditTitle;
            }
            $text .= "}}}\n";
        }
        $text .= <<<END
<div id="wikiPreview" style="display: none; padding-bottom: 25px; margin-bottom: 25px; border-bottom: 1px solid #AAAAAA;"></div>

END;
        foreach ($this->mTemplates as $template) {
            $text .= $template->createMarkup() . "\n";
        }
        $free_text_label = wfMsgForContent('sf_form_freetextlabel');
        $text .= <<<END
'''{$free_text_label}:'''

{{{standard input|free text|rows=10}}}


{{{standard input|summary}}}

{{{standard input|minor edit}}} {{{standard input|watch}}}

{{{standard input|save}}} {{{standard input|preview}}} {{{standard input|changes}}} {{{standard input|cancel}}}
</includeonly>

END;
        return $text;
    }
开发者ID:yusufchang,项目名称:app,代码行数:57,代码来源:SF_Form.php

示例7: getHtmlText

 /**
  * Returns the HTML code to be included in the output page for this input.
  */
 public function getHtmlText()
 {
     global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect;
     $className = $this->mIsMandatory ? 'mandatoryField' : 'createboxInput';
     if (array_key_exists('class', $this->mOtherArgs)) {
         $className .= ' ' . $this->mOtherArgs['class'];
     }
     $input_id = "input_{$sfgFieldNum}";
     // get list delimiter - default is comma
     if (array_key_exists('delimiter', $this->mOtherArgs)) {
         $delimiter = $this->mOtherArgs['delimiter'];
     } else {
         $delimiter = ',';
     }
     $cur_values = SFUtils::getValuesArray($this->mCurrentValue, $delimiter);
     $className .= ' sfShowIfSelected';
     if (($possible_values = $this->mOtherArgs['possible_values']) == null) {
         $possible_values = array();
     }
     $optionsText = '';
     foreach ($possible_values as $possible_value) {
         if (array_key_exists('value_labels', $this->mOtherArgs) && is_array($this->mOtherArgs['value_labels']) && array_key_exists($possible_value, $this->mOtherArgs['value_labels'])) {
             $optionLabel = $this->mOtherArgs['value_labels'][$possible_value];
         } else {
             $optionLabel = $possible_value;
         }
         $optionAttrs = array('value' => $possible_value);
         if (in_array($possible_value, $cur_values)) {
             $optionAttrs['selected'] = 'selected';
         }
         $optionsText .= Html::element('option', $optionAttrs, $optionLabel);
     }
     $selectAttrs = array('id' => $input_id, 'tabindex' => $sfgTabIndex, 'name' => $this->mInputName . '[]', 'class' => $className, 'multiple' => 'multiple');
     if (array_key_exists('size', $this->mOtherArgs)) {
         $selectAttrs['size'] = $this->mOtherArgs['size'];
     }
     if ($this->mIsDisabled) {
         $selectAttrs['disabled'] = 'disabled';
     }
     $text = Html::rawElement('select', $selectAttrs, $optionsText);
     $text .= Html::hidden($this->mInputName . '[is_list]', 1);
     if ($this->mIsMandatory) {
         $text = Html::rawElement('span', array('class' => 'inputSpan mandatoryFieldSpan'), $text);
     }
     if (array_key_exists('show on select', $this->mOtherArgs)) {
         foreach ($this->mOtherArgs['show on select'] as $div_id => $options) {
             if (array_key_exists($input_id, $sfgShowOnSelect)) {
                 $sfgShowOnSelect[$input_id][] = array($options, $div_id);
             } else {
                 $sfgShowOnSelect[$input_id] = array(array($options, $div_id));
             }
         }
     }
     return $text;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:58,代码来源:SF_ListBoxInput.php

示例8: getHTML

 public static function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args)
 {
     // For backward compatibility with pre-SF-2.1 forms
     if (array_key_exists('no autocomplete', $other_args) && $other_args['no autocomplete'] == true) {
         unset($other_args['autocompletion source']);
         return SFTextInput::getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args);
     }
     global $sfgTabIndex, $sfgFieldNum;
     $className = 'sfComboBox';
     if ($is_mandatory) {
         $className .= ' mandatoryField';
     }
     if (array_key_exists('class', $other_args)) {
         $className .= ' ' . $other_args['class'];
     }
     if (array_key_exists('size', $other_args)) {
         $size = $other_args['size'];
     } else {
         $size = '35';
     }
     // There's no direct correspondence between the 'size='
     // attribute for text inputs and the number of pixels, but
     // multiplying by 6 seems to be about right for the major
     // browsers.
     $pixel_width = $size * 6 . 'px';
     list($autocompleteFieldType, $autocompletionSource) = SFTextWithAutocompleteInput::getAutocompletionTypeAndSource($other_args);
     // @TODO - that count() check shouldn't be necessary
     if (array_key_exists('possible_values', $other_args) && count($other_args['possible_values']) > 0) {
         $values = $other_args['possible_values'];
     } elseif ($autocompleteFieldType == 'values') {
         $values = explode(',', $other_args['values']);
     } else {
         $values = SFUtils::getAutocompleteValues($autocompletionSource, $autocompleteFieldType);
     }
     $autocompletionSource = str_replace("'", "\\'", $autocompletionSource);
     $optionsText = Html::element('option', array('value' => $cur_value), null, false) . "\n";
     foreach ($values as $value) {
         $optionsText .= Html::element('option', array('value' => $value), $value) . "\n";
     }
     $selectAttrs = array('id' => "input_{$sfgFieldNum}", 'name' => $input_name, 'class' => $className, 'tabindex' => $sfgTabIndex, 'autocompletesettings' => $autocompletionSource, 'comboboxwidth' => $pixel_width);
     if (array_key_exists('origName', $other_args)) {
         $selectAttrs['origname'] = $other_args['origName'];
     }
     if (array_key_exists('existing values only', $other_args)) {
         $selectAttrs['existingvaluesonly'] = 'true';
     }
     $selectText = Html::rawElement('select', $selectAttrs, $optionsText);
     $divClass = 'ui-widget';
     if ($is_mandatory) {
         $divClass .= ' mandatory';
     }
     $text = Html::rawElement('div', array('class' => $divClass), $selectText);
     return $text;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:54,代码来源:SF_ComboBoxInput.php

示例9: showContentForm

 protected function showContentForm()
 {
     $target_title = $this->mArticle->getTitle();
     $target_name = SFUtils::titleString($target_title);
     if ($target_title->exists()) {
         SFEditData::printEditForm($this->form_name, $target_name, $this->textbox1);
     } else {
         SFAddData::printAddForm($this->form_name, $target_name, array(), $this->textbox1);
     }
     // @todo This needs a proper form builder
 }
开发者ID:roland2025,项目名称:mediawiki-extensions-SemanticForms,代码行数:11,代码来源:SF_FormEditPage.php

示例10: execute

	public function execute() {
		$params = $this->extractRequestParams();
		$substr = $params['substr'];
		$namespace = $params['namespace'];
		$property = $params['property'];
		$category = $params['category'];
		$concept = $params['concept'];
		$external_url = $params['external_url'];
		$baseprop = $params['baseprop'];
		$basevalue = $params['basevalue'];
		//$limit = $params['limit'];

		if ( is_null( $baseprop ) && strlen( $substr ) == 0 ) {
			$this->dieUsage( 'The substring must be specified', 'param_substr' );
		}

		if ( !is_null( $baseprop ) ) {
			if ( !is_null( $property ) ) {
				$data = self::getAllValuesForProperty( $property, null, $baseprop, $basevalue );
			}
		} elseif ( !is_null( $property ) ) {
			$data = self::getAllValuesForProperty( $property, $substr );
		} elseif ( !is_null( $category ) ) {
			$data = SFUtils::getAllPagesForCategory( $category, 3, $substr );
		} elseif ( !is_null( $concept ) ) {
			$data = SFUtils::getAllPagesForConcept( $concept, $substr );
		} elseif ( !is_null( $namespace ) ) {
			$data = SFUtils::getAllPagesForNamespace( $namespace, $substr );
		} elseif ( !is_null( $external_url ) ) {
			$data = SFUtils::getValuesFromExternalURL( $external_url, $substr );
		} else {
			$data = array();
		}

		// to prevent JS parsing problems, display should be the same
		// even if there are no results
		/*
		if ( count( $data ) <= 0 ) {
			return;
		}
		 */

		// Format data as the API requires it.
		$formattedData = array();
		foreach ( $data as $value ) {
			$formattedData[] = array( 'title' => $value );
		}

		// Set top-level elements.
		$result = $this->getResult();
		$result->setIndexedTagName( $formattedData, 'p' );
		$result->addValue( null, $this->getModuleName(), $formattedData );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:53,代码来源:SF_AutocompleteAPI.php

示例11: formlink

 /**
  * @param Parser $parser
  * @return mixed
  */
 public static function formlink($parser)
 {
     $params = func_get_args();
     array_shift($params);
     // We don't need the parser.
     $original = SFUtils::createFormLink($parser, $params, 'formlink');
     if (strpos($original, 'class="new"') !== false) {
         $original = str_replace('class="new"', 'class="btn btn-primary pull-right"', $original);
     } else {
         $original = str_replace('href=', 'class="btn btn-primary pull-right" href=', $original);
     }
     $original = str_replace('self">', 'self"><i class="fa fa-edit"></i> ', $original);
     return $parser->insertStripItem($original);
 }
开发者ID:vedmaka,项目名称:SettleInSkin,代码行数:18,代码来源:stools.class.php

示例12: setupSkinUserCss

 /**
  * Loads skin and user CSS files.
  * @param OutputPage $out
  */
 function setupSkinUserCss(OutputPage $out)
 {
     parent::setupSkinUserCss($out);
     $title = $out->getTitle();
     $isCard = false;
     if ($title && $title->exists()) {
         $categoris = SFUtils::getCategoriesForPage($title);
         if (in_array('Card', $categoris)) {
             if (!$out->getRequest()->getVal('action') || $out->getRequest()->getVal('action') == 'view') {
                 $isCard = true;
             }
         }
     }
     if ($title && $title->exists() && $title->getNamespace() == NS_MAIN) {
         if ($title->getArticleID() === Title::newMainPage()->getArticleID()) {
             $styles = array('skins.settlein.styles');
         } else {
             if ($isCard) {
                 $styles = array('skins.settlein.page.styles');
             } else {
                 $styles = array('skins.settlein.styles');
             }
         }
     } else {
         if ($isCard) {
             $styles = array('skins.settlein.page.styles');
         } else {
             $styles = array('skins.settlein.styles');
         }
     }
     if ($out->getRequest()->getVal('color')) {
         global $wgServer, $wgScriptPath;
         $color = htmlspecialchars($out->getRequest()->getVal('color'));
         $out->addStyle($wgServer . $wgScriptPath . '/skins/SettleIn/assets/colors/' . $color . '.css');
     }
     if ($out->getRequest()->getVal('beta_font')) {
         global $wgServer, $wgScriptPath;
         $font = htmlspecialchars($out->getRequest()->getVal('beta_font'));
         $out->addStyle($wgServer . $wgScriptPath . '/skins/SettleIn/assets/fonts/' . $font . '.css');
     }
     if ($this->getUser() && $this->getUser()->isLoggedIn()) {
         $out->addModuleStyles('ext.settlegeoforminput.foo');
     }
     $out->addModuleStyles($styles);
 }
开发者ID:vedmaka,项目名称:SettleInSkin,代码行数:49,代码来源:SkinSettleIn.php

示例13: renderSeriesLink

 /**
  * Renders the #serieslink parser function.
  * 
  * @param Parser $parser
  * @return string the unique tag which must be inserted into the stripped text 
  */
 public static function renderSeriesLink(&$parser)
 {
     global $wgTitle;
     $params = func_get_args();
     array_shift($params);
     // We don't need the parser.
     // remove the target parameter should it be present
     foreach ($params as $key => $value) {
         $elements = explode('=', $value, 2);
         if ($elements[0] === 'target') {
             unset($params[$key]);
         }
     }
     // set the origin parameter
     // This will block it from use as iterator parameter. Oh well.
     $params[] = "origin=" . $parser->getTitle()->getArticleId();
     // hack to remove newline from beginning of output, thanks to
     // http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Parser_Function
     return $parser->insertStripItem(SFUtils::createFormLink($parser, 'SeriesEdit', $params), $parser->mStripState);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:26,代码来源:SPSUtils.php

示例14: getAllValuesForProperty

 private static function getAllValuesForProperty($property_name, $substring, $basePropertyName = null, $baseValue = null)
 {
     global $sfgMaxAutocompleteValues, $sfgCacheAutocompleteValues, $sfgAutocompleteCacheTimeout;
     global $smwgDefaultStore;
     $values = array();
     $db = wfGetDB(DB_SLAVE);
     $sqlOptions = array();
     $sqlOptions['LIMIT'] = $sfgMaxAutocompleteValues;
     $property = SMWPropertyValue::makeUserProperty($property_name);
     $propertyHasTypePage = $property->getPropertyTypeID() == '_wpg';
     $property_name = str_replace(' ', '_', $property_name);
     $conditions = array('p_ids.smw_title' => $property_name);
     // Use cache if allowed
     if ($sfgCacheAutocompleteValues) {
         $cache = SFFormUtils::getFormCache();
         // Remove trailing whitespace to avoid unnecessary database selects
         $cacheKeyString = $property_name . '::' . rtrim($substring);
         if (!is_null($basePropertyName)) {
             $cacheKeyString .= ',' . $basePropertyName . ',' . $baseValue;
         }
         $cacheKey = wfMemcKey('sf-autocomplete', md5($cacheKeyString));
         $values = $cache->get($cacheKey);
         if (!empty($values)) {
             // Return with results immediately
             return $values;
         }
     }
     if ($propertyHasTypePage) {
         $valueField = 'o_ids.smw_title';
         if ($smwgDefaultStore === 'SMWSQLStore3') {
             $idsTable = $db->tableName('smw_object_ids');
             $propsTable = $db->tableName('smw_di_wikipage');
         } else {
             $idsTable = $db->tableName('smw_ids');
             $propsTable = $db->tableName('smw_rels2');
         }
         $fromClause = "{$propsTable} p JOIN {$idsTable} p_ids ON p.p_id = p_ids.smw_id JOIN {$idsTable} o_ids ON p.o_id = o_ids.smw_id";
     } else {
         if ($smwgDefaultStore === 'SMWSQLStore3') {
             $valueField = 'p.o_hash';
             $idsTable = $db->tableName('smw_object_ids');
             $propsTable = $db->tableName('smw_di_blob');
         } else {
             $valueField = 'p.value_xsd';
             $idsTable = $db->tableName('smw_ids');
             $propsTable = $db->tableName('smw_atts2');
         }
         $fromClause = "{$propsTable} p JOIN {$idsTable} p_ids ON p.p_id = p_ids.smw_id";
     }
     if (!is_null($basePropertyName)) {
         $baseProperty = SMWPropertyValue::makeUserProperty($basePropertyName);
         $basePropertyHasTypePage = $baseProperty->getPropertyTypeID() == '_wpg';
         $basePropertyName = str_replace(' ', '_', $basePropertyName);
         $conditions['base_p_ids.smw_title'] = $basePropertyName;
         if ($basePropertyHasTypePage) {
             if ($smwgDefaultStore === 'SMWSQLStore3') {
                 $idsTable = $db->tableName('smw_object_ids');
                 $propsTable = $db->tableName('smw_di_wikipage');
             } else {
                 $idsTable = $db->tableName('smw_ids');
                 $propsTable = $db->tableName('smw_rels2');
             }
             $fromClause .= " JOIN {$propsTable} p_base ON p.s_id = p_base.s_id";
             $fromClause .= " JOIN {$idsTable} base_p_ids ON p_base.p_id = base_p_ids.smw_id JOIN {$idsTable} base_o_ids ON p_base.o_id = base_o_ids.smw_id";
             $baseValue = str_replace(' ', '_', $baseValue);
             $conditions['base_o_ids.smw_title'] = $baseValue;
         } else {
             if ($smwgDefaultStore === 'SMWSQLStore3') {
                 $baseValueField = 'p_base.o_hash';
                 $idsTable = $db->tableName('smw_object_ids');
                 $propsTable = $db->tableName('smw_di_blob');
             } else {
                 $baseValueField = 'p_base.value_xsd';
                 $idsTable = $db->tableName('smw_ids');
                 $propsTable = $db->tableName('smw_atts2');
             }
             $fromClause .= " JOIN {$propsTable} p_base ON p.s_id = p_base.s_id";
             $fromClause .= " JOIN {$idsTable} base_p_ids ON p_base.p_id = base_p_ids.smw_id";
             $conditions[$baseValueField] = $baseValue;
         }
     }
     if (!is_null($substring)) {
         // "Page" type property valeus are stored differently
         // in the DB, i.e. underlines instead of spaces.
         $conditions[] = SFUtils::getSQLConditionForAutocompleteInColumn($valueField, $substring, $propertyHasTypePage);
     }
     $sqlOptions['ORDER BY'] = $valueField;
     $res = $db->select($fromClause, "DISTINCT {$valueField}", $conditions, __METHOD__, $sqlOptions);
     while ($row = $db->fetchRow($res)) {
         $values[] = str_replace('_', ' ', $row[0]);
     }
     $db->freeResult($res);
     if ($sfgCacheAutocompleteValues) {
         // Save to cache.
         $cache->set($cacheKey, $values, $sfgAutocompleteCacheTimeout);
     }
     return $values;
 }
开发者ID:roland2025,项目名称:mediawiki-extensions-SemanticForms,代码行数:98,代码来源:SF_AutocompleteAPI.php

示例15: getDefaultFormsForPage

 /**
  * Get the form(s) used to edit this page - either:
  * - the default form(s) for the page itself, if there are any; or
  * - the default form(s) for a category that this article belongs to,
  * if there are any; or
  * - the default form(s) for the article's namespace, if there are any.
  */
 static function getDefaultFormsForPage($title)
 {
     // See if the page itself has a default form (or forms), and
     // return it/them if so.
     // (Disregard category pages for this check.)
     if ($title->getNamespace() != NS_CATEGORY) {
         $default_form = self::getDefaultForm($title);
         if ($default_form != '') {
             return array($default_form);
         }
     }
     $default_forms = self::getFormsThatPagePointsTo($title->getText(), $title->getNamespace(), self::PAGE_DEFAULT_FORM);
     if (count($default_forms) > 0) {
         return $default_forms;
     }
     // If this is not a category page, look for a default form
     // for its parent category or categories.
     $namespace = $title->getNamespace();
     if (NS_CATEGORY !== $namespace) {
         $default_forms = array();
         $categories = SFUtils::getCategoriesForPage($title);
         foreach ($categories as $category) {
             if (class_exists('PSSchema')) {
                 // Check the Page Schema, if one exists.
                 $psSchema = new PSSchema($category);
                 if ($psSchema->isPSDefined()) {
                     $formName = SFPageSchemas::getFormName($psSchema);
                     if (!is_null($formName)) {
                         $default_forms[] = $formName;
                     }
                 }
             }
             $categoryPage = Title::makeTitleSafe(NS_CATEGORY, $category);
             $defaultFormForCategory = self::getDefaultForm($categoryPage);
             if ($defaultFormForCategory != '') {
                 $default_forms[] = $defaultFormForCategory;
             }
             $default_forms = array_merge($default_forms, self::getFormsThatPagePointsTo($category, NS_CATEGORY, self::DEFAULT_FORM));
         }
         if (count($default_forms) > 0) {
             // It is possible for two categories to have the same default form, so purge any
             // duplicates from the array to avoid a "more than one default form" warning.
             return array_unique($default_forms);
         }
     }
     // All that's left is checking for the namespace. If this is
     // a subpage, exit out - default forms for namespaces don't
     // apply to subpages.
     if ($title->isSubpage()) {
         return array();
     }
     // If we're still here, just return the default form for the
     // namespace, which may well be null.
     if (NS_MAIN === $namespace) {
         // If it's in the main (blank) namespace, check for the
         // file named with the word for "Main" in this language.
         $namespace_label = wfMessage('sf_blank_namespace')->inContentLanguage()->text();
     } else {
         global $wgContLang;
         $namespace_labels = $wgContLang->getNamespaces();
         $namespace_label = $namespace_labels[$namespace];
     }
     $namespacePage = Title::makeTitleSafe(NS_PROJECT, $namespace_label);
     $default_form = self::getDefaultForm($namespacePage);
     if ($default_form != '') {
         return array($default_form);
     }
     $default_forms = self::getFormsThatPagePointsTo($namespace_label, NS_PROJECT, self::DEFAULT_FORM);
     return $default_forms;
 }
开发者ID:paladox,项目名称:mediawiki-extensions-SemanticForms,代码行数:77,代码来源:SF_FormLinker.php


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