idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
54,100
public function search ( ) { $ params = $ this -> getRequestParameter ( 'params' ) ; $ query = $ params [ 'query' ] ; $ class = $ this -> getClass ( $ params [ 'rootNode' ] ) ; $ rows = $ this -> hasRequestParameter ( 'rows' ) ? ( int ) $ this -> getRequestParameter ( 'rows' ) : null ; $ page = $ this -> hasRequestPara...
Search results The search is paginated and initiated by the datatable component .
54,101
public function create ( $ type ) { $ typeOptions = $ this -> getOption ( self :: OPTION_MAPPERS ) ; $ typeOption = isset ( $ typeOptions [ $ type ] ) ? $ typeOptions [ $ type ] : $ this -> throwException ( ) ; $ importerString = isset ( $ typeOption [ self :: OPTION_MAPPERS_IMPORTER ] ) ? $ typeOption [ self :: OPTION...
Create an importer
54,102
public function insertSuperUser ( array $ userData ) { if ( empty ( $ userData [ 'login' ] ) || empty ( $ userData [ 'password' ] ) ) { throw new tao_install_utils_Exception ( "To create a super user you must provide at least a login and a password" ) ; } $ superUserOntology = dirname ( __FILE__ ) . "/../ontology/super...
Specifiq method to insert the super user model by using a template RDF file
54,103
public function getLanguageModels ( ) { $ models = array ( ) ; $ ns = $ this -> localNs ; $ extensionPath = dirname ( __FILE__ ) . '/../../../tao' ; $ localesPath = $ extensionPath . '/locales' ; if ( @ is_dir ( $ localesPath ) && @ is_readable ( $ localesPath ) ) { $ localeDirectories = scandir ( $ localesPath ) ; for...
Convenience method that returns available language descriptions to be inserted in the knowledge base .
54,104
public function getResources ( \ core_kernel_classes_Class $ rootClass , array $ selectedUris = [ ] , array $ propertyFilters = [ ] , $ offset = 0 , $ limit = 30 ) { if ( count ( $ propertyFilters ) == 1 && isset ( $ propertyFilters [ OntologyRdfs :: RDFS_LABEL ] ) ) { $ searchString = current ( $ propertyFilters ) ; r...
Retrieve Resources for the given parameters as a list
54,105
private function searchByString ( $ searchString , $ rootClass , $ offset , $ limit ) { $ searchService = $ this -> getServiceLocator ( ) -> get ( Search :: SERVICE_ID ) ; $ result = $ searchService -> query ( $ searchString , $ rootClass , $ offset , $ limit ) ; $ count = $ result -> getTotalCount ( ) ; return $ this ...
Search using an advanced search string
54,106
private function searchByProperties ( $ propertyFilters , $ rootClass , $ offset , $ limit ) { $ options = [ 'recursive' => true , 'like' => true , 'limit' => $ limit , 'offset' => $ offset ] ; $ count = $ rootClass -> countInstances ( $ propertyFilters , $ options ) ; $ resources = $ rootClass -> searchInstances ( $ p...
Search using properties
54,107
private function format ( $ result , $ count , $ offset , $ limit ) { $ nodes = [ ] ; foreach ( $ result as $ item ) { $ resource = $ this -> getResource ( $ item ) ; $ data = $ this -> getResourceData ( $ resource ) ; if ( $ data ) { $ nodes [ ] = $ data ; } } return [ 'total' => $ count , 'offset' => $ offset , 'limi...
Format the results according to the needs of ListLookup
54,108
private function getResourceData ( $ resource ) { $ data = false ; if ( ! is_null ( $ resource ) && $ resource -> exists ( ) ) { $ resourceTypes = array_keys ( $ resource -> getTypes ( ) ) ; $ data = [ 'uri' => $ resource -> getUri ( ) , 'classUri' => $ resourceTypes [ 0 ] , 'label' => $ resource -> getLabel ( ) , 'typ...
Preparing resource to be used in the ListLookup
54,109
protected function getReferencedFile ( $ serial ) { try { $ file = $ this -> getFileReferenceSerializer ( ) -> unserialize ( $ serial ) ; if ( $ file instanceof File && $ file -> exists ( ) ) { return $ file ; } } catch ( \ Exception $ e ) { } return null ; }
Tries to get the referenced file if it exists .
54,110
private function getCurrentExporter ( ) { if ( $ this -> hasRequestParameter ( 'exportHandler' ) ) { $ exportHandler = $ _REQUEST [ 'exportHandler' ] ; if ( class_exists ( $ exportHandler ) && in_array ( 'tao_models_classes_export_ExportHandler' , class_implements ( $ exportHandler ) ) ) { return new $ exportHandler ( ...
Returns the selected ExportHandler
54,111
protected function composeView ( $ scope = '' , $ data = array ( ) , $ template = '' , $ extension = '' ) { if ( ! is_array ( $ data ) ) { $ data = [ ] ; } if ( isset ( $ _SERVER [ 'HTTP_ACCEPT' ] ) && strpos ( $ _SERVER [ 'HTTP_ACCEPT' ] , 'application/json' ) !== false ) { $ this -> returnJson ( [ 'success' => true ,...
Main method to render a view using a particular template . Detects whether the client only need JSON content . You still need to set the main view however it must be set before to call this method as this view may be overridden .
54,112
protected function setPage ( $ scope = '' , $ template = '' , $ extension = '' ) { $ template = empty ( $ template ) ? 'pages/index.tpl' : $ template ; $ extension = empty ( $ extension ) ? \ Context :: getInstance ( ) -> getExtensionName ( ) : $ extension ; $ this -> defaultData ( ) ; $ this -> setData ( 'scope' , $ s...
Assigns the template to render .
54,113
public function isApplicable ( array $ params ) { $ this -> setOutputColorVisibility ( $ params ) ; return $ this -> hasParameter ( $ params , '-vvv' ) || $ this -> hasParameter ( $ params , '--verbose' , 3 ) ; }
Check if params array contains targeted arguments Short and Long In case of Long check is done is following param argument
54,114
public function hasSameTranslationUnitSubject ( tao_helpers_translation_RDFTranslationUnit $ translationUnit ) { $ returnValue = ( bool ) false ; $ returnValue = $ this -> getSubject ( ) == $ translationUnit -> getSubject ( ) ; return ( bool ) $ returnValue ; }
Checks whether or not a given RDFTranslationUnit has the same subject value as the current instance .
54,115
public function hasSameTranslationUnitPredicate ( tao_helpers_translation_RDFTranslationUnit $ translationUnit ) { $ returnValue = ( bool ) false ; $ returnValue = $ this -> getPredicate ( ) == $ translationUnit -> getPredicate ( ) ; return ( bool ) $ returnValue ; }
Checks whether or not a given RDFTranslationUnit has the same predicate value as the current instance .
54,116
public function hasSameTranslationUnitSource ( tao_helpers_translation_TranslationUnit $ translationUnit ) { $ returnValue = ( bool ) false ; $ returnValue = $ this -> hasSameTranslationUnitPredicate ( $ translationUnit ) && $ this -> hasSameTranslationUnitSubject ( $ translationUnit ) && $ this -> hasSameTranslationUn...
Checks wether or not that the current translation unit has the same than another one . For RDFTranslationUnits we consider that two units have the same source if their source subject predicate and target are identical .
54,117
public function getAll ( ) { if ( $ this -> isRequestGet ( ) ) { try { $ class = $ this -> getClassParameter ( ) ; $ classes = $ this -> getResourceService ( ) -> getAllClasses ( $ class ) ; $ this -> returnSuccess ( [ $ classes ] ) ; } catch ( common_Exception $ e ) { $ this -> returnFailure ( $ e ) ; } } else { $ thi...
Get all the classes that belong to a subclass .
54,118
public function call ( RequestInterface $ request , array $ clientOptions = [ ] ) { return ( new Client ( $ clientOptions ) ) -> send ( $ request , [ 'auth' => $ this -> getCredentials ( ) , 'verify' => false ] ) ; }
Call a request through basic client
54,119
protected function loadCredentials ( ) { $ instance = $ this -> getInstance ( ) ; if ( $ instance && $ instance -> exists ( ) ) { $ props = $ instance -> getPropertiesValues ( [ $ this -> getProperty ( self :: PROPERTY_LOGIN ) , $ this -> getProperty ( self :: PROPERTY_PASSWORD ) ] ) ; $ data = [ self :: PROPERTY_LOGIN...
Fetch the credentials for the current resource .
54,120
public function run ( ) { $ this -> logDebug ( 'Starting Task.' ) ; try { return $ this -> processTask ( $ this -> task ) ; } catch ( \ Exception $ e ) { $ this -> logError ( 'Error processing task ' . $ e -> getMessage ( ) ) ; } $ this -> logDebug ( 'Task finished.' ) ; return TaskLogInterface :: STATUS_FAILED ; }
Start processing tasks from a given queue
54,121
public function denied ( ) { $ accepts = explode ( ',' , $ this -> getRequest ( ) -> getHeader ( 'Accept' ) ) ; if ( array_search ( 'application/json' , $ accepts ) !== false || array_search ( 'text/javascript' , $ accepts ) !== false ) { $ this -> returnJson ( array ( 'error' => __ ( "You do not have the required righ...
Access to resource id denied
54,122
private function getStreamHash ( $ stream , $ hash = 'md5' ) { $ hc = hash_init ( $ hash ) ; hash_update_stream ( $ hc , $ stream ) ; return hash_final ( $ hc ) ; }
Calculates hash for given stream
54,123
protected function getThemeIdFromThemeDetailsProviders ( ) { $ providers = $ this -> getThemeDetailsProviders ( ) ; foreach ( $ providers as $ provider ) { if ( $ provider instanceof ThemeDetailsProviderInterface ) { $ themeId = $ provider -> getThemeId ( ) ; if ( ! empty ( $ themeId ) && $ themeId !== ' ' ) { if ( $ t...
Returns the theme id provided by the themeDetailsProviders .
54,124
protected function getUniqueId ( Theme $ theme ) { $ baseId = $ theme -> getId ( ) ; $ idNumber = 0 ; while ( $ this -> hasTheme ( $ baseId . $ idNumber ) ) { $ idNumber ++ ; } return $ baseId . $ idNumber ; }
Returns the unique identifier .
54,125
protected function getIsHeadlessFromThemeDetailsProviders ( ) { $ providers = $ this -> getThemeDetailsProviders ( ) ; foreach ( $ providers as $ provider ) { if ( $ provider instanceof ThemeDetailsProviderInterface ) { $ isHeadless = $ provider -> isHeadless ( ) ; if ( ! empty ( $ isHeadless ) ) { return $ isHeadless ...
Returns the isHeadless details provided by the themeDetailsProviders .
54,126
public function create ( ) { if ( $ this -> isRequestGet ( ) ) { try { $ this -> returnSuccess ( $ this -> getForm ( $ this -> getClassParameter ( ) ) -> getData ( ) ) ; } catch ( common_Exception $ e ) { $ this -> returnFailure ( $ e ) ; } } elseif ( $ this -> isRequestPost ( ) ) { try { $ this -> processForm ( $ this...
Create a resource for class found into http request parameters
54,127
public function edit ( ) { if ( $ this -> isRequestGet ( ) ) { try { $ this -> returnSuccess ( $ this -> getForm ( $ this -> getResourceParameter ( ) ) -> getData ( ) ) ; } catch ( common_Exception $ e ) { $ this -> returnFailure ( $ e ) ; } } if ( $ this -> isRequestPost ( ) ) { try { $ this -> processForm ( $ this ->...
Edit a resource found into http request parameters
54,128
public function getAll ( ) { if ( $ this -> isRequestGet ( ) ) { try { $ format = $ this -> getRequestParameter ( 'format' ) ; $ search = $ this -> hasRequestParameter ( 'search' ) ? $ this -> getRawParameter ( 'search' ) : '' ; $ limit = $ this -> hasRequestParameter ( 'limit' ) ? $ this -> getRequestParameter ( 'limi...
Get all resources belonging to a given class . The result is paginated and structured based on the given format . The result can be filtered or target a given selection .
54,129
protected function processForm ( $ instance ) { $ parameters = $ this -> getRequestParameters ( ) ; $ form = $ this -> getForm ( $ instance ) -> bind ( $ parameters ) ; $ report = $ form -> validate ( ) ; if ( $ report -> containsError ( ) ) { $ this -> returnValidationFailure ( $ report ) ; } else { $ resource = $ for...
Process the form submission Bind the http data to form validate and save
54,130
protected function getResourceParameter ( ) { if ( ! $ this -> hasRequestParameter ( self :: RESOURCE_PARAMETER ) ) { throw new \ common_exception_MissingParameter ( self :: RESOURCE_PARAMETER , __CLASS__ ) ; } $ uri = $ this -> getRequestParameter ( self :: RESOURCE_PARAMETER ) ; if ( empty ( $ uri ) || ! common_Utils...
Extract the resource from http request The parameter uri must exists and be a valid uri
54,131
protected function getClassParameter ( ) { if ( ! $ this -> hasRequestParameter ( self :: CLASS_PARAMETER ) ) { throw new \ common_exception_MissingParameter ( self :: CLASS_PARAMETER , __CLASS__ ) ; } $ uri = $ this -> getRequestParameter ( self :: CLASS_PARAMETER ) ; if ( empty ( $ uri ) || ! common_Utils :: isUri ( ...
Extract the class from http request The parameter classUri must exists and be a valid uri
54,132
protected function returnValidationFailure ( common_report_Report $ report , $ withMessage = true ) { $ data = [ 'data' => [ ] ] ; foreach ( $ report -> getErrors ( ) as $ error ) { $ data [ 'data' ] [ $ error -> getData ( ) ] = $ error -> getMessage ( ) ; } if ( $ withMessage ) { $ data [ 'success' ] = false ; $ data ...
Transform a report to http response with 422 code and report error messages
54,133
protected function returnFailure ( Exception $ exception , $ withMessage = true ) { $ data = array ( ) ; if ( $ withMessage ) { $ data [ 'success' ] = false ; $ data [ 'errorCode' ] = 500 ; $ data [ 'version' ] = TAO_VERSION ; if ( $ exception instanceof common_exception_UserReadableException ) { $ data [ 'errorMsg' ] ...
Return an error reponse following the given exception An exception handler manages http code avoid to use returnJson to add unneeded header
54,134
protected function returnSuccess ( $ rawData = array ( ) , $ withMessage = true ) { $ data = array ( ) ; if ( $ withMessage ) { $ data [ 'success' ] = true ; $ data [ 'data' ] = $ rawData ; $ data [ 'version' ] = TAO_VERSION ; } else { $ data = $ rawData ; } $ this -> returnJson ( $ data ) ; }
Return a successful http response
54,135
public function index ( ) { $ this -> defaultData ( ) ; $ formContainer = new tao_actions_form_PasswordRecovery ( ) ; $ form = $ formContainer -> getForm ( ) ; if ( $ form -> isSubmited ( ) && $ form -> isValid ( ) ) { $ mail = $ form -> getValue ( 'userMail' ) ; $ user = $ this -> getPasswordRecovery ( ) -> getUser ( ...
Show password recovery request form
54,136
public function resetPassword ( ) { $ this -> defaultData ( ) ; $ token = $ this -> getRequestParameter ( 'token' ) ; $ formContainer = new tao_actions_form_ResetUserPassword ( ) ; $ form = $ formContainer -> getForm ( ) ; $ form -> setValues ( array ( 'token' => $ token ) ) ; $ user = $ this -> getPasswordRecovery ( )...
Password resrt form
54,137
private function sendMessage ( core_kernel_classes_Resource $ user ) { try { $ messageSent = $ this -> getPasswordRecovery ( ) -> sendMail ( $ user ) ; } catch ( Exception $ e ) { $ messageSent = false ; $ this -> logWarning ( "Unsuccessful recovery password. {$e->getMessage()}." ) ; } if ( $ messageSent ) { $ mail = $...
Send message with password recovery instructions
54,138
public function addFlag ( $ flag ) { $ currentAnnotations = $ this -> getAnnotations ( ) ; if ( ! isset ( $ currentAnnotations [ self :: FLAGS ] ) ) { $ currentAnnotations [ self :: FLAGS ] = $ flag ; } else if ( ! ( mb_strpos ( $ currentAnnotations [ self :: FLAGS ] , $ flag , 0 , TAO_DEFAULT_ENCODING ) !== false ) ) ...
Add a PO compliant flag to the TranslationUnit . The FLAGS annotation will created if no flags were added before .
54,139
public function removeFlag ( $ flag ) { $ currentFlags = $ this -> getFlags ( ) ; for ( $ i = 0 ; $ i < count ( $ currentFlags ) ; $ i ++ ) { if ( $ currentFlags [ $ i ] == $ flag ) { break ; } } if ( $ i <= count ( $ currentFlags ) ) { unset ( $ currentFlags [ $ i ] ) ; $ this -> setFlags ( $ currentFlags ) ; } }
Remove a given PO compliant flag from the TranslationUnit . The FLAGS will be removed from the TranslationUnit if it was the last one of the
54,140
public function hasFlag ( $ flag ) { $ returnValue = ( bool ) false ; foreach ( $ this -> getFlags ( ) as $ f ) { if ( $ f == $ flag ) { $ returnValue = true ; break ; } } return ( bool ) $ returnValue ; }
Short description of method hasFlag
54,141
public function getFlags ( ) { $ returnValue = array ( ) ; $ currentAnnotations = $ this -> getAnnotations ( ) ; if ( isset ( $ currentAnnotations [ self :: FLAGS ] ) ) { $ returnValue = explode ( " " , $ currentAnnotations [ self :: FLAGS ] ) ; } return ( array ) $ returnValue ; }
Get the flags associated to the TranslationUnit . If there are no flags empty array is returned . Otherwise a collection of strings is returned .
54,142
public function setFlags ( $ flags ) { $ currentAnnotations = $ this -> getAnnotations ( ) ; $ currentAnnotations [ self :: FLAGS ] = implode ( " " , $ flags ) ; $ this -> setAnnotations ( $ currentAnnotations ) ; }
Associate a collection of PO flags to the TranslationUnit . A FLAGS will be added to the TranslationUnit will be added consequently to the
54,143
public function getActionDescription ( $ controllerClassName , $ actionName ) { if ( ! class_exists ( $ controllerClassName ) || ! method_exists ( $ controllerClassName , $ actionName ) ) { throw new ActionNotFoundException ( 'Unknown ' . $ controllerClassName . '@' . $ actionName ) ; } $ reflector = new \ ReflectionMe...
Get a description of the action
54,144
private function getControllerClasses ( \ common_ext_Extension $ extension ) { $ returnValue = array ( ) ; $ namespaces = array ( ) ; foreach ( $ extension -> getManifest ( ) -> getRoutes ( ) as $ mapedPath => $ ns ) { if ( is_string ( $ ns ) ) { $ namespaces [ ] = trim ( $ ns , '\\' ) ; } } if ( ! empty ( $ namespaces...
Helper to find all controllers
54,145
public function getPublicAccessUrl ( ) { if ( is_null ( $ this -> accessProvider ) ) { common_Logger :: e ( 'accessss' ) ; throw new common_Exception ( 'Tried obtaining access to private directory with ID ' . $ this -> getId ( ) ) ; } return $ this -> accessProvider -> getAccessUrl ( $ this -> prefix . DIRECTORY_SEPARA...
Returns a URL that allows you to access the files in a directory preserving the relative paths
54,146
public function getPath ( ) { $ adapter = $ this -> getFileSystem ( ) -> getAdapter ( ) ; if ( ! $ adapter instanceof Local ) { throw new common_exception_InconsistentData ( __CLASS__ . ' can only handle local files' ) ; } return $ adapter -> getPathPrefix ( ) . $ this -> getPrefix ( ) ; }
Returned the absolute path to this directory Please use read and write to access files
54,147
protected function getState ( ) { $ serviceService = $ this -> getServiceLocator ( ) -> get ( StateStorage :: SERVICE_ID ) ; $ userUri = $ this -> getSession ( ) -> getUserUri ( ) ; return is_null ( $ userUri ) ? null : $ serviceService -> get ( $ userUri , $ this -> getServiceCallId ( ) ) ; }
Returns the state stored or NULL ifs none was found
54,148
protected function setState ( $ state ) { $ serviceService = $ this -> getServiceLocator ( ) -> get ( StateStorage :: SERVICE_ID ) ; $ userUri = $ this -> getSession ( ) -> getUserUri ( ) ; return is_null ( $ userUri ) ? false : $ serviceService -> set ( $ userUri , $ this -> getServiceCallId ( ) , $ state ) ; }
Stores the state of the current service call
54,149
private static function getRootUrl ( ) { $ isHTTPS = common_http_Request :: isHttps ( ) ; $ host = $ _SERVER [ 'HTTP_HOST' ] ; $ uri = $ _SERVER [ 'REQUEST_URI' ] ; $ currentUrl = ( $ isHTTPS ? 'https' : 'http' ) . '://' . $ host . $ uri ; $ parsed = parse_url ( $ currentUrl ) ; $ port = ( empty ( $ parsed [ 'port' ] )...
Computes the root URL of the platform based on the current request .
54,150
public function getBroker ( ) { if ( is_null ( $ this -> broker ) ) { $ this -> broker = $ this -> getOption ( self :: OPTION_TASK_LOG_BROKER ) ; $ this -> broker -> setServiceLocator ( $ this -> getServiceLocator ( ) ) ; } return $ this -> broker ; }
Gets the task log broker . It will be created if it has not been initialized .
54,151
private function getTotalCount ( $ queryString , $ rootClass = null ) { return $ rootClass -> countInstances ( array ( OntologyRdfs :: RDFS_LABEL => $ queryString ) , array ( 'recursive' => true , 'like' => true , ) ) ; }
Return total count of corresponded instances
54,152
public function addTranslationUnit ( tao_helpers_translation_TranslationUnit $ translationUnit ) { foreach ( $ this -> getTranslationUnits ( ) as $ tu ) { if ( $ tu -> hasSameTranslationUnitSubject ( $ translationUnit ) && $ tu -> hasSameTranslationUnitPredicate ( $ translationUnit ) && $ tu -> hasSameTranslationUnitTa...
Short description of method addTranslationUnit
54,153
public function sendHeader ( Exception $ exception ) { switch ( get_class ( $ exception ) ) { case \ common_exception_BadRequest :: class : case \ common_exception_MissingParameter :: class : case \ common_exception_InvalidArgumentType :: class : case \ common_exception_InconsistentData :: class : case \ common_excepti...
Set response header according exception type
54,154
protected function getClassesHierarchy ( \ Exception $ e ) { $ exceptionClass = get_class ( $ e ) ; $ exceptionClassesHierarchy = array_values ( class_parents ( $ exceptionClass ) ) ; array_unshift ( $ exceptionClassesHierarchy , $ exceptionClass ) ; $ exceptionClassesHierarchy = array_flip ( $ exceptionClassesHierarch...
Function calculates exception classes hierarchy
54,155
protected function getResourceParameter ( ) { $ resource = parent :: getResourceParameter ( ) ; if ( $ resource -> isInstanceOf ( $ this -> getClass ( GenerisRdf :: CLASS_GENERIS_USER ) ) ) { return $ resource ; } throw new InvalidArgumentException ( 'Only user resource are allowed.' ) ; }
Return the resource parameter
54,156
protected function getClassParameter ( ) { $ class = parent :: getClassParameter ( ) ; $ rootUserClass = $ this -> getClass ( GenerisRdf :: CLASS_GENERIS_USER ) ; if ( $ class -> getUri ( ) == $ rootUserClass -> getUri ( ) ) { return $ class ; } foreach ( $ rootUserClass -> getSubClasses ( true ) as $ instance ) { if (...
Return the class parameter
54,157
public function getMetadata ( $ key , $ default = null ) { if ( ! is_string ( $ key ) ) { throw new \ InvalidArgumentException ( 'Non-string argument provided as a metadata key' ) ; } if ( array_key_exists ( $ key , $ this -> metadata ) ) { return $ this -> metadata [ $ key ] ; } return $ default ; }
Retrieve a single metadata as specified by key
54,158
public function setParameter ( $ spec , $ value = null ) { if ( is_string ( $ spec ) ) { $ this -> parameters [ $ spec ] = $ value ; return $ this ; } if ( ! is_array ( $ spec ) && ! $ spec instanceof \ Traversable ) { throw new \ InvalidArgumentException ( sprintf ( 'Expected a string, array, or Traversable argument i...
Set task parameter
54,159
public function getParameter ( $ key , $ default = null ) { if ( ! is_string ( $ key ) ) { throw new \ InvalidArgumentException ( 'Non-string argument provided as a parameter key' ) ; } if ( array_key_exists ( $ key , $ this -> parameters ) ) { return $ this -> parameters [ $ key ] ; } return $ default ; }
Retrieve a single parameter as specified by key
54,160
static public function getDateFormatter ( ) { if ( is_null ( self :: $ service ) ) { $ ext = common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( 'tao' ) ; $ service = $ ext -> getConfig ( self :: CONFIG_KEY ) ; self :: $ service = $ service instanceof DateFormatterInterface ? $ service : new EuropeanFor...
Returns configured date formatter .
54,161
protected function subCompile ( core_kernel_classes_Resource $ resource ) { $ compilerClass = $ this -> getSubCompilerClass ( $ resource ) ; if ( ! class_exists ( $ compilerClass ) ) { common_Logger :: e ( 'Class ' . $ compilerClass . ' not found while instanciating Compiler' ) ; return $ this -> fail ( __ ( '%s is of ...
Compile a subelement of the current resource
54,162
public function runIndexing ( ) { $ iterator = $ this -> getResourceIterator ( ) ; $ indexIterator = new IndexIterator ( $ iterator ) ; $ indexIterator -> setServiceLocator ( $ this -> getServiceLocator ( ) ) ; $ searchService = $ this -> getServiceLocator ( ) -> get ( Search :: SERVICE_ID ) ; $ result = $ searchServic...
Run a full reindexing
54,163
public function getTokens ( ) { $ pool = null ; $ session = \ PHPSession :: singleton ( ) ; if ( $ session -> hasAttribute ( self :: TOKEN_KEY ) ) { $ pool = $ session -> getAttribute ( self :: TOKEN_KEY ) ; } if ( is_null ( $ pool ) ) { $ pool = [ ] ; } return $ pool ; }
Retrieve the pool of tokens
54,164
public function setTokens ( array $ tokens = [ ] ) { $ session = \ PHPSession :: singleton ( ) ; $ session -> setAttribute ( self :: TOKEN_KEY , $ tokens ) ; }
Set the pool of tokens
54,165
public function getFilePathFromUrl ( $ url ) { $ url = parse_url ( $ url ) [ 'path' ] ; $ rel = substr ( $ url , strpos ( $ url , self :: ENTRY_POINT ) + strlen ( self :: ENTRY_POINT ) ) ; $ parts = explode ( '/' , $ rel , 4 ) ; list ( $ webSourceId , $ timestamp , $ token , $ subPath ) = $ parts ; $ parts = explode ( ...
Get file path from url .
54,166
private function buildAuthorizationHeader ( $ signatureParameters ) { $ authorizationHeader = 'OAuth realm=""' ; foreach ( $ signatureParameters as $ key => $ value ) { $ authorizationHeader .= ',' . $ key . "=" . '"' . urlencode ( $ value ) . '"' ; } return $ authorizationHeader ; }
As per the OAuth body hashing specification all of the OAuth parameters must be sent as part of the Authorization header . In particular OAuth parameters from the request URL and POST body will be ignored . Return the Authorization header
54,167
private function getOauthRequest ( common_http_Request $ request ) { $ params = array ( ) ; $ params = array_merge ( $ params , $ request -> getParams ( ) ) ; \ common_Logger :: d ( "OAuth Request created:" . $ request -> getUrl ( ) . " using " . $ request -> getMethod ( ) ) ; $ oauthRequest = new OAuthRequest ( $ requ...
Transform common_http_Request into an OAuth request
54,168
public function getModule ( $ id ) { foreach ( $ this -> registry -> getMap ( ) as $ module ) { if ( $ module [ 'id' ] == $ id ) { return $ this -> loadModule ( $ module ) ; } } return null ; }
Retrieve the given module from the registry
54,169
private function loadModule ( array $ data ) { $ module = null ; try { $ module = $ this -> createFromArray ( $ data ) ; } catch ( \ common_exception_InconsistentData $ dataException ) { \ common_Logger :: w ( 'Got inconsistent module data, skipping.' ) ; } return $ module ; }
Load a module from the given data
54,170
public function activateModule ( DynamicModule $ module ) { if ( ! is_null ( $ module ) ) { $ module -> setActive ( true ) ; return $ this -> registry -> register ( $ module ) ; } return false ; }
Change the state of a module to active
54,171
public function deactivateModule ( DynamicModule $ module ) { if ( ! is_null ( $ module ) ) { $ module -> setActive ( false ) ; return $ this -> registry -> register ( $ module ) ; } return false ; }
Change the state of a module to inactive
54,172
public function registerModules ( array $ modules ) { $ count = 0 ; foreach ( $ modules as $ module ) { if ( is_array ( $ module ) ) { $ module = $ this -> createFromArray ( $ module ) ; } $ this -> registry -> register ( $ module ) ; $ count ++ ; } return $ count ; }
Register a list of modules
54,173
public function registerModulesByCategories ( array $ modules ) { $ count = 0 ; foreach ( $ modules as $ categoryModules ) { if ( is_array ( $ categoryModules ) ) { $ count += $ this -> registerModules ( $ categoryModules ) ; } else { throw new \ common_exception_InvalidArgumentType ( self :: class , __FUNCTION__ , 0 ,...
Register a list of modules gathered by categories
54,174
public function getLists ( ) { $ returnValue = array ( ) ; $ returnValue [ ] = new core_kernel_classes_Class ( GenerisRdf :: GENERIS_BOOLEAN ) ; foreach ( $ this -> parentListClass -> getSubClasses ( false ) as $ list ) { $ returnValue [ ] = $ list ; } return ( array ) $ returnValue ; }
get all the lists class
54,175
public function getList ( $ uri ) { $ returnValue = null ; foreach ( $ this -> getLists ( ) as $ list ) { if ( $ list -> getUri ( ) == $ uri ) { $ returnValue = $ list ; break ; } } return $ returnValue ; }
Get a list class from the uri in parameter
54,176
public function getListElement ( core_kernel_classes_Class $ listClass , $ uri ) { $ returnValue = null ; if ( ! empty ( $ uri ) ) { foreach ( $ this -> getListElements ( $ listClass , false ) as $ element ) { if ( $ element -> getUri ( ) == $ uri ) { $ returnValue = $ element ; break ; } } } return $ returnValue ; }
get the element of the list defined by listClass and identified by the in parameter
54,177
public function getListElements ( core_kernel_classes_Class $ listClass , $ sort = true ) { $ returnValue = array ( ) ; if ( $ sort ) { $ levelProperty = new core_kernel_classes_Property ( TaoOntology :: PROPERTY_LIST_LEVEL ) ; foreach ( $ listClass -> getInstances ( false ) as $ element ) { $ literal = $ element -> ge...
get all the elements of the list
54,178
public function removeList ( core_kernel_classes_Class $ listClass ) { $ returnValue = ( bool ) false ; if ( ! is_null ( $ listClass ) ) { foreach ( $ this -> getListElements ( $ listClass ) as $ element ) { $ this -> removeListElement ( $ element ) ; } $ returnValue = $ listClass -> delete ( ) ; } return ( bool ) $ re...
remove a list and it s elements
54,179
public function removeListElement ( core_kernel_classes_Resource $ element ) { $ returnValue = ( bool ) false ; if ( ! is_null ( $ element ) ) { $ returnValue = $ element -> delete ( ) ; } return ( bool ) $ returnValue ; }
remove a list element
54,180
public function createList ( $ label = '' ) { $ returnValue = null ; if ( empty ( $ label ) ) { $ label = __ ( 'List' ) . ' ' . ( count ( $ this -> getLists ( ) ) + 1 ) ; } $ returnValue = $ this -> createSubClass ( $ this -> parentListClass , $ label ) ; return $ returnValue ; }
create a new list class
54,181
public function createListElement ( core_kernel_classes_Class $ listClass , $ label = '' ) { $ returnValue = null ; if ( ! is_null ( $ listClass ) ) { $ level = count ( $ this -> getListElements ( $ listClass ) ) + 1 ; if ( empty ( $ label ) ) { $ label = __ ( 'Element' ) . ' ' . $ level ; } $ returnValue = $ this -> c...
add a new element to a list
54,182
protected function getArguments ( ) { $ arguments = [ ] ; foreach ( $ this -> getOptionArguments ( ) as $ argument ) { if ( $ argument instanceof Argument ) { $ arguments [ ] = $ this -> getServiceManager ( ) -> propagate ( $ argument ) ; } } return $ arguments ; }
Get all grouped arguments from options
54,183
public function index ( ) { try { $ uri = null ; if ( $ this -> hasRequestParameter ( "uri" ) ) { $ uri = $ this -> getRequestParameter ( "uri" ) ; if ( ! common_Utils :: isUri ( $ uri ) ) { throw new common_exception_InvalidArgumentType ( ) ; } } switch ( $ this -> getRequestMethod ( ) ) { case "GET" : $ response = $ ...
Entry point of API If uri parameters is provided it must be a valid uri Depending on HTTP method request is routed to crud function
54,184
protected function delete ( $ uri = null ) { if ( is_null ( $ uri ) ) { throw new common_exception_BadRequest ( 'Delete method requires an uri parameter' ) ; } if ( ! ( $ this -> getCrudService ( ) -> isInScope ( $ uri ) ) ) { throw new common_exception_PreConditionFailure ( "The URI must be a valid resource under the ...
Method to wrap deleting to service if uri is not null
54,185
protected function post ( ) { $ parameters = $ this -> getParameters ( ) ; try { return $ this -> getCrudService ( ) -> createFromArray ( $ parameters ) ; } catch ( common_exception_PreConditionFailure $ e ) { throw new common_exception_RestApi ( $ e -> getMessage ( ) ) ; } }
Method to wrap creating to service
54,186
protected function put ( $ uri ) { if ( is_null ( $ uri ) ) { throw new common_exception_BadRequest ( 'Update method requires an uri parameter' ) ; } if ( ! ( $ this -> getCrudService ( ) -> isInScope ( $ uri ) ) ) { throw new common_exception_PreConditionFailure ( "The URI must be a valid resource under the root Class...
Method to wrap to updating to service if uri is not null
54,187
protected function getParameters ( ) { $ effectiveParameters = [ ] ; $ missedAliases = [ ] ; foreach ( $ this -> getParametersAliases ( ) as $ checkParameterShort => $ checkParameterUri ) { if ( $ this -> hasRequestParameter ( $ checkParameterUri ) ) { $ effectiveParameters [ $ checkParameterUri ] = $ this -> getReques...
Returns all parameters that are URIs or Aliased with values
54,188
public static function load ( $ mode ) { if ( ! is_string ( $ mode ) ) { throw new InvalidArgumentException ( 'Try to load an irregular mode in the context. The mode must be a string, ' . gettype ( $ mode ) . ' given.' ) ; } else if ( empty ( $ mode ) ) { throw new InvalidArgumentException ( 'Cannot load an empty mode ...
load a new current mode
54,189
public static function check ( $ mode ) { $ returnValue = ( bool ) false ; if ( ! is_string ( $ mode ) ) { throw new InvalidArgumentException ( 'Try to check an irregular mode. The mode must be a string, ' . gettype ( $ mode ) . ' given.' ) ; } else if ( empty ( $ mode ) ) { throw new InvalidArgumentException ( 'Cannot...
check if the mode in parameter is loaded in the context .
54,190
public static function unload ( $ mode ) { if ( ! is_string ( $ mode ) ) { throw new InvalidArgumentException ( 'Try to unload an irregular mode in the context. The mode must be a string, ' . gettype ( $ mode ) . ' given.' ) ; } else if ( empty ( $ mode ) ) { throw new InvalidArgumentException ( 'Cannot unload an empty...
Unload a specific mode .
54,191
public static function getUser ( $ userId ) { $ userService = ServiceManager :: getServiceManager ( ) -> get ( \ tao_models_classes_UserService :: SERVICE_ID ) ; $ user = $ userService -> getUserById ( $ userId ) ; return $ user ; }
Gets a user from a URI
54,192
public static function getUserStringProp ( User $ user , $ property ) { $ value = $ user -> getPropertyValues ( $ property ) ; return empty ( $ value ) ? '' : current ( $ value ) ; }
Gets the value of a string property from a user
54,193
public static function getUserFirstName ( User $ user , $ defaultToLabel = false ) { $ firstName = self :: getUserStringProp ( $ user , GenerisRdf :: PROPERTY_USER_FIRSTNAME ) ; if ( empty ( $ firstName ) && $ defaultToLabel ) { $ firstName = self :: getUserLabel ( $ user ) ; } return $ firstName ; }
Gets the user s first name
54,194
public static function getUserLastName ( User $ user , $ defaultToLabel = false ) { $ lastName = self :: getUserStringProp ( $ user , GenerisRdf :: PROPERTY_USER_LASTNAME ) ; if ( empty ( $ lastName ) && $ defaultToLabel ) { $ lastName = self :: getUserLabel ( $ user ) ; } return $ lastName ; }
Gets the user s last name
54,195
public static function getUserName ( User $ user , $ defaultToLabel = false ) { $ firstName = self :: getUserStringProp ( $ user , GenerisRdf :: PROPERTY_USER_FIRSTNAME ) ; $ lastName = self :: getUserStringProp ( $ user , GenerisRdf :: PROPERTY_USER_LASTNAME ) ; $ userName = trim ( $ firstName . ' ' . $ lastName ) ; i...
Gets the full user name
54,196
public function validate ( $ data ) { try { $ validators = ValidationRuleRegistry :: getRegistry ( ) -> getValidators ( $ this -> getPropertyToWrite ( ) ) ; } catch ( \ common_exception_NotFound $ e ) { throw new MetadataWriterException ( $ e -> getMessage ( ) ) ; } $ validated = true ; foreach ( $ validators as $ vali...
Validate if value is writable by current writer Validation is handle by property validators
54,197
public function attachAction ( RequiredActionInterface $ action ) { $ actions = $ this -> getRequiredActions ( ) ; $ actions [ ] = $ action ; $ this -> setOption ( self :: OPTION_REQUIRED_ACTIONS , $ actions ) ; }
Attach new action
54,198
public function detachAction ( $ name ) { $ actions = $ this -> getRequiredActions ( ) ; foreach ( $ actions as $ key => $ action ) { if ( $ action -> getName ( ) === $ name ) { unset ( $ actions [ $ key ] ) ; } } $ this -> setOption ( self :: OPTION_REQUIRED_ACTIONS , $ actions ) ; }
Detach old action by name
54,199
public function getRequiredAction ( $ name ) { $ result = null ; $ actions = $ this -> getOption ( self :: OPTION_REQUIRED_ACTIONS ) ; foreach ( $ actions as $ action ) { if ( $ action -> getName ( ) === $ name ) { $ result = $ action ; break ; } } return $ result ; }
Get required action by name