idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
46,700
protected function _parseExtensionDef ( $ target ) { $ paths = array ( ) ; if ( ! empty ( $ target [ 'paths' ] ) ) { $ paths = array_map ( array ( $ this , '_replacePathConstants' ) , ( array ) $ target [ 'paths' ] ) ; } $ target [ 'paths' ] = $ paths ; if ( ! empty ( $ target [ 'cachePath' ] ) ) { $ path = $ this -> _...
Parses paths in an extension definition
46,701
public function set ( $ path , $ value ) { $ parts = explode ( '.' , $ path ) ; switch ( count ( $ parts ) ) { case 2 : $ this -> _data [ $ parts [ 0 ] ] [ $ parts [ 1 ] ] = $ value ; break ; case 1 : $ this -> _data [ $ parts [ 0 ] ] = $ value ; break ; case 0 : throw new RuntimeException ( 'Path was empty.' ) ; defau...
Set values into the config object You can t modify targets or filters with this . Use the appropriate methods for those settings .
46,702
public function get ( $ path ) { $ parts = explode ( '.' , $ path ) ; switch ( count ( $ parts ) ) { case 2 : if ( isset ( $ this -> _data [ $ parts [ 0 ] ] [ $ parts [ 1 ] ] ) ) { return $ this -> _data [ $ parts [ 0 ] ] [ $ parts [ 1 ] ] ; } break ; case 1 : if ( isset ( $ this -> _data [ $ parts [ 0 ] ] ) ) { return...
Get values from the config data .
46,703
public function targetFilters ( $ name ) { $ ext = $ this -> getExt ( $ name ) ; $ filters = [ ] ; if ( isset ( $ this -> _data [ $ ext ] [ self :: FILTERS ] ) ) { $ filters = $ this -> _data [ $ ext ] [ self :: FILTERS ] ; } if ( ! empty ( $ this -> _targets [ $ name ] [ self :: FILTERS ] ) ) { $ buildFilters = $ this...
Get the filters for a build target .
46,704
public function allFilters ( ) { $ filters = [ ] ; foreach ( $ this -> extensions ( ) as $ ext ) { if ( empty ( $ this -> _data [ $ ext ] [ self :: FILTERS ] ) ) { continue ; } $ filters = array_merge ( $ filters , $ this -> _data [ $ ext ] [ self :: FILTERS ] ) ; } foreach ( $ this -> _targets as $ target ) { if ( emp...
Get configuration for all filters .
46,705
public function cachePath ( $ ext , $ path = null ) { if ( $ path === null ) { if ( isset ( $ this -> _data [ $ ext ] [ 'cachePath' ] ) ) { return $ this -> _data [ $ ext ] [ 'cachePath' ] ; } return '' ; } $ path = $ this -> _replacePathConstants ( $ path ) ; $ this -> _data [ $ ext ] [ 'cachePath' ] = rtrim ( $ path ...
Accessor for getting the cachePath for a given extension .
46,706
public function addTarget ( $ target , array $ config ) { $ ext = $ this -> getExt ( $ target ) ; $ config += [ 'files' => [ ] , 'filters' => [ ] , 'theme' => false , 'extend' => false , 'require' => [ ] , ] ; if ( ! empty ( $ config [ 'paths' ] ) ) { $ config [ 'paths' ] = array_map ( array ( $ this , '_replacePathCon...
Create a new build target .
46,707
public function theme ( $ theme = null ) { if ( $ theme === null ) { return isset ( $ this -> _data [ 'theme' ] ) ? $ this -> _data [ 'theme' ] : '' ; } $ this -> _data [ 'theme' ] = $ theme ; }
Set the active theme for building assets .
46,708
public function write ( AssetTarget $ build , $ content ) { $ ext = $ build -> ext ( ) ; $ path = $ build -> outputDir ( ) ; if ( ! is_writable ( $ path ) ) { throw new RuntimeException ( 'Cannot write cache file. Unable to write to ' . $ path ) ; } $ filename = $ this -> buildFileName ( $ build ) ; $ success = file_pu...
Writes content into a file
46,709
public function invalidate ( AssetTarget $ build ) { $ ext = $ build -> ext ( ) ; if ( empty ( $ this -> timestamp [ $ ext ] ) ) { return false ; } $ this -> _invalidated = $ build -> name ( ) ; $ this -> setTimestamp ( $ build , 0 ) ; }
Invalidate a build before re - generating the file .
46,710
public function finalize ( AssetTarget $ build ) { $ ext = $ build -> ext ( ) ; if ( empty ( $ this -> timestamp [ $ ext ] ) ) { return ; } $ data = $ this -> _readTimestamp ( ) ; $ name = $ this -> buildCacheName ( $ build ) ; if ( ! isset ( $ data [ $ name ] ) ) { return ; } $ time = $ data [ $ name ] ; unset ( $ dat...
Finalize a build after written to filesystem .
46,711
public function setTimestamp ( AssetTarget $ build , $ time ) { $ ext = $ build -> ext ( ) ; if ( empty ( $ this -> timestamp [ $ ext ] ) ) { return ; } $ data = $ this -> _readTimestamp ( ) ; $ name = $ this -> buildCacheName ( $ build ) ; $ data [ $ name ] = $ time ; $ this -> _writeTimestamp ( $ data ) ; }
Set the timestamp for a build file .
46,712
protected function _readTimestamp ( ) { $ data = array ( ) ; if ( empty ( $ data ) && file_exists ( $ this -> path . static :: BUILD_TIME_FILE ) ) { $ data = file_get_contents ( $ this -> path . static :: BUILD_TIME_FILE ) ; if ( $ data ) { $ data = unserialize ( $ data ) ; } } return $ data ; }
Read timestamps from either the fast cache or the serialized file .
46,713
protected function _writeTimestamp ( $ data ) { $ data = serialize ( $ data ) ; file_put_contents ( $ this -> path . static :: BUILD_TIME_FILE , $ data ) ; chmod ( $ this -> path . static :: BUILD_TIME_FILE , 0644 ) ; }
Write timestamps to either the fast cache or the serialized file .
46,714
public function buildFileName ( AssetTarget $ target , $ timestamp = true ) { $ file = $ target -> name ( ) ; if ( $ target -> isThemed ( ) && $ this -> theme ) { $ file = $ this -> theme . '-' . $ file ; } if ( $ timestamp ) { $ time = $ this -> getTimestamp ( $ target ) ; $ file = $ this -> _timestampFile ( $ file , ...
Get the final filename for a build . Resolves theme prefixes and timestamps .
46,715
public function buildCacheName ( $ build ) { $ name = $ this -> buildFileName ( $ build , false ) ; if ( $ build -> name ( ) == $ this -> _invalidated ) { return '~' . $ name ; } return $ name ; }
Get the cache name a build .
46,716
public function clearTimestamps ( ) { $ path = $ this -> path . static :: BUILD_TIME_FILE ; if ( file_exists ( $ path ) ) { unlink ( $ this -> path . static :: BUILD_TIME_FILE ) ; } }
Clear timestamps for assets .
46,717
protected function _timestampFile ( $ file , $ time ) { if ( ! $ time ) { return $ file ; } $ pos = strrpos ( $ file , '.' ) ; $ name = substr ( $ file , 0 , $ pos ) ; $ ext = substr ( $ file , $ pos ) ; return $ name . '.v' . $ time . $ ext ; }
Modify a file name and append in the timestamp
46,718
protected function _generateTree ( $ path ) { $ paths = glob ( $ path , GLOB_ONLYDIR ) ; if ( ! $ paths ) { $ paths = array ( ) ; } array_unshift ( $ paths , dirname ( $ path ) ) ; return $ paths ; }
Discover all the sub directories for a given path .
46,719
public function find ( $ file ) { $ found = false ; $ expanded = $ this -> _expandPrefix ( $ file ) ; if ( file_exists ( $ expanded ) ) { return $ expanded ; } foreach ( $ this -> _paths as $ path ) { $ file = $ this -> _normalizePath ( $ file , DIRECTORY_SEPARATOR ) ; $ fullPath = $ path . $ file ; if ( file_exists ( ...
Find a file in the connected paths and check for its existance .
46,720
public function getDelete ( Page $ page ) { $ this -> authorize ( 'delete' , $ page ) ; return view ( $ this -> viewPrefix . '.delete' , [ 'children' => $ page -> countChildren ( ) , 'page' => $ page , ] ) ; }
Show the delete page confirmation .
46,721
public function getHistory ( Page $ page ) { $ this -> authorize ( 'edit' , $ page ) ; return view ( "$this->viewPrefix.history" , [ 'versions' => PageVersionFacade :: history ( $ page ) , 'page' => $ page , 'diff' => new Diff ( ) , ] ) ; }
Show the page version history .
46,722
public function postAdmin ( Request $ request , Page $ page ) { $ this -> authorize ( 'editAdmin' , $ page ) ; $ page -> setInternalName ( $ request -> input ( 'internal_name' ) ) -> setAddPageBehaviour ( $ request -> input ( 'add_behaviour' ) ) -> setChildAddPageBehaviour ( $ request -> input ( 'child_add_behaviour' )...
Save the page admin settings .
46,723
public function postChildren ( Request $ request , Page $ page ) { $ this -> authorize ( 'editChildrenBasic' , $ page ) ; $ post = $ request -> input ( ) ; $ page -> setChildTemplateId ( $ request -> input ( 'children_template_id' ) ) ; if ( Gate :: allows ( 'editChildrenAdvanced' , $ page ) ) { $ page -> setChildrenUr...
Save the child page settings .
46,724
public function postFeature ( Request $ request , Page $ page ) { $ this -> authorize ( 'editFeature' , $ page ) ; $ page -> setFeatureImageId ( $ request -> input ( 'feature_image_id' ) ) ; PageFacade :: save ( $ page ) ; }
Save the page feature image .
46,725
public function postNavigation ( Request $ request , Page $ page ) { $ this -> authorize ( 'editNavBasic' , $ page ) ; if ( Gate :: allows ( 'editNavAdvanced' , $ page ) ) { $ parent = Page :: find ( $ request -> input ( 'parent_id' ) ) ; if ( $ parent ) { $ page -> setParent ( $ parent ) ; } } $ page -> setVisibleInNa...
Save the page navigation settings .
46,726
public function postSortChildren ( Request $ request , Page $ page ) { $ this -> authorize ( 'editChildrenBasic' , $ page ) ; Bus :: dispatch ( new ReorderChildPages ( $ page , $ request -> input ( 'sequences' ) ) ) ; }
Save the order of child pages .
46,727
public function postVisibility ( Request $ request , Page $ page ) { $ this -> authorize ( 'publish' , $ page ) ; $ wasVisible = $ page -> isVisible ( ) ; $ page -> setVisibleAtAnyTime ( $ request -> input ( 'visible' ) ) ; if ( $ page -> isVisibleAtAnyTime ( ) ) { if ( $ request -> has ( 'visible_from' ) ) { $ page ->...
Save the page visibility settings .
46,728
protected function _replace ( $ matches ) { $ file = $ this -> _currentFile ; if ( $ matches [ 1 ] === '"' ) { $ file = $ this -> _findFile ( $ matches [ 2 ] , dirname ( $ file ) . DIRECTORY_SEPARATOR ) ; } else { $ file = $ this -> _findFile ( $ matches [ 2 ] ) ; } if ( isset ( $ this -> _loaded [ $ file ] ) ) { retur...
Performs the replacements and inlines dependencies .
46,729
public function addVersion ( array $ attrs = [ ] ) : PageVersionInterface { if ( $ oldVersion = $ this -> getCurrentVersion ( ) ) { $ attrs += $ oldVersion -> toArray ( ) ; } unset ( $ attrs [ PageVersion :: ATTR_CHUNK_TYPE ] ) ; unset ( $ attrs [ PageVersion :: ATTR_CHUNK_ID ] ) ; unset ( $ attrs [ PageVersion :: ATTR...
Adds a new version to the page .
46,730
public function getDefaultChildTemplateId ( ) : int { if ( ! empty ( $ this -> { self :: ATTR_CHILD_TEMPLATE } ) ) { return ( int ) $ this -> { self :: ATTR_CHILD_TEMPLATE } ; } $ parent = $ this -> getParent ( ) ; return ( $ parent && ! empty ( $ parent -> getGrandchildTemplateId ( ) ) ) ? $ parent -> getGrandchildTem...
Returns the default template ID that child pages should use .
46,731
public function getDefaultGrandchildTemplateId ( ) : int { $ grandchildTemplateId = $ this -> getGrandchildTemplateId ( ) ; return empty ( $ grandchildTemplateId ) ? $ this -> getTemplateId ( ) : ( int ) $ grandchildTemplateId ; }
If a default grandchild template ID is set then that is returned .
46,732
public function getVisibleTo ( ) { return empty ( $ this -> { self :: ATTR_VISIBLE_TO } ) ? null : new DateTime ( '@' . $ this -> { self :: ATTR_VISIBLE_TO } ) ; }
Returns the visible to date or null if none is set .
46,733
public function setEmbargoTime ( DateTime $ time ) : PageInterface { $ this -> addVersion ( [ PageVersion :: ATTR_PENDING_APPROVAL => false , PageVersion :: ATTR_EMBARGOED_UNTIL => $ time -> getTimestamp ( ) , ] ) ; return $ this ; }
Set an embargo time for any unpublished changes .
46,734
public function url ( ) { if ( $ this -> { self :: ATTR_PRIMARY_URI } === null ) { return ; } if ( $ this -> primaryUrl === null ) { $ this -> primaryUrl = new URL ( [ 'page' => $ this , 'location' => $ this -> { self :: ATTR_PRIMARY_URI } , 'is_primary' => true , ] ) ; } return $ this -> primaryUrl ; }
Returns the URL object for the page s primary URI .
46,735
public function scopeCurrentVersion ( Builder $ query ) { $ subquery = $ this -> getCurrentVersionQuery ( ) ; return $ query -> select ( 'version.*' ) -> addSelect ( 'version.id as version:id' ) -> addSelect ( 'version.created_at as version:created_at' ) -> addSelect ( 'version.created_by as version:created_by' ) -> ad...
Scope for getting pages with the current version .
46,736
public static function fromTitle ( $ base , $ title ) { $ url = static :: sanitise ( $ title ) ; if ( $ base && substr ( $ base , - 1 ) != '/' ) { $ base = $ base . '/' ; } $ url = ( $ base == '/' ) ? $ url : $ base . $ url ; return static :: makeUnique ( $ url ) ; }
Generate a unique URL from a page title .
46,737
public static function getInternalPath ( $ url ) { $ path = parse_url ( $ url , PHP_URL_PATH ) ; return ( $ path === '/' ) ? $ path : ltrim ( $ path , '/' ) ; }
Returns a path which can be used to query the database of internal URLs .
46,738
public static function isInternal ( $ url ) { $ relative = static :: makeRelative ( $ url ) ; if ( substr ( $ relative , 0 , 1 ) !== '/' ) { return false ; } $ path = static :: getInternalPath ( $ relative ) ; return ! URLFacade :: isAvailable ( $ path ) ; }
Determine whether a path is valid internal path .
46,739
public static function sanitise ( $ url ) { $ url = trim ( $ url ) ; $ url = strtolower ( $ url ) ; $ url = parse_url ( $ url , PHP_URL_PATH ) ; $ url = preg_replace ( '|/+|' , '/' , $ url ) ; if ( $ url !== '/' ) { $ url = trim ( $ url , '/' ) ; } $ url = preg_replace ( '|[^' . preg_quote ( '-' ) . '\/\pL\pN\s]+|u' , ...
Remove invalid characters from a URL .
46,740
protected function getDefaultParameters ( ) : array { $ trace = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS ) ; $ last = end ( $ trace ) ; $ debugMode = static :: detectDebugMode ( ) ; return [ 'appDir' => isset ( $ trace [ 2 ] [ 'file' ] ) ? dirname ( $ trace [ 2 ] [ 'file' ] ) : null , 'wwwDir' => isset ( $ last [ ...
Collect default parameters
46,741
protected function _replace ( $ matches ) { $ required = empty ( $ matches [ 2 ] ) ? $ matches [ 4 ] : $ matches [ 2 ] ; $ filename = $ this -> scanner ( ) -> find ( $ required ) ; if ( ! $ filename ) { throw new RuntimeException ( sprintf ( 'Could not find dependency "%s"' , $ required ) ) ; } if ( empty ( $ this -> _...
Does file replacements .
46,742
public function attributes ( ) { return [ $ this -> attributePrefix . 'address' => ( int ) $ this -> address , $ this -> attributePrefix . 'title' => ( int ) $ this -> title , ] ; }
Returns the array of chunk attributes .
46,743
public function show ( ) { return View :: make ( $ this -> viewPrefix . "location.$this->template" , [ 'lat' => $ this -> getLat ( ) , 'lng' => $ this -> getLng ( ) , 'address' => $ this -> getAddress ( ) , 'title' => $ this -> getTitle ( ) , 'postcode' => $ this -> getPostcode ( ) , 'location' => $ this -> getLocation...
Show a chunk where the target is set .
46,744
public function editSuperuser ( Person $ user , Person $ editing ) { return $ user -> isSuperUser ( ) && ! $ user -> is ( $ editing ) ; }
Whether a user can edit the superuser status of another .
46,745
public function run ( $ input = null ) { $ descriptorSpec = array ( 0 => array ( 'pipe' , 'r' ) , 1 => array ( 'pipe' , 'w' ) , 2 => array ( 'pipe' , 'w' ) ) ; $ process = proc_open ( $ this -> _command , $ descriptorSpec , $ pipes , null , $ this -> _env ) ; if ( is_resource ( $ process ) ) { fwrite ( $ pipes [ 0 ] , ...
Run the command and capture the output as the return .
46,746
protected function _generateScript ( $ file , $ filename , $ input ) { $ id = str_replace ( $ this -> _settings [ 'ext' ] , '' , basename ( $ filename ) ) ; $ filepath = str_replace ( $ this -> _settings [ 'ext' ] , '' , $ filename ) ; foreach ( $ this -> _settings [ 'paths' ] as $ path ) { $ path = rtrim ( $ path , '/...
Generates the javascript passed into node to precompile the the mustache template .
46,747
public function getThumbnail ( ) : Imagick { $ image = new Imagick ( $ this -> file -> getPathname ( ) . '[0]' ) ; $ image -> setImageFormat ( 'png' ) ; return $ image ; }
Generates a thumbnail for the PDF from the first page of the document .
46,748
public function readMetadata ( ) : array { try { $ parser = new Parser ( ) ; $ pdf = $ parser -> parseFile ( $ this -> file -> getPathname ( ) ) ; return $ pdf -> getDetails ( ) ; } catch ( Exception $ e ) { return [ ] ; } }
Extracts metadata from a PDF .
46,749
protected function getRootDefinition ( TreeBuilder $ treeBuilder ) : ArrayNodeDefinition { $ rootNode = $ treeBuilder -> root ( 'root' ) ; $ rootNode -> ignoreExtraKeys ( false ) ; $ rootNode -> children ( ) -> append ( $ this -> getParametersDefinition ( ) ) ; return $ rootNode ; }
Root definition to be overridden in special cases
46,750
public function input ( $ file , $ content ) { foreach ( $ this -> filters as $ filter ) { $ content = $ filter -> input ( $ file , $ content ) ; } return $ content ; }
Apply all the input filters in sequence to the file and content .
46,751
public function output ( $ target , $ content ) { foreach ( $ this -> filters as $ filter ) { $ content = $ filter -> output ( $ target , $ content ) ; } return $ content ; }
Apply all the output filters in sequence to the file and content .
46,752
public function getAsset ( ) { if ( $ this -> asset === null ) { $ this -> asset = AssetFacade :: find ( $ this -> getAssetId ( ) ) ; } return $ this -> asset ; }
Returns the associated asset .
46,753
public function getLink ( ) { if ( $ this -> link === null && isset ( $ this -> attrs [ 'url' ] ) ) { $ this -> link = LinkObject :: factory ( $ this -> attrs [ 'url' ] ) ; } return $ this -> link ; }
Returns a LinkObject for the associated link .
46,754
public function config ( ) { if ( ! $ this -> config ) { $ config = new AssetConfig ( ) ; $ config -> load ( $ this -> cli -> arguments -> get ( 'config' ) ) ; $ this -> config = $ config ; } return $ this -> config ; }
Get the injected config or build a config object from the CLI option .
46,755
public function main ( $ argv ) { $ this -> addArguments ( ) ; try { $ this -> cli -> arguments -> parse ( $ argv ) ; } catch ( \ Exception $ e ) { $ this -> cli -> usage ( ) ; return 0 ; } if ( $ this -> cli -> arguments -> get ( 'help' ) ) { $ this -> cli -> usage ( ) ; return 0 ; } return $ this -> execute ( ) ; }
Execute the task given a set of CLI arguments .
46,756
public function verbose ( $ text , $ short = '' ) { if ( ! $ this -> cli -> arguments -> defined ( 'verbose' ) ) { if ( strlen ( $ short ) ) { $ this -> cli -> inline ( $ short ) ; } return ; } $ this -> cli -> out ( $ text ) ; }
Output verbose information .
46,757
protected function bootstrapApp ( ) { $ files = explode ( ',' , $ this -> cli -> arguments -> get ( 'bootstrap' ) ) ; foreach ( $ files as $ file ) { require_once $ file ; } }
Include any additional bootstrap files an application might need to create its environment of constants .
46,758
public function readMetadata ( ) : array { try { $ ffprobe = FFProbe :: create ( ) ; return $ ffprobe -> format ( $ this -> file -> getPathname ( ) ) -> all ( ) ; } catch ( ExecutableNotFoundException $ e ) { return [ ] ; } }
Extracts metadata via FFProbe .
46,759
public static function parseParameters ( array $ variables , string $ prefix ) : array { $ map = function ( & $ array , array $ keys , $ value ) use ( & $ map ) { if ( count ( $ keys ) <= 0 ) return $ value ; $ key = array_shift ( $ keys ) ; if ( ! is_array ( $ array ) ) { throw new InvalidStateException ( sprintf ( 'I...
Parse given parameters with custom prefix
46,760
public static function parseAllEnvironmentParameters ( ) : array { $ parameters = [ ] ; foreach ( $ _SERVER as $ key => $ value ) { $ value = getenv ( $ key ) ; if ( $ value !== false ) { $ parameters [ $ key ] = $ value ; } } return $ parameters ; }
Parse all environment variables
46,761
public function append ( AssetTarget $ target ) { $ name = $ target -> name ( ) ; $ this -> indexed [ $ name ] = $ target ; $ this -> items [ ] = $ name ; }
Append an asset to the collection .
46,762
public function get ( $ name ) { if ( ! isset ( $ this -> indexed [ $ name ] ) ) { return null ; } if ( empty ( $ this -> indexed [ $ name ] ) ) { $ this -> indexed [ $ name ] = $ this -> factory -> target ( $ name ) ; } return $ this -> indexed [ $ name ] ; }
Get an asset from the collection
46,763
public function remove ( $ name ) { if ( ! isset ( $ this -> indexed [ $ name ] ) ) { return ; } unset ( $ this -> indexed [ $ name ] ) ; foreach ( $ this -> items as $ i => $ v ) { if ( $ v === $ name ) { unset ( $ this -> items [ $ i ] ) ; } } }
Remove an asset from the collection
46,764
public function create ( File $ file ) : FileInfoDriver { $ driver = $ this -> getDriver ( $ file -> getMimeType ( ) ) ; $ className = __NAMESPACE__ . '\Drivers\\' . $ driver ; return new $ className ( $ file ) ; }
Factory method for retrieving a FileInfo object .
46,765
public function getDriver ( string $ mimetype ) { foreach ( $ this -> byMimetype as $ match => $ driver ) { if ( $ mimetype === $ match ) { return $ driver ; } } foreach ( $ this -> byMimeStart as $ match => $ driver ) { if ( strpos ( $ mimetype , $ match ) === 0 ) { return $ driver ; } } return 'DefaultDriver' ; }
Determines which driver to use for a given mimetype .
46,766
public function view ( Person $ person , Page $ page ) { if ( ! $ page -> aclEnabled ( ) ) { return true ; } if ( $ page -> wasCreatedBy ( $ person ) || $ this -> managesPages ( ) ) { return true ; } $ aclGroupIds = $ page -> getAclGroupIds ( ) ; if ( count ( $ aclGroupIds ) === 0 ) { return true ; } $ groups = $ perso...
Whether the page can be viewed .
46,767
public function collection ( AssetTarget $ target ) { $ filters = [ ] ; foreach ( $ target -> filterNames ( ) as $ name ) { $ filter = $ this -> get ( $ name ) ; if ( $ filter === null ) { throw new RuntimeException ( "Filter '$name' was not loaded/configured." ) ; } $ copy = clone $ filter ; $ copy -> settings ( [ 'ta...
Get a filter collection for a specific target .
46,768
public function fire ( ) { $ themes = $ this -> manager -> findAndInstallThemes ( ) ; foreach ( $ themes as $ theme ) { $ directories = [ $ theme -> getPublicDirectory ( ) => public_path ( 'vendor/boomcms/themes/' . $ theme -> getName ( ) ) , $ theme -> getMigrationsDirectory ( ) => base_path ( 'migrations/boomcms' ) ,...
Publishes migrations and public files for all themes to their respective directories .
46,769
public function input ( $ filename , $ input ) { if ( substr ( $ filename , strlen ( $ this -> _settings [ 'ext' ] ) * - 1 ) !== $ this -> _settings [ 'ext' ] ) { return $ input ; } if ( ! class_exists ( 'Leafo\\ScssPhp\\Compiler' ) ) { throw new \ Exception ( sprintf ( 'Cannot not load filter class "%s".' , 'Leafo\\Sc...
Runs scssc against any files that match the configured extension .
46,770
public function findAndInstallThemes ( ) : array { $ theme = new Theme ( ) ; $ directories = $ this -> filesystem -> directories ( $ theme -> getThemesDirectory ( ) ) ; $ themes = [ ] ; if ( is_array ( $ directories ) ) { foreach ( $ directories as $ directory ) { $ themeName = basename ( $ directory ) ; $ themes [ ] =...
Create a cache of the themes which are available on the filesystem .
46,771
public function getInstalledThemes ( ) : array { $ installed = $ this -> cache -> get ( $ this -> cacheKey ) ; if ( $ installed !== null ) { return $ installed ; } return $ this -> findAndInstallThemes ( ) ; }
Retrieves the installed themes from the cache .
46,772
public function createFromBlob ( Request $ request , Site $ site ) : array { $ this -> authorize ( 'uploadAssets' , $ site ) ; $ file = $ request -> file ( 'file' ) ; $ error = $ this -> validateFile ( $ file ) ; if ( $ error !== true ) { return [ ] ; } $ description = trans ( 'boomcms::asset.automatic-upload-descripti...
Controller for handling a single file upload from TinyMCE .
46,773
public function download ( Asset $ asset ) { return Response :: file ( AssetFacade :: path ( $ asset ) , [ 'Content-Type' => $ asset -> getMimetype ( ) , 'Content-Disposition' => 'download; filename="' . $ asset -> getOriginalFilename ( ) . '"' , ] ) ; }
Download the given asset .
46,774
public function embed ( Request $ request , Asset $ asset ) : View { $ viewPrefix = 'boomcms::assets.embed.' ; $ assetType = strtolower ( class_basename ( $ asset -> getType ( ) ) ) ; $ viewName = $ viewPrefix . $ assetType ; if ( ! view ( ) -> exists ( $ viewName ) ) { $ viewName = $ viewPrefix . 'default' ; } return ...
Returns the HTML to embed the given asset .
46,775
protected function getXmlAttrs ( ) { if ( $ this -> xmlAttrs === null ) { $ xml = simplexml_load_file ( $ this -> file -> getPathname ( ) ) ; $ this -> xmlAttrs = $ xml -> attributes ( ) ; } return $ this -> xmlAttrs ; }
Reads the SVG file and returns the XML attributes as an object .
46,776
public function output ( $ filename , $ input ) { $ env = array ( 'NODE_PATH' => $ this -> _settings [ 'node_path' ] ) ; $ tmpfile = tempnam ( sys_get_temp_dir ( ) , 'miniasset_css_compressor' ) ; $ this -> generateScript ( $ tmpfile , $ input ) ; $ cmd = $ this -> _settings [ 'node' ] . ' ' . $ tmpfile ; return $ this...
Run cleancss against the output and compress it .
46,777
protected function generateScript ( $ file , $ input ) { $ script = <<<JSvar csscompressor = require('css-compressor');var util = require('util');var source = %s;util.print(csscompressor.cssmin(source));process.exit(0);JS ; file_put_contents ( $ file , sprintf ( $ script , json_encode ( $ input ) ) ) ; }
Generates a small bit of Javascript code to invoke cleancss with .
46,778
public static function extractImports ( $ css ) { $ imports = [ ] ; preg_match_all ( static :: IMPORT_PATTERN , $ css , $ matches , PREG_SET_ORDER ) ; if ( empty ( $ matches ) ) { return $ imports ; } foreach ( $ matches as $ match ) { $ url = empty ( $ match [ 2 ] ) ? $ match [ 4 ] : $ match [ 2 ] ; $ imports [ ] = $ ...
Extract the urls in import directives .
46,779
protected function readMetadata ( ) : array { try { $ phpWord = IOFactory :: load ( $ this -> file -> getPathname ( ) ) ; $ docinfo = $ phpWord -> getDocInfo ( ) ; $ attrs = [ 'creator' => $ docinfo -> getCreator ( ) , 'created' => $ docinfo -> getCreated ( ) , 'lastModifiedBy' => $ docinfo -> getLastModifiedBy ( ) , '...
Retrieves metadata from the file and turns it into an array .
46,780
public function getTime ( ) { if ( ! $ this -> isHistory ( ) ) { return new DateTime ( 'now' ) ; } $ timestamp = $ this -> session -> get ( $ this -> timePersistenceKey , time ( ) ) ; return ( new DateTime ( ) ) -> setTimestamp ( $ timestamp ) ; }
Get the time to view pages at .
46,781
public function setTime ( DateTime $ time = null ) { $ timestamp = $ time ? $ time -> getTimestamp ( ) : null ; $ this -> session -> put ( $ this -> timePersistenceKey , $ timestamp ) ; if ( $ time ) { $ this -> setState ( static :: HISTORY ) ; } return $ this ; }
Set a time at which to view pages at .
46,782
public static function filesize ( $ bytes ) { $ precision = ( ( $ bytes % 1024 ) === 0 || $ bytes <= 1024 ) ? 0 : 1 ; $ formatter = new ByteSize \ Formatter \ Binary ( ) ; $ formatter -> setPrecision ( $ precision ) ; return $ formatter -> format ( $ bytes ) ; }
Turn a number of bytes into a human friendly filesize .
46,783
public static function nl2paragraph ( $ text ) { $ paragraphs = explode ( "\n" , $ text ) ; foreach ( $ paragraphs as & $ paragraph ) { $ paragraph = "<p>$paragraph</p>" ; } return implode ( '' , $ paragraphs ) ; }
Adds paragraph HTML tags to text treating each new line as a paragraph break .
46,784
public static function unique ( $ initial , Closure $ closure ) { $ append = 0 ; do { $ string = ( $ append > 0 ) ? ( $ initial . $ append ) : $ initial ; $ append ++ ; } while ( $ closure ( $ string ) === false ) ; return $ string ; }
Make a string unique .
46,785
public function getToolbar ( EditorObject $ editor , Request $ request ) { $ page = PageFacade :: find ( $ request -> input ( 'page_id' ) ) ; View :: share ( [ 'page' => $ page , 'editor' => $ editor , 'auth' => auth ( ) , 'person' => auth ( ) -> user ( ) , ] ) ; if ( $ editor -> isHistory ( ) ) { return view ( 'boomcm...
Displays the CMS interface with buttons for add page settings etc . Called from an iframe when logged into the CMS .
46,786
public function creating ( Model $ model ) { $ model -> created_at = time ( ) ; $ model -> created_by = $ this -> guard -> check ( ) ? $ this -> guard -> user ( ) -> getId ( ) : null ; }
Set created_at and created_by on the model prior to creation .
46,787
public function getStatus ( Page $ page ) { $ this -> authorize ( 'edit' , $ page ) ; return view ( "$this->viewPrefix.status" , [ 'page' => $ page , 'version' => $ page -> getCurrentVersion ( ) , 'auth' => auth ( ) , ] ) ; }
Show the current status of the page .
46,788
public function getTemplate ( Page $ page ) { $ this -> authorize ( 'editTemplate' , $ page ) ; return view ( "$this->viewPrefix.template" , [ 'current' => $ page -> getTemplate ( ) , 'templates' => TemplateFacade :: findValid ( ) , ] ) ; }
Show a form to change the template of the page .
46,789
public function requestApproval ( Page $ page ) { $ this -> authorize ( 'edit' , $ page ) ; $ page -> markUpdatesAsPendingApproval ( ) ; Event :: fire ( new Events \ PageApprovalRequested ( $ page , auth ( ) -> user ( ) ) ) ; return $ page -> getCurrentVersion ( ) -> getStatus ( ) ; }
Mark the page as requiring approval .
46,790
public function postEmbargo ( Request $ request , Page $ page ) { $ this -> authorize ( 'publish' , $ page ) ; $ embargoedUntil = new DateTime ( '@' . time ( ) ) ; if ( $ time = $ request -> input ( 'embargoed_until' ) ) { $ timestamp = strtotime ( $ time ) ; $ embargoedUntil -> setTimestamp ( $ timestamp ) ; } $ page ...
Set an embargo time for the current drafts .
46,791
public function postTemplate ( Page $ page , Template $ template ) { $ this -> authorize ( 'editTemplate' , $ page ) ; $ page -> setTemplate ( $ template ) ; Event :: fire ( new Events \ PageTemplateWasChanged ( $ page , $ template ) ) ; return $ page -> getCurrentVersion ( ) -> getStatus ( ) ; }
Set the template of the page .
46,792
public function postTitle ( Request $ request , Page $ page ) { $ this -> authorize ( 'edit' , $ page ) ; $ oldTitle = $ page -> getTitle ( ) ; $ page -> setTitle ( $ request -> input ( 'title' ) ) ; Event :: fire ( new Events \ PageTitleWasChanged ( $ page , $ oldTitle , $ page -> getTitle ( ) ) ) ; return [ 'status' ...
Set the title of the page .
46,793
public static function merge ( $ file ) { if ( file_exists ( $ file ) ) { $ config = c :: get ( 'boomcms' , [ ] ) ; c :: set ( 'boomcms' , array_merge_recursive ( include $ file , $ config ) ) ; } }
Recursively merges a file into the boomcms config group .
46,794
public function creating ( Model $ model ) { if ( $ model instanceof SingleSiteInterface ) { $ site = $ this -> router -> getActiveSite ( ) ? : $ this -> site -> findDefault ( ) ; $ model -> { SingleSiteInterface :: ATTR_SITE } = ( $ site ? $ site -> getId ( ) : null ) ; } }
Set the site_id of the model .
46,795
public function init ( ) { $ filename = $ this -> getDirectory ( ) . DIRECTORY_SEPARATOR . $ this -> initFilename ; if ( File :: exists ( $ filename ) ) { File :: requireOnce ( $ filename ) ; } }
Includes the theme s init file if it exists .
46,796
public function addAttributesToHtml ( $ html ) { $ html = trim ( ( string ) $ html ) ; $ attributes = array_merge ( $ this -> getRequiredAttributes ( ) , $ this -> attributes ( ) ) ; $ attributesString = Html :: attributes ( $ attributes ) ; return preg_replace ( '|<(.*?)>|' , "<$1$attributesString>" , $ html , 1 ) ; }
This adds the necessary classes to chunk HTML for them to be picked up by the JS editor . i . e . it makes chunks editable .
46,797
public function getRequiredAttributes ( ) { return [ $ this -> attributePrefix . 'chunk' => $ this -> getType ( ) , $ this -> attributePrefix . 'slot-name' => $ this -> slotname , $ this -> attributePrefix . 'slot-template' => $ this -> template , $ this -> attributePrefix . 'page' => $ this -> page -> getId ( ) , $ th...
Returns an array of HTML attributes which are required to be make the chunk editable .
46,798
public function render ( ) { try { $ html = $ this -> html ( ) ; if ( $ this -> editable === true || Editor :: isHistory ( ) ) { $ html = $ this -> addAttributesToHtml ( $ html ) ; } return empty ( $ html ) ? $ html : $ this -> before . $ html . $ this -> after ; } catch ( \ Exception $ e ) { if ( App :: environment ( ...
Attempts to get the chunk data from the cache otherwise calls _execute to generate the cache .
46,799
public function html ( ) { if ( ! $ this -> hasContent ( ) && ! $ this -> isEditable ( ) ) { return '' ; } $ content = $ this -> hasContent ( ) ? $ this -> show ( ) : $ this -> showDefault ( ) ; if ( $ content instanceof View && ! empty ( $ this -> viewParams ) ) { $ content -> with ( $ this -> viewParams ) ; } return ...
Generate the HTML to display the chunk .