idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
10,800 | public function addCookieObject ( Cookie $ cookie ) { $ name = $ cookie -> getName ( ) ; $ isNew = true ; foreach ( $ this -> cookies as $ index => $ value ) { if ( $ value -> getName ( ) === $ name ) { $ this -> cookies [ $ index ] = $ cookie ; $ isNew = false ; } } if ( $ isNew ) { $ index = array_search ( $ name , $ this -> clearedCookies , true ) ; if ( $ index !== false ) { unset ( $ this -> clearedCookies [ $ index ] ) ; $ this -> clearedCookies = array_values ( $ this -> clearedCookies ) ; } $ this -> cookies [ ] = $ cookie ; } return $ this ; } | Adds a Cookie object to the array of cookies for the object . |
10,801 | public function getCookieByName ( $ name ) { foreach ( $ this -> cookies as $ cookie ) { if ( $ cookie -> getName ( ) === $ name ) { return $ cookie ; } } return null ; } | Get the response cookie given its name . |
10,802 | public function clear ( $ name ) { if ( ! in_array ( $ name , $ this -> clearedCookies , true ) ) { $ this -> clearedCookies [ ] = $ name ; foreach ( $ this -> cookies as $ index => $ value ) { if ( $ value -> getName ( ) === $ name ) { unset ( $ this -> cookies [ $ index ] ) ; } } $ this -> cookies = array_values ( $ this -> cookies ) ; } } | Clear a cookie . |
10,803 | public function getByID ( $ id ) { $ id = ( int ) $ id ; return $ id > 0 ? $ this -> em -> find ( Geolocator :: class , $ id ) : null ; } | Get a geolocator library given its ID . |
10,804 | public function getByHandle ( $ handle ) { $ handle = ( string ) $ handle ; return $ handle === '' ? null : $ this -> repo -> findOneBy ( [ 'glHandle' => $ handle ] ) ; } | Get a geolocator library given its handle . |
10,805 | public function setCurrent ( Geolocator $ geolocator = null ) { $ currentGeolocator = $ this -> getCurrent ( ) ; if ( $ currentGeolocator !== $ geolocator ) { if ( $ currentGeolocator !== null ) { $ currentGeolocator -> setIsActive ( false ) ; if ( $ currentGeolocator -> getGeolocatorID ( ) !== null ) { $ this -> em -> flush ( $ currentGeolocator ) ; } } if ( $ geolocator !== null ) { $ geolocator -> setIsActive ( true ) ; if ( $ geolocator -> getGeolocatorID ( ) !== null ) { $ this -> em -> flush ( $ geolocator ) ; } } } } | Set the currently active geolocator library . |
10,806 | public function getList ( ) { $ result = $ this -> repo -> findAll ( ) ; $ comparer = new Comparer ( ) ; usort ( $ result , function ( Geolocator $ a , Geolocator $ b ) use ( $ comparer ) { return $ comparer -> compare ( $ a -> getGeolocatorDisplayName ( 'text' ) , $ b -> getGeolocatorDisplayName ( 'text' ) ) ; } ) ; return $ result ; } | Get all the installed geolocator libraries . |
10,807 | protected function addDetails ( ) { $ this -> addDataTable ( 'Concrete5' , [ 'Version' => Config :: get ( 'concrete.version' ) , 'Installed Version' => Config :: get ( 'concrete.version_installed' ) , ] ) ; $ this -> addDataTable ( 'Concrete Configuration' , $ this -> flatConfig ( Config :: get ( 'concrete' ) , 'concrete' ) ) ; } | Add the c5 specific debug stuff . |
10,808 | private function get ( $ url ) { try { $ result = $ this -> fileHelper -> getContents ( $ url , $ this -> config -> get ( 'concrete.marektplace.request_timeout' ) ) ; } catch ( TimeoutException $ e ) { $ this -> connectionError = self :: E_CONNECTION_TIMEOUT ; return null ; } catch ( Exception $ e ) { $ this -> connectionError = self :: E_GENERAL_CONNECTION_ERROR ; return null ; } return $ result ? : null ; } | Get the contents of a URL |
10,809 | public static function checkPackageUpdates ( ) { $ em = \ ORM :: entityManager ( ) ; $ items = self :: getAvailableMarketplaceItems ( false ) ; foreach ( $ items as $ i ) { $ p = Package :: getByHandle ( $ i -> getHandle ( ) ) ; if ( is_object ( $ p ) ) { $ p -> setPackageAvailableVersion ( $ i -> getVersion ( ) ) ; $ em -> persist ( $ p ) ; } } $ em -> flush ( ) ; } | Runs through all packages on the marketplace sees if they re installed here and updates the available version number for them . |
10,810 | public function createFromPath ( $ path , $ open_mode = 'r+' ) { $ class = $ this -> writerClass ; return $ this -> prepare ( $ class :: createFromPath ( $ path , $ open_mode ) ) ; } | Create a CSV writer from a string . |
10,811 | public static function getByID ( $ fID ) { return $ fID ? Application :: getFacadeApplication ( ) -> make ( EntityManagerInterface :: class ) -> find ( FileEntity :: class , $ fID ) : null ; } | Return a file object for the given file ID . |
10,812 | public static function add ( File $ file , $ filename , $ prefix , $ data = [ ] ) { $ data += [ 'uID' => 0 , 'fvTitle' => '' , 'fvDescription' => '' , 'fvTags' => '' , 'fvIsApproved' => true , ] ; $ app = Application :: getFacadeApplication ( ) ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ dh = $ app -> make ( 'date' ) ; $ date = new DateTime ( $ dh -> getOverridableNow ( ) ) ; $ uID = ( int ) $ data [ 'uID' ] ; if ( $ uID < 1 ) { if ( User :: isLoggedIn ( ) ) { $ uID = ( int ) ( new User ( ) ) -> getUserID ( ) ; } else { $ uID = 0 ; } } $ fv = new static ( ) ; $ fv -> file = $ file ; $ fv -> fvID = 1 ; $ fv -> fvFilename = ( string ) $ filename ; $ fv -> fvPrefix = $ prefix ; $ fv -> fvDateAdded = $ date ; $ fv -> fvActivateDateTime = $ date ; $ fv -> fvIsApproved = ( bool ) $ data [ 'fvIsApproved' ] ; $ fv -> fvAuthorUID = $ uID ; $ fv -> fvApproverUID = $ uID ; $ fv -> fvTitle = ( string ) $ data [ 'fvTitle' ] ; $ fv -> fvDescription = ( string ) $ data [ 'fvDescription' ] ; $ fv -> fvTags = self :: cleanTags ( ( string ) $ data [ 'fvTags' ] ) ; $ em -> persist ( $ fv ) ; $ em -> flush ( ) ; $ fve = new FileVersionEvent ( $ fv ) ; $ app -> make ( EventDispatcherInterface :: class ) -> dispatch ( 'on_file_version_add' , $ fve ) ; return $ fv ; } | Add a new file version . You should call refreshAttributes in order to update the size extension type and other attributes . |
10,813 | public static function cleanTags ( $ tagsStr ) { $ tagsArray = explode ( "\n" , str_replace ( [ "\r" , ',' ] , "\n" , $ tagsStr ) ) ; $ cleanTags = [ ] ; foreach ( $ tagsArray as $ tag ) { $ tag = trim ( $ tag ) ; if ( $ tag !== '' ) { $ cleanTags [ ] = $ tag ; } } return isset ( $ cleanTags [ 0 ] ) ? "\n" . implode ( "\n" , $ cleanTags ) . "\n" : '' ; } | Normalize the tags separator remove empty tags . |
10,814 | public function updateFile ( $ filename , $ prefix ) { $ this -> fvFilename = $ filename ; $ this -> fvPrefix = $ prefix ; $ this -> save ( ) ; $ this -> logVersionUpdate ( self :: UT_REPLACE_FILE ) ; } | Update the filename and the path prefix of the file . |
10,815 | public function deny ( ) { $ app = Application :: getFacadeApplication ( ) ; $ this -> fvIsApproved = false ; $ this -> save ( ) ; $ fve = new FileVersionEvent ( $ this ) ; $ app -> make ( EventDispatcherInterface :: class ) -> dispatch ( 'on_file_version_deny' , $ fve ) ; $ app -> make ( 'cache/request' ) -> delete ( 'file/version/approved/' . $ this -> getFileID ( ) ) ; } | Mark this file version as not approved . |
10,816 | public function updateTitle ( $ title ) { $ app = Application :: getFacadeApplication ( ) ; $ this -> fvTitle = $ title ; $ this -> save ( ) ; $ this -> logVersionUpdate ( self :: UT_TITLE ) ; $ fve = new FileVersionEvent ( $ this ) ; $ app -> make ( EventDispatcherInterface :: class ) -> dispatch ( 'on_file_version_update_title' , $ fve ) ; } | Update the title of the file . |
10,817 | public function updateDescription ( $ descr ) { $ app = Application :: getFacadeApplication ( ) ; $ this -> fvDescription = $ descr ; $ this -> save ( ) ; $ this -> logVersionUpdate ( self :: UT_DESCRIPTION ) ; $ fve = new FileVersionEvent ( $ this ) ; $ app -> make ( EventDispatcherInterface :: class ) -> dispatch ( 'on_file_version_update_description' , $ fve ) ; } | Update the description of the file . |
10,818 | public function updateTags ( $ tags ) { $ app = Application :: getFacadeApplication ( ) ; $ tags = self :: cleanTags ( $ tags ) ; $ this -> fvTags = $ tags ; $ this -> save ( ) ; $ this -> logVersionUpdate ( self :: UT_TAGS ) ; $ fve = new FileVersionEvent ( $ this ) ; $ app -> make ( EventDispatcherInterface :: class ) -> dispatch ( 'on_file_version_update_tags' , $ fve ) ; } | Update the tags associated to the file . |
10,819 | public function getMimeType ( ) { try { $ fre = $ this -> getFileResource ( ) ; $ result = $ fre -> getMimetype ( ) ; } catch ( FileNotFoundException $ x ) { $ result = false ; } return $ result ; } | Get the mime type of the file if known . |
10,820 | public function getTypeObject ( ) { $ app = Application :: getFacadeApplication ( ) ; $ fh = $ app -> make ( 'helper/file' ) ; $ ext = $ fh -> getExtension ( $ this -> fvFilename ) ; $ ftl = FileTypeList :: getType ( $ ext ) ; return $ ftl ; } | Get the type of the file . |
10,821 | public function logVersionUpdate ( $ updateTypeID , $ updateTypeAttributeID = 0 ) { $ app = Application :: getFacadeApplication ( ) ; $ db = $ app -> make ( Connection :: class ) ; $ db -> executeQuery ( 'INSERT INTO FileVersionLog (fID, fvID, fvUpdateTypeID, fvUpdateTypeAttributeID) VALUES (?, ?, ?, ?)' , [ $ this -> getFileID ( ) , $ this -> getFileVersionID ( ) , $ updateTypeID , $ updateTypeAttributeID , ] ) ; } | Log updates to files . |
10,822 | public function getVersionLogComments ( ) { $ app = Application :: getFacadeApplication ( ) ; $ db = $ app -> make ( Connection :: class ) ; $ updates = [ ] ; $ ga = $ db -> fetchAll ( 'SELECT fvUpdateTypeID, fvUpdateTypeAttributeID FROM FileVersionLog WHERE fID = ? AND fvID = ? ORDER BY fvlID ASC' , [ $ this -> getFileID ( ) , $ this -> getFileVersionID ( ) ] ) ; foreach ( $ ga as $ a ) { switch ( $ a [ 'fvUpdateTypeID' ] ) { case self :: UT_REPLACE_FILE : $ updates [ ] = t ( 'File' ) ; break ; case self :: UT_TITLE : $ updates [ ] = t ( 'Title' ) ; break ; case self :: UT_DESCRIPTION : $ updates [ ] = t ( 'Description' ) ; break ; case self :: UT_TAGS : $ updates [ ] = t ( 'Tags' ) ; break ; case self :: UT_CONTENTS : $ updates [ ] = t ( 'File Content' ) ; break ; case self :: UT_RENAME : $ updates [ ] = t ( 'File Name' ) ; break ; case self :: UT_EXTENDED_ATTRIBUTE : $ val = $ db -> fetchColumn ( 'SELECT akName FROM AttributeKeys WHERE akID = ?' , [ $ a [ 'fvUpdateTypeAttributeID' ] ] ) ; if ( $ val !== false ) { $ updates [ ] = $ val ; } break ; } } return array_values ( array_unique ( $ updates ) ) ; } | Get an array containing human - readable descriptions of everything that happened to this file version . |
10,823 | public function getDownloadURL ( ) { $ app = Application :: getFacadeApplication ( ) ; $ urlResolver = $ app -> make ( ResolverManagerInterface :: class ) ; $ c = Page :: getCurrentPage ( ) ; $ cID = $ c instanceof Page && ! $ c -> isError ( ) ? $ c -> getCollectionID ( ) : 0 ; return $ urlResolver -> resolve ( [ '/download_file' , $ this -> getFileID ( ) , $ cID ] ) ; } | Get an URL that can be used to download the file . This passes through the download_file single page . |
10,824 | public function buildForceDownloadResponse ( ) { $ fre = $ this -> getFileResource ( ) ; $ fs = $ this -> getFile ( ) -> getFileStorageLocationObject ( ) -> getFileSystemObject ( ) ; $ response = new FlysystemFileResponse ( $ fre -> getPath ( ) , $ fs ) ; $ response -> setContentDisposition ( ResponseHeaderBag :: DISPOSITION_ATTACHMENT ) ; return $ response ; } | Get a Response instance that will force the browser to download the file even if the browser can display it . |
10,825 | public function duplicateUnderlyingFile ( ) { $ app = Application :: getFacadeApplication ( ) ; $ importer = new Importer ( ) ; $ cf = $ app -> make ( 'helper/concrete/file' ) ; $ filesystem = $ this -> getFile ( ) -> getFileStorageLocationObject ( ) -> getFileSystemObject ( ) ; $ fileName = $ this -> getFileName ( ) ; do { $ prefix = $ importer -> generatePrefix ( ) ; $ path = $ cf -> prefix ( $ prefix , $ fileName ) ; } while ( $ filesystem -> has ( $ path ) ) ; $ fileContents = $ this -> getFileResource ( ) -> read ( ) ; $ mimeType = Util :: guessMimeType ( $ fileName , $ fileContents ) ; $ filesystem -> write ( $ path , $ fileContents , [ 'visibility' => AdapterInterface :: VISIBILITY_PUBLIC , 'mimetype' => $ mimeType , ] ) ; $ this -> updateFile ( $ fileName , $ prefix ) ; } | Duplicate the underlying file and assign its new position to this instance . |
10,826 | public function delete ( $ deleteFilesAndThumbnails = false ) { $ app = Application :: getFacadeApplication ( ) ; $ db = $ app -> make ( Connection :: class ) ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ category = $ this -> getObjectAttributeCategory ( ) ; foreach ( $ this -> getAttributes ( ) as $ attribute ) { $ category -> deleteValue ( $ attribute ) ; } $ db -> executeQuery ( 'DELETE FROM FileVersionLog WHERE fID = ? AND fvID = ?' , [ $ this -> getFileID ( ) , $ this -> fvID ] ) ; if ( $ deleteFilesAndThumbnails ) { if ( $ this -> getTypeObject ( ) -> getGenericType ( ) === FileType :: T_IMAGE ) { $ types = ThumbnailType :: getVersionList ( ) ; foreach ( $ types as $ type ) { $ this -> deleteThumbnail ( $ type ) ; } } try { $ fsl = $ this -> getFile ( ) -> getFileStorageLocationObject ( ) -> getFileSystemObject ( ) ; $ fre = $ this -> getFileResource ( ) ; if ( $ fsl -> has ( $ fre -> getPath ( ) ) ) { $ fsl -> delete ( $ fre -> getPath ( ) ) ; } } catch ( FileNotFoundException $ e ) { } } $ em -> remove ( $ this ) ; $ em -> flush ( ) ; } | Delete this version of the file . |
10,827 | public function updateContents ( $ contents , $ rescanThumbnails = true ) { $ this -> releaseImagineImage ( ) ; $ storage = $ this -> getFile ( ) -> getFileStorageLocationObject ( ) ; if ( $ storage !== null ) { $ app = Application :: getFacadeApplication ( ) ; $ cf = $ app -> make ( 'helper/concrete/file' ) ; $ path = $ cf -> prefix ( $ this -> fvPrefix , $ this -> fvFilename ) ; $ filesystem = $ storage -> getFileSystemObject ( ) ; try { if ( $ filesystem -> has ( $ path ) ) { $ filesystem -> delete ( $ path ) ; } } catch ( FileNotFoundException $ x ) { } $ filesystem -> write ( $ path , $ contents ) ; $ this -> logVersionUpdate ( self :: UT_CONTENTS ) ; $ fve = new FileVersionEvent ( $ this ) ; $ app -> make ( EventDispatcherInterface :: class ) -> dispatch ( 'on_file_version_update_contents' , $ fve ) ; $ this -> refreshAttributes ( $ rescanThumbnails ) ; } } | Update the contents of the file . |
10,828 | public function getFileContents ( ) { $ result = null ; $ fsl = $ this -> getFile ( ) -> getFileStorageLocationObject ( ) ; if ( $ fsl !== null ) { $ app = Application :: getFacadeApplication ( ) ; $ cf = $ app -> make ( 'helper/concrete/file' ) ; try { $ result = $ fsl -> getFileSystemObject ( ) -> read ( $ cf -> prefix ( $ this -> fvPrefix , $ this -> fvFilename ) ) ; if ( $ result === false ) { $ result = null ; } } catch ( FileNotFoundException $ x ) { } } return $ result ; } | Get the contents of the file . |
10,829 | public function refreshAttributes ( $ rescanThumbnails = true ) { $ app = Application :: getFacadeApplication ( ) ; $ storage = $ this -> getFile ( ) -> getFileStorageLocationObject ( ) ; if ( $ storage !== null ) { $ fs = $ storage -> getFileSystemObject ( ) ; $ adapter = $ fs -> getAdapter ( ) ; if ( $ adapter instanceof CachedAdapter ) { $ cache = $ adapter -> getCache ( ) ; $ cf = $ app -> make ( 'helper/concrete/file' ) ; $ path = Util :: normalizePath ( $ cf -> prefix ( $ this -> fvPrefix , $ this -> fvFilename ) ) ; $ cache -> delete ( $ path ) ; } } $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ fh = $ app -> make ( 'helper/file' ) ; $ ext = $ fh -> getExtension ( $ this -> fvFilename ) ; $ ftl = FileTypeList :: getType ( $ ext ) ; $ cl = $ ftl -> getCustomInspector ( ) ; if ( $ cl !== null ) { $ this -> fvGenericType = $ ftl -> getGenericType ( ) ; $ cl -> inspect ( $ this ) ; } $ em -> refresh ( $ this ) ; try { $ fsr = $ this -> getFileResource ( ) ; if ( ! $ fsr -> isFile ( ) ) { return Importer :: E_FILE_INVALID ; } } catch ( FileNotFoundException $ e ) { return Importer :: E_FILE_INVALID ; } $ this -> fvExtension = $ ext ; $ this -> fvType = $ ftl -> getGenericType ( ) ; if ( $ this -> fvTitle === null ) { $ this -> fvTitle = $ this -> getFileName ( ) ; } $ this -> fvSize = $ fsr -> getSize ( ) ; if ( $ rescanThumbnails ) { $ this -> rescanThumbnails ( ) ; } $ this -> save ( ) ; $ f = $ this -> getFile ( ) ; $ f -> reindex ( ) ; } | Rescan all the attributes of this file version . This will run any type - based import routines and store those attributes generate thumbnails etc ... |
10,830 | public function getImagineImage ( ) { if ( null === $ this -> imagineImage ) { $ app = Application :: getFacadeApplication ( ) ; $ resource = $ this -> getFileResource ( ) ; $ mimetype = $ resource -> getMimeType ( ) ; $ imageLibrary = $ app -> make ( ImagineInterface :: class ) ; switch ( $ mimetype ) { case 'image/svg+xml' : case 'image/svg-xml' : case 'text/plain' : if ( $ imageLibrary instanceof \ Imagine \ Gd \ Imagine ) { try { $ imageLibrary = $ app -> make ( 'image/imagick' ) ; } catch ( Exception $ x ) { $ this -> imagineImage = false ; } catch ( Throwable $ x ) { $ this -> imagineImage = false ; } } break ; } if ( null === $ this -> imagineImage ) { $ metadataReader = $ imageLibrary -> getMetadataReader ( ) ; if ( ! $ metadataReader instanceof ExifMetadataReader ) { if ( $ app -> make ( 'config' ) -> get ( 'concrete.file_manager.images.use_exif_data_to_rotate_images' ) ) { try { $ imageLibrary -> setMetadataReader ( new ExifMetadataReader ( ) ) ; } catch ( NotSupportedException $ e ) { } } } try { $ this -> imagineImage = $ imageLibrary -> load ( $ resource -> read ( ) ) ; } catch ( FileNotFoundException $ e ) { $ this -> imagineImage = false ; } } } return $ this -> imagineImage ? : null ; } | Get an \ Imagine \ Image \ ImageInterface representing the image . |
10,831 | public function releaseImagineImage ( ) { $ doGarbageCollection = $ this -> imagineImage ? true : false ; $ this -> imagineImage = null ; if ( $ doGarbageCollection ) { gc_collect_cycles ( ) ; } } | Unload the loaded Image instance . |
10,832 | public function importThumbnail ( ThumbnailTypeVersion $ version , $ path ) { $ app = Application :: getFacadeApplication ( ) ; $ config = $ app -> make ( 'config' ) ; $ thumbnailPath = $ version -> getFilePath ( $ this ) ; $ filesystem = $ this -> getFile ( ) -> getFileStorageLocationObject ( ) -> getFileSystemObject ( ) ; try { if ( $ filesystem -> has ( $ thumbnailPath ) ) { $ filesystem -> delete ( $ thumbnailPath ) ; } } catch ( FileNotFoundException $ e ) { } $ fileContents = file_get_contents ( $ path ) ; $ mimeType = Util :: guessMimeType ( $ path , $ fileContents ) ; $ filesystem -> write ( $ thumbnailPath , $ fileContents , [ 'visibility' => AdapterInterface :: VISIBILITY_PUBLIC , 'mimetype' => $ mimeType , ] ) ; if ( $ version -> getHandle ( ) == $ config -> get ( 'concrete.icons.file_manager_listing.handle' ) ) { $ this -> fvHasListingThumbnail = true ; } if ( $ version -> getHandle ( ) == $ config -> get ( 'concrete.icons.file_manager_detail.handle' ) ) { $ this -> fvHasDetailThumbnail = true ; } $ this -> save ( ) ; } | Import an existing file as a thumbnail type version . |
10,833 | public function getThumbnails ( ) { $ thumbnails = [ ] ; $ imageWidth = ( int ) $ this -> getAttribute ( 'width' ) ; $ imageHeight = ( int ) $ this -> getAttribute ( 'height' ) ; if ( $ imageWidth < 1 || $ imageHeight < 1 ) { throw new InvalidDimensionException ( $ this -> getFile ( ) , $ this , t ( 'Invalid dimensions.' ) ) ; } $ types = ThumbnailType :: getVersionList ( ) ; $ file = $ this -> getFile ( ) ; foreach ( $ types as $ type ) { if ( $ type -> shouldExistFor ( $ imageWidth , $ imageHeight , $ file ) ) { $ thumbnailPath = $ type -> getFilePath ( $ this ) ; $ location = $ file -> getFileStorageLocationObject ( ) ; $ configuration = $ location -> getConfigurationObject ( ) ; $ filesystem = $ location -> getFileSystemObject ( ) ; if ( $ filesystem -> has ( $ thumbnailPath ) ) { $ thumbnails [ ] = new Thumbnail ( $ type , $ configuration -> getPublicURLToFile ( $ thumbnailPath ) ) ; } } } return $ thumbnails ; } | Get the list of all the thumbnails . |
10,834 | public function deleteThumbnail ( $ type ) { $ app = Application :: getFacadeApplication ( ) ; $ config = $ app -> make ( 'config' ) ; if ( ! ( $ type instanceof ThumbnailTypeVersion ) ) { $ type = ThumbnailTypeVersion :: getByHandle ( $ type ) ; } $ fsl = $ this -> getFile ( ) -> getFileStorageLocationObject ( ) -> getFileSystemObject ( ) ; $ path = $ type -> getFilePath ( $ this ) ; try { if ( $ fsl -> has ( $ path ) ) { $ fsl -> delete ( $ path ) ; $ app [ 'director' ] -> dispatch ( 'on_thumbnail_delete' , new \ Concrete \ Core \ File \ Event \ ThumbnailDelete ( $ path , $ type ) ) ; } } catch ( FileNotFoundException $ e ) { } if ( $ type -> getHandle ( ) == $ config -> get ( 'concrete.icons.file_manager_listing.handle' ) && $ this -> fvHasListingThumbnail ) { $ this -> fvHasListingThumbnail = false ; $ this -> save ( ) ; } if ( $ type -> getHandle ( ) == $ config -> get ( 'concrete.icons.file_manager_detail.handle' ) && $ this -> fvHasDetailThumbnail ) { $ this -> fvHasDetailThumbnail = false ; $ this -> save ( ) ; } } | Delete the thumbnail for a specific thumbnail type version . |
10,835 | public function updateThumbnailStorageLocation ( $ type , StorageLocation $ location ) { if ( ! ( $ type instanceof ThumbnailTypeVersion ) ) { $ type = ThumbnailTypeVersion :: getByHandle ( $ type ) ; } $ fsl = $ this -> getFile ( ) -> getFileStorageLocationObject ( ) -> getFileSystemObject ( ) ; $ path = $ type -> getFilePath ( $ this ) ; $ manager = new MountManager ( [ 'current' => $ fsl , 'new' => $ location -> getFileSystemObject ( ) , ] ) ; try { $ manager -> move ( 'current://' . $ path , 'new://' . $ path ) ; } catch ( FileNotFoundException $ e ) { } } | Move the thumbnail of a specific thumbnail type version to a new storage location . |
10,836 | public function getJSONObject ( ) { $ app = Application :: getFacadeApplication ( ) ; $ urlResolver = $ app -> make ( ResolverManagerInterface :: class ) ; $ r = new stdClass ( ) ; $ fp = new Permissions ( $ this -> getFile ( ) ) ; $ r -> canCopyFile = $ fp -> canCopyFile ( ) ; $ r -> canEditFileProperties = $ fp -> canEditFileProperties ( ) ; $ r -> canEditFilePermissions = $ fp -> canEditFilePermissions ( ) ; $ r -> canDeleteFile = $ fp -> canDeleteFile ( ) ; $ r -> canReplaceFile = $ fp -> canEditFileContents ( ) ; $ r -> canEditFileContents = $ fp -> canEditFileContents ( ) ; $ r -> canViewFileInFileManager = $ fp -> canRead ( ) ; $ r -> canRead = $ fp -> canRead ( ) ; $ r -> canViewFile = $ this -> canView ( ) ; $ r -> canEditFile = $ this -> canEdit ( ) ; $ r -> url = $ this -> getURL ( ) ; $ r -> urlInline = ( string ) $ urlResolver -> resolve ( [ '/download_file' , 'view_inline' , $ this -> getFileID ( ) ] ) ; $ r -> urlDownload = ( string ) $ urlResolver -> resolve ( [ '/download_file' , 'view' , $ this -> getFileID ( ) ] ) ; $ r -> title = $ this -> getTitle ( ) ; $ r -> genericTypeText = $ this -> getGenericTypeText ( ) ; $ r -> description = $ this -> getDescription ( ) ; $ r -> fileName = $ this -> getFileName ( ) ; $ r -> resultsThumbnailImg = $ this -> getListingThumbnailImage ( ) ; $ r -> fID = $ this -> getFileID ( ) ; $ r -> treeNodeMenu = new Menu ( $ this -> getfile ( ) ) ; return $ r ; } | Get a representation of this Version instance that s easily serializable . |
10,837 | protected function save ( $ flush = true ) { $ app = Application :: getFacadeApplication ( ) ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ em -> persist ( $ this ) ; if ( $ flush ) { $ em -> flush ( ) ; } } | Save the instance changes . |
10,838 | public function getPackageIconURL ( $ pkg ) { if ( $ pkg && file_exists ( $ pkg -> getPackagePath ( ) . '/' . FILENAME_BLOCK_ICON ) ) { return $ this -> getPackageURL ( $ pkg ) . '/' . FILENAME_BLOCK_ICON ; } else { return PACKAGE_GENERIC_ICON ; } } | Gets a full URL to an icon for a particular application . |
10,839 | public function getBlockTypeIconURL ( $ bt ) { $ url = $ this -> getBlockTypeAssetsURL ( $ bt , FILENAME_BLOCK_ICON ) ; if ( $ url != false ) { return $ url ; } else { return BLOCK_TYPE_GENERIC_ICON ; } } | Gets a full URL to an icon for a particular block type . |
10,840 | public function getBlockTypeAssetsURL ( $ bt , $ file = false ) { $ ff = '' ; if ( $ file != false ) { $ ff = '/' . $ file ; } $ url = '' ; $ packageHandle = null ; if ( file_exists ( DIR_FILES_BLOCK_TYPES . '/' . $ bt -> getBlockTypeHandle ( ) . $ ff ) ) { $ url = REL_DIR_APPLICATION . '/' . DIRNAME_BLOCKS . '/' . $ bt -> getBlockTypeHandle ( ) . $ ff ; } elseif ( $ bt -> getPackageID ( ) > 0 ) { $ packageHandle = $ bt -> getPackageHandle ( ) ; $ dirp = ( is_dir ( DIR_PACKAGES . '/' . $ packageHandle ) ) ? DIR_PACKAGES . '/' . $ packageHandle : DIR_PACKAGES_CORE . '/' . $ packageHandle ; if ( file_exists ( $ dirp . '/' . DIRNAME_BLOCKS . '/' . $ bt -> getBlockTypeHandle ( ) . $ ff ) ) { $ url = ( is_dir ( DIR_PACKAGES . '/' . $ packageHandle ) ) ? DIR_REL : ASSETS_URL ; $ url = $ url . '/' . DIRNAME_PACKAGES . '/' . $ packageHandle . '/' . DIRNAME_BLOCKS . '/' . $ bt -> getBlockTypeHandle ( ) . $ ff ; } } elseif ( file_exists ( DIR_FILES_BLOCK_TYPES_CORE . '/' . $ bt -> getBlockTypeHandle ( ) . $ ff ) ) { $ url = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $ bt -> getBlockTypeHandle ( ) . $ ff ; } if ( $ url && $ file ) { $ asset = null ; if ( substr ( $ file , - 3 ) === '.js' ) { $ asset = new JavascriptAsset ( '' ) ; } elseif ( substr ( $ file , - 3 ) === '.css' ) { $ asset = new CssAsset ( '' ) ; } if ( $ asset !== null ) { $ asset -> setAssetIsLocal ( true ) ; $ asset -> setAssetURL ( $ url ) ; if ( $ packageHandle ) { $ app = Application :: getFacadeApplication ( ) ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ repo = $ em -> getRepository ( Package :: class ) ; $ asset -> setPackageObject ( $ repo -> findOneBy ( [ 'pkgHandle' => $ packageHandle ] ) ) ; } $ url = $ asset -> getAssetURL ( ) ; } } return $ url ; } | Gets a full URL to the directory containing all of a block s items including JavaScript tools icons etc ... |
10,841 | protected function constructView ( $ mixed ) { if ( $ mixed instanceof Block ) { $ this -> blockType = $ mixed -> getBlockTypeObject ( ) ; $ this -> block = $ mixed ; $ this -> area = $ mixed -> getBlockAreaObject ( ) ; } else { $ this -> blockType = $ mixed ; if ( $ this -> blockType -> controller ) { $ this -> controller = $ this -> blockType -> controller ; } } $ this -> blockTypePkgHandle = $ this -> blockType -> getPackageHandle ( ) ; if ( ! isset ( $ this -> controller ) ) { if ( isset ( $ this -> block ) ) { $ this -> controller = $ this -> block -> getInstance ( ) ; $ this -> controller -> setBlockObject ( $ this -> block ) ; } else { $ this -> controller = $ this -> blockType -> getController ( ) ; } } } | Construct a block view object |
10,842 | public function renderViewContents ( $ scopeItems ) { $ shouldRender = function ( ) { $ app = Application :: getFacadeApplication ( ) ; $ event = new BlockBeforeRender ( $ this -> block ) ; $ app -> make ( 'director' ) -> dispatch ( 'on_block_before_render' , $ event ) ; return $ event -> proceed ( ) ; } ; if ( ! $ shouldRender ( ) ) { return ; } unset ( $ shouldRender ) ; extract ( $ scopeItems ) ; if ( ! $ this -> outputContent ) { ob_start ( ) ; include $ this -> template ; $ this -> outputContent = ob_get_contents ( ) ; ob_end_clean ( ) ; } $ loc = Localization :: getInstance ( ) ; $ loc -> pushActiveContext ( Localization :: CONTEXT_UI ) ; if ( $ this -> blockViewHeaderFile ) { include $ this -> blockViewHeaderFile ; } $ this -> controller -> registerViewAssets ( $ this -> outputContent ) ; $ this -> onBeforeGetContents ( ) ; $ this -> fireOnBlockOutputEvent ( ) ; echo $ this -> outputContent ; $ this -> onAfterGetContents ( ) ; if ( $ this -> blockViewFooterFile ) { include $ this -> blockViewFooterFile ; } $ loc -> popActiveContext ( ) ; } | Echo block contents |
10,843 | public function getBlockPath ( $ filename = null ) { $ obj = $ this -> blockType ; if ( file_exists ( DIR_FILES_BLOCK_TYPES . '/' . $ obj -> getBlockTypeHandle ( ) . '/' . $ filename ) ) { $ base = DIR_FILES_BLOCK_TYPES . '/' . $ obj -> getBlockTypeHandle ( ) ; } else { if ( $ obj -> getPackageID ( ) > 0 ) { if ( is_dir ( DIR_PACKAGES . '/' . $ obj -> getPackageHandle ( ) ) ) { $ base = DIR_PACKAGES . '/' . $ obj -> getPackageHandle ( ) . '/' . DIRNAME_BLOCKS . '/' . $ obj -> getBlockTypeHandle ( ) ; } else { $ base = DIR_PACKAGES_CORE . '/' . $ obj -> getPackageHandle ( ) . '/' . DIRNAME_BLOCKS . '/' . $ obj -> getBlockTypeHandle ( ) ; } } else { $ base = DIR_FILES_BLOCK_TYPES_CORE . '/' . $ obj -> getBlockTypeHandle ( ) ; } } return $ base ; } | Returns the path to the current block s directory . |
10,844 | public function getBlockURL ( $ filename = null ) { $ obj = $ this -> blockType ; if ( $ obj -> getPackageID ( ) > 0 ) { if ( is_dir ( DIR_PACKAGES_CORE . '/' . $ obj -> getPackageHandle ( ) ) ) { $ base = ASSETS_URL . '/' . DIRNAME_PACKAGES . '/' . $ obj -> getPackageHandle ( ) . '/' . DIRNAME_BLOCKS . '/' . $ obj -> getBlockTypeHandle ( ) ; } else { $ base = DIR_REL . '/' . DIRNAME_PACKAGES . '/' . $ obj -> getPackageHandle ( ) . '/' . DIRNAME_BLOCKS . '/' . $ obj -> getBlockTypeHandle ( ) ; } } else { if ( file_exists ( DIR_FILES_BLOCK_TYPES . '/' . $ obj -> getBlockTypeHandle ( ) . '/' . $ filename ) ) { $ base = REL_DIR_APPLICATION . '/' . DIRNAME_BLOCKS . '/' . $ obj -> getBlockTypeHandle ( ) ; } else { $ base = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $ obj -> getBlockTypeHandle ( ) ; } } return $ base ; } | Returns a relative path to the current block s directory . If a filename is specified it will be appended and searched for as well . |
10,845 | private function fireOnBlockOutputEvent ( ) { $ event = new BlockOutput ( $ this -> block ) ; $ event -> setContents ( $ this -> outputContent ) ; $ app = Application :: getFacadeApplication ( ) ; $ app -> make ( 'director' ) -> dispatch ( 'on_block_output' , $ event ) ; $ this -> outputContent = $ event -> getContents ( ) ; } | Fire an event just before the block is outputted on the page |
10,846 | public function getChildFolderByName ( $ name , $ create = false ) { $ typeHandle = $ this -> getTreeNodeTypeHandle ( ) ; if ( $ this -> childNodesLoaded ) { $ childNodes = $ this -> childNodes ; } else { $ childNodesData = $ this -> getHierarchicalNodesOfType ( $ typeHandle , 1 , true , false , 1 ) ; $ childNodes = array_map ( function ( $ item ) { return $ item [ 'treeNodeObject' ] ; } , $ childNodesData ) ; } $ result = null ; foreach ( $ childNodes as $ childNode ) { if ( $ childNode -> getTreeNodeTypeHandle ( ) === $ typeHandle && $ childNode -> getTreeNodeName ( ) === $ name ) { $ result = $ childNode ; break ; } } if ( $ result === null && $ create ) { $ result = static :: add ( $ name , $ this ) ; } return $ result ; } | Get the first child folder this folder that has a specific name . |
10,847 | public function getChildFolderByPath ( array $ names , $ create = false ) { if ( count ( $ names ) === 0 ) { $ result = $ this ; } else { $ childName = array_shift ( $ names ) ; $ result = $ this -> getChildFolderByName ( $ childName , $ create ) ; if ( $ result !== null ) { $ result = $ result -> getChildFolderByPath ( $ names , $ create ) ; } } return $ result ; } | Get a descendent folder of this folder given its path . |
10,848 | public function asArray ( ) { $ error = $ this -> error ; if ( $ error -> has ( ) ) { $ o = [ 'error' => true , 'errors' => [ ] , 'htmlErrorIndexes' => [ ] , ] ; $ index = 0 ; foreach ( $ error -> getList ( ) as $ error ) { $ o [ 'errors' ] [ ] = ( string ) $ error ; if ( $ error instanceof HtmlAwareErrorInterface && $ error -> messageContainsHtml ( ) ) { $ o [ 'htmlErrorIndexes' ] [ ] = $ index ; } ++ $ index ; } if ( empty ( $ o [ 'htmlErrorIndexes' ] ) ) { unset ( $ o [ 'htmlErrorIndexes' ] ) ; } return $ o ; } } | Build an array describing the errors . |
10,849 | public function getApiKey ( $ apiKeyIdentifier ) { return isset ( $ this -> apiKeys [ $ apiKeyIdentifier ] ) ? $ this -> apiKeys [ $ apiKeyIdentifier ] : null ; } | Gets API key |
10,850 | public function getApiKeyPrefix ( $ apiKeyIdentifier ) { return isset ( $ this -> apiKeyPrefixes [ $ apiKeyIdentifier ] ) ? $ this -> apiKeyPrefixes [ $ apiKeyIdentifier ] : null ; } | Gets API key prefix |
10,851 | public function addDefaultHeader ( $ headerName , $ headerValue ) { if ( ! is_string ( $ headerName ) ) { throw new \ InvalidArgumentException ( 'Header name must be a string.' ) ; } $ this -> defaultHeaders [ $ headerName ] = $ headerValue ; return $ this ; } | Adds a default header |
10,852 | public function setCurlTimeout ( $ seconds ) { if ( ! is_numeric ( $ seconds ) || $ seconds < 0 ) { throw new \ InvalidArgumentException ( 'Timeout value must be numeric and a non-negative number.' ) ; } $ this -> curlTimeout = $ seconds ; return $ this ; } | Sets the HTTP timeout value |
10,853 | public static function getV1BatchTokenFromHeaders ( $ http_headers ) { if ( is_array ( $ http_headers ) && isset ( $ http_headers [ 'Link' ] ) ) { $ connect_link_regexp = "/^<([^>]+)>;rel='next'$/" ; if ( preg_match ( $ connect_link_regexp , $ http_headers [ 'Link' ] , $ match ) === 1 ) { $ link_uri = $ match [ 1 ] ; if ( $ query = parse_url ( $ link_uri , PHP_URL_QUERY ) ) { parse_str ( $ query , $ query_params ) ; if ( is_array ( $ query_params ) && isset ( $ query_params [ 'batch_token' ] ) ) { return $ query_params [ 'batch_token' ] ; } } } } return null ; } | Return a batch_token if present on the Link header or null if no token is present |
10,854 | public function serializeCollection ( array $ collection , $ collectionFormat , $ allowCollectionFormatMulti = false ) { if ( $ allowCollectionFormatMulti && ( 'multi' === $ collectionFormat ) ) { return preg_replace ( '/%5B[0-9]+%5D=/' , '=' , http_build_query ( $ collection , '' , '&' ) ) ; } switch ( $ collectionFormat ) { case 'pipes' : return implode ( '|' , $ collection ) ; case 'tsv' : return implode ( "\t" , $ collection ) ; case 'ssv' : return implode ( ' ' , $ collection ) ; case 'csv' : default : return implode ( ',' , $ collection ) ; } } | Serialize an array to a string . |
10,855 | private static function handler ( $ uri ) { return function ( \ Exception $ e ) use ( $ uri ) { if ( $ e instanceof TimeoutException ) { throw new \ RuntimeException ( 'Connection to ' . $ uri . ' timed out after ' . $ e -> getTimeout ( ) . ' seconds' , \ defined ( 'SOCKET_ETIMEDOUT' ) ? \ SOCKET_ETIMEDOUT : 0 ) ; } throw $ e ; } ; } | Creates a static rejection handler that reports a proper error message in case of a timeout . |
10,856 | protected function getValues ( array $ labels ) { if ( in_array ( strtolower ( $ this -> type ) , $ this -> specialDatasets ) ) { return Collection :: make ( $ this -> values ) -> map ( function ( $ value , $ key ) use ( $ labels ) { return [ 'name' => $ labels [ $ key ] , 'value' => $ value , ] ; } ) -> toArray ( ) ; } return $ this -> values ; } | Get the formated values . |
10,857 | public function dataset ( string $ name , string $ type , $ data ) { if ( $ data instanceof Collection ) { $ data = $ data -> toArray ( ) ; } $ dataset = new $ this -> dataset ( $ name , $ type , $ data ) ; array_push ( $ this -> datasets , $ dataset ) ; return $ dataset ; } | Adds a new dataset to the chart . |
10,858 | public function labels ( $ labels ) { if ( $ labels instanceof Collection ) { $ labels = $ labels -> toArray ( ) ; } $ this -> labels = $ labels ; return $ this ; } | Set the chart labels . |
10,859 | public function options ( $ options , bool $ overwrite = false ) { if ( ! empty ( $ options [ 'plugins' ] ) ) { $ options [ 'plugins' ] = new Raw ( trim ( preg_replace ( '/\s\s+/' , ' ' , $ options [ 'plugins' ] ) ) ) ; } if ( $ options instanceof Collection ) { $ options = $ options -> toArray ( ) ; } if ( $ overwrite ) { $ this -> options = $ options ; } else { $ this -> options = array_replace_recursive ( $ this -> options , $ options ) ; } return $ this ; } | Set the chart options . |
10,860 | public function plugins ( $ plugins , bool $ overwrite = true ) { if ( $ plugins instanceof Collection ) { $ plugins = $ plugins -> toArray ( ) ; } if ( $ overwrite ) { $ this -> plugins = $ plugins ; } else { $ this -> plugins = array_replace_recursive ( $ this -> plugins , $ plugins ) ; } return $ this ; } | Set the plugins options . |
10,861 | public function container ( string $ container = null ) { if ( ! $ container ) { return View :: make ( $ this -> container , [ 'chart' => $ this ] ) ; } $ this -> container = $ container ; return $ this ; } | Set the chart container . |
10,862 | public function script ( string $ script = null ) { if ( count ( $ this -> datasets ) == 0 && ! $ this -> api_url ) { throw new \ Exception ( 'No datasets provided, please provide at least one dataset to generate a chart' ) ; } if ( ! $ script ) { return View :: make ( $ this -> script , [ 'chart' => $ this ] ) ; } $ this -> script = $ script ; return $ this ; } | Set the chart script . |
10,863 | public function formatOptions ( bool $ strict = false , bool $ noBraces = false ) { if ( ! $ strict && count ( $ this -> options ) === 0 ) { return '' ; } $ options = Encoder :: encode ( $ this -> options ) ; return $ noBraces ? substr ( $ options , 1 , - 1 ) : $ options ; } | Formats the chart options . |
10,864 | public function formatPlugins ( bool $ strict = false , bool $ noBraces = false ) { if ( ! $ strict && count ( $ this -> plugins ) === 0 ) { return '' ; } $ plugins = str_replace ( '"' , '' , Encoder :: encode ( $ this -> plugins ) ) ; return $ noBraces ? substr ( $ plugins , 1 , - 1 ) : $ plugins ; } | Formats the plugins options . |
10,865 | public function formatDatasets ( ) { return Encoder :: encode ( Collection :: make ( $ this -> datasets ) -> each ( function ( $ dataset ) { $ dataset -> matchValues ( count ( $ this -> labels ) ) ; } ) -> map ( function ( $ dataset ) { return $ dataset -> format ( $ this -> labels ) ; } ) -> toArray ( ) ) ; } | Formats the datasets for the output . |
10,866 | public function setScriptAttribute ( string $ key , string $ value ) { $ this -> scriptAttributes [ $ key ] = $ value ; return $ this ; } | Sets an HTML attribute the the script tag of the chart . |
10,867 | public function formatContainerOptions ( string $ type = 'css' , bool $ maxIfNull = false ) { $ options = '' ; $ height = ( $ maxIfNull && ! $ this -> height ) ? '100%' : $ this -> height ; $ width = ( $ maxIfNull && ! $ this -> width ) ? '100%' : $ this -> width ; switch ( $ type ) { case 'css' : $ options .= " style='" ; ( ! $ height ) ? : $ options .= "height: {$height}px !important;" ; ( ! $ width ) ? : $ options .= "width: {$width}px !important;" ; $ options .= "' " ; break ; case 'js' : if ( $ height ) { if ( is_int ( $ height ) ) { $ options .= "height: {$height}, " ; } else { $ options .= "height: '{$height}', " ; } } if ( $ width ) { if ( is_int ( $ width ) ) { $ options .= "width: {$width}, " ; } else { $ options .= "width: '{$width}', " ; } } break ; default : ( ! $ height ) ? : $ options .= " height='{$this->height}' " ; ( ! $ this -> width ) ? : $ options .= " width='{$this->width}' " ; } return $ options ; } | Formats the container options . |
10,868 | public function format ( array $ labels = [ ] ) { return array_merge ( $ this -> options , [ 'data' => $ this -> formatValues ( $ labels ) , 'seriesName' => $ this -> name , 'renderAs' => strtolower ( $ this -> type ) , ] ) ; } | Dataset representation . |
10,869 | protected function formatValues ( array $ labels ) { $ values = Collection :: make ( $ this -> values ) ; if ( in_array ( strtolower ( $ this -> type ) , $ this -> specialDatasets ) ) { $ colors = $ this -> getColors ( $ labels ) ; return $ values -> map ( function ( $ value , $ key ) use ( $ colors , $ labels ) { $ val = [ 'label' => $ labels [ $ key ] , 'value' => $ value , ] ; if ( $ colors -> count ( ) > 0 ) { $ val [ 'color' ] = $ colors -> get ( $ key ) ; } return $ val ; } ) -> toArray ( ) ; } return $ values -> map ( function ( $ value ) { return [ 'value' => $ value , ] ; } ) -> toArray ( ) ; } | Formats the chart values . |
10,870 | protected function getColors ( array $ labels ) { $ colors = Collection :: make ( array_key_exists ( 'color' , $ this -> options ) ? $ this -> options [ 'color' ] : [ ] ) ; while ( $ colors -> count ( ) < count ( $ labels ) ) { $ colors -> push ( $ this -> undefinedColor ) ; } return $ colors ; } | Get the chart colors . |
10,871 | public function export ( bool $ export , bool $ client = true ) { return $ this -> options ( [ 'exportenabled' => $ export , 'exportatclient' => $ client , ] ) ; } | Determines if the chart should show the export button . |
10,872 | public function values ( $ values ) { if ( $ values instanceof Collection ) { $ values = $ values -> toArray ( ) ; } $ this -> values = $ values ; return $ this ; } | Set the dataset values . |
10,873 | public function options ( $ options , bool $ overwrite = false ) { if ( $ overwrite ) { $ this -> options = $ options ; } else { $ this -> options = array_replace_recursive ( $ this -> options , $ options ) ; } return $ this ; } | Set the dataset options . |
10,874 | public function matchValues ( int $ values , bool $ strict = false ) { while ( count ( $ this -> values ) < $ values ) { array_push ( $ this -> values , 0 ) ; } if ( $ strict ) { $ this -> values = array_slice ( $ this -> values , 0 , $ values ) ; } } | Matches the values of the dataset with the given number . |
10,875 | public function minimalist ( bool $ minimalist = true ) { $ this -> displayAxes ( ! $ minimalist ) ; $ this -> displayLegend ( ! $ minimalist ) ; return $ this -> options ( [ 'xAxis' => [ 'axisLabel' => [ 'show' => ! $ minimalist , ] , 'splitLine' => [ 'show' => ! $ minimalist , ] , ] , 'yAxis' => [ 'axisLabel' => [ 'show' => ! $ minimalist , ] , 'splitLine' => [ 'show' => ! $ minimalist , ] , ] , ] ) ; } | Show the minimalistic . |
10,876 | public function displayAxes ( bool $ display ) { return $ this -> options ( [ 'xAxis' => [ 'show' => $ display , 'axisLine' => [ 'show' => $ display , ] , 'axisTick' => [ 'show' => $ display , ] , ] , 'yAxis' => [ 'show' => $ display , 'axisLine' => [ 'show' => $ display , ] , 'axisTick' => [ 'show' => $ display , ] , ] , ] ) ; } | Display the chart axes . |
10,877 | public function export ( bool $ export = true , string $ title = ' ' ) { return $ this -> options ( [ 'toolbox' => [ 'show' => true , 'feature' => [ 'saveAsImage' => [ 'title' => $ title , ] , ] , ] , ] ) ; } | ALlow to export the chart . |
10,878 | public function formatDatasets ( ) { $ datasets = Collection :: make ( $ this -> datasets ) ; return json_encode ( [ 'columns' => Collection :: make ( $ this -> datasets ) -> each ( function ( $ dataset ) { $ dataset -> matchValues ( count ( $ this -> labels ) ) ; } ) -> map ( function ( $ dataset ) { return $ dataset -> format ( $ this -> labels ) ; } ) -> toArray ( ) , 'type' => $ datasets -> first ( ) -> type , 'types' => $ datasets -> mapWithKeys ( function ( $ d ) { return [ $ d -> name => $ d -> type ] ; } ) -> toArray ( ) , ] ) ; } | Formats the datasets . |
10,879 | public function displayAxes ( bool $ axes , bool $ strict = false ) { if ( $ strict ) { return $ this -> options ( [ 'scale' => [ 'display' => $ axes , ] , ] ) ; } return $ this -> options ( [ 'scales' => [ 'xAxes' => [ [ 'display' => $ axes , ] , ] , 'yAxes' => [ [ 'display' => $ axes , ] , ] , ] , ] ) ; } | Display the chart axis . |
10,880 | public function minimalist ( bool $ display = false ) { $ this -> displayLegend ( ! $ display ) ; return $ this -> displayAxes ( ! $ display ) ; } | Set the chart style to minimalist . |
10,881 | public function color ( $ color ) { if ( $ color instanceof Collection ) { $ color = $ color -> toArray ( ) ; } return $ this -> options ( [ 'color' => $ color , ] ) ; } | Set the dataset color . |
10,882 | public function formatOptions ( bool $ strict = false , bool $ noBraces = false ) { $ this -> options ( [ 'xAxis' => [ 'data' => json_decode ( $ this -> formatLabels ( ) ) , ] , ] ) ; return parent :: formatOptions ( $ strict , $ noBraces ) ; } | Formats the options . |
10,883 | public function formatOptions ( bool $ strict = false , bool $ noBraces = false ) { $ colors = [ ] ; $ default = 0 ; foreach ( $ this -> datasets as $ dataset ) { $ color = $ this -> default_colors [ $ default ] ; if ( array_key_exists ( 'color' , $ dataset -> options ) ) { $ color = $ dataset -> options [ 'color' ] ; unset ( $ dataset -> options [ 'color' ] ) ; } else { $ default ++ ; } array_push ( $ colors , $ color ) ; } $ this -> options ( [ 'colors' => $ colors , ] ) ; return parent :: formatOptions ( $ strict , $ noBraces ) ; } | Format the datasets . |
10,884 | public function format ( ) { return array_merge ( $ this -> options , [ 'data' => $ this -> values , 'label' => $ this -> name , 'type' => $ this -> type , ] ) ; } | Formats the dataset for chartjs . |
10,885 | public function onPreFileDownload ( CPlugin \ PreFileDownloadEvent $ ev ) { if ( $ this -> disabled ) { return ; } $ scheme = parse_url ( $ ev -> getProcessedUrl ( ) , PHP_URL_SCHEME ) ; if ( ! in_array ( $ scheme , self :: $ supportedSchemes , true ) ) { return ; } $ rfs = $ ev -> getRemoteFilesystem ( ) ; $ curlrfs = new CurlRemoteFilesystem ( $ this -> io , $ this -> config , $ rfs -> getOptions ( ) ) ; $ ev -> setRemoteFilesystem ( $ curlrfs ) ; } | Keep - Alived file downloader |
10,886 | public function onPostDependenciesSolving ( Installer \ InstallerEvent $ ev ) { if ( $ this -> disabled ) { return ; } $ prefetcher = new Prefetcher ; $ prefetcher -> fetchAllFromOperations ( $ this -> io , $ this -> config , $ ev -> getOperations ( ) ) ; } | pre - fetch parallel by curl_multi |
10,887 | public function extractContent ( $ content ) { $ regex = '~^(' . '---' . "){1}[\r\n|\n]*(.*?)[\r\n|\n]+(" . '---' . "){1}[\r\n|\n]*(.*)$~s" ; return preg_match ( $ regex , $ content , $ matches ) === 1 ? ltrim ( $ matches [ 4 ] ) : $ content ; } | Adapted from Mni \ FrontYAML . |
10,888 | private function dropVariants ( & $ Arr ) { if ( isset ( $ Arr [ 'GB18030' ] , $ Arr [ 'GB2312' ] ) ) { unset ( $ Arr [ 'GB2312' ] ) ; } if ( isset ( $ Arr [ 'UCS-2' ] ) && ( isset ( $ Arr [ 'UTF-16BE' ] ) || isset ( $ Arr [ 'UTF-16LE' ] ) ) ) { unset ( $ Arr [ 'UCS-2' ] ) ; } if ( isset ( $ Arr [ 'UCS-4' ] ) && ( isset ( $ Arr [ 'UTF-32BE' ] ) || isset ( $ Arr [ 'UTF-32LE' ] ) ) ) { unset ( $ Arr [ 'UCS-4' ] ) ; } if ( isset ( $ Arr [ 'UTF-8' ] ) || isset ( $ Arr [ 'UTF-16BE' ] ) || isset ( $ Arr [ 'UTF-16LE' ] ) || isset ( $ Arr [ 'UCS-2' ] ) || isset ( $ Arr [ 'UTF-32BE' ] ) || isset ( $ Arr [ 'UTF-32LE' ] ) || isset ( $ Arr [ 'UCS-4' ] ) || isset ( $ Arr [ 'GB18030' ] ) || isset ( $ Arr [ 'GB2312' ] ) || isset ( $ Arr [ 'BIG5' ] ) || isset ( $ Arr [ 'SHIFT-JIS' ] ) || isset ( $ Arr [ 'JOHAB' ] ) || isset ( $ Arr [ 'UCS-4' ] ) ) { foreach ( $ Arr as $ Key => $ Value ) { if ( ! preg_match ( '~^(?:UTF|UCS|GB|BIG5|SHIFT-JIS|JOHAB)~' , $ Key ) ) { unset ( $ Arr [ $ Key ] ) ; } } } } | Drop candidates belonging to encodings that are outdated subsets or variants of other encodings with valid candidates . |
10,889 | public function normalise ( $ String ) { $ this -> Last = '' ; $ this -> Len = strlen ( $ String ) ; $ Valid = [ ] ; set_error_handler ( function ( $ errno ) { return ; } ) ; foreach ( $ this -> supported ( ) as $ Encoding ) { if ( ! $ this -> checkConformity ( $ String , $ Encoding ) ) { continue ; } $ Attempt = iconv ( $ Encoding , $ this -> NormaliseTo , $ String ) ; if ( $ Attempt === false || ! $ this -> checkConformity ( $ Attempt , $ this -> NormaliseTo ) ) { continue ; } if ( strcmp ( iconv ( $ this -> NormaliseTo , $ Encoding , $ Attempt ) , $ String ) === 0 ) { $ Valid [ $ Encoding ] = $ Attempt ; if ( $ Encoding === $ this -> NormaliseTo ) { break ; } } } restore_error_handler ( ) ; if ( isset ( $ Valid [ $ this -> NormaliseTo ] ) ) { $ this -> Last = $ this -> NormaliseTo ; return $ Valid [ $ this -> NormaliseTo ] ; } foreach ( $ Valid as $ Key => $ Value ) { $ Valid [ $ Key ] = [ 'String' => $ Value , 'Weight' => 0 ] ; } $ this -> weigh ( $ String , $ Valid ) ; uasort ( $ Valid , function ( $ A , $ B ) { return $ A [ 'Weight' ] === $ B [ 'Weight' ] ? 0 : ( $ A [ 'Weight' ] < $ B [ 'Weight' ] ? 1 : - 1 ) ; } ) ; $ this -> dropVariants ( $ Valid ) ; $ Current = key ( $ Valid ) ; foreach ( $ Valid as $ Key => $ Value ) { if ( $ Value [ 'Weight' ] < $ Valid [ $ Current ] [ 'Weight' ] ) { unset ( $ Valid [ $ Key ] ) ; } } if ( ( $ Count = count ( $ Valid ) ) === 1 ) { $ this -> Last = $ Current ; return $ Valid [ $ Current ] [ 'String' ] ; } return $ String ; } | Attempts to normalise a string . |
10,890 | public function guard ( $ String ) { return ! function_exists ( 'iconv' ) || $ this -> checkConformity ( $ String , $ this -> NormaliseTo ) ? $ String : $ this -> normalise ( $ String ) ; } | Checks if the class requirements are met . If met then calls checkConformity . If the string is non - conformant then calls normalise . If the class requirements aren t met or if the string is already conformant return the original string immediately . |
10,891 | public function getEntry ( $ Entry ) { if ( $ this -> Using === 'APCu' ) { return $ this -> unserializeEntry ( apcu_fetch ( $ Entry ) ) ; } if ( $ this -> Using === 'Memcached' || $ this -> Using === 'Redis' ) { return $ this -> unserializeEntry ( $ this -> WorkingData -> get ( $ Entry ) ) ; } if ( $ this -> Using === 'PDO' ) { if ( $ this -> clearExpiredPDO ( ) ) { $ this -> Modified = true ; } $ PDO = $ this -> WorkingData -> prepare ( self :: getQuery ) ; if ( $ PDO !== false && $ PDO -> execute ( [ 'key' => $ Entry ] ) ) { $ Data = $ PDO -> fetch ( \ PDO :: FETCH_ASSOC ) ; return isset ( $ Data [ 'Data' ] ) ? $ this -> unserializeEntry ( $ Data [ 'Data' ] ) : false ; } return false ; } if ( is_array ( $ this -> WorkingData ) && isset ( $ this -> WorkingData [ $ Entry ] ) ) { if ( isset ( $ this -> WorkingData [ $ Entry ] [ 'Data' ] ) && ! empty ( $ this -> WorkingData [ $ Entry ] [ 'Time' ] ) ) { if ( $ this -> WorkingData [ $ Entry ] [ 'Time' ] <= 0 || $ this -> WorkingData [ $ Entry ] [ 'Time' ] > time ( ) ) { return $ this -> unserializeEntry ( $ this -> WorkingData [ $ Entry ] [ 'Data' ] ) ; } unset ( $ this -> WorkingData [ $ Entry ] ) ; $ this -> Modified = true ; return false ; } return $ this -> unserializeEntry ( $ this -> WorkingData [ $ Entry ] ) ; } return false ; } | Get a cache entry . |
10,892 | public function setEntry ( $ Key , $ Value , $ TTL = 3600 ) { $ Value = $ this -> serializeEntry ( $ Value ) ; if ( $ this -> Using === 'APCu' ) { if ( apcu_store ( $ Key , $ Value , $ TTL ) ) { return $ this -> Modified = true ; } return false ; } if ( $ this -> Using === 'Memcached' ) { if ( $ TTL >= 2592000 ) { $ TTL += time ( ) ; } if ( $ this -> WorkingData -> set ( $ Key , $ Value , $ TTL ) ) { return $ this -> Modified = true ; } return false ; } if ( $ this -> Using === 'Redis' ) { if ( $ this -> WorkingData -> set ( $ Key , $ Value , $ TTL ) ) { return $ this -> Modified = true ; } return false ; } if ( $ this -> Using === 'PDO' ) { if ( $ TTL > 0 ) { $ TTL += time ( ) ; } $ PDO = $ this -> WorkingData -> prepare ( self :: setQuery ) ; if ( $ PDO !== false && $ PDO -> execute ( [ 'key' => $ Key , 'data' => $ Value , 'time' => $ TTL , 'key2' => $ Key , 'data2' => $ Value , 'time2' => $ TTL ] ) ) { return ( $ PDO -> rowCount ( ) > 0 && $ this -> Modified = true ) ; } return false ; } if ( is_array ( $ this -> WorkingData ) ) { if ( $ TTL > 0 ) { $ TTL += time ( ) ; $ this -> WorkingData [ $ Key ] = [ 'Data' => $ Value , 'Time' => $ TTL ] ; } else { $ this -> WorkingData [ $ Key ] = $ Value ; } return $ this -> Modified = true ; } return false ; } | Set a cache entry . |
10,893 | public function deleteEntry ( $ Entry ) { if ( $ this -> Using === 'APCu' ) { if ( apcu_delete ( $ Entry ) ) { return $ this -> Modified = true ; } return false ; } if ( $ this -> Using === 'Memcached' || $ this -> Using === 'Redis' ) { if ( $ this -> WorkingData -> delete ( $ Entry ) ) { return $ this -> Modified = true ; } return false ; } if ( $ this -> Using === 'PDO' ) { $ PDO = $ this -> WorkingData -> prepare ( self :: deleteQuery ) ; if ( $ PDO !== false && $ PDO -> execute ( [ 'key' => $ Entry ] ) ) { return ( $ PDO -> rowCount ( ) > 0 && $ this -> Modified = true ) ; } return false ; } if ( is_array ( $ this -> WorkingData ) ) { if ( isset ( $ this -> WorkingData [ $ Entry ] ) ) { unset ( $ this -> WorkingData [ $ Entry ] ) ; return $ this -> Modified = true ; } } return false ; } | Delete a specific cache entry . |
10,894 | public function clearCache ( ) { if ( $ this -> Using === 'APCu' ) { return $ this -> Modified = apcu_clear_cache ( ) ; } if ( $ this -> Using === 'Memcached' ) { return ( $ this -> WorkingData -> flush ( ) && ( $ this -> Modified = true ) ) ; } if ( $ this -> Using === 'Redis' ) { return ( $ this -> WorkingData -> flushDb ( ) && ( $ this -> Modified = true ) ) ; } if ( $ this -> Using === 'PDO' ) { $ PDO = $ this -> WorkingData -> prepare ( self :: clearQuery ) ; if ( $ PDO !== false && $ PDO -> execute ( ) ) { return ( $ PDO -> rowCount ( ) > 0 && $ this -> Modified = true ) ; } return false ; } if ( is_array ( $ this -> WorkingData ) ) { $ this -> WorkingData = [ ] ; return $ this -> Modified = true ; } return false ; } | Clears the entire cache . |
10,895 | public function clearExpiredPDO ( ) { if ( $ this -> Using !== 'PDO' ) { return false ; } $ PDO = $ this -> WorkingData -> prepare ( self :: clearExpiredQuery ) ; if ( $ PDO !== false && $ PDO -> execute ( [ 'time' => time ( ) ] ) ) { return ( $ PDO -> rowCount ( ) > 0 ) ; } return false ; } | Clears expired entries stored via PDO . |
10,896 | public function unserializeEntry ( $ Entry ) { if ( ! $ Entry || ! is_string ( $ Entry ) || ! preg_match ( '~^a\:\d+\:\{.*\}$~' , $ Entry ) ) { return $ Entry ; } $ Arr = unserialize ( $ Entry ) ; if ( is_array ( $ Arr ) ) { $ this -> clearExpired ( $ Arr ) ; return $ Arr ; } return $ Entry ; } | Unserialize a returned cache entry if necessary . |
10,897 | public function generateMarkers ( $ Pattern ) { preg_match_all ( $ Pattern , $ this -> Input , $ this -> Markers , PREG_OFFSET_CAPTURE | PREG_SET_ORDER ) ; $ Start = 0 ; $ this -> Working = [ ] ; foreach ( $ this -> Markers as $ Marker ) { if ( ! is_array ( $ Marker [ 0 ] ) || ! isset ( $ Marker [ 0 ] [ 0 ] ) || is_array ( $ Marker [ 0 ] [ 0 ] ) || ! isset ( $ Marker [ 0 ] [ 1 ] ) ) { break ; } $ this -> Working [ ] = substr ( $ this -> Input , $ Start , $ Marker [ 0 ] [ 1 ] - $ Start ) ; $ Start = $ Marker [ 0 ] [ 1 ] + strlen ( $ Marker [ 0 ] [ 0 ] ) ; } $ this -> Working [ ] = substr ( $ this -> Input , $ Start ) ; } | Generate markers and working data . |
10,898 | public function iterateClosure ( $ Closure , $ Glue = false ) { if ( ! is_callable ( $ Closure ) || empty ( $ this -> Input ) ) { return ; } if ( ! $ Glue ) { foreach ( $ this -> Working as & $ Segment ) { $ Segment = $ Closure ( $ Segment ) ; } return ; } foreach ( $ this -> Markers as & $ Segment ) { if ( isset ( $ Segment [ 0 ] [ 0 ] ) && ! is_array ( $ Segment [ 0 ] [ 0 ] ) ) { $ Segment [ 0 ] [ 0 ] = $ Closure ( $ Segment [ 0 ] [ 0 ] ) ; } } } | Iterate over the working data using a given closure . |
10,899 | public function recompile ( ) { $ Output = '' ; $ Glue = 0 ; foreach ( $ this -> Working as $ Segment ) { $ Output .= $ Segment ; if ( isset ( $ this -> Markers [ $ Glue ] [ 0 ] [ 0 ] ) && ! is_array ( $ this -> Markers [ $ Glue ] [ 0 ] [ 0 ] ) ) { $ Output .= $ this -> Markers [ $ Glue ] [ 0 ] [ 0 ] ; $ Glue ++ ; } } return $ Output ; } | Recompile all data after all work has finished and return it . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.