idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
49,100
private function componentChecked ( common_configuration_Component $ component ) { if ( $ component !== $ this -> getRootComponent ( ) ) { array_push ( $ this -> checkedComponents , $ component ) ; } }
Short description of method componentChecked
49,101
private function checkComponent ( common_configuration_Component $ component ) { $ returnValue = ( int ) 0 ; $ report = $ component -> check ( ) ; $ this -> componentChecked ( $ component ) ; if ( false == $ this -> isSilent ( $ component ) ) { $ this -> addReport ( $ report ) ; } $ returnValue = $ report -> getStatus ( ) ; return ( int ) $ returnValue ; }
Short description of method checkComponent
49,102
public function silent ( common_configuration_Component $ component ) { $ silentComponents = $ this -> getSilentComponents ( ) ; foreach ( $ silentComponents as $ silent ) { if ( $ silent === $ component ) { return ; } } $ silentComponents [ ] = $ component ; $ this -> setSilentComponents ( $ silentComponents ) ; }
Short description of method silent
49,103
private function isSilent ( common_configuration_Component $ component ) { $ returnValue = ( bool ) false ; $ returnValue = in_array ( $ component , $ this -> getSilentComponents ( ) ) ; return ( bool ) $ returnValue ; }
Short description of method isSilent
49,104
private function setRootComponent ( common_configuration_Component $ component ) { $ this -> rootComponent = $ component ; $ components = $ this -> getComponents ( ) ; $ components [ ] = $ component ; $ this -> setComponents ( $ components ) ; $ this -> silent ( $ component ) ; }
Short description of method setRootComponent
49,105
public static function buildPHPRuntime ( $ min , $ max = null , $ optional = false ) { $ returnValue = null ; $ returnValue = new common_configuration_PHPRuntime ( $ min , $ max , $ optional ) ; return $ returnValue ; }
Short description of method buildPHPRuntime
49,106
public static function buildPHPExtension ( $ name , $ min = null , $ max = null , $ optional = false ) { $ returnValue = null ; $ returnValue = new common_configuration_PHPExtension ( $ min , $ max , $ name , $ optional ) ; return $ returnValue ; }
Short description of method buildPHPExtension
49,107
public static function buildPHPINIValue ( $ name , $ expectedValue , $ optional = false ) { $ returnValue = null ; $ returnValue = new common_configuration_PHPINIValue ( $ expectedValue , $ name , $ optional ) ; return $ returnValue ; }
Short description of method buildPHPINIValue
49,108
public static function buildPHPDatabaseDriver ( $ name , $ optional = false ) { $ returnValue = null ; $ returnValue = new common_configuration_PHPDatabaseDriver ( null , null , $ name , $ optional ) ; return $ returnValue ; }
Short description of method buildPHPDatabaseDriver
49,109
public static function buildFileSystemComponent ( $ location , $ expectedRights , $ optional = false , $ recursive = false , $ mustCheckIfEmpty = false ) { $ returnValue = new common_configuration_FileSystemComponent ( $ location , $ expectedRights , $ optional , $ recursive , $ mustCheckIfEmpty ) ; self :: incrementFileSystemCount ( ) ; $ returnValue -> setName ( 'FileSystemComponentCheck_' . self :: getFileSystemCount ( ) ) ; return $ returnValue ; }
Short description of method buildFileSystemComponent
49,110
public static function buildCustom ( $ name , $ extension , $ optional = false ) { $ returnValue = null ; $ name = explode ( '_' , $ name ) ; for ( $ i = 0 ; $ i < count ( $ name ) ; $ i ++ ) { $ name [ $ i ] = ucfirst ( $ name [ $ i ] ) ; } $ name = implode ( '' , $ name ) ; $ checkClassName = "${extension}_install_checks_${name}" ; try { $ checkClass = new ReflectionClass ( $ checkClassName ) ; $ returnValue = $ checkClass -> newInstanceArgs ( array ( "custom_${extension}_${name}" , $ optional ) ) ; } catch ( LogicException $ e ) { $ msg = "Cannot instantiate custom check '${name}' for extension '${extension}': " ; $ msg .= $ e -> getMessage ( ) ; throw new common_configuration_ComponentFactoryException ( $ msg ) ; } catch ( ReflectionException $ e ) { $ msg = "Cannot instantiate custom check '${name}' for extension '${extension}': " ; $ msg .= $ e -> getMessage ( ) ; throw new common_configuration_ComponentFactoryException ( $ msg ) ; } return $ returnValue ; }
Short description of method buildCustom
49,111
public static function buildMock ( $ expectedStatus , $ optional = false ) { $ returnValue = null ; self :: incrementMockCount ( ) ; $ returnValue = new common_configuration_Mock ( $ expectedStatus , 'MockComponentCheck_' . self :: getMockCount ( ) ) ; $ returnValue -> setOptional ( $ optional ) ; return $ returnValue ; }
Short description of method buildMock
49,112
public function evalutateSetOperation ( core_kernel_classes_Resource $ setOperator , common_Collection $ actualSet , core_kernel_classes_ContainerCollection $ newSet ) { $ returnValue = null ; if ( $ setOperator -> getUri ( ) == RulesRdf :: INSTANCE_OPERATOR_UNION ) { $ returnValue = $ actualSet -> union ( $ newSet ) ; } else if ( $ setOperator -> getUri ( ) == RulesRdf :: INSTANCE_OPERATOR_INTERSECT ) { $ returnValue = $ actualSet -> intersect ( $ newSet ) ; } else { throw new common_Exception ( 'unknow set operator' ) ; } return $ returnValue ; }
Short description of method evalutateSetOperation
49,113
protected function evaluateSPX ( $ variable = array ( ) ) { common_Logger :: d ( 'SPX TYPE' , array ( 'Generis Term evaluateSPX' ) ) ; $ resource = $ this -> getUniquePropertyValue ( new core_kernel_classes_Property ( RulesRdf :: PROPERTY_TERM_SPX_SUBJET ) ) ; if ( $ resource instanceof core_kernel_classes_Resource ) { if ( array_key_exists ( $ resource -> getUri ( ) , $ variable ) ) { common_Logger :: d ( 'Variable uri : ' . $ resource -> getUri ( ) . ' found' , array ( 'Generis Term evaluateSPX' ) ) ; common_Logger :: d ( 'Variable name : ' . $ resource -> getLabel ( ) . ' found' , array ( 'Generis Term evaluateSPX' ) ) ; $ resource = new core_kernel_classes_Resource ( $ variable [ $ resource -> getUri ( ) ] ) ; common_Logger :: d ( 'Variable repaced uri : ' . $ resource -> getUri ( ) , array ( 'Generis Term evaluateSPX' ) ) ; common_Logger :: d ( 'Variable repaced name : ' . $ resource -> getLabel ( ) , array ( 'Generis Term evaluateSPX' ) ) ; } try { $ propertyInstance = $ this -> getUniquePropertyValue ( new core_kernel_classes_Property ( RulesRdf :: PROPERTY_TERM_SPX_PREDICATE ) ) ; } catch ( common_Exception $ e ) { echo $ e ; var_dump ( $ this ) ; die ( 'unable to get property value in Term' ) ; } $ property = new core_kernel_classes_Property ( $ propertyInstance -> getUri ( ) ) ; common_Logger :: d ( 'Property uri ' . $ property -> getUri ( ) , array ( 'Generis Term evaluateSPX' ) ) ; common_Logger :: d ( 'Property name ' . $ property -> getLabel ( ) , array ( 'Generis Term evaluateSPX' ) ) ; $ returnValue = $ resource -> getPropertyValuesCollection ( $ property ) ; common_Logger :: d ( $ returnValue -> count ( ) . ' values returned ' , array ( 'Generis Term evaluateSPX' ) ) ; if ( $ returnValue -> isEmpty ( ) ) { $ newEmptyTerm = new core_kernel_rules_Term ( RulesRdf :: INSTANCE_TERM_IS_NULL , __METHOD__ ) ; common_Logger :: d ( 'Empty Term Created' , array ( 'Generis Term evaluateSPX' ) ) ; $ property = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_TERM_VALUE ) ; $ returnValue = $ newEmptyTerm -> getUniquePropertyValue ( $ property ) ; } else { if ( $ returnValue -> count ( ) == 1 ) { $ returnValue = $ returnValue -> get ( 0 ) ; } } } return $ returnValue ; }
Short description of method evaluateSPX
49,114
protected function evaluateXPO ( ) { common_Logger :: d ( 'XPO TYPE' , array ( 'Generis Term evaluateXPO' ) ) ; $ classTerm = new core_kernel_classes_Class ( RulesRdf :: CLASS_URI_TERM_X_PREDICATE_OBJECT ) ; $ obj = $ this -> getUniquePropertyValue ( new core_kernel_classes_Property ( RulesRdf :: PROPERTY_TERM_XPO_OBJECT ) ) ; $ pred = $ this -> getUniquePropertyValue ( new core_kernel_classes_Property ( RulesRdf :: PROPERTY_TERM_XPO_PREDICATE ) ) ; if ( $ obj instanceof core_kernel_classes_Literal ) { $ objValue = $ obj -> literal ; } if ( $ obj instanceof core_kernel_classes_Resource ) { $ objValue = $ pred -> getUri ( ) ; } $ returnValue = new core_kernel_classes_ContainerCollection ( new common_Object ( __METHOD__ ) ) ; $ terms = $ classTerm -> searchInstances ( array ( $ pred -> getUri ( ) => $ objValue ) , array ( 'like' => false ) ) ; foreach ( $ terms as $ term ) { $ returnValue -> add ( $ term ) ; } return $ returnValue ; }
Short description of method evaluateXPO
49,115
protected function evaluateSet ( ) { common_Logger :: d ( 'Constructed Set TYPE' , array ( 'Generis Term evaluateSet' ) ) ; $ operator = $ this -> getUniquePropertyValue ( new core_kernel_classes_Property ( RulesRdf :: PROPERTY_SET_OPERATOR ) ) ; $ subSets = $ this -> getPropertyValuesCollection ( new core_kernel_classes_Property ( RulesRdf :: PROPERTY_SUBSET ) ) ; $ returnValue = new core_kernel_classes_ContainerCollection ( $ this ) ; foreach ( $ subSets -> getIterator ( ) as $ aSet ) { if ( $ aSet instanceof core_kernel_classes_Resource ) { $ newSet = new core_kernel_rules_Term ( $ aSet -> getUri ( ) ) ; $ resultSet = $ newSet -> evaluate ( ) ; if ( $ resultSet instanceof core_kernel_classes_ContainerCollection ) { $ returnValue = $ this -> evalutateSetOperation ( $ operator , $ returnValue , $ resultSet ) ; } else { $ collection = new core_kernel_classes_ContainerCollection ( $ this ) ; $ collection -> add ( $ resultSet ) ; $ returnValue = $ this -> evalutateSetOperation ( $ operator , $ returnValue , $ collection ) ; } } else { throw new common_Exception ( 'Bad Type , waiting for a Resource ' ) ; } } return $ returnValue ; }
Short description of method evaluateSet
49,116
protected function evaluateConst ( ) { common_Logger :: d ( 'CONSTANTE TYPE' , array ( 'Generis Term evaluateConst' ) ) ; $ property = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_TERM_VALUE ) ; return $ this -> getUniquePropertyValue ( $ property ) ; }
Short description of method evaluateConst
49,117
public function evaluateArithmOperation ( $ variable = array ( ) ) { $ operation = new core_kernel_rules_Operation ( $ this -> getUri ( ) , __METHOD__ ) ; return $ operation -> evaluate ( $ variable ) ; }
Short description of method evaluateArtihmOperation
49,118
protected function getZendServiceManager ( ) { if ( is_null ( $ this -> services ) ) { $ options = $ this -> getOptions ( ) ; $ options [ 'services' ] [ 'search.options' ] [ 'model' ] = $ this -> model ; $ config = new Config ( $ options ) ; $ this -> services = new ServiceManager ( $ config ) ; } return $ this -> services ; }
Returns the internal service manager
49,119
public function getGateway ( ) { if ( is_null ( $ this -> gateway ) ) { $ this -> gateway = $ this -> getZendServiceManager ( ) -> get ( self :: SERVICE_SEARCH_ID ) -> setServiceLocator ( $ this -> getZendServiceManager ( ) ) -> init ( ) ; } return $ this -> gateway ; }
return search gateway
49,120
public function searchType ( QueryBuilderInterface $ query , $ class_uri , $ recursive = false ) { $ Class = new \ core_kernel_classes_Class ( $ class_uri ) ; $ rdftypes = [ ] ; if ( $ recursive === true ) { foreach ( $ Class -> getSubClasses ( true ) as $ subClass ) { $ rdftypes [ ] = $ subClass -> getUri ( ) ; } } $ rdftypes [ ] = $ class_uri ; $ criteria = $ query -> newQuery ( ) -> add ( 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' ) -> in ( $ rdftypes ) ; return $ criteria ; }
return a preset query builder with types
49,121
public function setLanguage ( QueryBuilderInterface $ query , $ userLanguage = '' , $ defaultLanguage = \ DEFAULT_LANG ) { $ options = $ this -> getGateway ( ) -> getOptions ( ) ; if ( ! empty ( $ userLanguage ) ) { $ options [ 'language' ] = $ userLanguage ; } $ options [ 'defaultLanguage' ] = $ defaultLanguage ; $ this -> getGateway ( ) -> setOptions ( $ options ) ; return $ query -> newQuery ( ) ; }
set gateway language options
49,122
public function getQuery ( core_kernel_persistence_smoothsql_SmoothModel $ model , $ classUri , array $ propertyFilters , $ and = true , $ isLikeOperator = true , $ lang = '' , $ offset = 0 , $ limit = 0 , $ order = '' , $ orderDir = 'ASC' ) { $ query = $ this -> getGateway ( ) -> query ( ) -> setLimit ( $ limit ) -> setOffset ( $ offset ) ; if ( ! empty ( $ order ) ) { $ query -> sort ( [ $ order => strtolower ( $ orderDir ) ] ) ; } $ this -> setLanguage ( $ query , $ lang ) ; $ criteria = $ query -> newQuery ( ) -> add ( 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' ) -> in ( $ classUri ) ; $ query -> setCriteria ( $ criteria ) ; $ count = 0 ; $ propertyFilters = FilterFactory :: buildFilters ( $ propertyFilters , $ isLikeOperator ) ; $ maxLength = count ( $ propertyFilters ) ; foreach ( $ propertyFilters as $ filter ) { $ this -> validValue ( $ filter -> getValue ( ) ) ; $ criteria -> addCriterion ( $ filter -> getKey ( ) , $ filter -> getOperator ( ) , $ this -> parseValue ( $ filter -> getValue ( ) ) ) ; $ orValues = $ filter -> getOrConditionValues ( ) ; foreach ( $ orValues as $ val ) { $ criteria -> addOr ( $ this -> parseValue ( $ val ) ) ; } $ count ++ ; if ( $ and === false && $ maxLength > $ count ) { $ criteria = $ query -> newQuery ( ) -> add ( 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' ) -> in ( $ classUri ) ; $ query -> setOr ( $ criteria ) ; } } $ queryString = $ this -> getGateway ( ) -> serialyse ( $ query ) -> getQuery ( ) ; return $ queryString ; }
serialyse a query for searchInstance use for legacy search
49,123
public static function createInstance ( core_kernel_classes_Class $ clazz , $ label = '' , $ comment = '' , $ uri = '' ) { $ returnValue = null ; $ newUri = ( ! empty ( $ uri ) ) ? self :: checkProvidedUri ( $ uri ) : common_Utils :: getNewUri ( ) ; $ newResource = new core_kernel_classes_Class ( $ newUri ) ; $ propertiesValues = array ( OntologyRdf :: RDF_TYPE => $ clazz -> getUri ( ) ) ; if ( ! empty ( $ label ) ) { $ propertiesValues [ OntologyRdfs :: RDFS_LABEL ] = $ label ; } if ( ! empty ( $ comment ) ) { $ propertiesValues [ OntologyRdfs :: RDFS_COMMENT ] = $ comment ; } $ check = $ newResource -> setPropertiesValues ( $ propertiesValues ) ; if ( $ check ) { $ returnValue = $ newResource ; } else { $ msg = "Failed to create an instance of class '" . $ clazz -> getUri ( ) . "'." ; throw new common_Exception ( $ msg ) ; common_Logger :: e ( $ msg ) ; } return $ returnValue ; }
Short description of method createInstance
49,124
public static function createSubClass ( core_kernel_classes_Class $ clazz , $ label = '' , $ comment = '' , $ uri = '' ) { $ returnValue = null ; $ class = new core_kernel_classes_Class ( OntologyRdfs :: RDFS_CLASS ) ; $ instance = self :: createInstance ( $ class , $ label , $ comment , $ uri ) ; $ returnValue = new core_kernel_classes_Class ( $ instance -> getUri ( ) ) ; $ returnValue -> setSubClassOf ( $ clazz ) ; return $ returnValue ; }
Short description of method createSubClass
49,125
private static function checkProvidedUri ( $ uri ) { $ returnValue = ( string ) '' ; if ( $ uri != '' ) { if ( common_Utils :: isUri ( $ uri ) ) { $ returnValue = $ uri ; } else { throw new common_Exception ( "Could not create new Resource, malformed URI provided: '" . $ uri . "'." ) ; } } else { $ returnValue = common_Utils :: getNewUri ( ) ; } return ( string ) $ returnValue ; }
Short description of method checkProvidedUri
49,126
public function setMax ( $ max ) { if ( ! empty ( $ max ) ) { $ this -> max = preg_replace ( '/x/u' , '99999' , $ max ) ; } else { $ this -> max = null ; } }
Short description of method setMax
49,127
public function autoload ( $ pClassName ) { if ( strpos ( $ pClassName , '_' ) !== false ) { $ tokens = explode ( "_" , $ pClassName ) ; $ size = count ( $ tokens ) ; $ path = '' ; for ( $ i = 0 ; $ i < $ size - 1 ; $ i ++ ) { $ path .= $ tokens [ $ i ] . '/' ; } $ filePath = '/' . $ path . 'class.' . $ tokens [ $ size - 1 ] . '.php' ; if ( file_exists ( $ this -> root . 'generis' . DIRECTORY_SEPARATOR . $ filePath ) ) { require_once $ this -> root . 'generis' . DIRECTORY_SEPARATOR . $ filePath ; return ; } $ filePathInterface = '/' . $ path . 'interface.' . $ tokens [ $ size - 1 ] . '.php' ; if ( file_exists ( $ this -> root . 'generis' . DIRECTORY_SEPARATOR . $ filePathInterface ) ) { require_once $ this -> root . 'generis' . DIRECTORY_SEPARATOR . $ filePathInterface ; return ; } $ filePathTrait = '/' . $ path . 'trait.' . $ tokens [ $ size - 1 ] . '.php' ; if ( file_exists ( $ this -> root . 'generis' . DIRECTORY_SEPARATOR . $ filePathTrait ) ) { require_once $ this -> root . 'generis' . DIRECTORY_SEPARATOR . $ filePathTrait ; return ; } if ( file_exists ( $ this -> root . $ filePath ) ) { require_once $ this -> root . $ filePath ; return ; } elseif ( file_exists ( $ this -> root . $ filePathInterface ) ) { require_once $ this -> root . $ filePathInterface ; return ; } $ legacyPrefix = false ; foreach ( $ this -> legacyPrefixes as $ key => $ namespace ) { if ( substr ( $ pClassName , 0 , strlen ( $ key ) ) == $ key ) { $ newClass = $ namespace . strtr ( substr ( $ pClassName , strlen ( $ key ) ) , '_' , '\\' ) ; $ this -> wrapClass ( $ pClassName , $ newClass ) ; return ; } } } }
Attempt to autload classes in tao
49,128
public static function exportAll ( ) { $ dbWrapper = core_kernel_classes_DbWrapper :: singleton ( ) ; $ result = $ dbWrapper -> query ( 'SELECT DISTINCT "subject", "predicate", "object", "l_language" FROM "statements"' ) ; return self :: statement2rdf ( $ result ) ; }
Export the entire ontology
49,129
public static function exportModels ( $ modelIds ) { $ dbWrapper = core_kernel_classes_DbWrapper :: singleton ( ) ; $ result = $ dbWrapper -> query ( 'SELECT DISTINCT "subject", "predicate", "object", "l_language" FROM "statements" WHERE "modelid" IN (\'' . implode ( '\',\'' , $ modelIds ) . '\')' ) ; common_Logger :: i ( 'Found ' . $ result -> rowCount ( ) . ' entries for models ' . implode ( ',' , $ modelIds ) ) ; return self :: statement2rdf ( $ result ) ; }
Export models by id
49,130
public static function exportModelByUri ( $ modelUri ) { $ dbWrapper = core_kernel_classes_DbWrapper :: singleton ( ) ; $ result = $ dbWrapper -> query ( 'SELECT modelid FROM "models" WHERE "modeluri" = ?' , array ( $ modelUri ) ) -> fetch ( PDO :: FETCH_ASSOC ) ; self :: exportModels ( $ result [ 'modelid' ] ) ; }
Export a model by URI
49,131
public function hashSet ( $ key , $ field , $ value ) { $ option = $ this -> getHashOption ( $ key ) ; $ option [ $ field ] = $ value ; return $ this -> setOption ( $ key , $ option ) ; }
Sets a specific field of an option
49,132
public function hashRemove ( $ key , $ field ) { $ option = $ this -> getHashOption ( $ key ) ; if ( ! isset ( $ option [ $ field ] ) ) { return false ; } else { unset ( $ option [ $ field ] ) ; return $ this -> setOption ( $ key , $ option ) ; } }
Removes a specific field of an option
49,133
public function hashGet ( $ key , $ field ) { $ option = $ this -> getHashOption ( $ key ) ; return isset ( $ option [ $ field ] ) ? $ option [ $ field ] : null ; }
Returns a specific field of an option
49,134
private function getHashOption ( $ key ) { $ option = $ this -> hasOption ( $ key ) ? $ this -> getOption ( $ key ) : [ ] ; if ( ! is_array ( $ option ) ) { throw new \ common_exception_InconsistentData ( $ key . ' is not an array' ) ; } return $ option ; }
Retroieve an option and ensure it is an array
49,135
protected function getResourceFilePropertiesValues ( $ serial ) { $ file = $ this -> getResource ( $ serial ) ; if ( ! $ file -> exists ( ) ) { throw new \ common_exception_NotFound ( 'File reference serial "' . $ serial . '" not exist as resource' ) ; } if ( ! $ file -> hasType ( $ this -> getClass ( GenerisRdf :: CLASS_GENERIS_FILE ) ) ) { throw new \ common_exception_NotFound ( 'Resource ' . $ serial . ' is not a file' ) ; } $ properties = [ ] ; $ propertiesDefinition = [ $ this -> getProperty ( GenerisRdf :: PROPERTY_FILE_FILEPATH ) , $ this -> getProperty ( GenerisRdf :: PROPERTY_FILE_FILESYSTEM ) , $ this -> getProperty ( GenerisRdf :: PROPERTY_FILE_FILENAME ) , ] ; $ propertiesValues = $ file -> getPropertiesValues ( $ propertiesDefinition ) ; $ fileSystemProperty = current ( $ propertiesValues [ GenerisRdf :: PROPERTY_FILE_FILESYSTEM ] ) ; $ properties [ self :: RESOURCE_FILE_FILESYSTEM_URI ] = $ fileSystemProperty instanceof \ core_kernel_classes_Resource ? $ fileSystemProperty -> getUri ( ) : $ fileSystemProperty -> literal ; $ filePath = current ( $ propertiesValues [ GenerisRdf :: PROPERTY_FILE_FILEPATH ] ) -> literal ; $ properties [ self :: RESOURCE_FILE_PATH ] = trim ( str_replace ( DIRECTORY_SEPARATOR , '/' , $ filePath ) , '/' ) ; if ( ! empty ( $ propertiesValues [ GenerisRdf :: PROPERTY_FILE_FILENAME ] ) ) { $ fileName = current ( $ propertiesValues [ GenerisRdf :: PROPERTY_FILE_FILENAME ] ) -> literal ; $ properties [ self :: RESOURCE_FILE_NAME ] = ltrim ( str_replace ( DIRECTORY_SEPARATOR , '/' , $ fileName ) , '/' ) ; } return $ properties ; }
Return an array with filesystem uri and path following serial Serial is Resource file uri data are extracted from database
49,136
static public function isFileInsideDirectory ( $ filename , $ directory ) { $ canonicalDirectory = realpath ( $ directory ) ; if ( false === $ canonicalDirectory ) { return false ; } $ canonicalFilename = realpath ( $ canonicalDirectory . DIRECTORY_SEPARATOR . $ filename ) ; if ( false === $ canonicalFilename ) { return false ; } return 0 === strpos ( $ canonicalFilename , $ canonicalDirectory ) ; }
Helps prevent path traversal attacks
49,137
static public function remove ( $ path ) { $ returnValue = ( bool ) false ; if ( is_file ( $ path ) ) { $ returnValue = unlink ( $ path ) ; } elseif ( is_dir ( $ path ) ) { $ handle = opendir ( $ path ) ; if ( $ handle !== false ) { while ( false !== ( $ entry = readdir ( $ handle ) ) ) { if ( $ entry != "." && $ entry != ".." ) { self :: remove ( $ path . DIRECTORY_SEPARATOR . $ entry ) ; } } closedir ( $ handle ) ; } else { throw new common_exception_Error ( '"' . $ path . '" cannot be opened for removal' ) ; } $ returnValue = rmdir ( $ path ) ; } else { throw new common_exception_Error ( '"' . $ path . '" cannot be removed since it\'s neither a file nor directory' ) ; } return ( bool ) $ returnValue ; }
deletes a file or a direcstory recursively
49,138
static public function emptyDirectory ( $ path , $ ignoreSystemFiles = false ) { $ success = true ; $ handle = opendir ( $ path ) ; while ( false !== ( $ entry = readdir ( $ handle ) ) ) { if ( $ entry != "." && $ entry != ".." ) { if ( $ entry [ 0 ] === '.' && $ ignoreSystemFiles === true ) { continue ; } $ success = self :: remove ( $ path . DIRECTORY_SEPARATOR . $ entry ) ? $ success : false ; } } closedir ( $ handle ) ; return $ success ; }
Empty a directory without deleting it
49,139
static public function copy ( $ source , $ destination , $ recursive = true , $ ignoreSystemFiles = true ) { if ( ! is_readable ( $ source ) ) { return false ; } $ returnValue = ( bool ) false ; $ basename = basename ( $ source ) ; if ( $ basename [ 0 ] === '.' && $ ignoreSystemFiles === true ) { return false ; } if ( is_link ( $ source ) ) { return symlink ( readlink ( $ source ) , $ destination ) ; } if ( is_file ( $ source ) ) { $ destInfo = pathinfo ( $ destination ) ; if ( isset ( $ destInfo [ 'dirname' ] ) && ! is_dir ( $ destInfo [ 'dirname' ] ) ) { if ( ! mkdir ( $ destInfo [ 'dirname' ] , 0777 , true ) ) { return false ; } } return copy ( $ source , $ destination ) ; } if ( $ recursive == true ) { if ( ! is_dir ( $ destination ) ) { mkdir ( $ destination , 0777 , true ) ; } $ dir = dir ( $ source ) ; while ( false !== $ entry = $ dir -> read ( ) ) { if ( $ entry === '.' || $ entry === '..' ) { continue ; } self :: copy ( "${source}/${entry}" , "${destination}/${entry}" , $ recursive , $ ignoreSystemFiles ) ; } $ dir -> close ( ) ; return true ; } else { return false ; } return ( bool ) $ returnValue ; }
Copy a file from source to destination may be done recursively and may ignore system files
49,140
static public function urlToPath ( $ path ) { $ path = parse_url ( $ path ) ; return $ path === null ? null : str_replace ( '/' , DIRECTORY_SEPARATOR , $ path [ 'path' ] ) ; }
Convert url to path
49,141
static public function truePath ( $ path ) { $ unipath = strlen ( $ path ) == 0 || $ path { 0 } != '/' ; if ( strpos ( $ path , ':' ) === false && $ unipath ) { $ path = getcwd ( ) . DIRECTORY_SEPARATOR . $ path ; } $ path = str_replace ( array ( '/' , '\\' ) , DIRECTORY_SEPARATOR , $ path ) ; $ parts = array_filter ( explode ( DIRECTORY_SEPARATOR , $ path ) , 'strlen' ) ; $ absolutes = array ( ) ; foreach ( $ parts as $ part ) { if ( '.' == $ part ) { continue ; } if ( '..' == $ part ) { array_pop ( $ absolutes ) ; } else { $ absolutes [ ] = $ part ; } } $ path = implode ( DIRECTORY_SEPARATOR , $ absolutes ) ; $ path = ! $ unipath ? '/' . $ path : $ path ; return $ path ; }
An alternative way to resolve the real path of a path . The resulting path might point to something non - existant on the file system contrary to PHP s realpath function .
49,142
static public function sanitizeInjectively ( $ string ) { $ sanitized = '' ; foreach ( str_split ( $ string ) as $ char ) { $ sanitized .= isset ( self :: $ ALLOWED_CHARACTERS [ $ char ] ) ? $ char : '=' . base64_encode ( $ char ) ; } return $ sanitized ; }
Sanitize a string using an injective function to prevent collisions
49,143
static public function createFileName ( $ originalName ) { $ returnValue = uniqid ( hash ( 'crc32' , $ originalName ) ) ; $ ext = @ pathinfo ( $ originalName , PATHINFO_EXTENSION ) ; if ( ! empty ( $ ext ) ) { $ returnValue .= '.' . $ ext ; } return $ returnValue ; }
Create a unique file name on basis of the original one .
49,144
public function getInstalledExtensionsIds ( ) { $ installData = $ this -> getExtensionById ( 'generis' ) -> getConfig ( self :: EXTENSIONS_CONFIG_KEY ) ; return is_array ( $ installData ) ? array_keys ( $ installData ) : array ( ) ; }
Get list of ids of installed extensions
49,145
public function getInstalledExtensions ( ) { $ returnValue = array ( ) ; foreach ( $ this -> getInstalledExtensionsIds ( ) as $ extId ) { $ returnValue [ $ extId ] = $ this -> getExtensionById ( $ extId ) ; } return $ returnValue ; }
Get the set of currently installed extensions . This method returns an array of common_ext_Extension .
49,146
public function loadExtensions ( ) { foreach ( $ this -> extensions as $ extension ) { foreach ( $ extension -> getManifest ( ) -> getDependencies ( ) as $ ext => $ version ) { if ( ! array_key_exists ( $ ext , $ this -> extensions ) && $ ext != 'generis' ) { throw new common_ext_ExtensionException ( 'Required Extension is Missing : ' . $ ext ) ; } } $ extension -> load ( ) ; } }
Load all extensions that have to be loaded
49,147
public function getAvailableExtensions ( ) { $ returnValue = array ( ) ; $ dir = new DirectoryIterator ( ROOT_PATH ) ; foreach ( $ dir as $ fileinfo ) { if ( $ fileinfo -> isDir ( ) && ! $ fileinfo -> isDot ( ) && substr ( $ fileinfo -> getBasename ( ) , 0 , 1 ) != '.' ) { $ extId = $ fileinfo -> getBasename ( ) ; if ( ! in_array ( $ extId , self :: $ RESERVED_WORDS ) && ! $ this -> isInstalled ( $ extId ) ) { try { $ ext = $ this -> getExtensionById ( $ extId ) ; $ returnValue [ ] = $ ext ; } catch ( common_ext_ExtensionException $ exception ) { common_Logger :: d ( $ extId . ' is not an extension' ) ; } } } } return $ returnValue ; }
Call a service to retrieve list of extensions that may be installed . This method returns an array of common_ext_Extension .
49,148
public function getModelsToLoad ( ) { $ returnValue = array ( ) ; foreach ( $ this -> getEnabledExtensions ( ) as $ ext ) { $ returnValue = array_merge ( $ returnValue , $ ext -> getManifest ( ) -> getModels ( ) ) ; } $ returnValue = array_unique ( $ returnValue ) ; return ( array ) $ returnValue ; }
Short description of method getModelsToLoad
49,149
public function getEnabledExtensions ( ) { $ returnValue = array ( ) ; $ enabled = $ this -> getExtensionById ( 'generis' ) -> getConfig ( self :: EXTENSIONS_CONFIG_KEY ) ; foreach ( $ this -> getInstalledExtensions ( ) as $ ext ) { if ( isset ( $ enabled [ $ ext -> getId ( ) ] ) && $ enabled [ $ ext -> getId ( ) ] [ 'enabled' ] ) { $ returnValue [ $ ext -> getId ( ) ] = $ ext ; } } return ( array ) $ returnValue ; }
Get the set of currently enabled extensions . This method returns an array of common_ext_Extension .
49,150
public function registerExtension ( common_ext_Extension $ extension ) { $ entry = array ( 'installed' => $ extension -> getManifest ( ) -> getVersion ( ) , 'enabled' => false ) ; $ extensions = $ this -> getExtensionById ( 'generis' ) -> getConfig ( self :: EXTENSIONS_CONFIG_KEY ) ; $ extensions [ $ extension -> getId ( ) ] = $ entry ; return $ this -> getExtensionById ( 'generis' ) -> setConfig ( self :: EXTENSIONS_CONFIG_KEY , $ extensions ) ; }
Add the end of an installation register the new extension
49,151
public function unregisterExtension ( common_ext_Extension $ extension ) { $ extensions = $ this -> getExtensionById ( 'generis' ) -> getConfig ( self :: EXTENSIONS_CONFIG_KEY ) ; unset ( $ extensions [ $ extension -> getId ( ) ] ) ; $ this -> getExtensionById ( 'generis' ) -> setConfig ( self :: EXTENSIONS_CONFIG_KEY , $ extensions ) ; }
Add the end of an uninstallation unregister the extension
49,152
public static function addPersistence ( $ persistenceId , array $ persistenceConf ) { $ manager = self :: getDefaultManager ( ) ; $ configs = $ manager -> getOption ( self :: OPTION_PERSISTENCES ) ; $ configs [ $ persistenceId ] = $ persistenceConf ; $ manager -> setOption ( self :: OPTION_PERSISTENCES , $ configs ) ; $ manager -> getServiceManager ( ) -> register ( self :: SERVICE_ID , $ manager ) ; }
Add a new persistence to the system
49,153
public function setSubClassOf ( core_kernel_classes_Class $ resource , core_kernel_classes_Class $ iClass ) { $ returnValue = ( bool ) false ; $ subClassOf = new core_kernel_classes_Property ( OntologyRdfs :: RDFS_SUBCLASSOF ) ; $ returnValue = $ this -> setPropertyValue ( $ resource , $ subClassOf , $ iClass -> getUri ( ) ) ; return ( bool ) $ returnValue ; }
Short description of method setSubClassOf
49,154
public static function createConst ( $ constant ) { $ returnValue = null ; $ termConstClass = new core_kernel_classes_Class ( RulesRdf :: CLASS_TERM_CONST , __METHOD__ ) ; $ termValueProperty = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_TERM_VALUE , __METHOD__ ) ; $ logicalOperatorProperty = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_HASLOGICALOPERATOR , __METHOD__ ) ; $ terminalExpressionProperty = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_TERMINAL_EXPRESSION , __METHOD__ ) ; $ label = 'Def Term Constant Label : ' . $ constant ; $ comment = 'Def Term Constant Comment : ' . $ constant ; $ constantResource = core_kernel_classes_ResourceFactory :: create ( $ termConstClass , $ label , $ comment ) ; $ returnValue = new core_kernel_rules_Term ( $ constantResource -> getUri ( ) ) ; $ returnValue -> setPropertyValue ( $ terminalExpressionProperty , $ returnValue -> getUri ( ) ) ; $ returnValue -> setPropertyValue ( $ logicalOperatorProperty , RulesRdf :: INSTANCE_EXISTS_OPERATOR_URI ) ; $ returnValue -> setPropertyValue ( $ termValueProperty , $ constant ) ; $ returnValue -> debug = __METHOD__ ; return $ returnValue ; }
Short description of method createConst
49,155
public static function createSPX ( core_kernel_classes_Resource $ subject , core_kernel_classes_Property $ predicate ) { $ returnValue = null ; $ termSPXClass = new core_kernel_classes_Class ( RulesRdf :: CLASS_TERM_SUJET_PREDICATE_X , __METHOD__ ) ; $ label = 'Def Term SPX Label : ' . $ subject -> getLabel ( ) . ' - ' . $ predicate -> getLabel ( ) ; $ comment = 'Def Term SPX Label : ' . $ subject -> getUri ( ) . ' ' . $ predicate -> getUri ( ) ; $ SPXResource = core_kernel_classes_ResourceFactory :: create ( $ termSPXClass , $ label , $ comment ) ; $ returnValue = new core_kernel_rules_Term ( $ SPXResource -> getUri ( ) ) ; $ subjectProperty = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_TERM_SPX_SUBJET , __METHOD__ ) ; $ predicateProperty = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_TERM_SPX_PREDICATE , __METHOD__ ) ; $ returnValue -> setPropertyValue ( $ subjectProperty , $ subject -> getUri ( ) ) ; $ returnValue -> setPropertyValue ( $ predicateProperty , $ predicate -> getUri ( ) ) ; return $ returnValue ; }
Short description of method createSPX
49,156
public function migrateFiles ( ) { $ fileResources = $ this -> getFileResourceData ( ) ; foreach ( $ fileResources as $ fileResourceData ) { $ resourceUri = $ fileResourceData [ 'fileResource' ] -> getUri ( ) ; if ( ! isset ( $ fileResourceData [ 'property' ] ) ) { $ this -> failedResources [ $ resourceUri ] [ ] = 'Unable to find property' ; continue ; } if ( ! isset ( $ fileResourceData [ 'subject' ] ) ) { $ this -> failedResources [ $ resourceUri ] [ ] = 'Unable to find subject' ; continue ; } ++ $ this -> migrationInformation [ 'old_resource_count' ] ; $ this -> migrateResource ( $ fileResourceData [ 'fileResource' ] , $ fileResourceData [ 'property' ] , $ fileResourceData [ 'subject' ] ) ; } }
Get the file resources and migrate them .
49,157
public function migrateResource ( core_kernel_classes_Resource $ fileResource , core_kernel_classes_Property $ property , core_kernel_classes_Resource $ subject ) { $ unserializedFileResource = $ this -> getResourceFileSerializer ( ) -> unserialize ( $ fileResource ) ; $ migratedValue = $ this -> getUrlFileSerializer ( ) -> serialize ( $ unserializedFileResource ) ; if ( $ this -> isWetRun ) { $ subject -> editPropertyValues ( $ property , $ migratedValue ) ; $ fileResource -> delete ( ) ; } ++ $ this -> migrationInformation [ 'migrated_count' ] ; }
Migrate a single resource .
49,158
private function getUrlFileSerializer ( ) { if ( $ this -> urlFileSerializer === null ) { $ this -> urlFileSerializer = new UrlFileSerializer ( ) ; $ this -> urlFileSerializer -> setServiceLocator ( $ this -> getServiceLocator ( ) ) ; } return $ this -> urlFileSerializer ; }
Get the URL file serializer
49,159
private function getResourceFileSerializer ( ) { if ( $ this -> resourceFileSerializer === null ) { $ this -> resourceFileSerializer = new ResourceFileSerializer ( ) ; $ this -> resourceFileSerializer -> setServiceLocator ( $ this -> getServiceLocator ( ) ) ; } return $ this -> resourceFileSerializer ; }
Get the Resource file serializer
49,160
public function getRoles ( ) { $ returnValue = array ( ) ; if ( ! $ this -> roles ) { foreach ( $ this -> getPropertyValues ( GenerisRdf :: PROPERTY_USER_ROLES ) as $ roleUri ) { $ returnValue [ ] = $ roleUri ; foreach ( core_kernel_users_Service :: singleton ( ) -> getIncludedRoles ( new core_kernel_classes_Resource ( $ roleUri ) ) as $ role ) { $ returnValue [ ] = $ role -> getUri ( ) ; } } $ returnValue = array_unique ( $ returnValue ) ; $ this -> roles = $ returnValue ; } return $ this -> roles ; }
Extends the users explizit roles with the implizit rules of the local system
49,161
public function total ( ) { if ( is_null ( $ this -> totalCount ) ) { $ cpt = $ this -> getParent ( ) -> fetchQuery ( $ this -> countQuery ) ; $ this -> totalCount = intval ( $ cpt [ 'cpt' ] ) ; } return $ this -> totalCount ; }
return total number of result
49,162
public function getSuccessors ( ) { $ returnValue = array ( ) ; $ reflection = new ReflectionClass ( $ this ) ; foreach ( $ reflection -> getProperties ( ) as $ property ) { if ( ! $ property -> isStatic ( ) && ! $ property -> isPrivate ( ) ) { $ propertyName = $ property -> getName ( ) ; $ value = $ this -> $ propertyName ; if ( is_array ( $ value ) ) { foreach ( $ value as $ key => $ subvalue ) { if ( is_object ( $ subvalue ) && $ subvalue instanceof self ) { $ returnValue [ ] = $ subvalue ; } } } elseif ( is_object ( $ value ) && $ value instanceof self ) { $ returnValue [ ] = $ value ; } } } return ( array ) $ returnValue ; }
Short description of method getSuccessors
49,163
public function getPredecessors ( $ classFilter = null ) { $ returnValue = array ( ) ; foreach ( $ this -> getCache ( ) -> getAll ( ) as $ serial => $ instance ) { if ( ( $ classFilter == null || $ instance instanceof $ classFilter ) && in_array ( $ this , $ instance -> getSuccessors ( ) ) ) { $ returnValue [ ] = $ instance ; break ; } } return ( array ) $ returnValue ; }
Short description of method getPredecessors
49,164
public function set ( $ id , $ value ) { $ map = $ this -> getMap ( ) ; $ map [ $ id ] = $ value ; $ this -> setConfig ( $ map ) ; }
Add a value to the config with given id
49,165
public static function createTerminalExpression ( core_kernel_rules_Term $ term ) { $ returnValue = null ; if ( $ term == null ) { var_dump ( $ term ) ; throw new common_Exception ( 'paramaters could not be null' ) ; } $ expressionClass = new core_kernel_classes_Class ( RulesRdf :: CLASS_URI_EXPRESSION , __METHOD__ ) ; $ label = 'Terminal Expression : ' . $ term -> getLabel ( ) ; $ comment = 'Terminal Expression : ' . $ term -> getUri ( ) ; $ expressionInst = core_kernel_classes_ResourceFactory :: create ( $ expressionClass , $ label , $ comment ) ; $ terminalExpressionProperty = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_TERMINAL_EXPRESSION , __METHOD__ ) ; $ returnValue = new core_kernel_rules_Expression ( $ expressionInst -> getUri ( ) ) ; $ returnValue -> setPropertyValue ( $ terminalExpressionProperty , $ term -> getUri ( ) ) ; $ returnValue -> debug = __METHOD__ ; return $ returnValue ; }
Short description of method createTerminalExpression
49,166
public static function createRecursiveExpression ( core_kernel_rules_Expression $ exp1 , core_kernel_rules_Expression $ exp2 , core_kernel_classes_Resource $ operator ) { $ returnValue = null ; if ( $ exp1 == null || $ exp2 == null || $ operator == null ) { var_dump ( $ exp1 , $ exp2 , $ operator ) ; throw new common_Exception ( 'paramaters could not be null' ) ; } $ expressionClass = new core_kernel_classes_Class ( RulesRdf :: CLASS_URI_EXPRESSION , __METHOD__ ) ; $ label = 'Expression : ' . $ exp1 -> getLabel ( ) . ' ' . $ operator -> getLabel ( ) . ' ' . $ exp2 -> getLabel ( ) ; $ comment = 'Expression : ' . $ exp1 -> getUri ( ) . ' ' . $ operator -> getUri ( ) . ' ' . $ exp2 -> getUri ( ) ; $ expressionInst = core_kernel_classes_ResourceFactory :: create ( $ expressionClass , $ label , $ comment ) ; $ terminalExpressionProperty = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_TERMINAL_EXPRESSION , __METHOD__ ) ; $ logicalOperatorProperty = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_HASLOGICALOPERATOR , __METHOD__ ) ; $ firstExpressionProperty = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_FIRST_EXPRESSION , __METHOD__ ) ; $ secondExpressionProperty = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_SECOND_EXPRESSION , __METHOD__ ) ; $ returnValue = new core_kernel_rules_Expression ( $ expressionInst -> getUri ( ) ) ; $ returnValue -> debug = __METHOD__ ; $ returnValue -> setPropertyValue ( $ terminalExpressionProperty , RulesRdf :: INSTANCE_EMPTY_TERM_URI ) ; $ returnValue -> setPropertyValue ( $ firstExpressionProperty , $ exp1 -> getUri ( ) ) ; $ returnValue -> setPropertyValue ( $ secondExpressionProperty , $ exp2 -> getUri ( ) ) ; $ returnValue -> setPropertyValue ( $ logicalOperatorProperty , $ operator -> getUri ( ) ) ; return $ returnValue ; }
Short description of method createRecursiveExpression
49,167
public function setUriProvider ( UriProvider $ provider ) { $ this -> uriProvider = $ provider ; common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( 'generis' ) -> setConfig ( self :: CONFIG_KEY , $ provider ) ; }
Set the UriProvider in force .
49,168
public function getUriProvider ( ) { if ( is_null ( $ this -> uriProvider ) ) { $ this -> uriProvider = common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( 'generis' ) -> getConfig ( self :: CONFIG_KEY ) ; } return $ this -> uriProvider ; }
Get the UriProvider in force .
49,169
public function setTransactionIsolation ( $ level ) { if ( $ level === self :: TRANSACTION_PLATFORM_DEFAULT ) { $ level = $ this -> dbalPlatform -> getDefaultTransactionIsolationLevel ( ) ; } $ this -> dbalConnection -> setTransactionIsolation ( $ level ) ; }
Sets the transaction isolation level for the current connection .
49,170
public function commit ( ) { try { $ this -> dbalConnection -> commit ( ) ; } catch ( \ PDOException $ e ) { if ( ( $ code = $ e -> getCode ( ) ) == '40001' ) { throw new common_persistence_sql_SerializationException ( "SQL Transaction Serialization Failure. See previous exception(s) for more information." , intval ( $ code ) , $ e ) ; } else { throw $ e ; } } }
Commits the current transaction .
49,171
public function getTypes ( core_kernel_classes_Resource $ resource ) { $ returnValue = array ( ) ; $ sqlQuery = 'SELECT object FROM statements WHERE subject = ? and predicate = ?' ; $ sth = $ this -> getPersistence ( ) -> query ( $ sqlQuery , array ( $ resource -> getUri ( ) , OntologyRdf :: RDF_TYPE ) ) ; while ( $ row = $ sth -> fetch ( ) ) { $ uri = $ this -> getPersistence ( ) -> getPlatForm ( ) -> getPhpTextValue ( $ row [ 'object' ] ) ; $ returnValue [ $ uri ] = new core_kernel_classes_Class ( $ uri ) ; } return ( array ) $ returnValue ; }
returns an array of types the ressource has
49,172
public function getPropertyValues ( core_kernel_classes_Resource $ resource , core_kernel_classes_Property $ property , $ options = array ( ) ) { $ returnValue = array ( ) ; $ one = isset ( $ options [ 'one' ] ) && $ options [ 'one' ] == true ? true : false ; if ( isset ( $ options [ 'last' ] ) ) { throw new core_kernel_persistence_Exception ( 'Option \'last\' no longer supported' ) ; } $ platform = $ this -> getPersistence ( ) -> getPlatForm ( ) ; $ lang = '' ; $ defaultLg = '' ; if ( isset ( $ options [ 'lg' ] ) ) { $ lang = $ options [ 'lg' ] ; } else { $ lang = $ this -> getServiceLocator ( ) -> get ( SessionService :: SERVICE_ID ) -> getCurrentSession ( ) -> getDataLanguage ( ) ; $ default = $ this -> getServiceLocator ( ) -> get ( UserLanguageServiceInterface :: SERVICE_ID ) -> getDefaultLanguage ( ) ; $ defaultLg = ' OR l_language = ' . $ this -> getPersistence ( ) -> quote ( $ default ) ; } $ query = 'SELECT object, l_language FROM statements WHERE subject = ? AND predicate = ? AND (l_language = ? OR l_language = ' . $ this -> getPersistence ( ) -> quote ( '' ) . $ defaultLg . ') AND ' . $ this -> getModelReadSqlCondition ( ) ; if ( $ one ) { $ query .= ' ORDER BY id DESC' ; $ query = $ platform -> limitStatement ( $ query , 1 , 0 ) ; $ result = $ this -> getPersistence ( ) -> query ( $ query , array ( $ resource -> getUri ( ) , $ property -> getUri ( ) , $ lang ) ) ; } else { $ result = $ this -> getPersistence ( ) -> query ( $ query , array ( $ resource -> getUri ( ) , $ property -> getUri ( ) , $ lang ) ) ; } if ( $ result == true ) { if ( isset ( $ options [ 'lg' ] ) ) { while ( $ row = $ result -> fetch ( ) ) { $ returnValue [ ] = $ this -> getPersistence ( ) -> getPlatForm ( ) -> getPhpTextValue ( $ row [ 'object' ] ) ; } } else { $ returnValue = core_kernel_persistence_smoothsql_Utils :: filterByLanguage ( $ this -> getPersistence ( ) , $ result -> fetchAll ( ) , 'l_language' , $ lang , $ default ) ; } } return ( array ) $ returnValue ; }
Short description of method getPropertyValues
49,173
public function setPropertyValue ( core_kernel_classes_Resource $ resource , core_kernel_classes_Property $ property , $ object , $ lg = null ) { $ userId = $ this -> getServiceLocator ( ) -> get ( SessionService :: SERVICE_ID ) -> getCurrentUser ( ) -> getIdentifier ( ) ; $ object = $ object instanceof core_kernel_classes_Resource ? $ object -> getUri ( ) : ( string ) $ object ; $ platform = $ this -> getPersistence ( ) -> getPlatForm ( ) ; $ lang = "" ; if ( $ property -> isLgDependent ( ) ) { if ( $ lg != null ) { $ lang = $ lg ; } else { $ lang = $ this -> getServiceLocator ( ) -> get ( SessionService :: SERVICE_ID ) -> getCurrentSession ( ) -> getDataLanguage ( ) ; } } $ query = 'INSERT INTO statements (modelid, subject, predicate, object, l_language, author,epoch) VALUES (?, ?, ?, ?, ?, ? , ?)' ; $ returnValue = $ this -> getPersistence ( ) -> exec ( $ query , array ( $ this -> getNewTripleModelId ( ) , $ resource -> getUri ( ) , $ property -> getUri ( ) , $ object , $ lang , $ userId , $ platform -> getNowExpression ( ) ) ) ; return ( bool ) $ returnValue ; }
Short description of method setPropertyValue
49,174
public function setPropertiesValues ( core_kernel_classes_Resource $ resource , $ properties ) { $ returnValue = ( bool ) false ; if ( is_array ( $ properties ) && count ( $ properties ) > 0 ) { $ session = $ this -> getServiceLocator ( ) -> get ( SessionService :: SERVICE_ID ) -> getCurrentSession ( ) ; $ platform = $ this -> getPersistence ( ) -> getPlatForm ( ) ; $ valuesToInsert = [ ] ; foreach ( $ properties as $ propertyUri => $ value ) { $ property = new core_kernel_classes_Property ( $ propertyUri ) ; $ lang = ( $ property -> isLgDependent ( ) ? $ session -> getDataLanguage ( ) : '' ) ; $ formatedValues = [ ] ; if ( $ value instanceof core_kernel_classes_Resource ) { $ formatedValues [ ] = $ value -> getUri ( ) ; } elseif ( is_array ( $ value ) ) { foreach ( $ value as $ val ) { $ formatedValues [ ] = ( $ val instanceof core_kernel_classes_Resource ) ? $ val -> getUri ( ) : $ val ; } } else { $ formatedValues [ ] = ( $ value == null ) ? '' : $ value ; } foreach ( $ formatedValues as $ object ) { $ valuesToInsert [ ] = [ 'modelid' => $ this -> getNewTripleModelId ( ) , 'subject' => $ resource -> getUri ( ) , 'predicate' => $ property -> getUri ( ) , 'object' => $ object , 'l_language' => $ lang , 'author' => $ session -> getUser ( ) -> getIdentifier ( ) , 'epoch' => $ platform -> getNowExpression ( ) ] ; } } $ returnValue = $ this -> getPersistence ( ) -> insertMultiple ( 'statements' , $ valuesToInsert ) ; } return ( bool ) $ returnValue ; }
Short description of method setPropertiesValues
49,175
public function removePropertyValues ( core_kernel_classes_Resource $ resource , core_kernel_classes_Property $ property , $ options = array ( ) ) { $ returnValue = ( bool ) false ; $ pattern = isset ( $ options [ 'pattern' ] ) && ! is_null ( $ options [ 'pattern' ] ) ? $ options [ 'pattern' ] : null ; $ like = isset ( $ options [ 'like' ] ) && $ options [ 'like' ] == true ? true : false ; $ query = 'DELETE FROM statements WHERE subject = ? AND predicate = ?' ; $ objectType = $ this -> getPersistence ( ) -> getPlatForm ( ) -> getObjectTypeCondition ( ) ; $ conditions = array ( ) ; if ( is_string ( $ pattern ) ) { if ( ! is_null ( $ pattern ) ) { $ searchPattern = core_kernel_persistence_smoothsql_Utils :: buildSearchPattern ( $ this -> getPersistence ( ) , $ pattern , $ like ) ; $ conditions [ ] = '( ' . $ objectType . ' ' . $ searchPattern . ' )' ; } } elseif ( is_array ( $ pattern ) ) { if ( count ( $ pattern ) > 0 ) { $ multiCondition = "( " ; foreach ( $ pattern as $ i => $ patternToken ) { $ searchPattern = core_kernel_persistence_smoothsql_Utils :: buildSearchPattern ( $ this -> getPersistence ( ) , $ patternToken , $ like ) ; if ( $ i > 0 ) { $ multiCondition .= " OR " ; } $ multiCondition .= '(' . $ objectType . ' ' . $ searchPattern . ' )' ; } $ conditions [ ] = "{$multiCondition} ) " ; } } foreach ( $ conditions as $ i => $ additionalCondition ) { $ query .= " AND ( {$additionalCondition} ) " ; } $ query .= ' AND ' . $ this -> getModelWriteSqlCondition ( ) ; if ( $ property -> isLgDependent ( ) ) { $ query .= ' AND (l_language = ? OR l_language = ?) ' ; $ returnValue = $ this -> getPersistence ( ) -> exec ( $ query , array ( $ resource -> getUri ( ) , $ property -> getUri ( ) , '' , $ this -> getServiceLocator ( ) -> get ( SessionService :: SERVICE_ID ) -> getCurrentSession ( ) -> getDataLanguage ( ) ) ) ; } else { $ returnValue = $ this -> getPersistence ( ) -> exec ( $ query , array ( $ resource -> getUri ( ) , $ property -> getUri ( ) ) ) ; } if ( ! $ returnValue ) { $ returnValue = false ; } return ( bool ) $ returnValue ; }
Short description of method removePropertyValues
49,176
public function getRdfTriples ( core_kernel_classes_Resource $ resource ) { $ returnValue = null ; $ query = 'SELECT * FROM statements WHERE subject = ? AND ' . $ this -> getModelReadSqlCondition ( ) . ' ORDER BY predicate' ; $ result = $ this -> getPersistence ( ) -> query ( $ query , array ( $ resource -> getUri ( ) ) ) ; $ returnValue = new core_kernel_classes_ContainerCollection ( new common_Object ( __METHOD__ ) ) ; while ( $ statement = $ result -> fetch ( ) ) { $ triple = new core_kernel_classes_Triple ( ) ; $ triple -> modelid = $ statement [ "modelid" ] ; $ triple -> subject = $ statement [ "subject" ] ; $ triple -> predicate = $ statement [ "predicate" ] ; $ triple -> object = $ statement [ "object" ] ; $ triple -> id = $ statement [ "id" ] ; $ triple -> epoch = $ statement [ "epoch" ] ; $ triple -> lg = $ statement [ "l_language" ] ; $ triple -> author = $ statement [ "author" ] ; $ returnValue -> add ( $ triple ) ; } return $ returnValue ; }
returns the triples having as subject the current resource
49,177
public function getUsedLanguages ( core_kernel_classes_Resource $ resource , core_kernel_classes_Property $ property ) { $ returnValue = array ( ) ; $ sqlQuery = 'SELECT l_language FROM statements WHERE subject = ? AND predicate = ? ' ; $ sqlResult = $ this -> getPersistence ( ) -> query ( $ sqlQuery , array ( $ resource -> getUri ( ) , $ property -> getUri ( ) ) ) ; while ( $ row = $ sqlResult -> fetch ( ) ) { if ( ! empty ( $ row [ 'l_language' ] ) ) { $ returnValue [ ] = $ row [ 'l_language' ] ; } } return ( array ) $ returnValue ; }
Short description of method getUsedLanguages
49,178
public function duplicate ( core_kernel_classes_Resource $ resource , $ excludedProperties = array ( ) ) { $ returnValue = null ; $ newUri = common_Utils :: getNewUri ( ) ; $ collection = $ this -> getRdfTriples ( $ resource ) ; if ( $ collection -> count ( ) > 0 ) { $ platform = $ this -> getPersistence ( ) -> getPlatForm ( ) ; $ user = $ this -> getServiceLocator ( ) -> get ( SessionService :: SERVICE_ID ) -> getCurrentUser ( ) -> getIdentifier ( ) ; $ valuesToInsert = [ ] ; foreach ( $ collection -> getIterator ( ) as $ triple ) { if ( ! in_array ( $ triple -> predicate , $ excludedProperties ) ) { $ valuesToInsert [ ] = [ 'modelid' => $ this -> getNewTripleModelId ( ) , 'subject' => $ newUri , 'predicate' => $ triple -> predicate , 'object' => ( $ triple -> object == null ) ? '' : $ triple -> object , 'l_language' => ( $ triple -> lg == null ) ? '' : $ triple -> lg , 'author' => $ user , 'epoch' => $ platform -> getNowExpression ( ) ] ; } } if ( $ this -> getPersistence ( ) -> insertMultiple ( 'statements' , $ valuesToInsert ) ) { $ returnValue = new core_kernel_classes_Resource ( $ newUri ) ; } } return $ returnValue ; }
Short description of method duplicate
49,179
public static function compare ( core_kernel_classes_Container $ o1 , core_kernel_classes_Container $ o2 ) { $ returnValue = ( int ) 0 ; if ( $ o1 instanceof core_kernel_classes_Literal && $ o2 instanceof core_kernel_classes_Literal ) { $ returnValue = strcasecmp ( $ o1 -> literal , $ o2 -> literal ) ; } else if ( $ o1 instanceof core_kernel_classes_Resource && $ o2 instanceof core_kernel_classes_Resource ) { $ returnValue = strcasecmp ( $ o1 -> getUri ( ) , $ o2 -> getUri ( ) ) ; } else { throw new common_Exception ( 'try to compared not implemented type' ) ; } return ( int ) $ returnValue ; }
Short description of method compare
49,180
public static function isUri ( $ strarg ) { $ returnValue = ( bool ) false ; $ uri = trim ( $ strarg ) ; if ( ! empty ( $ uri ) ) { if ( ( preg_match ( "/^(http|https|file|ftp):\/\/[\/:.A-Za-z0-9_-]+#[A-Za-z0-9_-]+$/" , $ uri ) && strpos ( $ uri , '#' ) > 0 ) || strpos ( $ uri , "#" ) === 0 ) { $ returnValue = true ; } } return ( bool ) $ returnValue ; }
Check if the given string is a proper uri
49,181
public static function toPHPVariableString ( $ value ) { switch ( gettype ( $ value ) ) { case "string" : $ returnValue = '\'' . str_replace ( '\'' , '\\\'' , str_replace ( '\\' , '\\\\' , $ value ) ) . '\'' ; break ; case "boolean" : $ returnValue = $ value ? 'true' : 'false' ; break ; case "integer" : case "double" : $ returnValue = $ value ; break ; case "array" : $ string = "" ; foreach ( $ value as $ key => $ val ) { $ string .= self :: toPHPVariableString ( $ key ) . " => " . self :: toPHPVariableString ( $ val ) . "," ; } $ returnValue = "array(" . substr ( $ string , 0 , - 1 ) . ")" ; break ; case "NULL" : $ returnValue = 'null' ; break ; case "object" : if ( $ value instanceof PhpSerializable ) { $ returnValue = $ value -> __toPhpCode ( ) ; } else { $ returnValue = 'unserialize(' . self :: toPHPVariableString ( serialize ( $ value ) ) . ')' ; } break ; default : throw new common_exception_Error ( "Could not convert variable of type " . gettype ( $ value ) . " to PHP variable string" ) ; } return ( string ) $ returnValue ; }
Returns the php code that if evaluated would return the value provided
49,182
public static function toHumanReadablePhpString ( $ value , $ indentation = 0 ) { if ( gettype ( $ value ) == "array" ) { $ array = array_keys ( $ value ) ; $ assocArray = ( $ array !== array_keys ( $ array ) ) ; $ string = "" ; if ( $ assocArray ) { foreach ( $ value as $ key => $ val ) { $ string .= PHP_EOL . str_repeat ( ' ' , $ indentation + 1 ) . self :: toPHPVariableString ( $ key ) . " => " . self :: toHumanReadablePhpString ( $ val , $ indentation + 1 ) . "," ; } } else { foreach ( $ value as $ val ) { $ string .= PHP_EOL . str_repeat ( ' ' , $ indentation + 1 ) . self :: toHumanReadablePhpString ( $ val , $ indentation + 1 ) . "," ; } } $ returnValue = "array(" . substr ( $ string , 0 , - 1 ) . PHP_EOL . str_repeat ( ' ' , $ indentation ) . ")" ; } else { $ lines = explode ( PHP_EOL , self :: toPHPVariableString ( $ value ) ) ; $ returnValue = implode ( PHP_EOL . str_repeat ( ' ' , $ indentation ) , $ lines ) ; } return ( string ) $ returnValue ; }
Same as toPHPVariableString except the sting is easier for humans to read
49,183
public function applyFilters ( QueryBuilder $ qb ) { foreach ( $ this -> getFilters ( ) as $ filter ) { $ type = null ; $ placeholder = $ filter [ 'valuePlaceholder' ] ; if ( is_array ( $ filter [ 'value' ] ) ) { $ type = Connection :: PARAM_STR_ARRAY ; $ filter [ 'valuePlaceholder' ] = '(' . $ placeholder . ')' ; } $ qb -> andWhere ( $ filter [ 'column' ] . ' ' . $ filter [ 'operator' ] . ' ' . $ filter [ 'valuePlaceholder' ] ) -> setParameter ( $ placeholder , $ filter [ 'value' ] , $ type ) ; } return $ qb ; }
Apply the filters
49,184
protected function initFile ( ) { if ( $ this -> maxFileSize > 0 && file_exists ( $ this -> filename ) && filesize ( $ this -> filename ) >= $ this -> maxFileSize ) { $ file = file ( $ this -> filename ) ; $ file = array_splice ( $ file , ceil ( count ( $ file ) * $ this -> reduceRatio ) ) ; $ this -> filehandle = @ fopen ( $ this -> filename , 'w' ) ; foreach ( $ file as $ line ) { @ fwrite ( $ this -> filehandle , $ line ) ; } } else { $ this -> filehandle = @ fopen ( $ this -> filename , 'a' ) ; } }
Initialises the logfile and checks whenever the file require pruning
49,185
public function doLog ( common_log_Item $ item ) { if ( is_null ( $ this -> filehandle ) ) { $ this -> initFile ( ) ; } if ( $ this -> filehandle !== false ) { $ map = array ( '%d' => gmdate ( 'Y-m-d H:i:s' , $ item -> getDateTime ( ) ) , '%m' => $ item -> getDescription ( ) , '%p' => $ this -> prefix , '%s' => $ item -> getSeverityDescriptionString ( ) , '%t' => $ item -> getDateTime ( ) , '%r' => $ item -> getRequest ( ) , '%f' => $ item -> getCallerFile ( ) , '%g' => implode ( ',' , $ item -> getTags ( ) ) , '%l' => $ item -> getCallerLine ( ) ) ; if ( strpos ( $ this -> format , '%b' ) ) { $ map [ '%b' ] = 'Backtrace not yet supported' ; } $ str = strtr ( $ this -> format , $ map ) . PHP_EOL ; @ fwrite ( $ this -> filehandle , $ str ) ; } }
Prepares and saves log entries to file
49,186
public function incr ( $ id ) { $ params = [ ':id' => $ id ] ; $ statement = 'UPDATE kv_store SET kv_value = kv_value + 1 WHERE kv_id = :id' ; return $ this -> sqlPeristence -> exec ( $ statement , $ params ) ; }
Increment existing value
49,187
public function decr ( $ id ) { $ params = [ ':id' => $ id ] ; $ statement = 'UPDATE kv_store SET kv_value = kv_value - 1 WHERE kv_id = :id' ; return $ this -> sqlPeristence -> exec ( $ statement , $ params ) ; }
Decrement existing value
49,188
public function install ( ) { $ this -> log ( 'i' , 'Installing extension ' . $ this -> extension -> getId ( ) ) ; if ( $ this -> extension -> getId ( ) == 'generis' ) { throw new common_ext_ForbiddenActionException ( 'Tried to install generis using the ExtensionInstaller' , $ this -> extension -> getId ( ) ) ; } if ( common_ext_ExtensionsManager :: singleton ( ) -> isInstalled ( $ this -> extension -> getId ( ) ) ) { throw new common_ext_AlreadyInstalledException ( 'Problem installing extension ' . $ this -> extension -> getId ( ) . ' : Already installed' , $ this -> extension -> getId ( ) ) ; } $ this -> log ( 'd' , 'Purging cache...' ) ; $ cache = common_cache_FileCache :: singleton ( ) ; $ cache -> purge ( ) ; helpers_ExtensionHelper :: checkRequiredExtensions ( $ this -> getExtension ( ) ) ; $ this -> installLoadDefaultConfig ( ) ; $ this -> installOntology ( ) ; $ this -> installRegisterExt ( ) ; $ this -> log ( 'd' , 'Installing custom script for extension ' . $ this -> extension -> getId ( ) ) ; $ this -> installCustomScript ( ) ; $ this -> log ( 'd' , 'Done installing custom script for extension ' . $ this -> extension -> getId ( ) ) ; if ( $ this -> getLocalData ( ) == true ) { $ this -> log ( 'd' , 'Installing local data for extension ' . $ this -> extension -> getId ( ) ) ; $ this -> installLocalData ( ) ; $ this -> log ( 'd' , 'Done installing local data for extension ' . $ this -> extension -> getId ( ) ) ; } $ this -> log ( 'd' , 'Extended install for extension ' . $ this -> extension -> getId ( ) ) ; $ this -> extendedInstall ( ) ; $ this -> log ( 'd' , 'Done extended install for extension ' . $ this -> extension -> getId ( ) ) ; $ eventManager = ServiceManager :: getServiceManager ( ) -> get ( EventManager :: CONFIG_ID ) ; $ eventManager -> trigger ( new common_ext_event_ExtensionInstalled ( $ this -> extension ) ) ; }
install an extension
49,189
protected function installLoadDefaultConfig ( ) { $ defaultsPath = $ this -> extension -> getDir ( ) . 'config/default' ; if ( is_dir ( $ defaultsPath ) ) { $ defaultIterator = new DirectoryIterator ( $ defaultsPath ) ; foreach ( $ defaultIterator as $ fileinfo ) { if ( ! $ fileinfo -> isDot ( ) && strpos ( $ fileinfo -> getFilename ( ) , '.conf.php' ) > 0 ) { $ confKey = substr ( $ fileinfo -> getFilename ( ) , 0 , - strlen ( '.conf.php' ) ) ; if ( ! $ this -> extension -> hasConfig ( $ confKey ) ) { $ config = include $ fileinfo -> getPathname ( ) ; if ( $ config instanceof ConfigurableService ) { $ this -> getServiceManager ( ) -> register ( $ this -> extension -> getId ( ) . '/' . $ confKey , $ config ) ; } else { $ this -> extension -> setConfig ( $ confKey , $ config ) ; } $ this -> extension -> setConfig ( $ confKey , $ config ) ; } } } } }
writes the config based on the config . sample
49,190
protected function installOntology ( ) { helpers_TimeOutHelper :: setTimeOutLimit ( helpers_TimeOutHelper :: MEDIUM ) ; $ rdf = ModelManager :: getModel ( ) -> getRdfInterface ( ) ; foreach ( $ this -> getExtensionModel ( ) as $ triple ) { $ rdf -> add ( $ triple ) ; } helpers_TimeOutHelper :: reset ( ) ; }
inserts the datamodels specified in the Manifest
49,191
protected function installRegisterExt ( ) { $ this -> log ( 'd' , 'Registering extension ' . $ this -> extension -> getId ( ) ) ; common_ext_ExtensionsManager :: singleton ( ) -> registerExtension ( $ this -> extension ) ; common_ext_ExtensionsManager :: singleton ( ) -> setEnabled ( $ this -> extension -> getId ( ) ) ; }
Registers the Extension with the extensionManager
49,192
protected function installCustomScript ( ) { foreach ( $ this -> extension -> getManifest ( ) -> getInstallPHPFiles ( ) as $ script ) { if ( is_string ( $ script ) ) { $ this -> runExtensionScript ( $ script ) ; } elseif ( is_array ( $ script ) && isset ( $ script [ 0 ] ) && is_string ( $ script [ 0 ] ) && ! empty ( $ script [ 0 ] ) && isset ( $ script [ 1 ] ) && is_array ( $ script [ 1 ] ) ) { $ this -> runExtensionScript ( $ script [ 0 ] , $ script [ 1 ] ) ; } else { \ common_Logger :: w ( "Ignored custom install script because it's call definition is malformed in extension manifest!" ) ; } } }
Install Custom Scripts
49,193
protected function installLocalData ( ) { $ localData = $ this -> extension -> getManifest ( ) -> getLocalData ( ) ; if ( isset ( $ localData [ 'php' ] ) ) { $ scripts = $ localData [ 'php' ] ; $ scripts = is_array ( $ scripts ) ? $ scripts : array ( $ scripts ) ; foreach ( $ scripts as $ script ) { $ this -> runExtensionScript ( $ script ) ; } } }
Installs example files and other non essential content
49,194
private function isTheClassSkippable ( array $ trace ) { if ( $ this -> skipLoggerClasses === false ) { return false ; } if ( empty ( $ trace [ 'class' ] ) ) { return false ; } foreach ( $ this -> classKeywordsToSkip as $ current ) { if ( strpos ( $ trace [ 'class' ] , $ current ) !== false ) { return true ; } } return false ; }
Returns TRUE if the given trace is skippable .
49,195
public function hasDirectory ( $ id ) { $ fsConfig = $ this -> getOption ( self :: OPTION_ADAPTERS ) ; return isset ( $ fsConfig [ $ id ] ) ; }
Returns whenever or not a FS exists
49,196
public function getFileSystem ( $ id ) { if ( ! isset ( $ this -> filesystems [ $ id ] ) ) { $ this -> filesystems [ $ id ] = new FileSystem ( $ id , $ this -> getFlysystemAdapter ( $ id ) ) ; } return $ this -> filesystems [ $ id ] ; }
Get FileSystem by ID
49,197
public function createLocalFileSystem ( $ id ) { $ path = $ this -> getOption ( self :: OPTION_FILE_PATH ) . \ helpers_File :: sanitizeInjectively ( $ id ) ; $ this -> registerLocalFileSystem ( $ id , $ path ) ; return $ this -> getFileSystem ( $ id ) ; }
Create a new local file system
49,198
public function registerLocalFileSystem ( $ id , $ path ) { $ adapters = $ this -> hasOption ( self :: OPTION_ADAPTERS ) ? $ this -> getOption ( self :: OPTION_ADAPTERS ) : array ( ) ; $ adapters [ $ id ] = array ( 'class' => self :: FLYSYSTEM_LOCAL_ADAPTER , 'options' => array ( 'root' => $ path ) ) ; $ this -> setOption ( self :: OPTION_ADAPTERS , $ adapters ) ; return true ; }
Registers a local file system used for transition
49,199
public function unregisterFileSystem ( $ id ) { $ adapters = $ this -> getOption ( self :: OPTION_ADAPTERS ) ; if ( isset ( $ adapters [ $ id ] ) ) { unset ( $ adapters [ $ id ] ) ; if ( isset ( $ this -> filesystems [ $ id ] ) ) { unset ( $ this -> filesystems [ $ id ] ) ; } $ this -> setOption ( self :: OPTION_ADAPTERS , $ adapters ) ; return true ; } else { return false ; } }
Remove a filesystem adapter