idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
54,400 | protected function hasAccess ( $ controllerClass , $ action , $ parameters = [ ] ) { $ user = $ this -> getSession ( ) -> getUser ( ) ; return AclProxy :: hasAccess ( $ user , $ controllerClass , $ action , $ parameters ) ; } | Whenever or not the current user has access to a specific action using functional and data access control |
54,401 | protected function defaultData ( ) { $ context = Context :: getInstance ( ) ; $ this -> setData ( 'extension' , $ context -> getExtensionName ( ) ) ; $ this -> setData ( 'module' , $ context -> getModuleName ( ) ) ; $ this -> setData ( 'action' , $ context -> getActionName ( ) ) ; if ( $ this -> hasRequestParameter ( '... | Retrieve the data from the url and make the base initialization |
54,402 | protected function returnError ( $ description , $ returnLink = true , $ httpStatus = null ) { if ( $ this -> isXmlHttpRequest ( ) ) { $ this -> logWarning ( 'Called ' . __FUNCTION__ . ' in an unsupported AJAX context' ) ; throw new common_Exception ( $ description ) ; } $ this -> setData ( 'message' , $ description ) ... | Function to return an user readable error Does not work with ajax Requests yet |
54,403 | protected static function getTemplatePath ( $ identifier , $ extensionID = null ) { if ( $ extensionID === true ) { $ extensionID = 'tao' ; common_Logger :: d ( 'Deprecated use of setView() using a boolean' ) ; } if ( $ extensionID === null ) { $ extensionID = Context :: getInstance ( ) -> getExtensionName ( ) ; } $ ex... | Returns the absolute path to the specified template |
54,404 | protected function getClientTimeout ( ) { $ ext = $ this -> getServiceManager ( ) -> get ( common_ext_ExtensionsManager :: SERVICE_ID ) -> getExtensionById ( 'tao' ) ; $ config = $ ext -> getConfig ( 'js' ) ; if ( $ config !== null && isset ( $ config [ 'timeout' ] ) ) { return ( int ) $ config [ 'timeout' ] ; } return... | Get the client timeout value from the config . |
54,405 | protected function returnJson ( $ data , $ httpStatus = 200 ) { header ( HTTPToolkit :: statusCodeHeader ( $ httpStatus ) ) ; Context :: getInstance ( ) -> getResponse ( ) -> setContentHeader ( 'application/json' ) ; $ this -> response = $ this -> getPsrResponse ( ) -> withBody ( stream_for ( json_encode ( $ data ) ) )... | Return json response . |
54,406 | protected function returnReport ( common_report_Report $ report ) { $ data = $ report -> getData ( ) ; $ successes = $ report -> getSuccesses ( ) ; while ( $ data === null && count ( $ successes ) > 0 ) { $ firstSubReport = current ( $ successes ) ; $ data = $ firstSubReport -> getData ( ) ; $ successes = $ firstSubRep... | Returns a report |
54,407 | protected function getServiceManager ( ) { try { $ serviceManager = $ this -> getOriginalServiceManager ( ) ; } catch ( InvalidServiceManagerException $ e ) { $ serviceManager = ServiceManager :: getServiceManager ( ) ; } return $ serviceManager ; } | Get the service Manager |
54,408 | protected function catchError ( Exception $ exception ) { $ exceptionInterpreterService = $ this -> getServiceLocator ( ) -> get ( ExceptionInterpreterService :: SERVICE_ID ) ; $ interpretor = $ exceptionInterpreterService -> getExceptionInterpreter ( $ exception ) ; $ interpretor -> getResponse ( ) -> send ( ) ; } | Catch any errors return a http response in function of client accepted mime type |
54,409 | protected function mvc ( ) { $ request = ServerRequest :: fromGlobals ( ) ; $ response = new Response ( ) ; $ frontController = $ this -> propagate ( new TaoFrontController ( ) ) ; $ frontController ( $ request , $ response ) ; } | Start the MVC Loop from the ClearFW |
54,410 | protected function scripts ( ) { $ assetService = $ this -> getServiceLocator ( ) -> get ( AssetService :: SERVICE_ID ) ; $ cssFiles = [ $ assetService -> getAsset ( 'css/layout.css' , 'tao' ) , $ assetService -> getAsset ( 'css/tao-main-style.css' , 'tao' ) , $ assetService -> getAsset ( 'css/tao-3.css' , 'tao' ) ] ; ... | Load external resources for the current context |
54,411 | public function getData ( ) { $ properties = $ this -> formProperties ; foreach ( $ properties as $ index => $ property ) { if ( $ this -> doesExist ( ) && $ property [ 'uri' ] == 'http://www.tao.lu/Ontologies/generis.rdf#login' ) { $ properties [ $ index ] [ 'widget' ] = 'http://www.tao.lu/datatypes/WidgetDefinitions.... | Get the form data . Set readOnly to login in case of edition . Add password and password confirmation with different label depending creation or edition |
54,412 | public function validate ( ) { $ report = parent :: validate ( ) ; $ password = null ; foreach ( $ this -> formProperties as $ key => $ property ) { if ( $ property [ 'uri' ] == GenerisRdf :: PROPERTY_USER_PASSWORD && ! empty ( $ this -> formProperties [ $ key ] [ 'formValue' ] ) ) { $ password = $ this -> formProperti... | Validate the form against the property validators . In case of range check if value belong to associated ranges list |
54,413 | protected function getPropertyValidators ( core_kernel_classes_Property $ property ) { $ validators = parent :: getPropertyValidators ( $ property ) ; $ notEmptyProperties = [ GenerisRdf :: PROPERTY_USER_UILG , GenerisRdf :: PROPERTY_USER_ROLES , OntologyRdfs :: RDFS_LABEL , ] ; if ( $ this -> isNew ( ) ) { $ notEmptyP... | Get validators of a property . Add not empty validator to user to languages and roles properties |
54,414 | protected function validatePassword ( $ password ) { if ( ! ( new tao_helpers_form_validators_NotEmpty ( ) ) -> evaluate ( $ password ) ) { throw new common_exception_ValidationFailed ( GenerisRdf :: PROPERTY_USER_PASSWORD , __ ( 'Password is empty.' ) ) ; } foreach ( PasswordConstraintsService :: singleton ( ) -> getV... | Validate password by evaluate it against PasswordConstraintService and NotEmpty validators |
54,415 | protected function prepareValuesToSave ( ) { $ values = parent :: prepareValuesToSave ( ) ; if ( $ this -> changePassword ) { $ password = null ; foreach ( $ this -> formProperties as $ key => $ property ) { if ( $ property [ 'uri' ] == GenerisRdf :: PROPERTY_USER_PASSWORD && isset ( $ this -> formProperties [ $ key ] ... | Prepare form properties values to be saved . Remove form fields for password and create a new one with encrypted value . |
54,416 | public static function timetoDuration ( $ time ) { $ duration = 'PT' ; $ regexp = "/^([0-9]{2}):([0-9]{2}):([0-9]{2})(\.[0-9]{1,6})?$/" ; if ( preg_match ( $ regexp , $ time , $ matches ) ) { $ duration .= intval ( $ matches [ 1 ] ) . 'H' . intval ( $ matches [ 2 ] ) . 'M' ; $ duration .= isset ( $ matches [ 4 ] ) ? in... | Converts a time string to an ISO8601 duration |
54,417 | public static function intervalToTime ( DateInterval $ interval ) { $ time = null ; if ( ! is_null ( $ interval ) ) { $ format = property_exists ( get_class ( $ interval ) , 'u' ) ? '%H:%I:%S.%U' : '%H:%I:%S' ; $ time = $ interval -> format ( $ format ) ; } return $ time ; } | Converts an interval to a time |
54,418 | public static function durationToTime ( $ duration ) { $ time = null ; try { $ interval = preg_match ( '/(\.[0-9]{1,6}S)$/' , $ duration ) ? new DateIntervalMS ( $ duration ) : new DateInterval ( $ duration ) ; $ time = self :: intervalToTime ( $ interval ) ; } catch ( Exception $ e ) { common_Logger :: e ( $ e -> getM... | Converts a duration to a time |
54,419 | private function getOneCached ( $ propertyUri ) { if ( is_null ( $ this -> cached ) ) { $ props = array ( static :: PROPERTY_INDEX_IDENTIFIER , static :: PROPERTY_INDEX_TOKENIZER , static :: PROPERTY_INDEX_FUZZY_MATCHING , static :: PROPERTY_DEFAULT_SEARCH ) ; $ this -> cached = $ this -> getPropertiesValues ( $ props ... | Preload all the index properties and return the property requested |
54,420 | public function isFuzzyMatching ( ) { $ res = $ this -> getOneCached ( static :: PROPERTY_INDEX_FUZZY_MATCHING ) ; return ! is_null ( $ res ) && is_object ( $ res ) && $ res -> getUri ( ) == GenerisRdf :: GENERIS_TRUE ; } | Should the string matching be fuzzy defaults to false if no information present |
54,421 | public function isDefaultSearchable ( ) { $ res = $ this -> getOneCached ( static :: PROPERTY_DEFAULT_SEARCH ) ; return ! is_null ( $ res ) && is_object ( $ res ) && $ res -> getUri ( ) == GenerisRdf :: GENERIS_TRUE ; } | Should the property be used by default if no index key is specified defaults to false if no information present |
54,422 | public static function init ( common_ext_Extension $ extension , $ langCode ) { if ( empty ( $ langCode ) ) { throw new Exception ( "Language is not defined" ) ; } $ translations = tao_models_classes_LanguageService :: singleton ( ) -> getServerBundle ( $ langCode ) ; l10n :: init ( $ translations ) ; $ serviceManager ... | Load the translation strings |
54,423 | public static function getLangResourceByCode ( $ code ) { $ langs = self :: getAvailableLangs ( ) ; return isset ( $ langs [ $ code ] ) ? new core_kernel_classes_Resource ( $ langs [ $ code ] [ 'uri' ] ) : null ; } | Returns the code of a resource |
54,424 | private static function getAvailableLangs ( ) { if ( count ( self :: $ availableLangs ) == 0 ) { try { self :: $ availableLangs = common_cache_FileCache :: singleton ( ) -> get ( self :: AVAILABLE_LANGS_CACHEKEY ) ; } catch ( common_cache_NotFoundException $ e ) { $ langClass = new core_kernel_classes_Class ( tao_model... | This method returns the languages available in TAO . |
54,425 | public static function getAvailableLangsByUsage ( core_kernel_classes_Resource $ usage ) { $ returnValue = array ( ) ; foreach ( self :: getAvailableLangs ( ) as $ code => $ langData ) { if ( in_array ( $ usage -> getUri ( ) , $ langData [ tao_models_classes_LanguageService :: PROPERTY_LANGUAGE_USAGES ] ) ) { $ lang = ... | Get available languages from the knownledge base depending on a specific usage . |
54,426 | protected function flatImport ( $ content , core_kernel_classes_Class $ class ) { $ report = common_report_Report :: createSuccess ( __ ( 'Data imported successfully' ) ) ; $ graph = new EasyRdf_Graph ( ) ; $ graph -> parse ( $ content ) ; $ map = [ OntologyRdf :: RDF_PROPERTY => OntologyRdf :: RDF_PROPERTY ] ; foreach... | Imports the rdf file into the selected class |
54,427 | protected function importProperties ( core_kernel_classes_Resource $ resource , $ propertiesValues , $ map , $ class ) { if ( isset ( $ propertiesValues [ OntologyRdf :: RDF_TYPE ] ) ) { if ( count ( $ propertiesValues [ OntologyRdf :: RDF_TYPE ] ) > 1 ) { return new common_report_Report ( common_report_Report :: TYPE_... | Import the properties of the resource |
54,428 | public function initForm ( ) { $ this -> form = tao_helpers_form_FormFactory :: getForm ( 'import' ) ; $ this -> form -> setActions ( is_null ( $ this -> subForm ) ? array ( ) : $ this -> subForm -> getActions ( 'top' ) , 'top' ) ; $ this -> form -> setActions ( is_null ( $ this -> subForm ) ? array ( ) : $ this -> sub... | inits the import form |
54,429 | public function initElements ( ) { $ formatElt = tao_helpers_form_FormFactory :: getElement ( 'importHandler' , 'Radiobox' ) ; $ formatElt -> setDescription ( __ ( 'Choose import format' ) ) ; $ formatElt -> addValidator ( tao_helpers_form_FormFactory :: getValidator ( 'NotEmpty' ) ) ; $ importHandlerOptions = array ( ... | Inits the element to select the importhandler and takes over the elements of the import form |
54,430 | public function getExtendedConfig ( ) { $ config = array ( ) ; foreach ( $ this -> getOption ( self :: OPTION_CONFIG_SOURCES ) as $ key => $ source ) { $ config [ $ key ] = $ source -> getConfig ( ) ; } return $ config ; } | Returns an array of json serialisable content to be send to the client json encoded |
54,431 | public function setClientConfig ( $ id , ClientConfig $ configSource ) { $ sources = $ this -> hasOption ( self :: OPTION_CONFIG_SOURCES ) ? $ this -> getOption ( self :: OPTION_CONFIG_SOURCES ) : array ( ) ; $ sources [ $ id ] = $ configSource ; $ this -> setOption ( self :: OPTION_CONFIG_SOURCES , $ sources ) ; } | Either adds or overrides an existing client config |
54,432 | public function archive ( $ userId , $ callId ) { $ stateStorage = $ this -> getServiceManager ( ) -> get ( StateStorage :: SERVICE_ID ) ; $ state = $ stateStorage -> get ( $ userId , $ callId ) ; return ( ! is_null ( $ state ) ) ? $ this -> getFileSystem ( ) -> write ( $ this -> generateSerial ( $ userId , $ callId ) ... | Store the state of the service call |
54,433 | public static function cssToArray ( $ css ) { if ( ! $ css ) { return array ( ) ; } $ css = str_replace ( ' /* Do not edit */' , '' , $ css ) ; $ oldCssArr = explode ( "\n" , $ css ) ; $ newCssArr = array ( ) ; foreach ( $ oldCssArr as $ line ) { if ( false === strpos ( $ line , '{' ) ) { continue ; } preg_match ( '~(?... | Convert incoming CSS to CSS array This CSS must have the format generated by the online editor |
54,434 | public function evaluate ( $ values ) { $ tokenService = $ this -> getServiceManager ( ) -> get ( TokenService :: SERVICE_ID ) ; if ( $ tokenService -> checkToken ( $ values ) ) { $ tokenService -> revokeToken ( $ values ) ; return true ; } \ common_Logger :: e ( 'Attempt to post a form with the incorrect token' ) ; th... | Validate an active XSRF token . |
54,435 | protected function getMediaSources ( ) { if ( is_null ( $ this -> mediaSources ) ) { $ this -> mediaSources = array ( ) ; $ tao = \ common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( 'tao' ) ; $ sources = $ tao -> getConfig ( self :: CONFIG_KEY ) ; $ sources = is_array ( $ sources ) ? $ sources : array... | Return all configured media sources |
54,436 | public function getBrowsableSources ( ) { $ returnValue = array ( ) ; foreach ( $ this -> getMediaSources ( ) as $ id => $ source ) { if ( $ source instanceof MediaBrowser ) { $ returnValue [ $ id ] = $ source ; } } return $ returnValue ; } | Returns all media sources that are browsable |
54,437 | public function getWritableSources ( ) { $ returnValue = array ( ) ; foreach ( $ this -> getMediaSources ( ) as $ id => $ source ) { if ( $ source instanceof MediaManagement ) { $ returnValue [ $ id ] = $ source ; } } return $ returnValue ; } | Returns all media sources that can write |
54,438 | public function addMediaSource ( MediaBrowser $ source ) { $ this -> getMediaSources ( ) ; $ this -> mediaSources [ 'mediamanager' ] = $ source ; $ tao = \ common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( 'tao' ) ; return $ tao -> setConfig ( self :: CONFIG_KEY , $ this -> mediaSources ) ; } | Adds a media source to Tao |
54,439 | public function removeMediaSource ( $ sourceId ) { $ this -> getMediaSources ( ) ; unset ( $ this -> mediaSources [ $ sourceId ] ) ; $ tao = \ common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( 'tao' ) ; return $ tao -> setConfig ( self :: CONFIG_KEY , $ this -> mediaSources ) ; } | Removes a media source for tao |
54,440 | public function createConfig ( ) { if ( ! is_writable ( dirname ( $ this -> file ) ) ) { throw new tao_install_utils_Exception ( 'Unable to create configuration file. Please set write permission to : ' . dirname ( $ this -> file ) ) ; } if ( file_exists ( $ this -> file ) && ! is_writable ( $ this -> file ) ) { throw n... | Create the config file from the sample |
54,441 | public function writeConstants ( array $ constants ) { if ( ! file_exists ( $ this -> file ) ) { throw new tao_install_utils_Exception ( "Unable to write constants: $this->file don't exists!" ) ; } if ( ! is_readable ( $ this -> file ) || ! is_writable ( $ this -> file ) ) { throw new tao_install_utils_Exception ( "Una... | Write the constants into the config file |
54,442 | public function writeJsVariable ( array $ variables , $ lineBeginWith = "var" ) { if ( ! file_exists ( $ this -> file ) ) { throw new tao_install_utils_Exception ( "Unable to write variables: $this->file don't exists!" ) ; } if ( ! is_readable ( $ this -> file ) || ! is_writable ( $ this -> file ) ) { throw new tao_ins... | Write the constants into a Javascript config file |
54,443 | public function getValues ( $ groupName = '' ) { $ returnValue = array ( ) ; foreach ( $ this -> elements as $ element ) { if ( ! empty ( $ this -> systemElements ) && in_array ( $ element -> getName ( ) , $ this -> systemElements ) ) { continue ; } if ( empty ( $ groupName ) || ! isset ( $ this -> groups [ $ groupName... | Short description of method getValues |
54,444 | public function resolve ( $ url ) { $ urlParts = parse_url ( $ url ) ; if ( isset ( $ urlParts [ 'scheme' ] ) && $ urlParts [ 'scheme' ] === MediaService :: SCHEME_NAME && isset ( $ urlParts [ 'host' ] ) ) { $ mediaService = new MediaService ( ) ; $ mediaSource = $ mediaService -> getMediaSource ( $ urlParts [ 'host' ]... | Resolve a taomedia url to a media asset |
54,445 | private function setFormData ( ) { $ postData = $ this -> getPostData ( ) ; $ currentSetting = $ this -> getSettings ( ) ; $ listSettings = [ ] ; if ( $ currentSetting === 'list' ) { $ listSettings = $ this -> getListSettings ( ) ; } if ( $ currentSetting && ! isset ( $ postData [ self :: SOURCE_RADIO_NAME ] ) ) { $ th... | Set the form data based on the available data |
54,446 | private function setValidation ( ) { $ this -> sourceDomainsElement -> addValidator ( new CspHeaderValidator ( [ 'sourceElement' => $ this -> sourceElement ] ) ) ; $ this -> sourceElement -> addValidator ( tao_helpers_form_FormFactory :: getValidator ( 'NotEmpty' ) ) ; } | Set the validation needed for the form elements . |
54,447 | private function getSettings ( ) { $ settingsStorage = $ this -> getSettingsStorage ( ) ; if ( ! $ settingsStorage -> exists ( CspHeaderSettingsInterface :: CSP_HEADER_SETTING ) ) { return '' ; } return $ settingsStorage -> get ( CspHeaderSettingsInterface :: CSP_HEADER_SETTING ) ; } | Get the current settings |
54,448 | private function getListSettings ( ) { $ settingsStorage = $ this -> getSettingsStorage ( ) ; if ( ! $ settingsStorage -> exists ( CspHeaderSettingsInterface :: CSP_HEADER_LIST ) ) { return [ ] ; } return json_decode ( $ settingsStorage -> get ( CspHeaderSettingsInterface :: CSP_HEADER_LIST ) ) ; } | Get the current list settings |
54,449 | public function saveSettings ( ) { $ formValues = $ this -> getForm ( ) -> getValues ( ) ; $ settingStorage = $ this -> getSettingsStorage ( ) ; $ configValue = $ formValues [ self :: SOURCE_RADIO_NAME ] ; if ( $ configValue === 'list' ) { $ sources = trim ( str_replace ( "\r" , '' , $ formValues [ self :: SOURCE_LIST_... | Stores the settings based on the form values . |
54,450 | private function classToNode ( core_kernel_classes_Class $ class , core_kernel_classes_Class $ parent = null ) { $ returnValue = $ this -> buildClassNode ( $ class , $ parent ) ; $ subclasses = $ this -> getSubClasses ( $ class ) ; if ( $ this -> showResources ) { $ options = array_merge ( [ 'recursive' => false ] , $ ... | Builds a class node including it s content |
54,451 | private function buildChildNodes ( core_kernel_classes_Class $ class , $ subclasses ) { $ children = [ ] ; foreach ( $ subclasses as $ subclass ) { $ children [ ] = $ this -> classToNode ( $ subclass , $ class ) ; } if ( $ this -> showResources ) { $ limit = $ this -> limit ; if ( in_array ( $ class -> getUri ( ) , $ t... | Builds the content of a class node including it s content |
54,452 | private function buildClassNode ( core_kernel_classes_Class $ class , core_kernel_classes_Class $ parent = null ) { $ label = $ class -> getLabel ( ) ; $ label = empty ( $ label ) ? __ ( 'no label' ) : $ label ; return array ( 'data' => _dh ( $ label ) , 'type' => 'class' , 'attributes' => array ( 'id' => tao_helpers_U... | generis tree representation of a class node without it s content |
54,453 | public function getDefaultQueue ( ) { return $ this -> hasOption ( self :: OPTION_DEFAULT_QUEUE ) && $ this -> getOption ( self :: OPTION_DEFAULT_QUEUE ) ? $ this -> getQueue ( $ this -> getOption ( self :: OPTION_DEFAULT_QUEUE ) ) : $ this -> getFirstQueue ( ) ; } | Return the first queue as a default one . Maybe later we need other logic the determine the default queue . |
54,454 | public function dequeue ( ) { if ( count ( $ this -> getQueues ( ) ) === 1 ) { return $ this -> getFirstQueue ( ) -> dequeue ( ) ; } return $ this -> selectorStrategy -> pickNextTask ( $ this -> getQueues ( ) ) ; } | Receive a task from a specified queue or from a queue selected by a predefined strategy |
54,455 | public function count ( ) { $ counts = array_map ( function ( QueueInterface $ queue ) { return $ queue -> count ( ) ; } , $ this -> getQueues ( ) ) ; return array_sum ( $ counts ) ; } | Count of messages in all queues . |
54,456 | protected function returnTaskJson ( TaskInterface $ task , array $ extraData = [ ] ) { return $ this -> returnJson ( [ 'success' => true , 'data' => [ 'extra' => $ extraData , 'task' => $ this -> getTaskLogReturnData ( $ task -> getId ( ) ) ] ] ) ; } | Returns task data in a specific data structure required by the front - end component . |
54,457 | public static function remove ( $ path , $ recursive = false ) { $ returnValue = ( bool ) false ; if ( $ recursive ) { $ returnValue = helpers_File :: remove ( $ path ) ; } elseif ( is_file ( $ path ) ) { $ returnValue = @ unlink ( $ path ) ; } return ( bool ) $ returnValue ; } | Remove a file . If the recursive parameter is set to true the target file can be a directory that contains data . |
54,458 | public static function move ( $ source , $ destination ) { $ returnValue = ( bool ) false ; if ( is_dir ( $ source ) ) { if ( ! file_exists ( $ destination ) ) { mkdir ( $ destination , 0777 , true ) ; } $ error = false ; foreach ( scandir ( $ source ) as $ file ) { if ( $ file != '.' && $ file != '..' ) { if ( is_dir ... | Move file from source to destination . |
54,459 | public static function getExtention ( $ mimeType ) { $ returnValue = ( string ) '' ; foreach ( self :: getMimeTypeList ( ) as $ key => $ value ) { if ( $ value == trim ( $ mimeType ) ) { $ returnValue = $ key ; break ; } } return ( string ) $ returnValue ; } | Retrieve file extensions usually associated to a given mime - type . |
54,460 | public static function getFileExtention ( $ path ) { $ ext = pathinfo ( $ path , PATHINFO_EXTENSION ) ; if ( $ ext === '' ) { $ splitedPath = explode ( '.' , $ path ) ; $ ext = end ( $ splitedPath ) ; } return $ ext ; } | Retrieve file extensions of a file |
54,461 | public static function getMimeType ( $ path , $ ext = false ) { $ mime_types = self :: getMimeTypeList ( ) ; if ( false == $ ext ) { $ ext = pathinfo ( $ path , PATHINFO_EXTENSION ) ; if ( array_key_exists ( $ ext , $ mime_types ) ) { $ mimetype = $ mime_types [ $ ext ] ; } else { $ mimetype = '' ; } if ( ! in_array ( ... | Get the mime - type of the file in parameter . different methods are used regarding the configuration of the server . |
54,462 | public static function createTempDir ( ) { do { $ folder = sys_get_temp_dir ( ) . DIRECTORY_SEPARATOR . "tmp" . mt_rand ( ) . DIRECTORY_SEPARATOR ; } while ( file_exists ( $ folder ) ) ; mkdir ( $ folder ) ; return $ folder ; } | creates a directory in the system s temp dir . |
54,463 | public static function delTree ( $ directory ) { $ files = array_diff ( scandir ( $ directory ) , array ( '.' , '..' ) ) ; foreach ( $ files as $ file ) { $ abspath = $ directory . DIRECTORY_SEPARATOR . $ file ; if ( is_dir ( $ abspath ) ) { self :: delTree ( $ abspath ) ; } else { unlink ( $ abspath ) ; } } return rmd... | deletes a directory and its content . |
54,464 | public static function createZip ( $ src , $ withEmptyDir = false ) { $ zipArchive = new \ ZipArchive ( ) ; $ path = self :: createTempDir ( ) . 'file.zip' ; if ( $ zipArchive -> open ( $ path , \ ZipArchive :: CREATE ) !== TRUE ) { throw new common_Exception ( 'Unable to create zipfile ' . $ path ) ; } self :: addFile... | Create a zip of a directory or file |
54,465 | public static function renameInZip ( ZipArchive $ zipArchive , $ oldname , $ newname ) { $ i = 0 ; $ renameCount = 0 ; while ( ( $ entryName = $ zipArchive -> getNameIndex ( $ i ) ) || ( $ statIndex = $ zipArchive -> statIndex ( $ i , ZipArchive :: FL_UNCHANGED ) ) ) { if ( $ entryName ) { $ newEntryName = str_replace ... | Rename in Zip |
54,466 | public static function checkWhetherArchiveIsBomb ( \ ZipArchive $ archive , $ minCompressionRatioToBeBomb = 200 ) { if ( ! $ archive -> filename ) { throw new common_Exception ( 'ZIP archive should be opened before checking for a ZIP bomb' ) ; } $ contentSize = 0 ; for ( $ fileIndex = 0 ; $ fileIndex < $ archive -> num... | Helps prevent decompression attacks . Since this method checks archive file size it needs filename property to be set so ZipArchive object should be already opened . |
54,467 | public static function excludeFromZip ( ZipArchive $ zipArchive , $ pattern ) { $ i = 0 ; $ exclusionCount = 0 ; while ( ( $ entryName = $ zipArchive -> getNameIndex ( $ i ) ) || ( $ statIndex = $ zipArchive -> statIndex ( $ i , ZipArchive :: FL_UNCHANGED ) ) ) { if ( $ entryName ) { if ( preg_match ( $ pattern , $ ent... | Exclude from Zip |
54,468 | public static function getAllZipNames ( ZipArchive $ zipArchive ) { $ i = 0 ; $ entries = [ ] ; while ( ( $ entryName = $ zipArchive -> getNameIndex ( $ i ) ) || ( $ statIndex = $ zipArchive -> statIndex ( $ i , ZipArchive :: FL_UNCHANGED ) ) ) { if ( $ entryName ) { $ entries [ ] = $ entryName ; } $ i ++ ; } return $ ... | Get All Zip Names |
54,469 | public static function getPathFromUrl ( $ url ) { if ( substr ( $ url , 0 , strlen ( ROOT_URL ) ) != ROOT_URL ) { throw new common_Exception ( $ url . ' does not lie within the tao instalation path' ) ; } $ subUrl = substr ( $ url , strlen ( ROOT_URL ) ) ; $ parts = array ( ) ; foreach ( explode ( '/' , $ subUrl ) as $... | Gets the local path to a publicly available resource no verification if the file should be accessible |
54,470 | public static function getSafeFileName ( $ fileName , $ directory = null ) { $ lastDot = strrpos ( $ fileName , '.' ) ; $ file = $ lastDot ? substr ( $ fileName , 0 , $ lastDot ) : $ fileName ; $ ending = $ lastDot ? substr ( $ fileName , $ lastDot + 1 ) : '' ; $ safeName = self :: removeSpecChars ( $ file ) ; $ safeEn... | Get a safe filename for a proposed filename . |
54,471 | public static function isDirEmpty ( $ directory ) { $ path = self :: concat ( array ( $ directory , '*' ) ) ; return ( count ( glob ( $ path , GLOB_NOSORT ) ) === 0 ) ; } | Check if the directory is empty |
54,472 | public static function isAjax ( ) { $ returnValue = ( bool ) false ; if ( isset ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) ) { if ( strtolower ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) == 'xmlhttprequest' ) { $ returnValue = true ; } } return ( bool ) $ returnValue ; } | Enables you to know if the request in the current scope is an ajax |
54,473 | public static function getRelativeUrl ( $ url = null ) { $ url = is_null ( $ url ) ? '/' . ltrim ( $ _SERVER [ 'REQUEST_URI' ] , '/' ) : $ url ; $ rootUrlPath = parse_url ( ROOT_URL , PHP_URL_PATH ) ; $ absPath = parse_url ( $ url , PHP_URL_PATH ) ; if ( substr ( $ absPath , 0 , strlen ( $ rootUrlPath ) ) != $ rootUrlP... | Returns the current relative call url without leading slash |
54,474 | public static function load ( $ url , $ useSession = false ) { $ returnValue = ( string ) '' ; if ( ! empty ( $ url ) ) { if ( $ useSession ) { session_write_close ( ) ; } $ curlHandler = curl_init ( ) ; if ( USE_HTTP_AUTH ) { curl_setopt ( $ curlHandler , CURLOPT_HTTPAUTH , CURLAUTH_BASIC ) ; curl_setopt ( $ curlHandl... | Perform an HTTP Request on the defined url and return the content |
54,475 | public static function contextInit ( $ extension , $ module , $ action ) { $ basePath = '/' . $ extension . '/views/' ; $ jsModuleFile = $ basePath . self :: JS . '/controllers/' . strtolower ( $ module ) . '/' . $ action . '.' . self :: JS ; $ cssModuleFile = $ basePath . self :: CSS . '/' . $ module . '.' . self :: C... | Short description of method contextInit |
54,476 | public static function setPaths ( $ paths , $ recursive = false , $ filter = '' ) { foreach ( $ paths as $ path ) { if ( ! preg_match ( "/\/$/" , $ path ) ) { $ path .= '/' ; } if ( empty ( $ filter ) || strtolower ( $ filter ) == tao_helpers_Scriptloader :: CSS ) { foreach ( glob ( $ path . "*." . tao_helpers_Scriptlo... | define the paths to look for the scripts |
54,477 | public static function addFile ( $ file , $ type = '' ) { if ( empty ( $ type ) ) { if ( preg_match ( "/\." . tao_helpers_Scriptloader :: CSS . "$/" , $ file ) ) { $ type = tao_helpers_Scriptloader :: CSS ; } if ( preg_match ( "/\." . tao_helpers_Scriptloader :: JS . "$/" , $ file ) ) { $ type = tao_helpers_Scriptloade... | add a file to load |
54,478 | public static function addJsVars ( $ vars ) { if ( is_array ( $ vars ) ) { foreach ( $ vars as $ name => $ value ) { if ( is_int ( $ name ) ) { $ name = 'var_' . $ name ; } self :: addJsVar ( $ name , $ value ) ; } } } | Short description of method addJsVars |
54,479 | public static function render ( $ filter = '' ) { $ returnValue = ( string ) '' ; if ( empty ( $ filter ) || strtolower ( $ filter ) == tao_helpers_Scriptloader :: CSS ) { foreach ( self :: $ cssFiles as $ file ) { $ returnValue .= "\t<link rel='stylesheet' type='text/css' href='{$file}' />\n" ; } } if ( empty ( $ filt... | render the html to load the resources |
54,480 | public function getLanguageByCode ( $ code ) { $ returnValue = null ; $ langClass = new core_kernel_classes_Class ( static :: CLASS_URI_LANGUAGES ) ; $ langs = $ langClass -> searchInstances ( array ( OntologyRdf :: RDF_VALUE => $ code ) , array ( 'like' => false ) ) ; if ( count ( $ langs ) == 1 ) { $ returnValue = cu... | Short description of method getLanguageByCode |
54,481 | public function getCode ( core_kernel_classes_Resource $ language ) { $ returnValue = ( string ) '' ; $ valueProperty = new core_kernel_classes_Property ( OntologyRdf :: RDF_VALUE ) ; $ returnValue = $ language -> getUniquePropertyValue ( $ valueProperty ) ; return ( string ) $ returnValue ; } | Short description of method getCode |
54,482 | public function getAvailableLanguagesByUsage ( core_kernel_classes_Resource $ usage ) { $ returnValue = array ( ) ; $ langClass = new core_kernel_classes_Class ( static :: CLASS_URI_LANGUAGES ) ; $ returnValue = $ langClass -> searchInstances ( array ( static :: PROPERTY_LANGUAGE_USAGES => $ usage -> getUri ( ) ) , arr... | Short description of method getAvailableLanguagesByUsage |
54,483 | public function generateAll ( $ checkPreviousBundle = false ) { $ this -> generateServerBundles ( ) ; $ files = $ this -> generateClientBundles ( $ checkPreviousBundle ) ; return $ files ; } | Regenerates client and server translation |
54,484 | public function generateServerBundles ( ) { $ usage = $ this -> getResource ( self :: INSTANCE_LANGUAGE_USAGE_GUI ) ; foreach ( $ this -> getAvailableLanguagesByUsage ( $ usage ) as $ language ) { $ langCode = $ this -> getCode ( $ language ) ; $ this -> buildServerBundle ( $ langCode ) ; } } | Generate server translation file forching a cache overwrite |
54,485 | public function getServerBundle ( $ langCode ) { $ cache = $ this -> getServiceLocator ( ) -> get ( common_cache_Cache :: SERVICE_ID ) ; try { $ translations = $ cache -> get ( self :: TRANSLATION_PREFIX . $ langCode ) ; } catch ( common_cache_NotFoundException $ ex ) { $ translations = $ this -> buildServerBundle ( $ ... | Returns the translation strings for a given language Conflicting translations get resolved by order of dependencies |
54,486 | protected function buildServerBundle ( $ langCode ) { $ extensions = common_ext_ExtensionsManager :: singleton ( ) -> getInstalledExtensions ( ) ; $ extensions = helpers_ExtensionHelper :: sortByDependencies ( $ extensions ) ; $ translations = [ ] ; foreach ( $ extensions as $ extension ) { $ file = $ extension -> getD... | Rebuild the translation cache from the POs situated in each installed extension |
54,487 | public static function filterLanguage ( $ value ) { $ uri = self :: getExistingLanguageUri ( $ value ) ; return $ uri !== null ? $ uri : self :: singleton ( ) -> getLanguageByCode ( DEFAULT_LANG ) -> getUri ( ) ; } | Filter a value of a language to transform it into uri |
54,488 | public function bind ( $ data ) { $ returnValue = null ; try { $ instance = $ this -> getTargetInstance ( ) ; $ eventManager = \ oat \ oatbox \ service \ ServiceManager :: getServiceManager ( ) -> get ( \ oat \ oatbox \ event \ EventManager :: CONFIG_ID ) ; foreach ( $ data as $ propertyUri => $ propertyValue ) { if ( ... | Simply bind data from the source to a specific generis class instance . |
54,489 | public static function textCleaner ( $ input , $ joker = '_' , $ maxLength = - 1 ) { $ returnValue = '' ; $ randJoker = ( $ joker == '*' ) ; $ length = ( ( defined ( 'TAO_DEFAULT_ENCODING' ) ) ? mb_strlen ( $ input , TAO_DEFAULT_ENCODING ) : mb_strlen ( $ input ) ) ; if ( $ maxLength > - 1 ) { $ length = min ( $ length... | Clean a text with a joker character to replace any characters that is alphanumeric . |
54,490 | public static function htmlize ( $ input ) { $ returnValue = htmlentities ( $ input , ENT_COMPAT , self :: getApplicationService ( ) -> getDefaultEncoding ( ) ) ; return ( string ) $ returnValue ; } | Display clean and more secure text into an HTML page . The implementation of this method is done with htmlentities . This method is Unicode safe . |
54,491 | public static function fromResource ( core_kernel_classes_Resource $ resource ) { $ values = $ resource -> getPropertiesValues ( array ( WfEngineOntology :: PROPERTY_ACTUAL_PARAMETER_FORMAL_PARAMETER , WfEngineOntology :: PROPERTY_ACTUAL_PARAMETER_CONSTANT_VALUE , WfEngineOntology :: PROPERTY_ACTUAL_PARAMETER_PROCESS_V... | Builds a service call parameter from it s serialized form |
54,492 | public function load ( Action $ action , array $ params ) { foreach ( $ this -> getArguments ( ) as $ argument ) { if ( $ argument -> isApplicable ( $ params ) ) { $ this -> getServiceManager ( ) -> propagate ( $ argument ) ; $ argument -> load ( $ action ) ; } } } | Get arguments from config and check if there are applicable In case of yes process them |
54,493 | public function log ( ) { $ result = [ ] ; if ( $ this -> hasRequestParameter ( 'messages' ) ) { $ messages = json_decode ( $ this -> getRawParameter ( 'messages' ) , true ) ; foreach ( $ messages as $ message ) { \ common_Logger :: singleton ( ) -> log ( $ this -> getLevel ( $ message [ 'level' ] ) , json_encode ( $ m... | Log the message sent from client side |
54,494 | private function getLevel ( $ level ) { $ result = \ common_Logger :: TRACE_LEVEL ; switch ( $ level ) { case 'fatal' : $ result = \ common_Logger :: FATAL_LEVEL ; break ; case 'error' : $ result = \ common_Logger :: ERROR_LEVEL ; break ; case 'warn' : $ result = \ common_Logger :: WARNING_LEVEL ; break ; case 'info' :... | Map log level |
54,495 | protected static function getImplementations ( ) { if ( is_null ( self :: $ implementations ) ) { self :: $ implementations = array ( new FuncProxy ( ) , new DataAccessControl ( ) ) ; } return self :: $ implementations ; } | get the current access control implementations |
54,496 | public static function hasAccess ( User $ user , $ controller , $ action , $ parameters ) { $ access = true ; foreach ( self :: getImplementations ( ) as $ impl ) { $ access = $ access && $ impl -> hasAccess ( $ user , $ controller , $ action , $ parameters ) ; } return $ access ; } | Returns whenever or not a user has access to a specified link |
54,497 | protected static function spawn ( $ fileSystemId , $ customConfig = array ( ) ) { $ customConfig [ self :: OPTION_FILESYSTEM_ID ] = $ fileSystemId ; $ customConfig [ self :: OPTION_ID ] = uniqid ( ) ; $ webSource = new static ( $ customConfig ) ; WebsourceManager :: singleton ( ) -> addWebsource ( $ webSource ) ; retur... | Used to instantiate new AccessProviders |
54,498 | protected function interpretError ( ) { switch ( get_class ( $ this -> exception ) ) { case UserErrorException :: class : case tao_models_classes_MissingRequestParameterException :: class : case common_exception_MissingParameter :: class : case common_exception_BadRequest :: class : $ this -> returnHttpCode = 400 ; $ t... | interpret exception type and set up render responseClassName and http status to return |
54,499 | public function toArray ( ) { $ result = parent :: toArray ( ) ; $ result [ 'category' ] = $ this -> taskLogService -> getCategoryForTask ( $ this -> getTaskName ( ) ) ; return $ result ; } | Add category to the result . Required by our frontend . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.