idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
49,200
public function getDomain ( ) { $ returnValue = null ; if ( is_null ( $ this -> domain ) ) { $ this -> domain = new core_kernel_classes_ContainerCollection ( new common_Object ( __METHOD__ ) ) ; $ domainValues = $ this -> getPropertyValues ( $ this -> getProperty ( OntologyRdfs :: RDFS_DOMAIN ) ) ; foreach ( $ domainValues as $ domainValue ) { $ this -> domain -> add ( $ this -> getClass ( $ domainValue ) ) ; } } $ returnValue = $ this -> domain ; return $ returnValue ; }
return classes that are described by this property
49,201
public function setDomain ( core_kernel_classes_Class $ class ) { $ returnValue = ( bool ) false ; if ( ! is_null ( $ class ) ) { foreach ( $ this -> getDomain ( ) -> getIterator ( ) as $ domainClass ) { if ( $ class -> equals ( $ domainClass ) ) { $ returnValue = true ; break ; } } if ( ! $ returnValue ) { $ this -> setPropertyValue ( $ this -> getProperty ( OntologyRdfs :: RDFS_DOMAIN ) , $ class -> getUri ( ) ) ; if ( ! is_null ( $ this -> domain ) ) { $ this -> domain -> add ( $ class ) ; } $ returnValue = true ; } } return ( bool ) $ returnValue ; }
Short description of method setDomain
49,202
public function getRange ( ) { $ returnValue = null ; if ( is_null ( $ this -> range ) ) { $ rangeProperty = $ this -> getProperty ( OntologyRdfs :: RDFS_RANGE ) ; $ rangeValues = $ this -> getPropertyValues ( $ rangeProperty ) ; if ( sizeOf ( $ rangeValues ) > 0 ) { $ returnValue = $ this -> getClass ( $ rangeValues [ 0 ] ) ; } $ this -> range = $ returnValue ; } $ returnValue = $ this -> range ; return $ returnValue ; }
Short description of method getRange
49,203
public function getWidget ( ) { if ( $ this -> widget === false ) { $ this -> widget = $ this -> getOnePropertyValue ( $ this -> getProperty ( WidgetRdf :: PROPERTY_WIDGET ) ) ; } return $ this -> widget ; }
Get the Property object corresponding to the widget of this Property .
49,204
public function isLgDependent ( ) { if ( is_null ( $ this -> lgDependent ) ) { $ this -> lgDependent = $ this -> getImplementation ( ) -> isLgDependent ( $ this ) ; } return ( bool ) $ this -> lgDependent ; }
Is the property translatable?
49,205
public function setLgDependent ( $ isLgDependent ) { $ this -> getImplementation ( ) -> setLgDependent ( $ this , $ isLgDependent ) ; $ this -> lgDependent = $ isLgDependent ; }
Set mannually if a property can be translated
49,206
public function isMultiple ( ) { $ returnValue = ( bool ) false ; if ( is_null ( $ this -> multiple ) ) { $ multipleProperty = $ this -> getProperty ( GenerisRdf :: PROPERTY_MULTIPLE ) ; $ multiple = $ this -> getOnePropertyValue ( $ multipleProperty ) ; if ( is_null ( $ multiple ) ) { $ returnValue = false ; } else { $ returnValue = ( $ multiple -> getUri ( ) == GenerisRdf :: GENERIS_TRUE ) ; } $ this -> multiple = $ returnValue ; } $ returnValue = $ this -> multiple ; return ( bool ) $ returnValue ; }
Check if a property can have multiple values .
49,207
public function setMultiple ( $ isMultiple ) { $ this -> getImplementation ( ) -> setMultiple ( $ this , $ isMultiple ) ; $ this -> multiple = $ isMultiple ; }
Define mannualy if a property is multiple or not . Usefull on just created property .
49,208
protected function deleteMappedKey ( $ key , $ value = null , $ level = 0 ) { if ( is_null ( $ value ) ) { $ value = $ this -> getDriver ( ) -> get ( $ key ) ; } if ( $ level > 0 ) { $ key = $ key . self :: LEVEL_SEPARATOR . $ level ; } $ success = true ; if ( $ this -> isSplit ( $ value ) ) { $ valueParts = [ ] ; foreach ( $ this -> unSerializeMap ( $ value ) as $ mappedKey ) { $ mappedKey = $ this -> transformReferenceToMappedKey ( $ mappedKey ) ; $ valueParts [ $ this -> getMappedKeyIndex ( $ mappedKey , $ key ) ] = $ this -> getDriver ( ) -> get ( $ mappedKey ) ; $ success = $ success && $ this -> getDriver ( ) -> del ( $ mappedKey ) ; } uksort ( $ valueParts , 'strnatcmp' ) ; $ value = implode ( '' , $ valueParts ) ; if ( $ this -> isSplit ( $ value ) ) { $ success = $ success && $ this -> deleteMappedKey ( $ key , $ value , $ level + 1 ) ; } } return $ success ; }
Delete a key and if the value is a map delete all mapped key recursively
49,209
protected function join ( $ key , $ value , $ level = 0 ) { if ( $ level > 0 ) { $ key = $ key . self :: LEVEL_SEPARATOR . $ level ; } $ valueParts = [ ] ; foreach ( $ this -> unSerializeMap ( $ value ) as $ mappedKey ) { $ mappedKey = $ this -> transformReferenceToMappedKey ( $ mappedKey ) ; $ valueParts [ $ this -> getMappedKeyIndex ( $ mappedKey , $ key ) ] = $ this -> getDriver ( ) -> get ( $ mappedKey ) ; } uksort ( $ valueParts , 'strnatcmp' ) ; $ value = implode ( '' , $ valueParts ) ; if ( $ this -> isSplit ( $ value ) ) { $ value = $ this -> join ( $ key , $ value , $ level + 1 ) ; } return $ value ; }
Join different values referenced into a map recursively
49,210
protected function createMap ( $ key , $ value ) { $ splitValue = $ this -> split ( $ value ) ; $ map = [ ] ; foreach ( $ splitValue as $ index => $ part ) { $ map [ $ key . self :: MAPPED_KEY_SEPARATOR . $ index ] = $ part ; } return $ map ; }
Split a large value to an array with value size lesser than required max size Construct the array with index of value
49,211
protected function getMappedKeyIndex ( $ mappedKey , $ key ) { $ startSize = strlen ( $ this -> getStartMapDelimiter ( ) ) - 1 ; $ key = substr ( $ key , $ startSize , strrpos ( $ key , $ this -> getEndMapDelimiter ( ) ) - $ startSize ) ; return substr ( $ mappedKey , strlen ( $ key . self :: MAPPED_KEY_SEPARATOR ) ) ; }
Get the mapped key index of a mappedKey
49,212
protected function getSize ( ) { if ( ! $ this -> size ) { $ size = $ this -> getParam ( self :: MAX_VALUE_SIZE ) ; if ( $ size !== false ) { if ( ! is_int ( $ size ) ) { throw new common_Exception ( 'Persistence max value size has to be an integer' ) ; } $ this -> size = $ size - strlen ( $ this -> getMapIdentifier ( ) ) ; } } return $ this -> size ; }
Get the current maximum allowed size for a value
49,213
protected function getParam ( $ param ) { $ params = $ this -> getParams ( ) ; if ( ! isset ( $ params [ $ param ] ) ) { return false ; } return $ params [ $ param ] ; }
Get the requested param from current parameters otherwise throws exception
49,214
public function supportsFeature ( $ feature ) { switch ( $ feature ) { case self :: FEATURE_NX : return ( $ this -> getDriver ( ) instanceof common_persistence_KeyValue_Nx ) ; default : throw new common_exception_Error ( 'Unknown feature ' . $ feature ) ; } return false ; }
Test wheever or not a feature is supported
49,215
public function setConfig ( $ key , $ value ) { if ( ! is_object ( $ value ) || ! $ value instanceof ConfigurableService ) { $ value = new ConfigurationService ( array ( ConfigurationService :: OPTION_CONFIG => $ value ) ) ; } $ value -> setHeader ( $ this -> getConfigHeader ( $ key ) ) ; $ this -> registerService ( $ this -> getId ( ) . '/' . $ key , $ value ) ; return true ; }
sets a configuration value
49,216
public function getConfig ( $ key ) { if ( ! $ this -> getServiceLocator ( ) -> has ( $ this -> getId ( ) . '/' . $ key ) ) { return false ; } try { $ config = $ this -> getServiceLocator ( ) -> get ( $ this -> getId ( ) . '/' . $ key ) ; if ( $ config instanceof ConfigurationService ) { $ config = $ config -> getConfig ( ) ; } } catch ( ServiceNotFoundException $ e ) { $ config = false ; } return $ config ; }
retrieves a configuration value returns false if not found
49,217
public function getConstant ( $ key ) { $ returnValue = null ; $ constants = $ this -> getConstants ( ) ; if ( isset ( $ constants [ $ key ] ) ) { $ returnValue = $ constants [ $ key ] ; } elseif ( defined ( $ key ) ) { common_logger :: w ( 'constant outside of extension called: ' . $ key ) ; $ returnValue = constant ( $ key ) ; } else { throw new common_exception_Error ( 'Unknown constant \'' . $ key . '\' for extension ' . $ this -> id ) ; } return $ returnValue ; }
Retrieves a constant from the manifest . php file of the extension .
49,218
public function getAllModules ( ) { $ returnValue = array ( ) ; $ namespaces = array ( ) ; foreach ( $ this -> getManifest ( ) -> getRoutes ( ) as $ mapedPath => $ ns ) { $ namespaces [ ] = trim ( $ ns , '\\' ) ; } if ( ! empty ( $ namespaces ) ) { common_Logger :: d ( 'Namespace not empty for extension ' . $ this -> getId ( ) ) ; $ recDir = new RecursiveDirectoryIterator ( $ this -> getDir ( ) ) ; $ recIt = new RecursiveIteratorIterator ( $ recDir ) ; $ regexIt = new RegexIterator ( $ recIt , '/^.+\.php$/i' , RecursiveRegexIterator :: GET_MATCH ) ; foreach ( $ regexIt as $ entry ) { $ info = helpers_PhpTools :: getClassInfo ( $ entry [ 0 ] ) ; if ( ! empty ( $ info [ 'ns' ] ) ) { $ ns = trim ( $ info [ 'ns' ] , '\\' ) ; if ( ! empty ( $ info [ 'ns' ] ) && in_array ( $ ns , $ namespaces ) ) { $ returnValue [ $ info [ 'class' ] ] = $ ns . '\\' . $ info [ 'class' ] ; } } } } if ( $ this -> hasConstant ( 'DIR_ACTIONS' ) && file_exists ( $ this -> getConstant ( 'DIR_ACTIONS' ) ) ) { $ dir = new DirectoryIterator ( $ this -> getConstant ( 'DIR_ACTIONS' ) ) ; foreach ( $ dir as $ fileinfo ) { if ( preg_match ( '/^class\.[^.]*\.php$/' , $ fileinfo -> getFilename ( ) ) ) { $ module = substr ( $ fileinfo -> getFilename ( ) , 6 , - 4 ) ; $ returnValue [ $ module ] = $ this -> getId ( ) . '_actions_' . $ module ; } } } foreach ( array_keys ( $ returnValue ) as $ key ) { $ class = $ returnValue [ $ key ] ; if ( ! class_exists ( $ class ) ) { common_Logger :: w ( $ class . ' not found' ) ; unset ( $ returnValue [ $ key ] ) ; } elseif ( ! is_subclass_of ( $ class , 'Module' ) ) { common_Logger :: w ( $ class . ' does not inherit Module' ) ; unset ( $ returnValue [ $ key ] ) ; } } return ( array ) $ returnValue ; }
get all modules of the extension by searching the actions directory not the ontology
49,219
public function getModule ( $ id ) { $ returnValue = null ; $ className = $ this -> getId ( ) . '_actions_' . $ id ; if ( class_exists ( $ className ) ) { $ returnValue = new $ className ; } else { common_Logger :: e ( 'could not load ' . $ className ) ; } return $ returnValue ; }
returns a module by ID
49,220
public function getDependencies ( ) { if ( empty ( $ this -> dependencies ) ) { foreach ( $ this -> getManifest ( ) -> getDependencies ( ) as $ id => $ version ) { $ this -> dependencies [ $ id ] = $ version ; $ dependence = $ this -> getExtensionManager ( ) -> getExtensionById ( $ id ) ; $ this -> dependencies = array_merge ( $ this -> dependencies , $ dependence -> getDependencies ( ) ) ; } } return $ this -> dependencies ; }
Returns the extension the current extension depends on recursively
49,221
public function getManifest ( ) { if ( ! $ this -> manifest ) { $ manifestFile = $ this -> getDir ( ) . self :: MANIFEST_NAME ; if ( is_file ( $ manifestFile ) && is_readable ( $ manifestFile ) ) { $ this -> manifest = new common_ext_Manifest ( $ manifestFile ) ; } else { throw new common_ext_ManifestNotFoundException ( "Extension Manifest not found for extension '" . $ this -> id . "'." , $ this -> id ) ; } } return $ this -> manifest ; }
Returns the manifest of the extension
49,222
protected function getExtensionManager ( ) { if ( $ this -> getServiceLocator ( ) -> has ( common_ext_ExtensionsManager :: SERVICE_ID ) ) { $ service = $ this -> getServiceLocator ( ) -> get ( common_ext_ExtensionsManager :: SERVICE_ID ) ; } else { $ service = new common_ext_ExtensionsManager ( ) ; $ this -> getServiceLocator ( ) -> propagate ( $ service ) ; } return $ service ; }
Get the ExtensionManager service
49,223
public function getConfigHeader ( $ key ) { $ path = $ this -> getDir ( ) . 'config/header/' . $ key . '.conf.php' ; if ( is_readable ( $ path ) && is_file ( $ path ) ) { return file_get_contents ( $ path ) ; } return null ; }
Get the documentation header for extension config located at key path
49,224
protected function getOutputRecord ( array $ record ) { $ output = [ static :: DATETIME_OFFSET => $ record [ 'datetime' ] -> format ( static :: DATETIME_FORMAT ) , static :: SEVERITY_OFFSET => $ record [ 'level_name' ] , static :: CONTENT_OFFSET => $ record [ 'message' ] , ] ; if ( isset ( $ record [ 'context' ] [ 'file' ] ) ) { $ output [ static :: FILE_OFFSET ] = $ record [ 'context' ] [ 'file' ] ; } if ( isset ( $ record [ 'context' ] [ 'line' ] ) ) { $ output [ static :: LINE_OFFSET ] = $ record [ 'context' ] [ 'line' ] ; } if ( isset ( $ record [ 'extra' ] [ EnvironmentProcessorAbstract :: LOG_STACK ] ) ) { $ output [ static :: STACK_OFFSET ] = $ record [ 'extra' ] [ EnvironmentProcessorAbstract :: LOG_STACK ] ; } if ( isset ( $ record [ 'extra' ] [ BacktraceProcessor :: TRACE_OFFSET ] ) ) { $ output [ static :: TRACE_OFFSET ] = $ record [ 'extra' ] [ BacktraceProcessor :: TRACE_OFFSET ] ; } return $ output ; }
Returns the customized record .
49,225
public function logIn ( $ login , $ password , $ module , $ role ) { $ returnValue = ( bool ) false ; if ( $ role === true ) { $ role = new core_kernel_classes_Resource ( TaoOntology :: PROPERTY_INSTANCE_ROLE_GLOBALMANAGER ) ; } core_kernel_users_Service :: singleton ( ) -> login ( $ login , $ password , $ role ) ; return ( bool ) $ returnValue ; }
Short description of method logIn
49,226
public function addLogger ( LoggerInterface $ logger ) { if ( $ this -> isLoggerLoaded ( ) && ! ( $ this -> logger instanceof NullLogger ) ) { $ logger = new LoggerAggregator ( [ $ logger , $ this -> logger ] ) ; } $ this -> logger = $ logger ; return $ logger ; }
Add a Psr3 logger to LoggerService instance Previous and new logger are encapsulated into a LoggerAggregator
49,227
protected function loadLogger ( ) { $ logger = null ; if ( $ this -> hasOption ( self :: LOGGER_OPTION ) ) { $ loggerOptions = $ this -> getOption ( self :: LOGGER_OPTION ) ; if ( is_object ( $ loggerOptions ) ) { if ( is_a ( $ loggerOptions , LoggerInterface :: class ) ) { $ logger = $ loggerOptions ; } } elseif ( is_array ( $ loggerOptions ) && isset ( $ loggerOptions [ 'class' ] ) ) { $ classname = $ loggerOptions [ 'class' ] ; if ( is_a ( $ classname , LoggerInterface :: class , true ) ) { if ( isset ( $ loggerOptions [ 'options' ] ) ) { $ logger = new $ classname ( $ loggerOptions [ 'options' ] ) ; } else { $ logger = new $ classname ( ) ; } } } } if ( ! is_null ( $ logger ) ) { $ this -> logger = $ logger ; } else { $ this -> logger = new NullLogger ( ) ; } return $ this -> logger ; }
Load the logger from configuration
49,228
public function remove ( ) { $ returnValue = ( bool ) false ; $ db = core_kernel_classes_DbWrapper :: singleton ( ) ; if ( false === $ db -> exec ( "DELETE FROM statements WHERE modelid = ?" , array ( $ this -> getModelId ( ) ) ) ) { $ returnValue = false ; } else { if ( false === $ db -> exec ( "DELETE FROM models WHERE modelid = ?" , array ( $ this -> getModelId ( ) ) ) ) { $ returnValue = false ; } else { $ returnValue = true ; } } return ( bool ) $ returnValue ; }
Remove a namespace from the ontology . All triples bound to the model will be removed .
49,229
public static function getFileUploadLimit ( ) { $ max_upload = self :: toBytes ( ini_get ( 'upload_max_filesize' ) ) ; $ max_post = self :: toBytes ( ini_get ( 'post_max_size' ) ) ; $ memory_limit = self :: toBytes ( ini_get ( 'memory_limit' ) ) ; $ returnValue = min ( $ max_upload , $ max_post , $ memory_limit ) ; return ( int ) $ returnValue ; }
Returns the maximum size for fileuploads in bytes .
49,230
private static function toBytes ( $ phpSyntax ) { $ val = trim ( $ phpSyntax ) ; $ last = strtolower ( $ val [ strlen ( $ val ) - 1 ] ) ; if ( ! is_numeric ( $ last ) ) { $ val = substr ( $ val , 0 , - 1 ) ; switch ( $ last ) { case 'g' : $ val *= 1024 ; case 'm' : $ val *= 1024 ; case 'k' : $ val *= 1024 ; } } return $ val ; }
Get the size in bytes of a PHP variable given as a string .
49,231
public static function getCached ( $ function ) { $ returnValue = null ; $ args = func_get_args ( ) ; array_shift ( $ args ) ; if ( ! is_string ( $ function ) ) { $ r = new ReflectionFunction ( $ function ) ; $ serial = md5 ( $ r -> getFileName ( ) . $ r -> getStartLine ( ) . serialize ( $ args ) ) ; } else { $ serial = md5 ( $ function . serialize ( $ args ) ) ; } if ( static :: singleton ( ) -> has ( $ serial ) ) { $ returnValue = static :: singleton ( ) -> has ( $ serial ) ; } else { $ returnValue = call_user_func_array ( $ fn , $ args ) ; static :: singleton ( ) -> put ( $ serial , $ returnValue ) ; } return $ returnValue ; }
Short description of method getCached
49,232
private function getDispatcher ( ) { if ( is_null ( $ this -> dispatcher ) ) { $ this -> dispatcher = new \ common_log_Dispatcher ( $ this -> getOption ( self :: OPTION_APPENDERS ) ) ; } return $ this -> dispatcher ; }
Returns the dispatcher
49,233
static public function getClassInfo ( $ file ) { $ buffer = file_get_contents ( $ file ) ; $ tokens = @ token_get_all ( $ buffer ) ; $ class = $ namespace = $ buffer = '' ; for ( $ i = 0 ; $ i < count ( $ tokens ) ; $ i ++ ) { if ( $ tokens [ $ i ] [ 0 ] === T_NAMESPACE ) { for ( $ j = $ i + 1 ; $ j < count ( $ tokens ) ; $ j ++ ) { if ( $ tokens [ $ j ] [ 0 ] === T_STRING ) { $ namespace .= '\\' . $ tokens [ $ j ] [ 1 ] ; } else if ( $ tokens [ $ j ] === '{' || $ tokens [ $ j ] === ';' ) { break ; } } } if ( $ tokens [ $ i ] [ 0 ] === T_CLASS ) { for ( $ j = $ i + 1 ; $ j < count ( $ tokens ) ; $ j ++ ) { if ( $ tokens [ $ j ] === '{' ) { if ( ! isset ( $ tokens [ $ i + 2 ] [ 1 ] ) ) { error_log ( $ file . ' does not contain a valid class definition' ) ; break ( 2 ) ; } else { $ class = $ tokens [ $ i + 2 ] [ 1 ] ; break ( 2 ) ; } } } } } return array ( 'ns' => $ namespace , 'class' => $ class ) ; }
Returns an array that contains namespace and name of the class defined in the file
49,234
public function load ( ) { if ( $ this -> extension -> getId ( ) != "generis" ) { foreach ( $ this -> extension -> getConstants ( ) as $ key => $ value ) { if ( ! defined ( $ key ) && ! is_array ( $ value ) ) { define ( $ key , $ value ) ; } } } }
Load the extension .
49,235
public static function restore ( array $ data ) { if ( ! isset ( $ data [ 'invocable' ] , $ data [ 'params' ] ) ) { return null ; } $ class = self :: class ; $ task = new $ class ( ) ; if ( isset ( $ data [ 'report' ] ) ) { $ task -> setReport ( $ data [ 'report' ] ) ; } if ( isset ( $ data [ 'status' ] ) ) { $ task -> setStatus ( $ data [ 'status' ] ) ; } if ( isset ( $ data [ 'id' ] ) ) { $ task -> setId ( $ data [ 'id' ] ) ; } if ( isset ( $ data [ 'added' ] ) ) { $ task -> setCreationDate ( $ data [ 'added' ] ) ; } if ( isset ( $ data [ 'owner' ] ) ) { $ task -> setOwner ( $ data [ 'owner' ] ) ; } if ( isset ( $ data [ 'label' ] ) ) { $ task -> setLabel ( $ data [ 'label' ] ) ; } if ( isset ( $ data [ 'type' ] ) ) { $ task -> setType ( $ data [ 'type' ] ) ; } if ( isset ( $ data [ 'added' ] ) ) { $ task -> setType ( $ data [ 'added' ] ) ; } if ( isset ( $ data [ 'invocable' ] ) ) { $ task -> setInvocable ( $ data [ 'invocable' ] ) ; } if ( isset ( $ data [ 'params' ] ) ) { $ task -> setParameters ( $ data [ 'params' ] ) ; } return $ task ; }
Restore a task
49,236
private function writeFile ( $ id , $ value , $ preWriteValueProcessor = null ) { $ filePath = $ this -> getPath ( $ id ) ; $ dirname = dirname ( $ filePath ) ; if ( ! file_exists ( $ dirname ) ) { mkdir ( $ dirname , self :: DEFAULT_MASK , true ) ; } if ( false !== ( $ fp = @ fopen ( $ filePath , 'c' ) ) && true === flock ( $ fp , LOCK_EX ) ) { if ( is_callable ( $ preWriteValueProcessor ) ) { $ value = call_user_func ( $ preWriteValueProcessor , $ id ) ; } ftruncate ( $ fp , 0 ) ; $ string = $ this -> getContent ( $ id , $ value ) ; $ success = fwrite ( $ fp , $ string ) ; @ flock ( $ fp , LOCK_UN ) ; @ fclose ( $ fp ) ; if ( $ success ) { if ( function_exists ( 'opcache_invalidate' ) ) { opcache_invalidate ( $ filePath , true ) ; } } else { common_Logger :: w ( 'Could not write ' . $ filePath ) ; } return $ success !== false ; } else { common_Logger :: w ( 'Could not obtain lock on ' . $ filePath ) ; return false ; } }
Writes the file .
49,237
private function getIncreasedValueEntry ( $ id ) { $ value = intval ( $ this -> get ( $ id ) ) ; $ value ++ ; if ( $ this -> isTtlMode ( ) ) { $ value = [ static :: ENTRY_VALUE => $ value , static :: ENTRY_EXPIRATION => null , ] ; } return $ value ; }
Returns the increased value entry .
49,238
public function purge ( ) { if ( file_exists ( $ this -> directory ) ) { $ files = $ this -> getCachedFiles ( ) ; $ successDeleted = true ; foreach ( $ files as $ file ) { $ successDeleted &= $ this -> removeCacheFile ( $ file ) ; } return ( bool ) $ successDeleted ; } return false ; }
purge the persistence directory
49,239
protected function getPath ( $ key ) { if ( $ this -> humanReadable ) { $ path = $ this -> sanitizeReadableFileName ( $ key ) ; } else { $ encoded = hash ( 'md5' , $ key ) ; $ path = implode ( DIRECTORY_SEPARATOR , str_split ( substr ( $ encoded , 0 , $ this -> levels ) ) ) . DIRECTORY_SEPARATOR . $ encoded ; } return $ this -> directory . $ path . '.php' ; }
Map the provided key to a relativ path
49,240
protected function getContent ( $ key , $ value ) { return $ this -> humanReadable ? "<?php return " . common_Utils :: toHumanReadablePhpString ( $ value ) . ";" . PHP_EOL : "<?php return " . common_Utils :: toPHPVariableString ( $ value ) . ";" ; }
Generate the php code that returns the provided value
49,241
public static function getPsrLevelFromCommon ( $ level ) { if ( empty ( self :: $ reverseMap [ $ level ] ) ) { throw new Exception ( 'Invalid error level in PSR to Common level conversion: ' . $ level ) ; } return self :: $ reverseMap [ $ level ] ; }
Returns the PSR log level based on the common log level .
49,242
private function getDefaultHeader ( $ key ) { return '<?php' . PHP_EOL . '/**' . PHP_EOL . ' * Default config header' . PHP_EOL . ' *' . PHP_EOL . ' * To replace this add a file ' . $ this -> getHeaderPath ( $ key ) . PHP_EOL . ' */' . PHP_EOL ; }
Generates a default header
49,243
private function getHeaderPath ( $ key ) { $ parts = explode ( '/' , $ key , 2 ) ; if ( count ( $ parts ) >= 2 ) { list ( $ extId , $ configId ) = $ parts ; $ ext = common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( $ extId ) ; return $ ext -> getDir ( ) . 'config/header/' . $ configId . '.conf.php' ; } else { return null ; } }
Returns the path to the expected header file
49,244
public function isLgDependent ( core_kernel_classes_Resource $ resource ) { if ( $ this -> getModel ( ) -> getCache ( ) -> has ( $ resource -> getUri ( ) ) ) { $ lgDependent = $ this -> getModel ( ) -> getCache ( ) -> get ( $ resource -> getUri ( ) ) ; } else { $ lgDependentProperty = new \ core_kernel_classes_Property ( GenerisRdf :: PROPERTY_IS_LG_DEPENDENT ) ; $ lgDependentResource = $ resource -> getOnePropertyValue ( $ lgDependentProperty ) ; $ lgDependent = ! is_null ( $ lgDependentResource ) && $ lgDependentResource instanceof \ core_kernel_classes_Resource && $ lgDependentResource -> getUri ( ) == GenerisRdf :: GENERIS_TRUE ; $ this -> getModel ( ) -> getCache ( ) -> put ( $ lgDependent , $ resource -> getUri ( ) ) ; } return ( bool ) $ lgDependent ; }
Short description of method isLgDependent
49,245
public function isMultiple ( core_kernel_classes_Resource $ resource ) { $ returnValue = ( bool ) false ; throw new core_kernel_persistence_ProhibitedFunctionException ( "not implemented => The function (" . __METHOD__ . ") is not available in this persistence implementation (" . __CLASS__ . ")" ) ; return ( bool ) $ returnValue ; }
Short description of method isMultiple
49,246
public function setMultiple ( core_kernel_classes_Resource $ resource , $ isMultiple ) { $ multipleProperty = new core_kernel_classes_Property ( GenerisRdf :: PROPERTY_MULTIPLE ) ; $ value = ( ( bool ) $ isMultiple ) ? GenerisRdf :: GENERIS_TRUE : GenerisRdf :: GENERIS_FALSE ; $ this -> removePropertyValues ( $ resource , $ multipleProperty ) ; $ this -> setPropertyValue ( $ resource , $ multipleProperty , $ value ) ; }
Short description of method setMultiple
49,247
public function setLgDependent ( core_kernel_classes_Resource $ resource , $ isLgDependent ) { $ lgDependentProperty = new core_kernel_classes_Property ( GenerisRdf :: PROPERTY_IS_LG_DEPENDENT , __METHOD__ ) ; $ value = ( ( bool ) $ isLgDependent ) ? GenerisRdf :: GENERIS_TRUE : GenerisRdf :: GENERIS_FALSE ; $ this -> removePropertyValues ( $ resource , $ lgDependentProperty ) ; $ this -> setPropertyValue ( $ resource , $ lgDependentProperty , $ value ) ; }
Short description of method setLgDependent
49,248
public function updateTaskStatus ( $ taskId , $ status ) { if ( $ this -> getPersistence ( ) -> has ( $ taskId ) ) { $ this -> getPersistence ( ) -> update ( $ taskId , $ status ) ; } return $ this ; }
change task status using task persistence
49,249
public function updateTaskReport ( $ taskId , $ report ) { if ( $ this -> getPersistence ( ) -> has ( $ taskId ) ) { $ this -> getPersistence ( ) -> setReport ( $ taskId , $ report ) ; } return $ this ; }
set task report using task persistence
49,250
public function getPayload ( $ currentUserId = null ) { $ class = $ this -> getOption ( 'payload' ) ; if ( ! is_a ( $ class , TaskPayLoad :: class , true ) ) { throw new BadTaskQueueOption ( 'task payload must implement ' . TaskPayLoad :: class ) ; } $ payload = new $ class ( $ this -> getPersistence ( ) , $ currentUserId ) ; $ payload -> setServiceLocator ( $ this -> getServiceLocator ( ) ) ; return $ payload ; }
return a new instance of payload
49,251
public function union ( common_Collection $ collection ) { $ returnValue = null ; $ returnValue = new core_kernel_classes_ContainerCollection ( $ this ) ; $ returnValue -> sequence = array_merge ( $ this -> sequence , $ collection -> sequence ) ; return $ returnValue ; }
Short description of method union
49,252
public function intersect ( common_Collection $ collection ) { $ returnValue = null ; $ returnValue = new core_kernel_classes_ContainerCollection ( new common_Object ( __METHOD__ ) ) ; $ returnValue -> sequence = array_uintersect ( $ this -> sequence , $ collection -> sequence , 'core_kernel_classes_ContainerComparator::compare' ) ; return $ returnValue ; }
Short description of method intersect
49,253
public function indexOf ( common_Object $ resource ) { $ returnValue = null ; $ returnValue = - 1 ; foreach ( $ this -> sequence as $ index => $ _resource ) { if ( $ _resource instanceof core_kernel_classes_Resource ) { if ( $ resource -> equals ( $ _resource ) ) { return $ index ; } } } return $ returnValue ; }
Short description of method indexOf
49,254
public static function getSession ( ) { if ( is_null ( self :: $ session ) ) { if ( PHPSession :: singleton ( ) -> hasAttribute ( self :: PHPSESSION_SESSION_KEY ) ) { $ session = PHPSession :: singleton ( ) -> getAttribute ( self :: PHPSESSION_SESSION_KEY ) ; if ( ! $ session instanceof common_session_Session ) { throw new common_exception_Error ( 'Non session stored in php-session' ) ; } self :: $ session = $ session ; } else { self :: $ session = new common_session_AnonymousSession ( ) ; } } if ( self :: $ session instanceof ServiceLocatorAwareInterface ) { self :: $ session -> setServiceLocator ( ServiceManager :: getServiceManager ( ) ) ; } return self :: $ session ; }
Retrurns the current session
49,255
public static function startSession ( common_session_Session $ session ) { self :: $ session = $ session ; if ( PHP_SAPI != 'cli' ) { if ( $ session instanceof common_session_StatefulSession ) { if ( session_id ( ) === '' ) { session_name ( GENERIS_SESSION_NAME ) ; session_start ( ) ; } else { session_regenerate_id ( ) ; } PHPSession :: singleton ( ) -> setAttribute ( self :: PHPSESSION_SESSION_KEY , $ session ) ; } } return true ; }
Starts a new session and stores it in the session if stateful
49,256
public function createTask ( $ action , $ parameters , $ recall = false , $ label = null , $ type = null ) { if ( $ recall ) { \ common_Logger :: w ( "Repeated call of action'; Execution canceled." ) ; return false ; } $ task = new SyncTask ( $ action , $ parameters ) ; $ task -> setLabel ( $ label ) ; $ task -> setType ( $ type ) ; $ this -> getPersistence ( ) -> add ( $ task ) ; $ this -> runTask ( $ task ) ; return $ task ; }
Create and run task
49,257
public function getServiceManager ( ) { $ serviceManager = $ this -> getServiceLocator ( ) ; if ( $ serviceManager instanceof ServiceManager ) { return $ serviceManager ; } $ msg = is_null ( $ serviceManager ) ? 'ServiceLocator not initialized for ' . get_class ( $ this ) : 'Alternate service locator not compatible with getServiceManager() in ' . __CLASS__ ; throw new InvalidServiceManagerException ( $ msg ) ; }
Get the oat service manager .
49,258
public function registerService ( $ serviceKey , ConfigurableService $ service , $ allowOverride = true ) { if ( $ allowOverride || ! $ this -> getServiceLocator ( ) -> has ( $ serviceKey ) ) { $ this -> getServiceManager ( ) -> register ( $ serviceKey , $ service ) ; } }
Register a service through ServiceManager
49,259
public function trigger ( $ event , $ params = array ( ) ) { $ eventObject = is_object ( $ event ) ? $ event : new GenericEvent ( $ event , $ params ) ; foreach ( $ this -> getListeners ( $ eventObject ) as $ callback ) { if ( is_array ( $ callback ) && count ( $ callback ) == 2 ) { list ( $ key , $ function ) = $ callback ; if ( is_string ( $ key ) && ! class_exists ( $ key ) && $ this -> getServiceManager ( ) -> has ( $ key ) ) { $ service = $ this -> getServiceManager ( ) -> get ( $ key ) ; $ callback = [ $ service , $ function ] ; } } call_user_func ( $ callback , $ eventObject ) ; } }
Dispatch an event and trigger its listeners
49,260
public function attach ( $ event , $ callback ) { $ events = is_array ( $ event ) ? $ event : array ( $ event ) ; $ listeners = $ this -> getOption ( self :: OPTION_LISTENERS ) ; foreach ( $ events as $ event ) { $ eventObject = is_object ( $ event ) ? $ event : new GenericEvent ( $ event ) ; if ( ! isset ( $ listeners [ $ eventObject -> getName ( ) ] ) ) { $ listeners [ $ eventObject -> getName ( ) ] = array ( ) ; } if ( ! in_array ( $ callback , $ listeners [ $ eventObject -> getName ( ) ] , true ) ) { $ listeners [ $ eventObject -> getName ( ) ] [ ] = $ callback ; } } $ this -> setOption ( self :: OPTION_LISTENERS , $ listeners ) ; }
Attach a Listener to one or multiple events
49,261
protected function removeListener ( array $ listeners , $ eventObject , $ callback ) { if ( isset ( $ listeners [ $ eventObject -> getName ( ) ] ) ) { if ( ( $ index = array_search ( $ callback , $ listeners [ $ eventObject -> getName ( ) ] ) ) !== false ) { unset ( $ listeners [ $ eventObject -> getName ( ) ] [ $ index ] ) ; if ( empty ( $ listeners [ $ eventObject -> getName ( ) ] ) ) { unset ( $ listeners [ $ eventObject -> getName ( ) ] ) ; } else { $ listeners [ $ eventObject -> getName ( ) ] = array_values ( $ listeners [ $ eventObject -> getName ( ) ] ) ; } } } return $ listeners ; }
remove listener from an event and delete event if it dosn t have any listeners
49,262
public function detach ( $ event , $ callback ) { $ events = is_array ( $ event ) ? $ event : array ( $ event ) ; $ listeners = $ this -> getOption ( self :: OPTION_LISTENERS ) ; foreach ( $ events as $ event ) { $ eventObject = is_object ( $ event ) ? $ event : new GenericEvent ( $ event ) ; $ listeners = $ this -> removeListener ( $ listeners , $ eventObject , $ callback ) ; } $ this -> setOption ( self :: OPTION_LISTENERS , $ listeners ) ; }
Detach a Listener from one or multiple events
49,263
protected function getListeners ( Event $ eventObject ) { $ listeners = $ this -> getOption ( self :: OPTION_LISTENERS ) ; return isset ( $ listeners [ $ eventObject -> getName ( ) ] ) ? $ listeners [ $ eventObject -> getName ( ) ] : array ( ) ; }
Get all Listeners listening to this kind of event
49,264
public function setExpectedRights ( $ expectedRights ) { if ( ! empty ( $ expectedRights ) && preg_match ( '/^r*w*x*$/' , $ expectedRights ) !== 0 ) { $ this -> expectedRights = $ expectedRights ; } else { throw new common_configuration_MalformedRightsException ( "Malformed rights. Expected format is r|rw|rwx." ) ; } }
Short description of method setExpectedRights
49,265
public function isEmptyDirectory ( $ location = null ) { $ returnValue = false ; if ( $ location === null ) { $ location = $ this -> getLocation ( ) ; } if ( is_readable ( $ location ) && is_dir ( $ location ) ) { $ iterator = new RecursiveDirectoryIterator ( $ location , RecursiveDirectoryIterator :: SKIP_DOTS ) ; $ returnValue = iterator_count ( $ iterator ) === 0 ; } return $ returnValue ; }
If directory is empty .
49,266
protected function runExtensionScript ( $ script , array $ arguments = [ ] ) { $ this -> log ( 'd' , 'Running custom extension script ' . $ script . ' for extension ' . $ this -> getExtension ( ) -> getId ( ) ) ; if ( file_exists ( $ script ) ) { require_once $ script ; } elseif ( class_exists ( $ script ) && is_subclass_of ( $ script , \ oat \ oatbox \ action \ Action :: class ) ) { $ action = new $ script ( ) ; if ( $ action instanceof ServiceLocatorAwareInterface ) { $ action -> setServiceLocator ( $ this -> getServiceManager ( ) ) ; } call_user_func ( $ action , $ arguments ) ; } else { $ error = new common_ext_InstallationException ( 'Unable to run install script ' . $ script ) ; $ error -> setExtensionId ( $ this -> getExtension ( ) -> getId ( ) ) ; throw $ error ; } }
Run Extension Script
49,267
public function importXmlRdf ( $ targetNameSpace , $ fileLocation ) { $ returnValue = ( bool ) false ; if ( ! file_exists ( $ fileLocation ) || ! is_readable ( $ fileLocation ) ) { throw new common_Exception ( "Unable to load ontology : $fileLocation" ) ; } if ( ! preg_match ( "/#$/" , $ targetNameSpace ) ) { $ targetNameSpace .= '#' ; } $ modFactory = new core_kernel_api_ModelFactory ( ) ; $ returnValue = $ modFactory -> createModel ( $ targetNameSpace , file_get_contents ( $ fileLocation ) ) ; return ( bool ) $ returnValue ; }
import xml rdf files into the knowledge base
49,268
public function getMetaClasses ( ) { $ returnValue = null ; $ returnValue = new core_kernel_classes_ContainerCollection ( new core_kernel_classes_Container ( __METHOD__ ) , __METHOD__ ) ; $ classClass = new core_kernel_classes_Class ( OntologyRdfs :: RDFS_CLASS ) ; foreach ( $ classClass -> getSubClasses ( true ) as $ uri => $ subClass ) { $ returnValue -> add ( $ subClass ) ; } return $ returnValue ; }
returns metaclasses tat are not subclasses of other metaclasses
49,269
public function setStatement ( $ subject , $ predicate , $ object , $ language ) { $ returnValue = ( bool ) false ; $ dbWrapper = core_kernel_classes_DbWrapper :: singleton ( ) ; $ platform = $ dbWrapper -> getPlatForm ( ) ; $ localNs = common_ext_NamespaceManager :: singleton ( ) -> getLocalNamespace ( ) ; $ mask = 'yyy[admin,administrators,authors]' ; $ query = 'INSERT INTO statements (modelid,subject,predicate,object,l_language,author,epoch) VALUES (?, ?, ?, ?, ?, ? , ?);' ; try { $ returnValue = $ dbWrapper -> exec ( $ query , array ( $ localNs -> getModelId ( ) , $ subject , $ predicate , $ object , $ language , \ common_session_SessionManager :: getSession ( ) -> getUserUri ( ) , $ platform -> getNowExpression ( ) ) ) ; } catch ( PDOException $ e ) { if ( $ e -> getCode ( ) !== '00000' ) { throw new common_Exception ( "Unable to setStatement (SPO) {$subject}, {$predicate}, {$object} : " . $ e -> getMessage ( ) ) ; } } return ( bool ) $ returnValue ; }
add a new statment to the knowledge base
49,270
public function getAllClasses ( ) { $ returnValue = null ; $ returnValue = new core_kernel_classes_ContainerCollection ( new core_kernel_classes_Container ( __METHOD__ ) , __METHOD__ ) ; $ dbWrapper = core_kernel_classes_DbWrapper :: singleton ( ) ; $ query = "SELECT DISTINCT subject FROM statements WHERE (predicate = ? AND object = ?) OR predicate = ?" ; $ result = $ dbWrapper -> query ( $ query , array ( OntologyRdf :: RDF_TYPE , OntologyRdfs :: RDFS_CLASS , OntologyRdfs :: RDFS_SUBCLASSOF ) ) ; while ( $ row = $ result -> fetch ( ) ) { $ returnValue -> add ( new core_kernel_classes_Class ( $ row [ 'subject' ] ) ) ; } return $ returnValue ; }
Short description of method getAllClasses
49,271
public function getSubject ( $ predicate , $ object ) { $ returnValue = null ; $ sqlQuery = "SELECT subject FROM statements WHERE predicate = ? AND object= ? " ; $ dbWrapper = core_kernel_classes_DbWrapper :: singleton ( ) ; $ sqlResult = $ dbWrapper -> query ( $ sqlQuery , array ( $ predicate , $ object ) ) ; $ returnValue = new core_kernel_classes_ContainerCollection ( new common_Object ( __METHOD__ ) ) ; while ( $ row = $ sqlResult -> fetch ( ) ) { $ container = new core_kernel_classes_Resource ( $ row [ 'subject' ] , __METHOD__ ) ; $ container -> debug = __METHOD__ ; $ returnValue -> add ( $ container ) ; } return $ returnValue ; }
Short description of method getSubject
49,272
public function removeStatement ( $ subject , $ predicate , $ object , $ language ) { $ returnValue = ( bool ) false ; $ dbWrapper = core_kernel_classes_DbWrapper :: singleton ( ) ; $ query = "DELETE FROM statements WHERE subject = ? AND predicate = ? AND object = ? AND (l_language = ? OR l_language = '')" ; $ returnValue = $ dbWrapper -> exec ( $ query , array ( $ subject , $ predicate , $ object , $ language ) ) ; return ( bool ) $ returnValue ; }
Short description of method removeStatement
49,273
public function getObject ( $ subject , $ predicate ) { $ returnValue = null ; $ sqlQuery = "SELECT object FROM statements WHERE subject = ? AND predicate = ?" ; $ dbWrapper = core_kernel_classes_DbWrapper :: singleton ( ) ; $ sqlResult = $ dbWrapper -> query ( $ sqlQuery , array ( $ subject , $ predicate ) ) ; $ returnValue = new core_kernel_classes_ContainerCollection ( new common_Object ( __METHOD__ ) ) ; while ( $ row = $ sqlResult -> fetch ( ) ) { $ value = $ row [ 'object' ] ; if ( ! common_Utils :: isUri ( $ value ) ) { $ container = new core_kernel_classes_Literal ( $ value ) ; } else { $ container = new core_kernel_classes_Resource ( $ value ) ; } $ container -> debug = __METHOD__ ; $ returnValue -> add ( $ container ) ; } return $ returnValue ; }
Short description of method getObject
49,274
public function validate ( $ password ) { $ result = true ; foreach ( $ this -> validators as $ validator ) { $ result &= $ validator -> evaluate ( $ password ) ; } return ( boolean ) $ result ; }
Test if password pass all constraints rules
49,275
protected function register ( $ config ) { $ this -> validators = array ( ) ; if ( array_key_exists ( 'length' , $ config ) && ( int ) $ config [ 'length' ] ) { $ this -> validators [ ] = new \ tao_helpers_form_validators_Length ( array ( 'min' => ( int ) $ config [ 'length' ] ) ) ; } if ( ( array_key_exists ( 'upper' , $ config ) && $ config [ 'upper' ] ) || ( array_key_exists ( 'lower' , $ config ) && $ config [ 'lower' ] ) ) { $ this -> validators [ ] = new \ tao_helpers_form_validators_Regex ( array ( 'message' => __ ( 'Must include at least one letter' ) , 'format' => '/\pL/' ) , 'letters' ) ; } if ( ( array_key_exists ( 'upper' , $ config ) && $ config [ 'upper' ] ) ) { $ this -> validators [ ] = new \ tao_helpers_form_validators_Regex ( array ( 'message' => __ ( 'Must include upper case letters' ) , 'format' => '/(\p{Lu}+)/' , ) , 'caseUpper' ) ; } if ( ( array_key_exists ( 'lower' , $ config ) && $ config [ 'lower' ] ) ) { $ this -> validators [ ] = new \ tao_helpers_form_validators_Regex ( array ( 'message' => __ ( 'Must include lower case letters' ) , 'format' => '/(\p{Ll}+)/' ) , 'caseLower' ) ; } if ( array_key_exists ( 'number' , $ config ) && $ config [ 'number' ] ) { $ this -> validators [ ] = new \ tao_helpers_form_validators_Regex ( array ( 'message' => __ ( 'Must include at least one number' ) , 'format' => '/\pN/' ) , 'number' ) ; } if ( array_key_exists ( 'spec' , $ config ) && $ config [ 'spec' ] ) { $ this -> validators [ ] = new \ tao_helpers_form_validators_Regex ( array ( 'message' => __ ( 'Must include at least one special letter' ) , 'format' => '/[^p{Ll}\p{Lu}\pL\pN]/' ) , 'spec' ) ; } }
Set up all validator according configuration file
49,276
public function getErrors ( ) { $ errors = array ( ) ; foreach ( $ this -> validators as $ validator ) { $ errors [ ] = $ validator -> getMessage ( ) ; } return $ errors ; }
Any errors that was found during validation process
49,277
public function log ( common_log_Item $ item ) { if ( ( 1 << $ item -> getSeverity ( ) & $ this -> mask ) > 0 && ( empty ( $ this -> tags ) || count ( array_intersect ( $ item -> getTags ( ) , $ this -> tags ) ) ) > 0 ) { $ this -> doLog ( $ item ) ; } }
decides whenever the Item should be logged by doLog
49,278
public function getLogThreshold ( ) { $ returnValue = ( int ) 0 ; $ threshold = 0 ; while ( ( $ this -> mask & 1 << $ threshold ) == 0 ) { $ threshold ++ ; } $ returnValue = $ threshold ; return ( int ) $ returnValue ; }
Short description of method getLogThreshold
49,279
public static function createFailure ( $ message , $ errors = array ( ) ) { $ report = new static ( self :: TYPE_ERROR , $ message ) ; foreach ( $ errors as $ error ) { $ report -> add ( $ error ) ; } return $ report ; }
convenience method to create a simple failure report
49,280
public function getSuccesses ( $ asFlat = false ) { $ iterator = true === $ asFlat ? $ this -> getRecursiveIterator ( ) : $ this ; $ successes = array ( ) ; foreach ( $ iterator as $ element ) { if ( $ element -> getType ( ) == self :: TYPE_SUCCESS ) { $ successes [ ] = $ element ; } } return $ successes ; }
returns all success elements
49,281
public function getInfos ( $ asFlat = false ) { $ iterator = true === $ asFlat ? $ this -> getRecursiveIterator ( ) : $ this ; $ infos = array ( ) ; foreach ( $ iterator as $ element ) { if ( $ element -> getType ( ) == self :: TYPE_INFO ) { $ infos [ ] = $ element ; } } return $ infos ; }
returns all info elements
49,282
public function getErrors ( $ asFlat = false ) { $ iterator = true === $ asFlat ? $ this -> getRecursiveIterator ( ) : $ this ; $ errors = array ( ) ; foreach ( $ iterator as $ element ) { if ( $ element -> getType ( ) == self :: TYPE_ERROR ) { $ errors [ ] = $ element ; } } return $ errors ; }
returns all error elements
49,283
public function contains ( $ type ) { foreach ( $ this as $ child ) { if ( $ child -> getType ( ) == $ type || $ child -> contains ( $ type ) ) { return true ; } } return false ; }
Whenever or not the type can be found in the report
49,284
public function add ( $ mixed ) { $ mixedArray = is_array ( $ mixed ) ? $ mixed : array ( $ mixed ) ; foreach ( $ mixedArray as $ element ) { if ( $ element instanceof common_report_Report ) { $ this -> elements [ ] = $ element ; } elseif ( $ element instanceof common_exception_UserReadableException ) { $ this -> elements [ ] = new static ( self :: TYPE_ERROR , $ element -> getUserMessage ( ) ) ; } else { throw new common_exception_Error ( 'Tried to add ' . ( is_object ( $ element ) ? get_class ( $ element ) : gettype ( $ element ) ) . ' to report' ) ; } } }
Add something to the report
49,285
protected function load ( ) { if ( $ this -> resources !== null ) { return $ this -> count ( ) > 0 ; } $ this -> resources = null ; $ this -> index = 0 ; $ this -> loadResources ( ) ; return $ this -> count ( ) > 0 ; }
Load a collection of resources
49,286
public function addFilter ( $ column , $ operator , $ value ) { $ this -> filter -> addFilter ( $ column , $ operator , $ value ) ; return $ this ; }
Add a filter to filter the resources we should iterate over .
49,287
public function addTypeFilter ( $ type ) { $ this -> filter -> eq ( 'predicate' , OntologyRdf :: RDF_TYPE ) -> eq ( 'object' , $ type ) ; return $ this ; }
Add a type resource filter .
49,288
public static function createOperation ( core_kernel_rules_Term $ term1 , core_kernel_rules_Term $ term2 , core_kernel_classes_Resource $ operator ) { $ returnValue = null ; $ operationClass = new core_kernel_classes_Class ( RulesRdf :: CLASS_OPERATION , __METHOD__ ) ; $ label = 'Def Operation Label ' . $ term1 -> getLabel ( ) . ' ' . $ operator -> getLabel ( ) . ' ' . $ term2 -> getLabel ( ) ; $ comment = 'Def Operation Comment ' . $ term1 -> getUri ( ) . ' ' . $ operator -> getUri ( ) . ' ' . $ term2 -> getUri ( ) ; $ operatorProperty = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_OPERATION_OPERATOR , __METHOD__ ) ; $ firstOperand = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_OPERATION_FIRST_OP , __METHOD__ ) ; $ secondOperand = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_OPERATION_SECOND_OP , __METHOD__ ) ; $ termOperationInstance = core_kernel_classes_ResourceFactory :: create ( $ operationClass , $ label , $ comment ) ; $ returnValue = new core_kernel_rules_Operation ( $ termOperationInstance -> getUri ( ) ) ; $ returnValue -> debug = __METHOD__ ; $ returnValue -> setPropertyValue ( $ operatorProperty , $ operator -> getUri ( ) ) ; $ returnValue -> setPropertyValue ( $ firstOperand , $ term1 -> getUri ( ) ) ; $ returnValue -> setPropertyValue ( $ secondOperand , $ term2 -> getUri ( ) ) ; return $ returnValue ; }
Short description of method createOperation
49,289
public function registerEvent ( $ event , $ callback ) { $ eventManager = $ this -> getServiceLocator ( ) -> get ( EventManager :: CONFIG_ID ) ; $ eventManager -> attach ( $ event , $ callback ) ; $ this -> getServiceManager ( ) -> register ( EventManager :: CONFIG_ID , $ eventManager ) ; }
Add a new event Listener
49,290
private function addStatement ( $ modelId , $ subject , $ predicate , $ object , $ lang = null ) { $ result = core_kernel_classes_DbWrapper :: singleton ( ) -> query ( 'SELECT count(*) FROM statements WHERE modelid = ? AND subject = ? AND predicate = ? AND object = ? AND l_language = ?' , array ( $ modelId , $ subject , $ predicate , $ object , ( is_null ( $ lang ) ) ? '' : $ lang ) ) ; if ( intval ( $ result -> fetchColumn ( ) ) === 0 ) { $ dbWrapper = core_kernel_classes_DbWrapper :: singleton ( ) ; $ date = $ dbWrapper -> getPlatForm ( ) -> getNowExpression ( ) ; $ dbWrapper -> insert ( 'statements' , array ( 'modelid' => $ modelId , 'subject' => $ subject , 'predicate' => $ predicate , 'object' => $ object , 'l_language' => is_null ( $ lang ) ? '' : $ lang , 'author' => 'http://www.tao.lu/Ontologies/TAO.rdf#installator' , 'epoch' => $ date ) ) ; } }
Adds a statement to the ontology if it does not exist yet
49,291
public function isBetween ( $ minVersion , $ maxVersion ) { $ current = common_ext_ExtensionsManager :: singleton ( ) -> getInstalledVersion ( $ this -> getExtension ( ) -> getId ( ) ) ; return version_compare ( $ minVersion , $ current , '<=' ) && version_compare ( $ current , $ maxVersion , '<=' ) ; }
Please use skip instead of inBetween .
49,292
public function skip ( $ from , $ to ) { $ current = common_ext_ExtensionsManager :: singleton ( ) -> getInstalledVersion ( $ this -> getExtension ( ) -> getId ( ) ) ; if ( version_compare ( $ from , $ current , '<=' ) && version_compare ( $ current , $ to , '<' ) ) { $ this -> setVersion ( $ to ) ; } }
Skip from version FROM to version TO without additional required actions
49,293
public function safeLoadService ( $ configId ) { $ missingClasses = array ( ) ; $ fallbackAutoload = function ( $ class_name ) use ( & $ missingClasses ) { $ missingClasses [ ] = $ class_name ; $ split = strrpos ( $ class_name , '\\' ) ; if ( $ split == false ) { $ result = eval ( 'class ' . $ class_name . ' extends oat\\oatbox\\service\\ConfigurableService {}' ) ; } else { $ namespace = substr ( $ class_name , 0 , $ split ) ; $ class = substr ( $ class_name , $ split + 1 ) ; eval ( 'namespace ' . $ namespace . '; ' . 'class ' . $ class . ' extends \\oat\\oatbox\\service\\ConfigurableService {}' ) ; } } ; $ serviceManager = $ this -> getServiceManager ( ) ; spl_autoload_register ( $ fallbackAutoload ) ; $ service = $ serviceManager -> get ( $ configId ) ; spl_autoload_unregister ( $ fallbackAutoload ) ; return $ service ; }
Loads a service in a safe way trying to convert unknown classes to abstract services
49,294
public static function getPasswordHash ( ) { return new helpers_PasswordHash ( defined ( 'PASSWORD_HASH_ALGORITHM' ) ? PASSWORD_HASH_ALGORITHM : self :: LEGACY_ALGORITHM , defined ( 'PASSWORD_HASH_SALT_LENGTH' ) ? PASSWORD_HASH_SALT_LENGTH : self :: LEGACY_SALT_LENGTH ) ; }
Returns the hashing algorithm defined in generis configuration
49,295
public function removeUser ( core_kernel_classes_Resource $ user ) { $ returnValue = ( bool ) false ; $ returnValue = $ user -> delete ( ) ; return ( bool ) $ returnValue ; }
Remove a Generis User from persistent memory . Bound roles will remain
49,296
public function getOneUser ( $ login , core_kernel_classes_Class $ class = null ) { $ returnValue = null ; if ( empty ( $ class ) ) { $ class = new core_kernel_classes_Class ( GenerisRdf :: CLASS_GENERIS_USER ) ; } $ users = $ class -> searchInstances ( array ( GenerisRdf :: PROPERTY_USER_LOGIN => $ login ) , array ( 'like' => false , 'recursive' => true ) ) ; if ( count ( $ users ) == 1 ) { $ returnValue = current ( $ users ) ; } else if ( count ( $ users ) > 1 ) { $ msg = "More than one user have the same login '${login}'." ; } return $ returnValue ; }
Get a specific Generis User from the persistent memory of Generis that a specific login . If multiple users have the same login a UserException be thrown .
49,297
public function isPasswordValid ( $ password , core_kernel_classes_Resource $ user ) { $ returnValue = ( bool ) false ; if ( ! is_string ( $ password ) ) { throw new core_kernel_users_Exception ( 'The password must be of "string" type, got ' . gettype ( $ password ) ) ; } $ hash = $ user -> getUniquePropertyValue ( new core_kernel_classes_Property ( GenerisRdf :: PROPERTY_USER_PASSWORD ) ) ; $ returnValue = core_kernel_users_Service :: getPasswordHash ( ) -> verify ( $ password , $ hash ) ; return ( bool ) $ returnValue ; }
used in conjunction with the callback validator to test the pasword entered
49,298
public function setPassword ( core_kernel_classes_Resource $ user , $ password ) { if ( ! is_string ( $ password ) ) { throw new core_kernel_users_Exception ( 'The password must be of "string" type, got ' . gettype ( $ password ) ) ; } $ user -> editPropertyValues ( new core_kernel_classes_Property ( GenerisRdf :: PROPERTY_USER_PASSWORD ) , core_kernel_users_Service :: getPasswordHash ( ) -> encrypt ( $ password ) ) ; }
Set the password of a specifc user .
49,299
public function getUserRoles ( core_kernel_classes_Resource $ user ) { $ returnValue = array ( ) ; $ rolesProperty = new core_kernel_classes_Property ( GenerisRdf :: PROPERTY_USER_ROLES ) ; $ rootRoles = $ user -> getPropertyValuesCollection ( $ rolesProperty ) ; foreach ( $ rootRoles -> getIterator ( ) as $ r ) { $ returnValue [ $ r -> getUri ( ) ] = $ r ; $ returnValue = array_merge ( $ returnValue , $ this -> getIncludedRoles ( $ r ) ) ; } $ returnValue = array_unique ( $ returnValue ) ; return ( array ) $ returnValue ; }
Get the roles that a given user has .