idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
10,400
public function getLanguageText ( $ locale = null ) { try { $ text = PunicLanguage :: getName ( $ this -> getLanguage ( ) , $ locale ? : '' ) ; } catch ( Exception $ e ) { $ text = $ this -> getLanguage ( ) ; } catch ( Throwable $ e ) { $ text = $ this -> getLanguage ( ) ; } return $ text ; }
Get the display name of this locale .
10,401
protected function triggerRequest ( \ PermissionKey $ pk ) { if ( ! $ this -> wrID ) { $ this -> save ( ) ; } if ( ! $ pk -> canPermissionKeyTriggerWorkflow ( ) ) { throw new \ Exception ( t ( 'This permission key cannot start a workflow.' ) ) ; } $ pa = $ pk -> getPermissionAccessObject ( ) ; $ skipWorkflow = true ; if ( is_object ( $ pa ) ) { $ workflows = $ pa -> getWorkflows ( ) ; foreach ( $ workflows as $ wf ) { if ( $ wf -> validateTrigger ( $ this ) ) { $ wp = $ this -> addWorkflowProgress ( $ wf ) ; $ response = $ wp -> getWorkflowProgressResponseObject ( ) ; if ( $ response instanceof SkippedResponse ) { $ wp -> delete ( ) ; } else { $ skipWorkflow = false ; } $ event = new GenericEvent ( ) ; $ event -> setArgument ( 'progress' , $ wp ) ; Events :: dispatch ( 'workflow_triggered' , $ event ) ; } } } if ( $ skipWorkflow ) { $ defaultWorkflow = new EmptyWorkflow ( ) ; $ wp = $ this -> addWorkflowProgress ( $ defaultWorkflow ) ; $ event = new GenericEvent ( ) ; $ event -> setArgument ( 'progress' , $ wp ) ; Events :: dispatch ( 'workflow_triggered' , $ event ) ; return $ wp -> getWorkflowProgressResponseObject ( ) ; } }
Triggers a workflow request queries a permission key to see what workflows are attached to it and initiates them .
10,402
public function getPlainTextValue ( ) { $ controller = $ this -> getController ( ) ; if ( method_exists ( $ controller , 'getPlainTextValue' ) ) { return $ controller -> getPlainTextValue ( ) ; } if ( $ this -> getValueObject ( ) ) { return ( string ) $ this -> getValueObject ( ) ; } if ( method_exists ( $ controller , 'getValue' ) ) { return $ controller -> getValue ( ) ; } return '' ; }
Returns content that is useful in plain text contexts .
10,403
private function transformEntry ( Entry \ EntryInterface $ entry ) { return [ 'id' => $ entry -> getID ( ) , 'name' => $ entry -> getLabel ( ) , 'icon' => ( string ) $ entry -> getIcon ( ) ] ; }
Convert an entry to an array
10,404
protected function checkEmail ( $ mixed ) { $ result = false ; if ( is_string ( $ mixed ) && $ mixed !== '' ) { $ eev = $ this -> getEguliasEmailValidator ( ) ; $ testMX = $ this -> isTestMXRecord ( ) ; if ( $ eev -> isValid ( $ mixed , $ testMX , $ this -> isStrict ( ) ) ) { if ( $ testMX ) { $ result = ! in_array ( EguliasEmailValidator :: DNSWARN_NO_RECORD , $ eev -> getWarnings ( ) , true ) ; } else { $ result = true ; } } } return $ result ; }
Actually check if an email address is valid .
10,405
public function getTrailToCollection ( $ c ) { $ db = Database :: connection ( ) ; $ cArray = array ( ) ; $ currentcParentID = $ c -> getCollectionParentID ( ) ; if ( $ currentcParentID > 0 ) { while ( is_numeric ( $ currentcParentID ) && $ currentcParentID > 0 && $ currentcParentID ) { $ q = "select cID, cParentID from Pages where cID = '{$currentcParentID}'" ; $ r = $ db -> query ( $ q ) ; $ row = $ r -> fetchRow ( ) ; if ( $ row [ 'cID' ] ) { $ cArray [ ] = Page :: getByID ( $ row [ 'cID' ] , 'ACTIVE' ) ; } $ currentcParentID = $ row [ 'cParentID' ] ; } } return $ cArray ; }
Returns an array of collections as a breadcrumb to the current page .
10,406
public static function clear ( $ file = null ) { if ( static :: hasEAccelerator ( ) ) { if ( function_exists ( 'eeaccelerator_clear' ) ) { $ paths = @ ini_get ( 'eaccelerator.allowed_admin_path' ) ; if ( is_string ( $ paths ) && ( $ paths !== '' ) ) { $ myPath = str_replace ( DIRECTORY_SEPARATOR , '/' , __DIR__ ) ; foreach ( explode ( PATH_SEPARATOR , $ paths ) as $ path ) { $ path = str_replace ( DIRECTORY_SEPARATOR , '/' , $ path ) ; if ( $ path !== '' ) { $ path = rtrim ( $ path , '/' ) ; if ( ( $ path === $ myPath ) || ( strpos ( $ myPath , $ path . '/' ) === 0 ) ) { @ eeaccelerator_clear ( ) ; break ; } } } } } } if ( static :: hasAPC ( ) ) { if ( function_exists ( 'apc_clear_cache' ) ) { @ apc_clear_cache ( 'system' ) ; } } if ( static :: hasXCache ( ) ) { if ( function_exists ( 'xcache_clear_cache' ) && ini_get ( 'xcache.admin.user' ) && ini_get ( 'xcache.admin.pass' ) ) { @ xcache_clear_cache ( XC_TYPE_PHP , 0 ) ; } } if ( static :: hasWinCache ( ) ) { if ( function_exists ( 'wincache_refresh_if_changed' ) ) { if ( $ file ) { @ wincache_refresh_if_changed ( ( array ) $ file ) ; } else { @ wincache_refresh_if_changed ( ) ; } } } if ( static :: hasZendOpCache ( ) ) { if ( $ file && function_exists ( 'opcache_invalidate' ) ) { @ opcache_invalidate ( $ file , true ) ; } elseif ( function_exists ( 'opcache_reset' ) ) { @ opcache_reset ( ) ; } } }
Clear the opcache .
10,407
public function deactivated ( DeactivateUser $ event ) { $ type = $ this -> notificationManager -> driver ( UserDeactivatedType :: IDENTIFIER ) ; $ notifier = $ type -> getNotifier ( ) ; if ( method_exists ( $ notifier , 'notify' ) ) { $ subscription = $ type -> getSubscription ( $ event ) ; $ users = $ notifier -> getUsersToNotify ( $ subscription , $ event ) ; $ notification = new UserDeactivatedNotification ( $ event ) ; $ notifier -> notify ( $ users , $ notification ) ; } }
Handle deactivated user events
10,408
public static function getResponse ( $ object ) { $ cache = Core :: make ( 'cache/request' ) ; $ identifier = sprintf ( 'permission/response/%s/%s' , get_class ( $ object ) , $ object -> getPermissionObjectIdentifier ( ) ) ; $ item = $ cache -> getItem ( $ identifier ) ; if ( ! $ item -> isMiss ( ) ) { return $ item -> get ( ) ; } $ className = $ object -> getPermissionResponseClassName ( ) ; $ pr = Core :: make ( $ className ) ; if ( $ object -> getPermissionObjectKeyCategoryHandle ( ) ) { $ category = PermissionKeyCategory :: getByHandle ( $ object -> getPermissionObjectKeyCategoryHandle ( ) ) ; $ pr -> setPermissionCategoryObject ( $ category ) ; } $ pr -> setPermissionObject ( $ object ) ; $ cache -> save ( $ item -> set ( $ pr ) ) ; return $ pr ; }
Passing in any object that implements the ObjectInterface retrieve the Permission Response object .
10,409
public function validate ( $ permissionHandle , $ args = array ( ) ) { $ u = new User ( ) ; if ( $ u -> isSuperUser ( ) ) { return true ; } if ( ! is_object ( $ this -> category ) ) { throw new Exception ( t ( 'Unable to get category for permission %s' , $ permissionHandle ) ) ; } $ pk = $ this -> category -> getPermissionKeyByHandle ( $ permissionHandle ) ; if ( ! $ pk ) { throw new Exception ( t ( 'Unable to get permission key for %s' , $ permissionHandle ) ) ; } $ pk -> setPermissionObject ( $ this -> object ) ; return call_user_func_array ( array ( $ pk , 'validate' ) , $ args ) ; }
This function returns true if the user has permission to the object or false if they do not have access .
10,410
protected function performSave ( $ args , $ loadExisting = false ) { if ( $ this -> btTable ) { $ db = Database :: connection ( ) ; $ columns = $ db -> MetaColumnNames ( $ this -> btTable ) ; $ this -> record = new BlockRecord ( $ this -> btTable ) ; $ this -> record -> bID = $ this -> bID ; if ( $ loadExisting ) { $ this -> record -> Load ( 'bID=' . $ this -> bID ) ; } if ( $ this -> supportSavingNullValues ) { foreach ( $ columns as $ key ) { if ( array_key_exists ( $ key , $ args ) ) { $ this -> record -> { $ key } = $ args [ $ key ] ; } } } else { foreach ( $ columns as $ key ) { if ( isset ( $ args [ $ key ] ) ) { $ this -> record -> { $ key } = $ args [ $ key ] ; } } } $ this -> record -> Replace ( ) ; if ( $ this -> cacheBlockRecord ( ) && Config :: get ( 'concrete.cache.blocks' ) ) { $ record = base64_encode ( serialize ( $ this -> record ) ) ; $ db = Database :: connection ( ) ; $ db -> Execute ( 'update Blocks set btCachedBlockRecord = ? where bID = ?' , [ $ record , $ this -> bID ] ) ; } } }
Persist the block options .
10,411
protected function load ( ) { if ( $ this -> btTable ) { if ( $ this -> btCacheBlockRecord && $ this -> btCachedBlockRecord && Config :: get ( 'concrete.cache.blocks' ) ) { $ this -> record = unserialize ( base64_decode ( $ this -> btCachedBlockRecord ) ) ; } else { $ this -> record = new BlockRecord ( $ this -> btTable ) ; $ this -> record -> bID = $ this -> bID ; $ this -> record -> Load ( 'bID=' . $ this -> bID ) ; if ( $ this -> btCacheBlockRecord && Config :: get ( 'concrete.cache.blocks' ) ) { $ record = base64_encode ( serialize ( $ this -> record ) ) ; $ db = Database :: connection ( ) ; $ db -> Execute ( 'update Blocks set btCachedBlockRecord = ? where bID = ?' , [ $ record , $ this -> bID ] ) ; } } } $ event = new \ Symfony \ Component \ EventDispatcher \ GenericEvent ( ) ; $ event -> setArgument ( 'record' , $ this -> record ) ; $ event -> setArgument ( 'btHandle' , $ this -> btHandle ) ; $ event -> setArgument ( 'bID' , $ this -> bID ) ; $ ret = Events :: dispatch ( 'on_block_load' , $ event ) ; $ this -> record = $ ret -> getArgument ( 'record' ) ; if ( is_object ( $ this -> record ) ) { foreach ( $ this -> record as $ key => $ value ) { $ this -> { $ key } = $ value ; $ this -> set ( $ key , $ value ) ; } } }
Loads the BlockRecord class based on its attribute names .
10,412
public function getActionURL ( $ task ) { try { if ( is_object ( $ this -> block ) ) { if ( is_object ( $ this -> block -> getProxyBlock ( ) ) ) { $ b = $ this -> block -> getProxyBlock ( ) ; } else { $ b = $ this -> block ; } $ action = $ this -> getAction ( ) ; if ( $ action === 'view' || strpos ( $ action , 'action_' ) === 0 ) { $ c = Page :: getCurrentPage ( ) ; if ( is_object ( $ b ) && is_object ( $ c ) ) { $ arguments = func_get_args ( ) ; $ arguments [ ] = $ b -> getBlockID ( ) ; array_unshift ( $ arguments , $ c ) ; return call_user_func_array ( array ( '\URL' , 'page' ) , $ arguments ) ; } } else { $ c = $ this -> getCollectionObject ( ) ; $ arguments = array_merge ( array ( '/ccm/system/block/action/edit' , $ c -> getCollectionID ( ) , urlencode ( $ this -> getAreaObject ( ) -> getAreaHandle ( ) ) , $ this -> block -> getBlockID ( ) , ) , func_get_args ( ) ) ; return call_user_func_array ( array ( '\URL' , 'to' ) , $ arguments ) ; } } else { $ c = \ Page :: getCurrentPage ( ) ; $ arguments = array_merge ( array ( '/ccm/system/block/action/add' , $ c -> getCollectionID ( ) , urlencode ( $ this -> getAreaObject ( ) -> getAreaHandle ( ) ) , $ this -> getBlockTypeID ( ) , ) , func_get_args ( ) ) ; return call_user_func_array ( array ( '\URL' , 'to' ) , $ arguments ) ; } } catch ( \ Exception $ e ) { } }
Creates a URL that can be posted or navigated to that when done so will automatically run the corresponding method inside the block s controller . It can also be used to perform system operations accordingly to the current action .
10,413
public function getBlockObject ( ) { if ( is_object ( $ this -> block ) ) { return $ this -> block ; } return Block :: getByID ( $ this -> bID ) ; }
Gets the generic Block object attached to this controller s instance .
10,414
public function delete ( ) { if ( $ this -> bID > 0 ) { if ( $ this -> btTable ) { $ ni = new BlockRecord ( $ this -> btTable ) ; $ ni -> bID = $ this -> bID ; $ ni -> Load ( 'bID=' . $ this -> bID ) ; $ ni -> delete ( ) ; } } }
Automatically run when a block is deleted . This removes the special data from the block s specific database table . If a block needs to do more than this this method should be overridden .
10,415
protected function setViewHelpers ( ) { $ this -> set ( 'token' , $ this -> app -> make ( 'token' ) ) ; $ this -> set ( 'form' , $ this -> app -> make ( 'helper/form' ) ) ; $ this -> set ( 'ui' , $ this -> app -> make ( 'helper/concrete/ui' ) ) ; $ this -> set ( 'resolverManager' , $ this -> app -> make ( ResolverManagerInterface :: class ) ) ; }
Set the helpers for the view .
10,416
protected function setViewSets ( ) { $ config = $ this -> app -> make ( 'config' ) ; $ this -> set ( 'formID' , 'ccm-file-manager-import-files-' . $ this -> app -> make ( Identifier :: class ) -> getString ( 32 ) ) ; $ this -> set ( 'currentFolder' , $ this -> getCurrentFolder ( ) ) ; $ this -> set ( 'originalPage' , $ this -> getOriginalPage ( ) ) ; $ this -> set ( 'isChunkingEnabled' , ( bool ) $ config -> get ( 'concrete.upload.chunking.enabled' ) ) ; $ chunkSize = ( int ) $ config -> get ( 'concrete.upload.chunking.chunkSize' ) ; if ( $ chunkSize < 1 ) { $ chunkSize = $ this -> getAutomaticChunkSize ( ) ; } $ this -> set ( 'chunkSize' , $ chunkSize ) ; $ incoming = $ this -> app -> make ( Incoming :: class ) ; $ this -> set ( 'incomingStorageLocation' , $ incoming -> getIncomingStorageLocation ( ) ) ; $ this -> set ( 'incomingPath' , $ incoming -> getIncomingPath ( ) ) ; try { $ incomingContents = $ this -> getIncomingFiles ( ) ; $ incomingContentsError = null ; } catch ( Exception $ e ) { $ incomingContents = [ ] ; $ incomingContentsError = $ e -> getMessage ( ) ; $ incomingContents = $ e ; } catch ( Throwable $ e ) { $ incomingContents = [ ] ; $ incomingContentsError = $ e -> getMessage ( ) ; } $ this -> set ( 'incomingContents' , $ incomingContents ) ; $ this -> set ( 'incomingContentsError' , $ incomingContentsError ) ; $ this -> set ( 'replacingFile' , null ) ; }
Set the variables for the view .
10,417
protected function getCurrentFolder ( ) { if ( $ this -> currentFolder === false ) { $ currentFolder = null ; $ fID = $ this -> request -> request -> get ( 'currentFolder' , $ this -> request -> query -> get ( 'currentFolder' ) ) ; if ( $ fID && is_scalar ( $ fID ) ) { $ fID = ( int ) $ fID ; if ( $ fID !== 0 ) { $ node = Node :: getByID ( $ fID ) ; if ( $ node instanceof FileFolder ) { $ currentFolder = $ node ; } } } $ this -> setCurrentFolder ( $ currentFolder ) ; } return $ this -> currentFolder ; }
Get the current folder .
10,418
protected function setCurrentFolder ( FileFolder $ value = null ) { if ( $ value !== $ this -> currentFolder ) { $ this -> currentFolder = $ value ; $ this -> currentFolderPermissions = null ; } return $ this ; }
Set the current folder .
10,419
protected function getCurrentFolderPermissions ( ) { if ( $ this -> currentFolderPermissions === null ) { $ folder = $ this -> getCurrentFolder ( ) ; if ( $ folder === null ) { $ folder = $ this -> app -> make ( Filesystem :: class ) -> getRootFolder ( ) ; if ( $ folder === null ) { $ folder = new FileFolder ( ) ; } } $ this -> currentFolderPermissions = new Checker ( $ folder ) ; } return $ this -> currentFolderPermissions ; }
Get the permissions for the current folder .
10,420
protected function getOriginalPage ( ) { if ( $ this -> originalPage === false ) { $ originalPage = null ; $ ocID = $ this -> request -> request -> get ( 'ocID' , $ this -> request -> query -> get ( 'ocID' ) ) ; if ( $ ocID && is_scalar ( $ ocID ) ) { $ ocID = ( int ) $ ocID ; if ( $ ocID !== 0 ) { $ originalPage = Page :: getByID ( $ ocID ) ; } } $ this -> setOriginalPage ( $ originalPage ) ; } return $ this -> originalPage ; }
Get the page where the file is originally placed on .
10,421
protected function setOriginalPage ( Page $ value = null ) { $ this -> originalPage = $ value === null || $ value -> isError ( ) ? null : $ value ; return $ this ; }
Set the page where the file is originally placed on .
10,422
protected function getAutomaticChunkSize ( ) { $ nh = $ this -> app -> make ( 'helper/number' ) ; $ uploadMaxFilesize = ( int ) $ nh -> getBytes ( ini_get ( 'upload_max_filesize' ) ) - 100 ; $ postMaxSize = ( int ) $ nh -> getBytes ( ini_get ( 'post_max_size' ) ) - 10000 ; if ( $ uploadMaxFilesize < 1 && $ postMaxSize < 1 ) { return 2000000 ; } if ( $ uploadMaxFilesize < 1 ) { return $ postMaxSize ; } if ( $ postMaxSize < 1 ) { return $ uploadMaxFilesize ; } return min ( $ uploadMaxFilesize , $ postMaxSize ) ; }
Determine the chunk size for chunked uploads .
10,423
protected function getIncomingFiles ( ) { $ fh = $ this -> app -> make ( 'helper/validation/file' ) ; $ nh = $ this -> app -> make ( 'helper/number' ) ; $ incoming = $ this -> app -> make ( Incoming :: class ) ; $ files = $ incoming -> getIncomingFilesystem ( ) -> listContents ( $ incoming -> getIncomingPath ( ) ) ; foreach ( array_keys ( $ files ) as $ index ) { $ files [ $ index ] [ 'allowed' ] = $ fh -> extension ( $ files [ $ index ] [ 'basename' ] ) ; $ files [ $ index ] [ 'thumbnail' ] = FileTypeList :: getType ( $ files [ $ index ] [ 'extension' ] ) -> getThumbnail ( ) ; $ files [ $ index ] [ 'displaySize' ] = $ nh -> formatSize ( $ files [ $ index ] [ 'size' ] , 'KB' ) ; } return $ files ; }
Get the list of files available in the incoming directory .
10,424
public function findByFile ( $ file ) { if ( $ file instanceof File ) { $ file = $ file -> getFileID ( ) ; } return $ this -> findBy ( [ 'file_id' => $ file ] ) ; }
Find usage records related to a file
10,425
public function findByCollection ( $ collection , $ version = null ) { if ( $ collection instanceof Collection ) { $ collection = $ collection -> getCollectionID ( ) ; } $ criteria = [ 'collection_id' => $ collection ] ; if ( $ version && $ version instanceof Version ) { $ version = $ version -> getVersionID ( ) ; } if ( $ version ) { $ criteria [ 'collection_version_id' ] = $ version ; } return $ this -> findBy ( $ criteria ) ; }
Find FileUsageRecords given a collection and a version
10,426
public function findByBlock ( $ block ) { if ( $ block instanceof Block ) { $ block = $ block -> getBlockID ( ) ; } elseif ( $ block instanceof BlockController ) { $ block = $ block -> getBlockObject ( ) -> getBlockID ( ) ; } return $ this -> findBy ( [ 'block_id' => $ block ] ) ; }
Find FileUsageRecords given a block
10,427
public function register ( ) { $ this -> registerFileConfig ( ) ; $ this -> registerDatabaseConfig ( ) ; $ this -> app -> bind ( 'Concrete\Core\Config\Repository\Repository' , 'config' ) ; $ this -> app -> bind ( 'Illuminate\Config\Repository' , 'Concrete\Core\Config\Repository\Repository' ) ; }
Configuration repositories .
10,428
private function registerFileConfig ( ) { $ this -> app -> singleton ( 'config' , function ( $ app ) { $ loader = $ app -> make ( 'Concrete\Core\Config\FileLoader' ) ; $ saver = $ app -> make ( 'Concrete\Core\Config\FileSaver' ) ; return $ app -> build ( 'Concrete\Core\Config\Repository\Repository' , array ( $ loader , $ saver , $ app -> environment ( ) ) ) ; } ) ; }
Create a file config repository .
10,429
private function registerDatabaseConfig ( ) { $ this -> app -> bindShared ( 'config/database' , function ( $ app ) { $ loader = $ app -> make ( 'Concrete\Core\Config\DatabaseLoader' ) ; $ saver = $ app -> make ( 'Concrete\Core\Config\DatabaseSaver' ) ; return $ app -> build ( 'Concrete\Core\Config\Repository\Repository' , array ( $ loader , $ saver , $ app -> environment ( ) ) ) ; } ) ; }
Create a database config repository .
10,430
public function filter ( $ column , $ value , $ comparison = '=' ) { $ foundFilterIndex = - 1 ; if ( $ column ) { foreach ( $ this -> filters as $ key => $ info ) { if ( $ info [ 0 ] == $ column ) { $ foundFilterIndex = $ key ; break ; } } } if ( $ foundFilterIndex > - 1 ) { $ this -> filters [ $ foundFilterIndex ] = array ( $ column , $ value , $ comparison ) ; } else { $ this -> filters [ ] = array ( $ column , $ value , $ comparison ) ; } }
Adds a filter to this item list .
10,431
protected function prepareConfig ( $ config ) { if ( isset ( $ config [ 'loggers' ] ) && is_array ( $ config [ 'loggers' ] ) && array_key_exists ( Channels :: META_CHANNEL_ALL , $ config [ 'loggers' ] ) ) { $ allConfig = $ config [ 'loggers' ] [ Channels :: META_CHANNEL_ALL ] ; $ channels = array_merge ( Channels :: getCoreChannels ( ) , [ Channels :: CHANNEL_APPLICATION ] ) ; foreach ( $ channels as $ channel ) { $ config [ 'loggers' ] [ $ channel ] = $ allConfig ; } unset ( $ config [ 'loggers' ] [ Channels :: META_CHANNEL_ALL ] ) ; } return $ config ; }
Takes the config array we re going to pass to monolog cascade and transforms it a bit . For example if we have configuration we need to apply to all channels we loop through all the channels in the channels class and add them to the config array .
10,432
public function filterByExtension ( $ extension ) { $ extensions = is_array ( $ extension ) ? $ extension : [ $ extension ] ; if ( count ( $ extensions ) > 0 ) { $ expr = $ this -> query -> expr ( ) ; $ or = $ expr -> orX ( ) ; foreach ( $ extensions as $ extension ) { $ extension = ltrim ( ( string ) $ extension , '.' ) ; $ or -> add ( $ expr -> eq ( 'fv.fvExtension' , $ this -> query -> createNamedParameter ( $ extension ) ) ) ; if ( $ extension === '' ) { $ or -> add ( $ expr -> isNull ( 'fv.fvExtension' ) ) ; } } $ this -> query -> andWhere ( $ or ) ; } }
Filter the files by their extension .
10,433
public function getPath ( ) { $ pathInfo = rawurldecode ( $ this -> getPathInfo ( ) ) ; $ path = '/' . trim ( $ pathInfo , '/' ) ; return ( $ path == '/' ) ? '' : $ path ; }
Returns the full path for a request .
10,434
public static function post ( $ key = null , $ defaultValue = null ) { if ( $ key == null ) { return $ _POST ; } if ( isset ( $ _POST [ $ key ] ) ) { return ( is_string ( $ _POST [ $ key ] ) ) ? trim ( $ _POST [ $ key ] ) : $ _POST [ $ key ] ; } return $ defaultValue ; }
If no arguments are passed returns the post array . If a key is passed it returns the value as it exists in the post array . If a default value is provided and the key does not exist in the POST array the default value is returned .
10,435
public function delete ( ) { $ db = Loader :: db ( ) ; $ v = array ( $ this -> pID ) ; $ q = "delete from Piles where pID = ?" ; $ db -> query ( $ q , $ v ) ; $ q2 = "delete from PileContents where pID = ?" ; $ db -> query ( $ q , $ v ) ; return true ; }
Delete a pile .
10,436
public function isAjaxRequest ( Request $ request ) { $ result = false ; $ requestedWith = $ request -> server -> get ( 'HTTP_X_REQUESTED_WITH' ) ; if ( is_string ( $ requestedWith ) && strcasecmp ( $ requestedWith , 'XMLHttpRequest' ) === 0 ) { $ result = true ; } return $ result ; }
Check if a request is an Ajax call .
10,437
public function sendResult ( $ result ) { if ( @ ob_get_length ( ) ) { @ ob_end_clean ( ) ; } if ( isset ( $ _SERVER [ 'HTTP_ACCEPT' ] ) && strpos ( $ _SERVER [ 'HTTP_ACCEPT' ] , 'application/json' ) !== false ) { header ( 'Content-Type: application/json; charset=' . APP_CHARSET , true ) ; } else { header ( 'Content-Type: text/plain; charset=' . APP_CHARSET , true ) ; } echo json_encode ( $ result ) ; die ( ) ; }
Sends a result to the client and ends the execution .
10,438
public function sendError ( $ error ) { if ( @ ob_get_length ( ) ) { @ ob_end_clean ( ) ; } if ( $ error instanceof \ Concrete \ Core \ Error \ ErrorList \ ErrorList ) { $ error -> outputJSON ( ) ; } else { header ( $ _SERVER [ 'SERVER_PROTOCOL' ] . ' 400 Bad Request' , true , 400 ) ; header ( 'Content-Type: text/plain; charset=' . APP_CHARSET , true ) ; echo ( $ error instanceof Exception ) ? $ error -> getMessage ( ) : $ error ; } die ( ) ; }
Sends an error to the client and ends the execution .
10,439
public function containsString ( $ needle , $ haystack = array ( ) , $ recurse = true ) { $ stringHelper = Core :: make ( 'helper/validation/strings' ) ; if ( ! $ stringHelper -> notempty ( $ needle ) ) { return false ; } $ arr = ( ! is_array ( $ haystack ) ) ? array ( $ haystack ) : $ haystack ; foreach ( $ arr as $ item ) { if ( $ stringHelper -> notempty ( $ item ) && strstr ( $ item , $ needle ) !== false ) { return true ; } elseif ( $ recurse && is_array ( $ item ) && $ this -> containsString ( $ needle , $ item ) ) { return true ; } } return false ; }
Returns true if any string in the haystack contains the needle .
10,440
private function parseKeys ( $ keys ) { if ( is_string ( $ keys ) ) { if ( strpos ( $ keys , '[' ) !== false ) { $ keys = str_replace ( ']' , '' , $ keys ) ; $ keys = explode ( '[' , trim ( $ keys , '[' ) ) ; } else { $ keys = ( array ) $ keys ; } } return $ keys ; }
Turns the string keys into an array of keys .
10,441
public function flatten ( array $ array ) { $ tmp = array ( ) ; foreach ( $ array as $ a ) { if ( is_array ( $ a ) ) { $ tmp = array_merge ( $ tmp , array_flat ( $ a ) ) ; } else { $ tmp [ ] = $ a ; } } return $ tmp ; }
Takes a multidimensional array and flattens it .
10,442
public function sanitizeFile ( $ inputFilename , SanitizerOptions $ options = null , $ outputFilename = '' ) { $ data = is_string ( $ inputFilename ) && $ this -> filesystem -> isFile ( $ inputFilename ) ? $ this -> filesystem -> get ( $ inputFilename ) : false ; if ( $ data === false ) { throw SanitizerException :: create ( SanitizerException :: ERROR_FAILED_TO_READ_FILE ) ; } $ sanitizedData = $ this -> sanitizeData ( $ data , $ options ) ; if ( ( string ) $ outputFilename === '' ) { $ outputFilename = $ inputFilename ; } if ( $ outputFilename !== $ inputFilename || $ data !== $ sanitizedData ) { if ( $ this -> filesystem -> put ( $ outputFilename , $ sanitizedData ) === false ) { throw SanitizerException :: create ( SanitizerException :: ERROR_FAILED_TO_WRITE_FILE ) ; } } }
Sanitize a file containing an SVG document .
10,443
public function sanitizeData ( $ data , SanitizerOptions $ options = null ) { $ xml = $ this -> dataToXml ( $ data ) ; if ( $ options === null ) { $ options = new SanitizerOptions ( ) ; } $ this -> processNode ( $ xml -> documentElement , $ options ) ; return $ this -> xmlToData ( $ xml ) ; }
Sanitize a string containing an SVG document .
10,444
protected function getLoadFlags ( ) { $ flags = LIBXML_NONET | LIBXML_NOWARNING ; foreach ( [ 'LIBXML_PARSEHUGE' , 'LIBXML_HTML_NOIMPLIED' , 'LIBXML_HTML_NODEFDTD' , 'LIBXML_BIGLINES' , ] as $ flagName ) { if ( defined ( $ flagName ) ) { $ flags |= constant ( $ flagName ) ; } } return $ flags ; }
Get the flags to be used when loading the XML .
10,445
protected function dataToXml ( $ data ) { if ( ! is_string ( $ data ) ) { throw SanitizerException :: create ( SanitizerException :: ERROR_FAILED_TO_PARSE_XML ) ; } $ xml = new DOMDocument ( ) ; $ error = null ; try { $ loaded = $ xml -> loadXML ( $ data , $ this -> getLoadFlags ( ) ) ; } catch ( Exception $ x ) { $ error = $ x ; } catch ( Throwable $ x ) { $ error = $ x ; } if ( $ error !== null || $ loaded === false ) { throw SanitizerException :: create ( SanitizerException :: ERROR_FAILED_TO_PARSE_XML , $ error ? $ error -> getMessage ( ) : '' ) ; } return $ xml ; }
Create a DOMDocument instance from a string .
10,446
protected function xmlToData ( DOMDocument $ xml ) { $ data = $ xml -> saveXML ( ) ; if ( $ data === false ) { throw SanitizerException :: create ( SanitizerException :: ERROR_FAILED_TO_GENERATE_XML ) ; } return $ data ; }
Render a DOMDocument instance as a string .
10,447
public function getDefaultCharacterSet ( ) { $ characterSet = $ this -> config -> get ( 'database.preferred_character_set' ) ; $ characterSet = $ this -> normalizeCharacterSet ( $ characterSet ) ; return $ characterSet ; }
Get the default character set .
10,448
public function setCharacterSet ( $ characterSet ) { if ( $ characterSet !== null ) { $ characterSet = $ this -> normalizeCharacterSet ( $ characterSet ) ; } $ this -> characterSet = $ characterSet ; return $ this ; }
Set the character set .
10,449
public function getDefaultCollation ( ) { $ collation = $ this -> config -> get ( 'database.preferred_collation' ) ; $ collation = $ this -> normalizeCollation ( $ collation ) ; return $ collation ; }
Get the default collation .
10,450
public function setCollation ( $ collation ) { if ( $ collation !== null ) { $ collation = $ this -> normalizeCollation ( $ collation ) ; } $ this -> collation = $ collation ; return $ this ; }
Set the collation .
10,451
public function resolveCharacterSetAndCollation ( Connection $ connection ) { $ characterSet = $ this -> getCharacterSet ( ) ; $ collation = $ this -> getCollation ( ) ; if ( $ collation !== '' ) { $ collations = $ connection -> getSupportedCollations ( ) ; if ( ! isset ( $ collations [ $ collation ] ) ) { throw new Exception \ UnsupportedCollationException ( $ collation ) ; } if ( $ characterSet === '' ) { $ characterSet = $ collations [ $ collation ] ; } elseif ( $ characterSet !== $ collations [ $ collation ] ) { throw new Exception \ InvalidCharacterSetCollationCombination ( $ characterSet , $ collation , $ collations [ $ characterSet ] ) ; } } elseif ( $ characterSet !== '' ) { $ characterSets = $ connection -> getSupportedCharsets ( ) ; if ( ! isset ( $ characterSets [ $ characterSet ] ) ) { throw new Exception \ UnsupportedCharacterSetException ( $ characterSet ) ; } $ collation = $ characterSets [ $ characterSet ] ; } else { throw new Exception \ NoCharacterSetCollationDefinedException ( ) ; } if ( ! $ connection -> isCollationSupportedForKeys ( $ collation , $ this -> getMaximumStringKeyLength ( ) ) ) { throw new Exception \ LongKeysUnsupportedByCollation ( $ collation , $ this -> getMaximumStringKeyLength ( ) ) ; } return [ $ characterSet , $ collation ] ; }
Resolve the character set and collation .
10,452
public function getConfiguration ( ) { $ driverChain = $ this -> getMetadataDriverImpl ( ) ; $ this -> configuration -> setMetadataDriverImpl ( $ driverChain ) ; return $ this -> configuration ; }
Add driverChain and get orm config
10,453
public static function questionCleanup ( $ qsID = 0 , $ bID = 0 ) { $ db = Database :: connection ( ) ; $ vals = array ( intval ( $ qsID ) ) ; $ questionsWithBIDs = $ db -> fetchColumn ( 'SELECT count(*) FROM btFormQuestions WHERE bID!=0 AND questionSetId=? ' , $ vals ) ; if ( ! $ questionsWithBIDs ) { $ vals = array ( intval ( $ bID ) , intval ( $ qsID ) ) ; $ rs = $ db -> executeQuery ( 'UPDATE btFormQuestions SET bID=? WHERE bID=0 AND questionSetId=?' , $ vals ) ; return ; } $ vals = array ( intval ( $ qsID ) ) ; $ rs = $ db -> executeQuery ( 'DELETE FROM btFormQuestions WHERE bID=0 AND questionSetId=?' , $ vals ) ; }
Run on Form block edit
10,454
public function save ( $ item , $ value , $ environment , $ group , $ namespace = null ) { $ builder = $ this -> getConnection ( ) -> createQueryBuilder ( ) ; $ query = $ builder -> delete ( 'Config' ) -> where ( 'configNamespace = :namespace' , 'configGroup = :group' , 'configItem LIKE :item' ) -> setParameters ( array ( ':namespace' => $ namespace ? : '' , ':group' => $ group , ':item' => "{$item}.%" , ) ) ; $ amount_deleted = $ query -> execute ( ) ; $ this -> doSave ( $ item , $ value , $ environment , $ group , $ namespace ) ; }
Save config item .
10,455
public function view ( $ pThemeID = null , $ message = false ) { if ( ! $ pThemeID ) { $ this -> redirect ( '/dashboard/pages/themes/' ) ; } $ v = Loader :: helper ( 'validation/error' ) ; $ pt = PageTheme :: getByID ( $ pThemeID ) ; if ( is_object ( $ pt ) ) { $ files = $ pt -> getFilesInTheme ( ) ; $ this -> set ( 'files' , $ files ) ; $ this -> set ( 'pThemeID' , $ pThemeID ) ; $ this -> set ( 'pageTheme' , $ pt ) ; } else { $ v -> add ( 'Invalid Theme' ) ; } switch ( $ message ) { case 'install' : $ this -> set ( 'message' , t ( "Theme installed. You may automatically create page templates from template files contained in your theme using the form below." ) ) ; break ; case 'activate' : $ this -> set ( 'message' , t ( "Theme activated. You may automatically create page templates from template files contained in your theme using the form below." ) ) ; break ; } if ( $ v -> has ( ) ) { $ this -> set ( 'error' , $ v ) ; } $ this -> set ( 'disableThirdLevelNav' , true ) ; }
grab all the page types from within a theme
10,456
public function createTextIndexes ( array $ textIndexes ) { if ( ! empty ( $ textIndexes ) ) { $ sm = $ this -> getSchemaManager ( ) ; foreach ( $ textIndexes as $ tableName => $ indexes ) { if ( $ sm -> tablesExist ( [ $ tableName ] ) ) { $ existingIndexNames = array_map ( function ( \ Doctrine \ DBAL \ Schema \ Index $ index ) { return $ index -> getShortestName ( '' ) ; } , $ sm -> listTableIndexes ( $ tableName ) ) ; $ chunks = [ ] ; foreach ( $ indexes as $ indexName => $ indexColumns ) { if ( ! in_array ( strtolower ( $ indexName ) , $ existingIndexNames , true ) ) { $ newIndexColumns = [ ] ; foreach ( ( array ) $ indexColumns as $ indexColumn ) { $ indexColumn = ( array ) $ indexColumn ; $ s = $ this -> quoteIdentifier ( $ indexColumn [ 0 ] ) ; if ( ! empty ( $ indexColumn [ 1 ] ) ) { $ s .= '(' . ( int ) $ indexColumn [ 1 ] . ')' ; } $ newIndexColumns [ ] = $ s ; } $ chunks [ ] = $ this -> quoteIdentifier ( $ indexName ) . ' (' . implode ( ', ' , $ newIndexColumns ) . ')' ; } } if ( ! empty ( $ chunks ) ) { $ sql = 'ALTER TABLE ' . $ this -> quoteIdentifier ( $ tableName ) . ' ADD INDEX ' . implode ( ', ADD INDEX ' , $ chunks ) ; $ this -> executeQuery ( $ sql ) ; } } } } }
This is essentially a workaround for not being able to define indexes on TEXT fields with the current version of Doctrine DBAL . This feature will be removed when DBAL will support it so don t use this feature .
10,457
public function replace ( $ table , $ fieldArray , $ keyCol , $ autoQuote = true ) { $ qb = $ this -> createQueryBuilder ( ) ; $ qb -> select ( 'count(*)' ) -> from ( $ table , 't' ) ; $ where = $ qb -> expr ( ) -> andX ( ) ; $ updateKeys = [ ] ; if ( ! is_array ( $ keyCol ) ) { $ keyCol = [ $ keyCol ] ; } foreach ( $ keyCol as $ key ) { if ( isset ( $ fieldArray [ $ key ] ) ) { $ field = $ fieldArray [ $ key ] ; } else { $ field = null ; } $ updateKeys [ $ key ] = $ field ; if ( $ autoQuote ) { $ field = $ qb -> expr ( ) -> literal ( $ field ) ; } $ where -> add ( $ qb -> expr ( ) -> eq ( $ key , $ field ) ) ; } $ qb -> where ( $ where ) ; $ sql = $ qb -> getSql ( ) ; $ num = parent :: query ( $ sql ) -> fetchColumn ( ) ; if ( $ num ) { $ update = true ; } else { try { $ this -> insert ( $ table , $ fieldArray ) ; $ update = false ; } catch ( UniqueConstraintViolationException $ x ) { $ update = true ; } } if ( $ update ) { $ this -> update ( $ table , $ fieldArray , $ updateKeys ) ; } }
Insert or update a row in a database table .
10,458
public function getSupportedCharsets ( ) { if ( $ this -> supportedCharsets === null ) { $ supportedCharsets = [ ] ; $ rs = $ this -> executeQuery ( 'SHOW CHARACTER SET' ) ; while ( ( $ row = $ rs -> fetch ( PDO :: FETCH_ASSOC ) ) !== false ) { if ( ! isset ( $ row [ 'Charset' ] ) || ! isset ( $ row [ 'Default collation' ] ) ) { throw new Exception ( t ( 'Unrecognized result of the "%s" database query.' , 'SHOW CHARACTER SET' ) ) ; } $ supportedCharsets [ strtolower ( $ row [ 'Charset' ] ) ] = strtolower ( $ row [ 'Default collation' ] ) ; } $ this -> supportedCharsets = $ supportedCharsets ; } return $ this -> supportedCharsets ; }
Get the supported character sets and associated default collation .
10,459
public function getSupportedCollations ( ) { if ( $ this -> supportedCollations === null ) { $ supportedCollations = [ ] ; $ rs = $ this -> executeQuery ( 'SHOW COLLATION' ) ; while ( ( $ row = $ rs -> fetch ( PDO :: FETCH_ASSOC ) ) !== false ) { if ( ! isset ( $ row [ 'Collation' ] ) || ! isset ( $ row [ 'Charset' ] ) ) { throw new Exception ( t ( 'Unrecognized result of the "%s" database query.' , 'SHOW COLLATION' ) ) ; } $ supportedCollations [ strtolower ( $ row [ 'Collation' ] ) ] = strtolower ( $ row [ 'Charset' ] ) ; } $ this -> supportedCollations = $ supportedCollations ; } return $ this -> supportedCollations ; }
Get the supported collations and the associated character sets .
10,460
public function isCollationSupportedForKeys ( $ collation , $ fieldLength ) { $ sm = $ this -> getSchemaManager ( ) ; $ existingTables = array_map ( 'strtolower' , $ sm -> listTableNames ( ) ) ; for ( $ i = 0 ; ; ++ $ i ) { $ tableName = 'tmp_checkCollationFieldLength' . $ i ; if ( ! in_array ( strtolower ( $ tableName ) , $ existingTables ) ) { break ; } } $ column = new DbalColumn ( 'ColumnName' , DbalType :: getType ( DbalType :: STRING ) , [ 'length' => ( int ) $ fieldLength ] ) ; $ column -> setPlatformOption ( 'collation' , ( string ) $ collation ) ; $ table = new DbalTable ( $ tableName , [ $ column ] ) ; $ table -> setPrimaryKey ( [ $ column -> getName ( ) ] ) ; try { $ sm -> createTable ( $ table ) ; } catch ( Exception $ x ) { return false ; } try { $ sm -> dropTable ( $ tableName ) ; } catch ( Exception $ x ) { } return true ; }
Check if a collation can be used for keys of a specific length .
10,461
private function projectRange ( IPRange $ range ) { $ result = [ $ range -> getIpRange ( ) -> toString ( ) , $ range -> getIpRange ( ) -> getComparableStartString ( ) , $ range -> getIpRange ( ) -> getComparableEndString ( ) , ] ; if ( $ this -> type === IPService :: IPRANGETYPE_BLACKLIST_AUTOMATIC ) { $ dt = $ range -> getExpires ( ) ; if ( $ dt === null ) { $ result [ ] = '' ; } else { $ result [ ] = $ this -> dateHelper -> formatCustom ( 'c' , $ dt ) ; } } return $ result ; }
Turn an IPRange instance into an array .
10,462
private function getHeaders ( ) { $ headers = [ t ( 'IP Range' ) , t ( 'Start address' ) , t ( 'End address' ) ] ; if ( $ this -> type === IPService :: IPRANGETYPE_BLACKLIST_AUTOMATIC ) { $ headers [ ] = t ( 'Expiration' ) ; } return $ headers ; }
Get the headers of the CSV .
10,463
public function showControls ( ) { if ( $ this -> showControls === true || $ this -> showControls === false ) { return $ this -> showControls ; } else { $ c = $ this -> getAreaCollectionObject ( ) ; return $ c -> isEditMode ( ) ; } }
Returns whether or not controls are to be displayed .
10,464
public function getTotalBlocksInArea ( $ c = false ) { if ( ! $ c ) { $ c = $ this -> c ; } $ this -> load ( $ c ) ; $ db = Database :: connection ( ) ; $ r = $ db -> fetchColumn ( 'select count(b.bID) from CollectionVersionBlocks cvb inner join Blocks b on cvb.bID = b.bID inner join BlockTypes bt on b.btID = bt.btID where cID = ? and cvID = ? and arHandle = ? and btHandle <> ?' , array ( $ c -> getCollectionID ( ) , $ c -> getVersionID ( ) , $ this -> arHandle , BLOCK_HANDLE_LAYOUT_PROXY ) ) ; $ arHandles = $ db -> GetCol ( 'select arHandle from Areas where arParentID = ?' , array ( $ this -> arID ) ) ; if ( is_array ( $ arHandles ) && count ( $ arHandles ) > 0 ) { $ v = array ( $ c -> getCollectionID ( ) , $ c -> getVersionID ( ) ) ; $ q = 'select count(bID) from CollectionVersionBlocks where cID = ? and cvID = ? and arHandle in (' ; for ( $ i = 0 ; $ i < count ( $ arHandles ) ; ++ $ i ) { $ arHandle = $ arHandles [ $ i ] ; $ v [ ] = $ arHandle ; $ q .= '?' ; if ( ( $ i + 1 ) < count ( $ arHandles ) ) { $ q .= ',' ; } } $ q .= ')' ; $ sr = $ db -> fetchColumn ( $ q , $ v ) ; $ r += $ sr ; } return ( int ) $ r ; }
Returns the total number of blocks in an area .
10,465
public function getTotalBlocksInAreaEditMode ( ) { $ db = Database :: connection ( ) ; return ( int ) $ db -> fetchColumn ( 'select count(b.bID) from CollectionVersionBlocks cvb inner join Blocks b on cvb.bID = b.bID inner join BlockTypes bt on b.btID = bt.btID where cID = ? and cvID = ? and arHandle = ?' , array ( $ this -> c -> getCollectionID ( ) , $ this -> c -> getVersionID ( ) , $ this -> arHandle ) ) ; }
Returns the amount of actual blocks in the area does not exclude core blocks or layouts does not recurse .
10,466
final public static function get ( $ c , $ arHandle ) { if ( ! is_object ( $ c ) ) { return false ; } $ identifier = sprintf ( '/page/area/%s' , $ c -> getCollectionID ( ) ) ; $ cache = \ Core :: make ( 'cache/request' ) ; $ item = $ cache -> getItem ( $ identifier ) ; if ( ! $ item -> isMiss ( ) ) { $ areas = $ item -> get ( ) ; } else { $ areas = array ( ) ; $ db = Database :: connection ( ) ; $ v = array ( $ c -> getCollectionID ( ) ) ; $ q = 'select arID, arHandle, cID, arOverrideCollectionPermissions, arInheritPermissionsFromAreaOnCID, arIsGlobal, arParentID from Areas where cID = ?' ; $ r = $ db -> executeQuery ( $ q , $ v ) ; while ( $ arRow = $ r -> FetchRow ( ) ) { if ( $ arRow [ 'arID' ] > 0 ) { if ( $ arRow [ 'arIsGlobal' ] ) { $ obj = new GlobalArea ( $ arHandle ) ; } else { if ( $ arRow [ 'arParentID' ] ) { $ arParentHandle = self :: getAreaHandleFromID ( $ arRow [ 'arParentID' ] ) ; $ obj = new SubArea ( $ arHandle , $ arParentHandle , $ arRow [ 'arParentID' ] ) ; } else { $ obj = new self ( $ arHandle ) ; } } $ obj -> setPropertiesFromArray ( $ arRow ) ; $ obj -> c = $ c ; $ arRowHandle = $ arRow [ 'arHandle' ] ; $ areas [ $ arRowHandle ] = $ obj ; } } $ cache -> save ( $ item -> set ( $ areas ) ) ; } return isset ( $ areas [ $ arHandle ] ) ? $ areas [ $ arHandle ] : null ; }
Gets the Area object for the given page and area handle .
10,467
public function create ( $ c , $ arHandle ) { $ db = Database :: connection ( ) ; $ db -> Replace ( 'Areas' , array ( 'cID' => $ c -> getCollectionID ( ) , 'arHandle' => $ arHandle , 'arIsGlobal' => $ this -> isGlobalArea ( ) ? 1 : 0 ) , array ( 'arHandle' , 'cID' ) , true ) ; $ this -> refreshCache ( $ c ) ; $ area = self :: get ( $ c , $ arHandle ) ; $ area -> rescanAreaPermissionsChain ( ) ; return $ area ; }
Creates an area in the database . I would like to make this static but PHP pre 5 . 3 sucks at this stuff .
10,468
public function getAreaBlocksArray ( $ c = false ) { if ( ! $ c ) { $ c = $ this -> c ; } if ( ! $ this -> arIsLoaded ) { $ this -> load ( $ c ) ; } return $ this -> areaBlocksArray ; }
Get all of the blocks within the current area for a given page .
10,469
public static function getHandleList ( ) { $ db = Database :: connection ( ) ; $ r = $ db -> executeQuery ( 'select distinct arHandle from Areas where arParentID = 0 and arIsGlobal = 0 order by arHandle asc' ) ; $ handles = array ( ) ; while ( $ row = $ r -> FetchRow ( ) ) { $ handles [ ] = $ row [ 'arHandle' ] ; } $ r -> Free ( ) ; unset ( $ r ) ; unset ( $ db ) ; return $ handles ; }
Gets a list of all areas .
10,470
public function revertToPagePermissions ( ) { $ db = Database :: connection ( ) ; $ v = array ( $ this -> getAreaHandle ( ) , $ this -> getCollectionID ( ) ) ; $ db -> executeQuery ( 'delete from AreaPermissionAssignments where arHandle = ? and cID = ?' , $ v ) ; $ db -> executeQuery ( 'update Areas set arOverrideCollectionPermissions = 0 where arID = ?' , array ( $ this -> getAreaID ( ) ) ) ; $ this -> arOverrideCollectionPermissions = false ; $ this -> rescanAreaPermissionsChain ( ) ; $ areac = $ this -> getAreaCollectionObject ( ) ; if ( $ areac -> isMasterCollection ( ) ) { $ this -> rescanSubAreaPermissionsMasterCollection ( $ areac ) ; } else { if ( $ areac -> overrideTemplatePermissions ( ) ) { $ this -> rescanSubAreaPermissions ( ) ; } } }
This function removes all permissions records for the current Area and sets it to inherit from the Page permissions .
10,471
public function rescanAreaPermissionsChain ( ) { $ db = Database :: connection ( ) ; if ( $ this -> overrideCollectionPermissions ( ) ) { return false ; } $ areac = $ this -> getAreaCollectionObject ( ) ; if ( is_a ( $ areac , 'Page' ) ) { if ( $ areac -> getCollectionInheritance ( ) == 'PARENT' ) { $ cIDToCheck = $ areac -> getCollectionParentID ( ) ; $ arInheritPermissionsFromAreaOnCID = $ db -> fetchColumn ( 'select a.arInheritPermissionsFromAreaOnCID from Pages c inner join Areas a on (c.cID = a.cID) where c.cID = ? and a.arHandle = ?' , array ( $ cIDToCheck , $ this -> getAreaHandle ( ) ) ) ; if ( $ arInheritPermissionsFromAreaOnCID > 0 ) { $ db -> executeQuery ( 'update Areas set arInheritPermissionsFromAreaOnCID = ? where arID = ?' , array ( $ arInheritPermissionsFromAreaOnCID , $ this -> getAreaID ( ) ) ) ; } while ( $ cIDToCheck > 0 ) { $ row = $ db -> fetchAssoc ( 'select c.cParentID, c.cID, a.arHandle, a.arOverrideCollectionPermissions, a.arID from Pages c inner join Areas a on (c.cID = a.cID) where c.cID = ? and a.arHandle = ?' , array ( $ cIDToCheck , $ this -> getAreaHandle ( ) ) ) ; if ( empty ( $ row ) ) { break ; } if ( $ row [ 'arOverrideCollectionPermissions' ] == 1 ) { if ( $ row [ 'cID' ] > 0 ) { $ db -> executeQuery ( 'update Areas set arInheritPermissionsFromAreaOnCID = ? where arID = ?' , array ( $ row [ 'cID' ] , $ this -> getAreaID ( ) ) ) ; $ this -> arInheritPermissionsFromAreaOnCID = $ row [ 'cID' ] ; } break ; } $ cIDToCheck = $ row [ 'cParentID' ] ; } } else { if ( $ areac -> getCollectionInheritance ( ) == 'TEMPLATE' ) { $ doOverride = $ db -> fetchColumn ( 'select arOverrideCollectionPermissions from Pages c inner join Areas a on (c.cID = a.cID) where c.cID = ? and a.arHandle = ?' , array ( $ areac -> getPermissionsCollectionID ( ) , $ this -> getAreaHandle ( ) ) ) ; if ( $ doOverride && $ areac -> getPermissionsCollectionID ( ) > 0 ) { $ db -> executeQuery ( 'update Areas set arInheritPermissionsFromAreaOnCID = ? where arID = ?' , array ( $ areac -> getPermissionsCollectionID ( ) , $ this -> getAreaID ( ) ) ) ; $ this -> arInheritPermissionsFromAreaOnCID = $ areac -> getPermissionsCollectionID ( ) ; } } } } }
Rescans the current Area s permissions ensuring that it s inheriting permissions properly up the chain .
10,472
public function rescanSubAreaPermissionsMasterCollection ( $ masterCollection ) { if ( ! $ masterCollection -> isMasterCollection ( ) ) { return false ; } $ toSetCID = ( $ this -> overrideCollectionPermissions ( ) ) ? $ masterCollection -> getCollectionID ( ) : 0 ; $ db = Database :: connection ( ) ; $ v = array ( $ this -> getAreaHandle ( ) , 'TEMPLATE' , $ masterCollection -> getCollectionID ( ) ) ; $ db -> executeQuery ( 'update Areas, Pages set Areas.arInheritPermissionsFromAreaOnCID = ' . $ toSetCID . ' where Areas.cID = Pages.cID and Areas.arHandle = ? and cInheritPermissionsFrom = ? and arOverrideCollectionPermissions = 0 and cInheritPermissionsFromCID = ?' , $ v ) ; }
similar to rescanSubAreaPermissions but for those who have setup their pages to inherit master collection permissions .
10,473
public function export ( $ p , $ page ) { $ area = $ p -> addChild ( 'area' ) ; $ area -> addAttribute ( 'name' , $ this -> getAreaHandle ( ) ) ; $ blocks = $ page -> getBlocks ( $ this -> getAreaHandle ( ) ) ; $ c = $ this -> getAreaCollectionObject ( ) ; $ style = $ c -> getAreaCustomStyle ( $ this ) ; if ( is_object ( $ style ) ) { $ set = $ style -> getStyleSet ( ) ; $ set -> export ( $ area ) ; } $ wrapper = $ area -> addChild ( 'blocks' ) ; foreach ( $ blocks as $ bl ) { $ bl -> export ( $ wrapper ) ; } }
Exports the area to content format .
10,474
public function isRequired ( ) { $ result = $ this -> required ; if ( is_callable ( $ result ) ) { $ result = $ result ( $ this ) ; } return ( bool ) $ result ; }
Is this option required?
10,475
public function enableLegacyNamespace ( ) { $ this -> enableLegacyNamespace = true ; $ this -> disable ( ) ; $ this -> activateAutoloaders ( ) ; $ this -> enable ( ) ; }
Set legacy namespaces to enabled . This method unsets and resets this loader .
10,476
public function disableLegacyNamespace ( ) { $ this -> enableLegacyNamespace = false ; $ this -> disable ( ) ; $ this -> activateAutoloaders ( ) ; $ this -> enable ( ) ; }
Set legacy namespaces to disabled . This method unsets and resets this loader .
10,477
public function getCss ( ) { $ parser = new \ Less_Parser ( array ( 'cache_dir' => Config :: get ( 'concrete.cache.directory' ) , 'compress' => ( bool ) Config :: get ( 'concrete.theme.compress_preprocessor_output' ) , 'sourceMap' => ! Config :: get ( 'concrete.theme.compress_preprocessor_output' ) && ( bool ) Config :: get ( 'concrete.theme.generate_less_sourcemap' ) , ) ) ; $ parser = $ parser -> parseFile ( $ this -> file , $ this -> sourceUriRoot ) ; if ( isset ( $ this -> valueList ) && $ this -> valueList instanceof \ Concrete \ Core \ StyleCustomizer \ Style \ ValueList ) { $ variables = array ( ) ; foreach ( $ this -> valueList -> getValues ( ) as $ value ) { $ variables = array_merge ( $ value -> toLessVariablesArray ( ) , $ variables ) ; } $ parser -> ModifyVars ( $ variables ) ; } $ css = $ parser -> getCss ( ) ; return $ css ; }
Compiles the stylesheet using LESS . If a ValueList is provided they are injected into the stylesheet .
10,478
public function getGroupedTimezones ( ) { $ groups = [ ] ; $ generics = [ ] ; $ genericGroupName = tc ( 'GenericTimezonesGroupName' , 'Others' ) ; foreach ( $ this -> getTimezones ( ) as $ id => $ fullName ) { $ chunks = explode ( '/' , $ fullName , 2 ) ; if ( ! isset ( $ chunks [ 1 ] ) ) { array_unshift ( $ chunks , $ genericGroupName ) ; } list ( $ groupName , $ territoryName ) = $ chunks ; if ( $ groupName === $ genericGroupName ) { $ generics [ $ id ] = $ territoryName ; } else { if ( ! isset ( $ groups [ $ groupName ] ) ) { $ groups [ $ groupName ] = [ ] ; } $ groups [ $ groupName ] [ $ id ] = $ territoryName ; } } if ( ! empty ( $ generics ) ) { $ groups [ $ genericGroupName ] = $ generics ; } return $ groups ; }
Returns the list of timezones with translated names grouped by region .
10,479
public function getTimezoneDisplayName ( $ timezone ) { $ displayName = '' ; if ( is_object ( $ timezone ) ) { if ( $ timezone instanceof \ DateTimeZone ) { $ displayName = $ timezone -> getName ( ) ; } elseif ( $ timezone instanceof \ DateTime ) { $ displayName = $ timezone -> getTimezone ( ) -> getName ( ) ; } } elseif ( is_string ( $ timezone ) ) { $ displayName = $ timezone ; } if ( strlen ( $ displayName ) > 0 ) { $ timezones = $ this -> getTimezones ( ) ; if ( array_key_exists ( $ displayName , $ timezones ) ) { $ displayName = $ timezones [ $ displayName ] ; } } return $ displayName ; }
Returns the display name of a timezone .
10,480
public function describeInterval ( $ diff , $ precise = false ) { $ secondsPerMinute = 60 ; $ secondsPerHour = 60 * $ secondsPerMinute ; $ secondsPerDay = 24 * $ secondsPerHour ; $ days = floor ( $ diff / $ secondsPerDay ) ; $ diff = $ diff - $ days * $ secondsPerDay ; $ hours = floor ( $ diff / $ secondsPerHour ) ; $ diff = $ diff - $ hours * $ secondsPerHour ; $ minutes = floor ( $ diff / $ secondsPerMinute ) ; $ seconds = $ diff - $ minutes * $ secondsPerMinute ; $ chunks = [ ] ; if ( $ days > 0 ) { $ chunks [ ] = t2 ( '%d day' , '%d days' , $ days , $ days ) ; if ( $ precise ) { $ chunks [ ] = t2 ( '%d hour' , '%d hours' , $ hours , $ hours ) ; } } elseif ( $ hours > 0 ) { $ chunks [ ] = t2 ( '%d hour' , '%d hours' , $ hours , $ hours ) ; if ( $ precise ) { $ chunks [ ] = t2 ( '%d minute' , '%d minutes' , $ minutes , $ minutes ) ; } } elseif ( $ minutes > 0 ) { $ chunks [ ] = t2 ( '%d minute' , '%d minutes' , $ minutes , $ minutes ) ; if ( $ precise ) { $ chunks [ ] = t2 ( '%d second' , '%d seconds' , $ seconds , $ seconds ) ; } } else { $ chunks [ ] = t2 ( '%d second' , '%d seconds' , $ seconds , $ seconds ) ; } return Misc :: join ( $ chunks ) ; }
Returns the localized representation of a time interval specified as seconds .
10,481
public function getTimezoneID ( $ timezone ) { $ app = Facade :: getFacadeApplication ( ) ; $ config = $ app -> make ( 'config' ) ; switch ( $ timezone ) { case 'system' : $ timezone = $ config -> get ( 'app.server_timezone' , @ date_default_timezone_get ( ) ? : 'UTC' ) ; break ; case 'app' : $ site = $ app -> make ( 'site' ) -> getSite ( ) ; $ timezone = $ site -> getConfigRepository ( ) -> get ( 'timezone' , @ date_default_timezone_get ( ) ? : 'UTC' ) ; break ; case 'user' : $ tz = null ; if ( $ config -> get ( 'concrete.misc.user_timezones' ) ) { $ u = null ; $ request = null ; if ( ! $ app -> isRunThroughCommandLineInterface ( ) ) { $ request = Request :: getInstance ( ) ; } if ( $ request && $ request -> hasCustomRequestUser ( ) ) { $ u = $ request -> getCustomRequestUser ( ) ; } else { $ u = new User ( ) ; } if ( is_object ( $ u ) && $ u -> isRegistered ( ) ) { $ tz = $ u -> getUserTimezone ( ) ; } } if ( $ tz ) { $ timezone = $ tz ; } else { $ timezone = $ this -> getTimezoneID ( 'app' ) ; } break ; } return $ timezone ; }
Returns the normalized timezone identifier .
10,482
public function getTimezone ( $ timezone ) { $ tz = null ; $ phpTimezone = $ this -> getTimezoneID ( $ timezone ) ; if ( is_string ( $ phpTimezone ) && strlen ( $ phpTimezone ) ) { try { $ tz = new \ DateTimeZone ( $ phpTimezone ) ; } catch ( \ Exception $ x ) { } } return $ tz ; }
Returns a \ DateTimeZone instance for a specified timezone identifier .
10,483
public function toDateTime ( $ value = 'now' , $ toTimezone = 'system' , $ fromTimezone = 'system' ) { return Calendar :: toDateTime ( $ value , $ this -> getTimezone ( $ toTimezone ) , $ this -> getTimezone ( $ fromTimezone ) ) ; }
Convert a date to a \ DateTime instance .
10,484
public function getDeltaDays ( $ from , $ to , $ timezone = 'user' ) { $ dtFrom = $ this -> toDateTime ( $ from , $ timezone ) ; $ dtTo = $ this -> toDateTime ( $ to , $ timezone ) ; if ( is_null ( $ dtFrom ) || is_null ( $ dtTo ) ) { return null ; } $ dtFrom = $ this -> toDateTime ( $ dtFrom -> format ( 'Y-m-d' ) , $ timezone ) ; $ dtTo = $ this -> toDateTime ( $ dtTo -> format ( 'Y-m-d' ) , $ timezone ) ; return ( int ) $ dtFrom -> diff ( $ dtTo ) -> format ( '%r%a' ) ; }
Returns the difference in days between to dates .
10,485
public function getPHPTimePattern ( ) { $ isoFormat = Calendar :: getTimeFormat ( 'short' ) ; $ result = Calendar :: tryConvertIsoToPhpFormat ( $ isoFormat ) ; if ( $ result === null ) { $ result = t ( 'g.i A' ) ; } return $ result ; }
Get the PHP date format string for times .
10,486
public function apply ( $ characterSet , $ collation , $ connectionName = '' , $ environment = '' , callable $ messageCallback = null , ErrorList $ warnings = null ) { if ( $ messageCallback === null ) { $ messageCallback = function ( $ message ) { } ; } if ( ( string ) $ connectionName === '' ) { $ connectionName = $ this -> databaseManager -> getDefaultConnection ( ) ; } $ connection = $ this -> databaseManager -> connection ( $ connectionName ) ; list ( $ characterSet , $ collation ) = $ this -> resolver -> setCharacterSet ( ( string ) $ characterSet ) -> setCollation ( ( string ) $ collation ) -> resolveCharacterSetAndCollation ( $ connection ) ; $ messageCallback ( t ( 'Setting character set "%1$s" and collation "%2$s" for connection "%3$s"' , $ characterSet , $ collation , $ connectionName ) ) ; $ this -> convertTables ( $ connection , $ characterSet , $ collation , $ messageCallback , $ warnings ) ; $ messageCallback ( t ( 'Saving connection configuration.' ) ) ; $ this -> persistConfiguration ( $ connectionName , $ environment , $ characterSet , $ collation , $ warnings ) ; $ connection -> refreshCharactersetCollation ( $ characterSet , $ collation ) ; }
Apply the character set and collation to a connection .
10,487
public function generateDefaultOccurrences ( CalendarEventVersion $ version ) { $ repetitions = $ version -> getRepetitionEntityCollection ( ) ; $ query = $ this -> entityManager -> createQuery ( 'delete from calendar:CalendarEventVersionOccurrence o where o.version = :version' ) ; $ query -> setParameter ( 'version' , $ version ) ; $ query -> execute ( ) ; foreach ( $ repetitions as $ repetitionEntity ) { $ repetition = $ repetitionEntity -> getRepetitionObject ( ) ; $ start = $ repetition -> getStartDateTimestamp ( ) - 1 ; $ datetime = new \ DateTime ( '+5 years' , $ repetition -> getTimezone ( ) ) ; $ end = $ datetime -> getTimestamp ( ) ; $ this -> occurrenceFactory -> generateOccurrences ( $ version , $ repetitionEntity , $ start , $ end ) ; } }
Handles generating occurrences with the default start and end times
10,488
public function requireOccurrenceRegeneration ( $ repetitions1 , $ repetitions2 ) { if ( count ( $ repetitions1 ) != count ( $ repetitions2 ) ) { return true ; } $ comparator = new Comparator ( ) ; for ( $ i = 0 ; $ i < count ( $ repetitions1 ) ; $ i ++ ) { if ( ! $ comparator -> areEqual ( $ repetitions1 [ $ i ] -> getRepetitionObject ( ) , $ repetitions2 [ $ i ] -> getRepetitionObject ( ) ) ) { return true ; } } return false ; }
Returns true if the difference between the event versions impacts repetitions and occurrences .
10,489
protected function loadConfig ( $ level ) { $ app = Application :: getFacadeApplication ( ) ; $ drivers = [ ] ; $ driverConfigs = $ app [ 'config' ] -> get ( "concrete.cache.levels.{$level}.drivers" , [ ] ) ; $ preferredDriverName = $ app [ 'config' ] -> get ( "concrete.cache.levels.{$level}.preferred_driver" , null ) ; if ( ! empty ( $ preferredDriverName ) ) { if ( is_array ( $ preferredDriverName ) ) { foreach ( $ preferredDriverName as $ driverName ) { $ preferredDriver = array_get ( $ driverConfigs , $ driverName , [ ] ) ; $ drivers [ ] = $ this -> buildDriver ( $ preferredDriver ) ; } } else { $ preferredDriver = array_get ( $ driverConfigs , $ preferredDriverName , [ ] ) ; $ drivers [ ] = $ this -> buildDriver ( $ preferredDriver ) ; } } if ( empty ( $ drivers ) ) { foreach ( $ driverConfigs as $ driverConfig ) { if ( ! $ driverConfig ) { continue ; } $ drivers [ ] = $ this -> buildDriver ( $ driverConfig ) ; } } array_filter ( $ drivers ) ; $ count = count ( $ drivers ) ; if ( $ count > 1 ) { $ driver = new Composite ( [ 'drivers' => $ drivers ] ) ; } elseif ( $ count === 1 ) { reset ( $ drivers ) ; $ driver = current ( $ drivers ) ; } else { $ driver = new BlackHole ( ) ; } return $ driver ; }
Loads the composite driver from constants .
10,490
private function buildDriver ( array $ driverConfig ) { $ class = array_get ( $ driverConfig , 'class' , '' ) ; if ( $ class && class_exists ( $ class ) ) { $ implements = class_implements ( $ class ) ; if ( isset ( $ implements [ 'Stash\Interfaces\DriverInterface' ] ) ) { if ( $ class :: isAvailable ( ) ) { $ tempDriver = new $ class ( array_get ( $ driverConfig , 'options' , null ) ) ; return $ tempDriver ; } } else { throw new \ RuntimeException ( 'Cache driver class must implement \Stash\Interfaces\DriverInterface.' ) ; } } return null ; }
Function used to build a driver from a driverConfig array .
10,491
public function exists ( $ key ) { if ( $ this -> enabled ) { return ! $ this -> pool -> getItem ( $ key ) -> isMiss ( ) ; } else { return false ; } }
Checks if an item exists in the cache .
10,492
public function enable ( ) { if ( $ this -> driver !== null ) { $ this -> pool -> setDriver ( $ this -> driver ) ; } $ this -> enabled = true ; }
Enables the cache .
10,493
public function disable ( ) { if ( ! ( $ this -> pool -> getDriver ( ) instanceof BlackHole ) ) { $ this -> driver = $ this -> pool -> getDriver ( ) ; } $ this -> pool -> setDriver ( new BlackHole ( ) ) ; $ this -> enabled = false ; }
Disables the cache .
10,494
public static function disableAll ( ) { $ app = Application :: getFacadeApplication ( ) ; $ app -> make ( 'cache/request' ) -> disable ( ) ; $ app -> make ( 'cache/expensive' ) -> disable ( ) ; $ app -> make ( 'cache' ) -> disable ( ) ; }
Disables all cache levels .
10,495
public static function enableAll ( ) { $ app = Application :: getFacadeApplication ( ) ; $ app -> make ( 'cache/request' ) -> enable ( ) ; $ app -> make ( 'cache/expensive' ) -> enable ( ) ; $ app -> make ( 'cache' ) -> enable ( ) ; }
Enables all cache levels .
10,496
protected function getExtraParams ( AccessTokenEntityInterface $ accessToken ) { $ params = parent :: getExtraParams ( $ accessToken ) ; if ( $ this -> isOidcRequest ( $ accessToken -> getScopes ( ) ) ) { $ user = $ this -> userInfoRepository -> getByID ( $ accessToken -> getUserIdentifier ( ) ) ; if ( $ user ) { $ params [ 'id_token' ] = ( string ) $ this -> createIdToken ( $ accessToken , $ this -> claimFactory -> createFromUserInfo ( $ user ) ) ; } } return $ params ; }
Get the extra params to include If this is an OIDC request we include the ID token
10,497
protected function createIdToken ( AccessTokenEntityInterface $ accessToken , ClaimsSet $ claims ) { $ issuer = $ this -> site -> getSite ( ) ; $ builder = ( new Builder ( ) ) -> setAudience ( $ accessToken -> getClient ( ) -> getIdentifier ( ) ) -> setIssuer ( $ issuer -> getSiteCanonicalURL ( ) ) -> setIssuedAt ( time ( ) ) -> setNotBefore ( time ( ) ) -> setExpiration ( $ accessToken -> getExpiryDateTime ( ) -> getTimestamp ( ) ) -> setSubject ( $ accessToken -> getUserIdentifier ( ) ) ; foreach ( $ claims -> jsonSerialize ( ) as $ key => $ claim ) { $ builder -> set ( $ key , $ claim ) ; } return $ builder -> sign ( new Sha256 ( ) , new Key ( $ this -> privateKey -> getKeyPath ( ) , $ this -> privateKey -> getPassPhrase ( ) ) ) -> getToken ( ) ; }
Create an ID token to include with our response
10,498
private function clientSupportsJson ( $ minWeight = null ) { try { $ app = Application :: getFacadeApplication ( ) ; $ rmrp = $ app -> make ( RequestMediaTypeParser :: class ) ; return $ rmrp -> isMediaTypeSupported ( 'application/json' , $ minWeight ) ; } catch ( Exception $ x ) { return null ; } catch ( Throwable $ x ) { return null ; } }
Check if the client supports JSON .
10,499
public static function getErrorMessage ( $ code ) { $ app = Application :: getFacadeApplication ( ) ; $ defaultStorage = $ app -> make ( StorageLocationFactory :: class ) -> fetchDefault ( ) -> getName ( ) ; $ msg = '' ; switch ( $ code ) { case self :: E_PHP_NO_FILE : case self :: E_FILE_INVALID : $ msg = t ( 'Invalid file.' ) ; break ; case self :: E_FILE_INVALID_EXTENSION : $ msg = t ( 'Invalid file extension.' ) ; break ; case self :: E_PHP_FILE_PARTIAL_UPLOAD : $ msg = t ( 'The file was only partially uploaded.' ) ; break ; case self :: E_FILE_INVALID_STORAGE_LOCATION : $ msg = t ( 'No default file storage location could be found to store this file.' ) ; break ; case self :: E_FILE_EXCEEDS_POST_MAX_FILE_SIZE : $ msg = t ( 'Uploaded file is too large. The current value of post_max_filesize is %s' , ini_get ( 'post_max_size' ) ) ; break ; case self :: E_PHP_FILE_EXCEEDS_HTML_MAX_FILE_SIZE : case self :: E_PHP_FILE_EXCEEDS_UPLOAD_MAX_FILESIZE : $ msg = t ( 'Uploaded file is too large. The current value of upload_max_filesize is %s' , ini_get ( 'upload_max_filesize' ) ) ; break ; case self :: E_FILE_UNABLE_TO_STORE : $ msg = t ( 'Unable to copy file to storage location "%s". Please check the settings for the storage location.' , $ defaultStorage ) ; break ; case self :: E_FILE_UNABLE_TO_STORE_PREFIX_PROVIDED : $ msg = t ( 'Unable to copy file to storage location "%s". This file already exists in your site, or there is insufficient disk space for this operation.' , $ defaultStorage ) ; break ; case self :: E_PHP_NO_TMP_DIR : $ msg = t ( 'Missing a temporary folder.' ) ; break ; case self :: E_PHP_CANT_WRITE : $ msg = t ( 'Failed to write file to disk.' ) ; break ; case self :: E_PHP_CANT_WRITE : $ msg = t ( 'A PHP extension stopped the file upload.' ) ; break ; case self :: E_PHP_FILE_ERROR_DEFAULT : default : $ msg = t ( "An unknown error occurred while uploading the file. Please check that file uploads are enabled, and that your file does not exceed the size of the post_max_size or upload_max_filesize variables.\n\nFile Uploads: %s\nMax Upload File Size: %s\nPost Max Size: %s" , ini_get ( 'file_uploads' ) , ini_get ( 'upload_max_filesize' ) , ini_get ( 'post_max_size' ) ) ; break ; } return $ msg ; }
Returns a text string explaining the error that was passed .